codexmate 0.1.34 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -86
- package/README.vi.md +105 -79
- package/README.zh.md +102 -84
- package/cli/analytics-export-args.js +7 -0
- package/cli/session-usage.js +4 -1
- package/cli.js +30 -6
- package/lib/data/model-prices.json +1868 -0
- package/lib/session-context-health.js +5 -1
- package/lib/session-evidence-collections.js +85 -0
- package/lib/session-features.js +15 -0
- package/lib/session-project-git.js +65 -0
- package/lib/session-projects.js +12 -1
- package/lib/session-stories.js +67 -0
- package/lib/session-usage-ledger.js +77 -0
- package/lib/session-usage-pricing.js +42 -0
- package/lib/session-usage-report.js +101 -0
- package/package.json +4 -1
- package/plugins/prompt-templates/computed.mjs +9 -0
- package/web-ui/app.js +12 -0
- package/web-ui/logic.codex.mjs +14 -0
- package/web-ui/logic.session-artifacts.mjs +39 -0
- package/web-ui/modules/app.methods.agents.mjs +3 -2
- package/web-ui/modules/app.methods.claude-config.mjs +26 -5
- package/web-ui/modules/app.methods.install.mjs +13 -17
- package/web-ui/modules/app.methods.navigation.mjs +1 -1
- package/web-ui/modules/app.methods.openclaw-editing.mjs +29 -0
- package/web-ui/modules/app.methods.openclaw-persist.mjs +3 -3
- package/web-ui/modules/app.methods.opencode-config.mjs +34 -0
- package/web-ui/modules/app.methods.pi-config.mjs +14 -9
- package/web-ui/modules/app.methods.providers.mjs +11 -0
- package/web-ui/modules/app.methods.session-browser.mjs +35 -0
- package/web-ui/modules/app.methods.session-trash.mjs +4 -5
- package/web-ui/modules/app.methods.startup-claude.mjs +1 -0
- package/web-ui/modules/app.methods.system-prompt.mjs +16 -7
- package/web-ui/modules/app.methods.web-ui-preferences.mjs +5 -0
- package/web-ui/modules/claude-provider-presets.mjs +23 -0
- package/web-ui/modules/i18n/locales/en.mjs +127 -1
- package/web-ui/modules/i18n/locales/ja.mjs +127 -1
- package/web-ui/modules/i18n/locales/vi.mjs +127 -1
- package/web-ui/modules/i18n/locales/zh-tw.mjs +127 -1
- package/web-ui/modules/i18n/locales/zh.mjs +127 -1
- package/web-ui/modules/pi-provider-templates.mjs +6 -1
- package/web-ui/modules/session-collections.mjs +65 -0
- package/web-ui/modules/session-evidence.mjs +81 -0
- package/web-ui/modules/session-features.mjs +15 -1
- package/web-ui/modules/session-git.mjs +39 -0
- package/web-ui/modules/session-stories.mjs +64 -0
- package/web-ui/modules/usage-pricing.mjs +30 -0
- package/web-ui/partials/index/layout-footer.html +1 -1
- package/web-ui/partials/index/modal-openclaw-config.html +3 -0
- package/web-ui/partials/index/modals-basic.html +1 -1
- package/web-ui/partials/index/modals-pi-provider.html +1 -1
- package/web-ui/partials/index/panel-config-claude.html +4 -21
- package/web-ui/partials/index/panel-config-codex.html +3 -1
- package/web-ui/partials/index/panel-config-opencode.html +4 -0
- package/web-ui/partials/index/panel-sessions.html +20 -20
- package/web-ui/partials/index/panel-settings.html +45 -0
- package/web-ui/partials/index/panel-usage.html +2 -0
- package/web-ui/partials/index/session-features.html +82 -2
- package/web-ui/partials/index/thread-handoff.html +73 -62
- package/web-ui/partials/index/usage-records.html +41 -0
- package/web-ui/res/web-ui-render.precompiled.js +896 -236
- package/web-ui/styles/session-features.css +63 -0
- package/web-ui/styles/sessions-list.css +74 -0
- package/web-ui/styles/sessions-preview.css +106 -68
- package/web-ui/styles/sessions-usage.css +8 -0
- package/web-ui/styles/settings-panel.css +4 -0
- package/web-ui/styles/theme-violet.css +9 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const ARTIFACT_FORMATS = Object.freeze({
|
|
2
|
+
evidence: 'codexmate-evidence.md',
|
|
3
|
+
receipt: 'codexmate-development-receipt.md',
|
|
4
|
+
relay: 'codexmate-agent-relay.md'
|
|
5
|
+
});
|
|
6
|
+
const quote = text => String(text).split('\n').map(line => '> ' + line).join('\n');
|
|
7
|
+
const sourceKey = item => JSON.stringify([item.session.source, item.session.sessionId, item.session.filePath, item.nodeId]);
|
|
8
|
+
|
|
9
|
+
export function sessionArtifactFilename(format) {
|
|
10
|
+
return ARTIFACT_FORMATS[format];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function renderSessionArtifact({ format, goal, note, selections, evidence, translate }) {
|
|
14
|
+
const t = translate;
|
|
15
|
+
const entries = selections.map(item => ({ item, source: evidence.get(sourceKey(item)) }));
|
|
16
|
+
const lines = [`# ${t('artifacts.' + format)}`, '', t('artifacts.scope'), '',
|
|
17
|
+
`## ${t('artifacts.goal')}`, '', quote(goal.trim() || t('artifacts.unspecified'))];
|
|
18
|
+
if (note.trim()) lines.push('', `## ${t('artifacts.note')}`, '', quote(note.trim()));
|
|
19
|
+
if (format === 'receipt') {
|
|
20
|
+
lines.push('', `## ${t('artifacts.checks')}`, '');
|
|
21
|
+
for (const status of ['passed', 'failed', 'unverified']) {
|
|
22
|
+
const count = entries.filter(entry => entry.source.status === status).length;
|
|
23
|
+
lines.push(`- ${t('evidence.' + status)}: ${count}`);
|
|
24
|
+
}
|
|
25
|
+
lines.push('', t('artifacts.noVerdict'));
|
|
26
|
+
} else {
|
|
27
|
+
lines.push('', `## ${t('artifacts.executor')}`, '', t('artifacts.executorTask'), '',
|
|
28
|
+
`## ${t('artifacts.reviewer')}`, '', t('artifacts.reviewerTask'));
|
|
29
|
+
}
|
|
30
|
+
lines.push('', `## ${t('artifacts.sources')}`);
|
|
31
|
+
for (const [index, { item, source }] of entries.entries()) {
|
|
32
|
+
lines.push('', `### ${index + 1}. ${item.session.title || item.session.sessionId}`, '',
|
|
33
|
+
`${item.session.source} · ${item.session.sessionId} · ${source.nodeId}`,
|
|
34
|
+
`${t('evidence.path')}: ${JSON.stringify(item.session.filePath || item.session.cwd || '')}`,
|
|
35
|
+
`SHA-256: ${source.textHash}`, `${t('evidence.status')}: ${t('evidence.' + source.status)}`, '', quote(source.excerpt));
|
|
36
|
+
}
|
|
37
|
+
lines.push('', `## ${t('artifacts.uat')}`, '', t('artifacts.uatTask'));
|
|
38
|
+
return lines.join('\n').trim() + '\n';
|
|
39
|
+
}
|
|
@@ -1087,10 +1087,11 @@ export function createAgentsMethods(options = {}) {
|
|
|
1087
1087
|
});
|
|
1088
1088
|
},
|
|
1089
1089
|
|
|
1090
|
-
loadPromptsTabContent() {
|
|
1090
|
+
async loadPromptsTabContent() {
|
|
1091
1091
|
if (typeof this.loadPromptsPathReferences === "function") this.loadPromptsPathReferences();
|
|
1092
1092
|
if (this.promptsSubTab === 'system') {
|
|
1093
|
-
|
|
1093
|
+
const didLoadFallback = typeof this.loadSystemPromptFiles === 'function' && await this.loadSystemPromptFiles();
|
|
1094
|
+
if (this.promptsSubTab !== 'system' || didLoadFallback) return;
|
|
1094
1095
|
if (this.sysPromptLoading || this.sysPromptSaving || this.sysPromptDiffVisible || this.hasSysPromptContentChanged()) return;
|
|
1095
1096
|
if (typeof this.loadSystemPrompt === 'function') this.loadSystemPrompt();
|
|
1096
1097
|
} else {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CLAUDE_PROVIDER_PRESETS } from './claude-provider-presets.mjs';
|
|
1
2
|
import { nextClaudeConfigName } from './provider-default-names.mjs';
|
|
2
3
|
|
|
3
4
|
function normalizeClaudeText(value) {
|
|
@@ -152,8 +153,8 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
152
153
|
this.onClaudeModelChange();
|
|
153
154
|
},
|
|
154
155
|
|
|
155
|
-
saveClaudeConfigs() {
|
|
156
|
-
if (typeof this.normalizeStoredClaudeConfigs === 'function') {
|
|
156
|
+
saveClaudeConfigs({ syncBridge = true } = {}) {
|
|
157
|
+
if (syncBridge && typeof this.normalizeStoredClaudeConfigs === 'function') {
|
|
157
158
|
this.normalizeStoredClaudeConfigs();
|
|
158
159
|
}
|
|
159
160
|
if (typeof this.persistWebUiPreferences === 'function') {
|
|
@@ -162,7 +163,7 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
162
163
|
currentClaudeConfig: this.currentClaudeConfig || ''
|
|
163
164
|
});
|
|
164
165
|
}
|
|
165
|
-
this.syncClaudeBridgeProviders();
|
|
166
|
+
if (syncBridge) this.syncClaudeBridgeProviders();
|
|
166
167
|
},
|
|
167
168
|
|
|
168
169
|
rememberDeletedClaudeSettingsImport(config) {
|
|
@@ -288,6 +289,7 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
288
289
|
},
|
|
289
290
|
|
|
290
291
|
openCloneClaudeConfigModal(name, config) {
|
|
292
|
+
this.claudeAddFromPreset = false;
|
|
291
293
|
this.newClaudeConfig = {
|
|
292
294
|
name: '',
|
|
293
295
|
apiKey: config.apiKey || '',
|
|
@@ -429,9 +431,14 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
429
431
|
|
|
430
432
|
this.claudeConfigs[name] = this.mergeClaudeConfig({}, this.newClaudeConfig);
|
|
431
433
|
|
|
432
|
-
|
|
433
|
-
this.
|
|
434
|
+
const saveOnly = this.claudeAddFromPreset;
|
|
435
|
+
if (!saveOnly) this.currentClaudeConfig = name;
|
|
436
|
+
this.saveClaudeConfigs({ syncBridge: !saveOnly });
|
|
434
437
|
this.closeClaudeConfigModal();
|
|
438
|
+
if (saveOnly) {
|
|
439
|
+
this.showMessage(this.t('toast.operation.success'), 'success');
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
435
442
|
await this.applyClaudeConfig(name);
|
|
436
443
|
},
|
|
437
444
|
|
|
@@ -530,7 +537,21 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
530
537
|
}
|
|
531
538
|
},
|
|
532
539
|
|
|
540
|
+
matchingClaudeProviderPresets() {
|
|
541
|
+
const query = (this.claudeProviderPresetQuery || '').trim().toLowerCase();
|
|
542
|
+
return CLAUDE_PROVIDER_PRESETS.filter(({ name, baseUrl, model }) =>
|
|
543
|
+
[name, baseUrl, model].some(value => value.toLowerCase().includes(query)));
|
|
544
|
+
},
|
|
545
|
+
|
|
546
|
+
openClaudeProviderPreset(preset) {
|
|
547
|
+
if (!this.isToolConfigWriteAllowed('claude')) return;
|
|
548
|
+
this.openClaudeConfigModal();
|
|
549
|
+
Object.assign(this.newClaudeConfig, preset);
|
|
550
|
+
this.claudeAddFromPreset = true;
|
|
551
|
+
},
|
|
552
|
+
|
|
533
553
|
closeClaudeConfigModal() {
|
|
554
|
+
this.claudeAddFromPreset = false;
|
|
534
555
|
this.showClaudeConfigModal = false;
|
|
535
556
|
this.showAddClaudeConfigKey = false;
|
|
536
557
|
this.newClaudeConfig = {
|
|
@@ -124,32 +124,28 @@ export function createInstallMethods(options = {}) {
|
|
|
124
124
|
if (this.appVersionStatusLoading) return false;
|
|
125
125
|
this.appVersionStatusLoading = true;
|
|
126
126
|
this.appVersionStatusError = '';
|
|
127
|
+
this.appVersionStatusChecked = false;
|
|
128
|
+
this.appLatestVersion = '';
|
|
129
|
+
this.appVersionStatusSource = '';
|
|
130
|
+
this.appVersionStatusCheckedAt = '';
|
|
127
131
|
try {
|
|
128
132
|
const res = await api('version-status', options.force ? { force: true } : {});
|
|
129
|
-
if (
|
|
130
|
-
this.appVersion = this.normalizePackageVersion(res
|
|
133
|
+
if (!this.appVersion) {
|
|
134
|
+
this.appVersion = this.normalizePackageVersion(res?.currentVersion);
|
|
131
135
|
}
|
|
132
|
-
if (res
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.appVersionStatusSource = res.source;
|
|
137
|
-
}
|
|
138
|
-
if (res && typeof res.checkedAt === 'string') {
|
|
139
|
-
this.appVersionStatusCheckedAt = res.checkedAt;
|
|
140
|
-
}
|
|
141
|
-
if (res && res.error) {
|
|
142
|
-
this.appVersionStatusError = res.error;
|
|
143
|
-
this.appVersionStatusChecked = true;
|
|
144
|
-
if (!options.silent) this.showMessage(res.error, 'error');
|
|
145
|
-
return false;
|
|
136
|
+
if (res?.error) throw new Error(res.error);
|
|
137
|
+
const latestVersion = this.normalizePackageVersion(res?.latestVersion);
|
|
138
|
+
if (!latestVersion || !this.normalizePackageVersion(this.appVersion)) {
|
|
139
|
+
throw new Error(this.t('side.update.checkFailed'));
|
|
146
140
|
}
|
|
141
|
+
this.appLatestVersion = latestVersion;
|
|
142
|
+
this.appVersionStatusSource = typeof res.source === 'string' ? res.source : '';
|
|
143
|
+
this.appVersionStatusCheckedAt = typeof res.checkedAt === 'string' ? res.checkedAt : '';
|
|
147
144
|
this.appVersionStatusChecked = true;
|
|
148
145
|
return true;
|
|
149
146
|
} catch (e) {
|
|
150
147
|
const message = e && e.message ? e.message : this.t('side.update.checkFailed');
|
|
151
148
|
this.appVersionStatusError = message;
|
|
152
|
-
this.appVersionStatusChecked = true;
|
|
153
149
|
if (!options.silent) this.showMessage(message, 'error');
|
|
154
150
|
return false;
|
|
155
151
|
} finally {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
: vm.pluginsActiveId;
|
|
119
119
|
const pluginsActiveId = typeof pluginsActiveIdSource === 'string' ? pluginsActiveIdSource.trim() : '';
|
|
120
120
|
const snapshot = {
|
|
121
|
-
settingsTab: settingsTab === 'data'
|
|
121
|
+
settingsTab: settingsTab === 'data' || settingsTab === 'about' ? settingsTab : 'general',
|
|
122
122
|
mainTab: resolveSelectableMainTab(mainTab),
|
|
123
123
|
configMode: configModeSet && configModeSet.has(configMode) ? configMode : 'codex',
|
|
124
124
|
modelTestTarget: vm.modelTestTarget === 'pi' ? 'pi' : 'codex',
|
|
@@ -145,6 +145,34 @@ export function createOpenclawEditingMethods() {
|
|
|
145
145
|
this.showMessage('已写入', 'success');
|
|
146
146
|
},
|
|
147
147
|
|
|
148
|
+
fillOpenclawProviderPreset() {
|
|
149
|
+
if (!this.isToolConfigWriteAllowed('openclaw') || this.openclawFileLoading || this.openclawSaving || this.openclawApplying) return;
|
|
150
|
+
const providerName = 'openai-api';
|
|
151
|
+
const parsed = this.parseOpenclawContent(this.openclawEditing.content, { allowEmpty: true });
|
|
152
|
+
if (!parsed.ok) {
|
|
153
|
+
this.showMessage(parsed.error, 'error');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (Object.hasOwn(parsed.data.models?.providers || {}, providerName)) {
|
|
157
|
+
this.showMessage(this.t('config.providerTemplate.duplicate', { name: providerName }), 'info');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.openclawQuick = {
|
|
161
|
+
...this.getOpenclawQuickDefaults(),
|
|
162
|
+
fromProviderPreset: true,
|
|
163
|
+
providerName,
|
|
164
|
+
baseUrl: 'https://api.openai.com/v1',
|
|
165
|
+
apiType: 'openai-responses',
|
|
166
|
+
modelId: 'gpt-5.4-mini',
|
|
167
|
+
setPrimary: false,
|
|
168
|
+
overrideProvider: false,
|
|
169
|
+
overrideModels: false
|
|
170
|
+
};
|
|
171
|
+
this.openclawAccordionStep = 1;
|
|
172
|
+
this.validateProviderName();
|
|
173
|
+
this.validateModelId();
|
|
174
|
+
},
|
|
175
|
+
|
|
148
176
|
applyOpenclawQuickToText() {
|
|
149
177
|
const parsed = this.parseOpenclawContent(this.openclawEditing.content, { allowEmpty: true });
|
|
150
178
|
if (!parsed.ok) {
|
|
@@ -273,6 +301,7 @@ export function createOpenclawEditingMethods() {
|
|
|
273
301
|
providers[providerName] = provider;
|
|
274
302
|
models.providers = providers;
|
|
275
303
|
config.models = models;
|
|
304
|
+
if (this.openclawQuick.fromProviderPreset) this.openclawEditing.fromProviderPreset = true;
|
|
276
305
|
|
|
277
306
|
if (this.openclawQuick.setPrimary) {
|
|
278
307
|
const agents = ensureObject(config.agents);
|
|
@@ -225,7 +225,7 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
227
|
|
|
228
|
-
persistOpenclawConfig({ closeModal = true } = {}) {
|
|
228
|
+
persistOpenclawConfig({ closeModal = true, select = !this.openclawEditing.fromProviderPreset } = {}) {
|
|
229
229
|
if (!this.openclawEditing.name || !this.openclawEditing.name.trim()) {
|
|
230
230
|
this.showMessage('请输入名称', 'error');
|
|
231
231
|
return '';
|
|
@@ -246,7 +246,7 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
246
246
|
this.openclawConfigs[name] = {
|
|
247
247
|
content: this.openclawEditing.content
|
|
248
248
|
};
|
|
249
|
-
this.currentOpenclawConfig = name;
|
|
249
|
+
if (select) this.currentOpenclawConfig = name;
|
|
250
250
|
if (this.saveOpenclawConfigs() === false) {
|
|
251
251
|
if (hadPreviousConfig) {
|
|
252
252
|
this.openclawConfigs[name] = previousConfig;
|
|
@@ -286,7 +286,7 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
286
286
|
}
|
|
287
287
|
this.openclawApplying = true;
|
|
288
288
|
try {
|
|
289
|
-
const name = this.persistOpenclawConfig({ closeModal: false });
|
|
289
|
+
const name = this.persistOpenclawConfig({ closeModal: false, select: true });
|
|
290
290
|
if (!name) return;
|
|
291
291
|
const config = this.openclawConfigs[name];
|
|
292
292
|
const res = await api('apply-openclaw-config', {
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
const OPENCODE_DEEPSEEK_PRESET = {
|
|
2
|
+
id: 'deepseek-api',
|
|
3
|
+
name: 'DeepSeek API',
|
|
4
|
+
npm: '@ai-sdk/openai-compatible',
|
|
5
|
+
options: {
|
|
6
|
+
baseURL: 'https://api.deepseek.com/v1',
|
|
7
|
+
apiKey: '{env:DEEPSEEK_API_KEY}'
|
|
8
|
+
},
|
|
9
|
+
models: { 'deepseek-flash': { name: 'DeepSeek Flash' } }
|
|
10
|
+
};
|
|
11
|
+
|
|
1
12
|
function normalizeOpencodeProviderName(value) {
|
|
2
13
|
const name = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
3
14
|
return /^[a-z0-9_.-]+$/.test(name) ? name : '';
|
|
@@ -29,6 +40,29 @@ export function createOpencodeConfigMethods(options = {}) {
|
|
|
29
40
|
const { api, modelCatalog = {} } = options;
|
|
30
41
|
|
|
31
42
|
return {
|
|
43
|
+
insertOpencodeProviderPreset() {
|
|
44
|
+
if (!this.isToolConfigWriteAllowed('opencode') || this.opencodeLoading || this.opencodeSaving || this.opencodeApplying) return;
|
|
45
|
+
let config;
|
|
46
|
+
try {
|
|
47
|
+
config = summarizeOpencodeDraft(this.opencodeContent);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
this.showMessage(error.message, 'error');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const { id, ...preset } = OPENCODE_DEEPSEEK_PRESET;
|
|
53
|
+
const providers = config.provider;
|
|
54
|
+
if (providers !== undefined && (!providers || typeof providers !== 'object' || Array.isArray(providers))) {
|
|
55
|
+
this.showMessage(this.t('opencode.preset.invalidProviders'), 'error');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if ((providers && Object.hasOwn(providers, id)) || (this.opencodeProviders || []).some(provider => provider.name === id)) {
|
|
59
|
+
this.showMessage(this.t('config.providerTemplate.duplicate', { name: id }), 'info');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
config.provider = { ...providers, [id]: preset };
|
|
63
|
+
this.opencodeContent = JSON.stringify(config, null, 2) + '\n';
|
|
64
|
+
},
|
|
65
|
+
|
|
32
66
|
opencodeProviderCatalog() {
|
|
33
67
|
const configured = Array.isArray(this.opencodeProviders)
|
|
34
68
|
? this.opencodeProviders.map(item => item && item.name).filter(Boolean)
|
|
@@ -170,6 +170,7 @@ export function createPiConfigMethods({ api: apiClient }) {
|
|
|
170
170
|
return '';
|
|
171
171
|
},
|
|
172
172
|
resetPiEditorTransientState() {
|
|
173
|
+
this.piRemoteModelsLoading = false;
|
|
173
174
|
this.piRemoteModels = [];
|
|
174
175
|
this.piRemoteModelError = '';
|
|
175
176
|
this.piRemoteChecked = {};
|
|
@@ -227,12 +228,11 @@ export function createPiConfigMethods({ api: apiClient }) {
|
|
|
227
228
|
api: template.api || 'openai-completions',
|
|
228
229
|
apiKey: '',
|
|
229
230
|
configJsonDraft: '',
|
|
230
|
-
models: []
|
|
231
|
+
models: (template.models || []).map(model => ({ ...model, input: [...model.input] }))
|
|
231
232
|
},
|
|
232
233
|
extras: {},
|
|
233
234
|
original: null
|
|
234
235
|
};
|
|
235
|
-
this.fetchPiRemoteModels();
|
|
236
236
|
},
|
|
237
237
|
resetPiProviderTemplateSelection() {
|
|
238
238
|
this.piSelectedProviderTemplate = '';
|
|
@@ -347,13 +347,7 @@ export function createPiConfigMethods({ api: apiClient }) {
|
|
|
347
347
|
},
|
|
348
348
|
resetPiProviderEditing() {
|
|
349
349
|
this.editingPiProvider = null;
|
|
350
|
-
this.
|
|
351
|
-
this.piRemoteModelError = '';
|
|
352
|
-
this.piRemoteChecked = {};
|
|
353
|
-
this.piCatalogFillError = '';
|
|
354
|
-
this.piCatalogFillIndex = -1;
|
|
355
|
-
this.piModelSearch = '';
|
|
356
|
-
this.piEditorJsonError = '';
|
|
350
|
+
this.resetPiEditorTransientState();
|
|
357
351
|
},
|
|
358
352
|
closePiProviderEditor() {
|
|
359
353
|
const editor = this.editingPiProvider;
|
|
@@ -364,6 +358,17 @@ export function createPiConfigMethods({ api: apiClient }) {
|
|
|
364
358
|
this.showAddPiProviderModal = false;
|
|
365
359
|
this.piProviderPickerQuery = '';
|
|
366
360
|
},
|
|
361
|
+
updatePiModelId(model, id) {
|
|
362
|
+
if (id === model.id) return;
|
|
363
|
+
const preset = PI_PROVIDER_TEMPLATE_GROUPS.flatMap(group => group.templates)
|
|
364
|
+
.find(template => template.id === this.piSelectedProviderTemplate);
|
|
365
|
+
const original = preset?.models?.find(entry => entry.id === model.id);
|
|
366
|
+
if (this.editingPiProvider?.isNew && original) {
|
|
367
|
+
Object.assign(model, this.piCreateModelRecord(id));
|
|
368
|
+
} else {
|
|
369
|
+
model.id = id;
|
|
370
|
+
}
|
|
371
|
+
},
|
|
367
372
|
removePiProviderModel(index) {
|
|
368
373
|
if (!this.editingPiProvider) return;
|
|
369
374
|
const list = this.editingPiProvider.form.models;
|
|
@@ -333,6 +333,17 @@ export function createProvidersMethods(options = {}) {
|
|
|
333
333
|
this.showAddModal = true;
|
|
334
334
|
},
|
|
335
335
|
|
|
336
|
+
openCodexProviderPreset(preset) {
|
|
337
|
+
if (!this.isToolConfigWriteAllowed('codex')) return;
|
|
338
|
+
this.openAddProviderModal();
|
|
339
|
+
Object.assign(this.newProvider, {
|
|
340
|
+
name: preset.name,
|
|
341
|
+
url: preset.url,
|
|
342
|
+
model: preset.model || '',
|
|
343
|
+
useTransform: !!preset.useTransform
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
|
|
336
347
|
openAddProviderModal() {
|
|
337
348
|
this.newProvider = {
|
|
338
349
|
name: nextCodexProviderName(this.providersList),
|
|
@@ -828,6 +828,40 @@ export function createSessionBrowserMethods(options = {}) {
|
|
|
828
828
|
}
|
|
829
829
|
},
|
|
830
830
|
|
|
831
|
+
toggleUsageRecords(event) {
|
|
832
|
+
this.usageRecordsOpen = event.target.open;
|
|
833
|
+
if (this.usageRecordsOpen) return this.loadUsageRecords();
|
|
834
|
+
},
|
|
835
|
+
formatUsageRecordCount(value) {
|
|
836
|
+
return value === null ? this.t('usage.records.unknown') : Number(value || 0).toLocaleString('en-US');
|
|
837
|
+
},
|
|
838
|
+
async loadUsageRecords(options = {}) {
|
|
839
|
+
if (this.usageRecordsLoading) return;
|
|
840
|
+
const range = this.sessionsUsageTimeRange;
|
|
841
|
+
if (!options.forceRefresh && this.usageRecords && this.usageRecordsRange === range) return;
|
|
842
|
+
this.usageRecordsLoading = true;
|
|
843
|
+
this.usageRecordsError = '';
|
|
844
|
+
if (this.usageRecordsRange !== range) this.usageRecords = null;
|
|
845
|
+
const today = new Date();
|
|
846
|
+
const from = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() - (range === '30d' ? 29 : 6)));
|
|
847
|
+
try {
|
|
848
|
+
const report = await api('read-sessions-usage-report', { source: 'all',
|
|
849
|
+
limit: range === 'all' ? 2000 : (range === '30d' ? 1200 : 600),
|
|
850
|
+
...(range === 'all' ? {} : { from: from.toISOString().slice(0, 10), to: today.toISOString().slice(0, 10) }),
|
|
851
|
+
forceRefresh: !!options.forceRefresh });
|
|
852
|
+
if (report.error) throw new Error(report.error);
|
|
853
|
+
if (range === this.sessionsUsageTimeRange) {
|
|
854
|
+
this.usageRecords = report;
|
|
855
|
+
this.usageRecordsRange = range;
|
|
856
|
+
}
|
|
857
|
+
} catch (error) {
|
|
858
|
+
if (range === this.sessionsUsageTimeRange) this.usageRecordsError = error.message;
|
|
859
|
+
} finally {
|
|
860
|
+
this.usageRecordsLoading = false;
|
|
861
|
+
if (this.usageRecordsOpen && range !== this.sessionsUsageTimeRange) return this.loadUsageRecords();
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
|
|
831
865
|
async loadSessionsUsage(options = {}) {
|
|
832
866
|
if (this.sessionsUsageLoading) return;
|
|
833
867
|
const normalizedRange = typeof options.range === 'string'
|
|
@@ -865,6 +899,7 @@ export function createSessionBrowserMethods(options = {}) {
|
|
|
865
899
|
return;
|
|
866
900
|
}
|
|
867
901
|
this.sessionsUsageList = Array.isArray(res.sessions) ? res.sessions : [];
|
|
902
|
+
if (this.usageRecordsOpen) void this.loadUsageRecords({ forceRefresh: !!options.forceRefresh });
|
|
868
903
|
loadSucceeded = true;
|
|
869
904
|
} catch (e) {
|
|
870
905
|
this.sessionsUsageError = '加载 usage 统计失败';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const SETTINGS_TABS = ['general', 'data', 'about'];
|
|
2
|
+
|
|
1
3
|
export function createSessionTrashMethods(options = {}) {
|
|
2
4
|
const {
|
|
3
5
|
api,
|
|
@@ -213,10 +215,7 @@ export function createSessionTrashMethods(options = {}) {
|
|
|
213
215
|
},
|
|
214
216
|
|
|
215
217
|
normalizeSettingsTab(tab) {
|
|
216
|
-
|
|
217
|
-
return tab;
|
|
218
|
-
}
|
|
219
|
-
return 'general';
|
|
218
|
+
return SETTINGS_TABS.includes(tab) ? tab : 'general';
|
|
220
219
|
},
|
|
221
220
|
|
|
222
221
|
async onSettingsTabClick(tab) {
|
|
@@ -227,7 +226,7 @@ export function createSessionTrashMethods(options = {}) {
|
|
|
227
226
|
if (!event) {
|
|
228
227
|
return;
|
|
229
228
|
}
|
|
230
|
-
const tabs =
|
|
229
|
+
const tabs = SETTINGS_TABS;
|
|
231
230
|
const currentTab = this.normalizeSettingsTab(tab || this.settingsTab);
|
|
232
231
|
const currentIndex = Math.max(0, tabs.indexOf(currentTab));
|
|
233
232
|
let nextIndex = currentIndex;
|
|
@@ -36,8 +36,12 @@ export function createSystemPromptMethods(options = {}) {
|
|
|
36
36
|
return false;
|
|
37
37
|
},
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
if (this.sysPromptFilesLoading)
|
|
39
|
+
loadSystemPromptFiles() {
|
|
40
|
+
if (!this.sysPromptFilesLoading) this._sysPromptFilesPromise = this.refreshSystemPromptFiles();
|
|
41
|
+
return this._sysPromptFilesPromise;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
async refreshSystemPromptFiles() {
|
|
41
45
|
const scope = this.sysPromptScope || 'global';
|
|
42
46
|
const token = issueLatestRequestToken(this, '_sysPromptFilesRequestToken');
|
|
43
47
|
this.sysPromptFilesLoading = true;
|
|
@@ -47,6 +51,11 @@ export function createSystemPromptMethods(options = {}) {
|
|
|
47
51
|
if (result.error) throw new Error(result.error);
|
|
48
52
|
this.sysPromptFiles = result.files;
|
|
49
53
|
const isListed = result.files.some(file => file.filename === this.currentSysPromptFileName());
|
|
54
|
+
if (!isListed && result.files.length && !this.hasSysPromptContentChanged()
|
|
55
|
+
&& !this.sysPromptLoading && !this.sysPromptSaving && !this.sysPromptDiffVisible) {
|
|
56
|
+
await this.switchSysPromptFileName(result.files[0].filename);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
50
59
|
if (!isListed) this.sysPromptFileMissing = true;
|
|
51
60
|
this.sysPromptFilesError = !isListed ? this.t('sysPrompt.fileMissing')
|
|
52
61
|
: (this.sysPromptFileMissing ? this.sysPromptFilesError : '');
|
|
@@ -67,21 +76,21 @@ export function createSystemPromptMethods(options = {}) {
|
|
|
67
76
|
if (filename === 'SYSTEM.md') this.sysPromptMode = 'system';
|
|
68
77
|
if (filename === 'APPEND_SYSTEM.md') this.sysPromptMode = 'append';
|
|
69
78
|
this.closeSysHistory();
|
|
70
|
-
this.loadSystemPrompt();
|
|
79
|
+
return this.loadSystemPrompt();
|
|
71
80
|
},
|
|
72
81
|
|
|
73
|
-
switchSysPromptScope(scope) {
|
|
82
|
+
async switchSysPromptScope(scope) {
|
|
74
83
|
if (!this.canSwitchSysPromptTarget()) return;
|
|
75
84
|
const normalized = scope === 'project' ? scope : 'global';
|
|
76
85
|
if (normalized === this.sysPromptScope) return;
|
|
77
86
|
this.sysPromptScope = normalized;
|
|
78
|
-
this.sysPromptFileName = '';
|
|
79
87
|
this.sysPromptFiles = [];
|
|
80
88
|
this._sysPromptFilesRequestToken = null;
|
|
81
89
|
this.sysPromptFilesLoading = false;
|
|
82
90
|
this.closeSysHistory();
|
|
83
|
-
this.loadSystemPromptFiles();
|
|
84
|
-
this.
|
|
91
|
+
const didLoadFallback = await this.loadSystemPromptFiles();
|
|
92
|
+
if (normalized !== this.sysPromptScope || didLoadFallback) return;
|
|
93
|
+
return this.loadSystemPrompt();
|
|
85
94
|
},
|
|
86
95
|
|
|
87
96
|
switchSysPromptMode(mode) {
|
|
@@ -349,6 +349,8 @@ export function createWebUiPreferencesMethods(options = {}) {
|
|
|
349
349
|
promptsPreviewCollapsed: normalizeBoolean(hasOwn(source, 'promptsPreviewCollapsed') ? source.promptsPreviewCollapsed : this.promptsPreviewCollapsed, true),
|
|
350
350
|
sysPromptScope: normalizeSysPromptScope(hasOwn(source, 'sysPromptScope') ? source.sysPromptScope : this.sysPromptScope),
|
|
351
351
|
sysPromptMode: normalizeSysPromptMode(hasOwn(source, 'sysPromptMode') ? source.sysPromptMode : this.sysPromptMode),
|
|
352
|
+
sysPromptFileName: typeof source.sysPromptFileName === 'string'
|
|
353
|
+
? source.sysPromptFileName : (this.sysPromptFileName || ''),
|
|
352
354
|
promptPresets: normalizePromptPresets(hasOwn(source, 'promptPresets') ? source.promptPresets : this.promptPresets),
|
|
353
355
|
projectClaudeMdPath: typeof source.projectClaudeMdPath === 'string'
|
|
354
356
|
? source.projectClaudeMdPath
|
|
@@ -416,6 +418,9 @@ export function createWebUiPreferencesMethods(options = {}) {
|
|
|
416
418
|
if (typeof source.sysPromptMode === 'string') {
|
|
417
419
|
this.sysPromptMode = normalizeSysPromptMode(source.sysPromptMode);
|
|
418
420
|
}
|
|
421
|
+
if (typeof source.sysPromptFileName === 'string') {
|
|
422
|
+
this.sysPromptFileName = source.sysPromptFileName;
|
|
423
|
+
}
|
|
419
424
|
if (Array.isArray(source.promptPresets)) {
|
|
420
425
|
this.promptPresets = normalizePromptPresets(source.promptPresets);
|
|
421
426
|
if (this.selectedPromptPresetId && !this.promptPresets.some(preset => preset.id === this.selectedPromptPresetId)) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Existing native Claude presets; credentials and proxy routes are not part of the catalog.
|
|
2
|
+
export const CLAUDE_PROVIDER_PRESETS = Object.freeze([
|
|
3
|
+
{ name: 'Anthropic API', baseUrl: 'https://api.anthropic.com', model: 'claude-sonnet-4-6' },
|
|
4
|
+
{ name: 'DeepSeek', baseUrl: 'https://api.deepseek.com/anthropic', model: 'deepseek-flash' },
|
|
5
|
+
{ name: 'Zhipu GLM', baseUrl: 'https://open.bigmodel.cn/api/anthropic', model: 'glm-5' },
|
|
6
|
+
{ name: 'Z.ai GLM', baseUrl: 'https://api.z.ai/api/anthropic', model: 'glm-5' },
|
|
7
|
+
{ name: 'Qwen Coder', baseUrl: 'https://coding.dashscope.aliyuncs.com/apps/anthropic', model: 'qwen3-coder' },
|
|
8
|
+
{ name: 'Kimi k2', baseUrl: 'https://api.moonshot.cn/anthropic', model: 'kimi-k2.5' },
|
|
9
|
+
{ name: 'Kimi For Coding', baseUrl: 'https://api.kimi.com/coding/', model: 'kimi-k2.5' },
|
|
10
|
+
{ name: 'KAT-Coder', baseUrl: 'https://vanchin.streamlake.ai/api/gateway/v1/endpoints/${ENDPOINT_ID}/claude-code-proxy', model: 'KAT-Coder-Pro V1' },
|
|
11
|
+
{ name: 'Longcat', baseUrl: 'https://api.longcat.chat/anthropic', model: 'LongCat-Flash-Chat' },
|
|
12
|
+
{ name: 'MiniMax', baseUrl: 'https://api.minimaxi.com/anthropic', model: 'MiniMax-M2.7' },
|
|
13
|
+
{ name: 'MiniMax en', baseUrl: 'https://api.minimax.io/anthropic', model: 'MiniMax-M2.7' },
|
|
14
|
+
{ name: 'DouBaoSeed', baseUrl: 'https://ark.cn-beijing.volces.com/api/coding', model: 'doubao-seed-2-0-code-preview-latest' },
|
|
15
|
+
{ name: 'BaiLing', baseUrl: 'https://api.tbox.cn/api/anthropic', model: 'Ling-2.5-1T' },
|
|
16
|
+
{ name: 'ModelScope', baseUrl: 'https://api-inference.modelscope.cn', model: 'ZhipuAI/GLM-5' },
|
|
17
|
+
{ name: 'AiHubMix', baseUrl: 'https://aihubmix.com', model: 'glm-4.7' },
|
|
18
|
+
{ name: 'DMXAPI', baseUrl: 'https://www.dmxapi.cn', model: 'glm-4.7' },
|
|
19
|
+
{ name: 'PackyCode', baseUrl: 'https://www.packyapi.com', model: 'glm-4.7' },
|
|
20
|
+
{ name: 'AnyRouter', baseUrl: 'https://anyrouter.top', model: 'claude-opus-4-7[1m]' },
|
|
21
|
+
{ name: 'Xiaomi MiMo', baseUrl: 'https://api.xiaomimimo.com/anthropic', model: 'mimo-v2.5-pro' },
|
|
22
|
+
{ name: 'Xiaomi Token Plan', baseUrl: 'https://token-plan-cn.xiaomimimo.com/anthropic', model: 'mimo-v2.5-pro' },
|
|
23
|
+
]);
|