dsh-agentone 0.5.18 → 0.5.19
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 +4 -2
- package/lib/index.js +30 -0
- package/lib/page.js +50 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,8 +13,10 @@ lark-cli / ccpg-cli 状态探测。
|
|
|
13
13
|
OpenAI 兼容代理(`/api/plugin/v1`),模型密钥不下发到本机;对话经平台
|
|
14
14
|
走 TokenHub 按用户计量。平台 403 的 `plan_required` 错误码原样透传,
|
|
15
15
|
前端据此引导申请套餐(不依赖中文文案匹配)。
|
|
16
|
-
- **SkillHub 技能(M3
|
|
17
|
-
|
|
16
|
+
- **SkillHub 技能(M3)**:套餐技能自动装齐(启动/登录时,且常驻期间
|
|
17
|
+
套餐生效、套餐新配技能时由前端触发器与手动「同步套餐技能」按钮补装);
|
|
18
|
+
技能市场搜索、手动安装/卸载,装/卸载后技能列表即时刷新(失效 45s
|
|
19
|
+
status 缓存);已装技能平台侧对比 latest 版本/指纹,有更新时展示
|
|
18
20
|
「v旧 → v新」并支持一键升级(覆盖式重装,原子替换旧目录);技能包
|
|
19
21
|
zip 走平台代理下载(穿越清洗 + 原子落盘)。
|
|
20
22
|
- **SkillHub 连接配置(M3+)**:登录后自动从平台拉取 registry 与用户级
|
package/lib/index.js
CHANGED
|
@@ -628,6 +628,12 @@ async function syncPlanSkills(config, log, credentials) {
|
|
|
628
628
|
const STATUS_CACHE_TTL_MS = 45_000;
|
|
629
629
|
let statusCache = { at: 0, key: null, skills: null, displayNames: null };
|
|
630
630
|
|
|
631
|
+
/** 失效技能列表缓存:安装/卸载/同步改动台账后调用,让下一次 status 立即
|
|
632
|
+
* 拉到新列表(前端装完按钮的 refresh() 依赖这点,否则最长 45s 显示旧状态)。 */
|
|
633
|
+
function invalidateStatusCache() {
|
|
634
|
+
statusCache = { at: 0, key: statusCache.key, skills: null, displayNames: null };
|
|
635
|
+
}
|
|
636
|
+
|
|
631
637
|
async function cachedPlatformStatus(config, credentials) {
|
|
632
638
|
const capabilities = await fetchPlatformCapabilities(config.platformUrl, credentials.access_token);
|
|
633
639
|
const key = `${config.platformUrl}|${credentials.access_token}`;
|
|
@@ -984,12 +990,35 @@ export function apply(ctx, config) {
|
|
|
984
990
|
slug,
|
|
985
991
|
{ config },
|
|
986
992
|
);
|
|
993
|
+
invalidateStatusCache();
|
|
987
994
|
sendJson(response, 200, { ok: true, ...result });
|
|
988
995
|
} catch (error) {
|
|
989
996
|
sendJson(response, 502, { error: error?.message || '技能安装失败' });
|
|
990
997
|
}
|
|
991
998
|
});
|
|
992
999
|
|
|
1000
|
+
// 套餐技能同步:把平台上 source=plan 且未安装的技能装齐。前端在套餐
|
|
1001
|
+
// 生效联动与自动补装触发器里调,也可手动触发;同步结果失效技能缓存。
|
|
1002
|
+
register('/agentone/api/skill/sync', async (request, response) => {
|
|
1003
|
+
if (request.method !== 'POST') {
|
|
1004
|
+
response.writeHead(405, { allow: 'POST' });
|
|
1005
|
+
response.end();
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
try {
|
|
1009
|
+
const credentials = await ensureFreshToken(config, log);
|
|
1010
|
+
if (!credentials) {
|
|
1011
|
+
sendJson(response, 401, { error: '请先完成飞书登录' });
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
const result = await syncPlanSkills(config, log, credentials);
|
|
1015
|
+
invalidateStatusCache();
|
|
1016
|
+
sendJson(response, 200, { ok: true, installed: result?.installed ?? 0, failed: result?.failed ?? 0 });
|
|
1017
|
+
} catch (error) {
|
|
1018
|
+
sendJson(response, 502, { error: error?.message || '同步套餐技能失败' });
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
|
|
993
1022
|
register('/agentone/api/skill/catalog', async (request, response) => {
|
|
994
1023
|
if (request.method !== 'GET') {
|
|
995
1024
|
response.writeHead(405, { allow: 'GET' });
|
|
@@ -1043,6 +1072,7 @@ export function apply(ctx, config) {
|
|
|
1043
1072
|
return;
|
|
1044
1073
|
}
|
|
1045
1074
|
await removePlatformSkill(config.platformUrl, credentials.access_token, slug, { config });
|
|
1075
|
+
invalidateStatusCache();
|
|
1046
1076
|
sendJson(response, 200, { ok: true, canonical_slug: slug });
|
|
1047
1077
|
} catch (error) {
|
|
1048
1078
|
sendJson(response, 502, { error: error?.message || '技能卸载失败' });
|
package/lib/page.js
CHANGED
|
@@ -230,6 +230,33 @@ $('cli-recheck-btn').onclick = () => {
|
|
|
230
230
|
document.querySelectorAll('.tab').forEach((tab) => {
|
|
231
231
|
tab.onclick = () => activateTab(tab.dataset.tab);
|
|
232
232
|
});
|
|
233
|
+
// 套餐技能自动补装触发器:forced=true(套餐刚生效)直接触发;否则仅当
|
|
234
|
+
// status 列表里有未安装的套餐技能才触发。60s 节流 + in-flight 单飞,
|
|
235
|
+
// 失败靠下一次轮询自然重试(skills_error 由 status 带回展示)。
|
|
236
|
+
let planSkillSyncAt = 0;
|
|
237
|
+
let planSkillSyncing = false;
|
|
238
|
+
const maybeAutoSyncPlanSkills = (forced) => {
|
|
239
|
+
if (planSkillSyncing) return;
|
|
240
|
+
const now = Date.now();
|
|
241
|
+
if (now - planSkillSyncAt < 60000) return;
|
|
242
|
+
const skills = lastStatus?.skills?.skills;
|
|
243
|
+
if (!forced) {
|
|
244
|
+
if (!Array.isArray(skills)) return;
|
|
245
|
+
if (!skills.some((skill) => skill.source === 'plan' && !skill.installed)) return;
|
|
246
|
+
}
|
|
247
|
+
planSkillSyncAt = now;
|
|
248
|
+
planSkillSyncing = true;
|
|
249
|
+
fetch('api/skill/sync', { method: 'POST' })
|
|
250
|
+
.catch(() => { planSkillSyncAt = 0; })
|
|
251
|
+
.finally(() => { planSkillSyncing = false; });
|
|
252
|
+
};
|
|
253
|
+
// 套餐技能同步:调后端 /skill/sync 装齐 source=plan 且未安装的技能。
|
|
254
|
+
// 三个调用方:套餐生效联动、自动补装触发器、技能页手动按钮。
|
|
255
|
+
const syncPlanSkills = (btn) => withLoading(
|
|
256
|
+
btn,
|
|
257
|
+
() => fetch('api/skill/sync', { method: 'POST' }),
|
|
258
|
+
null,
|
|
259
|
+
);
|
|
233
260
|
const skillAction = (slug, action, btn, successText) => withLoading(
|
|
234
261
|
btn,
|
|
235
262
|
() => fetch('api/skill/' + action, {
|
|
@@ -849,15 +876,20 @@ const refresh = async () => {
|
|
|
849
876
|
}
|
|
850
877
|
lastStatus = s;
|
|
851
878
|
const modelEnabled = s.capabilities?.channels?.model?.enabled !== false;
|
|
852
|
-
|
|
879
|
+
const skillhubEnabled = s.capabilities?.channels?.skillhub?.enabled !== false;
|
|
880
|
+
// 套餐审批通过检测:plan_state 由非 active 变为 active 时自动同步模型与技能
|
|
853
881
|
const planState = s.capabilities?.plan_state;
|
|
854
882
|
if (s.logged_in && modelEnabled) {
|
|
855
883
|
if (planState === 'active' && lastPlanState && lastPlanState !== 'active') {
|
|
856
884
|
notify('套餐已生效,正在同步模型…');
|
|
857
885
|
fetch('api/model/sync', { method: 'POST' }).catch(() => {});
|
|
886
|
+
if (skillhubEnabled) maybeAutoSyncPlanSkills(true);
|
|
858
887
|
}
|
|
859
888
|
lastPlanState = planState || null;
|
|
860
889
|
}
|
|
890
|
+
// 常驻期间自动补装:列表出现「套餐技能未安装」(管理员后配、启动时同步
|
|
891
|
+
// 瞬时失败)就触发一次同步;节流 + 单飞,装完列表变 installed 自然停
|
|
892
|
+
if (s.logged_in && skillhubEnabled) maybeAutoSyncPlanSkills(false);
|
|
861
893
|
statePill.className = 'pill ' + (s.logged_in ? 'ok' : 'warn');
|
|
862
894
|
statePill.textContent = s.logged_in ? '已登录' : '未登录';
|
|
863
895
|
// 首个状态到达:骨架占位让位给登录卡/主内容
|
|
@@ -944,6 +976,20 @@ $('skillhub-sync-btn').onclick = () => withLoading(
|
|
|
944
976
|
() => fetch('api/skillhub/sync', { method: 'POST' }),
|
|
945
977
|
'SkillHub 配置已同步',
|
|
946
978
|
);
|
|
979
|
+
// 手动同步套餐技能:文案按结果给(装了几个),失败由 withLoading 展示
|
|
980
|
+
$('skill-sync-btn').onclick = () => withLoading(
|
|
981
|
+
$('skill-sync-btn'),
|
|
982
|
+
async () => {
|
|
983
|
+
const resp = await fetch('api/skill/sync', { method: 'POST' });
|
|
984
|
+
const data = await resp.clone().json().catch(() => ({}));
|
|
985
|
+
if (resp.ok) {
|
|
986
|
+
const installed = Number(data.installed) || 0;
|
|
987
|
+
notify(installed > 0 ? '已同步,新装 ' + installed + ' 个套餐技能' : '套餐技能已是最新');
|
|
988
|
+
}
|
|
989
|
+
return resp;
|
|
990
|
+
},
|
|
991
|
+
null,
|
|
992
|
+
);
|
|
947
993
|
logoutBtn.onclick = () => withLoading(
|
|
948
994
|
logoutBtn,
|
|
949
995
|
() => fetch('api/logout', { method: 'POST' }),
|
|
@@ -1033,6 +1079,9 @@ export function statusPageHtml() {
|
|
|
1033
1079
|
<h3>平台技能 <span class="muted">套餐自动同步</span></h3>
|
|
1034
1080
|
<div id="skills-list"></div>
|
|
1035
1081
|
<div class="hint" id="skills-meta"></div>
|
|
1082
|
+
<div class="row" style="margin-top:8px">
|
|
1083
|
+
<button id="skill-sync-btn" class="btn ghost small" data-loading="同步中…">同步套餐技能</button>
|
|
1084
|
+
</div>
|
|
1036
1085
|
<div class="search" style="margin-top:12px">
|
|
1037
1086
|
<input id="search-input" placeholder="搜索技能市场,如:数据 / 报告 / lark" />
|
|
1038
1087
|
<button id="search-btn" class="btn ghost small">搜索</button>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agentone",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "AgentOne 平台集成插件:飞书登录、平台模型(同步失败自愈重试)、SkillHub
|
|
3
|
+
"version": "0.5.19",
|
|
4
|
+
"description": "AgentOne 平台集成插件:飞书登录、平台模型(同步失败自愈重试)、SkillHub 技能(升级检测一键升级、装后即时刷新、套餐技能自动同步)、套餐申请、插件管理与自助升级、lark-cli / ccpg-cli 探测(请求超时与错误码透传、令牌轮换 single-flight、凭据损坏容错与并发安全写入、状态页 UX 增强)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|