@ian2018cs/agenthub 0.1.38 → 0.1.43
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/dist/assets/index-hV3zc8w4.js +151 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/cli.js +43 -9
- package/server/routes/auth.js +2 -0
- package/server/services/feishu/card-builder.js +40 -29
- package/server/services/feishu/sdk-bridge.js +2 -10
- package/dist/assets/index-IiiL0NTz.js +0 -151
package/dist/index.html
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<!-- Prevent zoom on iOS -->
|
|
27
27
|
<meta name="format-detection" content="telephone=no" />
|
|
28
|
-
<script type="module" crossorigin src="/assets/index-
|
|
28
|
+
<script type="module" crossorigin src="/assets/index-hV3zc8w4.js"></script>
|
|
29
29
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BeVl62c0.js">
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-C_VWDoZS.js">
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/vendor-utils-00TdZexr.js">
|
package/package.json
CHANGED
package/server/cli.js
CHANGED
|
@@ -203,16 +203,37 @@ function isNewerVersion(v1, v2) {
|
|
|
203
203
|
return false;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
// Check for updates
|
|
206
|
+
// Check for updates via GitHub Releases
|
|
207
207
|
async function checkForUpdates(silent = false) {
|
|
208
208
|
try {
|
|
209
|
-
const
|
|
210
|
-
const
|
|
209
|
+
const https = await import('https');
|
|
210
|
+
const REPO = 'IAn2018cs/claudecodeui';
|
|
211
211
|
const currentVersion = packageJson.version;
|
|
212
212
|
|
|
213
|
+
const latestVersion = await new Promise((resolve, reject) => {
|
|
214
|
+
const req = https.get(
|
|
215
|
+
`https://api.github.com/repos/${REPO}/releases/latest`,
|
|
216
|
+
{ headers: { 'User-Agent': 'agenthub-cli' } },
|
|
217
|
+
(res) => {
|
|
218
|
+
let data = '';
|
|
219
|
+
res.on('data', chunk => data += chunk);
|
|
220
|
+
res.on('end', () => {
|
|
221
|
+
try {
|
|
222
|
+
const json = JSON.parse(data);
|
|
223
|
+
resolve(json.tag_name?.replace(/^v/, '') || '');
|
|
224
|
+
} catch { reject(new Error('Invalid response')); }
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
req.on('error', reject);
|
|
229
|
+
req.setTimeout(5000, () => { req.destroy(); reject(new Error('Timeout')); });
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
if (!latestVersion) throw new Error('Could not parse version');
|
|
233
|
+
|
|
213
234
|
if (isNewerVersion(latestVersion, currentVersion)) {
|
|
214
235
|
console.log(`\n${c.warn('[UPDATE]')} New version available: ${c.bright(latestVersion)} (current: ${currentVersion})`);
|
|
215
|
-
console.log(` Run ${c.bright('
|
|
236
|
+
console.log(` Run ${c.bright('agenthub update')} to update\n`);
|
|
216
237
|
return { hasUpdate: true, latestVersion, currentVersion };
|
|
217
238
|
} else if (!silent) {
|
|
218
239
|
console.log(`${c.ok('[OK]')} You are on the latest version (${currentVersion})`);
|
|
@@ -226,13 +247,21 @@ async function checkForUpdates(silent = false) {
|
|
|
226
247
|
}
|
|
227
248
|
}
|
|
228
249
|
|
|
229
|
-
// Update the package
|
|
250
|
+
// Update the package via GitHub Releases
|
|
230
251
|
async function updatePackage() {
|
|
231
252
|
try {
|
|
232
253
|
const { execSync } = await import('child_process');
|
|
254
|
+
const currentVersion = packageJson.version;
|
|
233
255
|
console.log(`${c.info('[INFO]')} Checking for updates...`);
|
|
234
256
|
|
|
235
|
-
const
|
|
257
|
+
const result = await checkForUpdates(true);
|
|
258
|
+
|
|
259
|
+
if (result.error) {
|
|
260
|
+
console.log(`${c.warn('[WARN]')} Could not check for updates: ${result.error}`);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const { hasUpdate, latestVersion } = result;
|
|
236
265
|
|
|
237
266
|
if (!hasUpdate) {
|
|
238
267
|
console.log(`${c.ok('[OK]')} Already on the latest version (${currentVersion})`);
|
|
@@ -240,11 +269,16 @@ async function updatePackage() {
|
|
|
240
269
|
}
|
|
241
270
|
|
|
242
271
|
console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
|
|
243
|
-
|
|
244
|
-
|
|
272
|
+
const tgzName = `ian2018cs-agenthub-${latestVersion}.tgz`;
|
|
273
|
+
const url = `https://github.com/IAn2018cs/claudecodeui/releases/download/v${latestVersion}/${tgzName}`;
|
|
274
|
+
execSync(`npm install -g "${url}"`, { stdio: 'inherit' });
|
|
275
|
+
console.log(`${c.ok('[OK]')} Update complete!`);
|
|
276
|
+
console.log(` Please restart the server to use the new version:`);
|
|
277
|
+
console.log(` - pm2: ${c.bright('pm2 restart agenthub')} or ${c.bright('./pm2.sh restart')}`);
|
|
278
|
+
console.log(` - manual: stop and run ${c.bright('agenthub')} again`);
|
|
245
279
|
} catch (e) {
|
|
246
280
|
console.error(`${c.error('[ERROR]')} Update failed: ${e.message}`);
|
|
247
|
-
console.log(`${c.tip('[TIP]')}
|
|
281
|
+
console.log(`${c.tip('[TIP]')} Check releases: https://github.com/IAn2018cs/claudecodeui/releases`);
|
|
248
282
|
}
|
|
249
283
|
}
|
|
250
284
|
|
package/server/routes/auth.js
CHANGED
|
@@ -6,6 +6,7 @@ import { userDb, verificationDb, domainWhitelistDb, usageDb, settingsDb } from '
|
|
|
6
6
|
import { generateToken, authenticateToken, JWT_SECRET } from '../middleware/auth.js';
|
|
7
7
|
import { initUserDirectories } from '../services/user-directories.js';
|
|
8
8
|
import { initSystemRepoForUser } from '../services/system-repo.js';
|
|
9
|
+
import { initSystemMcpRepoForUser } from '../services/system-mcp-repo.js';
|
|
9
10
|
import { sendVerificationCode, isSmtpConfigured } from '../services/email.js';
|
|
10
11
|
|
|
11
12
|
const router = express.Router();
|
|
@@ -128,6 +129,7 @@ router.post('/verify-code', async (req, res) => {
|
|
|
128
129
|
} else {
|
|
129
130
|
// Ensure system repo is linked for existing user
|
|
130
131
|
await initSystemRepoForUser(user.uuid);
|
|
132
|
+
await initSystemMcpRepoForUser(user.uuid);
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
// Check if user is disabled
|
|
@@ -562,24 +562,23 @@ function buildHelpCardDirect(boundEmail, state) {
|
|
|
562
562
|
const modeLabel = MODE_LABELS[permission_mode] || '默认模式';
|
|
563
563
|
|
|
564
564
|
return JSON.stringify({
|
|
565
|
-
|
|
565
|
+
schema: '2.0',
|
|
566
|
+
config: { update_multi: true },
|
|
566
567
|
header: {
|
|
567
568
|
title: { tag: 'plain_text', content: '🤖 AgentHub' },
|
|
568
569
|
template: 'blue',
|
|
570
|
+
padding: '12px 8px 12px 8px',
|
|
569
571
|
},
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
tag: '
|
|
572
|
+
body: {
|
|
573
|
+
direction: 'vertical',
|
|
574
|
+
elements: [
|
|
575
|
+
{
|
|
576
|
+
tag: 'markdown',
|
|
575
577
|
content: `**已绑定账号**:${boundEmail || '未绑定'}\n**当前项目**:${projectName}\n**当前模式**:${modeLabel}`,
|
|
576
578
|
},
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
tag: 'div',
|
|
581
|
-
text: {
|
|
582
|
-
tag: 'lark_md',
|
|
579
|
+
{ tag: 'hr' },
|
|
580
|
+
{
|
|
581
|
+
tag: 'markdown',
|
|
583
582
|
content: [
|
|
584
583
|
'**命令列表**',
|
|
585
584
|
'`/auth <token>` 绑定账号',
|
|
@@ -598,19 +597,16 @@ function buildHelpCardDirect(boundEmail, state) {
|
|
|
598
597
|
'`/help` 显示此帮助',
|
|
599
598
|
].join('\n'),
|
|
600
599
|
},
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
tag: 'div',
|
|
605
|
-
text: {
|
|
606
|
-
tag: 'lark_md',
|
|
600
|
+
{ tag: 'hr' },
|
|
601
|
+
{
|
|
602
|
+
tag: 'markdown',
|
|
607
603
|
content: [
|
|
608
604
|
'**权限模式**',
|
|
609
605
|
...Object.entries(MODE_LABELS).map(([k, v]) => `\`${k}\` ${v}`),
|
|
610
606
|
].join('\n'),
|
|
611
607
|
},
|
|
612
|
-
|
|
613
|
-
|
|
608
|
+
],
|
|
609
|
+
},
|
|
614
610
|
});
|
|
615
611
|
}
|
|
616
612
|
|
|
@@ -673,6 +669,7 @@ function buildAskUserQuestionCard(questions, requestId) {
|
|
|
673
669
|
width: 'auto',
|
|
674
670
|
elements: [{
|
|
675
671
|
tag: 'button',
|
|
672
|
+
name: 'ask_submit_btn',
|
|
676
673
|
text: { tag: 'plain_text', content: '提交答案' },
|
|
677
674
|
type: 'primary',
|
|
678
675
|
form_action_type: 'submit',
|
|
@@ -684,6 +681,7 @@ function buildAskUserQuestionCard(questions, requestId) {
|
|
|
684
681
|
width: 'auto',
|
|
685
682
|
elements: [{
|
|
686
683
|
tag: 'button',
|
|
684
|
+
name: 'ask_skip_btn',
|
|
687
685
|
text: { tag: 'plain_text', content: '跳过' },
|
|
688
686
|
type: 'default',
|
|
689
687
|
form_action_type: 'submit',
|
|
@@ -727,14 +725,19 @@ function buildAskUserQuestionResultCard(answers, skipped = false) {
|
|
|
727
725
|
.join('\n');
|
|
728
726
|
|
|
729
727
|
return JSON.stringify({
|
|
730
|
-
|
|
728
|
+
schema: '2.0',
|
|
729
|
+
config: { update_multi: true },
|
|
731
730
|
header: {
|
|
732
731
|
title: { tag: 'plain_text', content: skipped ? '⏭️ 已跳过' : '✅ 已提交回答' },
|
|
733
732
|
template: skipped ? 'grey' : 'green',
|
|
733
|
+
padding: '12px 8px 12px 8px',
|
|
734
|
+
},
|
|
735
|
+
body: {
|
|
736
|
+
direction: 'vertical',
|
|
737
|
+
elements: [
|
|
738
|
+
{ tag: 'markdown', content },
|
|
739
|
+
],
|
|
734
740
|
},
|
|
735
|
-
elements: [
|
|
736
|
-
{ tag: 'div', text: { tag: 'lark_md', content } },
|
|
737
|
-
],
|
|
738
741
|
});
|
|
739
742
|
}
|
|
740
743
|
|
|
@@ -888,11 +891,19 @@ function buildTextOrMarkdownMessage(text) {
|
|
|
888
891
|
return {
|
|
889
892
|
msgType: 'interactive',
|
|
890
893
|
content: JSON.stringify({
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
894
|
+
schema: '2.0',
|
|
895
|
+
config: { update_multi: true },
|
|
896
|
+
header: {
|
|
897
|
+
title: { tag: 'plain_text', content: '' },
|
|
898
|
+
template: 'default',
|
|
899
|
+
},
|
|
900
|
+
body: {
|
|
901
|
+
direction: 'vertical',
|
|
902
|
+
elements: [{
|
|
903
|
+
tag: 'markdown',
|
|
904
|
+
content: adapted,
|
|
905
|
+
}],
|
|
906
|
+
},
|
|
896
907
|
}),
|
|
897
908
|
};
|
|
898
909
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - claude-permission-cancelled → 更新卡片为已取消
|
|
12
12
|
* - session-created → 保存 sessionId
|
|
13
13
|
* - claude-complete → 发送聚合响应,保存 sessionId 到 DB
|
|
14
|
-
* - token-budget →
|
|
14
|
+
* - token-budget → 忽略(统计不准确,不推送给用户)
|
|
15
15
|
* - claude-error → 发送错误提示
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -376,15 +376,7 @@ class FakeSendWriter {
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
_handleTokenBudget(budget) {
|
|
379
|
-
|
|
380
|
-
const { used, total } = budget;
|
|
381
|
-
// 超过 90% 时发提醒
|
|
382
|
-
if (total > 0 && used / total >= 0.9) {
|
|
383
|
-
this.larkClient.sendText(
|
|
384
|
-
this.chatId,
|
|
385
|
-
`⚠️ 上下文已使用 ${Math.round(used / total * 100)}%(${used}/${total} tokens),建议开启新会话。`
|
|
386
|
-
).catch(() => {});
|
|
387
|
-
}
|
|
379
|
+
// token-budget 提醒统计不准确,不向用户推送
|
|
388
380
|
}
|
|
389
381
|
|
|
390
382
|
async _handleError(errorMsg) {
|