dsh-agentone 0.5.31 → 0.5.32

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/client.js CHANGED
@@ -16,18 +16,102 @@ window.__ModuleLoader__.load({
16
16
  factory: (require) => {
17
17
  const React = require('react');
18
18
 
19
+ // ==desktop-srcdoc-begin==
20
+ // DSH NEXT 桌面壳(dsh-app:// 协议)的转发层只给「主框架的子资源请求」注入
21
+ // x-dsh-desktop-renderer 令牌;iframe 子框架导航拿不到令牌,/agentone/ 被
22
+ // 403 空响应——这是桌面端设置区白屏的根因。桌面端改为主框架 fetch 取回页面
23
+ // HTML 后用 srcdoc 渲染,并注入两样东西:
24
+ // 1. <base href="/agentone/"> —— 页面相对路径(fetch('api/...'))的解析
25
+ // 基准与真实 iframe 一致;
26
+ // 2. fetch 代理 shim —— srcdoc 子框架自己发请求同样没有令牌,一律先按
27
+ // document.baseURI 解析成绝对 URL,再转主框架 parent.fetch 发出(同源
28
+ // srcdoc,令牌随主框架请求注入);同时打 __AGENTONE_DESKTOP__ 标记,
29
+ // 供页面登录流程走桌面本地回调。
30
+ const DESKTOP_PAGE_SHIM =
31
+ '<script>(function(){' +
32
+ 'window.__AGENTONE_DESKTOP__=true;' +
33
+ 'var pf=window.parent.fetch.bind(window.parent);' +
34
+ 'window.fetch=function(input,init){' +
35
+ 'if(typeof input==="string")input=new URL(input,document.baseURI).href;' +
36
+ 'return pf(input,init);' +
37
+ '};' +
38
+ '})();</scr' + 'ipt>';
39
+
40
+ function buildDesktopSrcdoc(html) {
41
+ const preamble = '<base href="/agentone/">\n' + DESKTOP_PAGE_SHIM + '\n';
42
+ const head = /<head[^>]*>/i.exec(html);
43
+ if (head) {
44
+ const at = head.index + head[0].length;
45
+ return html.slice(0, at) + '\n' + preamble + html.slice(at);
46
+ }
47
+ return preamble + html;
48
+ }
49
+ // ==desktop-srcdoc-end==
50
+
51
+ const SECTION_IFRAME_STYLE = {
52
+ border: 'none',
53
+ width: '100%',
54
+ height: '100%',
55
+ minHeight: '480px',
56
+ borderRadius: '12px',
57
+ background: 'transparent',
58
+ };
59
+
19
60
  function AgentOneSection() {
61
+ // dsh-app:// 即 DSH NEXT 桌面壳;http(s) 为 web/旧桌面(cookie 鉴权,iframe 直连可用)
62
+ const isDesktop = window.location.protocol === 'dsh-app:';
63
+ const [doc, setDoc] = React.useState(null);
64
+ const [loadError, setLoadError] = React.useState(false);
65
+ const [retryTick, setRetryTick] = React.useState(0);
66
+
67
+ React.useEffect(() => {
68
+ if (!isDesktop) return undefined;
69
+ let cancelled = false;
70
+ setDoc(null);
71
+ setLoadError(false);
72
+ fetch('/agentone/')
73
+ .then((response) => {
74
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
75
+ return response.text();
76
+ })
77
+ .then((html) => { if (!cancelled) setDoc(buildDesktopSrcdoc(html)); })
78
+ .catch(() => { if (!cancelled) setLoadError(true); });
79
+ return () => { cancelled = true; };
80
+ }, [isDesktop, retryTick]);
81
+
82
+ if (!isDesktop) {
83
+ return React.createElement('iframe', {
84
+ src: '/agentone/',
85
+ title: 'AgentOne',
86
+ style: SECTION_IFRAME_STYLE,
87
+ });
88
+ }
89
+ if (loadError) {
90
+ return React.createElement(
91
+ 'div',
92
+ { style: { padding: '24px', textAlign: 'center', color: 'var(--dsw-alias-label-secondary, #57606a)' } },
93
+ React.createElement('p', null, 'AgentOne 面板加载失败,请重试'),
94
+ React.createElement(
95
+ 'button',
96
+ {
97
+ onClick: () => setRetryTick((tick) => tick + 1),
98
+ style: { padding: '8px 20px', borderRadius: '10px', border: 'none', cursor: 'pointer', background: '#2f6feb', color: '#fff' },
99
+ },
100
+ '重新加载',
101
+ ),
102
+ );
103
+ }
104
+ if (doc === null) {
105
+ return React.createElement(
106
+ 'div',
107
+ { style: { padding: '24px', textAlign: 'center', color: 'var(--dsw-alias-label-secondary, #57606a)' } },
108
+ '加载中…',
109
+ );
110
+ }
20
111
  return React.createElement('iframe', {
21
- src: '/agentone/',
112
+ srcDoc: doc,
22
113
  title: 'AgentOne',
23
- style: {
24
- border: 'none',
25
- width: '100%',
26
- height: '100%',
27
- minHeight: '480px',
28
- borderRadius: '12px',
29
- background: 'transparent',
30
- },
114
+ style: SECTION_IFRAME_STYLE,
31
115
  });
32
116
  }
33
117
 
package/lib/page.js CHANGED
@@ -1084,8 +1084,10 @@ $('login-btn').onclick = async () => {
1084
1084
  const btn = $('login-btn');
1085
1085
  const base = location.pathname.replace(/\\/agentone\\/?$/, '');
1086
1086
  // DSH Desktop:页面 URL 带 dsh-desktop-mode 参数,且宿主对外请求 403——
1087
- // 传 desktop 标记让后端起一次性本地回调服务
1088
- const isDesktop = new URLSearchParams(location.search).has('dsh-desktop-mode');
1087
+ // 传 desktop 标记让后端起一次性本地回调服务。DSH NEXT 桌面壳下页面经
1088
+ // srcdoc 加载(无 URL 参数),由 client.js 注入的 __AGENTONE_DESKTOP__ 兜底。
1089
+ const isDesktop = new URLSearchParams(location.search).has('dsh-desktop-mode')
1090
+ || window.__AGENTONE_DESKTOP__ === true;
1089
1091
  const callbackUrl = isDesktop
1090
1092
  ? null
1091
1093
  : location.pathname.startsWith('/portal/')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-agentone",
3
- "version": "0.5.31",
4
- "description": "AgentOne 平台集成插件:飞书登录、平台模型(直连 Token Hub 不过境平台、同步失败自愈重试)、SkillHub 技能(升级检测一键升级、装后即时刷新、套餐技能自动同步)、套餐申请、插件管理与自助升级、lark-cli / ccpg-cli 探测与一键安装(请求超时与错误码透传、令牌轮换 single-flight、凭据损坏容错与并发安全写入、状态页 UX 增强、全局中文回复默认(AGENTS.md 受标记管理、永不覆盖用户设置))",
3
+ "version": "0.5.32",
4
+ "description": "AgentOne 平台集成插件:飞书登录、平台模型(直连 Token Hub 不过境平台、同步失败自愈重试)、SkillHub 技能(升级检测一键升级、装后即时刷新、套餐技能自动同步)、套餐申请、插件管理与自助升级、lark-cli / ccpg-cli 探测与一键安装(请求超时与错误码透传、令牌轮换 single-flight、凭据损坏容错与并发安全写入、状态页 UX 增强、全局中文回复默认(AGENTS.md 受标记管理、永不覆盖用户设置)、桌面版设置页白屏修复(iframe 子框架导航无桌面令牌改走主框架 fetch + srcdoc 渲染))",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "smoke": "node scripts/env-matrix-smoke.mjs"