openclaw-openagent 1.0.11 → 1.0.13

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.
Files changed (65) hide show
  1. package/dist/index.js +3 -1
  2. package/dist/src/app/remote-agent-tool.js +110 -14
  3. package/dist/src/app/types.d.ts +2 -2
  4. package/dist/src/config/config-schema.d.ts +9 -0
  5. package/dist/src/config/config-schema.js +6 -0
  6. package/dist/src/plugin-ui/adapters/adapters/oc-2026-04.js +103 -0
  7. package/dist/src/plugin-ui/adapters/adapters/oc-2026-05.js +125 -0
  8. package/dist/src/plugin-ui/adapters/adapters/oc-2026-06.js +125 -0
  9. package/dist/src/plugin-ui/adapters/adapters/oc-unknown.js +48 -0
  10. package/dist/src/plugin-ui/adapters/oc-2026-04.js +103 -0
  11. package/dist/src/plugin-ui/adapters/oc-2026-05.js +125 -0
  12. package/dist/src/plugin-ui/adapters/oc-2026-06.js +125 -0
  13. package/dist/src/plugin-ui/adapters/oc-unknown.js +48 -0
  14. package/dist/src/plugin-ui/assets/openagent-override.js +1129 -273
  15. package/dist/src/plugin-ui/index.d.ts +1 -1
  16. package/dist/src/plugin-ui/index.js +2 -2
  17. package/dist/src/plugin-ui/ui-extension-loader/index.d.ts +2 -1
  18. package/dist/src/plugin-ui/ui-extension-loader/index.js +5 -5
  19. package/dist/src/plugin-ui/ui-extension-loader/registry-regex.js +75 -8
  20. package/dist/src/plugin-ui/ui-extension-loader/types.d.ts +4 -1
  21. package/dist/src/proxy/auth-proxy.js +5 -0
  22. package/dist/src/runtime/update-checker.d.ts +18 -0
  23. package/dist/src/runtime/update-checker.js +253 -0
  24. package/dist/src/state/store.d.ts +21 -0
  25. package/dist/src/state/store.js +54 -0
  26. package/dist/src/transport/oasn/oasn-invocation.d.ts +3 -0
  27. package/dist/src/transport/oasn/oasn-invocation.js +28 -12
  28. package/dist/src/transport/oasn/oasn-types.d.ts +8 -4
  29. package/index.ts +4 -1
  30. package/package.json +4 -3
  31. package/src/app/remote-agent-tool.ts +131 -16
  32. package/src/app/types.ts +2 -2
  33. package/src/config/config-schema.ts +6 -0
  34. package/src/plugin-ui/adapters/oc-2026-04.js +103 -0
  35. package/src/plugin-ui/adapters/oc-2026-05.js +125 -0
  36. package/src/plugin-ui/adapters/oc-2026-06.js +125 -0
  37. package/src/plugin-ui/adapters/oc-unknown.js +48 -0
  38. package/src/plugin-ui/assets/openagent-override.js +1129 -273
  39. package/src/plugin-ui/build.cjs +249 -38
  40. package/src/plugin-ui/index.ts +2 -2
  41. package/src/plugin-ui/modules/agent-book/panel/agent-book.js +102 -12
  42. package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +105 -3
  43. package/src/plugin-ui/modules/agent-book/panel/styles.js +54 -48
  44. package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +4 -2
  45. package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +4 -1
  46. package/src/plugin-ui/modules/agent-book/scanner.js +17 -5
  47. package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +12 -1
  48. package/src/plugin-ui/modules/loader/bootstrap.js +95 -0
  49. package/src/plugin-ui/modules/loader/shared-state.js +244 -20
  50. package/src/plugin-ui/modules/remote-agent/execution-card.js +54 -16
  51. package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +5 -23
  52. package/src/plugin-ui/modules/remote-agent/output-card.js +13 -7
  53. package/src/plugin-ui/modules/remote-agent/render-hooks.js +53 -41
  54. package/src/plugin-ui/modules/remote-agent/styles.js +238 -89
  55. package/src/plugin-ui/modules/remote-agent/tool-card-model.js +72 -4
  56. package/src/plugin-ui/postinstall-deploy.cjs +52 -0
  57. package/src/plugin-ui/ui-extension-loader/index.ts +6 -6
  58. package/src/plugin-ui/ui-extension-loader/registry-regex.ts +81 -9
  59. package/src/plugin-ui/ui-extension-loader/types.ts +5 -1
  60. package/src/proxy/auth-proxy.ts +5 -0
  61. package/src/runtime/update-checker.ts +286 -0
  62. package/src/state/store.ts +80 -0
  63. package/src/transport/oasn/oasn-invocation.ts +47 -12
  64. package/src/transport/oasn/oasn-types.ts +6 -2
  65. package/src/types/openclaw-plugin-sdk-media-store.d.ts +9 -0
@@ -2,7 +2,7 @@
2
2
  * OpenAgent UI Override — Auto-generated, do not edit directly!
3
3
  *
4
4
  * Source: src/plugin-ui/modules/
5
- * Built: 2026-07-01T12:59:59.814Z
5
+ * Built: 2026-07-06T09:05:33.996Z
6
6
  *
7
7
  * To modify, edit the source modules and run:
8
8
  * npm run build:override
