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
@@ -0,0 +1,126 @@
1
+ const http = require('http');
2
+ const https = require('https');
3
+ const { modelTestClientHeaders } = require('./model-test-client');
4
+ const { buildApiProbeUrlCandidates, extractModelResponseText } = require('./cli-models-utils');
5
+
6
+ const MAX_PROMPT_LENGTH = 8000;
7
+ const MAX_RESPONSE_BYTES = 256 * 1024;
8
+ const MAX_OUTPUT_TOKENS = 2048;
9
+ const SUPPORTED_APIS = new Set(['responses', 'chat_completions', 'completions', 'anthropic-messages']);
10
+ const PI_NON_STANDARD_PROVIDERS = new Set(['cerebras', 'xai', 'zai', 'opencode']);
11
+
12
+ function buildTestRequest(provider, model, prompt) {
13
+ const api = provider.api;
14
+ if (!SUPPORTED_APIS.has(api)) throw new Error('此配置的接口暂不支持真实测试');
15
+ const paths = { responses: 'responses', chat_completions: 'chat/completions', completions: 'completions', 'anthropic-messages': 'messages' };
16
+ const url = buildApiProbeUrlCandidates(provider.baseUrl, paths[api])[0];
17
+ const key = (provider.apiKey || '').replace(/^Bearer\s+/i, '');
18
+ const authentication = api === 'anthropic-messages'
19
+ ? { 'anthropic-version': '2023-06-01', ...(key ? { 'x-api-key': key } : {}) }
20
+ : key ? { authorization: `Bearer ${key}` } : {};
21
+ const headers = Object.fromEntries([
22
+ ...Object.entries(provider.clientHeaders || {}), ...Object.entries(authentication),
23
+ ...Object.entries(provider.headers || {})
24
+ ].map(([name, value]) => [name.toLowerCase(), value]));
25
+ const maxTokens = Number.isFinite(provider.maxTokens) && provider.maxTokens > 0
26
+ ? Math.min(provider.maxTokens, MAX_OUTPUT_TOKENS) : MAX_OUTPUT_TOKENS;
27
+ let body;
28
+ if (api === 'responses') {
29
+ body = { model, input: [{ role: 'user', content: [{ type: 'input_text', text: prompt }] }],
30
+ store: false, max_output_tokens: maxTokens, stream: false };
31
+ if (provider.target === 'codex') {
32
+ body.instructions = '';
33
+ body.parallel_tool_calls = false;
34
+ if (provider.reasoningEffort) body.reasoning = { effort: provider.reasoningEffort };
35
+ if (provider.reasoningSummary && provider.reasoningSummary !== 'none') {
36
+ body.reasoning = { ...body.reasoning, summary: provider.reasoningSummary };
37
+ }
38
+ if (provider.verbosity) body.text = { verbosity: provider.verbosity };
39
+ }
40
+ } else if (api === 'completions') {
41
+ body = { model, prompt, max_tokens: maxTokens, stream: false };
42
+ } else {
43
+ body = { model, messages: [{ role: 'user', content: prompt }], stream: false };
44
+ const isPiChat = provider.target === 'pi' && api === 'chat_completions';
45
+ const maxTokensField = isPiChat && provider.compat?.maxTokensField !== 'max_tokens' && !url.includes('chutes.ai')
46
+ ? 'max_completion_tokens' : 'max_tokens';
47
+ body[maxTokensField] = maxTokens;
48
+ const isNonStandard = PI_NON_STANDARD_PROVIDERS.has(provider.name) || /cerebras\.ai|api\.x\.ai|chutes\.ai|deepseek\.com|api\.z\.ai|opencode\.ai/.test(url);
49
+ if (isPiChat && (provider.compat?.supportsStore ?? !isNonStandard)) body.store = false;
50
+ }
51
+ return { url, headers, body };
52
+ }
53
+
54
+ function requestModel({ url, headers, body }, { timeoutMs = 0, maxBytes = MAX_RESPONSE_BYTES } = {}) {
55
+ return new Promise((resolve, reject) => {
56
+ const parsed = new URL(url);
57
+ if (!['http:', 'https:'].includes(parsed.protocol)) throw new Error('供应商地址必须使用 HTTP 或 HTTPS');
58
+ const payload = JSON.stringify(body);
59
+ const transport = parsed.protocol === 'https:' ? https : http;
60
+ // A single request, no probe fallback or retry: a test can incur usage charges.
61
+ const request = transport.request(parsed, { method: 'POST', headers: {
62
+ ...headers, 'Content-Type': 'application/json', Accept: 'application/json', 'Content-Length': Buffer.byteLength(payload)
63
+ } }, response => {
64
+ const chunks = [];
65
+ let size = 0;
66
+ response.on('data', chunk => {
67
+ size += chunk.length;
68
+ if (size > maxBytes) {
69
+ reject(new Error('回复超过 256 KiB,测试已停止'));
70
+ response.destroy(); request.destroy(); return;
71
+ }
72
+ chunks.push(chunk);
73
+ });
74
+ response.on('error', reject);
75
+ response.on('aborted', () => reject(new Error('上游回复中断')));
76
+ response.on('end', () => resolve({ status: response.statusCode, body: Buffer.concat(chunks).toString('utf8') }));
77
+ });
78
+ if (timeoutMs > 0) {
79
+ const timer = setTimeout(() => {
80
+ reject(new Error('测试等待超时'));
81
+ request.destroy();
82
+ }, timeoutMs);
83
+ request.on('close', () => clearTimeout(timer));
84
+ }
85
+ request.on('error', error => reject(new Error(`连接失败:${error.code || 'network-error'}`)));
86
+ request.end(payload);
87
+ });
88
+ }
89
+
90
+ function createModelTestService({ providers, request = requestModel, clientHeaders = modelTestClientHeaders }) {
91
+ function catalog() {
92
+ return Object.fromEntries(['codex', 'pi'].map(target => [target, providers(target).map(provider => ({
93
+ name: provider.name, models: provider.models, supported: SUPPORTED_APIS.has(provider.api)
94
+ }))]));
95
+ }
96
+ async function run(params = {}) {
97
+ const started = Date.now();
98
+ const identity = { target: params.target, provider: params.provider, model: params.model };
99
+ const elapsed = () => Date.now() - started;
100
+ try {
101
+ const { target, provider: name, model, prompt } = params;
102
+ if (!['codex', 'pi'].includes(target)) throw new Error('测试仅支持 Codex 和 Pi');
103
+ if (typeof prompt !== 'string' || !prompt.trim() || prompt.length > MAX_PROMPT_LENGTH) throw new Error('输入 1–8000 字符的测试内容');
104
+ const provider = providers(target).find(entry => entry.name === name);
105
+ if (!provider || !provider.models.includes(model)) throw new Error('请选择已有供应商与模型,刷新后重试');
106
+ if (provider.error) throw new Error(provider.error);
107
+ const selected = { ...provider, ...provider.modelOptions?.[model], target };
108
+ selected.clientHeaders = clientHeaders(target, selected.api);
109
+ const result = await request(buildTestRequest(selected, model, prompt.trim()));
110
+ if (result.status < 200 || result.status >= 300) return { ...identity, ok: false, status: result.status, durationMs: elapsed(), error: `HTTP ${result.status}` };
111
+ let payload;
112
+ try { payload = JSON.parse(result.body); } catch (_) { throw new Error('上游未返回有效 JSON 回复'); }
113
+ if (payload.error) throw new Error('上游返回错误,未生成回复');
114
+ const text = extractModelResponseText(payload);
115
+ if (!text) throw new Error('上游未返回可显示的回复内容');
116
+ const incomplete = payload.status === 'incomplete' || payload.choices?.[0]?.finish_reason === 'length' || payload.stop_reason === 'max_tokens';
117
+ return { ...identity, ok: true, status: result.status, durationMs: elapsed(), text, incomplete,
118
+ responseModel: typeof payload.model === 'string' ? payload.model : model };
119
+ } catch (error) {
120
+ return { ...identity, ok: false, durationMs: elapsed(), error: error.message };
121
+ }
122
+ }
123
+ return { catalog, run };
124
+ }
125
+
126
+ module.exports = { createModelTestService, buildTestRequest, requestModel };
@@ -0,0 +1,161 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const crypto = require('crypto');
5
+
6
+ const OPENAI_CHAT_TARGET = 'openai-chat';
7
+ const TARGETS = new Set(['codex', 'claude', OPENAI_CHAT_TARGET]);
8
+ const STRATEGIES = new Set(['order', 'rotate']);
9
+ const MAX_GROUPS = 64;
10
+ const MAX_MEMBERS = 16;
11
+ const MAX_NAME_LENGTH = 128;
12
+ const MAX_MODEL_LENGTH = 256;
13
+ const VERSION = 1;
14
+ const MAX_STORAGE_BYTES = 2 * 1024 * 1024;
15
+
16
+ function routeError(code, message) {
17
+ const error = new Error(message);
18
+ error.code = code;
19
+ return error;
20
+ }
21
+ function revisionOf(source) {
22
+ return crypto.createHash('sha256').update(source).digest('hex');
23
+ }
24
+ function validText(value, limit) {
25
+ return typeof value === 'string' && value.trim() && value.trim().length <= limit;
26
+ }
27
+ function validateGroup(group) {
28
+ if (!group || !validText(group.name, MAX_NAME_LENGTH) || !TARGETS.has(group.target) || !STRATEGIES.has(group.strategy)) {
29
+ throw routeError('routing-invalid', '路由组名称、目标或策略无效');
30
+ }
31
+ if (!Array.isArray(group.members) || !group.members.length || group.members.length > MAX_MEMBERS) {
32
+ throw routeError('routing-invalid', '每组需要 1–16 个成员');
33
+ }
34
+ const seen = new Set();
35
+ const members = group.members.map(member => {
36
+ if (!member || !validText(member.provider, MAX_NAME_LENGTH) || !validText(member.model, MAX_MODEL_LENGTH)) {
37
+ throw routeError('routing-invalid', '成员必须指定供应商与模型');
38
+ }
39
+ const normalized = { provider: member.provider.trim(), model: member.model.trim() };
40
+ const key = JSON.stringify(normalized);
41
+ if (seen.has(key)) throw routeError('routing-invalid', '成员不能重复');
42
+ seen.add(key);
43
+ return normalized;
44
+ });
45
+ return { id: group.id, name: group.name.trim(), target: group.target, strategy: group.strategy, members };
46
+ }
47
+
48
+ function createRoutingGroups({ filePath, assertAllowed, catalog }) {
49
+ function read() {
50
+ if (fs.existsSync(filePath) && fs.statSync(filePath).size > MAX_STORAGE_BYTES) throw routeError('routing-corrupt', '路由组文件超过 2 MiB');
51
+ const source = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
52
+ const state = source ? JSON.parse(source) : { version: VERSION, groups: [], bindings: { codex: '', claude: '' } };
53
+ if (!state || state.version !== VERSION || !Array.isArray(state.groups) || !state.bindings || state.groups.length > MAX_GROUPS) {
54
+ throw routeError('routing-corrupt', '路由组文件格式无效');
55
+ }
56
+ if (state.bindings[OPENAI_CHAT_TARGET] === undefined) state.bindings[OPENAI_CHAT_TARGET] = '';
57
+ const ids = new Set();
58
+ state.groups = state.groups.map(group => {
59
+ if (!validText(group.id, MAX_NAME_LENGTH) || ids.has(group.id)) throw routeError('routing-corrupt', '路由组标识无效');
60
+ ids.add(group.id);
61
+ return validateGroup(group);
62
+ });
63
+ for (const target of TARGETS) {
64
+ const id = state.bindings[target];
65
+ if (typeof id !== 'string' || (id && !state.groups.some(group => group.id === id && group.target === target))) {
66
+ throw routeError('routing-corrupt', '路由绑定无效');
67
+ }
68
+ }
69
+ return { version: VERSION, groups: state.groups, bindings: Object.fromEntries([...TARGETS].map(target => [target, state.bindings[target]])), revision: revisionOf(source) };
70
+ }
71
+ function write(state, expectedRevision) {
72
+ if (read().revision !== expectedRevision) throw routeError('routing-conflict', '路由组已被修改,请刷新后重试');
73
+ const source = JSON.stringify({ version: VERSION, groups: state.groups, bindings: state.bindings }, null, 2) + '\n';
74
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
75
+ const temporary = filePath + '.' + crypto.randomBytes(8).toString('hex') + '.tmp';
76
+ try {
77
+ fs.writeFileSync(temporary, source, { mode: 0o600, flag: 'wx' });
78
+ fs.renameSync(temporary, filePath);
79
+ } finally {
80
+ if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
81
+ }
82
+ return { ...state, revision: revisionOf(source) };
83
+ }
84
+ function checkRevision(state, revision) {
85
+ if (revision !== state.revision) throw routeError('routing-conflict', '路由组已被修改,请刷新后重试');
86
+ }
87
+ function checkMembers(group) {
88
+ const names = new Set(catalog(group.target).map(entry => entry.name));
89
+ if (group.members.some(member => !names.has(member.provider))) {
90
+ throw routeError('routing-provider-missing', '成员供应商不存在或已排除');
91
+ }
92
+ }
93
+ function save(params) {
94
+ const state = read();
95
+ checkRevision(state, params.revision);
96
+ const previous = params.id ? state.groups.find(group => group.id === params.id) : null;
97
+ if (params.id && !previous) throw routeError('routing-not-found', '路由组不存在');
98
+ const group = validateGroup({ ...params, id: previous ? previous.id : crypto.randomBytes(12).toString('hex') });
99
+ if (previous && previous.target !== group.target) throw routeError('routing-invalid', '已有路由组不能更换目标工具');
100
+ assertAllowed(group.target);
101
+ checkMembers(group);
102
+ if (state.groups.some(item => item.id !== group.id && item.target === group.target && item.name === group.name)) {
103
+ throw routeError('routing-invalid', '同一工具的路由组名称不能重复');
104
+ }
105
+ if (!previous && state.groups.length >= MAX_GROUPS) throw routeError('routing-invalid', '最多保存 64 个路由组');
106
+ state.groups = previous ? state.groups.map(item => item.id === group.id ? group : item) : [...state.groups, group];
107
+ return write(state, params.revision);
108
+ }
109
+ function remove(params) {
110
+ const state = read();
111
+ checkRevision(state, params.revision);
112
+ const group = state.groups.find(item => item.id === params.id);
113
+ if (!group) throw routeError('routing-not-found', '路由组不存在');
114
+ assertAllowed(group.target);
115
+ if (state.bindings[group.target] === group.id) throw routeError('routing-in-use', '请先解除绑定再删除路由组');
116
+ state.groups = state.groups.filter(item => item.id !== group.id);
117
+ return write(state, params.revision);
118
+ }
119
+ function bind(params) {
120
+ const state = read();
121
+ checkRevision(state, params.revision);
122
+ if (!TARGETS.has(params.target) || typeof params.id !== 'string') throw routeError('routing-invalid', '路由绑定参数无效');
123
+ assertAllowed(params.target);
124
+ if (params.id) {
125
+ const group = state.groups.find(item => item.id === params.id && item.target === params.target);
126
+ if (!group) throw routeError('routing-not-found', '路由组不存在或工具不匹配');
127
+ checkMembers(group);
128
+ }
129
+ state.bindings[params.target] = params.id;
130
+ return write(state, params.revision);
131
+ }
132
+ function resolve(target) {
133
+ const state = read();
134
+ const id = state.bindings[target];
135
+ if (!id) return null;
136
+ const group = state.groups.find(item => item.id === id && item.target === target);
137
+ const entries = catalog(target);
138
+ const members = group.members.map(member => {
139
+ const entry = entries.find(item => item.name === member.provider);
140
+ return entry ? { ...entry, model: member.model } : null;
141
+ }).filter(Boolean);
142
+ if (!members.length) throw routeError('routing-no-upstream', '绑定路由组没有可用成员,请检查供应商与排除设置');
143
+ return { ...group, members };
144
+ }
145
+ return { read, save, remove, bind, resolve };
146
+ }
147
+
148
+ function createRoutingScheduler() {
149
+ const positions = new Map();
150
+ return group => {
151
+ if (group.strategy === 'order') return group.members;
152
+ const signature = JSON.stringify([group.strategy, group.members.map(member => [member.name, member.model])]);
153
+ const previous = positions.get(group.id);
154
+ const index = previous && previous.signature === signature ? previous.index % group.members.length : 0;
155
+ positions.delete(group.id);
156
+ positions.set(group.id, { signature, index: index + 1 });
157
+ while (positions.size > MAX_GROUPS) positions.delete(positions.keys().next().value);
158
+ return [...group.members.slice(index), ...group.members.slice(0, index)];
159
+ };
160
+ }
161
+ module.exports = { createRoutingGroups, createRoutingScheduler, OPENAI_CHAT_TARGET };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexmate",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "Codex/Claude Code/OpenClaw 配置、会话与任务编排 CLI + Web 工具",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -0,0 +1,10 @@
1
+ export const fileSharingPluginMeta = {
2
+ id: 'file-sharing',
3
+ title: 'File Sharing',
4
+ titleKey: 'plugins.fileSharing.title',
5
+ statusLabel: 'standard',
6
+ statusLabelKey: 'plugins.status.standard',
7
+ tone: 'configured'
8
+ };
9
+
10
+ export { fileSharingPluginMeta as pluginMeta };
@@ -0,0 +1,101 @@
1
+ import { authorizationHeaders, withAccessToken } from '../../web-ui/modules/access-token.mjs';
2
+
3
+ const FILE_SHARING_ROUTE = '/api/file-sharing';
4
+ const MAX_SHARE_MANIFEST_BYTES = 512 * 1024;
5
+ const FILE_SHARING_ERRORS = new Set(['emptyFolder', 'invalid', 'busy', 'notFound', 'lanUnavailable', 'failed']);
6
+
7
+ async function requestFileSharing(suffix = '', options = {}) {
8
+ const response = await fetch(FILE_SHARING_ROUTE + suffix, {
9
+ ...options,
10
+ headers: authorizationHeaders(options.headers),
11
+ cache: 'no-store'
12
+ });
13
+ const payload = await response.json();
14
+ if (!response.ok) throw new Error(FILE_SHARING_ERRORS.has(payload.error) ? payload.error : 'failed');
15
+ return payload;
16
+ }
17
+
18
+ function fileSharingMessage(t, error) {
19
+ return t(`plugins.fileSharing.${FILE_SHARING_ERRORS.has(error.message) ? error.message : 'failed'}`);
20
+ }
21
+
22
+ export function createFileSharingMethods() {
23
+ return {
24
+ async refreshFileSharing() {
25
+ return this.runFileSharingAction(async () => {
26
+ this.fileSharingBatches = (await requestFileSharing()).batches;
27
+ });
28
+ },
29
+ selectFileSharingItems(event, isFolder) {
30
+ const input = event.target;
31
+ const files = Array.from(input.files || []);
32
+ input.value = '';
33
+ if (this.fileSharingBusy) return;
34
+ this.fileSharingError = '';
35
+ if (!files.length) {
36
+ if (isFolder) this.fileSharingError = this.t('plugins.fileSharing.emptyFolder');
37
+ return;
38
+ }
39
+ const entries = files.map(file => ({ name: isFolder ? file.webkitRelativePath : file.name, size: file.size }));
40
+ const folder = isFolder ? entries[0].name.split('/')[0] : '';
41
+ const bytes = new TextEncoder().encode(JSON.stringify({ folder, files: entries }));
42
+ if (bytes.length > MAX_SHARE_MANIFEST_BYTES) {
43
+ this.fileSharingError = this.t('plugins.fileSharing.invalid');
44
+ return;
45
+ }
46
+ const prefix = new ArrayBuffer(4);
47
+ new DataView(prefix).setUint32(0, bytes.length);
48
+ this.fileSharingPending = { entries, body: new Blob([prefix, bytes, ...files]) };
49
+ },
50
+ async runFileSharingAction(action) {
51
+ if (this.fileSharingBusy) return false;
52
+ this.fileSharingBusy = true;
53
+ this.fileSharingError = '';
54
+ try {
55
+ await action();
56
+ return true;
57
+ } catch (error) {
58
+ this.fileSharingError = fileSharingMessage(this.t, error);
59
+ return false;
60
+ } finally {
61
+ this.fileSharingBusy = false;
62
+ }
63
+ },
64
+ async uploadFileSharingItems() {
65
+ if (!this.fileSharingPending) return;
66
+ await this.runFileSharingAction(async () => {
67
+ const { batch } = await requestFileSharing('', {
68
+ method: 'POST', headers: { 'Content-Type': 'application/octet-stream' }, body: this.fileSharingPending.body
69
+ });
70
+ this.fileSharingPending = null;
71
+ this.fileSharingBatches.push(batch);
72
+ });
73
+ },
74
+ async removeFileSharingBatch(id) {
75
+ await this.runFileSharingAction(async () => {
76
+ await requestFileSharing(`/${id}`, { method: 'DELETE' });
77
+ this.fileSharingBatches = this.fileSharingBatches.filter(batch => batch.id !== id);
78
+ });
79
+ },
80
+ async copyFileSharingLink(id, index) {
81
+ await this.runFileSharingAction(async () => {
82
+ const { url } = await requestFileSharing(`/${id}/${index}/link`, { method: 'POST' });
83
+ let copied = false;
84
+ try {
85
+ if (navigator.clipboard?.writeText) {
86
+ await navigator.clipboard.writeText(url);
87
+ copied = true;
88
+ }
89
+ } catch (_) { /* HTTP and restricted contexts use the fallback. */ }
90
+ if (copied || this.fallbackCopyText(url)) {
91
+ this.showMessage(this.t('toast.copy.ok'), 'success');
92
+ } else {
93
+ window.prompt(this.t('plugins.fileSharing.copyManually'), url);
94
+ }
95
+ });
96
+ },
97
+ fileSharingDownloadUrl(id, index) {
98
+ return withAccessToken(`${FILE_SHARING_ROUTE}/${id}/${index}`);
99
+ }
100
+ };
101
+ }
@@ -0,0 +1,3 @@
1
+ export async function loadFileSharingOverview(app) {
2
+ return app.refreshFileSharing();
3
+ }
@@ -0,0 +1,5 @@
1
+ export const pluginOwnership = {
2
+ pluginId: 'file-sharing',
3
+ createdBy: 'ymkiux',
4
+ maintainers: ['ymkiux']
5
+ };
@@ -1,9 +1,12 @@
1
+ import { fileSharingPluginMeta } from './file-sharing/manifest.mjs';
2
+ import { loadFileSharingOverview } from './file-sharing/overview.mjs';
1
3
  import { promptTemplatesPluginMeta } from './prompt-templates/manifest.mjs';
