codexmate 0.1.33 → 0.1.34

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.
Files changed (61) hide show
  1. package/README.md +13 -2
  2. package/README.vi.md +13 -2
  3. package/README.zh.md +13 -2
  4. package/cli/local-bridge.js +10 -6
  5. package/cli/openai-chat-routing.js +38 -0
  6. package/cli/routing-bridge.js +143 -0
  7. package/cli/system-prompt-files.js +75 -53
  8. package/cli.js +162 -4
  9. package/lib/file-sharing-lan.js +111 -0
  10. package/lib/file-sharing.js +196 -0
  11. package/lib/model-test-client.js +61 -0
  12. package/lib/model-test.js +126 -0
  13. package/lib/routing-groups.js +161 -0
  14. package/package.json +1 -1
  15. package/plugins/file-sharing/manifest.mjs +10 -0
  16. package/plugins/file-sharing/methods.mjs +101 -0
  17. package/plugins/file-sharing/overview.mjs +3 -0
  18. package/plugins/file-sharing/ownership.mjs +5 -0
  19. package/plugins/registry.mjs +3 -0
  20. package/web-ui/app.js +15 -2
  21. package/web-ui/index.html +3 -2
  22. package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
  23. package/web-ui/modules/app.methods.agents.mjs +12 -0
  24. package/web-ui/modules/app.methods.install.mjs +23 -3
  25. package/web-ui/modules/app.methods.navigation.mjs +2 -0
  26. package/web-ui/modules/app.methods.prompts-editor.mjs +7 -4
  27. package/web-ui/modules/app.methods.session-actions.mjs +2 -2
  28. package/web-ui/modules/app.methods.system-prompt.mjs +88 -17
  29. package/web-ui/modules/app.methods.theme.mjs +4 -3
  30. package/web-ui/modules/app.methods.web-ui-preferences.mjs +7 -0
  31. package/web-ui/modules/i18n/locales/en.mjs +123 -4
  32. package/web-ui/modules/i18n/locales/ja.mjs +123 -4
  33. package/web-ui/modules/i18n/locales/vi.mjs +123 -4
  34. package/web-ui/modules/i18n/locales/zh-tw.mjs +123 -4
  35. package/web-ui/modules/i18n/locales/zh.mjs +123 -4
  36. package/web-ui/modules/model-test.mjs +82 -0
  37. package/web-ui/modules/plugins.methods.mjs +3 -1
  38. package/web-ui/modules/prompt-ecosystem.methods.mjs +4 -3
  39. package/web-ui/modules/routing.mjs +206 -0
  40. package/web-ui/partials/index/layout-header.html +33 -12
  41. package/web-ui/partials/index/modals-basic.html +15 -0
  42. package/web-ui/partials/index/panel-plugins.html +3 -9
  43. package/web-ui/partials/index/panel-prompts.html +13 -7
  44. package/web-ui/partials/index/panel-routing.html +3 -0
  45. package/web-ui/partials/index/panel-settings.html +11 -1
  46. package/web-ui/partials/index/plugin-file-sharing.html +47 -0
  47. package/web-ui/partials/index/routing-model-test.html +53 -0
  48. package/web-ui/partials/index/session-diagnostics.html +7 -4
  49. package/web-ui/res/web-ui-render.precompiled.js +606 -105
  50. package/web-ui/styles/base-theme.css +1 -1
  51. package/web-ui/styles/modals-core.css +6 -5
  52. package/web-ui/styles/navigation-panels.css +4 -0
  53. package/web-ui/styles/plugins-panel.css +40 -1
  54. package/web-ui/styles/responsive.css +10 -5
  55. package/web-ui/styles/routing.css +78 -0
  56. package/web-ui/styles/session-features.css +117 -7
  57. package/web-ui/styles/settings-panel.css +30 -0
  58. package/web-ui/styles/system-prompt.css +8 -7
  59. package/web-ui/styles/theme-violet-tokens.css +52 -0
  60. package/web-ui/styles/theme-violet.css +1736 -0
  61. 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": "点击消息旁的收藏图标,保留有用的片段。",
