codexmate 0.1.33 → 0.1.35
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 +27 -2
- package/README.vi.md +27 -2
- package/README.zh.md +27 -2
- package/cli/analytics-export-args.js +7 -0
- package/cli/local-bridge.js +10 -6
- package/cli/openai-chat-routing.js +38 -0
- package/cli/routing-bridge.js +143 -0
- package/cli/session-usage.js +4 -1
- package/cli/system-prompt-files.js +75 -53
- package/cli.js +191 -9
- package/lib/data/model-prices.json +1868 -0
- package/lib/file-sharing-lan.js +111 -0
- package/lib/file-sharing.js +196 -0
- package/lib/model-test-client.js +61 -0
- package/lib/model-test.js +126 -0
- package/lib/routing-groups.js +161 -0
- package/lib/session-context-health.js +5 -1
- package/lib/session-evidence-collections.js +85 -0
- package/lib/session-features.js +15 -0
- package/lib/session-project-git.js +65 -0
- package/lib/session-projects.js +12 -1
- package/lib/session-stories.js +67 -0
- package/lib/session-usage-ledger.js +77 -0
- package/lib/session-usage-pricing.js +42 -0
- package/lib/session-usage-report.js +101 -0
- package/package.json +4 -1
- package/plugins/file-sharing/manifest.mjs +10 -0
- package/plugins/file-sharing/methods.mjs +101 -0
- package/plugins/file-sharing/overview.mjs +3 -0
- package/plugins/file-sharing/ownership.mjs +5 -0
- package/plugins/prompt-templates/computed.mjs +9 -0
- package/plugins/registry.mjs +3 -0
- package/web-ui/app.js +25 -2
- package/web-ui/index.html +3 -2
- package/web-ui/logic.session-artifacts.mjs +39 -0
- package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
- package/web-ui/modules/app.methods.agents.mjs +14 -1
- package/web-ui/modules/app.methods.install.mjs +23 -3
- package/web-ui/modules/app.methods.navigation.mjs +2 -0
- package/web-ui/modules/app.methods.prompts-editor.mjs +7 -4
- package/web-ui/modules/app.methods.session-actions.mjs +2 -2
- package/web-ui/modules/app.methods.session-browser.mjs +35 -0
- package/web-ui/modules/app.methods.system-prompt.mjs +99 -19
- package/web-ui/modules/app.methods.theme.mjs +4 -3
- package/web-ui/modules/app.methods.web-ui-preferences.mjs +12 -0
- package/web-ui/modules/i18n/locales/en.mjs +239 -5
- package/web-ui/modules/i18n/locales/ja.mjs +239 -5
- package/web-ui/modules/i18n/locales/vi.mjs +239 -5
- package/web-ui/modules/i18n/locales/zh-tw.mjs +239 -5
- package/web-ui/modules/i18n/locales/zh.mjs +239 -5
- package/web-ui/modules/model-test.mjs +82 -0
- package/web-ui/modules/plugins.methods.mjs +3 -1
- package/web-ui/modules/prompt-ecosystem.methods.mjs +4 -3
- package/web-ui/modules/routing.mjs +206 -0
- package/web-ui/modules/session-collections.mjs +65 -0
- package/web-ui/modules/session-evidence.mjs +81 -0
- package/web-ui/modules/session-features.mjs +15 -1
- package/web-ui/modules/session-git.mjs +39 -0
- package/web-ui/modules/session-stories.mjs +64 -0
- package/web-ui/modules/usage-pricing.mjs +30 -0
- package/web-ui/partials/index/layout-footer.html +1 -1
- package/web-ui/partials/index/layout-header.html +33 -12
- package/web-ui/partials/index/modals-basic.html +15 -0
- package/web-ui/partials/index/panel-plugins.html +3 -9
- package/web-ui/partials/index/panel-prompts.html +13 -7
- package/web-ui/partials/index/panel-routing.html +3 -0
- package/web-ui/partials/index/panel-sessions.html +20 -20
- package/web-ui/partials/index/panel-settings.html +11 -1
- package/web-ui/partials/index/panel-usage.html +2 -0
- package/web-ui/partials/index/plugin-file-sharing.html +47 -0
- package/web-ui/partials/index/routing-model-test.html +53 -0
- package/web-ui/partials/index/session-diagnostics.html +7 -4
- package/web-ui/partials/index/session-features.html +82 -2
- package/web-ui/partials/index/thread-handoff.html +73 -62
- package/web-ui/partials/index/usage-records.html +41 -0
- package/web-ui/res/web-ui-render.precompiled.js +1378 -230
- package/web-ui/styles/base-theme.css +1 -1
- package/web-ui/styles/modals-core.css +6 -5
- package/web-ui/styles/navigation-panels.css +4 -0
- package/web-ui/styles/plugins-panel.css +40 -1
- package/web-ui/styles/responsive.css +10 -5
- package/web-ui/styles/routing.css +78 -0
- package/web-ui/styles/session-features.css +180 -7
- package/web-ui/styles/sessions-list.css +74 -0
- package/web-ui/styles/sessions-preview.css +106 -68
- package/web-ui/styles/sessions-usage.css +8 -0
- package/web-ui/styles/settings-panel.css +30 -0
- package/web-ui/styles/system-prompt.css +8 -7
- package/web-ui/styles/theme-violet-tokens.css +52 -0
- package/web-ui/styles/theme-violet.css +1742 -0
- package/web-ui/styles.css +2 -0
|
@@ -1,4 +1,103 @@
|
|
|
1
1
|
const zh = Object.freeze({
|
|
2
|
+
"modelTest.title": "真实测试",
|
|
3
|
+
"modelTest.selection": "选择测试模型",
|
|
4
|
+
"modelTest.source": "配置来源",
|
|
5
|
+
"modelTest.selectModel": "选择模型",
|
|
6
|
+
"modelTest.prompt": "测试内容",
|
|
7
|
+
"modelTest.run": "发送测试",
|
|
8
|
+
"modelTest.running": "测试中…",
|
|
9
|
+
"modelTest.completed": "已回复",
|
|
10
|
+
"modelTest.failed": "测试失败",
|
|
11
|
+
"modelTest.seconds": "{seconds} 秒",
|
|
12
|
+
"modelTest.loading": "读取已有模型…",
|
|
13
|
+
"modelTest.empty": "暂无可选模型。",
|
|
14
|
+
"modelTest.required": "填写测试内容,选择已有模型。",
|
|
15
|
+
"modelTest.incomplete": "回复达到长度限制,内容未完整生成。",
|
|
16
|
+
|
|
17
|
+
"routing.openai.purpose": "给 OpenAI 兼容客户端提供模型分配 API,按组设置主力与备用。",
|
|
18
|
+
"routing.openai.active": "OpenAI Chat 已选择「{name}」。",
|
|
19
|
+
"routing.openai.off": "API 未启用。创建模型组后点「启用此组」。",
|
|
20
|
+
"routing.openai.bindingHint": "启用组即开放此 API;取消组即停用,不回退到 Codex 或 Claude。",
|
|
21
|
+
"routing.openai.disable": "停用接入",
|
|
22
|
+
"routing.openai.providers": "复用 Codex 配置页管理的供应商,只调用 Chat Completions 接口。无需安装 Codex;不会修改 Codex 或 Claude 的连接配置。",
|
|
23
|
+
"routing.openai.baseUrl": "客户端 Base URL",
|
|
24
|
+
"routing.openai.model": "客户端模型 ID",
|
|
25
|
+
"routing.openai.auth": "客户端 API Key 填 CODEXMATE_HTTP_TOKEN 的访问令牌,不填供应商密钥。此令牌也可访问管理 API。",
|
|
26
|
+
"routing.openai.localOnly": "未配置访问令牌,仅允许本机调用。客户端需要 API Key 时可填 local,服务器不向上游转发此值。",
|
|
27
|
+
"routing.openai.alias": "routing 是固定入口别名;实际模型由组内主力、备用或轮流规则决定。",
|
|
28
|
+
"routing.openai.permission": "组管理沿用 Codex 供应商的写权限。开启后允许修改 Codex 本机配置;启用此组仅写路由选择,不接管工具。",
|
|
29
|
+
"routing.openai.use": "把下方地址与模型 ID 填入 OpenAI 兼容客户端。",
|
|
30
|
+
"routing.purpose": "给 {agent} 设置模型使用顺序:先选主力,需要时再加备用。",
|
|
31
|
+
"routing.help.title": "工作方式与限制",
|
|
32
|
+
"routing.help.scope": "这里只分配模型请求,不启动工具,不执行任务,也不让多个模型一起回答。已启用仅表示配置已接入,供应商是否可用要看真实请求结果。",
|
|
33
|
+
"routing.help.errors": "仅在回复开始前遇到 HTTP 408(超时)、429(限流)、5xx(服务异常)时尝试下一个组内模型。其他 4xx 不切换,开始回复后也不切换。",
|
|
34
|
+
"routing.help.model": "供应商是提供模型的服务。组名可以自定义;组内模型栏填写供应商支持的模型 ID,不是昵称。已有配置会自动带入,未知值留空。",
|
|
35
|
+
"routing.start.create": "创建模型组:主力必选,备用可选。",
|
|
36
|
+
"routing.start.save": "保存这组设置。",
|
|
37
|
+
"routing.start.enable": "点击「启用此组」。",
|
|
38
|
+
"routing.start.use": "首次启用后,重启所选工具再提问。",
|
|
39
|
+
"routing.role.primary": "主力",
|
|
40
|
+
"routing.role.backup": "备用 {index}",
|
|
41
|
+
"routing.role.member": "模型 {index}",
|
|
42
|
+
"routing.editActive": "正在编辑已启用的组。保存后影响后续请求,当前请求不会重放。",
|
|
43
|
+
"routing.defaultName": "{target} 模型组 {index}",
|
|
44
|
+
"routing.nameRequired": "填写模型组名称。",
|
|
45
|
+
"routing.memberRequired": "为成员 {index} 选择供应商并填写模型。",
|
|
46
|
+
"routing.memberMissing": "成员 {index} 的供应商不可用,请更换或移除。",
|
|
47
|
+
"routing.memberDuplicate": "成员 {index} 与其他成员重复,请更换模型或移除。",
|
|
48
|
+
"routing.notActive": "当前配置未使用此组,请刷新核对。",
|
|
49
|
+
"routing.activationUnconfirmed": "绑定已完成;启用状态未确认。请刷新核对:{message}",
|
|
50
|
+
"routing.groupActivated": "已配置「{name}」。首次使用请重启所选工具,再提问。",
|
|
51
|
+
"routing.noProviders": "本页还没有可选供应商。先到配置页添加或检查。",
|
|
52
|
+
"routing.modelHint": "输入供应商支持的模型 ID",
|
|
53
|
+
"routing.inUse": "已启用",
|
|
54
|
+
"routing.awaitingEnable": "待启用",
|
|
55
|
+
"routing.working": "处理中…",
|
|
56
|
+
"routing.restorePool": "取消此组",
|
|
57
|
+
"routing.useGroup": "启用此组",
|
|
58
|
+
"routing.bindEnable": "启用此组",
|
|
59
|
+
"tab.routing": "模型测试",
|
|
60
|
+
"kicker.routing": "",
|
|
61
|
+
"title.routing": "模型测试",
|
|
62
|
+
"subtitle.routing": "",
|
|
63
|
+
"routing.target": "接入目标",
|
|
64
|
+
"routing.refresh": "刷新",
|
|
65
|
+
"routing.create": "新建模型组",
|
|
66
|
+
"routing.failed": "模型分配设置未完成。",
|
|
67
|
+
"routing.updated": "模型分配设置已保存。",
|
|
68
|
+
"routing.loading": "读取模型分配设置",
|
|
69
|
+
"routing.bindingHint": "新建组不会自动启用。首次使用,请点「启用此组」。",
|
|
70
|
+
"routing.readOnly": "当前只查看。开启写权限后允许修改此工具的本机配置。",
|
|
71
|
+
"routing.edit": "编辑模型组",
|
|
72
|
+
"routing.name": "组名称",
|
|
73
|
+
"routing.strategy": "使用方式",
|
|
74
|
+
"routing.strategy.order": "主力优先",
|
|
75
|
+
"routing.strategy.rotate": "轮流使用",
|
|
76
|
+
"routing.strategy.order.hint": "先用主力;超时、限流或服务异常时,在开始回复前按顺序尝试备用。",
|
|
77
|
+
"routing.strategy.rotate.hint": "按请求轮流换首选模型,不是让多个模型一起回答。",
|
|
78
|
+
"routing.provider": "供应商",
|
|
79
|
+
"routing.model": "模型",
|
|
80
|
+
"routing.selectProvider": "选择供应商",
|
|
81
|
+
"routing.unavailable": "不存在或已排除",
|
|
82
|
+
"routing.moveUp": "上移成员",
|
|
83
|
+
"routing.moveDown": "下移成员",
|
|
84
|
+
"routing.removeMember": "移除成员",
|
|
85
|
+
"routing.addMember": "添加成员",
|
|
86
|
+
"routing.save": "保存",
|
|
87
|
+
"routing.empty": "还没有模型组,按下面步骤设置。",
|
|
88
|
+
"routing.openConfig": "前往配置",
|
|
89
|
+
"routing.bound": "已绑定",
|
|
90
|
+
"routing.memberCount": "查看 {count} 项模型配置",
|
|
91
|
+
"routing.unbind": "解除绑定",
|
|
92
|
+
"routing.bind": "仅绑定",
|
|
93
|
+
"routing.delete": "删除",
|
|
94
|
+
"routing.deleteConfirm": "删除路由组「{name}」?此操作无法撤销。",
|
|
95
|
+
"routing.bridge.disable": "恢复工具配置",
|
|
96
|
+
"routing.bridge.enable": "接入模型分配",
|
|
97
|
+
"routing.state.group": "工具配置已使用「{name}」。",
|
|
98
|
+
"routing.state.legacy": "配置已接入,但尚未选模型组。",
|
|
99
|
+
"routing.state.pending": "已开启,但工具配置尚未接入。",
|
|
100
|
+
"routing.state.off": "尚未启用。选好模型组后点「启用此组」。",
|
|
2
101
|
"features.searchScope": "检索范围",
|
|
3
102
|
"features.moreFilters": "更多筛选",
|
|
4
103
|
"features.bookmarkHint": "点击消息旁的收藏图标,保留有用的片段。",
|
|
@@ -28,7 +127,11 @@ const zh = Object.freeze({
|
|
|
28
127
|
"features.index": "全文索引",
|
|
29
128
|
"features.refreshIndex": "更新索引",
|
|
30
129
|
"features.indexStatus": "已索引 {count} 条会话;本轮 {processed}/{total}",
|
|
31
|
-
"features.
|
|
130
|
+
"features.indexCatalogTime": "索引目录更新时间(UTC):{time}",
|
|
131
|
+
"features.indexSourceCoverage": "{source}:发现 {count} 个候选;发现上限 {limit}",
|
|
132
|
+
"features.indexUnknown": "未知",
|
|
133
|
+
"features.indexCoverageUnknown": "当前来源没有覆盖记录;请更新索引。",
|
|
134
|
+
"features.indexScope": "仅搜索已索引候选,不代表全部历史或最新消息。目录时间不代表每个来源的同步时间。沿用上方来源、项目与角色筛选;新消息需更新索引。",
|
|
32
135
|
"features.indexFailures": "{count} 项读取失败;结果未覆盖这些记录",
|
|
33
136
|
"features.coverage": "已查 {scanned}/{total} 条已索引会话",
|
|
34
137
|
"features.partial": "结果未完整覆盖当前范围;最多展示 100 条命中",
|
|
@@ -363,6 +466,7 @@ const zh = Object.freeze({
|
|
|
363
466
|
'side.update.availableWithVersion': '有新版本 v{version}',
|
|
364
467
|
'side.update.meta': '点击查看更新命令',
|
|
365
468
|
'side.update.metaVersions': '当前 v{current} → 最新 v{latest}',
|
|
469
|
+
'side.update.commandHint': '在运行 Codex Mate 的主机终端执行。更新成功后重启服务。',
|
|
366
470
|
'side.update.checkFailed': '检查最新版本失败',
|
|
367
471
|
'side.update.check': '检查更新',
|
|
368
472
|
'side.update.checking': '正在检查更新…',
|
|
@@ -483,7 +587,6 @@ const zh = Object.freeze({
|
|
|
483
587
|
'prompts.project.pathLabel': '项目路径(可选)',
|
|
484
588
|
'prompts.project.selectPlaceholder': '-- 全局 (~/.claude/CLAUDE.md) --',
|
|
485
589
|
'prompts.project.manualPlaceholder': '或手动输入项目根路径...',
|
|
486
|
-
'prompts.project.detected': '正在编辑: {path}',
|
|
487
590
|
'dashboard.doctor.title': 'Doctor',
|
|
488
591
|
'dashboard.doctor.runChecks': '运行检查',
|
|
489
592
|
'dashboard.doctor.checking': '检查中...',
|
|
@@ -582,11 +685,28 @@ const zh = Object.freeze({
|
|
|
582
685
|
|
|
583
686
|
// Plugins panel
|
|
584
687
|
'plugins.sidebar.title': 'Plugins',
|
|
585
|
-
'plugins.sidebar.note': '可复用的标准化工具。未来自定义插件应遵循相同结构。',
|
|
586
688
|
'plugins.sidebar.ariaList': '插件列表',
|
|
587
689
|
'plugins.catalog.promptTemplates.title': '提示词模板',
|
|
588
690
|
'plugins.catalog.promptTemplates.description': '标准化、模板驱动的提示词工具,支持变量、复制与导出。',
|
|
589
691
|
'plugins.status.standard': '标准',
|
|
692
|
+
'plugins.fileSharing.title': '文件共享',
|
|
693
|
+
'plugins.fileSharing.chooseFiles': '选择文件',
|
|
694
|
+
'plugins.fileSharing.chooseFolder': '选择文件夹',
|
|
695
|
+
'plugins.fileSharing.confirm': '仅上传以下文件。所有有权访问此 Web 实例的用户均可下载。',
|
|
696
|
+
'plugins.fileSharing.upload': '上传',
|
|
697
|
+
'plugins.fileSharing.empty': '暂无共享文件',
|
|
698
|
+
'plugins.fileSharing.files': '{count} 个文件',
|
|
699
|
+
'plugins.fileSharing.remove': '移除共享',
|
|
700
|
+
'plugins.fileSharing.bytes': '{size} 字节',
|
|
701
|
+
'plugins.fileSharing.download': '下载',
|
|
702
|
+
'plugins.fileSharing.copyLink': '复制局域网下载链接',
|
|
703
|
+
'plugins.fileSharing.copyManually': '请手动复制此下载链接。',
|
|
704
|
+
'plugins.fileSharing.lanUnavailable': '没有可用的私有 IPv4 网卡,或无法打开下载端口。',
|
|
705
|
+
'plugins.fileSharing.emptyFolder': '请选择至少包含一个文件的文件夹。',
|
|
706
|
+
'plugins.fileSharing.invalid': '上传内容或路径无效。',
|
|
707
|
+
'plugins.fileSharing.busy': '另一批文件正在上传,请稍后重试。',
|
|
708
|
+
'plugins.fileSharing.notFound': '该共享已不存在,请刷新列表。',
|
|
709
|
+
'plugins.fileSharing.failed': '文件共享请求失败,请重试。',
|
|
590
710
|
'plugins.catalog.textTools.title': '文本工具',
|
|
591
711
|
'plugins.catalog.textTools.description': '一组轻量纯文本小工具,首个工具可将多行文本压缩为单行。',
|
|
592
712
|
'plugins.textTools.title': '文本工具',
|
|
@@ -611,12 +731,10 @@ const zh = Object.freeze({
|
|
|
611
731
|
'plugins.promptTemplates.compose.chooseTemplateHint': '请选择一个模板开始生成。',
|
|
612
732
|
'plugins.promptTemplates.compose.builtinSuffix': '(内置)',
|
|
613
733
|
'plugins.promptTemplates.compose.empty': '暂无可用模板。',
|
|
614
|
-
'plugins.promptTemplates.compose.varsHint': '变量填写与新增请在「管理」中进行。',
|
|
615
734
|
'plugins.promptTemplates.compose.missingCount': '未填 {count} 项',
|
|
616
735
|
'plugins.promptTemplates.compose.jumpToMissing': '跳到未填',
|
|
617
736
|
'plugins.promptTemplates.compose.goManage': '去管理填写变量',
|
|
618
737
|
'plugins.promptTemplates.compose.outputTitle': '生成结果',
|
|
619
|
-
'plugins.promptTemplates.compose.outputHint': '点“复制”后直接粘贴到 Codex/Claude 输入框。',
|
|
620
738
|
'plugins.promptTemplates.compose.outputAria': '生成结果(提示词)',
|
|
621
739
|
'plugins.promptTemplates.compose.copy': '复制',
|
|
622
740
|
'plugins.promptTemplates.manage.searchAria': '搜索模板',
|
|
@@ -1018,6 +1136,21 @@ const zh = Object.freeze({
|
|
|
1018
1136
|
'sessions.roleLabel.assistant': 'Assistant',
|
|
1019
1137
|
|
|
1020
1138
|
// Usage panel
|
|
1139
|
+
"usage.records.title": "用量记录明细",
|
|
1140
|
+
"usage.records.scope": "记录按 UTC 日期归属;Codex 使用累计计数增量,Claude/Pi 使用助手用量,Gemini 使用既有 JSON 会话的 tokens。Gemini 总量含思考与工具 Token,缓存是输入子集;未提供分项保持未知。旧图表仍按会话更新时间归属。完整文本估算单列,不代表费用。",
|
|
1141
|
+
"usage.records.coverage": "已扫描 {scanned}/{candidates} 个候选会话;无用量记录 {unreported},未支持逐记录来源 {unsupported}。",
|
|
1142
|
+
"usage.records.failed": "读取失败 {count} 个会话,当前结果不完整;刷新后重试。",
|
|
1143
|
+
"usage.records.total": "记录 Token",
|
|
1144
|
+
"usage.records.estimated": "完整文本估算 Token",
|
|
1145
|
+
"usage.records.cacheRead": "缓存读取",
|
|
1146
|
+
"usage.records.cacheWrite": "缓存写入",
|
|
1147
|
+
"usage.records.unknown": "未知",
|
|
1148
|
+
"usage.records.date": "日期 (UTC)",
|
|
1149
|
+
"usage.records.source": "来源",
|
|
1150
|
+
"usage.records.model": "模型",
|
|
1151
|
+
"usage.records.input": "输入",
|
|
1152
|
+
"usage.records.output": "输出",
|
|
1153
|
+
"usage.records.undated": "缺少记录时间的 Token:{tokens};不分摊至某一天。",
|
|
1021
1154
|
'usage.overview': 'Usage 概览',
|
|
1022
1155
|
'usage.range.aria': 'Usage 时间范围',
|
|
1023
1156
|
'usage.range.7d': '近 7 天',
|
|
@@ -1353,6 +1486,7 @@ const zh = Object.freeze({
|
|
|
1353
1486
|
'settings.theme.light': '浅色',
|
|
1354
1487
|
'settings.theme.dark': '深色',
|
|
1355
1488
|
'settings.theme.ocean': '海洋蓝',
|
|
1489
|
+
'settings.theme.violet': '柔紫',
|
|
1356
1490
|
'settings.theme.hint': '主题偏好会自动保存,刷新后保持不变。',
|
|
1357
1491
|
'settings.sharePrefix.title': '分享命令前缀',
|
|
1358
1492
|
'settings.sharePrefix.meta': '影响 Web UI 里“复制分享命令”的前缀',
|
|
@@ -1734,6 +1868,10 @@ const zh = Object.freeze({
|
|
|
1734
1868
|
'kilocode.writeRequired': '请先打开 KiloCode 写入开关',
|
|
1735
1869
|
'kilocode.saved': 'KiloCode 配置已保存',
|
|
1736
1870
|
'kilocode.autoSaved': 'KiloCode 配置已同步',
|
|
1871
|
+
'sysPrompt.fileLabel': '文件',
|
|
1872
|
+
'sysPrompt.filesLoading': '读取文件列表…',
|
|
1873
|
+
'sysPrompt.fileMissing': '文件已移除或无法读取,请刷新文件列表',
|
|
1874
|
+
'sysPrompt.fileUnsaved': '请先保存或取消当前改动,再切换文件',
|
|
1737
1875
|
'sysPrompt.scope.label': '作用域',
|
|
1738
1876
|
'sysPrompt.scope.global': '全局 (~/.pi/agent/)',
|
|
1739
1877
|
'sysPrompt.scope.project': '项目 (<cwd>/.pi/)',
|
|
@@ -1744,6 +1882,102 @@ const zh = Object.freeze({
|
|
|
1744
1882
|
'sysPrompt.hint.unsaved': '有未保存的改动',
|
|
1745
1883
|
'sysPrompt.hint.twoStepSave': '点击预览查看差异,确认后保存。',
|
|
1746
1884
|
'sysPrompt.toast.saved': 'System prompt 已保存',
|
|
1885
|
+
"evidence.title": "跨会话证据包",
|
|
1886
|
+
"evidence.select": "加入证据包",
|
|
1887
|
+
"evidence.remove": "移除",
|
|
1888
|
+
"evidence.goal": "交接目标",
|
|
1889
|
+
"evidence.generate": "生成证据包",
|
|
1890
|
+
"evidence.preview": "预览({count} 字符)",
|
|
1891
|
+
"evidence.download": "下载 Markdown",
|
|
1892
|
+
"evidence.memory": "材料仅存本页,刷新清空;原记录不变。",
|
|
1893
|
+
"evidence.scope": "仅摘录用户选定的历史材料;未发送,未验证当前版本。",
|
|
1894
|
+
"evidence.path": "原文路径",
|
|
1895
|
+
"evidence.status": "历史证据状态",
|
|
1896
|
+
"evidence.passed": "历史工具日志提示通过,当前版本未验",
|
|
1897
|
+
"evidence.failed": "历史工具日志提示失败",
|
|
1898
|
+
"evidence.unverified": "待核对",
|
|
1899
|
+
"evidence.changed": "原文已变化;更新索引后重新选择。",
|
|
1900
|
+
"evidence.limit": "最多选择 100 条材料。",
|
|
1901
|
+
"artifacts.format": "输出格式",
|
|
1902
|
+
"artifacts.receipt": "开发小票",
|
|
1903
|
+
"artifacts.relay": "多 Agent 接力包",
|
|
1904
|
+
"artifacts.generate.receipt": "生成开发小票",
|
|
1905
|
+
"artifacts.generate.relay": "生成接力包",
|
|
1906
|
+
"artifacts.scope": "仅基于选定历史材料,本地生成;未发送、未执行、当前版本未验收。",
|
|
1907
|
+
"artifacts.goal": "目标(用户填写)",
|
|
1908
|
+
"artifacts.note": "补充说明(用户填写,可选)",
|
|
1909
|
+
"artifacts.notePlaceholder": "填写改动原因、下一步或验收标准;不作为验证证据。",
|
|
1910
|
+
"artifacts.unspecified": "未填写,请人工补充。",
|
|
1911
|
+
"artifacts.checks": "历史检查记录汇总",
|
|
1912
|
+
"artifacts.noVerdict": "记录数量不代表任务完成或当前版本测试通过;原文摘录见下方。",
|
|
1913
|
+
"artifacts.sources": "选定材料与来源",
|
|
1914
|
+
"artifacts.executor": "第一棒:执行者",
|
|
1915
|
+
"artifacts.executorTask": "核对目标、原文和允许修改范围。仅按明确授权执行;目标不清或材料失效时停止。交付实际改动、检查结果、失败与未验证项,不重放历史命令。",
|
|
1916
|
+
"artifacts.reviewer": "第二棒:审阅者",
|
|
1917
|
+
"artifacts.reviewerTask": "只读核查执行者结果、原文来源与当前版本。区分事实、推论和缺证,不把已投递或自报读取当作完成。列出仍需人工验收的步骤。",
|
|
1918
|
+
"artifacts.uat": "人工 UAT:待执行,未验收",
|
|
1919
|
+
"artifacts.uatTask": "在待验版本从真实入口复测目标,记录可观察结果与失败判据。历史日志、交接或自报读取不能替代当前验收。",
|
|
1920
|
+
|
|
1921
|
+
"collections.title": "证据专题夹",
|
|
1922
|
+
"collections.scope": "仅显式保存名称、目标与原文引用;打开会替换临时材料篮。刷新后需手动打开,不备份原会话。",
|
|
1923
|
+
"collections.name": "专题名称",
|
|
1924
|
+
"collections.save": "保存专题",
|
|
1925
|
+
"collections.saveAs": "另存专题",
|
|
1926
|
+
"collections.remove": "移除专题",
|
|
1927
|
+
"collections.refresh": "刷新专题",
|
|
1928
|
+
"collections.empty": "暂无已保存专题",
|
|
1929
|
+
"collections.state.ready": "原文一致",
|
|
1930
|
+
"collections.state.changed": "原文已变化",
|
|
1931
|
+
"collections.state.unavailable": "原文不可读取",
|
|
1932
|
+
"stories.title": "开发故事线",
|
|
1933
|
+
"stories.scope": "用户显式关联,不证明会话产生提交或测试通过。仅保存本机元数据,不写 Git、不上传。",
|
|
1934
|
+
"stories.linked": "用户关联",
|
|
1935
|
+
"stories.unavailable": "会话不在当前发现候选中",
|
|
1936
|
+
"stories.session": "关联会话",
|
|
1937
|
+
"stories.choose": "选择当前项目会话",
|
|
1938
|
+
"stories.note": "改动原因",
|
|
1939
|
+
"stories.save": "保存关联",
|
|
1940
|
+
"stories.remove": "取消关联",
|
|
1941
|
+
"stories.refresh": "刷新关联",
|
|
1942
|
+
"features.error.collection-input-invalid": "检查专题名称、目标与选中的引用",
|
|
1943
|
+
"features.error.collection-not-found": "专题已移除;刷新列表",
|
|
1944
|
+
"features.error.collection-source-unavailable": "原文已变化或不可读取;更新索引后重新选择",
|
|
1945
|
+
"features.error.story-input-invalid": "检查项目、完整提交 SHA 与备注",
|
|
1946
|
+
"features.error.story-project-unavailable": "项目不在当前发现范围",
|
|
1947
|
+
"features.error.story-session-unavailable": "会话不在当前项目候选中",
|
|
1948
|
+
"features.error.story-not-found": "关联已移除;刷新列表",
|
|
1949
|
+
"features.error.project-git-commit-invalid": "提交不在当前项目最近 30 条记录中",
|
|
1950
|
+
|
|
1951
|
+
"pricing.title": "费用参考(USD)",
|
|
1952
|
+
"pricing.scope": "按内置价格快照的基础文本单价估算,不是账单。不含阶梯、服务层、缓存时长、工具或多模态附加费;不推断历史计费供应商。",
|
|
1953
|
+
"pricing.total": "参考总额",
|
|
1954
|
+
"pricing.subtotal": "已知行小计",
|
|
1955
|
+
"pricing.coverage": "已定价 {known} 行;未知 {unknown} 行;读取失败 {failed};未报告 {unreported};未适配 {unsupported}",
|
|
1956
|
+
"pricing.basis": "依据",
|
|
1957
|
+
"pricing.rates": "每百万 Token:输入 {input} / 输出 {output} / 缓存读取 {cached} / 缓存写入 {created}",
|
|
1958
|
+
"pricing.download": "下载价格参考 JSON",
|
|
1959
|
+
"pricing.reason.base-rate": "基础单价估算",
|
|
1960
|
+
"pricing.reason.model-unknown": "模型无价格记录",
|
|
1961
|
+
"pricing.reason.usage-incomplete": "Token 分项不完整",
|
|
1962
|
+
"pricing.reason.usage-unclassified": "存在未归类 Token",
|
|
1963
|
+
"pricing.reason.rate-missing": "分项单价缺失",
|
|
1964
|
+
|
|
1965
|
+
"git.title": "Git 改动关联(只读)",
|
|
1966
|
+
"git.scope": "仅查看当前项目仓库。按会话更新时间前后 24 小时列出提交候选,不代表因果或测试通过;不写 Git、不上传会话。",
|
|
1967
|
+
"git.detached": "游离 HEAD",
|
|
1968
|
+
"git.noHead": "暂无提交",
|
|
1969
|
+
"git.changes": "当前变更 {count} 个文件",
|
|
1970
|
+
"git.truncated": "最多展示 30 个提交与 50 个变更文件;当前列表已截断。",
|
|
1971
|
+
"git.candidate": "时间关联候选",
|
|
1972
|
+
"git.refresh": "刷新 Git",
|
|
1973
|
+
"git.status.ready": "已读取当前 Git 状态",
|
|
1974
|
+
"git.status.unborn": "仓库尚无提交",
|
|
1975
|
+
"git.status.not-repository": "不是 Git 仓库",
|
|
1976
|
+
"git.status.path-unavailable": "项目路径不可访问",
|
|
1977
|
+
"git.status.git-unavailable": "未找到 Git",
|
|
1978
|
+
"git.status.read-timeout": "读取 Git 超时",
|
|
1979
|
+
"git.status.read-failed": "读取 Git 失败",
|
|
1980
|
+
|
|
1747
1981
|
});
|
|
1748
1982
|
|
|
1749
1983
|
export { zh };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { api } from './api.mjs';
|
|
2
|
+
import { buildMarkdownPreviewHtml } from '../logic.markdown-editor.mjs';
|
|
3
|
+
|
|
4
|
+
const MAX_PROMPT_LENGTH = 8000;
|
|
5
|
+
|
|
6
|
+
export function modelTestData() {
|
|
7
|
+
return {
|
|
8
|
+
modelTestTarget: 'codex', modelTestCatalogs: { codex: [], pi: [] }, modelTestProvider: '', modelTestModel: '',
|
|
9
|
+
modelTestPrompt: '', modelTestLoading: false, modelTestRunning: false, modelTestError: '', modelTestResult: null
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createModelTestMethods({ request }) {
|
|
14
|
+
return {
|
|
15
|
+
async loadModelTestCatalog() {
|
|
16
|
+
if (this.modelTestLoading || this.modelTestRunning) return;
|
|
17
|
+
this.modelTestLoading = true;
|
|
18
|
+
this.modelTestError = '';
|
|
19
|
+
try {
|
|
20
|
+
const state = await request('model-test-catalog');
|
|
21
|
+
if (state.error) throw new Error(typeof state.error === 'string' ? state.error : state.error.message);
|
|
22
|
+
this.modelTestCatalogs = state.catalogs;
|
|
23
|
+
this.selectModelTestProvider();
|
|
24
|
+
} catch (error) { this.modelTestError = error.message; }
|
|
25
|
+
finally { this.modelTestLoading = false; }
|
|
26
|
+
},
|
|
27
|
+
modelTestProviders() { return this.modelTestCatalogs[this.modelTestTarget]; },
|
|
28
|
+
modelTestModels() { return this.modelTestProviders().find(entry => entry.name === this.modelTestProvider)?.models || []; },
|
|
29
|
+
selectModelTestProvider() {
|
|
30
|
+
const providers = this.modelTestProviders();
|
|
31
|
+
const current = this.modelTestTarget === 'codex' ? this.currentProvider : this.piActiveProvider;
|
|
32
|
+
if (!providers.some(entry => entry.name === this.modelTestProvider)) {
|
|
33
|
+
this.modelTestProvider = providers.find(entry => entry.name === current)?.name || providers[0]?.name || '';
|
|
34
|
+
}
|
|
35
|
+
const models = this.modelTestModels();
|
|
36
|
+
const currentModel = this.modelTestTarget === 'codex' ? this.currentModels?.[this.modelTestProvider] || this.currentModel : this.piActiveModel;
|
|
37
|
+
if (!models.includes(this.modelTestModel)) this.modelTestModel = models.includes(currentModel) ? currentModel : models[0] || '';
|
|
38
|
+
},
|
|
39
|
+
setModelTestTarget(target) {
|
|
40
|
+
if (this.modelTestRunning) return;
|
|
41
|
+
this.modelTestTarget = target;
|
|
42
|
+
this.modelTestProvider = '';
|
|
43
|
+
this.modelTestModel = '';
|
|
44
|
+
this.selectModelTestProvider();
|
|
45
|
+
if (!this.__webUiPreferencesApplying && typeof this.persistWebUiPreferences === 'function') {
|
|
46
|
+
this.persistWebUiPreferences({ navigation: { modelTestTarget: target } });
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
modelTestDuration(result = this.modelTestResult) {
|
|
50
|
+
return this.t('modelTest.seconds', { seconds: (result.durationMs / 1000).toFixed(2) });
|
|
51
|
+
},
|
|
52
|
+
modelTestPreview() {
|
|
53
|
+
return buildMarkdownPreviewHtml(this.modelTestResult?.text, globalThis.marked, globalThis.DOMPurify);
|
|
54
|
+
},
|
|
55
|
+
async runModelTest() {
|
|
56
|
+
if (this.modelTestRunning || this.modelTestLoading) return;
|
|
57
|
+
const prompt = this.modelTestPrompt.trim();
|
|
58
|
+
if (!prompt || this.modelTestPrompt.length > MAX_PROMPT_LENGTH || !this.modelTestModels().includes(this.modelTestModel)) {
|
|
59
|
+
this.modelTestError = this.t('modelTest.required'); return;
|
|
60
|
+
}
|
|
61
|
+
this.modelTestRunning = true;
|
|
62
|
+
this.modelTestError = '';
|
|
63
|
+
this.modelTestResult = { target: this.modelTestTarget, provider: this.modelTestProvider, model: this.modelTestModel, prompt };
|
|
64
|
+
const started = Date.now();
|
|
65
|
+
try {
|
|
66
|
+
const result = await request('model-test-run', {
|
|
67
|
+
target: this.modelTestTarget, provider: this.modelTestProvider, model: this.modelTestModel, prompt
|
|
68
|
+
});
|
|
69
|
+
this.modelTestResult = { ...this.modelTestResult, durationMs: Date.now() - started, ...result };
|
|
70
|
+
} catch (error) {
|
|
71
|
+
this.modelTestResult = { ...this.modelTestResult, ok: false, error: error.message, durationMs: Date.now() - started };
|
|
72
|
+
} finally { this.modelTestRunning = false; }
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const modelTestMixin = {
|
|
78
|
+
data: modelTestData,
|
|
79
|
+
computed: { modelTestRenderedResponse() { return this.modelTestPreview(); } },
|
|
80
|
+
watch: { mainTab(tab) { if (tab === 'routing') this.loadModelTestCatalog(); } },
|
|
81
|
+
methods: createModelTestMethods({ request: api })
|
|
82
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createPromptTemplatesMethods } from '../../plugins/prompt-templates/methods.mjs';
|
|
2
|
+
import { createFileSharingMethods } from '../../plugins/file-sharing/methods.mjs';
|
|
2
3
|
import { createTextToolsMethods } from '../../plugins/text-tools/methods.mjs';
|
|
3
4
|
import { createPromptInvocationMethods } from '../../plugins/prompt-templates/invocation.mjs';
|
|
4
5
|
|
|
@@ -6,6 +7,7 @@ export function createPluginsMethods() {
|
|
|
6
7
|
return {
|
|
7
8
|
...createPromptTemplatesMethods(),
|
|
8
9
|
...createPromptInvocationMethods(),
|
|
9
|
-
...createTextToolsMethods()
|
|
10
|
+
...createTextToolsMethods(),
|
|
11
|
+
...createFileSharingMethods()
|
|
10
12
|
};
|
|
11
13
|
}
|
|
@@ -5,11 +5,12 @@ export function createPromptEcosystemMethods({ api }) {
|
|
|
5
5
|
return {
|
|
6
6
|
promptHistoryTarget(kind) {
|
|
7
7
|
if (kind === 'sys') return {
|
|
8
|
-
key: `${this.sysPromptScope}:${this.sysPromptMode}:${this.sysHistoryPreviewId}`,
|
|
9
|
-
busy: this.sysPromptLoading || this.sysPromptSaving || this.sysPromptDiffVisible,
|
|
8
|
+
key: `${this.sysPromptScope}:${this.sysPromptMode}:${this.sysPromptFileName || ''}:${this.sysHistoryPreviewId}`,
|
|
9
|
+
busy: this.sysPromptFileMissing || this.sysPromptLoading || this.sysPromptSaving || this.sysPromptDiffVisible,
|
|
10
10
|
id: this.sysHistoryPreviewId, content: this.sysHistoryPreviewContent,
|
|
11
11
|
action: 'apply-system-prompt', saving: 'sysPromptSaving',
|
|
12
|
-
params: { scope: this.sysPromptScope, mode: this.sysPromptMode, baseHash: this.sysPromptHash
|
|
12
|
+
params: { scope: this.sysPromptScope, mode: this.sysPromptMode, baseHash: this.sysPromptHash,
|
|
13
|
+
...(this.sysPromptFileName ? { fileName: this.sysPromptFileName } : {}) },
|
|
13
14
|
load: 'loadSystemPrompt', history: 'loadSysHistory', bucket: this.sysHistoryBucket
|
|
14
15
|
};
|
|
15
16
|
const context = this.agentsContext || 'codex';
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { api } from './api.mjs';
|
|
2
|
+
import { createModelTestMethods, modelTestData } from './model-test.mjs';
|
|
3
|
+
|
|
4
|
+
const MAX_MEMBERS = 16;
|
|
5
|
+
export function createRoutingMethods({ request = api, origin = () => globalThis.location.origin } = {}) {
|
|
6
|
+
return {
|
|
7
|
+
...createModelTestMethods({ request }),
|
|
8
|
+
applyRoutingState(state) {
|
|
9
|
+
this.routingGroups = state.groups;
|
|
10
|
+
this.routingBindings = { 'openai-chat': '', ...state.bindings };
|
|
11
|
+
this.routingCatalogs = { 'openai-chat': [], ...state.catalogs };
|
|
12
|
+
this.routingBridges = { 'openai-chat': { active: false, enabled: false }, ...state.bridges };
|
|
13
|
+
this.routingRevision = state.revision;
|
|
14
|
+
if (state.openaiChat) this.routingOpenaiAccess = state.openaiChat;
|
|
15
|
+
this.routingLoaded = true;
|
|
16
|
+
},
|
|
17
|
+
async loadRouting() {
|
|
18
|
+
if (this.routingLoading || this.routingSaving) return;
|
|
19
|
+
this.routingLoading = true;
|
|
20
|
+
this.routingError = '';
|
|
21
|
+
try {
|
|
22
|
+
const state = await request('routing-get');
|
|
23
|
+
if (state.error) throw new Error(typeof state.error === 'string' ? state.error : state.error.message);
|
|
24
|
+
this.applyRoutingState(state);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
this.routingError = error.message || this.t('routing.failed');
|
|
27
|
+
} finally { this.routingLoading = false; }
|
|
28
|
+
},
|
|
29
|
+
routingTargetName(target = this.routingTarget) {
|
|
30
|
+
return { codex: 'Codex', claude: 'Claude', 'openai-chat': 'OpenAI Chat' }[target];
|
|
31
|
+
},
|
|
32
|
+
routingPermissionTarget(target = this.routingTarget) {
|
|
33
|
+
return target === 'openai-chat' ? 'codex' : target;
|
|
34
|
+
},
|
|
35
|
+
routingOpenaiBaseUrl() {
|
|
36
|
+
return origin() + this.routingOpenaiAccess.basePath;
|
|
37
|
+
},
|
|
38
|
+
routingGroupsForTarget() {
|
|
39
|
+
return this.routingGroups.filter(group => group.target === this.routingTarget);
|
|
40
|
+
},
|
|
41
|
+
routingCatalog() {
|
|
42
|
+
return this.routingCatalogs[this.routingTarget] || [];
|
|
43
|
+
},
|
|
44
|
+
routingStateLabel() {
|
|
45
|
+
const bridge = this.routingBridges[this.routingTarget];
|
|
46
|
+
if (bridge.active) {
|
|
47
|
+
const id = this.routingBindings[this.routingTarget];
|
|
48
|
+
if (!id) return this.t('routing.state.legacy');
|
|
49
|
+
const group = this.routingGroups.find(item => item.id === id);
|
|
50
|
+
return this.t(this.routingTarget === 'openai-chat' ? 'routing.openai.active' : 'routing.state.group', { name: group.name });
|
|
51
|
+
}
|
|
52
|
+
return this.t(this.routingTarget === 'openai-chat' ? 'routing.openai.off' : bridge.enabled ? 'routing.state.pending' : 'routing.state.off');
|
|
53
|
+
},
|
|
54
|
+
routingMemberRole(index, strategy) {
|
|
55
|
+
if (strategy === 'rotate') return this.t('routing.role.member', { index: index + 1 });
|
|
56
|
+
return this.t(index === 0 ? 'routing.role.primary' : 'routing.role.backup', { index });
|
|
57
|
+
},
|
|
58
|
+
setRoutingTarget(target) {
|
|
59
|
+
if (this.routingDraft || this.routingSaving) return;
|
|
60
|
+
this.routingTarget = target;
|
|
61
|
+
},
|
|
62
|
+
routingMemberModel(providerName) {
|
|
63
|
+
if (this.routingPermissionTarget() === 'codex') {
|
|
64
|
+
const model = this.currentModels?.[providerName] || (this.currentProvider === providerName ? this.currentModel : '');
|
|
65
|
+
if (typeof model === 'string' && model.trim()) return model.trim();
|
|
66
|
+
}
|
|
67
|
+
return this.routingCatalog().find(entry => entry.name === providerName)?.model || '';
|
|
68
|
+
},
|
|
69
|
+
routingDefaultMember() {
|
|
70
|
+
const used = new Set((this.routingDraft?.members || []).map(member => member.provider));
|
|
71
|
+
const provider = this.routingCatalog().find(entry => !used.has(entry.name));
|
|
72
|
+
return provider ? { provider: provider.name, model: this.routingMemberModel(provider.name) } : { provider: '', model: '' };
|
|
73
|
+
},
|
|
74
|
+
editRoutingGroup(group = null) {
|
|
75
|
+
this.routingError = '';
|
|
76
|
+
if (group) this.routingDraft = { ...group, members: group.members.map(member => ({ ...member })), revision: this.routingRevision };
|
|
77
|
+
else {
|
|
78
|
+
const names = new Set(this.routingGroupsForTarget().map(item => item.name));
|
|
79
|
+
let index = 1;
|
|
80
|
+
const target = this.routingTargetName();
|
|
81
|
+
let name = this.t('routing.defaultName', { target, index });
|
|
82
|
+
while (names.has(name)) name = this.t('routing.defaultName', { target, index: ++index });
|
|
83
|
+
this.routingDraft = { name, target: this.routingTarget, strategy: 'order', members: [this.routingDefaultMember()], revision: this.routingRevision };
|
|
84
|
+
}
|
|
85
|
+
if (typeof this.$nextTick === 'function') this.$nextTick(() => {
|
|
86
|
+
const input = this.$refs.routingNameInput;
|
|
87
|
+
if (input) { input.focus(); input.select(); }
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
cancelRoutingEdit() {
|
|
91
|
+
if (!this.routingSaving) this.routingDraft = null;
|
|
92
|
+
},
|
|
93
|
+
addRoutingMember() {
|
|
94
|
+
if (this.routingDraft.members.length < MAX_MEMBERS) this.routingDraft.members.push(this.routingDefaultMember());
|
|
95
|
+
},
|
|
96
|
+
setRoutingMemberProvider(index) {
|
|
97
|
+
const member = this.routingDraft.members[index];
|
|
98
|
+
member.model = this.routingMemberModel(member.provider);
|
|
99
|
+
},
|
|
100
|
+
moveRoutingMember(index, offset) {
|
|
101
|
+
const members = this.routingDraft.members;
|
|
102
|
+
const destination = index + offset;
|
|
103
|
+
if (destination < 0 || destination >= members.length) return;
|
|
104
|
+
const [member] = members.splice(index, 1);
|
|
105
|
+
members.splice(destination, 0, member);
|
|
106
|
+
},
|
|
107
|
+
routingDraftError() {
|
|
108
|
+
const draft = this.routingDraft;
|
|
109
|
+
if (!draft || !draft.name.trim()) return this.t('routing.nameRequired');
|
|
110
|
+
const pairs = new Set();
|
|
111
|
+
for (const [index, member] of draft.members.entries()) {
|
|
112
|
+
if (!member.provider.trim() || !member.model.trim()) return this.t('routing.memberRequired', { index: index + 1 });
|
|
113
|
+
if (!this.routingCatalog().some(entry => entry.name === member.provider)) return this.t('routing.memberMissing', { index: index + 1 });
|
|
114
|
+
const pair = JSON.stringify([member.provider.trim(), member.model.trim()]);
|
|
115
|
+
if (pairs.has(pair)) return this.t('routing.memberDuplicate', { index: index + 1 });
|
|
116
|
+
pairs.add(pair);
|
|
117
|
+
}
|
|
118
|
+
return '';
|
|
119
|
+
},
|
|
120
|
+
async writeRouting(action, params, options = {}) {
|
|
121
|
+
if (this.routingSaving || this.routingLoading || !this.isToolConfigWriteAllowed(this.routingPermissionTarget())) return false;
|
|
122
|
+
const target = this.routingTarget;
|
|
123
|
+
let bindingConfirmed = false;
|
|
124
|
+
this.routingSaving = true;
|
|
125
|
+
this.routingError = '';
|
|
126
|
+
try {
|
|
127
|
+
const result = await request(action, params);
|
|
128
|
+
if (result.error) throw new Error(typeof result.error === 'string' ? result.error : result.error.message);
|
|
129
|
+
let state = result.groups ? result : await request('routing-get');
|
|
130
|
+
if (state.error) throw new Error(typeof state.error === 'string' ? state.error : state.error.message);
|
|
131
|
+
if (options.activate) {
|
|
132
|
+
if (state.bindings[target] !== params.id) throw new Error(this.t('routing.notActive'));
|
|
133
|
+
bindingConfirmed = true;
|
|
134
|
+
if (!state.bridges[target].active) {
|
|
135
|
+
this.applyRoutingState(state);
|
|
136
|
+
const toggle = target === 'claude' ? 'claude-local-bridge-toggle' : 'local-bridge-toggle';
|
|
137
|
+
const bridge = await request(toggle, { enable: true });
|
|
138
|
+
if (bridge.error) throw new Error(typeof bridge.error === 'string' ? bridge.error : bridge.error.message);
|
|
139
|
+
state = await request('routing-get');
|
|
140
|
+
if (state.error) throw new Error(typeof state.error === 'string' ? state.error : state.error.message);
|
|
141
|
+
}
|
|
142
|
+
if (!state.bridges[target].active || state.bindings[target] !== params.id) throw new Error(this.t('routing.notActive'));
|
|
143
|
+
}
|
|
144
|
+
this.applyRoutingState(state);
|
|
145
|
+
this.showMessage(this.t(options.activate ? 'routing.groupActivated' : 'routing.updated', { name: options.name }), 'success');
|
|
146
|
+
return true;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
const message = error.message || this.t('routing.failed');
|
|
149
|
+
this.routingError = bindingConfirmed ? this.t('routing.activationUnconfirmed', { message }) : message;
|
|
150
|
+
return false;
|
|
151
|
+
} finally { this.routingSaving = false; }
|
|
152
|
+
},
|
|
153
|
+
async saveRoutingGroup() {
|
|
154
|
+
if (this.routingSaving || this.routingLoading || !this.isToolConfigWriteAllowed(this.routingPermissionTarget())) return;
|
|
155
|
+
const error = this.routingDraftError();
|
|
156
|
+
if (error) { this.routingError = error; return; }
|
|
157
|
+
if (await this.writeRouting('routing-save', this.routingDraft)) this.routingDraft = null;
|
|
158
|
+
},
|
|
159
|
+
async bindRoutingGroup(id) {
|
|
160
|
+
await this.writeRouting('routing-bind', { target: this.routingTarget, id, revision: this.routingRevision });
|
|
161
|
+
},
|
|
162
|
+
async useRoutingGroup(group) {
|
|
163
|
+
if (this.routingSaving || this.routingLoading || !this.isToolConfigWriteAllowed(this.routingPermissionTarget())) return;
|
|
164
|
+
this.routingPendingGroupId = group.id;
|
|
165
|
+
try {
|
|
166
|
+
if (this.routingBindings[this.routingTarget] === group.id && this.routingBridges[this.routingTarget].active) {
|
|
167
|
+
await this.bindRoutingGroup('');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
await this.writeRouting('routing-bind', { target: this.routingTarget, id: group.id, revision: this.routingRevision }, { activate: true, name: group.name });
|
|
171
|
+
} finally { this.routingPendingGroupId = ''; }
|
|
172
|
+
},
|
|
173
|
+
async deleteRoutingGroup(group) {
|
|
174
|
+
if (this.routingBindings[group.target] === group.id || !this.isToolConfigWriteAllowed(this.routingPermissionTarget(group.target))) return;
|
|
175
|
+
const revision = this.routingRevision;
|
|
176
|
+
const confirmed = await this.requestConfirmDialog({
|
|
177
|
+
title: this.t('routing.delete'), message: this.t('routing.deleteConfirm', { name: group.name }),
|
|
178
|
+
confirmText: this.t('routing.delete'), cancelText: this.t('common.cancel'), danger: true
|
|
179
|
+
});
|
|
180
|
+
if (confirmed) await this.writeRouting('routing-delete', { id: group.id, revision });
|
|
181
|
+
},
|
|
182
|
+
async toggleRoutingBridge() {
|
|
183
|
+
if (this.routingTarget === 'openai-chat') { await this.bindRoutingGroup(''); return; }
|
|
184
|
+
const action = this.routingTarget === 'claude' ? 'claude-local-bridge-toggle' : 'local-bridge-toggle';
|
|
185
|
+
await this.writeRouting(action, { enable: !this.routingBridges[this.routingTarget].active });
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export const routingMixin = {
|
|
190
|
+
data() {
|
|
191
|
+
return {
|
|
192
|
+
...modelTestData(),
|
|
193
|
+
routingTarget: 'codex', routingGroups: [], routingBindings: { codex: '', claude: '', 'openai-chat': '' },
|
|
194
|
+
routingCatalogs: { codex: [], claude: [], 'openai-chat': [] },
|
|
195
|
+
routingBridges: { codex: { enabled: false, active: false }, claude: { enabled: false, active: false }, 'openai-chat': { enabled: false, active: false } },
|
|
196
|
+
routingOpenaiAccess: { basePath: '/bridge/openai-chat/v1', model: 'routing', requiresToken: false },
|
|
197
|
+
routingRevision: '', routingDraft: null, routingLoading: false, routingSaving: false, routingPendingGroupId: '',
|
|
198
|
+
routingLoaded: false, routingError: ''
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
computed: { modelTestRenderedResponse() { return this.modelTestPreview(); } },
|
|
202
|
+
watch: {
|
|
203
|
+
mainTab(tab) { if (tab === 'routing') { this.loadRouting(); this.loadModelTestCatalog(); } }
|
|
204
|
+
},
|
|
205
|
+
methods: createRoutingMethods()
|
|
206
|
+
};
|