page-agent-sdk 3.19.1 → 3.20.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 +4 -2
- package/README.zh-CN.md +4 -2
- package/dist/page-agent-sdk.headless.js +235 -29
- package/dist/page-agent-sdk.iife.js +143 -144
- package/dist/page-agent-sdk.js +1240 -1002
- package/dist/page-agent-sdk.umd.cjs +39 -40
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +90 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/page-agent-sdk)
|
|
10
10
|
[](https://github.com/whyymj/page-agent-sdk/blob/master/LICENSE)
|
|
11
|
-
[](#self-tests)
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -248,6 +248,8 @@ ChatDialog, MessageContent, CodePreview, SkillPanel, DebugDrawer, useChat
|
|
|
248
248
|
| `inputRows` | `number` · default `2` | Input box rows (visible height); `1` = single row; `2` = 2-row initial height, auto-expands up to max-height:100px; `>2` = taller initial height |
|
|
249
249
|
| `onClose` | `() => void` | Drawer mode close callback (default `hide`; pass to override and sync external mount state) |
|
|
250
250
|
| `theme` | `'light' \| 'dark'` · default `'dark'` | Built-in theme (dark = Ark design palette); fully customizable via `--cs-*` on an ancestor |
|
|
251
|
+
| `locale` | `'zh-CN' \| 'en-US'` · default `'zh-CN'` | **UI language**: switches the built-in dialog message pack; `formatTime` (12h/24h) and autoTitle language follow |
|
|
252
|
+
| `messages` | `Partial<DialogMessages>` | **Per-key message overrides** (priority over the locale pack): switching language and tweaking individual strings (e.g. `statusDone`) in one mechanism; missing keys fall back to the pack |
|
|
251
253
|
| `icons` | `Partial<DialogIcons>` | **Icon customization**: partial override of default emojis (`header` 🤖 / `subagent` 🤖 / `subagentProgress` 🧬 / `empty` 💬 / `focus` 🎯 / `queued` 📋 / `queuedEdit` ✏️ / `recommend` 💡 / `conflict` ⚠️; `assistantAvatar`/`userAvatar` default to built-in SVG, pass a text glyph to replace). Values: plain text (emoji/char) **or an HTML fragment** (starting with `<`, e.g. inline `<svg>`/`<img>` — sanitized via a DOMPurify icon allowlist; event attributes/dangerous protocols stripped); empty string hides the icon; unset keys keep defaults |
|
|
252
254
|
|
|
253
255
|
### Extension points
|
|
@@ -530,7 +532,7 @@ function switchTo(i: number) {
|
|
|
530
532
|
## Self-tests
|
|
531
533
|
|
|
532
534
|
```bash
|
|
533
|
-
npm test #
|
|
535
|
+
npm test # 2241 assertions (tsx, source-level; no LLM dependency)
|
|
534
536
|
npm run test:e2e # 718 integration assertions (node, built dist; covers APIs/options/modules/simple&complex scenes: default systemPrompt(capability overview) / dynamic register + inspect sync / inspect(tools/middleware/subagent/verify/mcp/todos/lastCompression/checkpoints reflect config) / custom tools/middleware/skills/memory injection / runtime dynamic reconfiguration(setTools/addTool/removeTool/setLlm/setMemory/setSubagents reflect) / switchSession(on/off) / shareContext on/off sharing/independent / storage backends + object config / presets(3) / checkpoint / exports complete(39+ fns/components) / util fns usable(isQuotaError/estimateTokens/jpEval/searchJson) / source=builtin / mount boundary / hook multi-listener / llm config / hide/show / error scenes)
|
|
535
537
|
```
|
|
536
538
|
|
package/README.zh-CN.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/page-agent-sdk)
|
|
10
10
|
[](https://github.com/whyymj/page-agent-sdk/blob/master/LICENSE)
|
|
11
|
-
[](#自测)
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -244,6 +244,8 @@ ChatDialog, MessageContent, CodePreview, SkillPanel, DebugDrawer, useChat
|
|
|
244
244
|
| `inputRows` | `number` · 默认 `2` | 输入框行数(可见高度);`1` = 单行;`2` = 2 行初始高度,自动扩展至 max-height:100px;`>2` = 更高初始高度 |
|
|
245
245
|
| `onClose` | `() => void` | 抽屉模式关闭回调(默认 `hide`;传此选项覆盖默认,便于同步外部挂载状态) |
|
|
246
246
|
| `theme` | `'light' \| 'dark'` · 默认 `'dark'` | 内置主题(dark = 方舟设计稿深色紫调);亦可祖先覆盖 `--cs-*` 完全自定义 |
|
|
247
|
+
| `locale` | `'zh-CN' \| 'en-US'` · 默认 `'zh-CN'` | **UI 语言**:切换内置对话框文案包;`formatTime`(12h/24h)与 autoTitle 标题语言跟随 |
|
|
248
|
+
| `messages` | `Partial<DialogMessages>` | **文案键级覆盖**(优先于 locale 包):换语言与改个别文案(如 `statusDone: '完成'`)一套机制;漏配键回退 locale 包 |
|
|
247
249
|
| `icons` | `Partial<DialogIcons>` | **图标自定义**:局部覆盖默认 emoji(`header` 🤖 / `subagent` 🤖 / `subagentProgress` 🧬 / `empty` 💬 / `focus` 🎯 / `queued` 📋 / `queuedEdit` ✏️ / `recommend` 💡 / `conflict` ⚠️;`assistantAvatar`/`userAvatar` 缺省 = 内置 SVG,传文本字形替换)。值为纯文本(emoji/字符)或 **HTML 片段**(以 `<` 开头,如内联 `<svg>`/`<img>`,经 DOMPurify 图标白名单净化,事件属性/危险协议剥除);空串 = 隐藏该图标;未传键用默认 |
|
|
248
250
|
|
|
249
251
|
### 扩展点
|
|
@@ -475,7 +477,7 @@ function switchTo(i: number) {
|
|
|
475
477
|
## 自测
|
|
476
478
|
|
|
477
479
|
```bash
|
|
478
|
-
npm test #
|
|
480
|
+
npm test # 2241 项断言(tsx 源码级,不依赖 LLM)
|
|
479
481
|
npm run test:e2e # 718 项集成断言(node 跑构建产物 dist;覆盖各 API/配置项/功能模块/简单与复杂场景:默认 systemPrompt(含能力概述) / 动态注册与 inspect 同步 / inspect(tools/middleware/subagent/verify/mcp/todos/lastCompression/checkpoints 反映配置) / 自定义 tools/middleware/skills/memory 注入 / 运行时动态重配置(setTools/addTool/removeTool/setLlm/setMemory/setSubagents 反映) / switchSession(开/未开) / shareContext 开/关共享独立 / storage 后端+对象配置 / presets 三预设 / checkpoint / 导出项完整(39+ 函数/组件) / 工具函数可用(isQuotaError/estimateTokens/jpEval/searchJson) / source=builtin / mount 边界 / hook 多监听器 / llm 配置 / 错误场景)
|
|
480
482
|
```
|
|
481
483
|
|
|
@@ -3780,7 +3780,8 @@ function Qa(e) {
|
|
|
3780
3780
|
let n = [
|
|
3781
3781
|
"## 当前精修目标",
|
|
3782
3782
|
t.map((e) => `· ${e.path}${e.label ? `(${e.label})` : ""}`).join("\n"),
|
|
3783
|
-
`仅操作上述 ${t.length} 个聚焦子树${t.length > 1 ? "之一" : ""},用户未指明目标的指令默认作用于聚焦组件;不要改动其他组件;${i}
|
|
3783
|
+
`仅操作上述 ${t.length} 个聚焦子树${t.length > 1 ? "之一" : ""},用户未指明目标的指令默认作用于聚焦组件;不要改动其他组件;${i}`,
|
|
3784
|
+
"read 不带路径时默认只返回聚焦子树;需要全量主数据时显式列顶层键(read({jsonPaths:[...]}) )"
|
|
3784
3785
|
], r = e.getSchema();
|
|
3785
3786
|
if (r) {
|
|
3786
3787
|
let e = t.map((e) => {
|
|
@@ -3809,6 +3810,22 @@ function Qa(e) {
|
|
|
3809
3810
|
if (!r.length) return o("(整体数据)");
|
|
3810
3811
|
for (let n of r) if (!t.some((e) => Xa(n, e.path)) && !Za(n, e.getBind?.())) return o(n);
|
|
3811
3812
|
}
|
|
3813
|
+
if (n.name === "read") {
|
|
3814
|
+
let e = n.args;
|
|
3815
|
+
if (!e?.jsonPath && !e?.jsonPaths) {
|
|
3816
|
+
let i = t.map((e) => e.path), a = await r({
|
|
3817
|
+
...n,
|
|
3818
|
+
args: {
|
|
3819
|
+
...e,
|
|
3820
|
+
jsonPaths: i
|
|
3821
|
+
}
|
|
3822
|
+
}), o = `【聚焦模式】read 未带路径 → 默认返回聚焦子树(${i.join(", ")});需要全量主数据时显式列顶层键,如 read({jsonPaths:['<顶层键1>','<顶层键2>']})\n`;
|
|
3823
|
+
return {
|
|
3824
|
+
...a,
|
|
3825
|
+
content: o + a.content
|
|
3826
|
+
};
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3812
3829
|
}
|
|
3813
3830
|
return r(n);
|
|
3814
3831
|
},
|
|
@@ -6877,17 +6894,19 @@ function nl(e) {
|
|
|
6877
6894
|
let n = $c(t) ? t : null, r = $c(t) ? null : t;
|
|
6878
6895
|
if (r && !r.apiKey) return;
|
|
6879
6896
|
let i = n;
|
|
6880
|
-
return async (
|
|
6881
|
-
let
|
|
6897
|
+
return async (t) => {
|
|
6898
|
+
let n = t.filter((e) => e.role === "user" || e.role === "assistant").map((e) => `${e.role === "user" ? "用户" : "助手"}: ${e.content}`).join("\n").slice(0, 800), s = new AbortController(), c = setTimeout(() => s.abort(), 1e4);
|
|
6882
6899
|
try {
|
|
6883
|
-
|
|
6900
|
+
!i && r && (i = await m(r, {
|
|
6884
6901
|
temperature: 0,
|
|
6885
6902
|
maxTokens: 30
|
|
6886
|
-
}))
|
|
6903
|
+
}));
|
|
6904
|
+
let t = await i.invoke([new o(e.dialog?.locale === "en-US" ? "Generate a short English title (max 10 words) summarizing the conversation below. Output the title text only, no quotes or punctuation." : "根据以下对话的主旨,生成一个简短的中文标题(不超过15个字,不要标点和引号,直接输出标题文字)。"), new a(n)], { signal: s.signal }), c = e.dialog?.locale === "en-US" ? 60 : 20;
|
|
6905
|
+
return el(t).trim().replace(/^["'""「『]|["'""」』]$/g, "").split("\n")[0].slice(0, c);
|
|
6887
6906
|
} catch {
|
|
6888
6907
|
return "";
|
|
6889
6908
|
} finally {
|
|
6890
|
-
clearTimeout(
|
|
6909
|
+
clearTimeout(c);
|
|
6891
6910
|
}
|
|
6892
6911
|
};
|
|
6893
6912
|
}
|
|
@@ -11591,12 +11610,197 @@ function Fd(e) {
|
|
|
11591
11610
|
let n = e[r];
|
|
11592
11611
|
typeof n == "string" && (t[r] = n);
|
|
11593
11612
|
}
|
|
11594
|
-
return e.assistantAvatar && (t.assistantAvatar = e.assistantAvatar), e.userAvatar && (t.userAvatar = e.userAvatar), t;
|
|
11613
|
+
return e.assistantAvatar && (t.assistantAvatar = e.assistantAvatar), e.userAvatar && (t.userAvatar = e.userAvatar), e.send && (t.send = e.send), t;
|
|
11614
|
+
}
|
|
11615
|
+
//#endregion
|
|
11616
|
+
//#region src/core/components/messages.ts
|
|
11617
|
+
var Id = {
|
|
11618
|
+
defaultTitle: "AI 助手",
|
|
11619
|
+
inputPlaceholder: "输入消息,Enter 发送...",
|
|
11620
|
+
newSession: "新建会话",
|
|
11621
|
+
history: "历史记录",
|
|
11622
|
+
more: "更多",
|
|
11623
|
+
close: "关闭",
|
|
11624
|
+
debugMenu: "调试 / 日志",
|
|
11625
|
+
debugMenuTitle: "日志 / 执行流程 / Agent 信息",
|
|
11626
|
+
skillMenu: "Skill 管理",
|
|
11627
|
+
skillMenuTitle: "创建 / 管理自定义 Skill",
|
|
11628
|
+
clearChat: "清空对话",
|
|
11629
|
+
sessionFallbackPrefix: "会话 ",
|
|
11630
|
+
justNow: "刚刚",
|
|
11631
|
+
minutesAgoSuffix: "分钟前",
|
|
11632
|
+
emptyGreeting: "有什么可以帮你的?",
|
|
11633
|
+
retry: "重试",
|
|
11634
|
+
undo: "↩ 回退",
|
|
11635
|
+
undoTitle: "回退到上次正常状态(还原对话历史 + 页面属性 + 工作区)",
|
|
11636
|
+
thinking: "思考中...",
|
|
11637
|
+
statusRunning: "执行中",
|
|
11638
|
+
statusDone: "成功",
|
|
11639
|
+
statusError: "失败",
|
|
11640
|
+
subagentBadge: "子",
|
|
11641
|
+
subagentBadgeTitle: "子 agent 委派(独立上下文,只回结论)",
|
|
11642
|
+
subagentProgress: "子 agent 进度",
|
|
11643
|
+
nthCallPrefix: "第 ",
|
|
11644
|
+
nthCallSuffix: " 次",
|
|
11645
|
+
argsLabel: "入参",
|
|
11646
|
+
resultLabel: "返回值",
|
|
11647
|
+
copy: "复制",
|
|
11648
|
+
copied: "已复制",
|
|
11649
|
+
regenerate: "重新生成",
|
|
11650
|
+
expand: "展开",
|
|
11651
|
+
collapse: "收起",
|
|
11652
|
+
noResult: "(无返回值)",
|
|
11653
|
+
displayTruncatedSuffix: "\n…(展示截断,复制可得全量)",
|
|
11654
|
+
thinkingCountPrefix: "思考中… ",
|
|
11655
|
+
charCountSuffix: "字",
|
|
11656
|
+
reasoningTitle: "思考过程",
|
|
11657
|
+
truncatedNotePrefix: "(仅显最近 ",
|
|
11658
|
+
truncatedNoteSuffix: " 字)",
|
|
11659
|
+
copyThinking: "复制完整思考内容",
|
|
11660
|
+
copyThinkingTruncTitle: "复制完整思考(渲染已截尾,复制取全量)",
|
|
11661
|
+
focusChipTitlePrefix: "精修中:",
|
|
11662
|
+
focusChipTitleHint: "(点击回看 · ✕ 移除)",
|
|
11663
|
+
historyFocusChipTitlePrefix: "回看 ",
|
|
11664
|
+
removeFocus: "移除此焦点",
|
|
11665
|
+
sendHint: "Enter 发送 · Shift+Enter 换行",
|
|
11666
|
+
sendTitle: "发送",
|
|
11667
|
+
stopTitle: "停止生成",
|
|
11668
|
+
queuedTitle: "排队中 · 生成完后自动执行",
|
|
11669
|
+
queuedEditTitle: "修改(填回输入框编辑)",
|
|
11670
|
+
removeQueuedTitle: "撤销该任务",
|
|
11671
|
+
humanConfirmTitle: "AI 需要你确认",
|
|
11672
|
+
recommendPrefix: " 推荐:",
|
|
11673
|
+
approve: "允许",
|
|
11674
|
+
deny: "拒绝",
|
|
11675
|
+
toolConfirmPrefix: "需确认工具调用:",
|
|
11676
|
+
viewArgs: "查看参数",
|
|
11677
|
+
collapseArgs: "收起参数",
|
|
11678
|
+
argsTruncatedSuffix: "\n…(已截断)",
|
|
11679
|
+
conflictTitlePrefix: "写入冲突:",
|
|
11680
|
+
conflictTitleSuffix: " 已被外部修改",
|
|
11681
|
+
conflictDetailTemplate: "AI 基于「读取时的旧值」准备{op},但该属性在你读取之后被外部代码/其他 agent/手动改过。",
|
|
11682
|
+
conflictOpWrite: "写入",
|
|
11683
|
+
conflictOpDelete: "删除",
|
|
11684
|
+
viewDiff: "查看值对比",
|
|
11685
|
+
collapseDiff: "收起对比",
|
|
11686
|
+
agentValueLabel: "AI 想写的值",
|
|
11687
|
+
currentValueLabel: "外部改后的当前值",
|
|
11688
|
+
deleteNoValue: "(delete 操作无值)",
|
|
11689
|
+
keepExternal: "保留外部",
|
|
11690
|
+
keepExternalTitle: "不写入,保留外部修改后的值,AI 重新读取再改",
|
|
11691
|
+
overwrite: "强制覆盖",
|
|
11692
|
+
overwriteTitle: "用 AI 的值覆盖外部修改",
|
|
11693
|
+
restore: "回退",
|
|
11694
|
+
restoreTitle: "回退到最近一次历史快照(agent 之前操作的检查点),撤销外部修改 + AI 不写入",
|
|
11695
|
+
switchFocusTitle: "切换聚焦路径",
|
|
11696
|
+
exitFocusTitle: "退出精修",
|
|
11697
|
+
focusPathPlaceholder: "jsonPath,如 components.3",
|
|
11698
|
+
focusLabelPlaceholder: "标签(可选)",
|
|
11699
|
+
focusSubmit: "聚焦"
|
|
11700
|
+
}, Ld = {
|
|
11701
|
+
"zh-CN": Id,
|
|
11702
|
+
"en-US": {
|
|
11703
|
+
defaultTitle: "AI Assistant",
|
|
11704
|
+
inputPlaceholder: "Type a message, Enter to send...",
|
|
11705
|
+
newSession: "New chat",
|
|
11706
|
+
history: "History",
|
|
11707
|
+
more: "More",
|
|
11708
|
+
close: "Close",
|
|
11709
|
+
debugMenu: "Debug / Logs",
|
|
11710
|
+
debugMenuTitle: "Logs / execution flow / agent info",
|
|
11711
|
+
skillMenu: "Skills",
|
|
11712
|
+
skillMenuTitle: "Create / manage custom skills",
|
|
11713
|
+
clearChat: "Clear conversation",
|
|
11714
|
+
sessionFallbackPrefix: "Session ",
|
|
11715
|
+
justNow: "just now",
|
|
11716
|
+
minutesAgoSuffix: " min ago",
|
|
11717
|
+
emptyGreeting: "How can I help you?",
|
|
11718
|
+
retry: "Retry",
|
|
11719
|
+
undo: "↩ Undo",
|
|
11720
|
+
undoTitle: "Restore the last good state (conversation + page data + workspace)",
|
|
11721
|
+
thinking: "Thinking...",
|
|
11722
|
+
statusRunning: "Running",
|
|
11723
|
+
statusDone: "Success",
|
|
11724
|
+
statusError: "Failed",
|
|
11725
|
+
subagentBadge: "sub",
|
|
11726
|
+
subagentBadgeTitle: "Sub-agent delegation (isolated context, conclusion only)",
|
|
11727
|
+
subagentProgress: "Sub-agent progress",
|
|
11728
|
+
nthCallPrefix: "Call #",
|
|
11729
|
+
nthCallSuffix: "",
|
|
11730
|
+
argsLabel: "Args",
|
|
11731
|
+
resultLabel: "Result",
|
|
11732
|
+
copy: "Copy",
|
|
11733
|
+
copied: "Copied",
|
|
11734
|
+
regenerate: "Regenerate",
|
|
11735
|
+
expand: "Expand",
|
|
11736
|
+
collapse: "Collapse",
|
|
11737
|
+
noResult: "(no result)",
|
|
11738
|
+
displayTruncatedSuffix: "\n…(truncated for display, copy for full)",
|
|
11739
|
+
thinkingCountPrefix: "Thinking… ",
|
|
11740
|
+
charCountSuffix: " chars",
|
|
11741
|
+
reasoningTitle: "Reasoning",
|
|
11742
|
+
truncatedNotePrefix: "(last ",
|
|
11743
|
+
truncatedNoteSuffix: " chars only)",
|
|
11744
|
+
copyThinking: "Copy full reasoning",
|
|
11745
|
+
copyThinkingTruncTitle: "Copy full reasoning (display truncated, copy gets all)",
|
|
11746
|
+
focusChipTitlePrefix: "Focus:",
|
|
11747
|
+
focusChipTitleHint: "(click to view · ✕ remove)",
|
|
11748
|
+
historyFocusChipTitlePrefix: "View ",
|
|
11749
|
+
removeFocus: "Remove this focus",
|
|
11750
|
+
sendHint: "Enter to send · Shift+Enter for newline",
|
|
11751
|
+
sendTitle: "Send",
|
|
11752
|
+
stopTitle: "Stop generating",
|
|
11753
|
+
queuedTitle: "Queued · runs when current finishes",
|
|
11754
|
+
queuedEditTitle: "Edit (fill back into input)",
|
|
11755
|
+
removeQueuedTitle: "Drop this task",
|
|
11756
|
+
humanConfirmTitle: "AI needs your confirmation",
|
|
11757
|
+
recommendPrefix: " Recommend:",
|
|
11758
|
+
approve: "Allow",
|
|
11759
|
+
deny: "Deny",
|
|
11760
|
+
toolConfirmPrefix: "Confirm tool call:",
|
|
11761
|
+
viewArgs: "View args",
|
|
11762
|
+
collapseArgs: "Collapse args",
|
|
11763
|
+
argsTruncatedSuffix: "\n…(truncated)",
|
|
11764
|
+
conflictTitlePrefix: "Write conflict:",
|
|
11765
|
+
conflictTitleSuffix: " was modified externally",
|
|
11766
|
+
conflictDetailTemplate: "The AI prepared to {op} based on the stale value it read, but the property was changed afterwards by external code / another agent / manual edit.",
|
|
11767
|
+
conflictOpWrite: "write",
|
|
11768
|
+
conflictOpDelete: "delete",
|
|
11769
|
+
viewDiff: "View diff",
|
|
11770
|
+
collapseDiff: "Collapse diff",
|
|
11771
|
+
agentValueLabel: "Value AI wants to write",
|
|
11772
|
+
currentValueLabel: "Current value (external)",
|
|
11773
|
+
deleteNoValue: "(delete op has no value)",
|
|
11774
|
+
keepExternal: "Keep external",
|
|
11775
|
+
keepExternalTitle: "Skip the write, keep the external value; AI re-reads then retries",
|
|
11776
|
+
overwrite: "Overwrite",
|
|
11777
|
+
overwriteTitle: "Overwrite external changes with the AI value",
|
|
11778
|
+
restore: "Restore",
|
|
11779
|
+
restoreTitle: "Restore the latest snapshot (checkpoint before the agent op); undo external change, AI does not write",
|
|
11780
|
+
switchFocusTitle: "Switch focus path",
|
|
11781
|
+
exitFocusTitle: "Exit focus",
|
|
11782
|
+
focusPathPlaceholder: "jsonPath, e.g. components.3",
|
|
11783
|
+
focusLabelPlaceholder: "Label (optional)",
|
|
11784
|
+
focusSubmit: "Focus"
|
|
11785
|
+
}
|
|
11786
|
+
};
|
|
11787
|
+
function Rd(e = "zh-CN", t) {
|
|
11788
|
+
let n = {
|
|
11789
|
+
...Id,
|
|
11790
|
+
...Ld[e]
|
|
11791
|
+
};
|
|
11792
|
+
if (!t) return n;
|
|
11793
|
+
let r = { ...n };
|
|
11794
|
+
for (let e of Object.keys(n)) {
|
|
11795
|
+
let n = t[e];
|
|
11796
|
+
typeof n == "string" && (r[e] = n);
|
|
11797
|
+
}
|
|
11798
|
+
return r;
|
|
11595
11799
|
}
|
|
11596
11800
|
//#endregion
|
|
11597
11801
|
//#region src/core/composables/chatContext.ts
|
|
11598
|
-
var
|
|
11599
|
-
function
|
|
11802
|
+
var zd = Symbol("chatContext");
|
|
11803
|
+
function Bd(e = {}) {
|
|
11600
11804
|
let t = Nd({
|
|
11601
11805
|
fetchResponse: e.fetchResponse,
|
|
11602
11806
|
fetchStream: e.fetchStream,
|
|
@@ -11630,7 +11834,7 @@ function Ld(e = {}) {
|
|
|
11630
11834
|
};
|
|
11631
11835
|
}), x = Wr(() => (n.messages.length, typeof e.canUndo == "function" && !!e.canUndo())), S = () => {
|
|
11632
11836
|
e.onUndo?.() && (n.error = null);
|
|
11633
|
-
}, C = (e) => new Date(e).toLocaleTimeString(
|
|
11837
|
+
}, C = (e) => new Date(e).toLocaleTimeString(te, {
|
|
11634
11838
|
hour: "2-digit",
|
|
11635
11839
|
minute: "2-digit"
|
|
11636
11840
|
}), w = () => {
|
|
@@ -11644,7 +11848,16 @@ function Ld(e = {}) {
|
|
|
11644
11848
|
if (!r || r.role !== "assistant") return !1;
|
|
11645
11849
|
let i = "reasoning" in r ? r.reasoning : void 0;
|
|
11646
11850
|
return n.loading && e === t.length - 1 && !r.content && !i;
|
|
11647
|
-
}, O = Wr(() => (e.infoTick?.value, e.getFocuses?.() ?? []))
|
|
11851
|
+
}, O = Wr(() => (e.infoTick?.value, e.getFocuses?.() ?? [])), k = (t) => e.onAddFocus ? e.onAddFocus(t) : {
|
|
11852
|
+
ok: !1,
|
|
11853
|
+
error: "focus 未启用"
|
|
11854
|
+
}, A = (t) => {
|
|
11855
|
+
e.onRemoveFocus?.(t);
|
|
11856
|
+
}, ee = () => {
|
|
11857
|
+
e.onClearFocus?.();
|
|
11858
|
+
}, j = (t) => {
|
|
11859
|
+
e.onFocusChipClick?.(t);
|
|
11860
|
+
}, M = Fd(e.icons), te = e.locale ?? "zh-CN";
|
|
11648
11861
|
return {
|
|
11649
11862
|
chat: t,
|
|
11650
11863
|
inputText: o,
|
|
@@ -11670,31 +11883,24 @@ function Ld(e = {}) {
|
|
|
11670
11883
|
editQueued: E,
|
|
11671
11884
|
isPendingAssistant: D,
|
|
11672
11885
|
focuses: O,
|
|
11673
|
-
addFocus:
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
clearFocus: () => {
|
|
11681
|
-
e.onClearFocus?.();
|
|
11682
|
-
},
|
|
11683
|
-
focusChipClick: (t) => {
|
|
11684
|
-
e.onFocusChipClick?.(t);
|
|
11685
|
-
},
|
|
11686
|
-
icons: Fd(e.icons)
|
|
11886
|
+
addFocus: k,
|
|
11887
|
+
removeFocus: A,
|
|
11888
|
+
clearFocus: ee,
|
|
11889
|
+
focusChipClick: j,
|
|
11890
|
+
icons: M,
|
|
11891
|
+
locale: te,
|
|
11892
|
+
messages: Rd(te, e.dialogMessages)
|
|
11687
11893
|
};
|
|
11688
11894
|
}
|
|
11689
|
-
function
|
|
11690
|
-
let e = Rn(
|
|
11895
|
+
function Vd() {
|
|
11896
|
+
let e = Rn(zd);
|
|
11691
11897
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
11692
11898
|
return e;
|
|
11693
11899
|
}
|
|
11694
11900
|
//#endregion
|
|
11695
11901
|
//#region src/core/index.headless.ts
|
|
11696
|
-
function
|
|
11902
|
+
function Hd(e) {
|
|
11697
11903
|
return wd(e);
|
|
11698
11904
|
}
|
|
11699
11905
|
//#endregion
|
|
11700
|
-
export { Ll as CAPABILITIES, Bl as CONTEXT_PRESETS, Zc as CompressDecisionSchema, is as DEFAULT_PROMPT_SOFT_CAP, nc as DEFAULT_SYSTEM_PROMPT, vc as HTML_VOID_TAGS, Ao as HUMAN_CONFIRM_TOOL_NAME, ai as MIN_CONTEXT_WINDOW, rs as SOFT_CAP_MIN_WINDOW, Zo as STOP_WORDS, Aa as UNSAFE_KEYS, $u as actionsToInspectInfo, Qu as actionsToTools, Qr as agentError, Ys as analyzeContext, Ba as applyPatchToClone, Ua as applyPatchToLive, Zr as asAgentError, rc as buildDataPrompt, ic as buildSystemPrompt,
|
|
11906
|
+
export { Ll as CAPABILITIES, Bl as CONTEXT_PRESETS, Zc as CompressDecisionSchema, is as DEFAULT_PROMPT_SOFT_CAP, nc as DEFAULT_SYSTEM_PROMPT, vc as HTML_VOID_TAGS, Ao as HUMAN_CONFIRM_TOOL_NAME, ai as MIN_CONTEXT_WINDOW, rs as SOFT_CAP_MIN_WINDOW, Zo as STOP_WORDS, Aa as UNSAFE_KEYS, $u as actionsToInspectInfo, Qu as actionsToTools, Qr as agentError, Ys as analyzeContext, Ba as applyPatchToClone, Ua as applyPatchToLive, Zr as asAgentError, rc as buildDataPrompt, ic as buildSystemPrompt, zd as chatContextKey, Eu as commitSetToBind, tc as connectMcp, m as constructLlmFromConfig, p as constructOpenLlmSync, jd as copyText, Wi as createAgent, ko as createApprovalMiddleware, Bd as createChatContext, Hd as createChatSdk, Bo as createCheckpointManager, Vo as createCheckpointMiddleware, ll as createConflictManager, Xs as createContextInspectorMiddleware, Pu as createDataOps, Wc as createHtmlFormatCheck, qc as createHtmlSubagent, No as createHumanConfirmMiddleware, Mo as createHumanConfirmTool, Al as createMemoryBackend, So as createMemoryMiddleware, u as createProxyLlm, Ad as createRagSubagent, ao as createSandboxRunner, zl as createSdkEvents, gd as createSerialRunner, Pl as createSessionStore, fd as createSkillStore, Es as createSubagentMiddleware, us as createSubagentTracker, ks as createSubagentsMiddleware, od as createUsageHintsMiddleware, As as createVerifyMiddleware, cc as createVfs, Ml as createWebStorageBackend, Is as createWriteBackCheck, Fa as deepClone, nd as defineDataToolset, so as defineSkill, Jc as defineTool, Pa as deleteByPath, Qc as deriveTitle, sa as describeSchemaNode, Oi as detectGarbledToolCall, qa as diffObjects, Bu as domToStructure, Hu as domTools, td as domToolsStatic, $o as estimateMessageTokens, es as estimateRoundTokens, X as estimateTokens, g as extractReasoningDelta, ba as extractSchemaHint, Zs as extractText, h as extractTextDelta, _ as extractUsage, Iu as fetchDocTools, ed as fetchTools, Tu as filterByToolMode, Ka as findStrippedKeys, ca as formatConstraints, qr as formatZodIssues, Z as getByPath, Vu as getDomTool, Gu as getEnvSummary, Ji as getSchemaAtPath, Gi as getSchemaTopKeys, li as getTraceMetrics, $ as hashValue, ha as htmlOrchestratorPrompt, ts as indexSummarize, Ju as inspectEnvTool, Yu as inspectTools, $c as isChatModel, yi as isContextLengthError, Ki as isPathAllowed, Sl as isQuotaError, ja as isUnsafePath, eu as jpEval, Yr as jsonParseError, Ra as limitDepth, Ia as maybeParseValue, y as normalizeUsage, ci as offloadPassThroughChars, si as offloadThresholdChars, ma as presets, ta as projectBySchema, ea as projectBySchemaDeep, La as projectFields, ns as recallRounds, la as renderSchemaHint, ua as renderSchemaOverview, pa as renderSchemaShallow, Rl as resolveCapabilities, Hl as resolveContextOptions, Il as resolveDialogConfig, cl as resolveLlm, oi as resolveModelCaps, as as resolvePromptSoftCap, Fl as resolveStorage, Ga as restoreInPlace, Wa as restoreLive, Xr as routeError, oo as runHostScript, iu as runSandboxedScript, Ma as safeMerge, Wu as safeSerialize, Q as safeStringify, nu as searchJson, rd as selectBuiltinTools, Na as setByPath, os as shouldTriggerCompression, ga as systemPromptHelpers, Qo as tokenize, Y as toolError, qi as unwrapSchema, Nd as useChat, Vd as useChatContext, bc as validateHtmlFormat, e as z, Jr as zodError };
|