@@ -363,6 +462,7 @@ const zh = Object.freeze({
363
462
  'side.update.availableWithVersion': '有新版本 v{version}',
364
463
  'side.update.meta': '点击查看更新命令',
365
464
  'side.update.metaVersions': '当前 v{current} → 最新 v{latest}',
465
+ 'side.update.commandHint': '在运行 Codex Mate 的主机终端执行。更新成功后重启服务。',
366
466
  'side.update.checkFailed': '检查最新版本失败',
367
467
  'side.update.check': '检查更新',
368
468
  'side.update.checking': '正在检查更新…',
@@ -483,7 +583,6 @@ const zh = Object.freeze({
483
583
  'prompts.project.pathLabel': '项目路径(可选)',
484
584
  'prompts.project.selectPlaceholder': '-- 全局 (~/.claude/CLAUDE.md) --',
485
585
  'prompts.project.manualPlaceholder': '或手动输入项目根路径...',
486
- 'prompts.project.detected': '正在编辑: {path}',
487
586
  'dashboard.doctor.title': 'Doctor',
488
587
  'dashboard.doctor.runChecks': '运行检查',
489
588
  'dashboard.doctor.checking': '检查中...',
@@ -582,11 +681,28 @@ const zh = Object.freeze({
582
681
 
583
682
  // Plugins panel
584
683
  'plugins.sidebar.title': 'Plugins',
585
- 'plugins.sidebar.note': '可复用的标准化工具。未来自定义插件应遵循相同结构。',
586
684
  'plugins.sidebar.ariaList': '插件列表',
587
685
  'plugins.catalog.promptTemplates.title': '提示词模板',
588
686
  'plugins.catalog.promptTemplates.description': '标准化、模板驱动的提示词工具,支持变量、复制与导出。',
589
687
  'plugins.status.standard': '标准',
688
+ 'plugins.fileSharing.title': '文件共享',
689
+ 'plugins.fileSharing.chooseFiles': '选择文件',
690
+ 'plugins.fileSharing.chooseFolder': '选择文件夹',
691
+ 'plugins.fileSharing.confirm': '仅上传以下文件。所有有权访问此 Web 实例的用户均可下载。',
692
+ 'plugins.fileSharing.upload': '上传',
693
+ 'plugins.fileSharing.empty': '暂无共享文件',
694
+ 'plugins.fileSharing.files': '{count} 个文件',
695
+ 'plugins.fileSharing.remove': '移除共享',
696
+ 'plugins.fileSharing.bytes': '{size} 字节',
697
+ 'plugins.fileSharing.download': '下载',
698
+ 'plugins.fileSharing.copyLink': '复制局域网下载链接',
699
+ 'plugins.fileSharing.copyManually': '请手动复制此下载链接。',
700
+ 'plugins.fileSharing.lanUnavailable': '没有可用的私有 IPv4 网卡,或无法打开下载端口。',
701
+ 'plugins.fileSharing.emptyFolder': '请选择至少包含一个文件的文件夹。',
702
+ 'plugins.fileSharing.invalid': '上传内容或路径无效。',
703
+ 'plugins.fileSharing.busy': '另一批文件正在上传,请稍后重试。',
704
+ 'plugins.fileSharing.notFound': '该共享已不存在,请刷新列表。',
705
+ 'plugins.fileSharing.failed': '文件共享请求失败,请重试。',
590
706
  'plugins.catalog.textTools.title': '文本工具',
591
707
  'plugins.catalog.textTools.description': '一组轻量纯文本小工具,首个工具可将多行文本压缩为单行。',
592
708
  'plugins.textTools.title': '文本工具',
@@ -611,12 +727,10 @@ const zh = Object.freeze({
611
727
  'plugins.promptTemplates.compose.chooseTemplateHint': '请选择一个模板开始生成。',
612
728
  'plugins.promptTemplates.compose.builtinSuffix': '(内置)',
613
729
  'plugins.promptTemplates.compose.empty': '暂无可用模板。',
614
- 'plugins.promptTemplates.compose.varsHint': '变量填写与新增请在「管理」中进行。',
615
730
  'plugins.promptTemplates.compose.missingCount': '未填 {count} 项',
616
731
  'plugins.promptTemplates.compose.jumpToMissing': '跳到未填',
617
732
  'plugins.promptTemplates.compose.goManage': '去管理填写变量',
618
733
  'plugins.promptTemplates.compose.outputTitle': '生成结果',
619
- 'plugins.promptTemplates.compose.outputHint': '点“复制”后直接粘贴到 Codex/Claude 输入框。',
620
734
  'plugins.promptTemplates.compose.outputAria': '生成结果(提示词)',
621
735
  'plugins.promptTemplates.compose.copy': '复制',
622
736
  'plugins.promptTemplates.manage.searchAria': '搜索模板',
@@ -1353,6 +1467,7 @@ const zh = Object.freeze({
1353
1467
  'settings.theme.light': '浅色',
1354
1468
  'settings.theme.dark': '深色',
1355
1469
  'settings.theme.ocean': '海洋蓝',
1470
+ 'settings.theme.violet': '柔紫',
1356
1471
  'settings.theme.hint': '主题偏好会自动保存,刷新后保持不变。',
1357
1472
  'settings.sharePrefix.title': '分享命令前缀',
1358
1473
  'settings.sharePrefix.meta': '影响 Web UI 里“复制分享命令”的前缀',
@@ -1734,6 +1849,10 @@ const zh = Object.freeze({
1734
1849
  'kilocode.writeRequired': '请先打开 KiloCode 写入开关',
1735
1850
  'kilocode.saved': 'KiloCode 配置已保存',
1736
1851
  'kilocode.autoSaved': 'KiloCode 配置已同步',
1852
+ 'sysPrompt.fileLabel': '文件',
1853
+ 'sysPrompt.filesLoading': '读取文件列表…',
1854
+ 'sysPrompt.fileMissing': '文件已移除或无法读取,请刷新文件列表',
1855
+ 'sysPrompt.fileUnsaved': '请先保存或取消当前改动,再切换文件',
1737
1856
  'sysPrompt.scope.label': '作用域',
1738
1857
  'sysPrompt.scope.global': '全局 (~/.pi/agent/)',
1739
1858
  'sysPrompt.scope.project': '项目 (<cwd>/.pi/)',
@@ -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
+ };
@@ -46,6 +46,16 @@
46
46
  :class="{ active: isMainTabNavActive('config') }"
47
47
  @pointerdown="onMainTabPointerDown('config', $event)"
48
48
  @click="onMainTabClick('config', $event)">{{ t('tab.config') }}</button>
49
+ <button type="button" class="top-tab"
50
+ id="tab-routing"
51
+ role="tab"
52
+ data-main-tab="routing"
53
+ :tabindex="mainTab === 'routing' ? 0 : -1"
54
+ :aria-selected="mainTab === 'routing'"
55
+ aria-controls="panel-routing"
56
+ :class="{ active: isMainTabNavActive('routing') }"
57
+ @pointerdown="onMainTabPointerDown('routing', $event)"
58
+ @click="onMainTabClick('routing', $event)">{{ t('tab.routing') }}</button>
49
59
  <button type="button" class="top-tab"
50
60
  id="tab-sessions"
51
61
  role="tab"
@@ -116,17 +126,8 @@
116
126
  @click="openLanguageSettings">{{ t('settings.language.sideLabel', { language: currentLanguageLabel() }) }}</button>
117
127
  </div>
118
128
 
119
- <div :class="['app-shell', { standalone: sessionStandalone, 'sidebar-collapsed': sidebarCollapsed }]">
129
+ <div :class="['app-shell', 'sidebar-collapsed', { standalone: sessionStandalone }]">
120
130
  <aside class="side-rail" v-if="!sessionStandalone">
121
- <button
122
- type="button"
123
- class="side-rail-collapse-toggle"
124
- :aria-pressed="sidebarCollapsed ? 'true' : 'false'"
125
- :aria-label="sidebarCollapsed ? t('side.expand') : t('side.collapse')"
126
- :title="sidebarCollapsed ? t('side.expand') : t('side.collapse')"
127
- @click="toggleSidebarCollapsed">
128
- <span aria-hidden="true">{{ sidebarCollapsed ? '›' : '‹' }}</span>
129
- </button>
130
131
  <div class="brand-block">
131
132
  <div class="brand-head">
132
133
  <img class="brand-logo" src="/res/logo-pack.webp" alt="Codex Mate logo">
@@ -267,6 +268,15 @@
267
268
 
268
269
  <div class="side-section" role="navigation" :aria-label="t('side.workspace')">
269
270
  <div class="side-section-title">{{ t('side.workspace') }}</div>
271
+ <button
272
+ id="side-tab-routing"
273
+ data-main-tab="routing"
274
+ :aria-current="mainTab === 'routing' ? 'page' : null"
275
+ :class="['side-item', { active: isMainTabNavActive('routing') }]"
276
+ @pointerdown="onMainTabPointerDown('routing', $event)"
277
+ @click="onMainTabClick('routing', $event)">
278
+ <div class="side-item-title">{{ t('tab.routing') }}</div>
279
+ </button>
270
280
  <button
271
281
  id="side-tab-sessions"
272
282
  data-main-tab="sessions"
@@ -356,6 +366,17 @@
356
366
  <span>{{ t('plugins.textTools.tools.compress') }}</span>
357
367
  </div>
358
368
  </button>
369
+ <button
370
+ id="side-tab-plugins-file-sharing"
371
+ data-main-tab="plugins"
372
+ data-plugins-id="file-sharing"
373
+ :aria-current="mainTab === 'plugins' && pluginsActiveId === 'file-sharing' ? 'page' : null"
374
+ :class="['side-item', { active: isPluginsIdNavActive('file-sharing') }]"
375
+ @pointerdown="onPluginsTabPointerDown('file-sharing', $event)"
376
+ @click="onPluginsTabClick('file-sharing', $event)">
377
+ <span class="side-item-icon" aria-hidden="true">⇩</span>
378
+ <div class="side-item-title">{{ t('plugins.fileSharing.title') }}</div>
379
+ </button>
359
380
  </div>
360
381
 
361
382
  <div class="side-section" role="navigation" :aria-label="t('side.system')">
@@ -402,7 +423,7 @@
402
423
  aria-haspopup="menu"
403
424
  @click="toggleLanguageMenu"
404
425
  @keydown.esc.prevent="closeLanguageMenu">
405
- {{ t('settings.language.sideLabel', { language: currentLanguageLabel() }) }}
426
+ {{ currentLanguageLabel() }}
406
427
  <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6l4 4 4-4"/></svg>
407
428
  </button>
408
429
  <div v-if="languageMenuOpen" class="side-language-dropdown" role="menu" @focusout="handleLanguageMenuFocusOut">
@@ -439,7 +460,7 @@
439
460
  <div class="main-panel-topbar">
440
461
  <div class="panel-header panel-header-refined" v-if="!sessionStandalone">
441
462
  <div class="panel-header-copy">
442
- <div class="panel-kicker">{{ mainTabKicker }}</div>
463
+ <div v-if="mainTabKicker" class="panel-kicker">{{ mainTabKicker }}</div>
443
464
  <h1 class="main-title">{{ mainTabTitle }}</h1>
444
465
  </div>
445
466
  </div>
@@ -1,3 +1,18 @@
1
+ <div v-if="showAppUpdateModal" class="modal-overlay" @click.self="closeAppUpdateModal">
2
+ <div class="modal app-update-modal" role="dialog" aria-modal="true" aria-labelledby="app-update-title" aria-describedby="app-update-versions app-update-hint">
3
+ <div id="app-update-title" class="modal-title">{{ t('side.update.available') }}</div>
4
+ <div id="app-update-versions" class="form-group confirm-dialog-message">{{ t('side.update.metaVersions', { current: normalizePackageVersion(appVersion), latest: normalizePackageVersion(appLatestVersion) }) }}</div>
5
+ <div class="docs-command-box">
6
+ <input id="app-update-command" class="install-command" type="text" :value="appUpdateCommand()" readonly :aria-label="t('common.command')" @focus="$event.target.select()">
7
+ <button type="button" class="btn-mini docs-copy-btn" @click="copyInstallCommand(appUpdateCommand())">{{ t('common.copy') }}</button>
8
+ </div>
9
+ <p id="app-update-hint" class="form-hint">{{ t('side.update.commandHint') }}</p>
10
+ <div class="btn-group">
11
+ <button type="button" class="btn btn-cancel" @click="closeAppUpdateModal">{{ t('common.close') }}</button>
12
+ </div>
13
+ </div>
14
+ </div>
15
+
1
16
  <!-- 添加提供商模态框 -->
2
17
  <div v-if="showAddModal" class="modal-overlay" @click.self="closeAddModal">
3
18
  <div class="modal" role="dialog" aria-modal="true" aria-labelledby="add-provider-modal-title">