codexmate 0.1.32 → 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 (109) hide show
  1. package/README.md +18 -2
  2. package/README.vi.md +18 -2
  3. package/README.zh.md +18 -2
  4. package/cli/claude-proxy.js +2 -2
  5. package/cli/local-bridge.js +10 -6
  6. package/cli/openai-chat-routing.js +38 -0
  7. package/cli/prompt-history.js +2 -0
  8. package/cli/routing-bridge.js +143 -0
  9. package/cli/system-prompt-files.js +75 -53
  10. package/cli.js +325 -215
  11. package/lib/cli-config-engine.js +6 -1
  12. package/lib/cli-file-utils.js +6 -1
  13. package/lib/config-change-fs.js +132 -0
  14. package/lib/config-changes.js +293 -0
  15. package/lib/file-sharing-lan.js +111 -0
  16. package/lib/file-sharing.js +196 -0
  17. package/lib/handoff-mcp.js +18 -2
  18. package/lib/local-feature-store.js +39 -0
  19. package/lib/model-test-client.js +61 -0
  20. package/lib/model-test.js +126 -0
  21. package/lib/routing-groups.js +161 -0
  22. package/lib/session-bookmarks.js +72 -0
  23. package/lib/session-context-health.js +23 -3
  24. package/lib/session-diagnostics.js +75 -0
  25. package/lib/session-feature-settings.js +21 -0
  26. package/lib/session-features.js +63 -0
  27. package/lib/session-handoff-draft.js +43 -0
  28. package/lib/session-projects.js +76 -0
  29. package/lib/session-search-index.js +188 -0
  30. package/lib/thread-handoff.js +8 -0
  31. package/lib/web-server.js +216 -0
  32. package/package.json +1 -1
  33. package/plugins/file-sharing/manifest.mjs +10 -0
  34. package/plugins/file-sharing/methods.mjs +101 -0
  35. package/plugins/file-sharing/overview.mjs +3 -0
  36. package/plugins/file-sharing/ownership.mjs +5 -0
  37. package/plugins/registry.mjs +3 -0
  38. package/web-ui/app.js +22 -3
  39. package/web-ui/index.html +4 -2
  40. package/web-ui/logic.context-window.mjs +15 -0
  41. package/web-ui/modules/api.mjs +72 -39
  42. package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
  43. package/web-ui/modules/app.methods.agents.mjs +17 -0
  44. package/web-ui/modules/app.methods.claude-config.mjs +2 -0
  45. package/web-ui/modules/app.methods.codex-config.mjs +9 -0
  46. package/web-ui/modules/app.methods.config-changes.mjs +124 -0
  47. package/web-ui/modules/app.methods.install.mjs +23 -3
  48. package/web-ui/modules/app.methods.kilocode-config.mjs +2 -0
  49. package/web-ui/modules/app.methods.navigation.mjs +2 -0
  50. package/web-ui/modules/app.methods.openclaw-persist.mjs +2 -0
  51. package/web-ui/modules/app.methods.opencode-config.mjs +2 -0
  52. package/web-ui/modules/app.methods.pi-config.mjs +12 -3
  53. package/web-ui/modules/app.methods.prompts-editor.mjs +7 -4
  54. package/web-ui/modules/app.methods.provider-cache.mjs +9 -3
  55. package/web-ui/modules/app.methods.providers.mjs +6 -0
  56. package/web-ui/modules/app.methods.session-actions.mjs +2 -2
  57. package/web-ui/modules/app.methods.startup-claude.mjs +8 -47
  58. package/web-ui/modules/app.methods.system-prompt.mjs +88 -17
  59. package/web-ui/modules/app.methods.theme.mjs +4 -3
  60. package/web-ui/modules/app.methods.web-ui-preferences.mjs +7 -0
  61. package/web-ui/modules/config-change-actions.mjs +9 -0
  62. package/web-ui/modules/i18n/locales/en.mjs +254 -8
  63. package/web-ui/modules/i18n/locales/ja.mjs +254 -8
  64. package/web-ui/modules/i18n/locales/vi.mjs +254 -8
  65. package/web-ui/modules/i18n/locales/zh-tw.mjs +254 -8
  66. package/web-ui/modules/i18n/locales/zh.mjs +254 -8
  67. package/web-ui/modules/model-test.mjs +82 -0
  68. package/web-ui/modules/plugins.methods.mjs +3 -1
  69. package/web-ui/modules/prompt-ecosystem.methods.mjs +4 -3
  70. package/web-ui/modules/request-deadline.mjs +33 -0
  71. package/web-ui/modules/routing.mjs +206 -0
  72. package/web-ui/modules/session-features.mjs +279 -0
  73. package/web-ui/modules/thread-handoff.mjs +1 -1
  74. package/web-ui/partials/index/config-changes.html +25 -0
  75. package/web-ui/partials/index/context-window-reference.html +17 -0
  76. package/web-ui/partials/index/layout-header.html +40 -42
  77. package/web-ui/partials/index/modal-openclaw-config.html +0 -2
  78. package/web-ui/partials/index/modal-skills.html +0 -1
  79. package/web-ui/partials/index/modals-basic.html +15 -8
  80. package/web-ui/partials/index/modals-pi-provider.html +0 -1
  81. package/web-ui/partials/index/panel-config-codex.html +0 -3
  82. package/web-ui/partials/index/panel-config-openclaw.html +16 -13
  83. package/web-ui/partials/index/panel-dashboard.html +0 -2
  84. package/web-ui/partials/index/panel-plugins.html +3 -10
  85. package/web-ui/partials/index/panel-prompts.html +13 -8
  86. package/web-ui/partials/index/panel-routing.html +3 -0
  87. package/web-ui/partials/index/panel-sessions.html +9 -0
  88. package/web-ui/partials/index/panel-settings.html +12 -13
  89. package/web-ui/partials/index/panel-trash.html +0 -1
  90. package/web-ui/partials/index/plugin-file-sharing.html +47 -0
  91. package/web-ui/partials/index/routing-model-test.html +53 -0
  92. package/web-ui/partials/index/session-diagnostics.html +32 -0
  93. package/web-ui/partials/index/session-features.html +107 -0
  94. package/web-ui/partials/index/thread-handoff.html +6 -3
  95. package/web-ui/res/web-ui-render.precompiled.js +1689 -246
  96. package/web-ui/styles/base-theme.css +1 -1
  97. package/web-ui/styles/config-changes.css +30 -0
  98. package/web-ui/styles/modals-core.css +6 -5
  99. package/web-ui/styles/navigation-panels.css +4 -0
  100. package/web-ui/styles/openclaw-structured.css +205 -189
  101. package/web-ui/styles/plugins-panel.css +40 -1
  102. package/web-ui/styles/responsive.css +10 -5
  103. package/web-ui/styles/routing.css +78 -0
  104. package/web-ui/styles/session-features.css +258 -0
  105. package/web-ui/styles/settings-panel.css +30 -0
  106. package/web-ui/styles/system-prompt.css +8 -7
  107. package/web-ui/styles/theme-violet-tokens.css +52 -0
  108. package/web-ui/styles/theme-violet.css +1736 -0
  109. package/web-ui/styles.css +5 -1
