agent-things 1.3.1 → 1.3.3
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/mods/agent-things-ui/.claude-plugin/plugin.json +1 -1
- package/mods/agent-things-ui/hooks/foundation.js +78 -1
- package/mods/agent-things-ui/hooks/register.js +78 -13
- package/outputs/antigravity-session-status.js +121 -20
- package/outputs/codex-session-status.js +175 -19
- package/package.json +1 -1
- package/scripts/build-shared-ui.cjs +1 -1
- package/src/analysis-assets/output.en.schema.json +6 -3
- package/src/analysis-assets/output.schema.json +6 -3
- package/src/analysis-assets/prompt.en.txt +1 -1
- package/src/analysis-assets/prompt.zh-CN.txt +1 -1
- package/src/analysis-history.cjs +27 -6
- package/src/analysis-service.cjs +1 -1
- package/src/antigravity-card.cjs +237 -2
- package/src/harnesses/antigravity/antigravity-harness.js +23 -1
- package/src/harnesses/claude/claude-harness.js +77 -0
- package/src/harnesses/claude/claude-service.cjs +5 -1
- package/src/harnesses/claude/claude-source.cjs +18 -5
- package/src/harnesses/codex/codex-card-bridge.js +3 -2
- package/src/harnesses/codex/codex-card.cjs +2 -1
- package/src/npm-updates.cjs +3 -2
- package/src/plugins/things/sidecars/things_board/index.html +289 -2
- package/src/plugins/things/sidecars/things_board/main.mjs +13 -5
- package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +77 -0
- package/src/session-status.js +98 -19
- package/src/ui-foundation.cjs +77 -0
|
@@ -564,6 +564,72 @@
|
|
|
564
564
|
margin-top: 8px;
|
|
565
565
|
}
|
|
566
566
|
|
|
567
|
+
.app-update {
|
|
568
|
+
margin-top: 3px;
|
|
569
|
+
padding: 10px 11px;
|
|
570
|
+
background: var(--at-hover);
|
|
571
|
+
border: 1px solid var(--at-line);
|
|
572
|
+
border-radius: 10px;
|
|
573
|
+
}
|
|
574
|
+
.app-update-row {
|
|
575
|
+
display: flex;
|
|
576
|
+
align-items: center;
|
|
577
|
+
justify-content: space-between;
|
|
578
|
+
gap: 10px;
|
|
579
|
+
}
|
|
580
|
+
.app-update-label {
|
|
581
|
+
font-size: 12px;
|
|
582
|
+
line-height: 18px;
|
|
583
|
+
color: var(--at-ink);
|
|
584
|
+
min-width: 0;
|
|
585
|
+
overflow-wrap: anywhere;
|
|
586
|
+
}
|
|
587
|
+
.app-update-button {
|
|
588
|
+
flex: none;
|
|
589
|
+
padding: 5px 10px;
|
|
590
|
+
min-height: 28px;
|
|
591
|
+
border-radius: 7px;
|
|
592
|
+
font-size: 11px;
|
|
593
|
+
}
|
|
594
|
+
.app-update-detail {
|
|
595
|
+
margin-top: 7px;
|
|
596
|
+
font-size: 11px;
|
|
597
|
+
line-height: 1.6;
|
|
598
|
+
color: var(--at-secondary);
|
|
599
|
+
white-space: pre-wrap;
|
|
600
|
+
overflow-wrap: anywhere;
|
|
601
|
+
user-select: text;
|
|
602
|
+
}
|
|
603
|
+
.app-update[data-failed=true] .app-update-detail {
|
|
604
|
+
color: var(--error);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.version-bar {
|
|
608
|
+
display: flex;
|
|
609
|
+
align-items: center;
|
|
610
|
+
justify-content: space-between;
|
|
611
|
+
gap: 10px;
|
|
612
|
+
padding: 10px 0 2px;
|
|
613
|
+
font-size: 11px;
|
|
614
|
+
line-height: 16px;
|
|
615
|
+
color: var(--at-muted);
|
|
616
|
+
}
|
|
617
|
+
.version-bar-text {
|
|
618
|
+
min-width: 0;
|
|
619
|
+
overflow-wrap: anywhere;
|
|
620
|
+
}
|
|
621
|
+
.version-bar[data-failed=true] .version-bar-text {
|
|
622
|
+
color: var(--error);
|
|
623
|
+
}
|
|
624
|
+
.version-check-button {
|
|
625
|
+
flex: none;
|
|
626
|
+
font-size: 11px;
|
|
627
|
+
color: var(--at-muted);
|
|
628
|
+
}
|
|
629
|
+
.version-check-button:hover:not(:disabled) {
|
|
630
|
+
color: inherit;
|
|
631
|
+
}
|
|
632
|
+
|
|
567
633
|
/* Views */
|
|
568
634
|
.view-heading {
|
|
569
635
|
position: sticky;
|
|
@@ -1066,6 +1132,17 @@
|
|
|
1066
1132
|
<span id="notesRowLabel">备注</span>
|
|
1067
1133
|
<span class="row-detail" id="noteOpenLabel">添加</span>
|
|
1068
1134
|
</button>
|
|
1135
|
+
<div class="app-update" id="appUpdateBox" hidden>
|
|
1136
|
+
<div class="app-update-row">
|
|
1137
|
+
<span class="app-update-label" id="appUpdateLabel" role="status"></span>
|
|
1138
|
+
<button type="button" class="primary app-update-button" id="btnAppUpdate" onclick="onUpgradeClick()">立即升级</button>
|
|
1139
|
+
</div>
|
|
1140
|
+
<div class="app-update-detail" id="appUpdateDetail" hidden></div>
|
|
1141
|
+
</div>
|
|
1142
|
+
</div>
|
|
1143
|
+
<div class="version-bar" id="versionBar" hidden>
|
|
1144
|
+
<span class="version-bar-text" id="versionBarText" role="status"></span>
|
|
1145
|
+
<button type="button" class="text-button version-check-button" id="btnCheckUpdate" onclick="onCheckUpdateClick()">检查更新</button>
|
|
1069
1146
|
</div>
|
|
1070
1147
|
</div>
|
|
1071
1148
|
|
|
@@ -1243,6 +1320,23 @@
|
|
|
1243
1320
|
unknownActionError: '未知错误',
|
|
1244
1321
|
cardOpFailed: '操作失败',
|
|
1245
1322
|
cardAuthUnavailable: '获取连接凭据失败',
|
|
1323
|
+
updateStages: { queued: '正在准备升级', checking: '正在检查版本', downloading: '正在下载新版本', waiting: '等待当前分析结束', installing: '正在升级' },
|
|
1324
|
+
updateAvailablePattern: '发现新版本 v{version}',
|
|
1325
|
+
upgradedToPattern: '已升级至 v{version}',
|
|
1326
|
+
updateFailedLabel: '升级失败',
|
|
1327
|
+
upgradeBtn: '立即升级',
|
|
1328
|
+
upgradingShort: '正在升级…',
|
|
1329
|
+
checkUpdateBtn: '检查更新',
|
|
1330
|
+
checkingUpdateShort: '正在检查…',
|
|
1331
|
+
alreadyLatestPattern: '当前已是最新版 v{version}',
|
|
1332
|
+
versionTagPattern: 'v{version}',
|
|
1333
|
+
checkUpdateFailedLabel: '检查更新失败',
|
|
1334
|
+
pleaseWait: '请稍候',
|
|
1335
|
+
completedShort: '已完成',
|
|
1336
|
+
retryBtn: '重试',
|
|
1337
|
+
terminalUpgradePrefix: '终端升级:',
|
|
1338
|
+
reconnectHint: '正在重新连接后台,升级状态将在连接后恢复',
|
|
1339
|
+
reconnectMcpHint: '请在客户端重新连接 MCP 服务',
|
|
1246
1340
|
},
|
|
1247
1341
|
en: {
|
|
1248
1342
|
docTitleSuffix: 'Progress',
|
|
@@ -1308,6 +1402,23 @@
|
|
|
1308
1402
|
unknownActionError: 'Unknown error',
|
|
1309
1403
|
cardOpFailed: 'Card action failed',
|
|
1310
1404
|
cardAuthUnavailable: 'Card authorization unavailable',
|
|
1405
|
+
updateStages: { queued: 'Preparing upgrade', checking: 'Checking version', downloading: 'Downloading update', waiting: 'Waiting for analysis to finish', installing: 'Upgrading' },
|
|
1406
|
+
updateAvailablePattern: 'Update available v{version}',
|
|
1407
|
+
upgradedToPattern: 'Upgraded to v{version}',
|
|
1408
|
+
updateFailedLabel: 'Upgrade failed',
|
|
1409
|
+
upgradeBtn: 'Upgrade',
|
|
1410
|
+
upgradingShort: 'Upgrading...',
|
|
1411
|
+
checkUpdateBtn: 'Check updates',
|
|
1412
|
+
checkingUpdateShort: 'Checking...',
|
|
1413
|
+
alreadyLatestPattern: 'Up to date (v{version})',
|
|
1414
|
+
versionTagPattern: 'v{version}',
|
|
1415
|
+
checkUpdateFailedLabel: 'Update check failed',
|
|
1416
|
+
pleaseWait: 'Please wait',
|
|
1417
|
+
completedShort: 'Done',
|
|
1418
|
+
retryBtn: 'Retry',
|
|
1419
|
+
terminalUpgradePrefix: 'Terminal upgrade: ',
|
|
1420
|
+
reconnectHint: 'Reconnecting to background service; upgrade status will resume shortly',
|
|
1421
|
+
reconnectMcpHint: 'Please reconnect the MCP server in your client',
|
|
1311
1422
|
}
|
|
1312
1423
|
};
|
|
1313
1424
|
const colors = injectedI18n.colors || {"unstarted":"#9098a2","unfinished":"#c89b38","completed":"#548eea","pushed":"#a17be3"};
|
|
@@ -1327,6 +1438,45 @@
|
|
|
1327
1438
|
return String(tmpl).replace(/\{(\w+)\}/g, function(_, k) { return vars[k] !== undefined ? String(vars[k]) : ''; });
|
|
1328
1439
|
}
|
|
1329
1440
|
let lastRenderedData = null;
|
|
1441
|
+
const computeUpdateBannerState = window.__agentThingsUpdateBannerState || function(info, dict, opts = {}) {
|
|
1442
|
+
const update = info?.update;
|
|
1443
|
+
const stage = update?.stage;
|
|
1444
|
+
const stages = dict.updateStages || {};
|
|
1445
|
+
const activeStage = Boolean(stages[stage]) || Boolean(opts.starting);
|
|
1446
|
+
const updatedAtMs = update?.updatedAt ? Date.parse(update.updatedAt) : NaN;
|
|
1447
|
+
const completed = stage === 'completed' && Number.isFinite(updatedAtMs) && Date.now() - updatedAtMs < 60000;
|
|
1448
|
+
const failed = stage === 'failed';
|
|
1449
|
+
const visible = Boolean(info?.available || activeStage || failed || completed);
|
|
1450
|
+
const command = info?.command || 'npx agent-things@latest';
|
|
1451
|
+
return {
|
|
1452
|
+
visible,
|
|
1453
|
+
active: activeStage,
|
|
1454
|
+
completed,
|
|
1455
|
+
failed,
|
|
1456
|
+
buttonDisabled: activeStage || completed,
|
|
1457
|
+
label: activeStage ? (stages[stage] || stages.queued) : failed ? dict.updateFailedLabel : completed
|
|
1458
|
+
? str('upgradedToPattern', { version: update?.currentVersion || '' }) : str('updateAvailablePattern', { version: info?.latestVersion || '' }),
|
|
1459
|
+
buttonText: activeStage ? dict.pleaseWait : completed ? dict.completedShort : failed ? dict.retryBtn : dict.upgradeBtn,
|
|
1460
|
+
detail: opts.connectionError ? `${dict.reconnectHint}\n${dict.terminalUpgradePrefix}${command}`
|
|
1461
|
+
: failed ? `${update?.error || ''}\n${dict.terminalUpgradePrefix}${command}` : (completed && update?.reconnectMcp ? dict.reconnectMcpHint : ''),
|
|
1462
|
+
versionText: opts.manualCheckStatus === 'failed' ? `${dict.checkUpdateFailedLabel}${opts.checkError ? `: ${opts.checkError}` : ''}`
|
|
1463
|
+
: (opts.manualCheckStatus === 'latest' && info?.currentVersion ? str('alreadyLatestPattern', { version: info.currentVersion }) : (info?.currentVersion ? `v${info.currentVersion}` : '')),
|
|
1464
|
+
showVersionBar: !visible,
|
|
1465
|
+
checking: Boolean(opts.checking),
|
|
1466
|
+
checkDisabled: Boolean(opts.checking),
|
|
1467
|
+
checkFailed: !visible && opts.manualCheckStatus === 'failed',
|
|
1468
|
+
checkButtonText: opts.checking ? dict.checkingUpdateShort : dict.checkUpdateBtn,
|
|
1469
|
+
};
|
|
1470
|
+
};
|
|
1471
|
+
let currentUpdateInfo = null;
|
|
1472
|
+
let updateTimer = null;
|
|
1473
|
+
let manualCheckTimer = null;
|
|
1474
|
+
let updateChecking = false;
|
|
1475
|
+
let upgradeStarting = false;
|
|
1476
|
+
let updateConnectionError = '';
|
|
1477
|
+
let manualCheckStatus = '';
|
|
1478
|
+
let manualCheckError = '';
|
|
1479
|
+
let isSessionAnalyzing = false;
|
|
1330
1480
|
|
|
1331
1481
|
function applyStaticLanguage() {
|
|
1332
1482
|
document.documentElement.lang = activeLang === 'en' ? 'en' : 'zh-CN';
|
|
@@ -1380,7 +1530,8 @@
|
|
|
1380
1530
|
const saveBtn = document.getElementById('btnSaveRecord');
|
|
1381
1531
|
if (saveBtn) saveBtn.textContent = str('saveBtn');
|
|
1382
1532
|
const btnAnalyzeEl = document.getElementById('btnAnalyze');
|
|
1383
|
-
if (btnAnalyzeEl) btnAnalyzeEl.textContent =
|
|
1533
|
+
if (btnAnalyzeEl) btnAnalyzeEl.textContent = isSessionAnalyzing ? str('btnUpdating') : str('btnUpdate');
|
|
1534
|
+
renderUpdateUi();
|
|
1384
1535
|
const summaryBlock = document.getElementById('summaryBlock');
|
|
1385
1536
|
const summaryExpandBtn = document.getElementById('summaryExpand');
|
|
1386
1537
|
if (summaryBlock && summaryExpandBtn) {
|
|
@@ -1895,6 +2046,7 @@
|
|
|
1895
2046
|
}
|
|
1896
2047
|
|
|
1897
2048
|
const analyzing = Boolean(s.analyzing || s.analysisStatus?.status === 'pending');
|
|
2049
|
+
isSessionAnalyzing = analyzing;
|
|
1898
2050
|
const analysisStatus = s.analysisStatus;
|
|
1899
2051
|
const btnAnalyze = document.getElementById('btnAnalyze');
|
|
1900
2052
|
if (btnAnalyze) {
|
|
@@ -1902,7 +2054,7 @@
|
|
|
1902
2054
|
btnAnalyze.disabled = true;
|
|
1903
2055
|
btnAnalyze.textContent = str('btnUpdating');
|
|
1904
2056
|
} else {
|
|
1905
|
-
btnAnalyze.disabled =
|
|
2057
|
+
btnAnalyze.disabled = ['waiting', 'installing'].includes(currentUpdateInfo?.update?.stage);
|
|
1906
2058
|
btnAnalyze.textContent = str('btnUpdate');
|
|
1907
2059
|
if (analysisStatus?.status === 'failed') {
|
|
1908
2060
|
showFeedback(str('analysisNotDonePrefix') + (analysisStatus.error || str('analysisAbnormal')), true);
|
|
@@ -2263,6 +2415,140 @@
|
|
|
2263
2415
|
}
|
|
2264
2416
|
}
|
|
2265
2417
|
|
|
2418
|
+
function renderUpdateUi(info) {
|
|
2419
|
+
if (info !== undefined) currentUpdateInfo = info;
|
|
2420
|
+
const banner = computeUpdateBannerState(currentUpdateInfo, locale, {
|
|
2421
|
+
starting: upgradeStarting,
|
|
2422
|
+
checking: updateChecking,
|
|
2423
|
+
connectionError: updateConnectionError,
|
|
2424
|
+
manualCheckStatus,
|
|
2425
|
+
checkError: manualCheckError,
|
|
2426
|
+
});
|
|
2427
|
+
const box = document.getElementById('appUpdateBox');
|
|
2428
|
+
const labelEl = document.getElementById('appUpdateLabel');
|
|
2429
|
+
const upgradeEl = document.getElementById('btnAppUpdate');
|
|
2430
|
+
const detailEl = document.getElementById('appUpdateDetail');
|
|
2431
|
+
const versionBarEl = document.getElementById('versionBar');
|
|
2432
|
+
const versionTextEl = document.getElementById('versionBarText');
|
|
2433
|
+
const checkBtnEl = document.getElementById('btnCheckUpdate');
|
|
2434
|
+
if (box) {
|
|
2435
|
+
box.hidden = !banner.visible;
|
|
2436
|
+
box.setAttribute('data-failed', String(banner.failed));
|
|
2437
|
+
}
|
|
2438
|
+
if (labelEl) labelEl.textContent = banner.label;
|
|
2439
|
+
if (upgradeEl) {
|
|
2440
|
+
upgradeEl.textContent = banner.buttonText;
|
|
2441
|
+
upgradeEl.disabled = banner.buttonDisabled;
|
|
2442
|
+
}
|
|
2443
|
+
if (detailEl) {
|
|
2444
|
+
detailEl.textContent = banner.detail;
|
|
2445
|
+
detailEl.hidden = !banner.detail;
|
|
2446
|
+
}
|
|
2447
|
+
if (versionBarEl) {
|
|
2448
|
+
versionBarEl.hidden = !(banner.showVersionBar && (currentUpdateInfo || banner.checking || banner.checkFailed));
|
|
2449
|
+
versionBarEl.setAttribute('data-failed', String(banner.checkFailed));
|
|
2450
|
+
}
|
|
2451
|
+
if (versionTextEl) versionTextEl.textContent = banner.versionText;
|
|
2452
|
+
if (checkBtnEl) {
|
|
2453
|
+
checkBtnEl.textContent = banner.checkButtonText;
|
|
2454
|
+
checkBtnEl.disabled = banner.checkDisabled;
|
|
2455
|
+
}
|
|
2456
|
+
const btnAnalyze = document.getElementById('btnAnalyze');
|
|
2457
|
+
if (btnAnalyze) {
|
|
2458
|
+
btnAnalyze.disabled = isSessionAnalyzing || ['waiting', 'installing'].includes(currentUpdateInfo?.update?.stage);
|
|
2459
|
+
}
|
|
2460
|
+
return banner.active;
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
async function pollAppUpdate() {
|
|
2464
|
+
if (updateTimer) {
|
|
2465
|
+
clearTimeout(updateTimer);
|
|
2466
|
+
updateTimer = null;
|
|
2467
|
+
}
|
|
2468
|
+
try {
|
|
2469
|
+
const reply = await sendProxyAction('app-update-info', {});
|
|
2470
|
+
const info = reply?.updateInfo ?? null;
|
|
2471
|
+
updateConnectionError = '';
|
|
2472
|
+
if (info?.available) {
|
|
2473
|
+
manualCheckStatus = '';
|
|
2474
|
+
manualCheckError = '';
|
|
2475
|
+
}
|
|
2476
|
+
const active = renderUpdateUi(info);
|
|
2477
|
+
updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
|
|
2478
|
+
} catch (err) {
|
|
2479
|
+
updateConnectionError = err?.message || str('cardOpFailed');
|
|
2480
|
+
if (currentUpdateInfo) renderUpdateUi(currentUpdateInfo);
|
|
2481
|
+
updateTimer = setTimeout(pollAppUpdate, 5000);
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
async function onCheckUpdateClick() {
|
|
2486
|
+
if (updateChecking) return;
|
|
2487
|
+
if (updateTimer) {
|
|
2488
|
+
clearTimeout(updateTimer);
|
|
2489
|
+
updateTimer = null;
|
|
2490
|
+
}
|
|
2491
|
+
if (manualCheckTimer) {
|
|
2492
|
+
clearTimeout(manualCheckTimer);
|
|
2493
|
+
manualCheckTimer = null;
|
|
2494
|
+
}
|
|
2495
|
+
updateChecking = true;
|
|
2496
|
+
manualCheckStatus = '';
|
|
2497
|
+
manualCheckError = '';
|
|
2498
|
+
renderUpdateUi();
|
|
2499
|
+
try {
|
|
2500
|
+
const reply = await sendProxyAction('app-update-info', { force: true });
|
|
2501
|
+
const info = reply?.updateInfo ?? null;
|
|
2502
|
+
updateChecking = false;
|
|
2503
|
+
updateConnectionError = '';
|
|
2504
|
+
if (info?.checkError && !info?.available) {
|
|
2505
|
+
manualCheckStatus = 'failed';
|
|
2506
|
+
manualCheckError = info.checkError;
|
|
2507
|
+
} else if (!info?.available) {
|
|
2508
|
+
manualCheckStatus = 'latest';
|
|
2509
|
+
manualCheckTimer = setTimeout(() => {
|
|
2510
|
+
manualCheckTimer = null;
|
|
2511
|
+
if (manualCheckStatus === 'latest') {
|
|
2512
|
+
manualCheckStatus = '';
|
|
2513
|
+
renderUpdateUi();
|
|
2514
|
+
}
|
|
2515
|
+
}, 5000);
|
|
2516
|
+
}
|
|
2517
|
+
const active = renderUpdateUi(info);
|
|
2518
|
+
updateTimer = setTimeout(pollAppUpdate, active ? 2000 : 60000);
|
|
2519
|
+
} catch (err) {
|
|
2520
|
+
updateChecking = false;
|
|
2521
|
+
manualCheckStatus = 'failed';
|
|
2522
|
+
manualCheckError = err?.message || str('cardOpFailed');
|
|
2523
|
+
renderUpdateUi();
|
|
2524
|
+
updateTimer = setTimeout(pollAppUpdate, 60000);
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
async function onUpgradeClick() {
|
|
2529
|
+
const upgradeEl = document.getElementById('btnAppUpdate');
|
|
2530
|
+
if (upgradeEl?.disabled || upgradeStarting) return;
|
|
2531
|
+
if (updateTimer) {
|
|
2532
|
+
clearTimeout(updateTimer);
|
|
2533
|
+
updateTimer = null;
|
|
2534
|
+
}
|
|
2535
|
+
upgradeStarting = true;
|
|
2536
|
+
manualCheckStatus = '';
|
|
2537
|
+
manualCheckError = '';
|
|
2538
|
+
renderUpdateUi();
|
|
2539
|
+
try {
|
|
2540
|
+
const reply = await sendProxyAction('app-update-start', {});
|
|
2541
|
+
upgradeStarting = false;
|
|
2542
|
+
updateConnectionError = '';
|
|
2543
|
+
renderUpdateUi(reply?.updateInfo ?? null);
|
|
2544
|
+
} catch (err) {
|
|
2545
|
+
upgradeStarting = false;
|
|
2546
|
+
updateConnectionError = err?.message || str('cardOpFailed');
|
|
2547
|
+
renderUpdateUi();
|
|
2548
|
+
}
|
|
2549
|
+
updateTimer = setTimeout(pollAppUpdate, 1000);
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2266
2552
|
function initCard() {
|
|
2267
2553
|
applyStaticLanguage();
|
|
2268
2554
|
syncThemeWithHost();
|
|
@@ -2270,6 +2556,7 @@
|
|
|
2270
2556
|
setupScrollListener();
|
|
2271
2557
|
fetchSessionSnapshot(conversationId);
|
|
2272
2558
|
initEventStream();
|
|
2559
|
+
void pollAppUpdate();
|
|
2273
2560
|
|
|
2274
2561
|
// 当在 Antigravity 切换对话时自动刷新对应会话状态
|
|
2275
2562
|
setInterval(() => {
|
|
@@ -299,7 +299,7 @@ app.page('/', () => {
|
|
|
299
299
|
const lang = readConfiguredLang();
|
|
300
300
|
const ui = getActiveUi(lang);
|
|
301
301
|
const hostTheme = readConfiguredHostTheme();
|
|
302
|
-
const bootstrapScript = `<script>window.__agentThingsLang=${JSON.stringify(lang)};window.__agentThingsHostTheme=${JSON.stringify(hostTheme)};window.__agentThingsI18n=${JSON.stringify({
|
|
302
|
+
const bootstrapScript = `<script>window.__agentThingsLang=${JSON.stringify(lang)};window.__agentThingsHostTheme=${JSON.stringify(hostTheme)};window.__agentThingsUpdateBannerState=${ui.updateBannerState.toString()};window.__agentThingsI18n=${JSON.stringify({
|
|
303
303
|
lang,
|
|
304
304
|
labels: ui.labels,
|
|
305
305
|
taskLabels: ui.taskLabels,
|
|
@@ -412,7 +412,7 @@ app.api(
|
|
|
412
412
|
'GET'
|
|
413
413
|
);
|
|
414
414
|
|
|
415
|
-
// 代理交互操作 (analyze, save, update, clear)
|
|
415
|
+
// 代理交互操作 (analyze, save, update, clear, app-update-info, app-update-start)
|
|
416
416
|
app.api(
|
|
417
417
|
'/api/action',
|
|
418
418
|
async (body) => {
|
|
@@ -420,14 +420,22 @@ app.api(
|
|
|
420
420
|
const convId = (body?.conversationId || '').trim();
|
|
421
421
|
const action = body?.action;
|
|
422
422
|
const payload = body?.payload || {};
|
|
423
|
-
const
|
|
423
|
+
const isUpdateAction = action === 'app-update-info' || action === 'app-update-start';
|
|
424
424
|
|
|
425
|
-
if (!
|
|
425
|
+
if (!action || (!isUpdateAction && !convId)) {
|
|
426
426
|
return new Response(JSON.stringify({ error: sidecarMsg(lang, '缺少会话标识或操作类型', 'Missing conversation ID or action') }), { contentType: 'application/json', status: 400 });
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
+
const key = convId ? JSON.stringify(['local', convId]) : undefined;
|
|
429
430
|
try {
|
|
430
|
-
if (action === '
|
|
431
|
+
if (action === 'app-update-info' || action === 'app-update-start') {
|
|
432
|
+
const res = await requestDaemon('/rpc', 'POST', {
|
|
433
|
+
requestId: `tb-act-${Date.now()}`,
|
|
434
|
+
type: action,
|
|
435
|
+
...(action === 'app-update-info' && typeof payload?.force === 'boolean' ? { force: payload.force } : {}),
|
|
436
|
+
});
|
|
437
|
+
return res;
|
|
438
|
+
} else if (action === 'analyze') {
|
|
431
439
|
const res = await requestDaemon('/rpc', 'POST', {
|
|
432
440
|
requestId: `tb-act-${Date.now()}`,
|
|
433
441
|
type: 'analyze',
|
|
@@ -244,6 +244,11 @@ export const createPresentation = function createPresentation(lang) {
|
|
|
244
244
|
updateFailedLabel: '升级失败',
|
|
245
245
|
upgradeBtn: '立即升级',
|
|
246
246
|
upgradingShort: '正在升级…',
|
|
247
|
+
checkUpdateBtn: '检查更新',
|
|
248
|
+
checkingUpdateShort: '正在检查…',
|
|
249
|
+
alreadyLatestPattern: '当前已是最新版 v{version}',
|
|
250
|
+
versionTagPattern: 'v{version}',
|
|
251
|
+
checkUpdateFailedLabel: '检查更新失败',
|
|
247
252
|
pleaseWait: '请稍候',
|
|
248
253
|
completedShort: '已完成',
|
|
249
254
|
retryBtn: '重试',
|
|
@@ -433,6 +438,11 @@ export const createPresentation = function createPresentation(lang) {
|
|
|
433
438
|
updateFailedLabel: 'Upgrade failed',
|
|
434
439
|
upgradeBtn: 'Upgrade',
|
|
435
440
|
upgradingShort: 'Upgrading...',
|
|
441
|
+
checkUpdateBtn: 'Check updates',
|
|
442
|
+
checkingUpdateShort: 'Checking...',
|
|
443
|
+
alreadyLatestPattern: 'Up to date (v{version})',
|
|
444
|
+
versionTagPattern: 'v{version}',
|
|
445
|
+
checkUpdateFailedLabel: 'Update check failed',
|
|
436
446
|
pleaseWait: 'Please wait',
|
|
437
447
|
completedShort: 'Done',
|
|
438
448
|
retryBtn: 'Retry',
|
|
@@ -522,6 +532,72 @@ export const createPresentation = function createPresentation(lang) {
|
|
|
522
532
|
function analysisDisabled(busy, analyzing, upgradeStage) {
|
|
523
533
|
return Boolean(busy || analyzing || ['waiting', 'installing'].includes(upgradeStage));
|
|
524
534
|
}
|
|
535
|
+
function updateBannerState(info, dict, options = {}) {
|
|
536
|
+
const textDict = dict || {};
|
|
537
|
+
const fmtText = (template, vars = {}) => String(template || '').replace(/\{(\w+)\}/g, (_, k) => (vars[k] !== undefined ? String(vars[k]) : ''));
|
|
538
|
+
const update = info?.update;
|
|
539
|
+
const stage = update?.stage;
|
|
540
|
+
const stages = textDict.updateStages || {
|
|
541
|
+
queued: 'Preparing upgrade',
|
|
542
|
+
checking: 'Checking version',
|
|
543
|
+
downloading: 'Downloading update',
|
|
544
|
+
waiting: 'Waiting for analysis to finish',
|
|
545
|
+
installing: 'Upgrading',
|
|
546
|
+
};
|
|
547
|
+
const activeStage = Boolean(stages[stage]) || Boolean(options.starting);
|
|
548
|
+
const updatedAtMs = update?.updatedAt ? Date.parse(update.updatedAt) : NaN;
|
|
549
|
+
const now = options.now ?? Date.now();
|
|
550
|
+
const completed = stage === 'completed' && Number.isFinite(updatedAtMs) && now - updatedAtMs < 60000;
|
|
551
|
+
const failed = stage === 'failed';
|
|
552
|
+
const visible = Boolean(info?.available || activeStage || failed || completed);
|
|
553
|
+
const command = info?.command || 'npx agent-things@latest';
|
|
554
|
+
const label = activeStage
|
|
555
|
+
? (stages[stage] || stages.queued)
|
|
556
|
+
: failed
|
|
557
|
+
? fmtText(textDict.updateFailedLabel || 'Upgrade failed')
|
|
558
|
+
: completed
|
|
559
|
+
? fmtText(textDict.upgradedToPattern || 'Upgraded to v{version}', { version: update?.currentVersion || '' })
|
|
560
|
+
: fmtText(textDict.updateAvailablePattern || 'Update available v{version}', { version: info?.latestVersion || '' });
|
|
561
|
+
const buttonText = activeStage
|
|
562
|
+
? (textDict.pleaseWait || 'Please wait')
|
|
563
|
+
: completed
|
|
564
|
+
? (textDict.completedShort || 'Done')
|
|
565
|
+
: failed
|
|
566
|
+
? (textDict.retryBtn || 'Retry')
|
|
567
|
+
: (textDict.upgradeBtn || 'Upgrade');
|
|
568
|
+
const detail = options.connectionError
|
|
569
|
+
? `${textDict.reconnectHint || ''}\n${textDict.terminalUpgradePrefix || ''}${command}`
|
|
570
|
+
: failed
|
|
571
|
+
? `${update?.error || ''}\n${textDict.terminalUpgradePrefix || ''}${command}`
|
|
572
|
+
: (completed && update?.reconnectMcp ? (textDict.reconnectMcpHint || '') : '');
|
|
573
|
+
const currentVersion = info?.currentVersion || '';
|
|
574
|
+
const checkFailed = !visible && options.manualCheckStatus === 'failed';
|
|
575
|
+
let versionText = currentVersion ? fmtText(textDict.versionTagPattern || 'v{version}', { version: currentVersion }) : '';
|
|
576
|
+
if (checkFailed) {
|
|
577
|
+
const errText = options.checkError || info?.checkError || '';
|
|
578
|
+
versionText = errText ? `${textDict.checkUpdateFailedLabel || 'Update check failed'}: ${errText}` : (textDict.checkUpdateFailedLabel || 'Update check failed');
|
|
579
|
+
} else if (!visible && options.manualCheckStatus === 'latest' && currentVersion) {
|
|
580
|
+
versionText = fmtText(textDict.alreadyLatestPattern || 'Up to date (v{version})', { version: currentVersion });
|
|
581
|
+
}
|
|
582
|
+
const checking = Boolean(options.checking);
|
|
583
|
+
return {
|
|
584
|
+
visible,
|
|
585
|
+
active: activeStage,
|
|
586
|
+
completed,
|
|
587
|
+
failed,
|
|
588
|
+
buttonDisabled: activeStage || completed,
|
|
589
|
+
label,
|
|
590
|
+
buttonText,
|
|
591
|
+
detail,
|
|
592
|
+
currentVersion,
|
|
593
|
+
versionText,
|
|
594
|
+
showVersionBar: !visible,
|
|
595
|
+
checking,
|
|
596
|
+
checkDisabled: checking,
|
|
597
|
+
checkFailed,
|
|
598
|
+
checkButtonText: checking ? (textDict.checkingUpdateShort || 'Checking...') : (textDict.checkUpdateBtn || 'Check updates'),
|
|
599
|
+
};
|
|
600
|
+
}
|
|
525
601
|
|
|
526
602
|
const active = forLang(currentLang);
|
|
527
603
|
return {
|
|
@@ -544,6 +620,7 @@ export const createPresentation = function createPresentation(lang) {
|
|
|
544
620
|
progressState,
|
|
545
621
|
draftTransition,
|
|
546
622
|
analysisDisabled,
|
|
623
|
+
updateBannerState,
|
|
547
624
|
};
|
|
548
625
|
};
|
|
549
626
|
export function getUiForLang(lang) {
|