@ian2018cs/agenthub 0.1.38 → 0.1.42
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 +2 -0
- 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
|
|
@@ -673,6 +673,7 @@ function buildAskUserQuestionCard(questions, requestId) {
|
|
|
673
673
|
width: 'auto',
|
|
674
674
|
elements: [{
|
|
675
675
|
tag: 'button',
|
|
676
|
+
name: 'ask_submit_btn',
|
|
676
677
|
text: { tag: 'plain_text', content: '提交答案' },
|
|
677
678
|
type: 'primary',
|
|
678
679
|
form_action_type: 'submit',
|
|
@@ -684,6 +685,7 @@ function buildAskUserQuestionCard(questions, requestId) {
|
|
|
684
685
|
width: 'auto',
|
|
685
686
|
elements: [{
|
|
686
687
|
tag: 'button',
|
|
688
|
+
name: 'ask_skip_btn',
|
|
687
689
|
text: { tag: 'plain_text', content: '跳过' },
|
|
688
690
|
type: 'default',
|
|
689
691
|
form_action_type: 'submit',
|
|
@@ -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) {
|