@@ -0,0 +1,216 @@
1
+ function createWebServerLifecycle(options, dependencies) {
2
+ const { server, host, port, httpToken, openBrowser } = options;
3
+ const { http, spawn, process, console, setTimeout, formatHostForUrl, DEFAULT_WEB_OPEN_HOST, isAnyAddressHost, getUnattendedWorkflowRunner } = dependencies;
4
+ const connections = new Set();
5
+
6
+ const probeWebUiReadiness = (callback) => {
7
+ const payload = JSON.stringify({ action: 'health-check', params: {} });
8
+ const requestOptions = {
9
+ hostname: openHost,
10
+ port,
11
+ path: '/api',
12
+ method: 'POST',
13
+ headers: {
14
+ 'Content-Type': 'application/json; charset=utf-8',
15
+ 'Content-Length': Buffer.byteLength(payload, 'utf-8'),
16
+ ...(httpToken ? { Authorization: `Bearer ${httpToken}` } : {})
17
+ }
18
+ };
19
+ let settled = false;
20
+ const finish = (ready) => {
21
+ if (settled) return;
22
+ settled = true;
23
+ callback(ready);
24
+ };
25
+ const req = http.request(requestOptions, (probeRes) => {
26
+ if (typeof probeRes.resume === 'function') {
27
+ probeRes.resume();
28
+ }
29
+ probeRes.on('end', () => {
30
+ finish(probeRes.statusCode === 200);
31
+ });
32
+ });
33
+ req.on('error', () => finish(false));
34
+ req.setTimeout(1000, () => {
35
+ try { req.destroy(); } catch (_) { }
36
+ finish(false);
37
+ });
38
+ req.end(payload, 'utf-8');
39
+ };
40
+
41
+ const probeWebUiAssetReadiness = (callback) => {
42
+ const requestOptions = {
43
+ hostname: openHost,
44
+ port,
45
+ path: '/web-ui/app.js',
46
+ method: 'GET',
47
+ headers: httpToken ? { Authorization: `Bearer ${httpToken}` } : {}
48
+ };
49
+ let settled = false;
50
+ const finish = (ready) => {
51
+ if (settled) return;
52
+ settled = true;
53
+ callback(ready);
54
+ };
55
+ const req = http.request(requestOptions, (probeRes) => {
56
+ if (typeof probeRes.resume === 'function') {
57
+ probeRes.resume();
58
+ }
59
+ probeRes.on('end', () => {
60
+ finish(probeRes.statusCode === 200);
61
+ });
62
+ });
63
+ req.on('error', () => finish(false));
64
+ req.setTimeout(1000, () => {
65
+ try { req.destroy(); } catch (_) { }
66
+ finish(false);
67
+ });
68
+ req.end();
69
+ };
70
+
71
+ const openBrowserAfterReady = (url) => {
72
+ // Some environments may start the listener before the bundled web-ui assets
73
+ // are ready for the first browser hit; wait until both API and assets respond.
74
+ const maxAttempts = 120;
75
+ const retryDelayMs = 200;
76
+ let finished = false;
77
+
78
+ const finish = (ready) => {
79
+ if (finished) return;
80
+ finished = true;
81
+ if (!ready) {
82
+ console.warn('! Web UI 就绪探测超时,未自动打开浏览器,请手动访问:', url);
83
+ return;
84
+ }
85
+
86
+ const platform = process.platform;
87
+ const commandSpec = platform === 'win32'
88
+ ? { command: 'cmd', args: ['/c', 'start', '', url] }
89
+ : (platform === 'darwin'
90
+ ? { command: 'open', args: [url] }
91
+ : { command: 'xdg-open', args: [url] });
92
+
93
+ try {
94
+ const child = spawn(commandSpec.command, commandSpec.args, {
95
+ stdio: 'ignore',
96
+ detached: true,
97
+ windowsHide: true
98
+ });
99
+ child.on('error', () => {
100
+ console.warn('无法自动打开浏览器,请手动访问:', url);
101
+ });
102
+ if (typeof child.unref === 'function') {
103
+ child.unref();
104
+ }
105
+ } catch (_) {
106
+ console.warn('无法自动打开浏览器,请手动访问:', url);
107
+ }
108
+ };
109
+ const scheduleProbe = (attempt) => {
110
+ probeWebUiReadiness((apiReady) => {
111
+ if (!apiReady) {
112
+ if (attempt >= maxAttempts) {
113
+ finish(false);
114
+ return;
115
+ }
116
+ setTimeout(() => scheduleProbe(attempt + 1), retryDelayMs);
117
+ return;
118
+ }
119
+ probeWebUiAssetReadiness((assetReady) => {
120
+ if (assetReady) {
121
+ finish(true);
122
+ return;
123
+ }
124
+ if (attempt >= maxAttempts) {
125
+ finish(false);
126
+ return;
127
+ }
128
+ setTimeout(() => scheduleProbe(attempt + 1), retryDelayMs);
129
+ });
130
+ });
131
+ };
132
+
133
+ scheduleProbe(1);
134
+ };
135
+
136
+ server.on('connection', (socket) => {
137
+ connections.add(socket);
138
+ socket.on('close', () => connections.delete(socket));
139
+ });
140
+
141
+ const printPortOverrideHint = () => {
142
+ const examplePort = port === 8080 ? 8081 : 8080;
143
+ console.error(` 临时换端口(macOS/Linux): CODEXMATE_PORT=${examplePort} codexmate run`);
144
+ console.error(` 临时换端口(Windows PowerShell): $env:CODEXMATE_PORT=${examplePort}; codexmate run`);
145
+ console.error(` 临时换端口(Windows CMD): set CODEXMATE_PORT=${examplePort} && codexmate run`);
146
+ };
147
+
148
+ server.once('error', (err) => {
149
+ if (err && err.code === 'EADDRINUSE') {
150
+ console.error(`! 启动失败: 端口 ${port} 已被占用,可能有残留的 codexmate run 实例。`);
151
+ console.error(' 请先停止旧实例或更换端口后重试。');
152
+ printPortOverrideHint();
153
+ } else if (err && err.code === 'EACCES') {
154
+ console.error(`! 启动失败: 没有权限监听 ${host}:${port}。`);
155
+ console.error(' 请检查系统/安全软件限制,或更换端口后重试。');
156
+ printPortOverrideHint();
157
+ } else {
158
+ console.error('! 启动 Web UI 失败:', err && err.message ? err.message : err);
159
+ }
160
+ process.exit(1);
161
+ });
162
+
163
+ const openHost = host === '::'
164
+ ? '::1'
165
+ : (host === '0.0.0.0' ? DEFAULT_WEB_OPEN_HOST : host);
166
+
167
+ const openUrl = `http://${formatHostForUrl(openHost)}:${port}/?token=${encodeURIComponent(httpToken)}`;
168
+
169
+ server.listen(port, host, () => {
170
+ getUnattendedWorkflowRunner().recover();
171
+ console.log('\n✓ Web UI 已启动');
172
+ const willOpenBrowser = !!openBrowser && !process.env.CODEXMATE_NO_BROWSER;
173
+ console.log(` ${willOpenBrowser ? '已打开' : '待访问'}: ${openUrl}`);
174
+ if (host && host !== openHost) {
175
+ console.log(' 监听地址:', host);
176
+ }
177
+ console.log(' 退出: Ctrl+C\n');
178
+ if (isAnyAddressHost(host)) {
179
+ console.warn('! 安全提示: 当前监听所有网卡,局域网访问需要访问令牌。');
180
+ console.warn(' 远程 /bridge/ 请求需携带 Authorization: Bearer <访问令牌>。');
181
+ const allowedIps = (process.env.CODEXMATE_ALLOWED_IPS || '').trim();
182
+ if (allowedIps) {
183
+ console.warn(` 已启用的来源 IP 白名单: ${allowedIps}`);
184
+ }
185
+ }
186
+
187
+ if (willOpenBrowser) {
188
+ openBrowserAfterReady(openUrl);
189
+ }
190
+ });
191
+
192
+ const stop = () => new Promise((resolve) => {
193
+ let done = false;
194
+ const finish = () => {
195
+ if (done) return;
196
+ done = true;
197
+ for (const socket of connections) {
198
+ try { socket.destroy(); } catch (_) { }
199
+ }
200
+ connections.clear();
201
+ resolve();
202
+ };
203
+
204
+ if (!server.listening) {
205
+ finish();
206
+ return;
207
+ }
208
+
209
+ server.close(() => finish());
210
+ setTimeout(() => finish(), 800);
211
+ });
212
+
213
+ return { server, stop };
214
+ }
215
+
216
+ module.exports = { createWebServerLifecycle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexmate",
3
- "version": "0.1.32",
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,4 +1,7 @@
1
+ import { modelTestMixin } from './modules/model-test.mjs';
2
+ import { configChangeMixin } from './modules/app.methods.config-changes.mjs';
1
3
  import { threadHandoffMixin } from './modules/thread-handoff.mjs';
4
+ import { sessionFeaturesMixin } from './modules/session-features.mjs';
2
5
  import {
3
6
  DEFAULT_MODEL_AUTO_COMPACT_TOKEN_LIMIT,
4
7
  DEFAULT_MODEL_CONTEXT_WINDOW,
@@ -58,7 +61,7 @@ document.addEventListener('DOMContentLoaded', () => {
58
61
  });
59
62
 
60
63
  const appOptions = {
61
- mixins: [threadHandoffMixin],
64
+ mixins: [threadHandoffMixin, configChangeMixin],
62
65
  data() {
63
66
  return {
64
67
  workflowDefinitions: [], workflowRuns: [], workflowId: 'diagnose-config',
@@ -179,6 +182,10 @@ document.addEventListener('DOMContentLoaded', () => {
179
182
  pluginsError: '',
180
183
  textToolsActiveToolId: '',
181
184
  textToolsInput: '',
185
+ fileSharingBatches: [],
186
+ fileSharingPending: null,
187
+ fileSharingBusy: false,
188
+ fileSharingError: '',
182
189
  promptTemplatesListRaw: [],
183
190
  promptTemplatesLoadedOnce: false,
184
191
  promptTemplatesKeyword: '',
@@ -260,6 +267,12 @@ document.addEventListener('DOMContentLoaded', () => {
260
267
  agentsModalHint: '保存后会写入目标 AGENTS.md(与 config.toml 同级)。',
261
268
  sysPromptScope: 'global',
262
269
  sysPromptMode: 'system',
270
+ sysPromptFileName: '',
271
+ sysPromptFiles: [],
272
+ sysPromptFilesLoading: false,
273
+ sysPromptFilesError: '',
274
+ sysPromptFileMissing: false,
275
+ _sysPromptFilesRequestToken: null,
263
276
  sysPromptContent: '',
264
277
  sysPromptOriginalContent: '',
265
278
  sysPromptPath: '',
@@ -440,6 +453,7 @@ document.addEventListener('DOMContentLoaded', () => {
440
453
  installRegistryCustom: '',
441
454
  installStatusTargets: null,
442
455
  appLatestVersion: '',
456
+ showAppUpdateModal: false,
443
457
  appVersionStatusLoading: false,
444
458
  appVersionStatusError: '',
445
459
  appVersionStatusChecked: false,
@@ -610,7 +624,7 @@ document.addEventListener('DOMContentLoaded', () => {
610
624
  kilocodeShowKey: false,
611
625
  kilocodeAutoSaveSignature: '',
612
626
  forceCompactLayout: false,
613
- sidebarCollapsed: false,
627
+ sidebarCollapsed: true,
614
628
  theme: 'light',
615
629
  sessionLoadNativeDialog: false,
616
630
  starPrompted: false,
@@ -623,6 +637,7 @@ document.addEventListener('DOMContentLoaded', () => {
623
637
  },
624
638
 
625
639
  mounted() {
640
+ if (typeof this.installConfigChangePreview === 'function') this.installConfigChangePreview();
626
641
  this.refreshWorkflowRuns();
627
642
  this.workflowTimer = setInterval(() => this.refreshWorkflowRuns(), 3000);
628
643
  // URL 规范化:将 /web-ui/* 重定向到根路径 /
@@ -677,7 +692,7 @@ document.addEventListener('DOMContentLoaded', () => {
677
692
  this.agentsModalHint = this.t('modal.agents.hint');
678
693
  }
679
694
  {
680
- 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']);
681
696
  let urlMainTab = '';
682
697
  try {
683
698
  const url = new URL(window.location.href);
@@ -835,6 +850,7 @@ document.addEventListener('DOMContentLoaded', () => {
835
850
  },
836
851
 
837
852
  beforeUnmount() {
853
+ if (typeof this.uninstallConfigChangePreview === 'function') this.uninstallConfigChangePreview();
838
854
  clearInterval(this.workflowTimer);
839
855
  this.teardownSessionTabRender();
840
856
  this.cancelScheduledSessionTabDeferredTeardown();
@@ -936,6 +952,7 @@ document.addEventListener('DOMContentLoaded', () => {
936
952
  }
937
953
  },
938
954
  configMode(newMode) {
955
+ if (typeof this.refreshLastConfigChange === 'function') this.refreshLastConfigChange();
939
956
  if (newMode === 'pi' && typeof this.loadPiSources === 'function') {
940
957
  this.loadPiSources();
941
958
  }
@@ -953,6 +970,8 @@ document.addEventListener('DOMContentLoaded', () => {
953
970
  appOptions.render = window.__CODEXMATE_WEB_UI_RENDER__;
954
971
  }
955
972
 
973
+ appOptions.mixins.push(modelTestMixin);
974
+ appOptions.mixins.push(sessionFeaturesMixin);
956
975
  const app = createApp(appOptions);
957
976
  app.config.errorHandler = (err, vm, info) => {
958
977
  console.error('[Vue error handler]', err, 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 (_) {}
@@ -27,6 +27,7 @@
27
27
  <body>
28
28
  <!-- @include ./partials/index/layout-header.html -->
29
29
  <!-- @include ./partials/index/panel-dashboard.html -->
30
+ <!-- @include ./partials/index/config-changes.html -->
30
31
  <!-- @include ./partials/index/panel-config-codex.html -->
31
32
  <!-- @include ./partials/index/panel-config-claude.html -->
32
33
  <!-- @include ./partials/index/panel-config-openclaw.html -->
@@ -34,6 +35,7 @@
34
35
  <!-- @include ./partials/index/panel-config-kilocode.html -->
35
36
  <!-- @include ./partials/index/panel-config-pi.html -->
36
37
  <!-- @include ./partials/index/modals-pi-provider.html -->
38
+ <!-- @include ./partials/index/panel-routing.html -->
37
39
  <!-- @include ./partials/index/panel-sessions.html -->
38
40
  <!-- @include ./partials/index/panel-usage.html -->
39
41
  <!-- @include ./partials/index/panel-docs.html -->
@@ -0,0 +1,15 @@
1
+ const WARNING_RATIO = 0.8;
2
+ const HIGH_RATIO = 0.95;
3
+ export function contextWindowReference(report, { model = '', window = '' } = {}) {
4
+ if (!report) return null;
5
+ const models = report.models || [];
6
+ const selected = model || (models.length === 1 ? models[0] : '');
7
+ if (models.length > 1 && !selected) return { status: 'unknown', model: '', source: 'unknown' };
8
+ const manual = window !== '' && window !== null && window !== undefined;
9
+ const size = manual ? Number(window) : Number((report.modelWindows || {})[selected]);
10
+ if (manual && (!Number.isSafeInteger(size) || size <= 0)) throw new Error('context-window-invalid');
11
+ if (!Number.isSafeInteger(size) || size <= 0) return { status: 'unknown', model: selected, source: 'unknown' };
12
+ const ratio = report.totalEstimatedTokens / size;
13
+ return { status: ratio >= HIGH_RATIO ? 'high' : ratio >= WARNING_RATIO ? 'warning' : 'normal',
14
+ model: selected, window: size, ratio, percentage: ratio * 100, source: manual ? 'manual' : 'record', estimated: true };
15
+ }
@@ -1,15 +1,30 @@
1
+ import { withRequestDeadline } from './request-deadline.mjs';
2
+ import { CONFIG_CHANGE_ACTIONS } from './config-change-actions.mjs';
1
3
  import { authorizationHeaders } from './access-token.mjs';
4
+ let configChangeHandler = null;
5
+ const configChangeBaselines = new Map();
6
+
7
+ export function getConfigChangeBaseline(target) {
8
+ return configChangeBaselines.get(target) || [];
9
+ }
10
+
11
+ export function setConfigChangeHandler(handler, expectedHandler) {
12
+ if (expectedHandler && configChangeHandler !== expectedHandler) return;
13
+ configChangeHandler = handler;
14
+ }
15
+
2
16
  const browserLocation = typeof location !== 'undefined' ? location : null;
3
17
 
4
18
  export const API_BASE = (browserLocation && browserLocation.origin && browserLocation.origin !== 'null')
5
19
  ? browserLocation.origin
6
20
  : 'http://localhost:3737';
7
21
 
8
- async function postApi(action, params = {}) {
22
+ async function postApi(action, params = {}, signal) {
9
23
  return await fetch(`${API_BASE}/api`, {
10
24
  method: 'POST',
11
25
  headers: authorizationHeaders({ 'Content-Type': 'application/json' }),
12
- body: JSON.stringify({ action, params })
26
+ body: JSON.stringify({ action, params }),
27
+ ...(signal ? { signal } : {})
13
28
  });
14
29
  }
15
30
 
@@ -44,48 +59,66 @@ function withPayloadTooLargeErrorCode(res, payload) {
44
59
  return { ...payload, errorCode: 'payload-too-large' };
45
60
  }
46
61
 
47
- export async function api(action, params = {}) {
48
- const res = await postApi(action, params);
49
- const contentType = String(res.headers.get('content-type') || '').toLowerCase();
50
- if (contentType && !contentType.includes('application/json')) {
51
- const body = await res.text();
52
- const errorDetails = buildApiResponseContext(action, res, contentType);
53
- const bodySnippet = formatUnexpectedApiBodySnippet(body, contentType);
54
- const bodyDetails = bodySnippet ? `: ${bodySnippet}` : '';
55
- throw new Error(`Unexpected non-JSON API response for ${errorDetails}${bodyDetails}`);
56
- }
57
- try {
58
- return await res.json();
59
- } catch (error) {
60
- const errorDetails = buildApiResponseContext(action, res, contentType);
61
- throw new Error(`Failed to parse API response for ${errorDetails}: ${error.message}`);
62
- }
63
- }
62
+ export async function api(action, params = {}, options = {}) {
64
63
 
65
- export async function apiWithMeta(action, params = {}) {
66
- const res = await postApi(action, params);
67
- const contentType = String(res.headers.get('content-type') || '').toLowerCase();
68
- if (contentType.includes('application/json')) {
64
+ if (configChangeHandler && Object.prototype.hasOwnProperty.call(CONFIG_CHANGE_ACTIONS, action)) return await configChangeHandler(action, params);
65
+ if (configChangeHandler && action === 'start-kilocode' && params.configure === true) {
66
+ const saved = await configChangeHandler('apply-kilocode-config', params);
67
+ if (saved.error || saved.canceled || saved.success === false) return saved;
68
+ return await api(action, { ...params, configure: false }, options);
69
+ }
70
+ return await withRequestDeadline(async (signal) => {
71
+ const res = await postApi(action, params, signal);
72
+ const contentType = String(res.headers.get('content-type') || '').toLowerCase();
73
+ if (contentType && !contentType.includes('application/json')) {
74
+ const body = await res.text();
75
+ const errorDetails = buildApiResponseContext(action, res, contentType);
76
+ const bodySnippet = formatUnexpectedApiBodySnippet(body, contentType);
77
+ const bodyDetails = bodySnippet ? `: ${bodySnippet}` : '';
78
+ throw new Error(`Unexpected non-JSON API response for ${errorDetails}${bodyDetails}`);
79
+ }
69
80
  try {
70
81
  const payload = await res.json();
71
- if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
72
- return { ...withPayloadTooLargeErrorCode(res, payload), ok: res.ok, status: res.status };
82
+ if (payload && payload.configChangeTarget && Array.isArray(payload.configChangeBaseline)) {
83
+ const entries = new Map(getConfigChangeBaseline(payload.configChangeTarget).map(item => [item.path, item]));
84
+ for (const item of payload.configChangeBaseline) entries.set(item.path, item);
85
+ configChangeBaselines.set(payload.configChangeTarget, [...entries.values()]);
73
86
  }
74
- return res.status === 413
75
- ? { ok: res.ok, status: res.status, data: payload, errorCode: 'payload-too-large' }
76
- : { ok: res.ok, status: res.status, data: payload };
87
+ return payload;
77
88
  } catch (error) {
78
- if (res.status === 413) {
79
- return { ok: false, status: 413, errorCode: 'payload-too-large' };
89
+ const errorDetails = buildApiResponseContext(action, res, contentType);
90
+ throw new Error(`Failed to parse API response for ${errorDetails}: ${error.message}`);
91
+ }
92
+ }, options);
93
+ }
94
+
95
+ export async function apiWithMeta(action, params = {}, options = {}) {
96
+
97
+ return await withRequestDeadline(async (signal) => {
98
+ const res = await postApi(action, params, signal);
99
+ const contentType = String(res.headers.get('content-type') || '').toLowerCase();
100
+ if (contentType.includes('application/json')) {
101
+ try {
102
+ const payload = await res.json();
103
+ if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
104
+ return { ...withPayloadTooLargeErrorCode(res, payload), ok: res.ok, status: res.status };
105
+ }
106
+ return res.status === 413
107
+ ? { ok: res.ok, status: res.status, data: payload, errorCode: 'payload-too-large' }
108
+ : { ok: res.ok, status: res.status, data: payload };
109
+ } catch (error) {
110
+ if (res.status === 413) {
111
+ return { ok: false, status: 413, errorCode: 'payload-too-large' };
112
+ }
113
+ throw error;
80
114
  }
81
- throw error;
82
115
  }
83
- }
84
- const error = await res.text();
85
- return {
86
- ok: res.ok,
87
- status: res.status,
88
- error,
89
- errorCode: res.status === 413 ? 'payload-too-large' : ''
90
- };
116
+ const error = await res.text();
117
+ return {
118
+ ok: res.ok,
119
+ status: res.status,
120
+ error,
121
+ errorCode: res.status === 413 ? 'payload-too-large' : ''
122
+ };
123
+ }, options);
91
124
  }