codexmate 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -2
- package/README.vi.md +27 -2
- package/README.zh.md +27 -2
- package/cli/analytics-export-args.js +7 -0
- package/cli/local-bridge.js +10 -6
- package/cli/openai-chat-routing.js +38 -0
- package/cli/routing-bridge.js +143 -0
- package/cli/session-usage.js +4 -1
- package/cli/system-prompt-files.js +75 -53
- package/cli.js +191 -9
- package/lib/data/model-prices.json +1868 -0
- package/lib/file-sharing-lan.js +111 -0
- package/lib/file-sharing.js +196 -0
- package/lib/model-test-client.js +61 -0
- package/lib/model-test.js +126 -0
- package/lib/routing-groups.js +161 -0
- package/lib/session-context-health.js +5 -1
- package/lib/session-evidence-collections.js +85 -0
- package/lib/session-features.js +15 -0
- package/lib/session-project-git.js +65 -0
- package/lib/session-projects.js +12 -1
- package/lib/session-stories.js +67 -0
- package/lib/session-usage-ledger.js +77 -0
- package/lib/session-usage-pricing.js +42 -0
- package/lib/session-usage-report.js +101 -0
- package/package.json +4 -1
- package/plugins/file-sharing/manifest.mjs +10 -0
- package/plugins/file-sharing/methods.mjs +101 -0
- package/plugins/file-sharing/overview.mjs +3 -0
- package/plugins/file-sharing/ownership.mjs +5 -0
- package/plugins/prompt-templates/computed.mjs +9 -0
- package/plugins/registry.mjs +3 -0
- package/web-ui/app.js +25 -2
- package/web-ui/index.html +3 -2
- package/web-ui/logic.session-artifacts.mjs +39 -0
- package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
- package/web-ui/modules/app.methods.agents.mjs +14 -1
- package/web-ui/modules/app.methods.install.mjs +23 -3
- package/web-ui/modules/app.methods.navigation.mjs +2 -0
- package/web-ui/modules/app.methods.prompts-editor.mjs +7 -4
- package/web-ui/modules/app.methods.session-actions.mjs +2 -2
- package/web-ui/modules/app.methods.session-browser.mjs +35 -0
- package/web-ui/modules/app.methods.system-prompt.mjs +99 -19
- package/web-ui/modules/app.methods.theme.mjs +4 -3
- package/web-ui/modules/app.methods.web-ui-preferences.mjs +12 -0
- package/web-ui/modules/i18n/locales/en.mjs +239 -5
- package/web-ui/modules/i18n/locales/ja.mjs +239 -5
- package/web-ui/modules/i18n/locales/vi.mjs +239 -5
- package/web-ui/modules/i18n/locales/zh-tw.mjs +239 -5
- package/web-ui/modules/i18n/locales/zh.mjs +239 -5
- package/web-ui/modules/model-test.mjs +82 -0
- package/web-ui/modules/plugins.methods.mjs +3 -1
- package/web-ui/modules/prompt-ecosystem.methods.mjs +4 -3
- package/web-ui/modules/routing.mjs +206 -0
- package/web-ui/modules/session-collections.mjs +65 -0
- package/web-ui/modules/session-evidence.mjs +81 -0
- package/web-ui/modules/session-features.mjs +15 -1
- package/web-ui/modules/session-git.mjs +39 -0
- package/web-ui/modules/session-stories.mjs +64 -0
- package/web-ui/modules/usage-pricing.mjs +30 -0
- package/web-ui/partials/index/layout-footer.html +1 -1
- package/web-ui/partials/index/layout-header.html +33 -12
- package/web-ui/partials/index/modals-basic.html +15 -0
- package/web-ui/partials/index/panel-plugins.html +3 -9
- package/web-ui/partials/index/panel-prompts.html +13 -7
- package/web-ui/partials/index/panel-routing.html +3 -0
- package/web-ui/partials/index/panel-sessions.html +20 -20
- package/web-ui/partials/index/panel-settings.html +11 -1
- package/web-ui/partials/index/panel-usage.html +2 -0
- package/web-ui/partials/index/plugin-file-sharing.html +47 -0
- package/web-ui/partials/index/routing-model-test.html +53 -0
- package/web-ui/partials/index/session-diagnostics.html +7 -4
- package/web-ui/partials/index/session-features.html +82 -2
- package/web-ui/partials/index/thread-handoff.html +73 -62
- package/web-ui/partials/index/usage-records.html +41 -0
- package/web-ui/res/web-ui-render.precompiled.js +1378 -230
- package/web-ui/styles/base-theme.css +1 -1
- package/web-ui/styles/modals-core.css +6 -5
- package/web-ui/styles/navigation-panels.css +4 -0
- package/web-ui/styles/plugins-panel.css +40 -1
- package/web-ui/styles/responsive.css +10 -5
- package/web-ui/styles/routing.css +78 -0
- package/web-ui/styles/session-features.css +180 -7
- package/web-ui/styles/sessions-list.css +74 -0
- package/web-ui/styles/sessions-preview.css +106 -68
- package/web-ui/styles/sessions-usage.css +8 -0
- package/web-ui/styles/settings-panel.css +30 -0
- package/web-ui/styles/system-prompt.css +8 -7
- package/web-ui/styles/theme-violet-tokens.css +52 -0
- package/web-ui/styles/theme-violet.css +1742 -0
- package/web-ui/styles.css +2 -0
package/cli.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
const { createRoutingGroups, OPENAI_CHAT_TARGET } = require('./lib/routing-groups');
|
|
3
|
+
const { createRoutingBridgeHttpHandler, OPENAI_CHAT_BASE_PATH, OPENAI_CHAT_MODEL } = require('./cli/routing-bridge');
|
|
4
|
+
const { createOpenaiChatRoutingHandler } = require('./cli/openai-chat-routing');
|
|
2
5
|
const { fs, isConfigStaging, stageConfigWrites } = require('./lib/config-change-fs');
|
|
3
6
|
const { createConfigChanges } = require('./lib/config-changes');
|
|
4
7
|
const path = require('path');
|
|
@@ -47,6 +50,7 @@ const {
|
|
|
47
50
|
formatTimestampForFileName
|
|
48
51
|
} = require('./lib/cli-file-utils');
|
|
49
52
|
const { buildLineDiff } = require('./lib/text-diff');
|
|
53
|
+
const { createModelTestService } = require('./lib/model-test');
|
|
50
54
|
const { cmdThread, handleThreadAction } = require('./lib/thread-handoff');
|
|
51
55
|
const { createStartupAuth } = require('./lib/web-startup-auth');
|
|
52
56
|
const {
|
|
@@ -123,7 +127,7 @@ const {
|
|
|
123
127
|
resolveOpenaiBridgeUpstream
|
|
124
128
|
} = require('./cli/openai-bridge');
|
|
125
129
|
const {
|
|
126
|
-
createLocalBridgeHttpHandler
|
|
130
|
+
createLocalBridgeHttpHandler, buildUpstreamPool, buildClaudeUpstreamPool
|
|
127
131
|
} = require('./cli/local-bridge');
|
|
128
132
|
const {
|
|
129
133
|
createOpenclawConfigController
|
|
@@ -140,8 +144,10 @@ const {
|
|
|
140
144
|
const {
|
|
141
145
|
createPromptHistoryController
|
|
142
146
|
} = require('./cli/prompt-history');
|
|
147
|
+
const { createFileSharingRoutes } = require('./lib/file-sharing');
|
|
143
148
|
const { createPluginConfigController } = require('./cli/plugin-config');
|
|
144
149
|
const { createSessionContextHealthController } = require('./lib/session-context-health');
|
|
150
|
+
const { createSessionUsageReportController, exportSessionUsageReport } = require('./lib/session-usage-report');
|
|
145
151
|
const { createSessionFeatures } = require('./lib/session-features');
|
|
146
152
|
const { listHandoffs } = require('./lib/thread-handoff');
|
|
147
153
|
const { discoverServers, probeServer } = require('./lib/handoff-mcp');
|
|
@@ -440,6 +446,123 @@ const localBridgeHandler = createLocalBridgeHttpHandler({
|
|
|
440
446
|
httpsAgent: HTTPS_KEEP_ALIVE_AGENT
|
|
441
447
|
});
|
|
442
448
|
|
|
449
|
+
|
|
450
|
+
const routingGroups = createRoutingGroups({
|
|
451
|
+
filePath: path.join(CODEXMATE_DIR, 'routing-groups.json'),
|
|
452
|
+
assertAllowed: target => assertToolConfigWriteAllowed(target === OPENAI_CHAT_TARGET ? 'codex' : target),
|
|
453
|
+
catalog: getRoutingCatalog
|
|
454
|
+
});
|
|
455
|
+
const routingBridgeHandler = createRoutingBridgeHttpHandler({
|
|
456
|
+
groups: routingGroups,
|
|
457
|
+
maxBodySize: MAX_API_BODY_SIZE,
|
|
458
|
+
expectedToken: typeof process.env.CODEXMATE_HTTP_TOKEN === 'string' ? process.env.CODEXMATE_HTTP_TOKEN.trim() : '',
|
|
459
|
+
createHandler(target, member) {
|
|
460
|
+
if (target === OPENAI_CHAT_TARGET) {
|
|
461
|
+
const provider = readConfig().model_providers[member.name];
|
|
462
|
+
const settings = readOpenaiBridgeSettings(OPENAI_BRIDGE_SETTINGS_FILE);
|
|
463
|
+
const upstream = settings.providers && settings.providers[member.name];
|
|
464
|
+
const normalized = resolveOpenaiBridgeUpstream(OPENAI_BRIDGE_SETTINGS_FILE, member.name);
|
|
465
|
+
const configuredKey = !normalized.error && normalized.apiKey || upstream && upstream.apiKey || provider.experimental_bearer_token
|
|
466
|
+
|| (provider.env_key ? process.env[provider.env_key] : '');
|
|
467
|
+
const key = typeof configuredKey === 'string' ? configuredKey.trim() : '';
|
|
468
|
+
return createOpenaiChatRoutingHandler({
|
|
469
|
+
member, authorization: key ? (key.startsWith('Bearer ') ? key : `Bearer ${key}`) : '',
|
|
470
|
+
upstreamHeaders: normalized.error ? undefined : normalized.headers,
|
|
471
|
+
httpAgent: HTTP_KEEP_ALIVE_AGENT, httpsAgent: HTTPS_KEEP_ALIVE_AGENT
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return createLocalBridgeHttpHandler({
|
|
475
|
+
readConfigFn: () => ({ model_providers: { [member.name]: {
|
|
476
|
+
base_url: member.baseUrl, preferred_auth_method: member.authMethod,
|
|
477
|
+
requires_openai_auth: member.requiresOpenaiAuth
|
|
478
|
+
} } }),
|
|
479
|
+
openaiBridgeFile: OPENAI_BRIDGE_SETTINGS_FILE,
|
|
480
|
+
claudeProvidersFile: CLAUDE_LOCAL_PROVIDERS_FILE,
|
|
481
|
+
readClaudeProviders: () => ({ providers: { [member.name]: member } }),
|
|
482
|
+
expectedToken: typeof process.env.CODEXMATE_HTTP_TOKEN === 'string' ? process.env.CODEXMATE_HTTP_TOKEN.trim() : '',
|
|
483
|
+
requestMaxRetries: 0,
|
|
484
|
+
maxBodySize: MAX_API_BODY_SIZE,
|
|
485
|
+
httpAgent: HTTP_KEEP_ALIVE_AGENT, httpsAgent: HTTPS_KEEP_ALIVE_AGENT
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
function getRoutingCatalog(target) {
|
|
491
|
+
let config;
|
|
492
|
+
const result = target === 'claude'
|
|
493
|
+
? buildClaudeUpstreamPool(CLAUDE_LOCAL_PROVIDERS_FILE, readClaudeLocalBridgeSettings().excludedProviders)
|
|
494
|
+
: buildUpstreamPool(() => { config = readConfig(); return config; }, OPENAI_BRIDGE_SETTINGS_FILE, readLocalBridgeSettings().excludedProviders);
|
|
495
|
+
const pool = result.pool || [];
|
|
496
|
+
if (target !== OPENAI_CHAT_TARGET) return pool;
|
|
497
|
+
return pool.map(entry => {
|
|
498
|
+
const marked = config.model_providers[entry.name].codexmate_bridge === 'openai';
|
|
499
|
+
if (!marked && !new URL(entry.baseUrl).pathname.startsWith('/bridge/openai/')) return entry;
|
|
500
|
+
const upstream = resolveOpenaiBridgeUpstream(OPENAI_BRIDGE_SETTINGS_FILE, entry.name);
|
|
501
|
+
if (upstream.error) return marked ? null : entry;
|
|
502
|
+
return { ...entry, baseUrl: upstream.baseUrl };
|
|
503
|
+
}).filter(Boolean);
|
|
504
|
+
}
|
|
505
|
+
const modelTests = createModelTestService({ providers: getModelTestProviders });
|
|
506
|
+
function getModelTestProviders(target) {
|
|
507
|
+
if (target === 'pi') {
|
|
508
|
+
const state = readPiModels();
|
|
509
|
+
if (state.error) throw new Error(state.error);
|
|
510
|
+
const apis = { 'openai-responses': 'responses', 'openai-completions': 'chat_completions' };
|
|
511
|
+
return Object.entries(state.providers).map(([name, provider]) => {
|
|
512
|
+
const key = typeof provider.apiKey === 'string' ? provider.apiKey.trim() : '';
|
|
513
|
+
const models = Array.isArray(provider.models) ? provider.models : [];
|
|
514
|
+
return { name, baseUrl: provider.baseUrl, api: apis[provider.api] || provider.api,
|
|
515
|
+
apiKey: process.env[key] || key, headers: provider.headers,
|
|
516
|
+
error: key.startsWith('!') ? '命令式凭据暂不支持真实测试,请使用已有环境变量配置' : '',
|
|
517
|
+
models: models.map(model => model.id).filter(id => typeof id === 'string' && id.trim()),
|
|
518
|
+
modelOptions: Object.fromEntries(models.filter(model => model && model.id).map(model => [model.id, {
|
|
519
|
+
api: apis[model.api || provider.api] || model.api || provider.api,
|
|
520
|
+
baseUrl: model.baseUrl || provider.baseUrl, headers: { ...provider.headers, ...model.headers },
|
|
521
|
+
maxTokens: model.maxTokens, compat: model.compat || provider.compat
|
|
522
|
+
}])) };
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
const config = readConfig();
|
|
526
|
+
const currentModels = readCurrentModels();
|
|
527
|
+
const savedModels = readModels();
|
|
528
|
+
return Object.entries(config.model_providers || {}).filter(([, provider]) => provider.base_url).map(([name, provider]) => {
|
|
529
|
+
const isBridge = provider.codexmate_bridge === 'openai' || provider.preferred_auth_method === 'openai-bridge';
|
|
530
|
+
const upstream = isBridge ? resolveOpenaiBridgeUpstream(OPENAI_BRIDGE_SETTINGS_FILE, name) : {};
|
|
531
|
+
const apiKey = upstream.apiKey || provider.experimental_bearer_token || (provider.env_key ? process.env[provider.env_key] : '');
|
|
532
|
+
const model = currentModels[name] || config.model || '';
|
|
533
|
+
return { name, models: [...new Set([model, ...savedModels].filter(Boolean))],
|
|
534
|
+
baseUrl: upstream.baseUrl || provider.base_url, apiKey,
|
|
535
|
+
headers: { ...provider.http_headers, ...Object.fromEntries(Object.entries(provider.env_http_headers || {})
|
|
536
|
+
.filter(([, variable]) => process.env[variable]).map(([header, variable]) => [header, process.env[variable]])), ...upstream.headers },
|
|
537
|
+
reasoningEffort: config.model_reasoning_effort, reasoningSummary: config.model_reasoning_summary,
|
|
538
|
+
verbosity: config.model_verbosity,
|
|
539
|
+
api: provider.codexmate_bridge === 'claude' ? 'unsupported' : upstream.targetApi || normalizeWireApi(provider.wire_api),
|
|
540
|
+
error: upstream.error || (provider.requires_openai_auth && !apiKey ? '登录凭据暂不支持此测试,请选择已配置 API Key 的供应商' : '') };
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function getRoutingState() {
|
|
544
|
+
const state = routingGroups.read();
|
|
545
|
+
const catalogs = Object.fromEntries(['codex', 'claude', OPENAI_CHAT_TARGET].map(target => [target, getRoutingCatalog(target).map(entry => ({
|
|
546
|
+
name: entry.name, model: entry.model || '', origin: new URL(entry.baseUrl).origin
|
|
547
|
+
}))]));
|
|
548
|
+
const codex = getLocalBridgeStatus();
|
|
549
|
+
const claude = getClaudeLocalBridgeStatus();
|
|
550
|
+
return { ...state, catalogs, openaiChat: { basePath: OPENAI_CHAT_BASE_PATH, model: OPENAI_CHAT_MODEL, requiresToken: !!(process.env.CODEXMATE_HTTP_TOKEN || '').trim() }, bridges: {
|
|
551
|
+
codex: { enabled: codex.enabled, active: codex.active },
|
|
552
|
+
claude: { enabled: claude.enabled, active: claude.active },
|
|
553
|
+
[OPENAI_CHAT_TARGET]: { enabled: !!state.bindings[OPENAI_CHAT_TARGET], active: !!state.bindings[OPENAI_CHAT_TARGET] }
|
|
554
|
+
} };
|
|
555
|
+
}
|
|
556
|
+
function mutateRoutingGroup(operation, params) {
|
|
557
|
+
try {
|
|
558
|
+
if (configChanges.isBusy()) return { error: '已有配置变更正在执行', errorCode: 'config-change-busy' };
|
|
559
|
+
routingGroups[operation](params || {});
|
|
560
|
+
return { success: true, ...getRoutingState() };
|
|
561
|
+
} catch (error) {
|
|
562
|
+
return { error: error.message, errorCode: error.code || 'routing-storage-error' };
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
443
566
|
function resolveWebPort() {
|
|
444
567
|
const raw = process.env.CODEXMATE_PORT;
|
|
445
568
|
if (!raw) return DEFAULT_WEB_PORT;
|
|
@@ -1048,7 +1171,7 @@ function normalizeSettingsTabPreference(value) {
|
|
|
1048
1171
|
|
|
1049
1172
|
function normalizeMainTabPreference(value) {
|
|
1050
1173
|
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
1051
|
-
const allowed = new Set(['dashboard', 'config', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
|
|
1174
|
+
const allowed = new Set(['dashboard', 'config', 'routing', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
|
|
1052
1175
|
return allowed.has(normalized) ? normalized : 'dashboard';
|
|
1053
1176
|
}
|
|
1054
1177
|
|
|
@@ -1066,7 +1189,7 @@ function normalizeUsageTimeRangePreference(value) {
|
|
|
1066
1189
|
function normalizePromptsSubTabPreference(value) {
|
|
1067
1190
|
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
1068
1191
|
if (normalized === 'claude-project') return normalized;
|
|
1069
|
-
if (normalized === 'system') return normalized;
|
|
1192
|
+
if (normalized === 'system' || normalized === 'opencode') return normalized;
|
|
1070
1193
|
return 'codex';
|
|
1071
1194
|
}
|
|
1072
1195
|
|
|
@@ -1086,7 +1209,7 @@ function normalizeSidebarCollapsedPreference(value) {
|
|
|
1086
1209
|
|
|
1087
1210
|
function normalizeThemePreference(value) {
|
|
1088
1211
|
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
1089
|
-
return normalized === 'dark' || normalized === 'ocean' ? normalized : 'light';
|
|
1212
|
+
return normalized === 'dark' || normalized === 'ocean' || normalized === 'violet' ? normalized : 'light';
|
|
1090
1213
|
}
|
|
1091
1214
|
|
|
1092
1215
|
function normalizeSessionFilterSourcePreference(value) {
|
|
@@ -1158,6 +1281,7 @@ function normalizeWebUiPreferences(value = {}) {
|
|
|
1158
1281
|
promptsPreviewCollapsed: normalizeBooleanPreference(source.promptsPreviewCollapsed, true),
|
|
1159
1282
|
sysPromptScope: normalizeSysPromptScopePreference(source.sysPromptScope),
|
|
1160
1283
|
sysPromptMode: normalizeSysPromptModePreference(source.sysPromptMode),
|
|
1284
|
+
sysPromptFileName: typeof source.sysPromptFileName === 'string' ? source.sysPromptFileName : '',
|
|
1161
1285
|
projectClaudeMdPath: typeof source.projectClaudeMdPath === 'string' ? source.projectClaudeMdPath : '',
|
|
1162
1286
|
sidebarCollapsed: normalizeSidebarCollapsedPreference(source.sidebarCollapsed),
|
|
1163
1287
|
theme: normalizeThemePreference(source.theme),
|
|
@@ -1174,6 +1298,7 @@ function normalizeWebUiPreferences(value = {}) {
|
|
|
1174
1298
|
navigation: {
|
|
1175
1299
|
mainTab: normalizeMainTabPreference(navigation.mainTab),
|
|
1176
1300
|
configMode: normalizeConfigModePreference(navigation.configMode),
|
|
1301
|
+
modelTestTarget: navigation.modelTestTarget === 'pi' ? 'pi' : 'codex',
|
|
1177
1302
|
settingsTab: normalizeSettingsTabPreference(navigation.settingsTab),
|
|
1178
1303
|
skillsTargetApp: navigation.skillsTargetApp === 'claude' || navigation.skillsTargetApp === 'pi'
|
|
1179
1304
|
? navigation.skillsTargetApp
|
|
@@ -3086,6 +3211,7 @@ const {
|
|
|
3086
3211
|
});
|
|
3087
3212
|
|
|
3088
3213
|
const {
|
|
3214
|
+
listSystemPromptFiles,
|
|
3089
3215
|
readSystemPromptFile,
|
|
3090
3216
|
saveSystemPromptFile,
|
|
3091
3217
|
buildSystemPromptDiff
|
|
@@ -7867,6 +7993,8 @@ async function listSessionUsage(params = {}) {
|
|
|
7867
7993
|
}
|
|
7868
7994
|
|
|
7869
7995
|
async function exportSessionUsage(params = {}) {
|
|
7996
|
+
if (params.attribution !== undefined && !['session', 'records'].includes(params.attribution)) return { error: 'Invalid attribution' };
|
|
7997
|
+
if (params.attribution === 'records') return exportSessionUsageReport(await sessionUsageReport.read(params), params.format);
|
|
7870
7998
|
return exportSessionUsageCore(params, {
|
|
7871
7999
|
listSessionUsage
|
|
7872
8000
|
});
|
|
@@ -9902,11 +10030,14 @@ async function extractMessagesFromFile(filePath, source, options = {}) {
|
|
|
9902
10030
|
return state;
|
|
9903
10031
|
}
|
|
9904
10032
|
|
|
9905
|
-
const { readSessionContextHealth, readSessionContextNode, iterateSessionContextNodes } = createSessionContextHealthController({
|
|
10033
|
+
const { readSessionContextHealth, readSessionContextNode, iterateSessionContextNodes, iterateSessionUsageRecords } = createSessionContextHealthController({
|
|
9906
10034
|
fs, normalizeSessionSourceName, resolveSessionFilePath, queryOpencodeSessionMessages, queryZedSessionMessages
|
|
9907
10035
|
});
|
|
9908
10036
|
|
|
10037
|
+
const sessionUsageReport = createSessionUsageReportController({ fs, listSessionUsage, iterateSessionUsageRecords });
|
|
10038
|
+
|
|
9909
10039
|
const sessionFeatures = createSessionFeatures({ root: path.join(CODEXMATE_DIR, 'session-features'),
|
|
10040
|
+
usageReport: sessionUsageReport,
|
|
9910
10041
|
readNode: readSessionContextNode, nodes: iterateSessionContextNodes,
|
|
9911
10042
|
diagnostics: {
|
|
9912
10043
|
home: os.homedir(),
|
|
@@ -13660,7 +13791,7 @@ async function cmdExportSession(args = []) {
|
|
|
13660
13791
|
|
|
13661
13792
|
function printAnalyticsUsage() {
|
|
13662
13793
|
console.log('\n用法:');
|
|
13663
|
-
console.log(' codexmate analytics export [--format csv|json] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--source <codex|claude|gemini|codebuddy|workbuddy|pi|opencode|all>] [--output <PATH|->] [-o <PATH|->]');
|
|
13794
|
+
console.log(' codexmate analytics export [--format csv|json] [--attribution session|records] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--source <codex|claude|gemini|codebuddy|workbuddy|pi|opencode|all>] [--output <PATH|->] [-o <PATH|->]');
|
|
13664
13795
|
console.log('');
|
|
13665
13796
|
}
|
|
13666
13797
|
|
|
@@ -14305,6 +14436,7 @@ const PUBLIC_WEB_UI_STATIC_ASSETS = new Set([
|
|
|
14305
14436
|
|
|
14306
14437
|
function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser }) {
|
|
14307
14438
|
|
|
14439
|
+
const fileSharing = createFileSharingRoutes();
|
|
14308
14440
|
const startupAuth = createStartupAuth(readServerToken());
|
|
14309
14441
|
const httpToken = startupAuth.token;
|
|
14310
14442
|
const accessControlMiddleware = createWebAccessControlMiddleware(host);
|
|
@@ -14363,6 +14495,7 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14363
14495
|
});
|
|
14364
14496
|
res.end(body, 'utf-8');
|
|
14365
14497
|
};
|
|
14498
|
+
if (routingBridgeHandler(req, res)) return;
|
|
14366
14499
|
if (typeof localBridgeHandler === 'function' && localBridgeHandler(req, res)) {
|
|
14367
14500
|
return;
|
|
14368
14501
|
}
|
|
@@ -14403,6 +14536,10 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14403
14536
|
}
|
|
14404
14537
|
}
|
|
14405
14538
|
}
|
|
14539
|
+
if (fileSharing.match(requestPath)) {
|
|
14540
|
+
fileSharing.serve(req, res, requestPath);
|
|
14541
|
+
return;
|
|
14542
|
+
}
|
|
14406
14543
|
if (requestPath === '/api/import-skills-zip') {
|
|
14407
14544
|
void handleImportSkillsZipUpload(req, res);
|
|
14408
14545
|
return;
|
|
@@ -14787,6 +14924,9 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14787
14924
|
case 'apply-openclaw-workspace-file':
|
|
14788
14925
|
result = applyOpenclawWorkspaceFile(params || {});
|
|
14789
14926
|
break;
|
|
14927
|
+
case 'list-system-prompt-files':
|
|
14928
|
+
result = listSystemPromptFiles(params || {});
|
|
14929
|
+
break;
|
|
14790
14930
|
case 'get-system-prompt':
|
|
14791
14931
|
result = readSystemPromptFile(params || {});
|
|
14792
14932
|
break;
|
|
@@ -14990,6 +15130,10 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
14990
15130
|
}
|
|
14991
15131
|
}
|
|
14992
15132
|
break;
|
|
15133
|
+
case 'read-sessions-usage-report':
|
|
15134
|
+
if (params?.source && !isSessionSourceOrAll(params.source)) result = { error: 'Invalid source' };
|
|
15135
|
+
else result = await sessionUsageReport.read(isPlainObject(params) ? params : {});
|
|
15136
|
+
break;
|
|
14993
15137
|
case 'export-sessions-usage':
|
|
14994
15138
|
{
|
|
14995
15139
|
const usageParams = isPlainObject(params) ? params : {};
|
|
@@ -15058,9 +15202,19 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
15058
15202
|
case 'session-diagnostics-cancel':
|
|
15059
15203
|
case 'session-feature-settings-get':
|
|
15060
15204
|
case 'session-feature-settings-save':
|
|
15205
|
+
case 'session-collections-list':
|
|
15206
|
+
case 'session-collection-open':
|
|
15207
|
+
case 'session-collection-save':
|
|
15208
|
+
case 'session-collection-remove':
|
|
15209
|
+
case 'session-stories-list':
|
|
15210
|
+
case 'session-story-save':
|
|
15211
|
+
case 'session-story-remove':
|
|
15212
|
+
case 'session-project-git':
|
|
15213
|
+
case 'session-project-git-commit':
|
|
15061
15214
|
case 'session-projects':
|
|
15062
15215
|
case 'session-project-map':
|
|
15063
15216
|
case 'session-project-prompt':
|
|
15217
|
+
case 'session-usage-pricing':
|
|
15064
15218
|
case 'session-handoff-draft':
|
|
15065
15219
|
case 'session-index-status':
|
|
15066
15220
|
case 'session-index-refresh':
|
|
@@ -15149,6 +15303,24 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
15149
15303
|
case 'proxy-apply-provider':
|
|
15150
15304
|
result = applyBuiltinProxyProvider(params || {});
|
|
15151
15305
|
break;
|
|
15306
|
+
case 'model-test-catalog':
|
|
15307
|
+
result = { catalogs: modelTests.catalog() };
|
|
15308
|
+
break;
|
|
15309
|
+
case 'model-test-run':
|
|
15310
|
+
result = await modelTests.run(params || {});
|
|
15311
|
+
break;
|
|
15312
|
+
case 'routing-get':
|
|
15313
|
+
result = getRoutingState();
|
|
15314
|
+
break;
|
|
15315
|
+
case 'routing-save':
|
|
15316
|
+
result = mutateRoutingGroup('save', params);
|
|
15317
|
+
break;
|
|
15318
|
+
case 'routing-delete':
|
|
15319
|
+
result = mutateRoutingGroup('remove', params);
|
|
15320
|
+
break;
|
|
15321
|
+
case 'routing-bind':
|
|
15322
|
+
result = mutateRoutingGroup('bind', params);
|
|
15323
|
+
break;
|
|
15152
15324
|
case 'local-bridge-toggle':
|
|
15153
15325
|
result = toggleLocalBridgeProvider(params || {});
|
|
15154
15326
|
break;
|
|
@@ -15438,11 +15610,18 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
15438
15610
|
handleRequest(req, res);
|
|
15439
15611
|
}));
|
|
15440
15612
|
});
|
|
15441
|
-
|
|
15613
|
+
const lifecycle = createWebServerLifecycle({ server, host, port, httpToken, openBrowser }, {
|
|
15442
15614
|
http, process, console, setTimeout, formatHostForUrl, DEFAULT_WEB_OPEN_HOST, isAnyAddressHost,
|
|
15443
15615
|
spawn: (...args) => spawn(...args),
|
|
15444
15616
|
getUnattendedWorkflowRunner: () => getUnattendedWorkflowRunner()
|
|
15445
15617
|
});
|
|
15618
|
+
return {
|
|
15619
|
+
...lifecycle,
|
|
15620
|
+
async stop() {
|
|
15621
|
+
await lifecycle.stop();
|
|
15622
|
+
await fileSharing.dispose().catch(() => console.warn('! 文件共享临时目录清理失败'));
|
|
15623
|
+
}
|
|
15624
|
+
};
|
|
15446
15625
|
}
|
|
15447
15626
|
|
|
15448
15627
|
// Region markers are used by unit tests that extract these helpers directly.
|
|
@@ -18021,7 +18200,7 @@ function printMainHelp() {
|
|
|
18021
18200
|
console.log(' codexmate delete-model <模型> 删除模型');
|
|
18022
18201
|
console.log(' codexmate workflow <list|get|validate|run|runs|submit|active-runs|detail|resume|cancel> MCP 工作流中心');
|
|
18023
18202
|
console.log(' codexmate thread <handoff|list|fallback|ack> 交接卡与共享记忆路由');
|
|
18024
|
-
console.log(' codexmate analytics export [--format csv|json] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--output <PATH|->] [-o <PATH|->] 导出 Usage 数据');
|
|
18203
|
+
console.log(' codexmate analytics export [--format csv|json] [--attribution session|records] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--output <PATH|->] [-o <PATH|->] 导出 Usage 数据');
|
|
18025
18204
|
console.log(' codexmate run [--host <HOST>] [--no-browser] 启动 Web 界面');
|
|
18026
18205
|
console.log(' codexmate update [--check] 检查并快速更新工具');
|
|
18027
18206
|
console.log(' codexmate codex [参数...] [--follow-up <文本>|--queued-follow-up <文本> 可重复] 等同于 codex --yolo');
|
|
@@ -18046,6 +18225,10 @@ async function main() {
|
|
|
18046
18225
|
await cmdThread(args.slice(1));
|
|
18047
18226
|
return;
|
|
18048
18227
|
}
|
|
18228
|
+
if (command === 'analytics') {
|
|
18229
|
+
await cmdAnalytics(args.slice(1));
|
|
18230
|
+
return;
|
|
18231
|
+
}
|
|
18049
18232
|
const isMcpCommand = command === 'mcp';
|
|
18050
18233
|
const shouldGateInitialBootstrap = command === 'run' || isMcpCommand;
|
|
18051
18234
|
const bootstrap = ensureManagedConfigBootstrap({
|
|
@@ -18124,7 +18307,6 @@ async function main() {
|
|
|
18124
18307
|
case 'auth': cmdAuth(args.slice(1)); break;
|
|
18125
18308
|
case 'proxy': await cmdProxy(args.slice(1)); break;
|
|
18126
18309
|
case 'workflow': await cmdWorkflow(args.slice(1)); break;
|
|
18127
|
-
case 'analytics': await cmdAnalytics(args.slice(1)); break;
|
|
18128
18310
|
case 'run': await cmdStart(parseStartOptions(args.slice(1))); break;
|
|
18129
18311
|
case 'update': await cmdToolUpdate(args.slice(1)); break;
|
|
18130
18312
|
case 'start':
|