agent-things 0.0.0-stage → 1.2.2
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/LICENSE +21 -0
- package/NOTICE +5 -0
- package/README.md +221 -2
- package/bin/agent-things.cjs +8 -0
- package/bin/antigravity-session-status.cjs +96 -0
- package/bin/claude-session-status.cjs +55 -0
- package/bin/codex-session-status.cjs +287 -0
- package/mods/agent-things-ui/.claude-plugin/plugin.json +12 -0
- package/mods/agent-things-ui/SKILL.md +10 -0
- package/mods/agent-things-ui/hooks/controls.js +112 -0
- package/mods/agent-things-ui/hooks/foundation.js +431 -0
- package/mods/agent-things-ui/hooks/hooks.json +1 -0
- package/mods/agent-things-ui/hooks/presentation.js +223 -0
- package/mods/agent-things-ui/hooks/progress.js +1 -0
- package/mods/agent-things-ui/hooks/register.js +382 -0
- package/native/bin/bridge +0 -0
- package/native/bin/bridge.json +20 -0
- package/native/session-status-bridge.swift +280 -0
- package/outputs/antigravity-session-status.js +2476 -0
- package/outputs/codex-session-status.js +1761 -0
- package/package.json +75 -4
- package/scripts/build-antigravity-bundle.cjs +35 -0
- package/scripts/build-codex-bundle.cjs +31 -0
- package/scripts/build-native-bridge.cjs +55 -0
- package/scripts/build-shared-ui.cjs +16 -0
- package/scripts/setup-antigravity-service.cjs +71 -0
- package/scripts/setup-claude-service.cjs +21 -0
- package/skills/agent-things/SKILL.en.md +95 -0
- package/skills/agent-things/SKILL.md +99 -0
- package/skills/codex/things/SKILL.en.md +10 -0
- package/skills/codex/things/SKILL.md +10 -0
- package/skills/things/SKILL.en.md +10 -0
- package/skills/things/SKILL.md +10 -0
- package/skills/things/checklist.en.md +91 -0
- package/skills/things/checklist.md +95 -0
- package/src/analysis-app-server.cjs +74 -0
- package/src/analysis-assets/output.en.schema.json +93 -0
- package/src/analysis-assets/output.schema.json +93 -0
- package/src/analysis-assets/prompt.en.txt +17 -0
- package/src/analysis-assets/prompt.zh-CN.txt +18 -0
- package/src/analysis-budget.cjs +105 -0
- package/src/analysis-git.cjs +38 -0
- package/src/analysis-history.cjs +150 -0
- package/src/analysis-ledger.cjs +82 -0
- package/src/analysis-log.cjs +62 -0
- package/src/analysis-runner.cjs +203 -0
- package/src/analysis-service.cjs +197 -0
- package/src/analysis-source.cjs +72 -0
- package/src/antigravity-card.cjs +2063 -0
- package/src/antigravity-hook.cjs +138 -0
- package/src/antigravity-mcp-config.cjs +36 -0
- package/src/app-server.cjs +96 -0
- package/src/cdp.cjs +115 -0
- package/src/claude-inline-install.cjs +38 -0
- package/src/claude-mcp-config.cjs +29 -0
- package/src/cli/arguments.cjs +30 -0
- package/src/cli/environment-probe.cjs +130 -0
- package/src/cli/integration-state.cjs +15 -0
- package/src/cli/interactive-cli.cjs +236 -0
- package/src/cli/prompt-tui.cjs +420 -0
- package/src/cli/setup-orchestrator.cjs +449 -0
- package/src/codex-mcp-config.cjs +67 -0
- package/src/harnesses/antigravity/analysis-profile.cjs +41 -0
- package/src/harnesses/antigravity/antigravity-git.cjs +89 -0
- package/src/harnesses/antigravity/antigravity-harness.js +1477 -0
- package/src/harnesses/antigravity/antigravity-injector.cjs +104 -0
- package/src/harnesses/antigravity/antigravity-migration.cjs +235 -0
- package/src/harnesses/antigravity/antigravity-service.cjs +357 -0
- package/src/harnesses/antigravity/antigravity-title.cjs +155 -0
- package/src/harnesses/antigravity/gemini-runner.cjs +304 -0
- package/src/harnesses/antigravity/transcript-cleaner.cjs +129 -0
- package/src/harnesses/antigravity/transcript-source.cjs +100 -0
- package/src/harnesses/claude/claude-harness.js +93 -0
- package/src/harnesses/claude/claude-host-helper.cjs +176 -0
- package/src/harnesses/claude/claude-injector.cjs +95 -0
- package/src/harnesses/claude/claude-local-source.cjs +106 -0
- package/src/harnesses/claude/claude-navigation.cjs +99 -0
- package/src/harnesses/claude/claude-runner.cjs +74 -0
- package/src/harnesses/claude/claude-service.cjs +313 -0
- package/src/harnesses/claude/claude-source.cjs +70 -0
- package/src/harnesses/codex/codex-analysis.cjs +10 -0
- package/src/harnesses/codex/codex-card-bridge.js +123 -0
- package/src/harnesses/codex/codex-card-events.cjs +76 -0
- package/src/harnesses/codex/codex-card.cjs +169 -0
- package/src/harnesses/codex/codex-git.cjs +24 -0
- package/src/harnesses/codex/codex-harness.js +229 -0
- package/src/harnesses/codex/codex-local-card.js +97 -0
- package/src/harnesses/codex/codex-progress-context.cjs +84 -0
- package/src/harnesses/codex/codex-service.cjs +502 -0
- package/src/i18n.cjs +174 -0
- package/src/launchd.cjs +105 -0
- package/src/lifecycle-lock.cjs +13 -0
- package/src/local-progress-http.cjs +267 -0
- package/src/manual-status-agent.cjs +12 -0
- package/src/manual-status-startup.cjs +66 -0
- package/src/manual-status-store.cjs +466 -0
- package/src/mcp-stdio.cjs +67 -0
- package/src/model-router.cjs +63 -0
- package/src/native-bridge.cjs +17 -0
- package/src/npm-updates.cjs +228 -0
- package/src/plugins/things/assets/logo.svg +13 -0
- package/src/plugins/things/plugin.json +6 -0
- package/src/plugins/things/sidecars/things_board/app.js +447 -0
- package/src/plugins/things/sidecars/things_board/index.html +2141 -0
- package/src/plugins/things/sidecars/things_board/main.mjs +652 -0
- package/src/plugins/things/sidecars/things_board/package.json +6 -0
- package/src/plugins/things/sidecars/things_board/sidecar.json +21 -0
- package/src/plugins/things/sidecars/things_board/styles.css +560 -0
- package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +434 -0
- package/src/progress-error.cjs +54 -0
- package/src/progress-tools.cjs +145 -0
- package/src/project-path.cjs +15 -0
- package/src/renderer-resource.cjs +17 -0
- package/src/request-budget.cjs +24 -0
- package/src/resolve.cjs +51 -0
- package/src/runtime-install.cjs +635 -0
- package/src/session-status-filter.cjs +136 -0
- package/src/session-status.js +992 -0
- package/src/session-view.cjs +34 -0
- package/src/startup/controller.cjs +354 -0
- package/src/startup/watch.cjs +126 -0
- package/src/state-file-lock.cjs +31 -0
- package/src/task-provenance.cjs +42 -0
- package/src/ui-foundation.cjs +435 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
// Generated from src/ui-foundation.cjs. Edit the shared source.
|
|
2
|
+
export const createPresentation = function createPresentation(lang) {
|
|
3
|
+
const normalizeLang = value => (value === 'en' ? 'en' : 'zh');
|
|
4
|
+
const currentLang = normalizeLang(lang ?? (typeof globalThis !== 'undefined' ? globalThis.__agentThingsLang : undefined));
|
|
5
|
+
const colors = { unstarted: '#9098a2', unfinished: '#c89b38', completed: '#548eea', pushed: '#a17be3' };
|
|
6
|
+
const layout = { contentWidth: 300, panelWidth: 340, progressNodes: [0, 25, 50, 75, 100] };
|
|
7
|
+
const accent = { normal: '#0169CC', hover: '#005bb3', pressed: '#004f9c' };
|
|
8
|
+
|
|
9
|
+
const locales = {
|
|
10
|
+
zh: {
|
|
11
|
+
appTitle: 'Agent Things',
|
|
12
|
+
docTitleSuffix: '任务进展',
|
|
13
|
+
defaultDocTitle: 'Agent Things 会话任务进度',
|
|
14
|
+
defaultSessionTitle: '当前会话',
|
|
15
|
+
fallbackShortTitle: '会话进度',
|
|
16
|
+
fallbackThreadTitle: '会话',
|
|
17
|
+
labels: {
|
|
18
|
+
unstarted: '尚未开始',
|
|
19
|
+
unfinished: '有遗留事项',
|
|
20
|
+
completed: '全部完成',
|
|
21
|
+
pushed: '全部完成并已推送',
|
|
22
|
+
},
|
|
23
|
+
taskLabels: {
|
|
24
|
+
todo: '待开始',
|
|
25
|
+
in_progress: '进行中',
|
|
26
|
+
blocked: '受阻',
|
|
27
|
+
needs_verification: '待验收',
|
|
28
|
+
done: '已完成',
|
|
29
|
+
unknown: '状态未知',
|
|
30
|
+
},
|
|
31
|
+
unrecordedSummary: '尚未记录进展',
|
|
32
|
+
unorganized: '未整理',
|
|
33
|
+
progressUnrecorded: '进度未记录',
|
|
34
|
+
sidebarUpdating: '正在更新进度',
|
|
35
|
+
sidebarTooltipPattern: '{title}:{status},点击记录任务进展',
|
|
36
|
+
noTasksYet: '暂无任务统计',
|
|
37
|
+
totalsPattern: '已完成 {done} / {total} 项任务',
|
|
38
|
+
basisPattern: '已完成 {done}/{total} 项任务,剩余 {remaining} 项({remainingPercent}%)',
|
|
39
|
+
basisEmpty: '暂无任务',
|
|
40
|
+
sourceAuto: '自动分析',
|
|
41
|
+
sourceManual: '手动调整',
|
|
42
|
+
sourceManualRecord: '手动记录',
|
|
43
|
+
btnUpdate: '更新进度',
|
|
44
|
+
btnUpdating: '正在分析…',
|
|
45
|
+
btnAdjust: '手动调整',
|
|
46
|
+
btnClear: '清除进度',
|
|
47
|
+
clearTooltip: '立即清除进度与任务记录',
|
|
48
|
+
clearConfirm: '确定要清除本会话的任务进度和记录吗?',
|
|
49
|
+
clearingFeedback: '正在清除…',
|
|
50
|
+
clearedFeedback: '✓ 已清空进度',
|
|
51
|
+
clearFailedPrefix: '清除失败: ',
|
|
52
|
+
openInSidebar: '在侧栏打开',
|
|
53
|
+
openPaneFailedPrefix: '打开侧栏失败: ',
|
|
54
|
+
close: '关闭',
|
|
55
|
+
expandAll: '查看全部',
|
|
56
|
+
collapse: '收起',
|
|
57
|
+
remainingHeadingPattern: '剩余任务 {count}',
|
|
58
|
+
showAllCountPattern: '查看全部 {count} 条 ›',
|
|
59
|
+
collapseArrow: '收起 ›',
|
|
60
|
+
emptyNoTasks: '点击更新进度,整理这次会话的任务',
|
|
61
|
+
emptyNoRemaining: '暂无未完成任务',
|
|
62
|
+
completedHeading: '已完成任务',
|
|
63
|
+
countArrowPattern: '{count} 条 ›',
|
|
64
|
+
notesLabel: '备注',
|
|
65
|
+
addLabel: '添加',
|
|
66
|
+
editLabel: '编辑',
|
|
67
|
+
untitledTask: '未命名事项',
|
|
68
|
+
completedTaskFallback: '已完成事项',
|
|
69
|
+
viewSource: '查看来源',
|
|
70
|
+
viewSourceAriaPrefix: '查看来源:',
|
|
71
|
+
backLabel: '‹ 返回',
|
|
72
|
+
backPlain: '返回',
|
|
73
|
+
emptyCompleted: '暂无已完成任务',
|
|
74
|
+
emptySourceText: '此记录没有可显示的原文',
|
|
75
|
+
editHeading: '手动记录会话状态',
|
|
76
|
+
progressLabel: '进度',
|
|
77
|
+
progressAltPattern: '进度 {value}%',
|
|
78
|
+
progressUnrecordedWord: '未记录',
|
|
79
|
+
currentProgressAlt: '当前进度',
|
|
80
|
+
clearValueBtn: '清空进度',
|
|
81
|
+
notePlaceholder: '记下下一步要做的事…',
|
|
82
|
+
noteAriaLabel: '事项备注',
|
|
83
|
+
sliderAriaLabel: '拖动调整进度',
|
|
84
|
+
cancelBtn: '取消',
|
|
85
|
+
saveBtn: '保存记录',
|
|
86
|
+
savingBtn: '正在保存…',
|
|
87
|
+
savingFeedback: '正在保存…',
|
|
88
|
+
savedFeedback: '✓ 保存成功',
|
|
89
|
+
saveFailedPrefix: '保存失败: ',
|
|
90
|
+
conflictBanner: '保存冲突:内容已被其他入口修改。当前草稿已保留。',
|
|
91
|
+
conflictShortToast: '保存冲突,已保留当前草稿',
|
|
92
|
+
conflictDetectedFeedback: '保存失败:检测到版本冲突',
|
|
93
|
+
resolveConflictBtn: '读取最新版本并保留草稿',
|
|
94
|
+
conflictRebasedFeedback: '基准版本已对齐最新状态,再次点击保存即可提交当前草稿。',
|
|
95
|
+
conflictReloadedFeedback: '已读取最新版本,草稿已保留。再次保存即可提交。',
|
|
96
|
+
timelineHeading: '进展记录',
|
|
97
|
+
timelineLink: '进展记录 ›',
|
|
98
|
+
emptyTimeline: '暂无进展记录',
|
|
99
|
+
dividerAlt: '分隔线',
|
|
100
|
+
loadingTitle: '正在读取会话进度…',
|
|
101
|
+
loadingAlt: '加载中',
|
|
102
|
+
loadingTasksAlt: '正在加载任务列表',
|
|
103
|
+
loadingSubtitle: '正在同步当前会话任务,完成后将自动更新…',
|
|
104
|
+
notLoadedTitle: '尚未读取到会话进度',
|
|
105
|
+
notLoadedAlt: '未读取',
|
|
106
|
+
retryLoadBtn: '重试读取',
|
|
107
|
+
processing: '正在处理…',
|
|
108
|
+
retryingStatus: '状态查询暂时失败,正在重试…',
|
|
109
|
+
locatingMessage: '正在定位消息…',
|
|
110
|
+
locatingShort: '定位中...',
|
|
111
|
+
locatingSourceMessage: '正在定位来源消息…',
|
|
112
|
+
locatedMessage: '已定位来源',
|
|
113
|
+
locatedJumpMessage: '已跳转并定位到会话来源',
|
|
114
|
+
locateSent: '已发送定位请求',
|
|
115
|
+
locateFailedPrefix: '定位失败:',
|
|
116
|
+
locateHostUnavailable: '未能连接宿主定位接口',
|
|
117
|
+
locateNotFound: '未找到对应会话消息',
|
|
118
|
+
locateUnsupported: '当前环境不支持跳转来源',
|
|
119
|
+
locateTimeout: '定位来源超时,请在原会话中确认历史消息',
|
|
120
|
+
locateNoSource: '此记录没有可定位的消息',
|
|
121
|
+
locateHostDisconnected: '当前宿主未连接,暂时无法定位来源消息',
|
|
122
|
+
locateOpenFailed: '无法打开来源会话',
|
|
123
|
+
locateUnavailable: '暂时无法定位来源消息',
|
|
124
|
+
locateCommandErrorPrefix: '跳转失败:',
|
|
125
|
+
startingAnalysisFeedback: '正在开始分析…',
|
|
126
|
+
updateFailedPrefix: '更新失败: ',
|
|
127
|
+
analysisNotDonePrefix: '分析未完成: ',
|
|
128
|
+
analysisFailedPrefix: '分析失败:',
|
|
129
|
+
analysisFailedWord: '分析失败',
|
|
130
|
+
analyzingWord: '分析中',
|
|
131
|
+
analysisFailedRetry: '请重试',
|
|
132
|
+
analysisAbnormal: '执行异常',
|
|
133
|
+
analysisStages: {
|
|
134
|
+
starting: '正在启动分析…',
|
|
135
|
+
reading: '正在读取会话…',
|
|
136
|
+
analyzing: '正在分析任务…',
|
|
137
|
+
retrying: '正在重新连接…',
|
|
138
|
+
},
|
|
139
|
+
invalidProgressError: '请输入 0–100 的整数,或留空',
|
|
140
|
+
unknownActionError: '未知错误',
|
|
141
|
+
gitCheckUnavailable: '暂时无法检测 Git 信息',
|
|
142
|
+
sidebarHintText: '如需启用侧边栏插件,请打开「开发者 → Enable Main Process Debugger」。',
|
|
143
|
+
dismissHint: '不再提醒',
|
|
144
|
+
updateStages: {
|
|
145
|
+
queued: '正在准备升级',
|
|
146
|
+
checking: '正在检查版本',
|
|
147
|
+
downloading: '正在下载新版本',
|
|
148
|
+
waiting: '等待当前分析结束',
|
|
149
|
+
installing: '正在升级',
|
|
150
|
+
},
|
|
151
|
+
updateAvailablePattern: '发现新版本 v{version}',
|
|
152
|
+
upgradedToPattern: '已升级至 v{version}',
|
|
153
|
+
updateFailedLabel: '升级失败',
|
|
154
|
+
upgradeBtn: '立即升级',
|
|
155
|
+
upgradingShort: '正在升级…',
|
|
156
|
+
pleaseWait: '请稍候',
|
|
157
|
+
completedShort: '已完成',
|
|
158
|
+
retryBtn: '重试',
|
|
159
|
+
terminalUpgradePrefix: '终端升级:',
|
|
160
|
+
reconnectHint: '正在重新连接后台,升级状态将在连接后恢复',
|
|
161
|
+
reconnectMcpHint: '请在客户端重新连接 MCP 服务',
|
|
162
|
+
cardCommandDescription: '打开会话任务进度卡片',
|
|
163
|
+
cardCommandReply: 'Agent Things · 会话任务进度',
|
|
164
|
+
cardMissingSession: '卡片缺少当前会话信息',
|
|
165
|
+
cardAuthUnavailable: '卡片授权不可用,请重新打开会话进度卡片',
|
|
166
|
+
cardSyncUnavailable: '卡片同步暂不可用',
|
|
167
|
+
cardTimeout: '卡片连接超时',
|
|
168
|
+
cardClosed: '卡片已关闭',
|
|
169
|
+
cardOpFailed: '卡片操作失败',
|
|
170
|
+
cardRequestCancelled: '请求已取消',
|
|
171
|
+
cardRequestTimeout: '请求超时,请重试',
|
|
172
|
+
cardStatusDisconnected: '状态连接暂不可用',
|
|
173
|
+
cardDaemonDisconnected: '本地进程已断开',
|
|
174
|
+
claudeInlineOffline: '本地后台连接失败',
|
|
175
|
+
mdProgressHeading: '当前会话任务进度',
|
|
176
|
+
mdStateDone: '全部完成 (100%)',
|
|
177
|
+
mdStateUnstarted: '未开始',
|
|
178
|
+
mdTasksOverview: '任务总览',
|
|
179
|
+
mdTasksEmpty: '暂无任务清单',
|
|
180
|
+
mdNotesLabel: '会话备注',
|
|
181
|
+
mdQuickActionsLabel: '快捷交互',
|
|
182
|
+
mdQuickActionsText: '可在卡片中点击“手动调整”滑动调整进度或修改备注,或点击“更新进度”开始自动分析。',
|
|
183
|
+
hookPresentedMessage: '已呈现当前会话任务进度卡片',
|
|
184
|
+
noSessionBadge: '无会话',
|
|
185
|
+
offlineBadge: '离线',
|
|
186
|
+
},
|
|
187
|
+
en: {
|
|
188
|
+
appTitle: 'Agent Things',
|
|
189
|
+
docTitleSuffix: 'Progress',
|
|
190
|
+
defaultDocTitle: 'Agent Things Progress',
|
|
191
|
+
defaultSessionTitle: 'Current session',
|
|
192
|
+
fallbackShortTitle: 'Session progress',
|
|
193
|
+
fallbackThreadTitle: 'Session',
|
|
194
|
+
labels: {
|
|
195
|
+
unstarted: 'Not started',
|
|
196
|
+
unfinished: 'Remaining items',
|
|
197
|
+
completed: 'Completed',
|
|
198
|
+
pushed: 'Completed & pushed',
|
|
199
|
+
},
|
|
200
|
+
taskLabels: {
|
|
201
|
+
todo: 'To do',
|
|
202
|
+
in_progress: 'In progress',
|
|
203
|
+
blocked: 'Blocked',
|
|
204
|
+
needs_verification: 'Needs verification',
|
|
205
|
+
done: 'Done',
|
|
206
|
+
unknown: 'Unknown status',
|
|
207
|
+
},
|
|
208
|
+
unrecordedSummary: 'No progress recorded',
|
|
209
|
+
unorganized: 'Not organized',
|
|
210
|
+
progressUnrecorded: 'Progress not recorded',
|
|
211
|
+
sidebarUpdating: 'Updating progress',
|
|
212
|
+
sidebarTooltipPattern: '{title}: {status} · Click to track progress',
|
|
213
|
+
noTasksYet: 'No task stats yet',
|
|
214
|
+
totalsPattern: '{done} of {total} tasks done',
|
|
215
|
+
basisPattern: 'Completed {done}/{total} tasks, {remaining} remaining ({remainingPercent}%)',
|
|
216
|
+
basisEmpty: 'No tasks yet',
|
|
217
|
+
sourceAuto: 'Auto-analyzed',
|
|
218
|
+
sourceManual: 'Manual',
|
|
219
|
+
sourceManualRecord: 'Manual',
|
|
220
|
+
btnUpdate: 'Update progress',
|
|
221
|
+
btnUpdating: 'Analyzing...',
|
|
222
|
+
btnAdjust: 'Adjust',
|
|
223
|
+
btnClear: 'Clear',
|
|
224
|
+
clearTooltip: 'Clear progress and task records now',
|
|
225
|
+
clearConfirm: 'Clear progress and task records for this session?',
|
|
226
|
+
clearingFeedback: 'Clearing...',
|
|
227
|
+
clearedFeedback: '✓ Cleared',
|
|
228
|
+
clearFailedPrefix: 'Clear failed: ',
|
|
229
|
+
openInSidebar: 'Open in sidebar',
|
|
230
|
+
openPaneFailedPrefix: 'Open sidebar failed: ',
|
|
231
|
+
close: 'Close',
|
|
232
|
+
expandAll: 'Show all',
|
|
233
|
+
collapse: 'Collapse',
|
|
234
|
+
remainingHeadingPattern: 'Remaining tasks ({count})',
|
|
235
|
+
showAllCountPattern: 'Show all {count} ›',
|
|
236
|
+
collapseArrow: 'Collapse ›',
|
|
237
|
+
emptyNoTasks: 'Click Update progress to organize tasks for this session',
|
|
238
|
+
emptyNoRemaining: 'No remaining tasks',
|
|
239
|
+
completedHeading: 'Completed tasks',
|
|
240
|
+
countArrowPattern: '{count} ›',
|
|
241
|
+
notesLabel: 'Notes',
|
|
242
|
+
addLabel: 'Add',
|
|
243
|
+
editLabel: 'Edit',
|
|
244
|
+
untitledTask: 'Untitled task',
|
|
245
|
+
completedTaskFallback: 'Completed task',
|
|
246
|
+
viewSource: 'View source',
|
|
247
|
+
viewSourceAriaPrefix: 'View source: ',
|
|
248
|
+
backLabel: '‹ Back',
|
|
249
|
+
backPlain: 'Back',
|
|
250
|
+
emptyCompleted: 'No completed tasks',
|
|
251
|
+
emptySourceText: 'No original message text available for this record',
|
|
252
|
+
editHeading: 'Set session status',
|
|
253
|
+
progressLabel: 'Progress',
|
|
254
|
+
progressAltPattern: 'Progress {value}%',
|
|
255
|
+
progressUnrecordedWord: 'unrecorded',
|
|
256
|
+
currentProgressAlt: 'Current progress',
|
|
257
|
+
clearValueBtn: 'Clear value',
|
|
258
|
+
notePlaceholder: 'Add next steps or notes...',
|
|
259
|
+
noteAriaLabel: 'Session notes',
|
|
260
|
+
sliderAriaLabel: 'Drag to adjust progress',
|
|
261
|
+
cancelBtn: 'Cancel',
|
|
262
|
+
saveBtn: 'Save',
|
|
263
|
+
savingBtn: 'Saving...',
|
|
264
|
+
savingFeedback: 'Saving...',
|
|
265
|
+
savedFeedback: '✓ Saved',
|
|
266
|
+
saveFailedPrefix: 'Save failed: ',
|
|
267
|
+
conflictBanner: 'Save conflict: updated elsewhere. Your draft has been kept.',
|
|
268
|
+
conflictShortToast: 'Save conflict, draft kept',
|
|
269
|
+
conflictDetectedFeedback: 'Save failed: revision conflict detected',
|
|
270
|
+
resolveConflictBtn: 'Load latest & keep draft',
|
|
271
|
+
conflictRebasedFeedback: 'Synced to latest version. Click Save again to submit your draft.',
|
|
272
|
+
conflictReloadedFeedback: 'Loaded latest version with draft preserved. Save again to submit.',
|
|
273
|
+
timelineHeading: 'Timeline',
|
|
274
|
+
timelineLink: 'Timeline ›',
|
|
275
|
+
emptyTimeline: 'No activity yet',
|
|
276
|
+
dividerAlt: 'Divider',
|
|
277
|
+
loadingTitle: 'Loading session progress...',
|
|
278
|
+
loadingAlt: 'Loading',
|
|
279
|
+
loadingTasksAlt: 'Loading task list',
|
|
280
|
+
loadingSubtitle: 'Syncing session tasks, will update automatically...',
|
|
281
|
+
notLoadedTitle: 'Session progress not loaded yet',
|
|
282
|
+
notLoadedAlt: 'Not loaded',
|
|
283
|
+
retryLoadBtn: 'Retry',
|
|
284
|
+
processing: 'Processing...',
|
|
285
|
+
retryingStatus: 'Status check failed, retrying...',
|
|
286
|
+
locatingMessage: 'Locating message...',
|
|
287
|
+
locatingShort: 'Locating...',
|
|
288
|
+
locatingSourceMessage: 'Locating source message...',
|
|
289
|
+
locatedMessage: 'Source located',
|
|
290
|
+
locatedJumpMessage: 'Jumped to source message',
|
|
291
|
+
locateSent: 'Locate request sent',
|
|
292
|
+
locateFailedPrefix: 'Locate failed: ',
|
|
293
|
+
locateHostUnavailable: 'Unable to reach host locate API',
|
|
294
|
+
locateNotFound: 'Source message not found',
|
|
295
|
+
locateUnsupported: 'Jumping to source is not supported here',
|
|
296
|
+
locateTimeout: 'Locate timed out. Please check conversation history.',
|
|
297
|
+
locateNoSource: 'No locatable source message for this item',
|
|
298
|
+
locateHostDisconnected: 'Host is disconnected, unable to locate source message',
|
|
299
|
+
locateOpenFailed: 'Unable to open source session',
|
|
300
|
+
locateUnavailable: 'Unable to locate source message right now',
|
|
301
|
+
locateCommandErrorPrefix: 'Jump failed: ',
|
|
302
|
+
startingAnalysisFeedback: 'Starting analysis...',
|
|
303
|
+
updateFailedPrefix: 'Update failed: ',
|
|
304
|
+
analysisNotDonePrefix: 'Analysis incomplete: ',
|
|
305
|
+
analysisFailedPrefix: 'Analysis failed: ',
|
|
306
|
+
analysisFailedWord: 'Analysis failed',
|
|
307
|
+
analyzingWord: 'Analyzing',
|
|
308
|
+
analysisFailedRetry: 'please retry',
|
|
309
|
+
analysisAbnormal: 'execution error',
|
|
310
|
+
analysisStages: {
|
|
311
|
+
starting: 'Starting analysis...',
|
|
312
|
+
reading: 'Reading session...',
|
|
313
|
+
analyzing: 'Analyzing tasks...',
|
|
314
|
+
retrying: 'Reconnecting...',
|
|
315
|
+
},
|
|
316
|
+
invalidProgressError: 'Enter an integer 0–100, or leave blank',
|
|
317
|
+
unknownActionError: 'Unknown error',
|
|
318
|
+
gitCheckUnavailable: 'Git status unavailable right now',
|
|
319
|
+
sidebarHintText: 'To enable the sidebar pane, open Developer → Enable Main Process Debugger.',
|
|
320
|
+
dismissHint: 'Dismiss',
|
|
321
|
+
updateStages: {
|
|
322
|
+
queued: 'Preparing upgrade',
|
|
323
|
+
checking: 'Checking version',
|
|
324
|
+
downloading: 'Downloading update',
|
|
325
|
+
waiting: 'Waiting for analysis to finish',
|
|
326
|
+
installing: 'Upgrading',
|
|
327
|
+
},
|
|
328
|
+
updateAvailablePattern: 'Update available v{version}',
|
|
329
|
+
upgradedToPattern: 'Upgraded to v{version}',
|
|
330
|
+
updateFailedLabel: 'Upgrade failed',
|
|
331
|
+
upgradeBtn: 'Upgrade',
|
|
332
|
+
upgradingShort: 'Upgrading...',
|
|
333
|
+
pleaseWait: 'Please wait',
|
|
334
|
+
completedShort: 'Done',
|
|
335
|
+
retryBtn: 'Retry',
|
|
336
|
+
terminalUpgradePrefix: 'Terminal upgrade: ',
|
|
337
|
+
reconnectHint: 'Reconnecting to background service; upgrade status will resume shortly',
|
|
338
|
+
reconnectMcpHint: 'Please reconnect the MCP server in your client',
|
|
339
|
+
cardCommandDescription: 'Open session task progress card',
|
|
340
|
+
cardCommandReply: 'Agent Things · Session Progress',
|
|
341
|
+
cardMissingSession: 'Card is missing current session info',
|
|
342
|
+
cardAuthUnavailable: 'Card authorization unavailable; please reopen the card',
|
|
343
|
+
cardSyncUnavailable: 'Card sync unavailable',
|
|
344
|
+
cardTimeout: 'Card connection timed out',
|
|
345
|
+
cardClosed: 'Card closed',
|
|
346
|
+
cardOpFailed: 'Card action failed',
|
|
347
|
+
cardRequestCancelled: 'Request cancelled',
|
|
348
|
+
cardRequestTimeout: 'Request timed out, please retry',
|
|
349
|
+
cardStatusDisconnected: 'Status connection unavailable',
|
|
350
|
+
cardDaemonDisconnected: 'Local service disconnected',
|
|
351
|
+
claudeInlineOffline: 'Local service connection failed',
|
|
352
|
+
mdProgressHeading: 'Session task progress',
|
|
353
|
+
mdStateDone: 'Completed (100%)',
|
|
354
|
+
mdStateUnstarted: 'Not started',
|
|
355
|
+
mdTasksOverview: 'Overview',
|
|
356
|
+
mdTasksEmpty: 'No task checklist yet',
|
|
357
|
+
mdNotesLabel: 'Session notes',
|
|
358
|
+
mdQuickActionsLabel: 'Quick actions',
|
|
359
|
+
mdQuickActionsText: 'Click "Adjust" on the card to set progress/notes manually, or click "Update progress" to auto-analyze.',
|
|
360
|
+
hookPresentedMessage: 'Session task progress card presented',
|
|
361
|
+
noSessionBadge: 'No session',
|
|
362
|
+
offlineBadge: 'Offline',
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
function format(template, vars = {}) {
|
|
367
|
+
return String(template || '').replace(/\{(\w+)\}/g, (_, k) => (vars[k] !== undefined ? String(vars[k]) : ''));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function forLang(targetLang) {
|
|
371
|
+
const code = normalizeLang(targetLang);
|
|
372
|
+
const dict = locales[code];
|
|
373
|
+
return {
|
|
374
|
+
lang: code,
|
|
375
|
+
strings: dict,
|
|
376
|
+
labels: dict.labels,
|
|
377
|
+
taskLabels: dict.taskLabels,
|
|
378
|
+
t(key, vars) {
|
|
379
|
+
return format(dict[key] ?? locales.zh[key] ?? key, vars);
|
|
380
|
+
},
|
|
381
|
+
formatDate(value) {
|
|
382
|
+
if (!value) return '';
|
|
383
|
+
const d = new Date(value);
|
|
384
|
+
if (Number.isNaN(d.getTime())) return '';
|
|
385
|
+
return `${d.getMonth() + 1}/${d.getDate()} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function progressValue(value, dragging = false) {
|
|
391
|
+
value = Math.max(0, Math.min(100, Math.round(value)));
|
|
392
|
+
const nearest = Math.round(value / 25) * 25;
|
|
393
|
+
return dragging && Math.abs(value - nearest) <= 2 ? nearest : value;
|
|
394
|
+
}
|
|
395
|
+
function progressState(state, value) {
|
|
396
|
+
return value === 100 ? state === 'pushed' ? 'pushed' : 'completed'
|
|
397
|
+
: value === 0 && state === 'unstarted' ? 'unstarted' : 'unfinished';
|
|
398
|
+
}
|
|
399
|
+
function draftTransition(current, event) {
|
|
400
|
+
if (event.type === 'begin') return { draft: { state: event.record?.state || 'unfinished', progress: event.record?.progress ?? null, note: event.record?.note || '' }, baseRevision: event.revision ?? event.record?.revision ?? 0, conflict: false };
|
|
401
|
+
if (event.type === 'patch') return { ...current, draft: { ...current.draft, ...event.patch } };
|
|
402
|
+
if (event.type === 'conflict') return { ...current, conflict: true };
|
|
403
|
+
if (event.type === 'rebase') return { ...current, baseRevision: event.revision, conflict: false };
|
|
404
|
+
if (event.type === 'saved' || event.type === 'cleared') return { draft: null, baseRevision: event.revision, conflict: false };
|
|
405
|
+
return current;
|
|
406
|
+
}
|
|
407
|
+
function analysisDisabled(busy, analyzing, upgradeStage) {
|
|
408
|
+
return Boolean(busy || analyzing || ['waiting', 'installing'].includes(upgradeStage));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const active = forLang(currentLang);
|
|
412
|
+
return {
|
|
413
|
+
lang: active.lang,
|
|
414
|
+
labels: active.labels,
|
|
415
|
+
colors,
|
|
416
|
+
taskLabels: active.taskLabels,
|
|
417
|
+
strings: active.strings,
|
|
418
|
+
locales,
|
|
419
|
+
layout,
|
|
420
|
+
accent,
|
|
421
|
+
t: active.t,
|
|
422
|
+
format,
|
|
423
|
+
forLang,
|
|
424
|
+
formatDate: active.formatDate,
|
|
425
|
+
progressValue,
|
|
426
|
+
progressState,
|
|
427
|
+
draftTransition,
|
|
428
|
+
analysisDisabled,
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
export function getUiForLang(lang) {
|
|
432
|
+
const base = createPresentation(lang);
|
|
433
|
+
return base.forLang ? { ...base, ...base.forLang(lang) } : base;
|
|
434
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { readConfiguredLang } = require('./i18n.cjs');
|
|
3
|
+
|
|
4
|
+
const messages = {
|
|
5
|
+
zh: {
|
|
6
|
+
INVALID_ARGUMENT: '请求参数无效',
|
|
7
|
+
SESSION_MISMATCH: '会话身份不匹配',
|
|
8
|
+
REVISION_CONFLICT: '此会话已在其他窗口更新,请重新确认',
|
|
9
|
+
REQUEST_TIMEOUT: '请求超时,请重试',
|
|
10
|
+
HOST_UNAVAILABLE: '宿主连接不可用,请检查插件状态',
|
|
11
|
+
SOURCE_NOT_FOUND: '未找到来源消息',
|
|
12
|
+
CAPABILITY_UNAVAILABLE: '当前入口暂不支持此操作',
|
|
13
|
+
ANALYSIS_FAILED: '分析失败,请查看分析记录',
|
|
14
|
+
SERVICE_STOPPING: '后台正在停止,请稍后重试',
|
|
15
|
+
REQUEST_CANCELLED: '请求已取消',
|
|
16
|
+
PROTOCOL_MISMATCH: '插件版本已更新,请重新连接宿主 MCP',
|
|
17
|
+
},
|
|
18
|
+
en: {
|
|
19
|
+
INVALID_ARGUMENT: 'Invalid request arguments',
|
|
20
|
+
SESSION_MISMATCH: 'Session identity mismatch',
|
|
21
|
+
REVISION_CONFLICT: 'This session was updated in another window; please confirm again',
|
|
22
|
+
REQUEST_TIMEOUT: 'Request timed out, please retry',
|
|
23
|
+
HOST_UNAVAILABLE: 'Host connection unavailable; check plugin status',
|
|
24
|
+
SOURCE_NOT_FOUND: 'Source message not found',
|
|
25
|
+
CAPABILITY_UNAVAILABLE: 'This action is unavailable from the current entry point',
|
|
26
|
+
ANALYSIS_FAILED: 'Analysis failed; check analysis logs',
|
|
27
|
+
SERVICE_STOPPING: 'Background service is shutting down, please retry shortly',
|
|
28
|
+
REQUEST_CANCELLED: 'Request cancelled',
|
|
29
|
+
PROTOCOL_MISMATCH: 'Plugin updated; please reconnect the host MCP server',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const retry = new Set(['REQUEST_TIMEOUT', 'HOST_UNAVAILABLE', 'ANALYSIS_FAILED', 'SERVICE_STOPPING']);
|
|
34
|
+
|
|
35
|
+
function getMessage(code, lang = readConfiguredLang()) {
|
|
36
|
+
const dict = messages[lang === 'en' ? 'en' : 'zh'];
|
|
37
|
+
return dict[code] || messages.zh[code];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function progressError(code, message, retryable = retry.has(code), lang = readConfiguredLang()) {
|
|
41
|
+
const resolved = message || getMessage(code, lang);
|
|
42
|
+
return Object.assign(new Error(resolved), { code, retryable });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function errorDetails(error, fallback = 'HOST_UNAVAILABLE', lang = readConfiguredLang()) {
|
|
46
|
+
const dict = messages[lang === 'en' ? 'en' : 'zh'];
|
|
47
|
+
const code = Object.hasOwn(dict, error?.code) ? error.code
|
|
48
|
+
: ['APP_SERVER_TIMEOUT', 'ETIMEDOUT', 'TimeoutError'].includes(error?.code || error?.name) ? 'REQUEST_TIMEOUT'
|
|
49
|
+
: error?.name === 'AbortError' ? 'REQUEST_CANCELLED' : fallback;
|
|
50
|
+
// Unclassified errors may contain host responses, user text or credentials.
|
|
51
|
+
return { code, message: Object.hasOwn(dict, error?.code) ? error.message : dict[code], retryable: retry.has(code) };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = { progressError, errorDetails, getMessage };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { sessionView } = require('./session-view.cjs');
|
|
4
|
+
const { requireGitRemote } = require('./analysis-git.cjs');
|
|
5
|
+
const { normalizeProjectPath } = require('./project-path.cjs');
|
|
6
|
+
const { filterSessionStatuses } = require('./session-status-filter.cjs');
|
|
7
|
+
const { readConfiguredLang } = require('./i18n.cjs');
|
|
8
|
+
|
|
9
|
+
function getTools(lang = readConfiguredLang()) {
|
|
10
|
+
const en = lang === 'en';
|
|
11
|
+
const taskSchema = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
knownTaskId: { type: ['string', 'null'] },
|
|
15
|
+
title: { type: 'string' },
|
|
16
|
+
summary: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
maxLength: en ? 60 : 20,
|
|
19
|
+
description: en
|
|
20
|
+
? 'Short list label, max 60 chars. Summarize task action and object concisely in English.'
|
|
21
|
+
: '列表短总结,最多20个字符,中文、英文、数字与标点均计数。概括任务动作和对象。',
|
|
22
|
+
},
|
|
23
|
+
status: { type: 'string', enum: ['todo', 'in_progress', 'blocked', 'needs_verification', 'done'] },
|
|
24
|
+
evidenceRefs: { type: 'array', items: { type: 'string' } },
|
|
25
|
+
source: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
description: en
|
|
28
|
+
? 'Verbatim continuous snippet from user prompt or final reply, verified and linked to the actual message by the service.'
|
|
29
|
+
: '原始用户提问或最终答复中的连续原文,由服务验证并关联实际消息位置。',
|
|
30
|
+
properties: { locator: { type: 'string', minLength: 10, maxLength: 240 }, turnId: { type: 'string' }, itemId: { type: 'string' } },
|
|
31
|
+
required: ['locator'],
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ['knownTaskId', 'title', 'status'],
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
};
|
|
38
|
+
const identity = { project_path: { type: 'string' }, conversation_id: { type: 'string', minLength: 1 }, expected_revision: { type: 'integer', minimum: 0 } };
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
name: 'clear_session_progress',
|
|
42
|
+
description: en
|
|
43
|
+
? 'Immediately clear progress, all completed and remaining tasks, notes, and analysis timeline for the specified session. Read the current revision before clearing.'
|
|
44
|
+
: '立即清除指定会话的进度、全部已完成及剩余任务、备注和进展记录。先读取当前版本再清除。',
|
|
45
|
+
inputSchema: { type: 'object', properties: identity, required: ['conversation_id', 'expected_revision'], additionalProperties: false },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'get_session_progress',
|
|
49
|
+
description: en
|
|
50
|
+
? 'Read the current record, task ledger, task-derived progress, and revision for a session.'
|
|
51
|
+
: '读取会话当前记录、任务清单、任务计算进度与版本。',
|
|
52
|
+
inputSchema: { type: 'object', properties: identity, required: ['conversation_id'] },
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'update_session_progress',
|
|
56
|
+
description: en
|
|
57
|
+
? 'Record a manually set percentage and note. When syncing analyzed tasks, use update_session_tasks so the service computes progress automatically.'
|
|
58
|
+
: '记录人工指定的百分比和备忘。自动分析任务时请使用 update_session_tasks,同步任务并由程序计算比例。',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: { ...identity, state: { type: 'string', enum: ['unstarted', 'unfinished', 'completed', 'pushed'] }, progress: { type: 'integer', minimum: 0, maximum: 100 }, note: { type: 'string', maxLength: 4000 } },
|
|
62
|
+
required: ['conversation_id', 'state', 'progress'],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'update_session_tasks',
|
|
67
|
+
description: en
|
|
68
|
+
? 'Create or incrementally update the task list. Use expected_revision=0 and knownTaskId=null on initial creation; keep each task summary <= 60 chars. Otherwise read revision first and submit additions or changes while preserving other tasks.'
|
|
69
|
+
: '首次创建或增量更新任务清单。首次 expected_revision=0、新任务 knownTaskId=null;每项任务 summary 最多20个字符。已有记录先读取版本,提交新增或变化项,保留其余任务。',
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: { ...identity, summary: { type: 'string', maxLength: 4000 }, tasks: { type: 'array', items: taskSchema }, removedTaskIds: { type: 'array', items: { type: 'string' } } },
|
|
73
|
+
required: ['conversation_id', 'expected_revision', 'summary', 'tasks', 'removedTaskIds'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'list_all_session_statuses',
|
|
78
|
+
description: en
|
|
79
|
+
? 'Query sessions by resolved project identity, recent 25 sessions, or global summary.'
|
|
80
|
+
: '按实际工程身份、最近25条或全局汇总查询会话。',
|
|
81
|
+
inputSchema: { type: 'object', properties: { scope: { type: 'string', enum: ['current_project', 'recent_25', 'all_projects'] }, current_session_id: { type: 'string' }, project_path: { type: 'string' } } },
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const tools = getTools('zh');
|
|
87
|
+
|
|
88
|
+
async function callProgressTool(store, name, args, options = {}) {
|
|
89
|
+
const lang = options.lang || (typeof store.lang === 'function' ? store.lang() : readConfiguredLang({ dataDir: store.file ? path.dirname(store.file) : undefined }));
|
|
90
|
+
const en = lang === 'en';
|
|
91
|
+
const {
|
|
92
|
+
projectGit = async () => ({ hasRemote: false }),
|
|
93
|
+
resolveProjects = async () => ({}),
|
|
94
|
+
resolveSources = async () => { throw new Error(en ? 'Current host does not provide message source resolution' : '当前宿主未提供消息来源解析'); },
|
|
95
|
+
onChange = () => {},
|
|
96
|
+
} = options;
|
|
97
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) throw new Error(en ? 'Invalid tool arguments' : '工具参数无效');
|
|
98
|
+
if (name === 'list_all_session_statuses') {
|
|
99
|
+
const marked = store.snapshot().records;
|
|
100
|
+
const missing = Object.keys(marked).filter(key => marked[key].state && !marked[key].projectPath && !marked[key].projectResolved);
|
|
101
|
+
if (missing.length && store.enrichProjects(await resolveProjects(missing))) await onChange();
|
|
102
|
+
const snapshot = store.snapshot();
|
|
103
|
+
const records = Object.fromEntries(Object.entries(snapshot.records).map(([key, record]) => [key, { ...record, ledger: store.data.analysis?.[key]?.ledger }]));
|
|
104
|
+
return filterSessionStatuses({ records, scope: args.scope || 'current_project', currentSessionId: args.current_session_id || '', projectPath: args.project_path });
|
|
105
|
+
}
|
|
106
|
+
if (name === 'update_session_tasks' && !Number.isInteger(args.expected_revision)) throw new Error(en ? 'expected_revision from read is required for task update' : '任务更新需要提供读取时的版本');
|
|
107
|
+
const key = store.resolveKey(args.conversation_id);
|
|
108
|
+
if (name === 'clear_session_progress') {
|
|
109
|
+
if (!Number.isInteger(args.expected_revision) || args.expected_revision < 0) throw new Error(en ? 'expected_revision from read is required to clear progress' : '清除进度需要提供读取时的版本');
|
|
110
|
+
store.update({ key, expectedRevision: args.expected_revision, record: null });
|
|
111
|
+
await onChange();
|
|
112
|
+
return { cleared: true, key, revision: store.snapshot().records[key].revision, tasks: [], progress: null, session: sessionView(store, key, { lang }) };
|
|
113
|
+
}
|
|
114
|
+
if (name === 'get_session_progress') {
|
|
115
|
+
const previous = store.snapshot().records[key];
|
|
116
|
+
if (previous?.state && !previous.projectPath && !previous.projectResolved) {
|
|
117
|
+
const projects = await resolveProjects([key]);
|
|
118
|
+
if (store.enrichProjects(projects)) await onChange();
|
|
119
|
+
}
|
|
120
|
+
const progress = store.getProgress(key);
|
|
121
|
+
const record = store.snapshot().records[key];
|
|
122
|
+
return progress
|
|
123
|
+
? { ...progress, session: sessionView(store, key, { lang }) }
|
|
124
|
+
: (record?.state === null ? { key, cleared: true, revision: record.revision, tasks: [], progress: null, session: sessionView(store, key, { lang }) } : null);
|
|
125
|
+
}
|
|
126
|
+
if (!['update_session_progress', 'update_session_tasks'].includes(name)) throw new Error(en ? 'Unknown tool' : '未知工具');
|
|
127
|
+
const previous = store.snapshot().records[key];
|
|
128
|
+
const expectedRevision = args.expected_revision ?? previous?.revision ?? 0;
|
|
129
|
+
let git;
|
|
130
|
+
if ((name === 'update_session_progress' && args.state === 'pushed') || name === 'update_session_tasks') {
|
|
131
|
+
git = await projectGit(key);
|
|
132
|
+
}
|
|
133
|
+
if (args.state === 'pushed') requireGitRemote(git, lang);
|
|
134
|
+
if (name === 'update_session_tasks') {
|
|
135
|
+
const taskSources = args.tasks.some(task => task.source) ? await resolveSources(key, args.tasks) : [];
|
|
136
|
+
const projectPath = normalizeProjectPath(git?.projectKnown ? git.projectPath : git?.projectPath || (previous?.projectSource === 'host' ? previous.projectPath : args.project_path || previous?.projectPath));
|
|
137
|
+
store.applyTaskDelta({ key, expectedRevision, taskSources, delta: { summary: args.summary, tasks: args.tasks, removedTaskIds: args.removedTaskIds }, projectGit: { ...git, projectPath } });
|
|
138
|
+
} else {
|
|
139
|
+
store.update({ key, expectedRevision, record: { state: args.state, progress: args.progress, note: args.note || '' }, projectPath: args.project_path || git?.projectPath });
|
|
140
|
+
}
|
|
141
|
+
await onChange();
|
|
142
|
+
return { ...store.getProgress(key), session: sessionView(store, key, { projectGit: git, lang }) };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = { tools, getTools, callProgressTool };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
|
|
5
|
+
function normalizeProjectPath(value) {
|
|
6
|
+
if (value == null || value === '') return null;
|
|
7
|
+
if (typeof value !== 'string' || !path.isAbsolute(value)) throw new Error('工程路径应为绝对路径');
|
|
8
|
+
try { return fs.realpathSync.native(value); }
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (['ENOENT', 'ENOTDIR'].includes(error.code)) return path.resolve(value);
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = { normalizeProjectPath };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const crypto = require('node:crypto');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
function readRendererResource({ harnessFile, rendererFile, lang } = {}) {
|
|
7
|
+
const installedFoundation = path.join(path.dirname(rendererFile), 'ui-foundation.cjs');
|
|
8
|
+
const foundation = fs.readFileSync(fs.existsSync(installedFoundation) ? installedFoundation : path.join(__dirname, 'ui-foundation.cjs'), 'utf8');
|
|
9
|
+
const langPrefix = lang ? `globalThis.__agentThingsLang = ${JSON.stringify(lang)};\n` : '';
|
|
10
|
+
const browserSource = `(() => { const module = { exports: {} }; ${langPrefix}${foundation}\nglobalThis.__agentThingsPresentation = module.exports.createPresentation(globalThis.__agentThingsLang); })();`;
|
|
11
|
+
const localFile = path.join(path.dirname(harnessFile), 'codex-local-card.js');
|
|
12
|
+
const localSource = path.basename(harnessFile) === 'codex-harness.js' && fs.existsSync(localFile) ? fs.readFileSync(localFile, 'utf8') : '';
|
|
13
|
+
const source = localSource + '\n' + browserSource + '\n' + fs.readFileSync(harnessFile, 'utf8') + '\n' + fs.readFileSync(rendererFile, 'utf8');
|
|
14
|
+
return { source, version: crypto.createHash('sha256').update(source).digest('hex') };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { readRendererResource };
|