codexmate 0.1.30 → 0.1.32
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 +98 -7
- package/README.vi.md +98 -7
- package/README.zh.md +99 -7
- package/cli/agents-files.js +18 -4
- package/cli/config-bootstrap.js +25 -11
- package/cli/plugin-config.js +64 -0
- package/cli/prompt-history.js +17 -4
- package/cli/system-prompt-files.js +7 -2
- package/cli.js +396 -46
- package/lib/cli-config-engine.js +266 -0
- package/lib/cli-utils.js +2 -1
- package/lib/cli-webhook.js +1 -1
- package/lib/handoff-mcp.js +282 -0
- package/lib/http-access-control.js +335 -0
- package/lib/session-context-health.js +82 -0
- package/lib/session-context-records.js +153 -0
- package/lib/thread-handoff.js +130 -0
- package/lib/web-startup-auth.js +53 -0
- package/lib/workflow-engine.js +92 -21
- package/lib/workflow-runner.js +261 -0
- package/package.json +1 -1
- package/plugins/prompt-templates/computed.mjs +3 -3
- package/plugins/prompt-templates/invocation.mjs +73 -0
- package/plugins/prompt-templates/methods.mjs +48 -3
- package/plugins/prompt-templates/overview.mjs +2 -0
- package/web-ui/app.js +48 -2
- package/web-ui/index.html +1 -0
- package/web-ui/logic.context-health.mjs +144 -0
- package/web-ui/modules/access-token.mjs +33 -0
- package/web-ui/modules/api.mjs +2 -1
- package/web-ui/modules/app.computed.prompts.mjs +11 -0
- package/web-ui/modules/app.methods.agents.mjs +20 -3
- package/web-ui/modules/app.methods.index.mjs +6 -0
- package/web-ui/modules/app.methods.navigation.mjs +17 -3
- package/web-ui/modules/app.methods.prompts-editor.mjs +7 -0
- package/web-ui/modules/app.methods.providers.mjs +2 -2
- package/web-ui/modules/app.methods.runtime.mjs +3 -2
- package/web-ui/modules/app.methods.session-actions.mjs +3 -0
- package/web-ui/modules/app.methods.session-browser.mjs +6 -2
- package/web-ui/modules/app.methods.system-prompt.mjs +17 -2
- package/web-ui/modules/app.methods.workflows.mjs +41 -0
- package/web-ui/modules/context-health.methods.mjs +70 -0
- package/web-ui/modules/i18n/locales/en.mjs +70 -2
- package/web-ui/modules/i18n/locales/ja.mjs +70 -2
- package/web-ui/modules/i18n/locales/vi.mjs +70 -2
- package/web-ui/modules/i18n/locales/zh-tw.mjs +70 -2
- package/web-ui/modules/i18n/locales/zh.mjs +70 -2
- package/web-ui/modules/plugins.methods.mjs +2 -0
- package/web-ui/modules/prompt-ecosystem.methods.mjs +136 -0
- package/web-ui/modules/sessions-filters-url.mjs +3 -0
- package/web-ui/modules/skills.methods.mjs +6 -5
- package/web-ui/modules/thread-handoff.mjs +142 -0
- package/web-ui/partials/index/context-health.html +45 -0
- package/web-ui/partials/index/modal-prompt-invocation.html +17 -0
- package/web-ui/partials/index/panel-config-claude.html +2 -0
- package/web-ui/partials/index/panel-config-codex.html +2 -0
- package/web-ui/partials/index/panel-config-kilocode.html +3 -1
- package/web-ui/partials/index/panel-config-openclaw.html +2 -0
- package/web-ui/partials/index/panel-config-opencode.html +3 -1
- package/web-ui/partials/index/panel-config-pi.html +2 -0
- package/web-ui/partials/index/panel-dashboard.html +59 -0
- package/web-ui/partials/index/panel-plugins.html +37 -9
- package/web-ui/partials/index/panel-prompts.html +46 -18
- package/web-ui/partials/index/panel-sessions.html +35 -44
- package/web-ui/partials/index/thread-handoff.html +59 -0
- package/web-ui/res/web-ui-render.precompiled.js +1289 -177
- package/web-ui/styles/context-health.css +107 -0
- package/web-ui/styles/controls-forms.css +9 -0
- package/web-ui/styles/dashboard.css +51 -0
- package/web-ui/styles/modals-core.css +87 -0
- package/web-ui/styles/navigation-panels.css +1 -1
- package/web-ui/styles/plugins-panel.css +62 -0
- package/web-ui/styles/prompts-editor.css +34 -4
- package/web-ui/styles/responsive.css +19 -10
- package/web-ui/styles/sessions-preview.css +206 -111
- package/web-ui/styles/sub-tabs.css +181 -0
- package/web-ui/styles.css +2 -0
|
@@ -1,4 +1,69 @@
|
|
|
1
1
|
const zh = Object.freeze({
|
|
2
|
+
'contextHealth.title': "上下文体检",
|
|
3
|
+
'contextHealth.loading': "扫描完整会话…",
|
|
4
|
+
'contextHealth.composition': "上下文构成比例",
|
|
5
|
+
'contextHealth.estimateHint': "按保存的可读文本估算;不等同实际请求用量",
|
|
6
|
+
'contextHealth.nodes': "消息节点",
|
|
7
|
+
'contextHealth.topFive': "占用最多的 Top 5",
|
|
8
|
+
'contextHealth.jump': "定位此消息",
|
|
9
|
+
'contextHealth.empty': "没有可统计的文本消息",
|
|
10
|
+
'contextHealth.hotspots': "膨胀热点",
|
|
11
|
+
'contextHealth.message': "定位消息节点",
|
|
12
|
+
'contextHealth.category.system': "系统与规则",
|
|
13
|
+
'contextHealth.category.user': "用户指令",
|
|
14
|
+
'contextHealth.category.assistant': "模型文本与思考",
|
|
15
|
+
'contextHealth.category.tools': "工具输出与日志",
|
|
16
|
+
'contextHealth.category.code': "代码片段与 Diff",
|
|
17
|
+
'contextHealth.level.healthy': "健康 < 32k",
|
|
18
|
+
'contextHealth.level.heavy': "偏重 32k–64k",
|
|
19
|
+
'contextHealth.level.bloated': "膨胀 > 64k",
|
|
20
|
+
'contextHealth.reason.dominant_message': "单条超过 15%",
|
|
21
|
+
'contextHealth.reason.repeated_file_read': "重复读取文件",
|
|
22
|
+
'contextHealth.reason.long_error_log': "超长错误日志",
|
|
23
|
+
'ecosystem.rollbackConfirm': "回滚将替换当前配置与未保存内容;写入前保留当前版本备份。",
|
|
24
|
+
'ecosystem.variablesTitle': "填写模板变量",
|
|
25
|
+
'ecosystem.variablesHint': "填写后仅用于本次调用;git_diff 请粘贴差异文本,不执行命令。",
|
|
26
|
+
'ecosystem.variablesRequired': "请填写全部变量。",
|
|
27
|
+
'ecosystem.useTemplate': "使用模板",
|
|
28
|
+
'ecosystem.share': "分享模板",
|
|
29
|
+
'ecosystem.rollback': "回滚到此版本",
|
|
30
|
+
'ecosystem.historyCompare': "历史版本 → 当前内容",
|
|
31
|
+
'ecosystem.before': "历史版本",
|
|
32
|
+
'ecosystem.current': "当前内容",
|
|
33
|
+
'ecosystem.storageFail': "插件配置保存失败。",
|
|
34
|
+
'ecosystem.cacheFail': "模板配置已保存;浏览器缓存更新失败。",
|
|
35
|
+
'workflow.tagline': "选好任务,后台接着做。",
|
|
36
|
+
'workflow.options': "输入参数",
|
|
37
|
+
'workflow.title': "自动工作流",
|
|
38
|
+
'workflow.description': "提交后可关闭页面。服务重启后恢复安全步骤;写入结果不明时请求介入。",
|
|
39
|
+
'workflow.definition': "任务定义",
|
|
40
|
+
'workflow.noDefinitions': "暂无可用任务定义",
|
|
41
|
+
'workflow.input': "输入(JSON)",
|
|
42
|
+
'workflow.inputHint': "继续任务前,请先载入原输入并核对授权。",
|
|
43
|
+
'workflow.allowWrite': "授权本次任务写入",
|
|
44
|
+
'workflow.submit': "提交任务",
|
|
45
|
+
'workflow.submitting': "提交中…",
|
|
46
|
+
'workflow.refresh': "刷新结果",
|
|
47
|
+
'workflow.refreshing': "刷新中…",
|
|
48
|
+
'workflow.runs': "运行记录",
|
|
49
|
+
'workflow.empty': "暂无运行记录",
|
|
50
|
+
'workflow.emptyHint': "提交任务后,可在这里查看状态与执行结果。",
|
|
51
|
+
'workflow.loadInput': "载入原输入",
|
|
52
|
+
'workflow.resume': "确认输入与授权后继续",
|
|
53
|
+
'workflow.cancel': "取消后续执行",
|
|
54
|
+
'workflow.summary': "结果与未完成项",
|
|
55
|
+
'workflow.details': "执行详情与通知状态",
|
|
56
|
+
'workflow.runId': "运行标识",
|
|
57
|
+
'workflow.submitFailed': "提交失败",
|
|
58
|
+
'workflow.invalidJson': "请输入有效的 JSON。",
|
|
59
|
+
'workflow.status.queued': "排队中",
|
|
60
|
+
'workflow.status.running': "执行中",
|
|
61
|
+
'workflow.status.waiting': "需要处理",
|
|
62
|
+
'workflow.status.completed': "已完成",
|
|
63
|
+
'workflow.status.failed': "失败",
|
|
64
|
+
'workflow.status.cancelling': "正在取消,等待工具结束",
|
|
65
|
+
'workflow.status.cancelled': "已取消",
|
|
66
|
+
|
|
2
67
|
// Global
|
|
3
68
|
'lang.zh': '中文',
|
|
4
69
|
'lang.zh-tw': '繁體中文',
|
|
@@ -230,8 +295,11 @@ const zh = Object.freeze({
|
|
|
230
295
|
'subtitle.prompts': '编辑 AGENTS.md 与 CLAUDE.md。',
|
|
231
296
|
'prompts.subTab.codex': 'AGENTS.md (Codex)',
|
|
232
297
|
'prompts.subTab.opencode': 'AGENTS.md (OpenCode)',
|
|
233
|
-
'prompts.subTab.project': 'CLAUDE.md',
|
|
234
|
-
'prompts.subTab.system': '
|
|
298
|
+
'prompts.subTab.project': 'CLAUDE.md (Claude)',
|
|
299
|
+
'prompts.subTab.system': 'SYSTEM.md (Pi)',
|
|
300
|
+
'prompts.path.fullPath': '完整路径',
|
|
301
|
+
'prompts.actions.edit': '编辑',
|
|
302
|
+
'prompts.actions.view': '视图',
|
|
235
303
|
'prompts.pathReference.title': '插入规则引用',
|
|
236
304
|
'prompts.pathReference.placeholder': '插入规则引用…',
|
|
237
305
|
'prompts.pathReference.codex': 'AGENTS.md (Codex)',
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createPromptTemplatesMethods } from '../../plugins/prompt-templates/methods.mjs';
|
|
2
2
|
import { createTextToolsMethods } from '../../plugins/text-tools/methods.mjs';
|
|
3
|
+
import { createPromptInvocationMethods } from '../../plugins/prompt-templates/invocation.mjs';
|
|
3
4
|
|
|
4
5
|
export function createPluginsMethods() {
|
|
5
6
|
return {
|
|
6
7
|
...createPromptTemplatesMethods(),
|
|
8
|
+
...createPromptInvocationMethods(),
|
|
7
9
|
...createTextToolsMethods()
|
|
8
10
|
};
|
|
9
11
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { normalizePromptTemplateDraft } from '../../plugins/prompt-templates/methods.mjs';
|
|
2
|
+
import { persistPromptTemplatesToStorage } from '../../plugins/prompt-templates/storage.mjs';
|
|
3
|
+
|
|
4
|
+
export function createPromptEcosystemMethods({ api }) {
|
|
5
|
+
return {
|
|
6
|
+
promptHistoryTarget(kind) {
|
|
7
|
+
if (kind === 'sys') return {
|
|
8
|
+
key: `${this.sysPromptScope}:${this.sysPromptMode}:${this.sysHistoryPreviewId}`,
|
|
9
|
+
busy: this.sysPromptLoading || this.sysPromptSaving || this.sysPromptDiffVisible,
|
|
10
|
+
id: this.sysHistoryPreviewId, content: this.sysHistoryPreviewContent,
|
|
11
|
+
action: 'apply-system-prompt', saving: 'sysPromptSaving',
|
|
12
|
+
params: { scope: this.sysPromptScope, mode: this.sysPromptMode, baseHash: this.sysPromptHash },
|
|
13
|
+
load: 'loadSystemPrompt', history: 'loadSysHistory', bucket: this.sysHistoryBucket
|
|
14
|
+
};
|
|
15
|
+
const context = this.agentsContext || 'codex';
|
|
16
|
+
const action = { codex: 'apply-agents-file', opencode: 'apply-opencode-agents-file', 'claude-project': 'apply-claude-md-file' }[context];
|
|
17
|
+
if (!action) return null;
|
|
18
|
+
return {
|
|
19
|
+
key: `${context}:${this.projectClaudeMdPath || ''}:${this.promptHistoryPreviewId}`,
|
|
20
|
+
busy: this.agentsLoading || this.agentsSaving || this.agentsDiffVisible,
|
|
21
|
+
id: this.promptHistoryPreviewId, content: this.promptHistoryPreviewContent,
|
|
22
|
+
action, saving: 'agentsSaving',
|
|
23
|
+
params: { baseContent: this.agentsOriginalContent, lineEnding: this.agentsLineEnding,
|
|
24
|
+
...(context === 'claude-project' ? { baseDir: this.projectClaudeMdPath } : {}) },
|
|
25
|
+
load: 'loadPromptsContent', history: 'loadPromptHistory', bucket: this.promptHistoryBucket
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
async rollbackPromptHistory(kind = 'agents') {
|
|
29
|
+
const target = this.promptHistoryTarget(kind);
|
|
30
|
+
if (!target || target.busy || !target.id) return false;
|
|
31
|
+
const confirmed = await this.requestConfirmDialog({ title: this.t('ecosystem.rollback'),
|
|
32
|
+
message: this.t('ecosystem.rollbackConfirm'), confirmText: this.t('ecosystem.rollback'),
|
|
33
|
+
cancelText: this.t('common.cancel'), danger: true });
|
|
34
|
+
const latest = this.promptHistoryTarget(kind);
|
|
35
|
+
if (!confirmed || !latest || latest.busy || latest.key !== target.key
|
|
36
|
+
|| latest.params.baseContent !== target.params.baseContent || latest.params.baseHash !== target.params.baseHash) return false;
|
|
37
|
+
this[target.saving] = true;
|
|
38
|
+
try {
|
|
39
|
+
const result = await api(target.action, { ...target.params, content: target.content });
|
|
40
|
+
if (result.error) throw new Error(result.error);
|
|
41
|
+
await this[target.load]();
|
|
42
|
+
await this[target.history](target.bucket);
|
|
43
|
+
this.showMessage(this.t('toast.history.restored'), 'success');
|
|
44
|
+
return true;
|
|
45
|
+
} catch (error) { this.showMessage(error.message || this.t('toast.save.fail'), 'error'); return false; }
|
|
46
|
+
finally { this[target.saving] = false; }
|
|
47
|
+
},
|
|
48
|
+
async loadPluginConfig() {
|
|
49
|
+
try {
|
|
50
|
+
const result = await api('get-plugin-config', {});
|
|
51
|
+
if (result.error) throw new Error(result.error);
|
|
52
|
+
this.pluginConfigHash = result.hash;
|
|
53
|
+
this.pluginHistoryBucket = result.historyBucket;
|
|
54
|
+
this.pluginConfigLoaded = true;
|
|
55
|
+
if (result.exists) {
|
|
56
|
+
const builtins = this.promptTemplatesListRaw.filter((item) => item.isBuiltin === true);
|
|
57
|
+
this.promptTemplatesListRaw = [...builtins, ...result.templates];
|
|
58
|
+
if (!persistPromptTemplatesToStorage(this.promptTemplatesListRaw, localStorage)) {
|
|
59
|
+
this.showMessage(this.t('ecosystem.cacheFail'), 'error');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
} catch (error) { this.showMessage(error.message || this.t('toast.load.fail'), 'error'); return false; }
|
|
64
|
+
},
|
|
65
|
+
async persistPluginTemplates(list) {
|
|
66
|
+
if (this.pluginConfigSaving) return false;
|
|
67
|
+
if (!this.pluginConfigLoaded && !await this.loadPluginConfig()) return false;
|
|
68
|
+
this.pluginConfigSaving = true;
|
|
69
|
+
try {
|
|
70
|
+
const result = await api('apply-plugin-config', { baseHash: this.pluginConfigHash,
|
|
71
|
+
templates: list.map(normalizePromptTemplateDraft),
|
|
72
|
+
legacyTemplates: this.promptTemplatesListRaw.map(normalizePromptTemplateDraft) });
|
|
73
|
+
if (result.error) throw new Error(result.error);
|
|
74
|
+
this.pluginConfigHash = result.hash;
|
|
75
|
+
this.pluginHistoryBucket = result.historyBucket;
|
|
76
|
+
return true;
|
|
77
|
+
} catch (error) { this.showMessage(error.message || this.t('ecosystem.storageFail'), 'error'); return false; }
|
|
78
|
+
finally { this.pluginConfigSaving = false; }
|
|
79
|
+
},
|
|
80
|
+
async openPluginHistory() {
|
|
81
|
+
if (this.pluginHistoryLoading || this.pluginConfigSaving) return;
|
|
82
|
+
if (!this.pluginConfigLoaded && !await this.loadPluginConfig()) return;
|
|
83
|
+
this.pluginHistoryVisible = true;
|
|
84
|
+
this.pluginHistorySelectedId = '';
|
|
85
|
+
this.pluginHistoryError = '';
|
|
86
|
+
this.pluginHistoryLoading = true;
|
|
87
|
+
try {
|
|
88
|
+
const result = await api('list-prompt-history', { bucket: this.pluginHistoryBucket });
|
|
89
|
+
if (result.error) throw new Error(result.error);
|
|
90
|
+
this.pluginHistoryItems = Array.isArray(result) ? result : [];
|
|
91
|
+
} catch (error) { this.pluginHistoryError = error.message; }
|
|
92
|
+
finally { this.pluginHistoryLoading = false; }
|
|
93
|
+
},
|
|
94
|
+
async viewPluginHistory(item) {
|
|
95
|
+
if (this.pluginHistoryLoading || this.pluginConfigSaving) return;
|
|
96
|
+
this.pluginHistoryLoading = true;
|
|
97
|
+
this.pluginHistorySelectedId = '';
|
|
98
|
+
this.pluginHistoryError = '';
|
|
99
|
+
try {
|
|
100
|
+
const result = await api('get-prompt-history', { bucket: this.pluginHistoryBucket, id: item.id });
|
|
101
|
+
if (result.error) throw new Error(result.error);
|
|
102
|
+
if (!this.pluginHistoryVisible) return;
|
|
103
|
+
this.pluginHistoryContent = result.content;
|
|
104
|
+
this.pluginHistorySelectedId = item.id;
|
|
105
|
+
} catch (error) { this.pluginHistoryError = error.message; }
|
|
106
|
+
finally { this.pluginHistoryLoading = false; }
|
|
107
|
+
},
|
|
108
|
+
async rollbackPluginConfig() {
|
|
109
|
+
if (!this.pluginHistorySelectedId || this.pluginHistoryLoading || this.pluginConfigSaving) return false;
|
|
110
|
+
const id = this.pluginHistorySelectedId;
|
|
111
|
+
const content = this.pluginHistoryContent;
|
|
112
|
+
const hash = this.pluginConfigHash;
|
|
113
|
+
const confirmed = await this.requestConfirmDialog({ title: this.t('ecosystem.rollback'),
|
|
114
|
+
message: this.t('ecosystem.rollbackConfirm'), confirmText: this.t('ecosystem.rollback'),
|
|
115
|
+
cancelText: this.t('common.cancel'), danger: true });
|
|
116
|
+
if (!confirmed || id !== this.pluginHistorySelectedId || hash !== this.pluginConfigHash || this.pluginConfigSaving) return false;
|
|
117
|
+
try {
|
|
118
|
+
const parsed = JSON.parse(content);
|
|
119
|
+
if (parsed.version !== 1 || !Array.isArray(parsed.templates)) throw new Error(this.t('toast.import.invalidJson'));
|
|
120
|
+
if (!await this.persistPluginTemplates(parsed.templates)) return false;
|
|
121
|
+
const builtins = this.promptTemplatesListRaw.filter((item) => item.isBuiltin === true);
|
|
122
|
+
this.promptTemplatesListRaw = [...builtins, ...parsed.templates];
|
|
123
|
+
if (!persistPromptTemplatesToStorage(this.promptTemplatesListRaw, localStorage)) {
|
|
124
|
+
this.showMessage(this.t('ecosystem.cacheFail'), 'error');
|
|
125
|
+
}
|
|
126
|
+
this.promptTemplateDraftRaw = null;
|
|
127
|
+
this.promptTemplateSelectedId = '';
|
|
128
|
+
const first = this.promptTemplatesList[0];
|
|
129
|
+
if (first) this.selectPromptTemplate(first.id);
|
|
130
|
+
this.promptComposerSelectedTemplateId = first?.id || '';
|
|
131
|
+
await this.openPluginHistory();
|
|
132
|
+
return true;
|
|
133
|
+
} catch (error) { this.pluginHistoryError = error.message; return false; }
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAccessToken } from './access-token.mjs';
|
|
1
2
|
import {
|
|
2
3
|
buildSessionFilterCacheState,
|
|
3
4
|
isSessionQueryEnabled
|
|
@@ -119,6 +120,8 @@ export function buildSessionsFilterShareUrl(vm) {
|
|
|
119
120
|
// 使用干净的根路径作为基础 URL,避免把 /web-ui/index.html 或 /session 带进分享链接。
|
|
120
121
|
const baseUrl = window.location.origin + '/';
|
|
121
122
|
const url = canonicalizeWebUiUrl(new URL(baseUrl));
|
|
123
|
+
const accessToken = getAccessToken();
|
|
124
|
+
if (accessToken) url.searchParams.set('token', accessToken);
|
|
122
125
|
url.searchParams.set('tab', 'sessions');
|
|
123
126
|
url.searchParams.set('s_source', String(vm.sessionFilterSource || 'all'));
|
|
124
127
|
if (vm.sessionPathFilter) url.searchParams.set('s_path', String(vm.sessionPathFilter || ''));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { authorizationHeaders, withAccessToken } from './access-token.mjs';
|
|
1
2
|
function createUnsupportedSkillsTargetAppError(app) {
|
|
2
3
|
return new Error(`Unsupported skills target app: ${String(app)}`);
|
|
3
4
|
}
|
|
@@ -326,9 +327,9 @@ export function createSkillsMethods({ api }) {
|
|
|
326
327
|
: `${this.skillsTargetApp}-skills.zip`;
|
|
327
328
|
const response = await fetch(`/api/import-skills-zip?targetApp=${encodeURIComponent(this.skillsTargetApp)}`, {
|
|
328
329
|
method: 'POST',
|
|
329
|
-
headers: {
|
|
330
|
+
headers: authorizationHeaders({
|
|
330
331
|
'x-codexmate-file-name': encodeURIComponent(fileName)
|
|
331
|
-
},
|
|
332
|
+
}),
|
|
332
333
|
body: file
|
|
333
334
|
});
|
|
334
335
|
let payload = {};
|
|
@@ -414,9 +415,9 @@ export function createSkillsMethods({ api }) {
|
|
|
414
415
|
}
|
|
415
416
|
const exportedCount = Array.isArray(res.exported) ? res.exported.length : 0;
|
|
416
417
|
const failedCount = Array.isArray(res.failed) ? res.failed.length : 0;
|
|
417
|
-
const downloadUrl = typeof res.downloadPath === 'string' && res.downloadPath.trim()
|
|
418
|
+
const downloadUrl = withAccessToken(typeof res.downloadPath === 'string' && res.downloadPath.trim()
|
|
418
419
|
? res.downloadPath.trim()
|
|
419
|
-
: `/download/${encodeURIComponent(res.fileName)}
|
|
420
|
+
: `/download/${encodeURIComponent(res.fileName)}`);
|
|
420
421
|
const link = document.createElement('a');
|
|
421
422
|
link.href = downloadUrl;
|
|
422
423
|
link.download = res.fileName;
|
|
@@ -449,7 +450,7 @@ export function createSkillsMethods({ api }) {
|
|
|
449
450
|
return;
|
|
450
451
|
}
|
|
451
452
|
const link = document.createElement('a');
|
|
452
|
-
link.href = res.downloadPath || `/download/${encodeURIComponent(res.fileName)}
|
|
453
|
+
link.href = withAccessToken(res.downloadPath || `/download/${encodeURIComponent(res.fileName)}`);
|
|
453
454
|
link.download = res.fileName;
|
|
454
455
|
document.body.appendChild(link);
|
|
455
456
|
link.click();
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { api } from './api.mjs';
|
|
2
|
+
|
|
3
|
+
const STATUS_LABELS = Object.freeze({
|
|
4
|
+
awaiting_read: '等待读取',
|
|
5
|
+
file_ready: '文件已就绪',
|
|
6
|
+
read_confirmed: '目标自报已读取(附证据)'
|
|
7
|
+
});
|
|
8
|
+
const CARD_FIELDS = Object.freeze([
|
|
9
|
+
{ key: 'completed', label: '已完成事项' },
|
|
10
|
+
{ key: 'blockers', label: '阻塞事项' },
|
|
11
|
+
{ key: 'nextSteps', label: '后续步骤' },
|
|
12
|
+
{ key: 'files', label: '相关文件' }
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
function emptyDraft() {
|
|
16
|
+
return { target: '', goal: '', completed: '', blockers: '', nextSteps: '', files: '' };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const threadHandoffMixin = {
|
|
20
|
+
data() {
|
|
21
|
+
return {
|
|
22
|
+
handoffRecords: [],
|
|
23
|
+
handoffDraft: emptyDraft(),
|
|
24
|
+
handoffDrafts: new Map(),
|
|
25
|
+
handoffExpanded: false,
|
|
26
|
+
handoffFields: CARD_FIELDS,
|
|
27
|
+
handoffLoading: false,
|
|
28
|
+
handoffBusy: false,
|
|
29
|
+
handoffError: '',
|
|
30
|
+
handoffNotice: '',
|
|
31
|
+
handoffCopyText: '',
|
|
32
|
+
handoffRequestSeq: 0
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
computed: {
|
|
36
|
+
handoffSessionKey() {
|
|
37
|
+
const session = this.activeSession;
|
|
38
|
+
return session && session.sessionId
|
|
39
|
+
? JSON.stringify([session.source || '', session.sessionId]) : '';
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
watch: {
|
|
43
|
+
handoffSessionKey: {
|
|
44
|
+
immediate: true,
|
|
45
|
+
handler(key, previousKey) {
|
|
46
|
+
if (previousKey) this.handoffDrafts.set(previousKey, this.handoffDraft);
|
|
47
|
+
this.handoffRequestSeq++;
|
|
48
|
+
this.handoffRecords = [];
|
|
49
|
+
this.handoffDraft = this.handoffDrafts.get(key) || emptyDraft();
|
|
50
|
+
this.handoffExpanded = false;
|
|
51
|
+
this.handoffError = '';
|
|
52
|
+
this.handoffNotice = '';
|
|
53
|
+
this.handoffCopyText = '';
|
|
54
|
+
this.handoffLoading = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
methods: {
|
|
59
|
+
toggleThreadHandoff(event) {
|
|
60
|
+
// Nested optional-field details also emit toggle events.
|
|
61
|
+
if (event.target !== event.currentTarget) return;
|
|
62
|
+
const expanded = event.currentTarget.open;
|
|
63
|
+
if (expanded === this.handoffExpanded) return;
|
|
64
|
+
this.handoffExpanded = expanded;
|
|
65
|
+
if (expanded) void this.loadThreadHandoffs();
|
|
66
|
+
},
|
|
67
|
+
handoffStatusLabel(status) {
|
|
68
|
+
return STATUS_LABELS[status] || '未知状态';
|
|
69
|
+
},
|
|
70
|
+
async loadThreadHandoffs() {
|
|
71
|
+
const threadId = this.activeSession && this.activeSession.sessionId;
|
|
72
|
+
if (!threadId || !this.handoffExpanded) return;
|
|
73
|
+
const requestSeq = ++this.handoffRequestSeq;
|
|
74
|
+
this.handoffLoading = true;
|
|
75
|
+
this.handoffError = '';
|
|
76
|
+
try {
|
|
77
|
+
const result = await api('thread-handoff-list', { threadId });
|
|
78
|
+
if (requestSeq !== this.handoffRequestSeq) return;
|
|
79
|
+
if (result.error) throw new Error(result.error);
|
|
80
|
+
this.handoffRecords = result.records || [];
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (requestSeq === this.handoffRequestSeq) this.handoffError = '加载交接历史失败:' + error.message;
|
|
83
|
+
} finally {
|
|
84
|
+
if (requestSeq === this.handoffRequestSeq) this.handoffLoading = false;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
async createThreadHandoff() {
|
|
88
|
+
const threadId = this.activeSession && this.activeSession.sessionId;
|
|
89
|
+
if (!threadId || this.handoffBusy) return;
|
|
90
|
+
const draft = this.handoffDraft;
|
|
91
|
+
const requestSeq = this.handoffRequestSeq;
|
|
92
|
+
if (!draft.target.trim() || !draft.goal.trim()) {
|
|
93
|
+
this.handoffError = '请填写目标代理与交接目标';
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const card = { goal: draft.goal.trim() };
|
|
97
|
+
for (const { key } of CARD_FIELDS) {
|
|
98
|
+
card[key] = draft[key].split(/\r?\n/).map(line => line.trim()).filter(Boolean);
|
|
99
|
+
}
|
|
100
|
+
this.handoffBusy = true;
|
|
101
|
+
this.handoffError = '';
|
|
102
|
+
this.handoffNotice = '';
|
|
103
|
+
try {
|
|
104
|
+
const result = await api('thread-handoff-create', { threadId, target: draft.target.trim(), card, cwd: this.activeSession.cwd || undefined });
|
|
105
|
+
if (result.error) throw new Error(result.error);
|
|
106
|
+
if (requestSeq !== this.handoffRequestSeq) return;
|
|
107
|
+
this.handoffNotice = result.message || '已生成交接记录;读取状态以交接历史为准。';
|
|
108
|
+
await this.loadThreadHandoffs();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (requestSeq === this.handoffRequestSeq) this.handoffError = '生成交接失败:' + error.message;
|
|
111
|
+
} finally {
|
|
112
|
+
this.handoffBusy = false;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
async copyThreadHandoff(record) {
|
|
116
|
+
const threadId = this.activeSession && this.activeSession.sessionId;
|
|
117
|
+
if (!threadId || this.handoffBusy) return;
|
|
118
|
+
const requestSeq = this.handoffRequestSeq;
|
|
119
|
+
this.handoffBusy = true;
|
|
120
|
+
this.handoffError = '';
|
|
121
|
+
this.handoffNotice = '';
|
|
122
|
+
this.handoffCopyText = '';
|
|
123
|
+
try {
|
|
124
|
+
const result = await api('thread-handoff-fallback', { threadId, handoffId: record.id });
|
|
125
|
+
if (result.error) throw new Error(result.error);
|
|
126
|
+
if (requestSeq !== this.handoffRequestSeq) return;
|
|
127
|
+
if (result.record) {
|
|
128
|
+
this.handoffRecords = this.handoffRecords.map(item => item.id === record.id ? result.record : item);
|
|
129
|
+
}
|
|
130
|
+
if (typeof result.text !== 'string' || !result.text.trim()) throw new Error('未返回卡片文本');
|
|
131
|
+
this.handoffCopyText = result.text;
|
|
132
|
+
if (!navigator.clipboard || !navigator.clipboard.writeText) throw new Error('当前环境不支持剪贴板,请手动复制下方文本');
|
|
133
|
+
await navigator.clipboard.writeText(result.text);
|
|
134
|
+
if (requestSeq === this.handoffRequestSeq) this.handoffNotice = '已复制卡片文本;未发送给目标。请粘贴到目标会话。';
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (requestSeq === this.handoffRequestSeq) this.handoffError = '卡片复制未完成;未发送给目标:' + error.message;
|
|
137
|
+
} finally {
|
|
138
|
+
this.handoffBusy = false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<section v-if="activeSession" class="context-health" aria-labelledby="context-health-heading" :aria-busy="sessionContextHealthLoading" @vue:mounted="loadSessionContextHealth()" @vue:updated="loadSessionContextHealth()">
|
|
2
|
+
<div class="context-health-header">
|
|
3
|
+
<div class="context-health-heading">
|
|
4
|
+
<h3 id="context-health-heading" class="context-health-title">{{ t('contextHealth.title') }}</h3>
|
|
5
|
+
<span v-if="sessionContextHealth" :class="['context-health-rating', sessionContextHealth.health]" role="img" :aria-label="t('contextHealth.level.' + sessionContextHealth.health)"></span>
|
|
6
|
+
<p class="context-health-meta" v-if="sessionContextHealth">{{ sessionContextHealth.messageCount.toLocaleString() }} {{ t('contextHealth.nodes') }}</p>
|
|
7
|
+
<p class="context-health-meta" v-else-if="sessionContextHealthLoading" role="status">{{ t('contextHealth.loading') }}</p>
|
|
8
|
+
</div>
|
|
9
|
+
<div v-if="sessionContextHealth" class="context-health-summary">
|
|
10
|
+
<span class="context-health-total mono">≈ {{ sessionContextHealth.totalEstimatedTokens.toLocaleString() }} <small>Token</small></span>
|
|
11
|
+
</div>
|
|
12
|
+
<div v-else-if="sessionContextHealthLoading" class="context-health-summary context-health-summary-skeleton" aria-hidden="true"><span></span></div>
|
|
13
|
+
<button type="button" class="btn-mini context-health-refresh" @click="loadSessionContextHealth(true)" :disabled="sessionContextHealthLoading" :aria-label="t('common.refresh')" :title="t('common.refresh')">
|
|
14
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 7v5h-5M4 17v-5h5"/><path d="M6.1 7a7 7 0 0 1 11.5-1.3L20 8M4 16l2.4 2.3A7 7 0 0 0 17.9 17"/></svg>
|
|
15
|
+
</button>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="context-health-bar" role="img" :aria-label="t('contextHealth.composition')">
|
|
18
|
+
<template v-if="sessionContextHealth">
|
|
19
|
+
<span v-for="part in sessionContextHealth.categories" :key="part.id" :class="['context-health-segment', part.id]" :style="{ flexGrow: part.estimatedTokens }" :title="t('contextHealth.category.' + part.id) + ': ≈ ' + part.estimatedTokens + ' Token (' + part.percentage.toFixed(2) + '%)'" :aria-label="t('contextHealth.category.' + part.id) + ': ' + part.percentage.toFixed(2) + '%'" v-show="part.estimatedTokens > 0"></span>
|
|
20
|
+
</template>
|
|
21
|
+
</div>
|
|
22
|
+
<p v-if="sessionContextHealthError" class="form-error context-health-error" role="alert">{{ sessionContextHealthError }}</p>
|
|
23
|
+
<div v-if="sessionContextHealth" id="context-health-details" class="context-health-details">
|
|
24
|
+
<dl class="context-health-legend">
|
|
25
|
+
<div v-for="part in sessionContextHealth.categories" :key="part.id">
|
|
26
|
+
<dt><span :class="['context-health-dot', part.id]" aria-hidden="true"></span>{{ t('contextHealth.category.' + part.id) }}</dt>
|
|
27
|
+
<dd><span class="context-health-category-tokens mono">≈ {{ part.estimatedTokens.toLocaleString() }}</span><span class="context-health-category-share mono">{{ part.percentage.toFixed(2) }}%</span></dd>
|
|
28
|
+
</div>
|
|
29
|
+
</dl>
|
|
30
|
+
<p v-if="!sessionContextHealth.messageCount" class="context-health-note">{{ t('contextHealth.empty') }}</p>
|
|
31
|
+
</div>
|
|
32
|
+
<dl v-else-if="sessionContextHealthLoading" class="context-health-legend context-health-loading" aria-hidden="true">
|
|
33
|
+
<div v-for="part in ['system', 'user', 'assistant', 'tools', 'code']" :key="part" class="context-health-loading-row">
|
|
34
|
+
<dt><span :class="['context-health-dot', part]" aria-hidden="true"></span>{{ t('contextHealth.category.' + part) }}</dt>
|
|
35
|
+
<dd><span class="context-health-value-skeleton"></span><span class="context-health-share-skeleton"></span></dd>
|
|
36
|
+
</div>
|
|
37
|
+
</dl>
|
|
38
|
+
</section>
|
|
39
|
+
<article v-if="sessionContextHealthFocusedNode" ref="contextHealthFocusedMessage" class="context-health-focused-message" tabindex="-1" :data-context-node-id="sessionContextHealthFocusedNode.id" :aria-label="t('contextHealth.message')">
|
|
40
|
+
<header>
|
|
41
|
+
<div><strong>{{ t('contextHealth.message') }}</strong><span class="context-health-meta mono">{{ sessionContextHealthFocusedNode.id }}</span></div>
|
|
42
|
+
<button type="button" class="btn-mini context-health-refresh" @click="sessionContextHealthFocusedNode = null" :aria-label="t('common.close')"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" aria-hidden="true"><path d="m6 6 12 12M18 6 6 18"/></svg></button>
|
|
43
|
+
</header>
|
|
44
|
+
<pre>{{ sessionContextHealthFocusedNode.text }}</pre>
|
|
45
|
+
</article>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div v-if="promptInvocationVisible" class="modal-overlay" @click.self="closePromptTemplateInvocation">
|
|
2
|
+
<form ref="promptInvocationDialog" class="modal prompt-invocation-dialog" role="dialog" aria-modal="true" aria-labelledby="prompt-invocation-title" aria-describedby="prompt-invocation-hint" @submit.prevent="finishPromptTemplateInvocation" @keydown="onPromptInvocationKeydown">
|
|
3
|
+
<h2 id="prompt-invocation-title" class="modal-title">{{ t('ecosystem.variablesTitle') }}</h2>
|
|
4
|
+
<p id="prompt-invocation-hint" class="form-hint">{{ t('ecosystem.variablesHint') }}</p>
|
|
5
|
+
<div class="prompt-invocation-fields">
|
|
6
|
+
<label v-for="(name, index) in promptInvocationNames" :key="name" class="form-group" :for="'prompt-invocation-var-' + index">
|
|
7
|
+
<span class="form-label mono">{{ '{' + '{' + name + '}' + '}' }}</span>
|
|
8
|
+
<textarea :id="'prompt-invocation-var-' + index" v-model="promptInvocationValues[name]" class="form-input" :rows="name === 'git_diff' ? 6 : 2" autocomplete="off" spellcheck="false" aria-required="true" :aria-invalid="!!promptInvocationError && !promptInvocationValues[name].trim()"></textarea>
|
|
9
|
+
</label>
|
|
10
|
+
</div>
|
|
11
|
+
<p v-if="promptInvocationError" class="form-error" role="alert">{{ promptInvocationError }}</p>
|
|
12
|
+
<div class="modal-actions">
|
|
13
|
+
<button type="button" class="btn btn-secondary" @click="closePromptTemplateInvocation">{{ t('common.cancel') }}</button>
|
|
14
|
+
<button type="submit" class="btn btn-primary">{{ t('ecosystem.useTemplate') }}</button>
|
|
15
|
+
</div>
|
|
16
|
+
</form>
|
|
17
|
+
</div>
|
|
@@ -171,11 +171,13 @@
|
|
|
171
171
|
</div>
|
|
172
172
|
|
|
173
173
|
<div v-if="!isToolConfigWriteAllowed('claude')" class="tool-config-write-overlay">
|
|
174
|
+
<teleport to="body" v-if="mainTab === 'config' && configMode === 'claude'">
|
|
174
175
|
<div class="tool-config-write-overlay-card">
|
|
175
176
|
<div class="tool-config-write-overlay-title">{{ t('toolConfig.claude.lockedTitle') }}</div>
|
|
176
177
|
<p>{{ t('toolConfig.claude.lockedDesc') }}</p>
|
|
177
178
|
<button type="button" class="btn-tool" @click="setToolConfigPermission('claude', true)" :disabled="toolConfigPermissionSaving.claude">{{ t('toolConfig.enableWrite') }}</button>
|
|
178
179
|
</div>
|
|
180
|
+
</teleport>
|
|
179
181
|
</div>
|
|
180
182
|
</div>
|
|
181
183
|
</div>
|
|
@@ -190,11 +190,13 @@
|
|
|
190
190
|
</div>
|
|
191
191
|
</div>
|
|
192
192
|
<div v-if="!isToolConfigWriteAllowed('codex')" class="tool-config-write-overlay">
|
|
193
|
+
<teleport to="body" v-if="mainTab === 'config' && configMode === 'codex'">
|
|
193
194
|
<div class="tool-config-write-overlay-card">
|
|
194
195
|
<div class="tool-config-write-overlay-title">{{ t('toolConfig.codex.lockedTitle') }}</div>
|
|
195
196
|
<p>{{ t('toolConfig.codex.lockedDesc') }}</p>
|
|
196
197
|
<button type="button" class="btn-tool" @click="setToolConfigPermission('codex', true)" :disabled="toolConfigPermissionSaving.codex">{{ t('toolConfig.enableWrite') }}</button>
|
|
197
198
|
</div>
|
|
199
|
+
</teleport>
|
|
198
200
|
</div>
|
|
199
201
|
</div>
|
|
200
202
|
</div>
|
|
@@ -90,11 +90,13 @@
|
|
|
90
90
|
</section>
|
|
91
91
|
|
|
92
92
|
<div v-if="!isToolConfigWriteAllowed('kilocode')" class="tool-config-write-overlay">
|
|
93
|
-
<
|
|
93
|
+
<teleport to="body" v-if="mainTab === 'config' && configMode === 'kilocode'">
|
|
94
|
+
<div class="tool-config-write-overlay-card">
|
|
94
95
|
<div class="tool-config-write-overlay-title">{{ t('toolConfig.kilocode.lockedTitle') }}</div>
|
|
95
96
|
<p>{{ t('toolConfig.kilocode.lockedDesc') }}</p>
|
|
96
97
|
<button type="button" class="btn-tool" @click="setToolConfigPermission('kilocode', true)" :disabled="toolConfigPermissionSaving.kilocode">{{ t('toolConfig.enableWrite') }}</button>
|
|
97
98
|
</div>
|
|
99
|
+
</teleport>
|
|
98
100
|
</div>
|
|
99
101
|
</div>
|
|
100
102
|
</div>
|
|
@@ -134,11 +134,13 @@
|
|
|
134
134
|
</div>
|
|
135
135
|
</section>
|
|
136
136
|
<div v-if="!isToolConfigWriteAllowed('openclaw')" class="tool-config-write-overlay">
|
|
137
|
+
<teleport to="body" v-if="mainTab === 'config' && configMode === 'openclaw'">
|
|
137
138
|
<div class="tool-config-write-overlay-card">
|
|
138
139
|
<div class="tool-config-write-overlay-title">{{ t('toolConfig.openclaw.lockedTitle') }}</div>
|
|
139
140
|
<p>{{ t('toolConfig.openclaw.lockedDesc') }}</p>
|
|
140
141
|
<button type="button" class="btn-tool" @click="setToolConfigPermission('openclaw', true)" :disabled="toolConfigPermissionSaving.openclaw">{{ t('toolConfig.enableWrite') }}</button>
|
|
141
142
|
</div>
|
|
143
|
+
</teleport>
|
|
142
144
|
</div>
|
|
143
145
|
</div>
|
|
144
146
|
</div>
|
|
@@ -156,11 +156,13 @@
|
|
|
156
156
|
</div>
|
|
157
157
|
</section>
|
|
158
158
|
<div v-if="!isToolConfigWriteAllowed('opencode')" class="tool-config-write-overlay">
|
|
159
|
-
<
|
|
159
|
+
<teleport to="body" v-if="mainTab === 'config' && configMode === 'opencode'">
|
|
160
|
+
<div class="tool-config-write-overlay-card">
|
|
160
161
|
<div class="tool-config-write-overlay-title">{{ t('toolConfig.opencode.lockedTitle') }}</div>
|
|
161
162
|
<p>{{ t('toolConfig.opencode.lockedDesc') }}</p>
|
|
162
163
|
<button type="button" class="btn-tool" @click="setToolConfigPermission('opencode', true)" :disabled="toolConfigPermissionSaving.opencode">{{ t('toolConfig.enableWrite') }}</button>
|
|
163
164
|
</div>
|
|
165
|
+
</teleport>
|
|
164
166
|
</div>
|
|
165
167
|
</div>
|
|
166
168
|
</div>
|
|
@@ -141,11 +141,13 @@
|
|
|
141
141
|
</details>
|
|
142
142
|
</section>
|
|
143
143
|
<div v-if="!isToolConfigWriteAllowed('pi')" class="tool-config-write-overlay">
|
|
144
|
+
<teleport to="body" v-if="mainTab === 'config' && configMode === 'pi'">
|
|
144
145
|
<div class="tool-config-write-overlay-card">
|
|
145
146
|
<div class="tool-config-write-overlay-title">{{ t('toolConfig.pi.lockedTitle') }}</div>
|
|
146
147
|
<p>{{ t('toolConfig.pi.lockedDesc') }}</p>
|
|
147
148
|
<button type="button" class="btn-tool" @click="setToolConfigPermission('pi', true)" :disabled="toolConfigPermissionSaving.pi">{{ t('toolConfig.enableWrite') }}</button>
|
|
148
149
|
</div>
|
|
150
|
+
</teleport>
|
|
149
151
|
</div>
|
|
150
152
|
</div>
|
|
151
153
|
</div>
|