2
4
  import { loadPromptTemplatesOverview } from './prompt-templates/overview.mjs';
3
5
  import { textToolsPluginMeta } from './text-tools/manifest.mjs';
4
6
  import { loadTextToolsOverview } from './text-tools/overview.mjs';
5
7
 
6
8
  export const pluginsRegistry = [
9
+ { id: fileSharingPluginMeta.id, meta: fileSharingPluginMeta, loadOverview: loadFileSharingOverview },
7
10
  { id: promptTemplatesPluginMeta.id, meta: promptTemplatesPluginMeta, loadOverview: loadPromptTemplatesOverview },
8
11
  { id: textToolsPluginMeta.id, meta: textToolsPluginMeta, loadOverview: loadTextToolsOverview }
9
12
  ];
package/web-ui/app.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { modelTestMixin } from './modules/model-test.mjs';
1
2
  import { configChangeMixin } from './modules/app.methods.config-changes.mjs';
2
3
  import { threadHandoffMixin } from './modules/thread-handoff.mjs';
3
4
  import { sessionFeaturesMixin } from './modules/session-features.mjs';
@@ -181,6 +182,10 @@ document.addEventListener('DOMContentLoaded', () => {
181
182
  pluginsError: '',
182
183
  textToolsActiveToolId: '',
183
184
  textToolsInput: '',
185
+ fileSharingBatches: [],
186
+ fileSharingPending: null,
187
+ fileSharingBusy: false,
188
+ fileSharingError: '',
184
189
  promptTemplatesListRaw: [],
185
190
  promptTemplatesLoadedOnce: false,
186
191
  promptTemplatesKeyword: '',
@@ -262,6 +267,12 @@ document.addEventListener('DOMContentLoaded', () => {
262
267
  agentsModalHint: '保存后会写入目标 AGENTS.md(与 config.toml 同级)。',
263
268
  sysPromptScope: 'global',
264
269
  sysPromptMode: 'system',
270
+ sysPromptFileName: '',
271
+ sysPromptFiles: [],
272
+ sysPromptFilesLoading: false,
273
+ sysPromptFilesError: '',
274
+ sysPromptFileMissing: false,
275
+ _sysPromptFilesRequestToken: null,
265
276
  sysPromptContent: '',
266
277
  sysPromptOriginalContent: '',
267
278
  sysPromptPath: '',
@@ -442,6 +453,7 @@ document.addEventListener('DOMContentLoaded', () => {
442
453
  installRegistryCustom: '',
443
454
  installStatusTargets: null,
444
455
  appLatestVersion: '',
456
+ showAppUpdateModal: false,
445
457
  appVersionStatusLoading: false,
446
458
  appVersionStatusError: '',
447
459
  appVersionStatusChecked: false,
@@ -612,7 +624,7 @@ document.addEventListener('DOMContentLoaded', () => {
612
624
  kilocodeShowKey: false,
613
625
  kilocodeAutoSaveSignature: '',
614
626
  forceCompactLayout: false,
615
- sidebarCollapsed: false,
627
+ sidebarCollapsed: true,
616
628
  theme: 'light',
617
629
  sessionLoadNativeDialog: false,
618
630
  starPrompted: false,
@@ -680,7 +692,7 @@ document.addEventListener('DOMContentLoaded', () => {
680
692
  this.agentsModalHint = this.t('modal.agents.hint');
681
693
  }
682
694
  {
683
- const mainTabSet = new Set(['dashboard', 'config', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
695
+ const mainTabSet = new Set(['dashboard', 'config', 'routing', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
684
696
  let urlMainTab = '';
685
697
  try {
686
698
  const url = new URL(window.location.href);
@@ -958,6 +970,7 @@ document.addEventListener('DOMContentLoaded', () => {
958
970
  appOptions.render = window.__CODEXMATE_WEB_UI_RENDER__;
959
971
  }
960
972
 
973
+ appOptions.mixins.push(modelTestMixin);
961
974
  appOptions.mixins.push(sessionFeaturesMixin);
962
975
  const app = createApp(appOptions);
963
976
  app.config.errorHandler = (err, vm, info) => {
package/web-ui/index.html CHANGED
@@ -12,12 +12,12 @@
12
12
  <script src="/res/purify.min.js"></script>
13
13
  <link rel="stylesheet" href="/web-ui/styles.css">
14
14
  <script>
15
- // Render hint: skip the light flash for dark-theme users before the
15
+ // Render hint: restore the selected theme before the
16
16
  // server preference store loads. Kept in sync by applyDocumentTheme().
17
17
  (function () {
18
18
  try {
19
19
  var cachedTheme = localStorage.getItem('codexmateThemeCache');
20
- if (cachedTheme === 'dark' || cachedTheme === 'ocean') {
20
+ if (cachedTheme === 'dark' || cachedTheme === 'ocean' || cachedTheme === 'violet') {
21
21
  document.documentElement.setAttribute('data-theme', cachedTheme);
22
22
  }
23
23
  } catch (_) {}
@@ -35,6 +35,7 @@
35
35
  <!-- @include ./partials/index/panel-config-kilocode.html -->
36
36
  <!-- @include ./partials/index/panel-config-pi.html -->
37
37
  <!-- @include ./partials/index/modals-pi-provider.html -->
38
+ <!-- @include ./partials/index/panel-routing.html -->
38
39
  <!-- @include ./partials/index/panel-sessions.html -->
39
40
  <!-- @include ./partials/index/panel-usage.html -->
40
41
  <!-- @include ./partials/index/panel-docs.html -->
@@ -3,6 +3,7 @@ export function createMainTabsComputed() {
3
3
  mainTabKicker() {
4
4
  if (this.mainTab === 'dashboard') return this.t('kicker.dashboard');
5
5
  if (this.mainTab === 'config') return this.t('kicker.config');
6
+ if (this.mainTab === 'routing') return '';
6
7
  if (this.mainTab === 'sessions') return this.t('kicker.sessions');
7
8
  if (this.mainTab === 'usage') return this.t('kicker.usage');
8
9
  if (this.mainTab === 'market') return this.t('kicker.market');
@@ -15,6 +16,7 @@ export function createMainTabsComputed() {
15
16
  mainTabTitle() {
16
17
  if (this.mainTab === 'dashboard') return this.t('title.dashboard');
17
18
  if (this.mainTab === 'config') return this.t('title.config');
19
+ if (this.mainTab === 'routing') return this.t('title.routing');
18
20
  if (this.mainTab === 'sessions') return this.t('title.sessions');
19
21
  if (this.mainTab === 'usage') return this.t('title.usage');
20
22
  if (this.mainTab === 'market') return this.t('title.market');
@@ -27,6 +29,7 @@ export function createMainTabsComputed() {
27
29
  mainTabSubtitle() {
28
30
  if (this.mainTab === 'dashboard') return this.t('subtitle.dashboard');
29
31
  if (this.mainTab === 'config') return this.t('subtitle.config');
32
+ if (this.mainTab === 'routing') return '';
30
33
  if (this.mainTab === 'sessions') return this.t('subtitle.sessions');
31
34
  if (this.mainTab === 'usage') return this.t('subtitle.usage');
32
35
  if (this.mainTab === 'market') return this.t('subtitle.market');
@@ -293,6 +293,16 @@ export function createAgentsMethods(options = {}) {
293
293
  if (!event) {
294
294
  return;
295
295
  }
296
+ if (this.showAppUpdateModal && !this.showConfirmDialog) {
297
+ if (event.key === 'Escape') {
298
+ event.preventDefault();
299
+ event.stopPropagation();
300
+ this.closeAppUpdateModal();
301
+ } else if (event.key === 'Tab') {
302
+ this.trapModalFocus(event);
303
+ }
304
+ return;
305
+ }
296
306
  const isCmdLike = !!(event.metaKey || event.ctrlKey);
297
307
  const key = typeof event.key === 'string' ? event.key : '';
298
308
  const isSearchHotkey = isCmdLike && !event.altKey && (key === 'k' || key === 'K');
@@ -1080,6 +1090,8 @@ export function createAgentsMethods(options = {}) {
1080
1090
  loadPromptsTabContent() {
1081
1091
  if (typeof this.loadPromptsPathReferences === "function") this.loadPromptsPathReferences();
1082
1092
  if (this.promptsSubTab === 'system') {
1093
+ if (typeof this.loadSystemPromptFiles === 'function') this.loadSystemPromptFiles();
1094
+ if (this.sysPromptLoading || this.sysPromptSaving || this.sysPromptDiffVisible || this.hasSysPromptContentChanged()) return;
1083
1095
  if (typeof this.loadSystemPrompt === 'function') this.loadSystemPrompt();
1084
1096
  } else {
1085
1097
  if (this.promptsSubTab === 'claude-project' && !this.projectPathOptions.length && !this.projectPathOptionsLoading && typeof this.loadProjectPathOptions === 'function') {
@@ -1,3 +1,5 @@
1
+ const APP_UPDATE_COMMAND = 'codexmate update';
2
+
1
3
  export function createInstallMethods(options = {}) {
2
4
  const { api } = options;
3
5
  return {
@@ -91,14 +93,32 @@ export function createInstallMethods(options = {}) {
91
93
  return suffix ? `${meta} · ${suffix}` : meta;
92
94
  },
93
95
 
94
- handleAppVersionStatusClick() {
95
- if (this.isAppUpdateAvailable()) {
96
- this.openAppUpdateDocs();
96
+ handleAppVersionStatusClick(event) {
97
+ if (this.appVersionStatusLoading) return;
98
+ if (!this.appVersionStatusError && this.isAppUpdateAvailable()) {
99
+ this.openAppUpdateModal(event?.currentTarget);
97
100
  return;
98
101
  }
99
102
  void this.loadAppVersionStatus({ silent: false, force: true });
100
103
  },
101
104
 
105
+ appUpdateCommand() {
106
+ return APP_UPDATE_COMMAND;
107
+ },
108
+
109
+ openAppUpdateModal(trigger) {
110
+ this._appUpdateTrigger = trigger || document.activeElement;
111
+ this.showAppUpdateModal = true;
112
+ this.$nextTick(() => document.getElementById('app-update-command')?.focus());
113
+ },
114
+
115
+ closeAppUpdateModal() {
116
+ const trigger = this._appUpdateTrigger;
117
+ this._appUpdateTrigger = null;
118
+ this.showAppUpdateModal = false;
119
+ this.$nextTick(() => trigger?.focus());
120
+ },
121
+
102
122
  async loadAppVersionStatus(options = {}) {
103
123
  if (typeof api !== 'function') return false;
104
124
  if (this.appVersionStatusLoading) return false;
@@ -7,6 +7,7 @@
7
7
  const MAIN_TAB_ORDER = [
8
8
  'dashboard',
9
9
  'config',
10
+ 'routing',
10
11
  'sessions',
11
12
  'usage',
12
13
  'market',
@@ -120,6 +121,7 @@
120
121
  settingsTab: settingsTab === 'data' ? 'data' : 'general',
121
122
  mainTab: resolveSelectableMainTab(mainTab),
122
123
  configMode: configModeSet && configModeSet.has(configMode) ? configMode : 'codex',
124
+ modelTestTarget: vm.modelTestTarget === 'pi' ? 'pi' : 'codex',
123
125
  skillsTargetApp,
124
126
  promptTemplatesMode,
125
127
  pluginsActiveId: pluginsActiveId || 'prompt-templates'