@@ -51,6 +51,9 @@ const CL = {
51
51
  // ── Host 版本(构建时注入,fallback 运行时检测)──
52
52
  hostVersion: '__OPENCLAW_HOST_VERSION__',
53
53
 
54
+ // ── Override 构建标识(构建时注入,用于缓存自检)──
55
+ buildId: "4207d7dc1f64",
56
+
54
57
  // ── 配置 ──
55
58
  OPENAGENT_API: 'https://api.openagent.club',
56
59
  AUTH_API: '/plugins/openagent', // Proxied via Gateway registerHttpRoute (see src/proxy/auth-proxy.ts)
@@ -59,6 +62,98 @@ const CL = {
59
62
  CACHE_TTL: 30000,
60
63
  };
61
64
 
65
+ function _clFindOverrideScript() {
66
+ try {
67
+ var scripts = document.querySelectorAll('script[src*="openagent-override.js"]');
68
+ return scripts.length ? scripts[scripts.length - 1] : null;
69
+ } catch (e) {
70
+ return null;
71
+ }
72
+ }
73
+
74
+ function _clReadOverrideScriptVersionFromDocument() {
75
+ try {
76
+ var script = _clFindOverrideScript();
77
+ if (!script) return '';
78
+ var src = script.getAttribute('src') || '';
79
+ var url = new URL(src, window.location.href);
80
+ return url.searchParams.get('v') || '';
81
+ } catch (e) {
82
+ return '';
83
+ }
84
+ }
85
+
86
+ function _clResolveControlUiIndexUrl() {
87
+ try {
88
+ var script = _clFindOverrideScript();
89
+ if (script) {
90
+ var scriptUrl = new URL(script.src || script.getAttribute('src'), window.location.href);
91
+ return new URL('./', scriptUrl.href).href;
92
+ }
93
+ } catch (e) {}
94
+ try {
95
+ var url = new URL(window.location.href);
96
+ url.hash = '';
97
+ url.search = '';
98
+ return url.href;
99
+ } catch (e) {
100
+ return '/';
101
+ }
102
+ }
103
+
104
+ function _clExtractOverrideScriptVersionFromHtml(html) {
105
+ var match = String(html || '').match(/openagent-override\.js\?v=([A-Za-z0-9._-]+)/);
106
+ return match ? match[1] : '';
107
+ }
108
+
109
+ function _clInstallOverrideUpdateCheck() {
110
+ if (window.__openagentOverrideUpdateCheckInstalled) return;
111
+ window.__openagentOverrideUpdateCheckInstalled = true;
112
+
113
+ var currentVersion = _clReadOverrideScriptVersionFromDocument() || CL.buildId || '';
114
+ var storageKey = 'openagent.overrideScriptVersion.v1';
115
+ var reloadKey = 'openagent.overrideReloadedVersion.v1';
116
+ try {
117
+ document.documentElement.setAttribute('data-openagent-build-id', CL.buildId || 'unknown');
118
+ if (currentVersion) document.documentElement.setAttribute('data-openagent-script-version', currentVersion);
119
+ } catch (e) {}
120
+
121
+ try {
122
+ if (window.localStorage && currentVersion) {
123
+ window.localStorage.setItem(storageKey, currentVersion);
124
+ }
125
+ } catch (e) {}
126
+
127
+ function reloadForVersion(nextVersion) {
128
+ if (!nextVersion || nextVersion === currentVersion) return;
129
+ try {
130
+ if (window.sessionStorage && window.sessionStorage.getItem(reloadKey) === nextVersion) return;
131
+ if (window.sessionStorage) window.sessionStorage.setItem(reloadKey, nextVersion);
132
+ } catch (e) {}
133
+ console.info('[openagent] override updated, reloading Control UI', currentVersion, '→', nextVersion);
134
+ window.location.reload();
135
+ }
136
+
137
+ async function checkLatestOverrideVersion() {
138
+ if (document.visibilityState && document.visibilityState === 'hidden') return;
139
+ try {
140
+ var res = await fetch(_clResolveControlUiIndexUrl(), { cache: 'no-store' });
141
+ if (!res || !res.ok) return;
142
+ var latestVersion = _clExtractOverrideScriptVersionFromHtml(await res.text());
143
+ reloadForVersion(latestVersion);
144
+ } catch (e) {}
145
+ }
146
+
147
+ setTimeout(checkLatestOverrideVersion, 3000);
148
+ setInterval(checkLatestOverrideVersion, 60000);
149
+ window.addEventListener('focus', checkLatestOverrideVersion);
150
+ document.addEventListener('visibilitychange', function() {
151
+ if (!document.hidden) checkLatestOverrideVersion();
152
+ });
153
+ }
154
+
155
+ _clInstallOverrideUpdateCheck();
156
+
62
157
  // ── 版本解析与比较(供 execution-card V2 分支使用)──
63
158
 
64
159
  function _clParseHostVersion(v) {
@@ -74,6 +169,9 @@ function _clParseHostVersion(v) {
74
169
  }
75
170
 
76
171
  function _clIsHostVersionGte(minVer) {
172
+ if (CL.hostVersionSource !== 'exact' && CL.hostVersionSource !== 'script' && CL.hostVersionSource !== 'runtime') {
173
+ _clRefreshHostVersionFromRuntime();
174
+ }
77
175
  var cur = _clParseHostVersion(CL.hostVersion || '');
78
176
  var min = _clParseHostVersion(minVer);
79
177
  for (var i = 0; i < 3; i++) {
@@ -83,31 +181,131 @@ function _clIsHostVersionGte(minVer) {
83
181
  return true;
84
182
  }
85
183
 
86
- // 运行时 fallback:当构建时未注入版本,通过 CSS/DOM 特征检测 ──
87
- // v5.x (2026.5+) data-theme 属性和 --glass-surface CSS 变量
88
- // v4.x (2026.3-4.x) data-theme-mode 属性和 --vscode-* CSS 变量
89
- if (CL.hostVersion === '__OPENCLAW_HOST_VERSION__' || !CL.hostVersion) {
184
+ function _clResolveHostProfile(version) {
185
+ var parsed = _clParseHostVersion(version || '');
186
+ if (parsed[0] === 2026 && parsed[1] === 4) return 'oc-2026-04';
187
+ if (parsed[0] === 2026 && parsed[1] === 5) return 'oc-2026-05';
188
+ if (parsed[0] === 2026 && parsed[1] === 6) return 'oc-2026-06';
189
+ return 'oc-unknown';
190
+ }
191
+
192
+ function _clNormalizeHostVersion(value) {
193
+ var match = String(value || '').match(/20\d{2}\.\d{1,2}\.\d{1,2}(?:-[A-Za-z0-9._-]+)?/);
194
+ return match ? match[0] : '';
195
+ }
196
+
197
+ function _clGetByPath(root, path) {
198
+ var cur = root;
199
+ for (var i = 0; i < path.length; i++) {
200
+ if (!cur) return '';
201
+ cur = cur[path[i]];
202
+ }
203
+ return cur;
204
+ }
205
+
206
+ function _clReadHostVersionFromRuntime() {
207
+ try {
208
+ var scripts = document.querySelectorAll('script[data-openagent-host-version]');
209
+ for (var i = scripts.length - 1; i >= 0; i--) {
210
+ var scriptVersion = _clNormalizeHostVersion(scripts[i].getAttribute('data-openagent-host-version'));
211
+ if (scriptVersion) return { version: scriptVersion, source: 'script' };
212
+ }
213
+ } catch (e) {}
214
+
215
+ var globals = [
216
+ window.__OPENCLAW_HOST_VERSION__,
217
+ window.__OPENCLAW_VERSION__,
218
+ window.__openclawVersion,
219
+ window.openclawVersion,
220
+ ];
221
+ for (var g = 0; g < globals.length; g++) {
222
+ var globalVersion = _clNormalizeHostVersion(globals[g]);
223
+ if (globalVersion) return { version: globalVersion, source: 'runtime' };
224
+ }
225
+
226
+ try {
227
+ var metaVersion = _clNormalizeHostVersion(
228
+ document.querySelector('meta[name="openclaw-version"],meta[name="openclaw:version"]')?.getAttribute('content')
229
+ );
230
+ if (metaVersion) return { version: metaVersion, source: 'runtime' };
231
+ } catch (e) {}
232
+
233
+ try {
234
+ var app = document.querySelector('openclaw-app');
235
+ if (app) {
236
+ var paths = [
237
+ ['runtime', 'version'],
238
+ ['hello', 'server', 'version'],
239
+ ['hello', 'version'],
240
+ ['client', 'hello', 'server', 'version'],
241
+ ['client', 'version'],
242
+ ['version'],
243
+ ['appVersion'],
244
+ ];
245
+ for (var p = 0; p < paths.length; p++) {
246
+ var appVersion = _clNormalizeHostVersion(_clGetByPath(app, paths[p]));
247
+ if (appVersion) return { version: appVersion, source: 'runtime' };
248
+ }
249
+ }
250
+ } catch (e) {}
251
+
252
+ return null;
253
+ }
254
+
255
+ function _clApplyHostVersion(version, source) {
256
+ CL.hostVersion = version || '2026.3.0';
257
+ CL.hostVersionSource = source || 'fallback';
258
+ CL.hostProfile = _clResolveHostProfile(CL.hostVersion);
259
+ try {
260
+ document.documentElement.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
261
+ document.documentElement.setAttribute('data-openagent-host-profile', CL.hostProfile);
262
+ document.documentElement.setAttribute('data-openagent-host-version-source', CL.hostVersionSource);
263
+ } catch (e) {}
264
+ }
265
+
266
+ function _clRefreshHostVersionFromRuntime() {
267
+ var detected = _clReadHostVersionFromRuntime();
268
+ if (!detected) return false;
269
+ if (detected.version !== CL.hostVersion || detected.source !== CL.hostVersionSource) {
270
+ _clApplyHostVersion(detected.version, detected.source);
271
+ console.log('[cl-version] detected via ' + detected.source + ': ' + detected.version);
272
+ }
273
+ return true;
274
+ }
275
+
276
+ function _clScheduleHostVersionRefresh() {
277
+ var attempts = 0;
278
+ var timer = setInterval(function() {
279
+ attempts++;
280
+ if (_clRefreshHostVersionFromRuntime() || attempts >= 20) {
281
+ clearInterval(timer);
282
+ }
283
+ }, 500);
284
+ }
285
+
286
+ var _clInitialExactVersion = _clNormalizeHostVersion(CL.hostVersion);
287
+ if (_clInitialExactVersion) {
288
+ _clApplyHostVersion(_clInitialExactVersion, 'exact');
289
+ } else if (!_clRefreshHostVersionFromRuntime()) {
290
+ // ─ 运行时 fallback:只做版本族保守判断,避免把 2026.5 误判为 2026.6.9 ──
291
+ // v5.x (2026.5+) 有 data-theme / --glass-*;v4.x 有 data-theme-mode / --vscode-*。
90
292
  try {
91
- if (document.documentElement.hasAttribute('data-theme')) {
92
- // v5.x (2026.5+) — 有 data-theme 属性
93
- CL.hostVersion = '2026.6.9';
94
- } else if (document.documentElement.hasAttribute('data-theme-mode')) {
95
- // v4.x data-theme-mode 属性
96
- CL.hostVersion = '2026.4.0';
293
+ var cs = getComputedStyle(document.documentElement);
294
+ if (document.documentElement.hasAttribute('data-theme-mode')
295
+ || cs.getPropertyValue('--vscode-editor-background').trim()) {
296
+ _clApplyHostVersion('2026.4.0', 'feature-fallback');
297
+ } else if (document.documentElement.hasAttribute('data-theme')
298
+ || cs.getPropertyValue('--glass-surface').trim()
299
+ || cs.getPropertyValue('--kn-bg-primary').trim()) {
300
+ _clApplyHostVersion('2026.5.0', 'feature-fallback');
97
301
  } else {
98
- var cs = getComputedStyle(document.documentElement);
99
- if (cs.getPropertyValue('--glass-surface').trim()) {
100
- CL.hostVersion = '2026.6.9';
101
- } else if (cs.getPropertyValue('--vscode-editor-background').trim()) {
102
- CL.hostVersion = '2026.4.0';
103
- } else {
104
- CL.hostVersion = '2026.3.0';
105
- }
302
+ _clApplyHostVersion('2026.3.0', 'feature-fallback');
106
303
  }
107
- console.log('[cl-version] detected via DOM/CSS features: ' + CL.hostVersion);
304
+ console.log('[cl-version] fallback via DOM/CSS features: ' + CL.hostVersion);
108
305
  } catch (e) {
109
- CL.hostVersion = '2026.3.0';
306
+ _clApplyHostVersion('2026.3.0', 'feature-fallback');
110
307
  }
308
+ _clScheduleHostVersionRefresh();
111
309
  }
112
310
 
113
311
  // 暴露到 window 供控制台调试/测试
@@ -143,6 +341,28 @@ CL._saveAgentIdentityCache = function() {
143
341
  } catch (err) {}
144
342
  };
145
343
 
344
+ CL.pickAgentIdentityDescription = function(agent) {
345
+ if (!agent || typeof agent !== 'object') return '';
346
+ var keys = [
347
+ 'agent_bio',
348
+ 'agentBio',
349
+ 'bio',
350
+ 'description',
351
+ 'desc',
352
+ 'agent_description',
353
+ 'agentDescription',
354
+ 'MOM',
355
+ 'mom',
356
+ 'introduction',
357
+ 'summary'
358
+ ];
359
+ for (var i = 0; i < keys.length; i++) {
360
+ var value = agent[keys[i]];
361
+ if (typeof value === 'string' && value.trim()) return value.trim();
362
+ }
363
+ return '';
364
+ };
365
+
146
366
  CL.storeAgentIdentity = function(agent, fallbackName) {
147
367
  if (!agent || typeof agent !== 'object') return null;
148
368
  CL._loadAgentIdentityCache();
@@ -151,12 +371,16 @@ CL.storeAgentIdentity = function(agent, fallbackName) {
151
371
  agent.user_id || agent.userId || agent.identifier || agent.tim_user_id || agent.timUserId || '';
152
372
  var name = agent.name || agent.agent_name || agent.agentName || fallbackName || '';
153
373
  var avatar = agent.avatar || agent.avatar_url || agent.avatarUrl || agent.image || agent.logo || agent.photo || '';
374
+ var bio = CL.pickAgentIdentityDescription(agent);
154
375
  var record = {
155
376
  id: id,
156
377
  agent_id: id,
157
378
  tag: agent.tag || id,
158
379
  name: name,
159
380
  avatar: avatar || null,
381
+ bio: bio,
382
+ description: agent.description || bio || '',
383
+ MOM: agent.MOM || agent.mom || '',
160
384
  };
161
385
 
162
386
  var keys = [id, record.tag, name, fallbackName].filter(Boolean);
@@ -630,6 +854,62 @@ if (!window.__clDiagClickProbeInstalled) {
630
854
  }, true);
631
855
  }
632
856
 
857
+ // ════════════════════════════════════════════════════════════════
858
+ // MODULE: host-adapter/selected
859
+ // ════════════════════════════════════════════════════════════════
860
+
861
+ /*__OPENAGENT_HOST_ADAPTER_START__*/
862
+ // HOST ADAPTER: oc-unknown
863
+ // ── Unknown OpenClaw host adapter ──
864
+ // Fail closed: render OpenAgent's own card, but do not apply host-structure
865
+ // takeover selectors when the host version is not one of the supported series.
866
+
867
+ (function _clInstallHostAdapterUnknown() {
868
+ function _false() { return false; }
869
+
870
+ var adapter = {
871
+ id: 'oc-unknown',
872
+ family: 'unknown',
873
+ css: {
874
+ remoteShell: [],
875
+ outputHostMargin: [],
876
+ outputHostMarginReset: [],
877
+ summaryHidden: [],
878
+ hostShellRawText: [],
879
+ rawTextCardHosts: [],
880
+ rawTextPlaceholderHosts: [],
881
+ hostBody: [],
882
+ manualOpenReset: [],
883
+ hostShellReset: [],
884
+ hostShellSummary: [],
885
+ modernCardLayout: false,
886
+ },
887
+ nativeStyle: {
888
+ shellSelectors: [],
889
+ summarySelectors: [],
890
+ indentSelectors: [],
891
+ },
892
+ selectors: {
893
+ textContext: '.chat-text',
894
+ summary: '',
895
+ forceOpenHeader: '',
896
+ rawTextHostClosest: [],
897
+ rawTextHostsWithinShell: '',
898
+ },
899
+ isRemoteNativeToolShellCandidate: _false,
900
+ isNativeToolShell: _false,
901
+ isToolLikeShell: _false,
902
+ isToolBody: _false,
903
+ isMarkableHost: _false,
904
+ };
905
+
906
+ CL.hostAdapter = adapter;
907
+ try {
908
+ document.documentElement.setAttribute('data-openagent-host-adapter', adapter.id);
909
+ } catch (e) {}
910
+ })();
911
+ /*__OPENAGENT_HOST_ADAPTER_END__*/
912
+
633
913
  // ════════════════════════════════════════════════════════════════
634
914
  // MODULE: loader/ws-intercept.js
635
915
  // ════════════════════════════════════════════════════════════════
@@ -1755,10 +2035,13 @@ function AgentCard(agent, opts = {}) {
1755
2035
  // ── 样式注入 ──
1756
2036
 
1757
2037
  function injectStyles() {
1758
- if (document.getElementById('openagent-override-styles')) return;
2038
+ var oldStyle = document.getElementById('openagent-override-styles');
2039
+ if (oldStyle) oldStyle.remove();
1759
2040
 
1760
2041
  const style = document.createElement('style');
1761
2042
  style.id = 'openagent-override-styles';
2043
+ style.setAttribute('data-openagent-style', 'agent-book-panel');
2044
+ style.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
1762
2045
  style.textContent = `
1763
2046
  /* ── 流式回复边框闪烁:覆盖为蓝色 ── */
1764
2047
  @keyframes chatStreamPulse {
@@ -1827,7 +2110,6 @@ function injectStyles() {
1827
2110
  background: var(--oa-panel-bg, #fff);
1828
2111
  border: 0.5px solid #dbdbdb;
1829
2112
  border-radius: 16px;
1830
- box-shadow: 0 -4px 24px var(--oa-shadow-color, rgba(0,0,0,0.08)), 0 2px 8px var(--oa-shadow-color, rgba(0,0,0,0.04));
1831
2113
  z-index: 99999;
1832
2114
  overflow: hidden;
1833
2115
  display: none;
@@ -1836,9 +2118,17 @@ function injectStyles() {
1836
2118
  padding: 14px;
1837
2119
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
1838
2120
  box-sizing: border-box;
2121
+ scrollbar-width: none;
2122
+ -ms-overflow-style: none;
2123
+ }
2124
+ .openagent-agent-panel::-webkit-scrollbar {
2125
+ width: 0;
2126
+ height: 0;
2127
+ display: none;
1839
2128
  }
1840
2129
  .openagent-agent-panel.visible {
1841
2130
  display: flex;
2131
+ padding: 30px;
1842
2132
  animation: openagent-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
1843
2133
  }
1844
2134
  @keyframes openagent-up {
@@ -1852,22 +2142,21 @@ function injectStyles() {
1852
2142
  justify-content: space-between;
1853
2143
  align-items: center;
1854
2144
  min-height: 26px;
1855
- padding: 6px 10px 0 10px;
1856
2145
  border-bottom: none;
1857
2146
  }
1858
2147
  .openagent-panel-title {
1859
2148
  display: flex;
1860
2149
  align-items: center;
1861
2150
  gap: 6px;
1862
- font-size: 16px;
2151
+ font-size: 18px;
1863
2152
  font-weight: 500;
1864
- color: rgba(47, 47, 51, 0.8);
2153
+ color: #333;
1865
2154
  text-transform: uppercase;
1866
2155
  letter-spacing: 0.3px;
1867
2156
  }
1868
2157
  .openagent-panel-title-icon {
1869
- width: 21px;
1870
- height: 21px;
2158
+ width: 24px;
2159
+ height: 24px;
1871
2160
  flex-shrink: 0;
1872
2161
  }
1873
2162
  .openagent-panel-close {
@@ -1894,7 +2183,7 @@ function injectStyles() {
1894
2183
  .openagent-panel-divider {
1895
2184
  height: 0;
1896
2185
  border: none;
1897
- border-top: 0.2px solid rgba(47, 47, 51, 0.16);
2186
+ border-top: 0.2px solid #EAEAEA;
1898
2187
  margin: 0;
1899
2188
  }
1900
2189
 
@@ -2073,32 +2362,23 @@ function injectStyles() {
2073
2362
  flex: 1;
2074
2363
  display: flex;
2075
2364
  flex-direction: column;
2076
- gap: 14px;
2077
2365
  min-height: 0;
2078
2366
  max-height: min(56vh, 451px);
2079
- scrollbar-width: thin;
2080
- scrollbar-color: #ddd transparent;
2367
+ scrollbar-width: none;
2368
+ -ms-overflow-style: none;
2081
2369
  }
2082
2370
  .openagent-agent-list::-webkit-scrollbar {
2083
- width: 4px;
2084
- }
2085
- .openagent-agent-list::-webkit-scrollbar-track {
2086
- background: transparent;
2087
- }
2088
- .openagent-agent-list::-webkit-scrollbar-thumb {
2089
- background: #ddd;
2090
- border-radius: 2px;
2091
- }
2092
- .openagent-agent-list::-webkit-scrollbar-thumb:hover {
2093
- background: #bbb;
2371
+ width: 0;
2372
+ height: 0;
2373
+ display: none;
2094
2374
  }
2095
2375
 
2096
2376
  .openagent-agent-section {
2097
2377
  display: flex;
2098
2378
  flex-direction: column;
2099
- gap: 8px;
2100
2379
  width: 100%;
2101
2380
  min-width: 0;
2381
+ margin-bottom: 30px;
2102
2382
  }
2103
2383
 
2104
2384
  /* ── 父分类标题(两级结构:Research > Market Research) ── */
@@ -2109,33 +2389,22 @@ function injectStyles() {
2109
2389
  width: 100%;
2110
2390
  min-width: 0;
2111
2391
  }
2112
- .openagent-parent-heading {
2113
- font-size: 11px;
2114
- font-weight: 600;
2115
- line-height: 13px;
2116
- color: rgba(47, 47, 51, 0.45);
2117
- padding: 0 12px;
2118
- text-transform: uppercase;
2119
- letter-spacing: 0.8px;
2120
- }
2121
-
2122
2392
  /* ── 分组标题 ── */
2123
2393
  .openagent-section-heading {
2124
2394
  font-size: 16px;
2125
2395
  font-weight: 400;
2126
2396
  line-height: 16px;
2127
2397
  color: rgba(47, 47, 51, 0.80);
2128
- padding: 0 12px 0 12px;
2129
2398
  letter-spacing: 0;
2399
+ margin-bottom: 20px;
2130
2400
  }
2131
2401
 
2132
2402
  /* ── 分组网格容器 ── */
2133
2403
  .openagent-section-grid {
2134
2404
  display: grid;
2135
- grid-template-columns: repeat(3, minmax(0, 439.5px));
2405
+ grid-template-columns: repeat(3, 1fr);
2136
2406
  justify-content: start;
2137
- gap: 8px 14px;
2138
- padding: 0 12px;
2407
+ gap: 12px;
2139
2408
  width: 100%;
2140
2409
  box-sizing: border-box;
2141
2410
  }
@@ -2168,9 +2437,15 @@ function injectStyles() {
2168
2437
  .agent-card__body { flex: 1; min-width: 0; }
2169
2438
  .agent-card__name-line { display: flex; align-items: baseline; gap: 8px; }
2170
2439
  .agent-card__name {
2440
+ display: block;
2441
+ min-width: 0;
2442
+ max-width: 100%;
2171
2443
  font-family: "PingFang SC", sans-serif;
2172
2444
  font-weight: 600;
2173
2445
  color: rgba(47, 47, 51, 1);
2446
+ white-space: nowrap;
2447
+ overflow: hidden;
2448
+ text-overflow: ellipsis;
2174
2449
  }
2175
2450
  .agent-card__tag { font-size: 12px; color: #6366f1; font-weight: 500; }
2176
2451
  .agent-card__specialty { font-size: 12px; color: #999; font-weight: 400; }
@@ -2245,12 +2520,31 @@ function injectStyles() {
2245
2520
  border-radius: 20px;
2246
2521
  border: 0.5px solid #dbdbdb;
2247
2522
  background: #fff;
2248
- min-height: 0;
2249
2523
  min-width: 0;
2250
2524
  box-sizing: border-box;
2251
2525
  }
2252
2526
  .agent-card--mention:hover {
2253
- background: rgba(0, 0, 0, 0.02);
2527
+ border-color: transparent;
2528
+ box-shadow: 0 4px 12px 0 rgba(149, 147, 240, 0.10);
2529
+ }
2530
+ .openagent-agent-list .agent-card--mention:hover,
2531
+ .openagent-agent-list .agent-card--search:hover {
2532
+ position: relative;
2533
+ border-color: transparent;
2534
+ }
2535
+ .openagent-agent-list .agent-card--mention:hover::after,
2536
+ .openagent-agent-list .agent-card--search:hover::after {
2537
+ content: "";
2538
+ position: absolute;
2539
+ inset: 0;
2540
+ border-radius: inherit;
2541
+ padding: 1px;
2542
+ background: linear-gradient(90deg, rgba(92, 74, 255, 0.5), rgba(130, 116, 255, 0.5));
2543
+ pointer-events: none;
2544
+ box-sizing: border-box;
2545
+ -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
2546
+ -webkit-mask-composite: xor;
2547
+ mask-composite: exclude;
2254
2548
  }
2255
2549
  /* avart 外壳简化 — 不再需要 */
2256
2550
  .agent-card--mention .agent-card__avart {
@@ -2379,9 +2673,6 @@ function injectStyles() {
2379
2673
  border: 0.5px solid transparent;
2380
2674
  box-sizing: border-box;
2381
2675
  }
2382
- .agent-card--search:hover {
2383
- background: rgba(0, 0, 0, 0.02);
2384
- }
2385
2676
  .agent-card--search .agent-card__avatar {
2386
2677
  width: 40px;
2387
2678
  height: 40px;
@@ -2499,7 +2790,6 @@ function injectStyles() {
2499
2790
  [data-theme-mode="dark"] .openagent-agent-panel,
2500
2791
  [data-theme="dark"] .openagent-agent-panel {
2501
2792
  background: #1c1c1c; border-color: rgba(255,255,255,0.12);
2502
- box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
2503
2793
  }
2504
2794
  [data-theme-mode="dark"] .openagent-panel-head,
2505
2795
  [data-theme="dark"] .openagent-panel-head { border-color: #2a2a2a; }
@@ -2511,8 +2801,6 @@ function injectStyles() {
2511
2801
  [data-theme="dark"] .openagent-panel-close:hover { background: #333; }
2512
2802
  [data-theme-mode="dark"] .openagent-section-heading,
2513
2803
  [data-theme="dark"] .openagent-section-heading { color: rgba(224, 224, 224, 0.45); }
2514
- [data-theme-mode="dark"] .openagent-parent-heading,
2515
- [data-theme="dark"] .openagent-parent-heading { color: rgba(224, 224, 224, 0.3); }
2516
2804
  [data-theme-mode="dark"] .openagent-panel-divider,
2517
2805
  [data-theme="dark"] .openagent-panel-divider { border-color: rgba(255,255,255,0.1); }
2518
2806
 
@@ -2526,7 +2814,7 @@ function injectStyles() {
2526
2814
  [data-theme-mode="dark"] .agent-card--mention,
2527
2815
  [data-theme="dark"] .agent-card--mention { background: #1c1c1c; border-color: rgba(255,255,255,0.12); }
2528
2816
  [data-theme-mode="dark"] .agent-card--mention:hover,
2529
- [data-theme="dark"] .agent-card--mention:hover { background: #252525; }
2817
+ [data-theme="dark"] .agent-card--mention:hover { border-color: transparent; }
2530
2818
  [data-theme-mode="dark"] .agent-card--mention .agent-card__name,
2531
2819
  [data-theme="dark"] .agent-card--mention .agent-card__name { color: #e0e0e0; }
2532
2820
  [data-theme-mode="dark"] .agent-card--mention .agent-card__bio,
@@ -2541,8 +2829,6 @@ function injectStyles() {
2541
2829
  }
2542
2830
  [data-theme-mode="dark"] .agent-card--mention .agent-card__action:hover,
2543
2831
  [data-theme="dark"] .agent-card--mention .agent-card__action:hover { background: rgba(255,255,255,0.06); }
2544
- [data-theme-mode="dark"] .agent-card--search:hover,
2545
- [data-theme="dark"] .agent-card--search:hover { background: #252525; }
2546
2832
  [data-theme-mode="dark"] .agent-card--search .agent-card__name,
2547
2833
  [data-theme="dark"] .agent-card--search .agent-card__name { color: #e0e0e0; }
2548
2834
  [data-theme-mode="dark"] .agent-card--search .agent-card__bio,
@@ -2802,6 +3088,7 @@ let panel = null;
2802
3088
  let backdrop = null;
2803
3089
 
2804
3090
  let inputWrapperRef = null; // 保存输入框包裹层引用
3091
+ let panelPositionResizeObserver = null;
2805
3092
 
2806
3093
  // ── 键盘导航状态(§1.5)──
2807
3094
  // 对标 TIM index.ts:13 "let selectedIndex: number = 0"
@@ -2836,7 +3123,7 @@ panel.className = 'openagent-agent-panel';
2836
3123
  panel.innerHTML = `
2837
3124
  <div class="openagent-panel-head">
2838
3125
  <span class="openagent-panel-title">
2839
- <svg class="openagent-panel-title-icon" width="28" height="28" viewBox="0 0 56 56" fill="none">
3126
+ <svg class="openagent-panel-title-icon" width="24" height="24" viewBox="0 0 56 56" fill="none">
2840
3127
  <path d="M28 25H32C34.2091 25 36 26.7909 36 29V39C36 41.2091 34.2091 43 32 43H14C11.7909 43 10 41.2091 10 39V29C10 26.7909 11.7909 25 14 25H15" stroke="#12CCF6" stroke-width="3.3" stroke-linecap="round"/>
2841
3128
  <path d="M39 31H42C44.2091 31 46 29.2091 46 27V17C46 14.7909 44.2091 13 42 13H24C21.7909 13 20 14.7909 20 17V27C20 29.2091 21.7909 31 24 31H30.0652C30.236 31 30.3282 31.2004 30.217 31.3302L27.5 34.5" stroke="#12CCF6" stroke-width="3.3" stroke-linecap="round"/>
2842
3129
  <path d="M27 25.5L32.5 21" stroke="#12CCF6" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
@@ -2879,12 +3166,71 @@ const width = Math.min(rect.width, window.innerWidth - viewportPadding * 2);
2879
3166
  const left = Math.max(viewportPadding, Math.min(rect.left, window.innerWidth - width - viewportPadding));
2880
3167
  panel.style.left = left + 'px';
2881
3168
  panel.style.width = width + 'px';
2882
- panel.style.bottom = (window.innerHeight - rect.top + 8) + 'px';
3169
+ const toolbar = _findPanelToolbar();
3170
+ const isComposerWrapper = inputWrapperRef.classList
3171
+ && inputWrapperRef.classList.contains('agent-chat__composer-combobox');
3172
+ if (isComposerWrapper) {
3173
+ panel.style.bottom = (_readElementHeight(inputWrapperRef) + _readElementHeight(toolbar) + 35) + 'px';
3174
+ } else {
3175
+ panel.style.bottom = (window.innerHeight - rect.top + 8) + 'px';
3176
+ }
2883
3177
  }
2884
3178
 
2885
3179
  /** resize 时实时跟随输入框 */
2886
3180
  function _onResize() { _positionPanel(); }
2887
3181
 
3182
+ function _findPanelToolbar() {
3183
+ if (!inputWrapperRef) return null;
3184
+ var chatInput = inputWrapperRef.closest && inputWrapperRef.closest('.agent-chat__input');
3185
+ if (chatInput) {
3186
+ var toolbar = chatInput.querySelector('.agent-chat__toolbar');
3187
+ if (toolbar) return toolbar;
3188
+ }
3189
+
3190
+ var parentEl = inputWrapperRef.parentElement;
3191
+ if (parentEl) {
3192
+ for (var i = 0; i < parentEl.children.length; i++) {
3193
+ var child = parentEl.children[i];
3194
+ if (child !== inputWrapperRef && child.className && String(child.className).indexOf('agent-chat__toolbar') !== -1) {
3195
+ return child;
3196
+ }
3197
+ }
3198
+ }
3199
+ return null;
3200
+ }
3201
+
3202
+ function _readElementHeight(el) {
3203
+ if (!el) return 0;
3204
+ var rect = el.getBoundingClientRect ? el.getBoundingClientRect() : null;
3205
+ if (rect && rect.height > 0) return rect.height;
3206
+ return typeof el.offsetHeight === 'number' ? el.offsetHeight : 0;
3207
+ }
3208
+
3209
+ function _schedulePanelPosition() {
3210
+ window.requestAnimationFrame
3211
+ ? window.requestAnimationFrame(_positionPanel)
3212
+ : setTimeout(_positionPanel, 0);
3213
+ }
3214
+
3215
+ function _installPanelPositionObservers() {
3216
+ if (panelPositionResizeObserver) {
3217
+ panelPositionResizeObserver.disconnect();
3218
+ panelPositionResizeObserver = null;
3219
+ }
3220
+ if (typeof ResizeObserver !== 'function' || !inputWrapperRef) return;
3221
+
3222
+ panelPositionResizeObserver = new ResizeObserver(_schedulePanelPosition);
3223
+ panelPositionResizeObserver.observe(inputWrapperRef);
3224
+ var toolbar = _findPanelToolbar();
3225
+ if (toolbar) panelPositionResizeObserver.observe(toolbar);
3226
+ }
3227
+
3228
+ function _teardownPanelPositionObservers() {
3229
+ if (!panelPositionResizeObserver) return;
3230
+ panelPositionResizeObserver.disconnect();
3231
+ panelPositionResizeObserver = null;
3232
+ }
3233
+
2888
3234
  // 搜索状态管理
2889
3235
  let currentAbort = null; // AbortController for in-flight search
2890
3236
  let searchDebounceId = null;
@@ -2911,6 +3257,7 @@ if (oldEmpty) oldEmpty.remove();
2911
3257
 
2912
3258
  const p = ensurePanel();
2913
3259
  _positionPanel(); // 动态定位到 input 上方
3260
+ _installPanelPositionObservers();
2914
3261
  p.classList.add('visible');
2915
3262
  backdrop.classList.add('visible');
2916
3263
  window.addEventListener('resize', _onResize);
@@ -2973,6 +3320,7 @@ function closePanel() {
2973
3320
  if (panel) panel.classList.remove('visible');
2974
3321
  if (backdrop) backdrop.classList.remove('visible');
2975
3322
  window.removeEventListener('resize', _onResize);
3323
+ _teardownPanelPositionObservers();
2976
3324
  // 清理搜索状态
2977
3325
  if (currentAbort) { currentAbort.abort(); currentAbort = null; }
2978
3326
  if (searchDebounceId) { clearTimeout(searchDebounceId); searchDebounceId = null; }
@@ -3027,7 +3375,6 @@ function _scrollItemIntoView(index) {
3027
3375
 
3028
3376
  function _appendParentSection(container, parentTitle, children, textarea, renderedAgents) {
3029
3377
  const parentSec = _el('section', 'openagent-parent-section');
3030
- parentSec.appendChild(_text('div', 'openagent-parent-heading', parentTitle));
3031
3378
  children.forEach(function(child) {
3032
3379
  if (child.agents && child.agents.length > 0) {
3033
3380
  _appendAgentSection(parentSec, child.title, child.agents, textarea, renderedAgents);
@@ -3102,7 +3449,12 @@ function _dismissEmptyToast() {
3102
3449
  }
3103
3450
 
3104
3451
  /** 独立浮层空状态(不在面板内) */
3105
- function _showEmptyToast(query) {
3452
+ function _getEmptyMessage(query) {
3453
+ return CL.agentBookLastError ||
3454
+ (query ? '暂未匹配到您想要的Agent 我们将持续上新~' : '暂无在线 Agent,请输入关键词搜索');
3455
+ }
3456
+
3457
+ function _showEmptyToast(query, message) {
3106
3458
  _dismissEmptyToast();
3107
3459
  var toast = _el('div', 'openagent-empty-toast');
3108
3460
 
@@ -3112,8 +3464,7 @@ function _showEmptyToast(query) {
3112
3464
  '</svg>';
3113
3465
  toast.appendChild(iconWrap);
3114
3466
 
3115
- toast.appendChild(_text('span', 'openagent-empty-state__text',
3116
- query ? '暂未匹配到您想要的Agent 我们将持续上新~' : '暂无在线 Agent,请输入关键词搜索'));
3467
+ toast.appendChild(_text('span', 'openagent-empty-state__text', message || _getEmptyMessage(query)));
3117
3468
 
3118
3469
  var closeBtn = _el('button', 'openagent-empty-state__close');
3119
3470
  closeBtn.innerHTML = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none">' +
@@ -3129,12 +3480,17 @@ function _showEmptyToast(query) {
3129
3480
  toast.style.left = Math.max(16, rect.left) + 'px';
3130
3481
  toast.style.width = Math.min(rect.width, window.innerWidth - 32) + 'px';
3131
3482
  toast.style.bottom = (window.innerHeight - rect.top + 8) + 'px';
3483
+ // ── V2 版本兼容:v1 bottom 固定 117px ──
3484
+ var isV2Toast = typeof _clIsHostVersionGte === 'function' && _clIsHostVersionGte('2026.6.9');
3485
+ if (!isV2Toast) {
3486
+ toast.style.bottom = '117px';
3487
+ }
3132
3488
  toast.style.zIndex = '100000';
3133
3489
  }
3134
3490
  document.body.appendChild(toast);
3135
3491
  }
3136
3492
 
3137
- function _createEmptyState(query) {
3493
+ function _createEmptyState(query, message) {
3138
3494
  var wrapper = _el('div', 'openagent-empty-state');
3139
3495
  var row = _el('div', 'openagent-empty-state__row');
3140
3496
 
@@ -3144,8 +3500,7 @@ function _createEmptyState(query) {
3144
3500
  '</svg>';
3145
3501
  row.appendChild(iconWrap);
3146
3502
 
3147
- var text = _text('span', 'openagent-empty-state__text',
3148
- query ? '暂未匹配到您想要的Agent 我们将持续上新~' : '暂无在线 Agent,请输入关键词搜索');
3503
+ var text = _text('span', 'openagent-empty-state__text', message || _getEmptyMessage(query));
3149
3504
  row.appendChild(text);
3150
3505
 
3151
3506
  var closeBtn = _el('button', 'openagent-empty-state__close');
@@ -3163,10 +3518,11 @@ function _createEmptyState(query) {
3163
3518
 
3164
3519
  function renderAgentList(container, agents, textarea, query) {
3165
3520
  if (!agents.length) {
3521
+ var emptyMessage = _getEmptyMessage(query);
3166
3522
  _currentAgents = [];
3167
3523
  _currentTextarea = textarea;
3168
3524
  closePanel();
3169
- _showEmptyToast(query);
3525
+ _showEmptyToast(query, emptyMessage);
3170
3526
  return;
3171
3527
  }
3172
3528
 
@@ -3203,6 +3559,19 @@ _highlightItem(0);
3203
3559
  * 对齐 openagent-frontend NewChatPanel L92-105:
3204
3560
  * 找到最后一个 @,替换其后内容为 @agentName
3205
3561
  */
3562
+ function _pickMentionAgentDescription(agent) {
3563
+ if (!agent || typeof agent !== 'object') return '';
3564
+ if (CL && typeof CL.pickAgentIdentityDescription === 'function') {
3565
+ return CL.pickAgentIdentityDescription(agent);
3566
+ }
3567
+ const keys = ['agent_bio', 'agentBio', 'bio', 'description', 'desc', 'agent_description', 'agentDescription', 'MOM', 'mom'];
3568
+ for (let i = 0; i < keys.length; i++) {
3569
+ const value = agent[keys[i]];
3570
+ if (typeof value === 'string' && value.trim()) return value.trim();
3571
+ }
3572
+ return '';
3573
+ }
3574
+
3206
3575
  function insertMention(textarea, agentName, agentData) {
3207
3576
  // 重新查找 textarea(Lit 可能重新渲染导致引用失效)
3208
3577
  const liveTextarea = document.querySelector(
@@ -3222,9 +3591,11 @@ liveTextarea.focus();
3222
3591
  const agentId = agentData?.agent_id || agentData?.agentId || agentData?.id || agentData?.tag ||
3223
3592
  agentData?.user_id || agentData?.userId || agentData?.identifier || agentData?.tim_user_id || agentData?.timUserId || '';
3224
3593
  const agentAvatar = agentData?.avatar || agentData?.avatar_url || agentData?.avatarUrl || agentData?.image || agentData?.logo || agentData?.photo || null;
3594
+ const agentBio = _pickMentionAgentDescription(agentData);
3225
3595
  console.log('[cl-diag][mention-select]', {
3226
3596
  agentName,
3227
3597
  resolvedAgentId: agentId || null,
3598
+ hasAgentBio: !!agentBio,
3228
3599
  rawKeys: Object.keys(agentData || {}),
3229
3600
  rawAgent: agentData,
3230
3601
  });
@@ -3233,9 +3604,14 @@ if (!agentId) {
3233
3604
  console.warn('[openagent] mention skipped: missing agent identifier for', agentName, agentData);
3234
3605
  return;
3235
3606
  }
3236
- CL.pendingMention = { agent_id: agentId, name: agentName, avatar: agentAvatar };
3607
+ CL.pendingMention = { agent_id: agentId, name: agentName, avatar: agentAvatar, agent_bio: agentBio };
3237
3608
  if (CL && typeof CL.storeAgentIdentity === 'function') {
3238
- CL.storeAgentIdentity({ agent_id: agentId, name: agentName, avatar: agentAvatar });
3609
+ CL.storeAgentIdentity(Object.assign({}, agentData || {}, {
3610
+ agent_id: agentId,
3611
+ name: agentName,
3612
+ avatar: agentAvatar,
3613
+ agent_bio: agentBio,
3614
+ }));
3239
3615
  }
3240
3616
  console.log('[openagent] mention stored:', CL.pendingMention);
3241
3617
 
@@ -3315,12 +3691,27 @@ function _setTextareaValue(textarea, value) {
3315
3691
  textarea.dispatchEvent(new Event('input', { bubbles: true }));
3316
3692
  }
3317
3693
 
3694
+ function _escapeRemoteAgentMarkerValue(value) {
3695
+ return String(value || '')
3696
+ .replace(/\s+/g, ' ')
3697
+ .trim()
3698
+ .replace(/"/g, "'");
3699
+ }
3700
+
3318
3701
  function _buildRemoteAgentMarker(mention, userText) {
3319
3702
  const hasChinese = /[\u4e00-\u9fff]/.test(userText || '');
3320
3703
  const instruction = hasChinese
3321
3704
  ? '请调用 openagent_call_remote_agent 工具将此请求转发给远端 Agent 处理'
3322
3705
  : 'Please invoke the openagent_call_remote_agent tool to forward this request to the remote agent';
3323
- return `{openagent_call_remote_agent:agent_id="${mention.agent_id}",agent_name="${mention.name}",instruction="${instruction}"}`;
3706
+ const attrs = [
3707
+ `agent_id="${_escapeRemoteAgentMarkerValue(mention.agent_id)}"`,
3708
+ `agent_name="${_escapeRemoteAgentMarkerValue(mention.name)}"`,
3709
+ ];
3710
+ if (mention.agent_bio) {
3711
+ attrs.push(`agent_bio="${_escapeRemoteAgentMarkerValue(mention.agent_bio)}"`);
3712
+ }
3713
+ attrs.push(`instruction="${_escapeRemoteAgentMarkerValue(instruction)}"`);
3714
+ return `{openagent_call_remote_agent:${attrs.join(',')}}`;
3324
3715
  }
3325
3716
 
3326
3717
  function _composeRemoteAgentMessage(textarea, mention) {
@@ -3562,13 +3953,13 @@ function tryInject() {
3562
3953
  console.log('[openagent] ✅ Agent Book UI injected (v3 hook-driven)');
3563
3954
 
3564
3955
  // ── 提示栏(Figma 141:3293):页面加载即显示 ──
3565
- _injectHintBar(inputContainer || textarea.parentElement);
3956
+ _injectHintBar(inputContainer || textarea.parentElement, toolbarRow);
3566
3957
 
3567
3958
  return true;
3568
3959
  }
3569
3960
 
3570
3961
  /** 注入提示栏到输入区域上方 */
3571
- function _injectHintBar(anchorEl) {
3962
+ function _injectHintBar(anchorEl, toolbarEl) {
3572
3963
  if (!anchorEl || document.querySelector('.openagent-hint-bar')) return;
3573
3964
 
3574
3965
  const hintBar = document.createElement('div');
@@ -3604,8 +3995,95 @@ function _injectHintBar(anchorEl) {
3604
3995
  hintBar.style.display = 'none';
3605
3996
  });
3606
3997
 
3998
+ // ── V2 版本兼容:≥ 2026.6.9 使用 absolute 定位,bottom 动态跟随输入区高度 ──
3999
+ var isV2 = typeof _clIsHostVersionGte === 'function' && _clIsHostVersionGte('2026.6.9');
4000
+ if (isV2) {
4001
+ hintBar.style.position = 'absolute';
4002
+ }
4003
+
3607
4004
  // 插入到 wrapper 外面、上方
3608
4005
  anchorEl.parentElement.insertBefore(hintBar, anchorEl);
4006
+
4007
+ function _findHintBarToolbar() {
4008
+ if (toolbarEl) return toolbarEl;
4009
+ var parentEl = anchorEl.parentElement;
4010
+ if (parentEl) {
4011
+ for (var i = 0; i < parentEl.children.length; i++) {
4012
+ var child = parentEl.children[i];
4013
+ if (child !== anchorEl && child.className && String(child.className).indexOf('agent-chat__toolbar') !== -1) {
4014
+ return child;
4015
+ }
4016
+ }
4017
+ }
4018
+ return anchorEl.closest && anchorEl.closest('.agent-chat__input')
4019
+ ? anchorEl.closest('.agent-chat__input').querySelector('.agent-chat__toolbar')
4020
+ : null;
4021
+ }
4022
+
4023
+ function _readElementHeight(el) {
4024
+ if (!el) return 0;
4025
+ var rect = el.getBoundingClientRect ? el.getBoundingClientRect() : null;
4026
+ if (rect && rect.height > 0) return rect.height;
4027
+ return typeof el.offsetHeight === 'number' ? el.offsetHeight : 0;
4028
+ }
4029
+
4030
+ // 跟随 composer wrapper 的实际尺寸。侧栏拖拽/布局重排不一定触发 window resize。
4031
+ function _syncHintBarLayout() {
4032
+ var rect = anchorEl.getBoundingClientRect();
4033
+ if (rect.width > 0) {
4034
+ hintBar.style.width = rect.width + 'px';
4035
+ var rootStyle = document.documentElement && document.documentElement.style;
4036
+ if (rootStyle) {
4037
+ rootStyle.setProperty('--openagent-input-wrapper-right-offset', Math.max(0, window.innerWidth - rect.right) + 'px');
4038
+ rootStyle.setProperty('--openagent-input-wrapper-right-edge', Math.max(0, rect.right) + 'px');
4039
+ rootStyle.setProperty('--openagent-input-wrapper-width', rect.width + 'px');
4040
+ }
4041
+ _syncSidebarRightEdge(rect);
4042
+ }
4043
+ if (isV2) {
4044
+ var toolbar = _findHintBarToolbar();
4045
+ var bottom = _readElementHeight(anchorEl) + _readElementHeight(toolbar) + 6;
4046
+ hintBar.style.bottom = bottom + 'px';
4047
+ }
4048
+ }
4049
+
4050
+ function _syncSidebarRightEdge(inputRect) {
4051
+ var sidebars = document.querySelectorAll('.chat-sidebar');
4052
+ for (var i = 0; i < sidebars.length; i++) {
4053
+ var sidebar = sidebars[i];
4054
+ var sidebarRect = sidebar.getBoundingClientRect();
4055
+ if (!sidebarRect || sidebarRect.width <= 0) continue;
4056
+ var left = Math.max(0, sidebarRect.left);
4057
+ var targetRight = Math.min(window.innerWidth, Math.max(0, inputRect.right));
4058
+ var targetWidth = Math.floor(targetRight - left);
4059
+ if (targetWidth <= 0) continue;
4060
+ sidebar.style.setProperty('--openagent-sidebar-target-width', targetWidth + 'px');
4061
+ sidebar.style.setProperty('width', targetWidth + 'px', 'important');
4062
+ sidebar.style.setProperty('max-width', targetWidth + 'px', 'important');
4063
+ sidebar.style.setProperty('flex-basis', targetWidth + 'px', 'important');
4064
+ sidebar.style.setProperty('margin-right', '0px', 'important');
4065
+ }
4066
+ }
4067
+
4068
+ function _scheduleHintBarLayoutSync() {
4069
+ window.requestAnimationFrame
4070
+ ? window.requestAnimationFrame(_syncHintBarLayout)
4071
+ : setTimeout(_syncHintBarLayout, 0);
4072
+ }
4073
+
4074
+ _syncHintBarLayout();
4075
+ _scheduleHintBarLayoutSync();
4076
+ window.addEventListener('resize', _scheduleHintBarLayoutSync);
4077
+ if (typeof ResizeObserver === 'function') {
4078
+ var hintBarResizeObserver = new ResizeObserver(_scheduleHintBarLayoutSync);
4079
+ hintBarResizeObserver.observe(anchorEl);
4080
+ var toolbarForResize = _findHintBarToolbar();
4081
+ if (toolbarForResize) hintBarResizeObserver.observe(toolbarForResize);
4082
+ }
4083
+ if (typeof MutationObserver === 'function' && document.body) {
4084
+ var sidebarLayoutObserver = new MutationObserver(_scheduleHintBarLayoutSync);
4085
+ sidebarLayoutObserver.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });
4086
+ }
3609
4087
  }
3610
4088
 
3611
4089
  // ════════════════════════════════════════════════════════════════
@@ -3952,10 +4430,12 @@ registerComponent('agent-card', async (data) => {
3952
4430
  function _clHandleTripDataSignal(payload, contextNode) {
3953
4431
  if (!payload) return;
3954
4432
  console.log('[trip-data] detected signal, payload:', payload.substring(0, 40));
4433
+ const hostTextContextSelector = (typeof CL !== 'undefined' && CL.hostAdapter && CL.hostAdapter.selectors && CL.hostAdapter.selectors.textContext)
4434
+ || '.chat-text';
3955
4435
 
3956
4436
  if (payload === 'file') {
3957
4437
  const chatText = contextNode && contextNode.closest
3958
- ? contextNode.closest('.chat-text, .chat-tool-card__detail, .chat-tools-collapse__body')
4438
+ ? contextNode.closest(hostTextContextSelector)
3959
4439
  : null;
3960
4440
  if (chatText) {
3961
4441
  chatText.dataset.clProcessed = '';
@@ -3972,7 +4452,7 @@ function _clHandleTripDataSignal(payload, contextNode) {
3972
4452
  }
3973
4453
  console.log('[trip-data] ✅ Card data from base64');
3974
4454
  const chatText = contextNode && contextNode.closest
3975
- ? contextNode.closest('.chat-text, .chat-tool-card__detail, .chat-tools-collapse__body')
4455
+ ? contextNode.closest(hostTextContextSelector)
3976
4456
  : null;
3977
4457
  if (chatText) {
3978
4458
  chatText.dataset.clProcessed = '';
@@ -4153,9 +4633,12 @@ if (document.readyState === 'loading') {
4153
4633
  // ── 1. CSS 注入 ──
4154
4634
 
4155
4635
  (function injectThoughtChainStyles() {
4156
- if (document.getElementById('cl-tools-collapse-css')) return;
4636
+ var oldStyle = document.getElementById('cl-tools-collapse-css');
4637
+ if (oldStyle) oldStyle.remove();
4157
4638
  const style = document.createElement('style');
4158
4639
  style.id = 'cl-tools-collapse-css';
4640
+ style.setAttribute('data-openagent-style', 'thought-chain');
4641
+ style.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
4159
4642
  style.textContent = `
4160
4643
  /* ── Agent Pill(通用身份标签) ── */
4161
4644
  .cl-agent-pill {
@@ -4359,7 +4842,12 @@ CL.handleDelegateWsEvent = function (msg) {
4359
4842
  // ════════════════════════════════════════════════════════════════
4360
4843
 
4361
4844
  // ── 1. CSS 注入 ──
4845
+ var _oldTripCSS = document.getElementById('openagent-trip-card-styles');
4846
+ if (_oldTripCSS) _oldTripCSS.remove();
4362
4847
  const _tripCSS = document.createElement('style');
4848
+ _tripCSS.id = 'openagent-trip-card-styles';
4849
+ _tripCSS.setAttribute('data-openagent-style', 'trip-card');
4850
+ _tripCSS.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
4363
4851
  _tripCSS.textContent = `
4364
4852
  /* ── 行程文字:普通文字灰色,特殊标注(粗体/链接/标题)黑色 ── */
4365
4853
  .trip-styled li, .trip-styled p { color: #888 !important; }
@@ -4434,7 +4922,13 @@ margin: 0 8px; position: relative; top: -1px;
4434
4922
  .trip-img-card {
4435
4923
  display: flex; flex-direction: row; gap: 6px;
4436
4924
  overflow-x: auto; padding: 8px 0; margin-left: 20px;
4437
- scrollbar-width: thin;
4925
+ scrollbar-width: none;
4926
+ -ms-overflow-style: none;
4927
+ }
4928
+ .trip-img-card::-webkit-scrollbar {
4929
+ width: 0;
4930
+ height: 0;
4931
+ display: none;
4438
4932
  }
4439
4933
  .trip-img-item {
4440
4934
  position: relative; width: 191px; height: 100px; border-radius: 8px;
@@ -5783,20 +6277,32 @@ function _processCustomCards(bubble) {
5783
6277
 
5784
6278
  // CL.clScanCount lives on CL.clScanCount
5785
6279
 
6280
+ function _clIsInsideNativeToolHost(node) {
6281
+ var adapter = CL && CL.hostAdapter;
6282
+ var cur = node;
6283
+ var hops = 0;
6284
+ while (cur && cur !== document.body && hops < 12) {
6285
+ if (adapter && adapter.isToolLikeShell && adapter.isToolLikeShell(cur)) return true;
6286
+ cur = cur.parentElement;
6287
+ hops++;
6288
+ }
6289
+ return !!(node && node.closest && node.closest('details'));
6290
+ }
6291
+
5786
6292
  function _clScan() {
5787
6293
  CL.clScanCount++;
5788
6294
 
5789
6295
  // ── 0.5 清理标记 → 显示为 @agentName ──
5790
- // 新格式: {openagent_call_remote_agent:agent_id="...",agent_name="...",instruction="..."}
6296
+ // 新格式: {openagent_call_remote_agent:agent_id="...",agent_name="...",agent_bio="...",instruction="..."}
5791
6297
  // 旧格式: {openagent:agent_id="...",agent_name="..."}
5792
6298
  // 两种都要匹配清理;这里只处理普通聊天气泡,不处理 ToolCard。
5793
6299
  var CL_MENTION_STYLE = '';
5794
6300
  document.querySelectorAll('.chat-bubble').forEach(function(el) {
5795
6301
  if (el.dataset.clMarkerCleaned) return;
5796
- if (el.closest('.chat-tool-card, .chat-tools-collapse, details')) return;
6302
+ if (_clIsInsideNativeToolHost(el)) return;
5797
6303
 
5798
6304
  var text = el.textContent || '';
5799
- var rawRegex = /\{openagent(?:_call_remote_agent)?:agent_id="([^"]*)",agent_name="([^"]*)"(?:,instruction="[^"]*")?\}\s*/g;
6305
+ var rawRegex = /\{openagent(?:_call_remote_agent)?:agent_id="([^"]*)",agent_name="([^"]*)"(?:,[^{}]*)?\}\s*/g;
5800
6306
  if (!rawRegex.test(text)) return;
5801
6307
 
5802
6308
  if (el.querySelector('.cl-remote-agent-card')) {
@@ -5804,7 +6310,7 @@ function _clScan() {
5804
6310
  return; // 包含活 DOM,跳过 innerHTML 重写
5805
6311
  }
5806
6312
 
5807
- var htmlRegex = /\{openagent(?:_call_remote_agent)?:agent_id=(?:&quot;|")([^&"]*)(?:&quot;|"),agent_name=(?:&quot;|")([^&"]*)(?:&quot;|")(?:,instruction=(?:&quot;|")[^&"]*(?:&quot;|"))?\}\s*/g;
6313
+ var htmlRegex = /\{openagent(?:_call_remote_agent)?:agent_id=(?:&quot;|")([^&"]*)(?:&quot;|"),agent_name=(?:&quot;|")([^&"]*)(?:&quot;|")(?:,[^{}]*)?\}\s*/g;
5808
6314
  if (CL && typeof CL.diagHtmlRewrite === 'function') {
5809
6315
  CL.diagHtmlRewrite('scanner.marker.before', el, { scan: CL.clScanCount });
5810
6316
  }
@@ -5839,7 +6345,7 @@ function _clScan() {
5839
6345
  if (mentionedAgents.length > 0) {
5840
6346
  document.querySelectorAll('.chat-bubble').forEach(function(el) {
5841
6347
  if (el.dataset.clAgentStyled) return;
5842
- if (el.closest('.chat-tool-card, .chat-tools-collapse, details')) return;
6348
+ if (_clIsInsideNativeToolHost(el)) return;
5843
6349
 
5844
6350
  var text = el.textContent || '';
5845
6351
  var html = el.innerHTML;
@@ -5910,30 +6416,12 @@ function _clScan() {
5910
6416
 
5911
6417
  (function _clInitNativeStyleAdapter() {
5912
6418
  var _clNativeStyleSampled = false;
6419
+ var hostAdapter = CL.hostAdapter || {};
6420
+ var nativeStyle = hostAdapter.nativeStyle || {};
5913
6421
 
5914
- var SHELL_SELECTORS = [
5915
- '.chat-tool-card:not(:has(.cl-remote-agent-card))',
5916
- '.chat-tool-msg-collapse:not(:has(.cl-remote-agent-card))',
5917
- '.chat-tools-collapse:not(:has(.cl-remote-agent-card))',
5918
- // v5.x+ variants
5919
- '.tool-card:not(:has(.cl-remote-agent-card))',
5920
- '.chat-tool-card__wrapper:not(:has(.cl-remote-agent-card))'
5921
- ];
5922
-
5923
- var SUMMARY_SELECTORS = [
5924
- '.chat-tool-card__header',
5925
- '.chat-tool-card__title',
5926
- '.chat-tool-msg-summary:not(.cl-remote-agent-host-shell *)',
5927
- '.chat-tools-summary:not(.cl-remote-agent-host-shell *)',
5928
- // v5.x+ variants
5929
- '.tool-card__header',
5930
- '.tool-card__title'
5931
- ];
5932
-
5933
- var INDENT_SELECTORS = [
5934
- '.chat-group.tool:not(:has(.cl-remote-agent-card))',
5935
- '.chat-bubble:not(:has(.cl-remote-agent-card))'
5936
- ];
6422
+ var SHELL_SELECTORS = nativeStyle.shellSelectors || [];
6423
+ var SUMMARY_SELECTORS = nativeStyle.summarySelectors || [];
6424
+ var INDENT_SELECTORS = nativeStyle.indentSelectors || [];
5937
6425
 
5938
6426
  // Fallback 默认值(和当前 styles.js 折叠态写死值保持一致,避免跳变)
5939
6427
  var FALLBACKS = {
@@ -6069,62 +6557,75 @@ function _clScan() {
6069
6557
  if (oldStyle) oldStyle.remove();
6070
6558
  var style = document.createElement('style');
6071
6559
  style.id = 'cl-remote-agent-styles';
6560
+ style.setAttribute('data-openagent-style', 'remote-agent');
6561
+ style.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
6562
+ style.setAttribute('data-openagent-host-adapter', (CL.hostAdapter && CL.hostAdapter.id) || 'oc-unknown');
6563
+ var hostCss = (CL.hostAdapter && CL.hostAdapter.css) || {};
6564
+ function _clSelectorList(selectors) {
6565
+ if (!selectors) return '';
6566
+ if (Array.isArray(selectors)) return selectors.filter(Boolean).join(',\n');
6567
+ return String(selectors || '');
6568
+ }
6569
+ function _clRule(selectors, declarations) {
6570
+ var selectorText = _clSelectorList(selectors);
6571
+ if (!selectorText) return '';
6572
+ return selectorText + ' {\n' + declarations.join('\n') + '\n}';
6573
+ }
6072
6574
  style.textContent = [
6073
- // ── RenderHook 远端 Agent 卡片接管 native tool header ──
6074
- 'details.chat-tools-collapse:has(.cl-remote-agent-card),',
6075
- 'details.chat-tool-msg-collapse:has(.cl-remote-agent-card),',
6076
- '.chat-tools-collapse:has(.cl-remote-agent-card),',
6077
- '.chat-tool-msg-collapse:has(.cl-remote-agent-card) {',
6078
- ' width: 100% !important;',
6079
- ' max-width: none !important;',
6080
- ' box-sizing: border-box !important;',
6081
- ' border: 0 !important;',
6082
- ' background: transparent !important;',
6083
- ' box-shadow: none !important;',
6084
- '}',
6085
- '/* Align output host shells with execution shells. 3.28 renders output as',
6086
- ' chat-tools-collapse + .cl-output-card; some versions use chat-tool-msg-collapse.',
6087
- ' Move the host shell, not the inner OpenAgent card. */',
6088
- 'details.chat-tools-collapse:has(.cl-output-card),',
6089
- '.chat-tools-collapse:has(.cl-output-card),',
6090
- 'details.chat-tool-msg-collapse:has(.cl-remote-agent-card),',
6091
- '.chat-tool-msg-collapse:has(.cl-remote-agent-card) {',
6092
- ' margin-left: 12px !important;',
6093
- '}',
6094
- 'details.chat-tools-collapse:has(.cl-remote-agent-card) > summary.chat-tools-summary,',
6095
- 'details.chat-tool-msg-collapse:has(.cl-remote-agent-card) > summary.chat-tool-msg-summary,',
6096
- '.chat-tools-collapse:has(.cl-remote-agent-card) > .chat-tools-summary,',
6097
- '.chat-tool-msg-collapse:has(.cl-remote-agent-card) > .chat-tool-msg-summary {',
6098
- ' display: none !important;',
6099
- '}',
6100
- '.chat-tools-collapse__body.cl-remote-agent-host-shell > .chat-text,',
6101
- '.chat-tool-msg-body.cl-remote-agent-host-shell > .chat-text {',
6575
+ // ── 隐藏宿主上下文用量提示 ──
6576
+ '.context-notice.context-notice--usage,',
6577
+ '.context-notice .context-notice--usage {',
6102
6578
  ' display: none !important;',
6103
6579
  '}',
6580
+
6581
+ // ── RenderHook 远端 Agent 卡片接管 native tool header ──
6582
+ _clRule(hostCss.remoteShell, [
6583
+ ' width: 100% !important;',
6584
+ ' max-width: 100% !important;',
6585
+ ' min-width: 0 !important;',
6586
+ ' box-sizing: border-box !important;',
6587
+ ' border: 0 !important;',
6588
+ ' background: transparent !important;',
6589
+ ' box-shadow: none !important;',
6590
+ ]),
6591
+ '/* Align output host shells with execution shells. Keep v4 msg-collapse',
6592
+ ' separate from newer tools-collapse so modern spacing never leaks into',
6593
+ ' the 2026.4 DOM. Move the host shell, not the inner OpenAgent card. */',
6594
+ _clRule(hostCss.outputHostMargin, [
6595
+ ' margin-left: 12px !important;',
6596
+ ]),
6597
+ _clRule(hostCss.outputHostMarginReset, [
6598
+ ' margin-left: 0 !important;',
6599
+ ]),
6600
+ _clRule(hostCss.summaryHidden, [
6601
+ ' display: none !important;',
6602
+ ]),
6603
+ _clRule(hostCss.hostShellRawText, [
6604
+ ' display: none !important;',
6605
+ ]),
6104
6606
  '.cl-remote-agent-raw-hidden > .chat-text,',
6105
6607
  '.cl-remote-agent-raw-hidden.chat-bubble > .chat-text {',
6106
6608
  ' display: none !important;',
6107
6609
  '}',
6108
6610
  '/* Phase A: 不依赖 host-shell class,用 :has() 直接隐藏宿主 raw text */',
6109
- '.chat-tools-collapse__body:has(.cl-remote-agent-card) > .chat-text,',
6110
- '.chat-tool-msg-body:has(.cl-remote-agent-card) > .chat-text,',
6111
- '.chat-tool-card__detail:has(.cl-remote-agent-card) > .chat-text,',
6112
- '.chat-tools-collapse__body:has(.cl-remote-agent-output-placeholder) > .chat-text,',
6113
- '.chat-tool-msg-body:has(.cl-remote-agent-output-placeholder) > .chat-text,',
6114
- '.chat-tool-card__detail:has(.cl-remote-agent-output-placeholder) > .chat-text {',
6115
- ' display: none !important;',
6116
- '}',
6117
- 'details.chat-tools-collapse:has(.cl-remote-agent-card) > .chat-tools-collapse__body,',
6118
- 'details.chat-tool-msg-collapse:has(.cl-remote-agent-card) > .chat-tool-msg-body,',
6119
- '.chat-tools-collapse:has(.cl-remote-agent-card) > .chat-tools-collapse__body,',
6120
- '.chat-tool-msg-collapse:has(.cl-remote-agent-card) > .chat-tool-msg-body {',
6121
- ' border: 0 !important;',
6122
- ' outline: 0 !important;',
6123
- ' background: transparent !important;',
6124
- ' box-shadow: none !important;',
6125
- ' padding: 0 !important;',
6126
- ' margin: 0 !important;',
6127
- '}',
6611
+ _clRule(hostCss.rawTextCardHosts, [
6612
+ ' display: none !important;',
6613
+ ]),
6614
+ _clRule(hostCss.rawTextPlaceholderHosts, [
6615
+ ' display: none !important;',
6616
+ ]),
6617
+ _clRule(hostCss.hostBody, [
6618
+ ' border: 0 !important;',
6619
+ ' outline: 0 !important;',
6620
+ ' background: transparent !important;',
6621
+ ' box-shadow: none !important;',
6622
+ ' padding: 0 !important;',
6623
+ ' margin: 0 !important;',
6624
+ ' width: 100% !important;',
6625
+ ' max-width: 100% !important;',
6626
+ ' min-width: 0 !important;',
6627
+ ' box-sizing: border-box !important;',
6628
+ ]),
6128
6629
  '.chat-bubble:has(.cl-remote-agent-card) {',
6129
6630
  ' border: 0 !important;',
6130
6631
  ' background: transparent !important;',
@@ -6132,11 +6633,22 @@ function _clScan() {
6132
6633
  ' padding: 10px 0 !important;',
6133
6634
  ' width: 100%;',
6134
6635
  ' max-width: 100% !important;',
6636
+ ' min-width: 0 !important;',
6135
6637
  ' overflow: hidden !important;',
6638
+ ' box-sizing: border-box !important;',
6136
6639
  '}',
6137
- '.chat-tool-msg-collapse.chat-tool-msg-collapse--manual.is-open:has(.cl-remote-agent-card) {',
6138
- ' margin-left: 0 !important;',
6640
+ '.chat-split-container:has(.cl-output-card),',
6641
+ '.chat-main:has(.cl-output-card),',
6642
+ '.chat-sidebar:has(.cl-output-card),',
6643
+ '.chat-side-result:has(.cl-output-card),',
6644
+ '.chat-side-result__body:has(.cl-output-card) {',
6645
+ ' min-width: 0 !important;',
6646
+ ' max-width: 100% !important;',
6647
+ ' box-sizing: border-box !important;',
6139
6648
  '}',
6649
+ _clRule(hostCss.manualOpenReset, [
6650
+ ' margin-left: 0 !important;',
6651
+ ]),
6140
6652
  // ── 外层活动组容器 ──
6141
6653
  '.chat-activity-group__body:has(.cl-remote-agent-card) {',
6142
6654
  ' border-radius: 14px;',
@@ -6152,22 +6664,18 @@ function _clScan() {
6152
6664
  '.cl-remote-agent-host-shell {',
6153
6665
  ' width: min(100%, 912px) !important;',
6154
6666
  ' max-width: 100% !important;',
6667
+ ' min-width: 0 !important;',
6155
6668
  ' box-sizing: border-box !important;',
6156
6669
  '}',
6157
- '.cl-remote-agent-host-shell.chat-tool-card,',
6158
- '.cl-remote-agent-host-shell.chat-tool-card__detail,',
6159
- '.cl-remote-agent-host-shell.chat-tools-collapse__body,',
6160
- '.cl-remote-agent-host-shell.chat-tool-msg-body,',
6161
- 'details.cl-remote-agent-host-shell {',
6162
- ' border: 0 !important;',
6163
- ' outline: 0 !important;',
6164
- ' background: transparent !important;',
6165
- ' box-shadow: none !important;',
6166
- '}',
6167
- '.cl-remote-agent-host-shell > summary.chat-tools-summary,',
6168
- '.cl-remote-agent-host-shell > summary.chat-tool-msg-summary {',
6169
- ' display: none !important;',
6170
- '}',
6670
+ _clRule(hostCss.hostShellReset, [
6671
+ ' border: 0 !important;',
6672
+ ' outline: 0 !important;',
6673
+ ' background: transparent !important;',
6674
+ ' box-shadow: none !important;',
6675
+ ]),
6676
+ _clRule(hostCss.hostShellSummary, [
6677
+ ' display: none !important;',
6678
+ ]),
6171
6679
  // ── 新卡片容器 ──
6172
6680
  // 覆盖 OpenClaw .chat-tool-card 的 max-height: 120px 限制
6173
6681
  '.cl-remote-agent-card {',
@@ -6180,9 +6688,14 @@ function _clScan() {
6180
6688
  ' background: #fff;',
6181
6689
  ' display: flex;',
6182
6690
  ' flex-direction: column;',
6183
- ' gap: 10px;',
6184
6691
  ' box-sizing: border-box;',
6185
6692
  '}',
6693
+ _clRule(hostCss.modernCardLayout ? ['.cl-remote-agent-card'] : [], [
6694
+ ' overflow: hidden;',
6695
+ ' min-width: 0;',
6696
+ ' gap: 0;',
6697
+ ' padding: 15px;',
6698
+ ]),
6186
6699
 
6187
6700
  // ── 顶部 OpenAgent 标题条 ──
6188
6701
  '.cl-openagent-header {',
@@ -6200,8 +6713,16 @@ function _clScan() {
6200
6713
  '}',
6201
6714
  '.cl-openagent-header:hover {',
6202
6715
  '}',
6716
+ _clRule(!hostCss.modernCardLayout ? ['.cl-openagent-header'] : [], [
6717
+ ' height: auto;',
6718
+ ' padding: 16px 25px;',
6719
+ ]),
6720
+ _clRule(hostCss.modernCardLayout ? ['.cl-openagent-header'] : [], [
6721
+ ' gap: 0;',
6722
+ ' height: auto;',
6723
+ ' padding: 15px;',
6724
+ ]),
6203
6725
  '/* Output mode (Figma 373:12082) */',
6204
- '.cl-openagent-header--output,',
6205
6726
  '.cl-exec-v2 .cl-openagent-header--output {',
6206
6727
  ' border-radius: 10px 10px 0 0 !important;',
6207
6728
  ' border: 1px solid rgba(229, 229, 234, 0.75) !important;',
@@ -6210,11 +6731,9 @@ function _clScan() {
6210
6731
  ' box-shadow: 0px 8px 11px rgba(0, 0, 0, 0.12);',
6211
6732
  ' padding: 8px 6px !important;',
6212
6733
  '}',
6213
- '.cl-openagent-header--output .cl-openagent-agent,',
6214
6734
  '.cl-exec-v2 .cl-openagent-header--output .cl-openagent-agent {',
6215
6735
  ' display: none;',
6216
6736
  '}',
6217
- '.cl-openagent-header--output:hover,',
6218
6737
  '.cl-exec-v2 .cl-openagent-header--output:hover {',
6219
6738
  ' border-color: rgba(0,0,0,0.1);',
6220
6739
  '}',
@@ -6234,10 +6753,14 @@ function _clScan() {
6234
6753
  ' width: 14px;',
6235
6754
  ' height: 14px;',
6236
6755
  ' border-radius: 14px;',
6237
- ' background: url(./icon.png) center/cover no-repeat;',
6756
+ ' background: url(./icon.png) center / contain no-repeat;',
6238
6757
  ' flex-shrink: 0;',
6239
6758
  ' overflow: hidden;',
6240
6759
  '}',
6760
+ _clRule(hostCss.modernCardLayout ? ['.cl-openagent-badge'] : [], [
6761
+ ' background: url(./icon.png) center/cover no-repeat;',
6762
+ ' margin: 0 6px;',
6763
+ ]),
6241
6764
  '.cl-openagent-text-row {',
6242
6765
  ' display: flex;',
6243
6766
  ' align-items: center;',
@@ -6268,7 +6791,20 @@ function _clScan() {
6268
6791
  ' display: flex;',
6269
6792
  ' flex-direction: column;',
6270
6793
  ' gap: 16px;',
6794
+ ' min-width: 0;',
6795
+ ' max-width: 100%;',
6796
+ ' box-sizing: border-box;',
6271
6797
  '}',
6798
+ _clRule(!hostCss.modernCardLayout ? ['.cl-thought-chain-content.cl-thought-chain-content--execution'] : [], [
6799
+ ' padding: 0 15px 15px;',
6800
+ ]),
6801
+ _clRule(hostCss.modernCardLayout ? ['.cl-thought-chain-content'] : [], [
6802
+ ' margin-left: 0;',
6803
+ ' width: 100%;',
6804
+ ' min-width: 0;',
6805
+ ' box-sizing: border-box;',
6806
+ ' overflow: hidden;',
6807
+ ]),
6272
6808
  '.cl-exec-detail-card {',
6273
6809
  ' padding: 8px 16px 8px 12px;',
6274
6810
  ' border-radius: 8px;',
@@ -6287,8 +6823,7 @@ function _clScan() {
6287
6823
  '.cl-exec-agent-avatar {',
6288
6824
  ' width: 68px;',
6289
6825
  ' height: 68px;',
6290
- ' border-radius: 50%;',
6291
- ' object-fit: cover;',
6826
+ ' object-fit: contain;',
6292
6827
  ' flex-shrink: 0;',
6293
6828
  '}',
6294
6829
  '.cl-exec-detail-info {',
@@ -6340,6 +6875,17 @@ function _clScan() {
6340
6875
  ' margin: 0;',
6341
6876
  ' line-height: 1;',
6342
6877
  '}',
6878
+ _clRule(!hostCss.modernCardLayout ? ['.cl-exec-agent-bio'] : [], [
6879
+ ' width: 250px;',
6880
+ ' max-width: 100%;',
6881
+ ' min-width: 0;',
6882
+ ' box-sizing: border-box;',
6883
+ ' overflow: hidden;',
6884
+ ' text-overflow: ellipsis;',
6885
+ ' display: -webkit-box;',
6886
+ ' -webkit-line-clamp: 2;',
6887
+ ' -webkit-box-orient: vertical;',
6888
+ ]),
6343
6889
 
6344
6890
  // ── Progress text (Figma 346:253) ──
6345
6891
  '.cl-thought-chain-content.cl-content-collapsed {',
@@ -6384,26 +6930,72 @@ function _clScan() {
6384
6930
  ' border: 1.2px solid rgba(47,47,51,0.1) !important;',
6385
6931
  ' border-radius: 24px !important;',
6386
6932
  ' padding: 10px 15px !important;',
6387
- ' gap: 10px !important;',
6933
+ ' width: 100% !important;',
6934
+ ' max-width: 100% !important;',
6935
+ ' min-width: 0 !important;',
6936
+ ' box-sizing: border-box !important;',
6937
+ ' overflow: hidden;',
6388
6938
  '}',
6939
+ _clRule(hostCss.modernCardLayout ? ['.cl-output-card'] : [], [
6940
+ ' gap: 10px !important;',
6941
+ ]),
6942
+ _clRule(!hostCss.modernCardLayout ? ['.cl-output-card'] : [], [
6943
+ ' border-radius: 14px !important;',
6944
+ ]),
6945
+ _clRule(!hostCss.modernCardLayout ? ['.cl-remote-agent-card.cl-thought-chain.cl-output-card'] : [], [
6946
+ ' padding: 0 !important;',
6947
+ ]),
6389
6948
  '.cl-output-card > .cl-thought-chain-content {',
6390
6949
  ' background: #fff;',
6391
6950
  ' border: 1px solid #f4f4f4;',
6392
6951
  ' border-radius: 12px;',
6393
6952
  ' padding: 20px 30px;',
6394
6953
  ' overflow: hidden;',
6954
+ ' width: 100%;',
6395
6955
  ' max-width: 100%;',
6956
+ ' min-width: 0;',
6957
+ ' box-sizing: border-box;',
6958
+ '}',
6959
+ _clRule(!hostCss.modernCardLayout ? ['.cl-output-card > .cl-thought-chain-content'] : [], [
6960
+ ' margin: 10px 15px;',
6961
+ ' width: calc(100% - 30px);',
6962
+ ]),
6963
+ '.cl-output-card .cl-output-result {',
6964
+ ' width: 100%;',
6965
+ ' max-width: 100%;',
6966
+ ' min-width: 0;',
6396
6967
  ' box-sizing: border-box;',
6968
+ ' overflow-wrap: anywhere;',
6969
+ ' word-break: break-word;',
6397
6970
  '}',
6398
6971
  '.cl-output-card > .cl-thought-chain-content * {',
6399
6972
  ' max-width: 100%;',
6973
+ ' min-width: 0;',
6400
6974
  ' box-sizing: border-box;',
6401
6975
  '}',
6976
+ '.cl-output-card > .cl-thought-chain-content p,',
6977
+ '.cl-output-card > .cl-thought-chain-content li,',
6978
+ '.cl-output-card > .cl-thought-chain-content a {',
6979
+ ' overflow-wrap: anywhere;',
6980
+ ' word-break: break-word;',
6981
+ '}',
6982
+ '.cl-output-card > .cl-thought-chain-content hr {',
6983
+ ' border: 0;',
6984
+ ' border-top: 1px solid #bdbdbd;',
6985
+ '}',
6402
6986
  '.cl-output-card > .cl-thought-chain-content pre,',
6403
6987
  '.cl-output-card > .cl-thought-chain-content code {',
6404
6988
  ' overflow-x: auto;',
6405
6989
  ' white-space: pre-wrap;',
6406
6990
  ' word-break: break-all;',
6991
+ ' scrollbar-width: none;',
6992
+ ' -ms-overflow-style: none;',
6993
+ '}',
6994
+ '.cl-output-card > .cl-thought-chain-content pre::-webkit-scrollbar,',
6995
+ '.cl-output-card > .cl-thought-chain-content code::-webkit-scrollbar {',
6996
+ ' width: 0;',
6997
+ ' height: 0;',
6998
+ ' display: none;',
6407
6999
  '}',
6408
7000
  // V2 output card:统一 border/padding 与 execution card 一致
6409
7001
  '.cl-exec-v2.cl-output-card {',
@@ -6432,6 +7024,10 @@ function _clScan() {
6432
7024
  ' font-size: 14px;',
6433
7025
  ' color: #999;',
6434
7026
  '}',
7027
+ _clRule(!hostCss.modernCardLayout ? ['.cl-output-footer'] : [], [
7028
+ ' padding: 10px 15px;',
7029
+ ' line-height: 22px;',
7030
+ ]),
6435
7031
  '.cl-output-footer-text {',
6436
7032
  ' white-space: nowrap;',
6437
7033
  '}',
@@ -6452,6 +7048,9 @@ function _clScan() {
6452
7048
  ' border-radius: 14px !important;',
6453
7049
  ' padding: 16px 20px !important;',
6454
7050
  ' box-sizing: border-box !important;',
7051
+ ' min-width: 0 !important;',
7052
+ ' max-width: 100% !important;',
7053
+ ' overflow-x: hidden !important;',
6455
7054
  ' display: flex !important;',
6456
7055
  ' flex-direction: column !important;',
6457
7056
  ' gap: 16px !important;',
@@ -6461,6 +7060,10 @@ function _clScan() {
6461
7060
  ' flex-direction: column !important;',
6462
7061
  ' gap: 16px !important;',
6463
7062
  ' width: 100% !important;',
7063
+ ' min-width: 0 !important;',
7064
+ ' max-width: 100% !important;',
7065
+ ' overflow-x: hidden !important;',
7066
+ ' box-sizing: border-box !important;',
6464
7067
  ' background: transparent !important;',
6465
7068
  '}',
6466
7069
  '.chat-sidebar .sidebar-header {',
@@ -6496,7 +7099,12 @@ function _clScan() {
6496
7099
  ' line-height: 1.8 !important;',
6497
7100
  ' color: #333 !important;',
6498
7101
  ' width: 100% !important;',
7102
+ ' min-width: 0 !important;',
7103
+ ' max-width: 100% !important;',
6499
7104
  ' padding: 0 !important;',
7105
+ ' overflow-x: hidden !important;',
7106
+ ' box-sizing: border-box !important;',
7107
+ ' overflow-wrap: anywhere !important;',
6500
7108
  '}',
6501
7109
  '.chat-sidebar .sidebar-markdown {',
6502
7110
  ' font-family: "PingFang SC", sans-serif !important;',
@@ -6507,6 +7115,21 @@ function _clScan() {
6507
7115
  ' background: transparent !important;',
6508
7116
  ' border: none !important;',
6509
7117
  ' padding: 0 !important;',
7118
+ ' min-width: 0 !important;',
7119
+ ' max-width: 100% !important;',
7120
+ ' overflow-x: hidden !important;',
7121
+ ' box-sizing: border-box !important;',
7122
+ ' overflow-wrap: anywhere !important;',
7123
+ '}',
7124
+ '.chat-sidebar .sidebar-markdown * {',
7125
+ ' max-width: 100% !important;',
7126
+ ' min-width: 0 !important;',
7127
+ ' box-sizing: border-box !important;',
7128
+ '}',
7129
+ '.chat-sidebar .sidebar-markdown pre,',
7130
+ '.chat-sidebar .sidebar-markdown code {',
7131
+ ' white-space: pre-wrap !important;',
7132
+ ' word-break: break-word !important;',
6510
7133
  '}',
6511
7134
  // 隐藏宿主 sidebar 自带的 "Rendered Markdown / View Raw Text" 工具栏
6512
7135
  '.chat-sidebar .sidebar-markdown-shell__toolbar {',
@@ -6520,6 +7143,8 @@ function _clScan() {
6520
7143
  // ── V2 容器 ──
6521
7144
  '.cl-exec-v2 {',
6522
7145
  ' position: relative;',
7146
+ ' gap: 10px;',
7147
+ ' padding: 0;',
6523
7148
  '}',
6524
7149
 
6525
7150
  // ── V2 Header(Figma 371:6987 — 红晕渐变背景 + 独立边框)──
@@ -6532,6 +7157,7 @@ function _clScan() {
6532
7157
  ' border-radius: 10px 10px 0 0;',
6533
7158
  ' height: auto !important;',
6534
7159
  ' min-height: auto !important;',
7160
+ ' gap: 6px;',
6535
7161
  ' box-sizing: border-box;',
6536
7162
  '}',
6537
7163
  '.cl-exec-v2 .cl-openagent-header-v2:hover {',
@@ -6569,6 +7195,7 @@ function _clScan() {
6569
7195
  ' border-radius: 12px !important;',
6570
7196
  ' background: #f7f7f8 !important;',
6571
7197
  ' margin: 12px 14px 14px 14px !important;',
7198
+ ' margin-top: 0 !important;',
6572
7199
  ' margin-left: 0 !important;',
6573
7200
  ' position: relative;',
6574
7201
  ' overflow: hidden;',
@@ -6596,7 +7223,6 @@ function _clScan() {
6596
7223
 
6597
7224
  '.cl-exec-v2 .cl-exec-detail-row-v2 {',
6598
7225
  ' display: flex;',
6599
- ' align-items: flex-start;',
6600
7226
  ' gap: 16px;',
6601
7227
  '}',
6602
7228
 
@@ -6608,12 +7234,11 @@ function _clScan() {
6608
7234
  ' min-width: 0;',
6609
7235
  '}',
6610
7236
 
6611
- // ── V2 大头像 80×80 ──
7237
+ // ── V2 大头像 68×68 ──
6612
7238
  '.cl-exec-v2 .cl-exec-agent-avatar-v2 {',
6613
- ' width: 80px !important;',
6614
- ' height: 80px !important;',
6615
- ' border-radius: 16px !important;',
6616
- ' object-fit: cover;',
7239
+ ' width: 68px !important;',
7240
+ ' height: 68px !important;',
7241
+ ' object-fit: contain;',
6617
7242
  ' flex-shrink: 0;',
6618
7243
  '}',
6619
7244
 
@@ -6746,12 +7371,33 @@ function _clScan() {
6746
7371
  ' font-weight: 500;',
6747
7372
  ' white-space: nowrap;',
6748
7373
  '}',
7374
+
7375
+ // ── chat-text 下 p 标签样式 ──
7376
+ '.cl-remote-agent-card .chat-text p {',
7377
+ ' color: #2F2F33 !important;',
7378
+ ' text-align: justify;',
7379
+ ' font-family: "PingFang SC" !important;',
7380
+ ' font-size: 14px !important;',
7381
+ ' font-style: normal !important;',
7382
+ ' font-weight: 400 !important;',
7383
+ ' line-height: 132% !important;',
7384
+ '}',
7385
+
7386
+ // ── chat-text 下 code 标签样式(去背景、去边框、加粗)──
7387
+ '.chat-text code,',
7388
+ '.cl-remote-agent-card .chat-text code,',
7389
+ '.cl-remote-agent-card .chat-text p code {',
7390
+ ' background: transparent !important;',
7391
+ ' border: none !important;',
7392
+ ' font-weight: 700 !important;',
7393
+ '}',
6749
7394
  ].join('\n');
6750
7395
  document.head.appendChild(style);
6751
7396
  // ── 局部 host-shell 标记(不做全局扫描)──
6752
7397
  // 只处理当前 cardNode 的祖先链路,不 querySelectorAll 全局
6753
7398
  window._clMarkRemoteAgentHostShell = function _clMarkRemoteAgentHostShell(cardNode) {
6754
7399
  try {
7400
+ var hostAdapter = CL.hostAdapter || {};
6755
7401
  var node = cardNode && cardNode.parentElement;
6756
7402
  var hops = 0;
6757
7403
  while (node && node !== document.body && hops < 10) {
@@ -6764,17 +7410,8 @@ function _clScan() {
6764
7410
 
6765
7411
  var shouldMark = false;
6766
7412
  var tag = (node.tagName || '').toLowerCase();
6767
- if (tag === 'details') {
6768
- shouldMark = node.matches && node.matches(
6769
- 'details.chat-tools-collapse, details.chat-tool-msg-collapse'
6770
- );
6771
- } else if (node.matches) {
6772
- shouldMark = node.matches(
6773
- '.chat-tool-card,' +
6774
- '.chat-tool-card__detail,' +
6775
- '.chat-tools-collapse__body,' +
6776
- '.chat-tool-msg-body'
6777
- );
7413
+ if (typeof hostAdapter.isMarkableHost === 'function') {
7414
+ shouldMark = hostAdapter.isMarkableHost(node);
6778
7415
  }
6779
7416
 
6780
7417
  if (shouldMark && node.classList) {
@@ -7367,6 +8004,73 @@ function _clInferToolCardKind(card) {
7367
8004
  return 'call';
7368
8005
  }
7369
8006
 
8007
+ function _clPickAgentDescription(source) {
8008
+ if (!source) return '';
8009
+ var keys = [
8010
+ 'agent_bio',
8011
+ 'agentBio',
8012
+ 'bio',
8013
+ 'description',
8014
+ 'desc',
8015
+ 'agent_description',
8016
+ 'agentDescription',
8017
+ 'MOM',
8018
+ 'mom',
8019
+ 'introduction',
8020
+ 'summary'
8021
+ ];
8022
+ for (var i = 0; i < keys.length; i++) {
8023
+ var value = source[keys[i]];
8024
+ if (typeof value === 'string' && value.trim()) return value.trim();
8025
+ }
8026
+ return '';
8027
+ }
8028
+
8029
+ function _clIsFailureStatusValue(value) {
8030
+ var normalized = String(value || '').trim().toLowerCase();
8031
+ return normalized === 'failed'
8032
+ || normalized === 'failure'
8033
+ || normalized === 'error'
8034
+ || normalized === 'errored'
8035
+ || normalized === 'rejected'
8036
+ || normalized === 'cancelled'
8037
+ || normalized === 'canceled';
8038
+ }
8039
+
8040
+ function _clLooksLikeRemoteFailureText(text) {
8041
+ var value = String(text || '').trim();
8042
+ if (!value || value.length > 300) return false;
8043
+ return /(^|[,。;\s])(调用失败|执行失败|任务失败|远端服务目前连不上|远端服务.*不可用|两次都返回了调用失败)([,。;\s]|$)/.test(value);
8044
+ }
8045
+
8046
+ function _clInferToolCardError(card, chunks, rawText) {
8047
+ if (chunks && chunks.some(function(c) { return c && c.type === 'error'; })) return true;
8048
+ if (!card) return _clLooksLikeRemoteFailureText(rawText);
8049
+ if (card.isError === true || card.error === true) return true;
8050
+ if (_clIsFailureStatusValue(card.status)
8051
+ || _clIsFailureStatusValue(card.state)
8052
+ || _clIsFailureStatusValue(card.resultStatus)) {
8053
+ return true;
8054
+ }
8055
+ if (card.error && typeof card.error === 'object') return true;
8056
+ return _clLooksLikeRemoteFailureText(rawText);
8057
+ }
8058
+
8059
+ function _clApplyAgentIdentityToModel(model) {
8060
+ if (!model || typeof CL === 'undefined' || !CL || typeof CL.getAgentIdentity !== 'function') return model;
8061
+ var identity = CL.getAgentIdentity(model.agentId, model.agentName);
8062
+ if (!identity) return model;
8063
+ model.agentId = model.agentId || identity.id || identity.agent_id;
8064
+ if (!model.agentName || model.agentName === 'Remote Agent') {
8065
+ model.agentName = identity.name || model.agentName;
8066
+ }
8067
+ model.agentAvatar = model.agentAvatar || identity.avatar || identity.avatar_url || identity.avatarUrl || null;
8068
+ if (!model.agentBio) {
8069
+ model.agentBio = _clPickAgentDescription(identity);
8070
+ }
8071
+ return model;
8072
+ }
8073
+
7370
8074
  function _clParseToolCardModel(card) {
7371
8075
  var inferredKind = _clInferToolCardKind(card);
7372
8076
 
@@ -7375,7 +8079,7 @@ function _clParseToolCardModel(card) {
7375
8079
  var agentId = args.agent_id || args.agentId || null;
7376
8080
  var agentName = args.agent_name || args.agentName || agentId || 'Remote Agent';
7377
8081
  var agentAvatar = args.agent_avatar || args.agentAvatar || args.avatar || args.avatar_url || args.avatarUrl || null;
7378
- var agentBio = args.agent_bio || args.agentBio || args.description || args.agent_description || args.MOM || '';
8082
+ var agentBio = _clPickAgentDescription(args);
7379
8083
  var agentStars = args.agent_stars || args.agentStars || args.stars || args.claws || '3.2万';
7380
8084
  var taskText = args.task || args.message || args.instruction || '';
7381
8085
 
@@ -7386,7 +8090,7 @@ function _clParseToolCardModel(card) {
7386
8090
  rawText: rawText
7387
8091
  });
7388
8092
  var hasOutput = inferredKind === 'result' && rawText.trim().length > 0;
7389
- var isError = chunks.some(function(c) { return c.type === 'error'; });
8093
+ var isError = _clInferToolCardError(card, chunks, rawText);
7390
8094
 
7391
8095
  var model = {
7392
8096
  agentId: agentId,
@@ -7396,7 +8100,7 @@ function _clParseToolCardModel(card) {
7396
8100
  agentStars: agentStars,
7397
8101
  taskText: taskText,
7398
8102
  toolCallId: card.toolCallId || '',
7399
- status: hasOutput ? 'completed' : 'executing',
8103
+ status: isError ? 'failed' : (hasOutput ? 'completed' : 'executing'),
7400
8104
  rawText: rawText,
7401
8105
  text: rawText,
7402
8106
  outputText: rawText,
@@ -7404,8 +8108,9 @@ function _clParseToolCardModel(card) {
7404
8108
  isError: isError,
7405
8109
  inferredKind: inferredKind,
7406
8110
  };
8111
+ _clApplyAgentIdentityToModel(model);
7407
8112
 
7408
- console.log('[cl-model] parsed:', 'agent=' + agentName,
8113
+ console.log('[cl-model] parsed:', 'agent=' + model.agentName,
7409
8114
  'status=' + model.status,
7410
8115
  'chunks=' + chunks.length,
7411
8116
  'error=' + isError);
@@ -7477,9 +8182,10 @@ function _clRenderExecutionCard(model) {
7477
8182
  var avatarEl = container.querySelector('.cl-exec-agent-avatar');
7478
8183
  var nameEl = container.querySelector('.cl-exec-agent-name');
7479
8184
  var bioEl = container.querySelector('.cl-exec-agent-bio');
8185
+ var agentBio = _clGetAgentDescriptionText(agent);
7480
8186
  // avatar 保持 icon.png,不覆盖
7481
8187
  if (nameEl) nameEl.textContent = agent.name || model.agentName;
7482
- if (bioEl && (agent.bio || agent.description)) bioEl.textContent = agent.bio || agent.description;
8188
+ if (bioEl && agentBio) bioEl.textContent = agentBio;
7483
8189
  var starsEl = container.querySelector('.cl-exec-star-count');
7484
8190
  if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
7485
8191
  if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
@@ -7495,6 +8201,42 @@ function _clRenderExecutionCard(model) {
7495
8201
  return container;
7496
8202
  }
7497
8203
 
8204
+ function _clGetAgentDescriptionText(model) {
8205
+ if (typeof _clPickAgentDescription === 'function') {
8206
+ var direct = _clPickAgentDescription(model || {});
8207
+ if (direct) return direct;
8208
+ if (model && typeof CL !== 'undefined' && CL && typeof CL.getAgentIdentity === 'function') {
8209
+ var identity = CL.getAgentIdentity(
8210
+ model.agentId || model.agent_id || model.id || model.tag,
8211
+ model.agentName || model.agent_name || model.name
8212
+ );
8213
+ var identityBio = _clPickAgentDescription(identity || {});
8214
+ if (identityBio) return identityBio;
8215
+ }
8216
+ return '';
8217
+ }
8218
+ if (!model) return '';
8219
+ return model.agentBio || model.bio || model.description || model.desc || model.agentDescription || model.agent_description || model.MOM || '';
8220
+ }
8221
+
8222
+ function _clSyncOutputFooterVisibility(card, isCollapsed) {
8223
+ if (!card || !card.querySelector || !card.querySelector('.cl-openagent-header--output')) return;
8224
+ var footers = card.querySelectorAll('.cl-output-footer');
8225
+ for (var i = 0; i < footers.length; i++) {
8226
+ footers[i].style.display = isCollapsed ? 'none' : '';
8227
+ }
8228
+ }
8229
+
8230
+ function _clGetAgentStatusText(status) {
8231
+ if (status === 'completed') return '执行已完成';
8232
+ if (status === 'failed' || status === 'error') return '执行失败';
8233
+ return '正在执行任务';
8234
+ }
8235
+
8236
+ function _clIsAgentTerminalStatus(status) {
8237
+ return status === 'completed' || status === 'failed' || status === 'error';
8238
+ }
8239
+
7498
8240
  // ── Agent 详情卡片(Figma 266:11136) ──
7499
8241
  function _clCreateAgentDetailCard(model) {
7500
8242
  var card = document.createElement('div');
@@ -7527,7 +8269,7 @@ function _clCreateAgentDetailCard(model) {
7527
8269
  // 星级徽章
7528
8270
  var starBadge = document.createElement('div');
7529
8271
  starBadge.className = 'cl-exec-star-badge';
7530
- var starSvgOutline = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M7 1.16L8.356 5.33H12.78L9.195 7.94L10.565 12.1L7 9.51L3.435 12.1L4.805 7.94L1.22 5.33H5.644L7 1.16Z" stroke="#999" stroke-width="0.8"/></svg>';
8272
+ var starSvgOutline = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M6.46401 1.8327C6.66621 1.36177 7.33396 1.36174 7.53612 1.8327L8.82412 4.83481L12.0718 5.1373C12.5808 5.18469 12.7873 5.8177 12.4039 6.15586L9.95148 8.31772L10.6687 11.5101C10.7809 12.0098 10.2404 12.4012 9.80052 12.139L7.00006 10.4699L4.19904 12.139C3.75913 12.4012 3.21924 12.0098 3.33145 11.5101L4.04808 8.31772L1.59626 6.15586C1.21282 5.81777 1.4189 5.18488 1.9278 5.1373L5.17601 4.83481L6.46401 1.8327ZM5.89435 5.8226L3.10073 6.08237L5.20905 7.94118L4.59325 10.6818L7.00006 9.24798L9.40575 10.6818L8.79108 7.94118L10.8983 6.08237L8.10521 5.8226L6.9995 3.24603L5.89435 5.8226Z" fill="#555555"/></svg>';
7531
8273
  starBadge.innerHTML = starSvgOutline +
7532
8274
  '<span class="cl-exec-star-count">' + (model.agentStars || '3.2万') + '</span>';
7533
8275
  nameRow.appendChild(starBadge);
@@ -7535,7 +8277,7 @@ function _clCreateAgentDetailCard(model) {
7535
8277
 
7536
8278
  var bioEl = document.createElement('p');
7537
8279
  bioEl.className = 'cl-exec-agent-bio';
7538
- bioEl.textContent = model.agentBio || '智能行程规划·定制每日行程·优化路线安排';
8280
+ bioEl.textContent = _clGetAgentDescriptionText(model);
7539
8281
  info.appendChild(bioEl);
7540
8282
 
7541
8283
  row.appendChild(info);
@@ -7564,8 +8306,6 @@ function _clCreateOpenAgentHeader(model) {
7564
8306
  // OASN 小图标
7565
8307
  var oasnBadge = document.createElement('span');
7566
8308
  oasnBadge.className = 'cl-openagent-badge';
7567
- oasnBadge.style.backgroundImage = "url(./icon.png)";
7568
- oasnBadge.style.backgroundSize = 'cover';
7569
8309
  header.appendChild(oasnBadge);
7570
8310
 
7571
8311
  // 文字行
@@ -7584,7 +8324,7 @@ function _clCreateOpenAgentHeader(model) {
7584
8324
 
7585
8325
  var labelStatus = document.createElement('span');
7586
8326
  labelStatus.className = 'cl-openagent-status';
7587
- labelStatus.textContent = (model.status === 'completed') ? '执行已完成' : '正在执行任务';
8327
+ labelStatus.textContent = _clGetAgentStatusText(model.status);
7588
8328
  textRow.appendChild(labelStatus);
7589
8329
 
7590
8330
  header.appendChild(textRow);
@@ -7597,6 +8337,7 @@ function _clCreateOpenAgentHeader(model) {
7597
8337
  var content = card.querySelector('.cl-thought-chain-content');
7598
8338
  if (!content) return;
7599
8339
  var isCollapsed = content.classList.toggle('cl-content-collapsed');
8340
+ _clSyncOutputFooterVisibility(card, isCollapsed);
7600
8341
  // 切换图标
7601
8342
  expandIcon.innerHTML = isCollapsed
7602
8343
  ? '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none"><path d="M9.75 6.79978C10.0833 6.99223 10.0833 7.47336 9.75 7.66581L6.75 9.39786C6.41667 9.59031 6 9.34975 6 8.96485L6 5.50075C6 5.11585 6.41667 4.87528 6.75 5.06773L9.75 6.79978Z" fill="#666666"/></svg>'
@@ -7696,9 +8437,9 @@ function _clCreateStepElement(step, isLatest) {
7696
8437
  // ── 动态更新 header 状态文字 ──
7697
8438
  function _clUpdateAgentStatusText(cardNode, status) {
7698
8439
  var label = cardNode && cardNode.querySelector('.cl-openagent-status');
7699
- if (label) label.textContent = (status === 'completed') ? '执行已完成' : '正在执行任务';
8440
+ if (label) label.textContent = _clGetAgentStatusText(status);
7700
8441
  var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row');
7701
- if (progressRow) progressRow.style.display = (status === 'completed') ? 'none' : '';
8442
+ if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7702
8443
  }
7703
8444
 
7704
8445
  function _cl_formatStarCount(count) {
@@ -7780,8 +8521,9 @@ function _clRenderExecutionCardV2(model) {
7780
8521
  var avatarEl = container.querySelector('.cl-exec-agent-avatar-v2');
7781
8522
  var nameEl = container.querySelector('.cl-exec-agent-name-v2');
7782
8523
  var bioEl = container.querySelector('.cl-exec-agent-bio-v2');
8524
+ var agentBio = _clGetAgentDescriptionText(agent);
7783
8525
  if (nameEl) nameEl.textContent = agent.name || model.agentName;
7784
- if (bioEl && (agent.bio || agent.description)) bioEl.textContent = agent.bio || agent.description;
8526
+ if (bioEl && agentBio) bioEl.textContent = agentBio;
7785
8527
  var starsEl = container.querySelector('.cl-exec-star-count-v2');
7786
8528
  if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
7787
8529
  if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
@@ -7826,7 +8568,7 @@ function _clCreateOpenAgentHeaderV2(model) {
7826
8568
 
7827
8569
  var labelStatus = document.createElement('span');
7828
8570
  labelStatus.className = 'cl-openagent-status';
7829
- labelStatus.textContent = (model.status === 'completed') ? '执行已完成' : '正在执行任务';
8571
+ labelStatus.textContent = _clGetAgentStatusText(model.status);
7830
8572
  textRow.appendChild(labelStatus);
7831
8573
 
7832
8574
  header.appendChild(textRow);
@@ -7839,6 +8581,7 @@ function _clCreateOpenAgentHeaderV2(model) {
7839
8581
  var content = card.querySelector('.cl-thought-chain-content');
7840
8582
  if (!content) return;
7841
8583
  var isCollapsed = content.classList.toggle('cl-content-collapsed');
8584
+ _clSyncOutputFooterVisibility(card, isCollapsed);
7842
8585
  expandIcon.innerHTML = isCollapsed
7843
8586
  ? '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none"><path d="M9.75 6.79978C10.0833 6.99223 10.0833 7.47336 9.75 7.66581L6.75 9.39786C6.41667 9.59031 6 9.34975 6 8.96485L6 5.50075C6 5.11585 6.41667 4.87528 6.75 5.06773L9.75 6.79978Z" fill="#666666"/></svg>'
7844
8587
  : expandedSvg;
@@ -7879,7 +8622,7 @@ function _clCreateAgentDetailCardV2(model) {
7879
8622
  // 描述文字
7880
8623
  var bioEl = document.createElement('p');
7881
8624
  bioEl.className = 'cl-exec-agent-bio cl-exec-agent-bio-v2';
7882
- bioEl.textContent = model.agentBio || '智能行程规划·定制每日行程·优化路线安排';
8625
+ bioEl.textContent = _clGetAgentDescriptionText(model);
7883
8626
  info.appendChild(bioEl);
7884
8627
 
7885
8628
  row.appendChild(info);
@@ -7888,7 +8631,7 @@ function _clCreateAgentDetailCardV2(model) {
7888
8631
  // 星级徽章右置到卡片右上角
7889
8632
  var starBadge = document.createElement('div');
7890
8633
  starBadge.className = 'cl-exec-star-badge cl-exec-star-badge-v2';
7891
- var starSvgOutline = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M7 1.16L8.356 5.33H12.78L9.195 7.94L10.565 12.1L7 9.51L3.435 12.1L4.805 7.94L1.22 5.33H5.644L7 1.16Z" stroke="#999" stroke-width="0.8"/></svg>';
8634
+ var starSvgOutline = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M6.46401 1.8327C6.66621 1.36177 7.33396 1.36174 7.53612 1.8327L8.82412 4.83481L12.0718 5.1373C12.5808 5.18469 12.7873 5.8177 12.4039 6.15586L9.95148 8.31772L10.6687 11.5101C10.7809 12.0098 10.2404 12.4012 9.80052 12.139L7.00006 10.4699L4.19904 12.139C3.75913 12.4012 3.21924 12.0098 3.33145 11.5101L4.04808 8.31772L1.59626 6.15586C1.21282 5.81777 1.4189 5.18488 1.9278 5.1373L5.17601 4.83481L6.46401 1.8327ZM5.89435 5.8226L3.10073 6.08237L5.20905 7.94118L4.59325 10.6818L7.00006 9.24798L9.40575 10.6818L8.79108 7.94118L10.8983 6.08237L8.10521 5.8226L6.9995 3.24603L5.89435 5.8226Z" fill="#555555"/></svg>';
7892
8635
  starBadge.innerHTML = starSvgOutline +
7893
8636
  '<span class="cl-exec-star-count cl-exec-star-count-v2">' + (model.agentStars || '3.2万') + '</span>';
7894
8637
  card.appendChild(starBadge);
@@ -7899,15 +8642,15 @@ function _clCreateAgentDetailCardV2(model) {
7899
8642
  // ── V2 状态文字更新 ──
7900
8643
  function _clUpdateAgentStatusTextV2(cardNode, status) {
7901
8644
  var label = cardNode && cardNode.querySelector('.cl-openagent-status');
7902
- if (label) label.textContent = (status === 'completed') ? '执行已完成' : '正在执行任务';
8645
+ if (label) label.textContent = _clGetAgentStatusText(status);
7903
8646
  // 进度文字行:完成后隐藏
7904
8647
  var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row-v2');
7905
- if (progressRow) progressRow.style.display = (status === 'completed') ? 'none' : '';
8648
+ if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7906
8649
  // 步骤列表:完成后隐藏
7907
8650
  var stepsBody = cardNode && cardNode.querySelector('.cl-tools-collapse-body-v2');
7908
- if (stepsBody) stepsBody.style.display = (status === 'completed') ? 'none' : '';
8651
+ if (stepsBody) stepsBody.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7909
8652
  var stepsHeader = cardNode && cardNode.querySelector('.cl-tools-collapse-header-v2');
7910
- if (stepsHeader) stepsHeader.style.display = (status === 'completed') ? 'none' : '';
8653
+ if (stepsHeader) stepsHeader.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7911
8654
  }
7912
8655
 
7913
8656
  // ════════════════════════════════════════════════════════════════
@@ -8364,6 +9107,9 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8364
9107
  ? _clStripOpenagentMediaLines(chunk.text)
8365
9108
  : chunk.text;
8366
9109
  if (_clShouldRenderOutputText(textChunk)) resultTexts.push(textChunk);
9110
+ } else if (chunk.type === 'error') {
9111
+ var errorText = chunk.text || model.rawText || '远端 Agent 调用失败';
9112
+ if (_clShouldRenderOutputText(errorText)) resultTexts.push(errorText);
8367
9113
  }
8368
9114
  }
8369
9115
 
@@ -8408,13 +9154,13 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8408
9154
  }
8409
9155
 
8410
9156
  model._outputMode = true;
8411
- model.status = 'completed';
9157
+ model.status = model.isError ? 'failed' : 'completed';
8412
9158
  if (isV2) {
8413
9159
  var v2Header = _clCreateOpenAgentHeaderV2(model);
8414
9160
  v2Header.classList.remove('cl-openagent-header--output');
8415
9161
  container.appendChild(v2Header);
8416
9162
  if (typeof _clUpdateAgentStatusTextV2 === 'function') {
8417
- _clUpdateAgentStatusTextV2(container, 'completed');
9163
+ _clUpdateAgentStatusTextV2(container, model.status);
8418
9164
  }
8419
9165
  } else {
8420
9166
  var shellHeader = _clCreateOpenAgentHeader(model);
@@ -8509,8 +9255,11 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8509
9255
  var avatarElV2 = container.querySelector('.cl-exec-agent-avatar-v2');
8510
9256
  var nameElV2 = container.querySelector('.cl-exec-agent-name-v2');
8511
9257
  var bioElV2 = container.querySelector('.cl-exec-agent-bio-v2');
9258
+ var agentBioV2 = typeof _clGetAgentDescriptionText === 'function'
9259
+ ? _clGetAgentDescriptionText(agent)
9260
+ : (agent.bio || agent.description || '');
8512
9261
  if (nameElV2) nameElV2.textContent = agent.name || model.agentName;
8513
- if (bioElV2 && (agent.bio || agent.description)) bioElV2.textContent = agent.bio || agent.description;
9262
+ if (bioElV2 && agentBioV2) bioElV2.textContent = agentBioV2;
8514
9263
  var starsElV2 = container.querySelector('.cl-exec-star-count-v2');
8515
9264
  if (starsElV2 && agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.claws);
8516
9265
  if (starsElV2 && agent.stars && !agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.stars);
@@ -8520,10 +9269,6 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8520
9269
  }).catch(function() {});
8521
9270
  }
8522
9271
 
8523
- if (typeof _cl_applyCardUiState === 'function') {
8524
- _cl_applyCardUiState(container, model);
8525
- }
8526
-
8527
9272
  // ── Footer ──
8528
9273
  if (isV2) {
8529
9274
  var footerV2 = document.createElement('div');
@@ -8542,6 +9287,10 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8542
9287
  container.appendChild(footer);
8543
9288
  }
8544
9289
 
9290
+ if (typeof _cl_applyCardUiState === 'function') {
9291
+ _cl_applyCardUiState(container, model);
9292
+ }
9293
+
8545
9294
  console.log('[cl-output] ✅ output card built: results=' + resultTexts.length + ' v2=' + isV2);
8546
9295
  return container;
8547
9296
  }
@@ -9189,6 +9938,15 @@ window.__openagentRenderToolCard = function(card, onOpenSidebar) {
9189
9938
 
9190
9939
  model.toolCallId = resTcid;
9191
9940
  model.cardKind = 'result';
9941
+ if (model.isError) {
9942
+ var executionNodeForResult = (resState && resState.cardNode)
9943
+ || (resTcid ? __cl_executionCardCache.get(resTcid) : null);
9944
+ if (executionNodeForResult && executionNodeForResult.classList && executionNodeForResult.classList.contains('cl-exec-v2')) {
9945
+ if (typeof _clUpdateAgentStatusTextV2 === 'function') _clUpdateAgentStatusTextV2(executionNodeForResult, 'failed');
9946
+ } else if (executionNodeForResult && typeof _clUpdateAgentStatusText === 'function') {
9947
+ _clUpdateAgentStatusText(executionNodeForResult, 'failed');
9948
+ }
9949
+ }
9192
9950
 
9193
9951
  // 缓存:同一 toolCallId 的 output card 只创建一次,Lit 重复调用时复用
9194
9952
  var cachedOutput = resTcid ? __cl_outputCardCache.get(resTcid) : null;
@@ -9313,26 +10071,32 @@ function _cl_isRemoteRawTextContent(text) {
9313
10071
  return false;
9314
10072
  }
9315
10073
 
10074
+ function _cl_getHostAdapter() {
10075
+ return (typeof CL !== 'undefined' && CL.hostAdapter) ? CL.hostAdapter : {};
10076
+ }
10077
+
9316
10078
  function _cl_collectRawTextHosts(node) {
9317
10079
  var hosts = [];
10080
+ var adapter = _cl_getHostAdapter();
10081
+ var selectors = adapter.selectors && adapter.selectors.rawTextHostClosest;
9318
10082
  function add(host) {
9319
10083
  if (!host || hosts.indexOf(host) !== -1) return;
9320
10084
  hosts.push(host);
9321
10085
  }
9322
10086
  add(node.parentElement);
9323
- if (node.closest) {
9324
- add(node.closest('.chat-tools-collapse__body'));
9325
- add(node.closest('.chat-tool-msg-body'));
9326
- add(node.closest('.chat-tool-card__detail'));
9327
- add(node.closest('.chat-bubble'));
10087
+ if (node.closest && Array.isArray(selectors)) {
10088
+ for (var i = 0; i < selectors.length; i++) {
10089
+ add(node.closest(selectors[i]));
10090
+ }
9328
10091
  }
9329
10092
  return hosts;
9330
10093
  }
9331
10094
 
9332
10095
  function _cl_hideRawTextInHost(host) {
9333
10096
  if (!host || !host.querySelectorAll) return;
10097
+ var adapter = _cl_getHostAdapter();
9334
10098
  host.classList.add('cl-remote-agent-raw-hidden');
9335
- if (host.classList.contains('chat-tools-collapse__body') || host.classList.contains('chat-tool-msg-body')) {
10099
+ if (adapter.isToolBody && adapter.isToolBody(host)) {
9336
10100
  host.classList.add('cl-remote-agent-host-shell');
9337
10101
  }
9338
10102
  var texts = host.querySelectorAll(':scope > .chat-text');
@@ -9343,16 +10107,11 @@ function _cl_hideRawTextInHost(host) {
9343
10107
  }
9344
10108
 
9345
10109
  function _cl_findRemoteNativeToolShell(node) {
10110
+ var adapter = _cl_getHostAdapter();
9346
10111
  var cur = node && (node.nodeType === 1 ? node : node.parentElement);
9347
10112
  var hops = 0;
9348
10113
  while (cur && cur !== document.body && hops < 12) {
9349
- if (cur.matches && cur.matches(
9350
- 'details.chat-tools-collapse,' +
9351
- 'details.chat-tool-msg-collapse,' +
9352
- '.chat-tools-collapse,' +
9353
- '.chat-tool-msg-collapse,' +
9354
- '.chat-tool-card'
9355
- )) {
10114
+ if (adapter.isRemoteNativeToolShellCandidate && adapter.isRemoteNativeToolShellCandidate(cur)) {
9356
10115
  if (_cl_isRemoteNativeToolShell(cur)) return cur;
9357
10116
  }
9358
10117
  cur = cur.parentElement;
@@ -9363,14 +10122,12 @@ function _cl_findRemoteNativeToolShell(node) {
9363
10122
 
9364
10123
  function _cl_isRemoteNativeToolShell(shell) {
9365
10124
  if (!shell) return false;
10125
+ var adapter = _cl_getHostAdapter();
10126
+ var summarySelector = adapter.selectors && adapter.selectors.summary;
9366
10127
  var summaryText = '';
9367
- var summary = shell.querySelector && shell.querySelector(
9368
- ':scope > summary,' +
9369
- ':scope > .chat-tools-summary,' +
9370
- ':scope > .chat-tool-msg-summary,' +
9371
- '.chat-tools-summary,' +
9372
- '.chat-tool-msg-summary'
9373
- );
10128
+ var summary = shell.querySelector && summarySelector
10129
+ ? shell.querySelector(summarySelector)
10130
+ : null;
9374
10131
  if (summary) summaryText = summary.textContent || '';
9375
10132
  if (_cl_isRemoteToolNameText(summaryText)) return true;
9376
10133
 
@@ -9411,27 +10168,23 @@ function _cl_tryHideRemoteRawTextNode(node) {
9411
10168
 
9412
10169
  var shell = _cl_findRemoteNativeToolShell(node);
9413
10170
  if (shell && shell.querySelectorAll) {
9414
- var hosts = shell.querySelectorAll('.chat-tools-collapse__body, .chat-tool-msg-body, .chat-tool-card__detail, .chat-bubble');
9415
- for (var h = 0; h < hosts.length; h++) {
9416
- _cl_hideRawTextInHost(hosts[h]);
10171
+ var adapter = _cl_getHostAdapter();
10172
+ var hostSelector = adapter.selectors && adapter.selectors.rawTextHostsWithinShell;
10173
+ if (hostSelector) {
10174
+ var hosts = shell.querySelectorAll(hostSelector);
10175
+ for (var h = 0; h < hosts.length; h++) {
10176
+ _cl_hideRawTextInHost(hosts[h]);
10177
+ }
9417
10178
  }
9418
10179
  }
9419
10180
  }
9420
10181
 
9421
10182
  function _cl_findNearestToolLikeShell(node) {
10183
+ var adapter = _cl_getHostAdapter();
9422
10184
  var cur = node && (node.nodeType === 1 ? node : node.parentElement);
9423
10185
  var hops = 0;
9424
10186
  while (cur && cur !== document.body && hops < 12) {
9425
- if (cur.matches && cur.matches(
9426
- 'details.chat-tools-collapse,' +
9427
- 'details.chat-tool-msg-collapse,' +
9428
- '.chat-tools-collapse,' +
9429
- '.chat-tool-msg-collapse,' +
9430
- '.chat-tool-card,' +
9431
- '.chat-tools-collapse__body,' +
9432
- '.chat-tool-msg-body,' +
9433
- '.chat-tool-card__detail'
9434
- )) {
10187
+ if (adapter.isToolLikeShell && adapter.isToolLikeShell(cur)) {
9435
10188
  return cur;
9436
10189
  }
9437
10190
  cur = cur.parentElement;
@@ -9480,15 +10233,11 @@ _cl_installRemoteRawTextObserver();
9480
10233
  // ── 局部打开最近宿主 wrapper(不做全局扫描)──
9481
10234
 
9482
10235
  function _cl_findNearestNativeToolShell(node) {
10236
+ var adapter = _cl_getHostAdapter();
9483
10237
  var cur = node && node.parentElement;
9484
10238
  var hops = 0;
9485
10239
  while (cur && cur !== document.body && hops < 10) {
9486
- if (cur.matches && cur.matches(
9487
- 'details.chat-tools-collapse,' +
9488
- 'details.chat-tool-msg-collapse,' +
9489
- '.chat-tools-collapse,' +
9490
- '.chat-tool-msg-collapse'
9491
- )) {
10240
+ if (adapter.isNativeToolShell && adapter.isNativeToolShell(cur)) {
9492
10241
  return cur;
9493
10242
  }
9494
10243
  cur = cur.parentElement;
@@ -9516,7 +10265,9 @@ function _cl_forceOpenNativeToolDetails(node, source, tcid) {
9516
10265
 
9517
10266
  if (shell.classList && !shell.classList.contains('is-open')) {
9518
10267
  shell.classList.add('is-open');
9519
- var header = shell.querySelector('.chat-tool-msg-summary, .chat-tools-summary');
10268
+ var adapter = _cl_getHostAdapter();
10269
+ var headerSelector = (adapter.selectors && adapter.selectors.forceOpenHeader) || '';
10270
+ var header = headerSelector ? shell.querySelector(headerSelector) : null;
9520
10271
  if (header) header.setAttribute('aria-expanded', 'true');
9521
10272
  console.log('[cl-render] 🔓 opened native collapse source=' + source
9522
10273
  + ' tcid=' + String(tcid || '').substring(0, 8));
@@ -9592,6 +10343,9 @@ function _cl_applyCardUiState(container, modelOrNode) {
9592
10343
  content.classList.remove('cl-content-collapsed');
9593
10344
  if (caret) caret.textContent = '▼';
9594
10345
  }
10346
+ if (typeof _clSyncOutputFooterVisibility === 'function') {
10347
+ _clSyncOutputFooterVisibility(container, state.contentCollapsed);
10348
+ }
9595
10349
  }
9596
10350
 
9597
10351
  var body = container.querySelector('.cl-tools-collapse-body');
@@ -9622,7 +10376,9 @@ function _cl_applyStoredRecordToModel(model, record) {
9622
10376
  model.agentAvatar = args.agent_avatar || args.agentAvatar || args.avatar || args.avatar_url || args.avatarUrl || null;
9623
10377
  }
9624
10378
  if (!model.agentBio) {
9625
- model.agentBio = args.agent_bio || args.agentBio || '';
10379
+ model.agentBio = typeof _clPickAgentDescription === 'function'
10380
+ ? _clPickAgentDescription(args)
10381
+ : (args.agent_bio || args.agentBio || args.description || args.agent_description || args.MOM || '');
9626
10382
  }
9627
10383
  if (!model.agentStars) {
9628
10384
  model.agentStars = args.agent_stars || args.agentStars || '3.2万';
@@ -9634,6 +10390,11 @@ function _cl_applyStoredRecordToModel(model, record) {
9634
10390
  model.agentId = model.agentId || identity.id || identity.agent_id;
9635
10391
  model.agentName = (model.agentName && model.agentName !== 'Remote Agent') ? model.agentName : (identity.name || model.agentName);
9636
10392
  model.agentAvatar = model.agentAvatar || identity.avatar || null;
10393
+ if (!model.agentBio) {
10394
+ model.agentBio = typeof _clPickAgentDescription === 'function'
10395
+ ? _clPickAgentDescription(identity)
10396
+ : (identity.bio || identity.description || identity.agent_bio || identity.agentBio || identity.MOM || '');
10397
+ }
9637
10398
  }
9638
10399
  model.taskText = model.taskText || args.task || args.message || args.instruction || '';
9639
10400
  }
@@ -10393,9 +11154,104 @@ function _startClObserver() {
10393
11154
  _clObserverTarget = document.querySelector('openclaw-app') || document.body;
10394
11155
  _clObserver.observe(_clObserverTarget, { childList: true, subtree: true });
10395
11156
  setTimeout(_debouncedClScan, 2000);
11157
+ setTimeout(_clCheckPluginUpdateStatus, 5000);
10396
11158
  /* muted */ void 0;
10397
11159
  }
10398
11160
 
11161
+ function _clCheckPluginUpdateStatus() {
11162
+ fetch('/plugins/openagent/update-status', { cache: 'no-store' })
11163
+ .then(function(res) {
11164
+ if (!res.ok) return null;
11165
+ return res.json();
11166
+ })
11167
+ .then(function(status) {
11168
+ if (!status || !status.updateAvailable) return;
11169
+ _clShowPluginUpdateNotice(status);
11170
+ })
11171
+ .catch(function() {});
11172
+ }
11173
+
11174
+ function _clShowPluginUpdateNotice(status) {
11175
+ var latestVersion = String(status.latestVersion || '').trim();
11176
+ var currentVersion = String(status.currentVersion || '').trim();
11177
+ var dismissKey = 'openagent-update-dismissed-' + latestVersion;
11178
+ try {
11179
+ if (latestVersion && localStorage.getItem(dismissKey) === '1') return;
11180
+ } catch (e) {}
11181
+
11182
+ var existing = document.getElementById('openagent-update-notice');
11183
+ if (existing) existing.remove();
11184
+
11185
+ var notice = document.createElement('div');
11186
+ notice.id = 'openagent-update-notice';
11187
+ notice.style.cssText = [
11188
+ 'position:fixed',
11189
+ 'right:18px',
11190
+ 'bottom:18px',
11191
+ 'z-index:2147483647',
11192
+ 'max-width:360px',
11193
+ 'padding:14px 16px',
11194
+ 'border:1px solid rgba(0,0,0,0.08)',
11195
+ 'border-radius:12px',
11196
+ 'background:#fff',
11197
+ 'box-shadow:0 12px 32px rgba(15,23,42,0.16)',
11198
+ 'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif',
11199
+ 'color:#1f2937',
11200
+ 'font-size:13px',
11201
+ 'line-height:1.5'
11202
+ ].join(';');
11203
+
11204
+ var title = document.createElement('div');
11205
+ title.textContent = 'OpenAgent 有新版本 ' + latestVersion;
11206
+ title.style.cssText = 'font-weight:600;font-size:14px;margin-right:22px;margin-bottom:4px;';
11207
+ notice.appendChild(title);
11208
+
11209
+ var body = document.createElement('div');
11210
+ var command = String(status.installCommand || 'npx -y openclaw-openagent-cli update');
11211
+ body.textContent = currentVersion ? ('当前版本 ' + currentVersion + ',运行命令完成更新。') : '运行命令完成更新。';
11212
+ body.style.cssText = 'color:#4b5563;margin-bottom:10px;';
11213
+ notice.appendChild(body);
11214
+
11215
+ var code = document.createElement('code');
11216
+ code.textContent = command;
11217
+ code.style.cssText = 'display:block;white-space:normal;word-break:break-all;background:#f6f7f9;border-radius:8px;padding:8px 10px;color:#111827;';
11218
+ notice.appendChild(code);
11219
+
11220
+ var actions = document.createElement('div');
11221
+ actions.style.cssText = 'display:flex;justify-content:flex-end;gap:8px;margin-top:10px;';
11222
+ var copy = document.createElement('button');
11223
+ copy.type = 'button';
11224
+ copy.textContent = '复制命令';
11225
+ copy.style.cssText = 'border:1px solid #d1d5db;background:#fff;border-radius:8px;padding:6px 10px;cursor:pointer;color:#374151;';
11226
+ copy.onclick = function() {
11227
+ try {
11228
+ navigator.clipboard.writeText(command);
11229
+ copy.textContent = '已复制';
11230
+ } catch (e) {}
11231
+ };
11232
+ actions.appendChild(copy);
11233
+
11234
+ var close = document.createElement('button');
11235
+ close.type = 'button';
11236
+ close.textContent = '关闭';
11237
+ close.style.cssText = 'border:0;background:#111827;color:#fff;border-radius:8px;padding:6px 10px;cursor:pointer;';
11238
+ close.onclick = function() {
11239
+ try {
11240
+ if (latestVersion) localStorage.setItem(dismissKey, '1');
11241
+ } catch (e) {}
11242
+ notice.remove();
11243
+ };
11244
+ actions.appendChild(close);
11245
+ notice.appendChild(actions);
11246
+
11247
+ if (status.policy === 'auto' && status.autoUpdateStarted) {
11248
+ body.textContent = '正在自动更新,OpenClaw Gateway 可能会自动重启。';
11249
+ actions.remove();
11250
+ }
11251
+
11252
+ document.body.appendChild(notice);
11253
+ }
11254
+
10399
11255
  if (document.readyState === 'loading') {
10400
11256
  document.addEventListener('DOMContentLoaded', _startClObserver);
10401
11257
  } else {