dsh-agentone 0.5.14 → 0.5.16

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/lib/model.js CHANGED
@@ -21,8 +21,9 @@ const REASONING_EFFORTS = { off: null, low: 'low', medium: 'medium', high: 'high
21
21
 
22
22
  /**
23
23
  * 把平台 /models 条目转成 llm-pi-ai models 配置。
24
- * input(视觉)与 reasoning(思考)是平台能力表下发的声明,插件只翻译:
25
- * 未声明的旧平台版本回退到全档位思考 + 纯文本。
24
+ * input(视觉)、reasoning(思考)与 contextWindow(上下文窗口)是平台
25
+ * 能力表下发的声明,插件只翻译:未声明的旧平台版本回退到全档位思考 +
26
+ * 纯文本 + 不写上下文(llm-pi-ai 回退自身 catalog 默认)。
26
27
  */
27
28
  function platformModelEntry(item) {
28
29
  const id = typeof item === 'string' ? item : item?.id;
@@ -30,6 +31,9 @@ function platformModelEntry(item) {
30
31
  const entry = { id, name: friendlyModelName(id) };
31
32
  const input = Array.isArray(item?.input) ? item.input : ['text'];
32
33
  if (input.includes('image')) entry.input = ['text', 'image'];
34
+ if (typeof item?.contextWindow === 'number' && item.contextWindow > 0) {
35
+ entry.contextWindow = item.contextWindow;
36
+ }
33
37
  if (item?.reasoning === false) entry.reasoningEfforts = false;
34
38
  else entry.reasoningEfforts = { ...REASONING_EFFORTS };
35
39
  return entry;
@@ -137,7 +141,13 @@ export async function fetchPlatformModels(platformUrl, accessToken) {
137
141
  const data = await response.json().catch(() => ({}));
138
142
  const models = Array.isArray(data.data)
139
143
  ? data.data
140
- .map((item) => (typeof item === 'string' ? item : item?.id ? { id: item.id, input: item.input, reasoning: item.reasoning } : null))
144
+ .map((item) =>
145
+ typeof item === 'string'
146
+ ? item
147
+ : item?.id
148
+ ? { id: item.id, input: item.input, reasoning: item.reasoning, contextWindow: item.contextWindow }
149
+ : null,
150
+ )
141
151
  .filter(Boolean)
142
152
  : [];
143
153
  if (models.length === 0) throw new Error('平台返回的可用模型列表为空');
package/lib/page.js CHANGED
@@ -426,8 +426,26 @@ const renderCli = async (s) => {
426
426
  body.innerHTML = '<div class="skill-sub" style="color:var(--err)">CLI 状态检测失败,请稍后重试。</div>';
427
427
  return;
428
428
  }
429
+ renderCliData(s, tools);
430
+ };
431
+ // 纯渲染:tools 形如 { 'lark-cli': {state,version,latest}, ... }。
432
+ // 升级成功后端会带回升级后立即探测的单工具详情,直接合进缓存同步刷新,
433
+ // 不再整页二次探测(否则要再等一轮「检测中…」,用户以为没生效)。
434
+ const renderCliData = (s, tools) => {
435
+ renderCli._tools = { ...(renderCli._tools || {}), ...tools };
436
+ const allTools = renderCli._tools;
437
+ const cliEnabled = s.capabilities?.cli_deployd_enabled !== false;
438
+ const body = $('cli-body');
439
+ if (!s.logged_in) {
440
+ body.innerHTML = '<div class="skill-sub">登录后可用公司托管的 CLI 工具。</div>';
441
+ return;
442
+ }
443
+ if (!cliEnabled) {
444
+ body.innerHTML = '<div class="skill-sub">平台未开启 CLI 功能。</div>';
445
+ return;
446
+ }
429
447
  const rows = Object.entries(CLI_TOOL_META).map(([name, meta]) => {
430
- const info = tools[name] || { state: 'missing' };
448
+ const info = allTools[name] || { state: 'missing' };
431
449
  const state = info.state || 'missing';
432
450
  const status = state === 'authorized'
433
451
  ? '<span class="pill ok" style="font-size:11px">已授权</span>'
@@ -468,10 +486,17 @@ const cliUpgrade = async (tool, btn) => {
468
486
  });
469
487
  const data = await resp.json().catch(() => ({}));
470
488
  if (!resp.ok) throw new Error(data.error || 'CLI 升级失败');
489
+ // 升级响应自带升级后立即探测的单工具详情:先同步刷新界面再弹输出,
490
+ // 用户关掉弹窗时看到的就是新版本(此前弹窗阻塞 + 整页二次探测,
491
+ // 界面长时间停留旧版本,用户以为升级没生效)
492
+ renderCli._probedAt = 0;
493
+ if (data.tool) {
494
+ renderCliData(lastStatus, { [tool]: data.tool });
495
+ } else {
496
+ renderCli(lastStatus);
497
+ }
471
498
  // lark-cli 手动安装时 update 只会打印下载地址,原样展示给用户
472
499
  if (data.output) alert(data.output);
473
- renderCli._probedAt = 0;
474
- renderCli(lastStatus);
475
500
  } catch (error) {
476
501
  alert(error.message || 'CLI 升级失败,请稍后重试');
477
502
  btn.disabled = false;
@@ -509,12 +534,16 @@ const renderPlugins = async () => {
509
534
  return;
510
535
  }
511
536
  const rows = data.plugins.map((plugin) => {
512
- // 三态:未安装 → 安装按钮;已装 → 升级(有新版本时)+ 卸载(非内置非自身)
537
+ // 状态区分三种:未安装 → 安装按钮;插件(带 bundle 声明)→ 激活态;
538
+ // 纯依赖(无 bundle 声明,如 @larksuite/cli 这类 CLI 工具包)→ 「依赖」
539
+ // 标签——它永远不进 bundle 层,不能显示「未激活/重启生效」误导用户
513
540
  const statePill = !plugin.version
514
541
  ? '<span class="pill warn" style="font-size:11px">未安装</span>'
515
542
  : plugin.active
516
543
  ? '<span class="pill ok" style="font-size:11px">已激活</span>'
517
- : '<span class="pill warn" style="font-size:11px">未激活</span>';
544
+ : plugin.bundled
545
+ ? '<span class="pill warn" style="font-size:11px">未激活</span>'
546
+ : '<span class="tag">依赖</span>';
518
547
  const builtinTag = plugin.builtin
519
548
  ? '<span class="tag">内置</span>'
520
549
  : '';
@@ -543,7 +572,7 @@ const renderPlugins = async () => {
543
572
  return '<div class="skill-item"><div class="skill-info"><div class="skill-name">'
544
573
  + esc(plugin.name) + builtinTag + statePill
545
574
  + '</div><div class="skill-sub">' + desc + esc(plugin.source) + ' · ' + version
546
- + (plugin.version && !plugin.active ? ' · 未在 bundle 层,重启 dsh 后生效' : '')
575
+ + (plugin.bundled && !plugin.active ? ' · 未在 bundle 层,重启 dsh 后生效' : '')
547
576
  + '</div></div>' + actionHtml + '</div>';
548
577
  });
549
578
  list.innerHTML = rows.join('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agentone",
3
- "version": "0.5.14",
3
+ "version": "0.5.16",
4
4
  "description": "AgentOne 平台集成插件:飞书登录、平台模型、SkillHub 技能、套餐申请、插件管理与自助升级、lark-cli / ccpg-cli 探测(请求超时与错误码透传、令牌轮换 single-flight、凭据损坏容错、状态页 UX 增强)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",