openclaw-openagent 1.0.11 → 1.0.12

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 (56) hide show
  1. package/dist/index.js +1 -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/plugin-ui/adapters/adapters/oc-2026-04.js +103 -0
  5. package/dist/src/plugin-ui/adapters/adapters/oc-2026-05.js +125 -0
  6. package/dist/src/plugin-ui/adapters/adapters/oc-2026-06.js +125 -0
  7. package/dist/src/plugin-ui/adapters/adapters/oc-unknown.js +48 -0
  8. package/dist/src/plugin-ui/adapters/oc-2026-04.js +103 -0
  9. package/dist/src/plugin-ui/adapters/oc-2026-05.js +125 -0
  10. package/dist/src/plugin-ui/adapters/oc-2026-06.js +125 -0
  11. package/dist/src/plugin-ui/adapters/oc-unknown.js +48 -0
  12. package/dist/src/plugin-ui/assets/openagent-override.js +1007 -258
  13. package/dist/src/plugin-ui/index.d.ts +1 -1
  14. package/dist/src/plugin-ui/index.js +2 -2
  15. package/dist/src/plugin-ui/ui-extension-loader/index.d.ts +2 -1
  16. package/dist/src/plugin-ui/ui-extension-loader/index.js +5 -5
  17. package/dist/src/plugin-ui/ui-extension-loader/registry-regex.js +75 -8
  18. package/dist/src/plugin-ui/ui-extension-loader/types.d.ts +4 -1
  19. package/dist/src/state/store.d.ts +21 -0
  20. package/dist/src/state/store.js +54 -0
  21. package/dist/src/transport/oasn/oasn-invocation.d.ts +3 -0
  22. package/dist/src/transport/oasn/oasn-invocation.js +28 -12
  23. package/dist/src/transport/oasn/oasn-types.d.ts +8 -4
  24. package/index.ts +1 -1
  25. package/package.json +4 -3
  26. package/src/app/remote-agent-tool.ts +131 -16
  27. package/src/app/types.ts +2 -2
  28. package/src/plugin-ui/adapters/oc-2026-04.js +103 -0
  29. package/src/plugin-ui/adapters/oc-2026-05.js +125 -0
  30. package/src/plugin-ui/adapters/oc-2026-06.js +125 -0
  31. package/src/plugin-ui/adapters/oc-unknown.js +48 -0
  32. package/src/plugin-ui/assets/openagent-override.js +1007 -258
  33. package/src/plugin-ui/build.cjs +249 -38
  34. package/src/plugin-ui/index.ts +2 -2
  35. package/src/plugin-ui/modules/agent-book/panel/agent-book.js +102 -12
  36. package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +105 -3
  37. package/src/plugin-ui/modules/agent-book/panel/styles.js +42 -35
  38. package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +4 -2
  39. package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +4 -1
  40. package/src/plugin-ui/modules/agent-book/scanner.js +17 -5
  41. package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +5 -0
  42. package/src/plugin-ui/modules/loader/shared-state.js +244 -20
  43. package/src/plugin-ui/modules/remote-agent/execution-card.js +54 -16
  44. package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +5 -23
  45. package/src/plugin-ui/modules/remote-agent/output-card.js +13 -7
  46. package/src/plugin-ui/modules/remote-agent/render-hooks.js +53 -41
  47. package/src/plugin-ui/modules/remote-agent/styles.js +230 -88
  48. package/src/plugin-ui/modules/remote-agent/tool-card-model.js +72 -4
  49. package/src/plugin-ui/postinstall-deploy.cjs +52 -0
  50. package/src/plugin-ui/ui-extension-loader/index.ts +6 -6
  51. package/src/plugin-ui/ui-extension-loader/registry-regex.ts +81 -9
  52. package/src/plugin-ui/ui-extension-loader/types.ts +5 -1
  53. package/src/state/store.ts +80 -0
  54. package/src/transport/oasn/oasn-invocation.ts +47 -12
  55. package/src/transport/oasn/oasn-types.ts +6 -2
  56. 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-06T03:23:32.989Z
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: "65bf8968e270",
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() {
90
207
  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';
97
- } 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';
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' };
105
248
  }
106
249
  }
107
- console.log('[cl-version] detected via DOM/CSS features: ' + CL.hostVersion);
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-*。
292
+ try {
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');
301
+ } else {
302
+ _clApplyHostVersion('2026.3.0', 'feature-fallback');
303
+ }
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;
@@ -1839,6 +2121,7 @@ function injectStyles() {
1839
2121
  }
1840
2122
  .openagent-agent-panel.visible {
1841
2123
  display: flex;
2124
+ padding: 30px;
1842
2125
  animation: openagent-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
1843
2126
  }
1844
2127
  @keyframes openagent-up {
@@ -1852,22 +2135,21 @@ function injectStyles() {
1852
2135
  justify-content: space-between;
1853
2136
  align-items: center;
1854
2137
  min-height: 26px;
1855
- padding: 6px 10px 0 10px;
1856
2138
  border-bottom: none;
1857
2139
  }
1858
2140
  .openagent-panel-title {
1859
2141
  display: flex;
1860
2142
  align-items: center;
1861
2143
  gap: 6px;
1862
- font-size: 16px;
2144
+ font-size: 18px;
1863
2145
  font-weight: 500;
1864
- color: rgba(47, 47, 51, 0.8);
2146
+ color: #333;
1865
2147
  text-transform: uppercase;
1866
2148
  letter-spacing: 0.3px;
1867
2149
  }
1868
2150
  .openagent-panel-title-icon {
1869
- width: 21px;
1870
- height: 21px;
2151
+ width: 24px;
2152
+ height: 24px;
1871
2153
  flex-shrink: 0;
1872
2154
  }
1873
2155
  .openagent-panel-close {
@@ -1894,7 +2176,7 @@ function injectStyles() {
1894
2176
  .openagent-panel-divider {
1895
2177
  height: 0;
1896
2178
  border: none;
1897
- border-top: 0.2px solid rgba(47, 47, 51, 0.16);
2179
+ border-top: 0.2px solid #EAEAEA;
1898
2180
  margin: 0;
1899
2181
  }
1900
2182
 
@@ -2073,7 +2355,6 @@ function injectStyles() {
2073
2355
  flex: 1;
2074
2356
  display: flex;
2075
2357
  flex-direction: column;
2076
- gap: 14px;
2077
2358
  min-height: 0;
2078
2359
  max-height: min(56vh, 451px);
2079
2360
  scrollbar-width: thin;
@@ -2096,9 +2377,9 @@ function injectStyles() {
2096
2377
  .openagent-agent-section {
2097
2378
  display: flex;
2098
2379
  flex-direction: column;
2099
- gap: 8px;
2100
2380
  width: 100%;
2101
2381
  min-width: 0;
2382
+ margin-bottom: 30px;
2102
2383
  }
2103
2384
 
2104
2385
  /* ── 父分类标题(两级结构:Research > Market Research) ── */
@@ -2109,33 +2390,22 @@ function injectStyles() {
2109
2390
  width: 100%;
2110
2391
  min-width: 0;
2111
2392
  }
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
2393
  /* ── 分组标题 ── */
2123
2394
  .openagent-section-heading {
2124
2395
  font-size: 16px;
2125
2396
  font-weight: 400;
2126
2397
  line-height: 16px;
2127
2398
  color: rgba(47, 47, 51, 0.80);
2128
- padding: 0 12px 0 12px;
2129
2399
  letter-spacing: 0;
2400
+ margin-bottom: 20px;
2130
2401
  }
2131
2402
 
2132
2403
  /* ── 分组网格容器 ── */
2133
2404
  .openagent-section-grid {
2134
2405
  display: grid;
2135
- grid-template-columns: repeat(3, minmax(0, 439.5px));
2406
+ grid-template-columns: repeat(3, 1fr);
2136
2407
  justify-content: start;
2137
- gap: 8px 14px;
2138
- padding: 0 12px;
2408
+ gap: 12px;
2139
2409
  width: 100%;
2140
2410
  box-sizing: border-box;
2141
2411
  }
@@ -2168,9 +2438,15 @@ function injectStyles() {
2168
2438
  .agent-card__body { flex: 1; min-width: 0; }
2169
2439
  .agent-card__name-line { display: flex; align-items: baseline; gap: 8px; }
2170
2440
  .agent-card__name {
2441
+ display: block;
2442
+ min-width: 0;
2443
+ max-width: 100%;
2171
2444
  font-family: "PingFang SC", sans-serif;
2172
2445
  font-weight: 600;
2173
2446
  color: rgba(47, 47, 51, 1);
2447
+ white-space: nowrap;
2448
+ overflow: hidden;
2449
+ text-overflow: ellipsis;
2174
2450
  }
2175
2451
  .agent-card__tag { font-size: 12px; color: #6366f1; font-weight: 500; }
2176
2452
  .agent-card__specialty { font-size: 12px; color: #999; font-weight: 400; }
@@ -2245,12 +2521,31 @@ function injectStyles() {
2245
2521
  border-radius: 20px;
2246
2522
  border: 0.5px solid #dbdbdb;
2247
2523
  background: #fff;
2248
- min-height: 0;
2249
2524
  min-width: 0;
2250
2525
  box-sizing: border-box;
2251
2526
  }
2252
2527
  .agent-card--mention:hover {
2253
- background: rgba(0, 0, 0, 0.02);
2528
+ border-color: transparent;
2529
+ box-shadow: 0 4px 12px 0 rgba(149, 147, 240, 0.10);
2530
+ }
2531
+ .openagent-agent-list .agent-card--mention:hover,
2532
+ .openagent-agent-list .agent-card--search:hover {
2533
+ position: relative;
2534
+ border-color: transparent;
2535
+ }
2536
+ .openagent-agent-list .agent-card--mention:hover::after,
2537
+ .openagent-agent-list .agent-card--search:hover::after {
2538
+ content: "";
2539
+ position: absolute;
2540
+ inset: 0;
2541
+ border-radius: inherit;
2542
+ padding: 1px;
2543
+ background: linear-gradient(90deg, rgba(92, 74, 255, 0.5), rgba(130, 116, 255, 0.5));
2544
+ pointer-events: none;
2545
+ box-sizing: border-box;
2546
+ -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
2547
+ -webkit-mask-composite: xor;
2548
+ mask-composite: exclude;
2254
2549
  }
2255
2550
  /* avart 外壳简化 — 不再需要 */
2256
2551
  .agent-card--mention .agent-card__avart {
@@ -2379,9 +2674,6 @@ function injectStyles() {
2379
2674
  border: 0.5px solid transparent;
2380
2675
  box-sizing: border-box;
2381
2676
  }
2382
- .agent-card--search:hover {
2383
- background: rgba(0, 0, 0, 0.02);
2384
- }
2385
2677
  .agent-card--search .agent-card__avatar {
2386
2678
  width: 40px;
2387
2679
  height: 40px;
@@ -2499,7 +2791,6 @@ function injectStyles() {
2499
2791
  [data-theme-mode="dark"] .openagent-agent-panel,
2500
2792
  [data-theme="dark"] .openagent-agent-panel {
2501
2793
  background: #1c1c1c; border-color: rgba(255,255,255,0.12);
2502
- box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
2503
2794
  }
2504
2795
  [data-theme-mode="dark"] .openagent-panel-head,
2505
2796
  [data-theme="dark"] .openagent-panel-head { border-color: #2a2a2a; }
@@ -2511,8 +2802,6 @@ function injectStyles() {
2511
2802
  [data-theme="dark"] .openagent-panel-close:hover { background: #333; }
2512
2803
  [data-theme-mode="dark"] .openagent-section-heading,
2513
2804
  [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
2805
  [data-theme-mode="dark"] .openagent-panel-divider,
2517
2806
  [data-theme="dark"] .openagent-panel-divider { border-color: rgba(255,255,255,0.1); }
2518
2807
 
@@ -2526,7 +2815,7 @@ function injectStyles() {
2526
2815
  [data-theme-mode="dark"] .agent-card--mention,
2527
2816
  [data-theme="dark"] .agent-card--mention { background: #1c1c1c; border-color: rgba(255,255,255,0.12); }
2528
2817
  [data-theme-mode="dark"] .agent-card--mention:hover,
2529
- [data-theme="dark"] .agent-card--mention:hover { background: #252525; }
2818
+ [data-theme="dark"] .agent-card--mention:hover { border-color: transparent; }
2530
2819
  [data-theme-mode="dark"] .agent-card--mention .agent-card__name,
2531
2820
  [data-theme="dark"] .agent-card--mention .agent-card__name { color: #e0e0e0; }
2532
2821
  [data-theme-mode="dark"] .agent-card--mention .agent-card__bio,
@@ -2541,8 +2830,6 @@ function injectStyles() {
2541
2830
  }
2542
2831
  [data-theme-mode="dark"] .agent-card--mention .agent-card__action:hover,
2543
2832
  [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
2833
  [data-theme-mode="dark"] .agent-card--search .agent-card__name,
2547
2834
  [data-theme="dark"] .agent-card--search .agent-card__name { color: #e0e0e0; }
2548
2835
  [data-theme-mode="dark"] .agent-card--search .agent-card__bio,
@@ -2802,6 +3089,7 @@ let panel = null;
2802
3089
  let backdrop = null;
2803
3090
 
2804
3091
  let inputWrapperRef = null; // 保存输入框包裹层引用
3092
+ let panelPositionResizeObserver = null;
2805
3093
 
2806
3094
  // ── 键盘导航状态(§1.5)──
2807
3095
  // 对标 TIM index.ts:13 "let selectedIndex: number = 0"
@@ -2836,7 +3124,7 @@ panel.className = 'openagent-agent-panel';
2836
3124
  panel.innerHTML = `
2837
3125
  <div class="openagent-panel-head">
2838
3126
  <span class="openagent-panel-title">
2839
- <svg class="openagent-panel-title-icon" width="28" height="28" viewBox="0 0 56 56" fill="none">
3127
+ <svg class="openagent-panel-title-icon" width="24" height="24" viewBox="0 0 56 56" fill="none">
2840
3128
  <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
3129
  <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
3130
  <path d="M27 25.5L32.5 21" stroke="#12CCF6" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
@@ -2879,12 +3167,71 @@ const width = Math.min(rect.width, window.innerWidth - viewportPadding * 2);
2879
3167
  const left = Math.max(viewportPadding, Math.min(rect.left, window.innerWidth - width - viewportPadding));
2880
3168
  panel.style.left = left + 'px';
2881
3169
  panel.style.width = width + 'px';
2882
- panel.style.bottom = (window.innerHeight - rect.top + 8) + 'px';
3170
+ const toolbar = _findPanelToolbar();
3171
+ const isComposerWrapper = inputWrapperRef.classList
3172
+ && inputWrapperRef.classList.contains('agent-chat__composer-combobox');
3173
+ if (isComposerWrapper) {
3174
+ panel.style.bottom = (_readElementHeight(inputWrapperRef) + _readElementHeight(toolbar) + 35) + 'px';
3175
+ } else {
3176
+ panel.style.bottom = (window.innerHeight - rect.top + 8) + 'px';
3177
+ }
2883
3178
  }
2884
3179
 
2885
3180
  /** resize 时实时跟随输入框 */
2886
3181
  function _onResize() { _positionPanel(); }
2887
3182
 
3183
+ function _findPanelToolbar() {
3184
+ if (!inputWrapperRef) return null;
3185
+ var chatInput = inputWrapperRef.closest && inputWrapperRef.closest('.agent-chat__input');
3186
+ if (chatInput) {
3187
+ var toolbar = chatInput.querySelector('.agent-chat__toolbar');
3188
+ if (toolbar) return toolbar;
3189
+ }
3190
+
3191
+ var parentEl = inputWrapperRef.parentElement;
3192
+ if (parentEl) {
3193
+ for (var i = 0; i < parentEl.children.length; i++) {
3194
+ var child = parentEl.children[i];
3195
+ if (child !== inputWrapperRef && child.className && String(child.className).indexOf('agent-chat__toolbar') !== -1) {
3196
+ return child;
3197
+ }
3198
+ }
3199
+ }
3200
+ return null;
3201
+ }
3202
+
3203
+ function _readElementHeight(el) {
3204
+ if (!el) return 0;
3205
+ var rect = el.getBoundingClientRect ? el.getBoundingClientRect() : null;
3206
+ if (rect && rect.height > 0) return rect.height;
3207
+ return typeof el.offsetHeight === 'number' ? el.offsetHeight : 0;
3208
+ }
3209
+
3210
+ function _schedulePanelPosition() {
3211
+ window.requestAnimationFrame
3212
+ ? window.requestAnimationFrame(_positionPanel)
3213
+ : setTimeout(_positionPanel, 0);
3214
+ }
3215
+
3216
+ function _installPanelPositionObservers() {
3217
+ if (panelPositionResizeObserver) {
3218
+ panelPositionResizeObserver.disconnect();
3219
+ panelPositionResizeObserver = null;
3220
+ }
3221
+ if (typeof ResizeObserver !== 'function' || !inputWrapperRef) return;
3222
+
3223
+ panelPositionResizeObserver = new ResizeObserver(_schedulePanelPosition);
3224
+ panelPositionResizeObserver.observe(inputWrapperRef);
3225
+ var toolbar = _findPanelToolbar();
3226
+ if (toolbar) panelPositionResizeObserver.observe(toolbar);
3227
+ }
3228
+
3229
+ function _teardownPanelPositionObservers() {
3230
+ if (!panelPositionResizeObserver) return;
3231
+ panelPositionResizeObserver.disconnect();
3232
+ panelPositionResizeObserver = null;
3233
+ }
3234
+
2888
3235
  // 搜索状态管理
2889
3236
  let currentAbort = null; // AbortController for in-flight search
2890
3237
  let searchDebounceId = null;
@@ -2911,6 +3258,7 @@ if (oldEmpty) oldEmpty.remove();
2911
3258
 
2912
3259
  const p = ensurePanel();
2913
3260
  _positionPanel(); // 动态定位到 input 上方
3261
+ _installPanelPositionObservers();
2914
3262
  p.classList.add('visible');
2915
3263
  backdrop.classList.add('visible');
2916
3264
  window.addEventListener('resize', _onResize);
@@ -2973,6 +3321,7 @@ function closePanel() {
2973
3321
  if (panel) panel.classList.remove('visible');
2974
3322
  if (backdrop) backdrop.classList.remove('visible');
2975
3323
  window.removeEventListener('resize', _onResize);
3324
+ _teardownPanelPositionObservers();
2976
3325
  // 清理搜索状态
2977
3326
  if (currentAbort) { currentAbort.abort(); currentAbort = null; }
2978
3327
  if (searchDebounceId) { clearTimeout(searchDebounceId); searchDebounceId = null; }
@@ -3027,7 +3376,6 @@ function _scrollItemIntoView(index) {
3027
3376
 
3028
3377
  function _appendParentSection(container, parentTitle, children, textarea, renderedAgents) {
3029
3378
  const parentSec = _el('section', 'openagent-parent-section');
3030
- parentSec.appendChild(_text('div', 'openagent-parent-heading', parentTitle));
3031
3379
  children.forEach(function(child) {
3032
3380
  if (child.agents && child.agents.length > 0) {
3033
3381
  _appendAgentSection(parentSec, child.title, child.agents, textarea, renderedAgents);
@@ -3102,7 +3450,12 @@ function _dismissEmptyToast() {
3102
3450
  }
3103
3451
 
3104
3452
  /** 独立浮层空状态(不在面板内) */
3105
- function _showEmptyToast(query) {
3453
+ function _getEmptyMessage(query) {
3454
+ return CL.agentBookLastError ||
3455
+ (query ? '暂未匹配到您想要的Agent 我们将持续上新~' : '暂无在线 Agent,请输入关键词搜索');
3456
+ }
3457
+
3458
+ function _showEmptyToast(query, message) {
3106
3459
  _dismissEmptyToast();
3107
3460
  var toast = _el('div', 'openagent-empty-toast');
3108
3461
 
@@ -3112,8 +3465,7 @@ function _showEmptyToast(query) {
3112
3465
  '</svg>';
3113
3466
  toast.appendChild(iconWrap);
3114
3467
 
3115
- toast.appendChild(_text('span', 'openagent-empty-state__text',
3116
- query ? '暂未匹配到您想要的Agent 我们将持续上新~' : '暂无在线 Agent,请输入关键词搜索'));
3468
+ toast.appendChild(_text('span', 'openagent-empty-state__text', message || _getEmptyMessage(query)));
3117
3469
 
3118
3470
  var closeBtn = _el('button', 'openagent-empty-state__close');
3119
3471
  closeBtn.innerHTML = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none">' +
@@ -3129,12 +3481,17 @@ function _showEmptyToast(query) {
3129
3481
  toast.style.left = Math.max(16, rect.left) + 'px';
3130
3482
  toast.style.width = Math.min(rect.width, window.innerWidth - 32) + 'px';
3131
3483
  toast.style.bottom = (window.innerHeight - rect.top + 8) + 'px';
3484
+ // ── V2 版本兼容:v1 bottom 固定 117px ──
3485
+ var isV2Toast = typeof _clIsHostVersionGte === 'function' && _clIsHostVersionGte('2026.6.9');
3486
+ if (!isV2Toast) {
3487
+ toast.style.bottom = '117px';
3488
+ }
3132
3489
  toast.style.zIndex = '100000';
3133
3490
  }
3134
3491
  document.body.appendChild(toast);
3135
3492
  }
3136
3493
 
3137
- function _createEmptyState(query) {
3494
+ function _createEmptyState(query, message) {
3138
3495
  var wrapper = _el('div', 'openagent-empty-state');
3139
3496
  var row = _el('div', 'openagent-empty-state__row');
3140
3497
 
@@ -3144,8 +3501,7 @@ function _createEmptyState(query) {
3144
3501
  '</svg>';
3145
3502
  row.appendChild(iconWrap);
3146
3503
 
3147
- var text = _text('span', 'openagent-empty-state__text',
3148
- query ? '暂未匹配到您想要的Agent 我们将持续上新~' : '暂无在线 Agent,请输入关键词搜索');
3504
+ var text = _text('span', 'openagent-empty-state__text', message || _getEmptyMessage(query));
3149
3505
  row.appendChild(text);
3150
3506
 
3151
3507
  var closeBtn = _el('button', 'openagent-empty-state__close');
@@ -3163,10 +3519,11 @@ function _createEmptyState(query) {
3163
3519
 
3164
3520
  function renderAgentList(container, agents, textarea, query) {
3165
3521
  if (!agents.length) {
3522
+ var emptyMessage = _getEmptyMessage(query);
3166
3523
  _currentAgents = [];
3167
3524
  _currentTextarea = textarea;
3168
3525
  closePanel();
3169
- _showEmptyToast(query);
3526
+ _showEmptyToast(query, emptyMessage);
3170
3527
  return;
3171
3528
  }
3172
3529
 
@@ -3203,6 +3560,19 @@ _highlightItem(0);
3203
3560
  * 对齐 openagent-frontend NewChatPanel L92-105:
3204
3561
  * 找到最后一个 @,替换其后内容为 @agentName
3205
3562
  */
3563
+ function _pickMentionAgentDescription(agent) {
3564
+ if (!agent || typeof agent !== 'object') return '';
3565
+ if (CL && typeof CL.pickAgentIdentityDescription === 'function') {
3566
+ return CL.pickAgentIdentityDescription(agent);
3567
+ }
3568
+ const keys = ['agent_bio', 'agentBio', 'bio', 'description', 'desc', 'agent_description', 'agentDescription', 'MOM', 'mom'];
3569
+ for (let i = 0; i < keys.length; i++) {
3570
+ const value = agent[keys[i]];
3571
+ if (typeof value === 'string' && value.trim()) return value.trim();
3572
+ }
3573
+ return '';
3574
+ }
3575
+
3206
3576
  function insertMention(textarea, agentName, agentData) {
3207
3577
  // 重新查找 textarea(Lit 可能重新渲染导致引用失效)
3208
3578
  const liveTextarea = document.querySelector(
@@ -3222,9 +3592,11 @@ liveTextarea.focus();
3222
3592
  const agentId = agentData?.agent_id || agentData?.agentId || agentData?.id || agentData?.tag ||
3223
3593
  agentData?.user_id || agentData?.userId || agentData?.identifier || agentData?.tim_user_id || agentData?.timUserId || '';
3224
3594
  const agentAvatar = agentData?.avatar || agentData?.avatar_url || agentData?.avatarUrl || agentData?.image || agentData?.logo || agentData?.photo || null;
3595
+ const agentBio = _pickMentionAgentDescription(agentData);
3225
3596
  console.log('[cl-diag][mention-select]', {
3226
3597
  agentName,
3227
3598
  resolvedAgentId: agentId || null,
3599
+ hasAgentBio: !!agentBio,
3228
3600
  rawKeys: Object.keys(agentData || {}),
3229
3601
  rawAgent: agentData,
3230
3602
  });
@@ -3233,9 +3605,14 @@ if (!agentId) {
3233
3605
  console.warn('[openagent] mention skipped: missing agent identifier for', agentName, agentData);
3234
3606
  return;
3235
3607
  }
3236
- CL.pendingMention = { agent_id: agentId, name: agentName, avatar: agentAvatar };
3608
+ CL.pendingMention = { agent_id: agentId, name: agentName, avatar: agentAvatar, agent_bio: agentBio };
3237
3609
  if (CL && typeof CL.storeAgentIdentity === 'function') {
3238
- CL.storeAgentIdentity({ agent_id: agentId, name: agentName, avatar: agentAvatar });
3610
+ CL.storeAgentIdentity(Object.assign({}, agentData || {}, {
3611
+ agent_id: agentId,
3612
+ name: agentName,
3613
+ avatar: agentAvatar,
3614
+ agent_bio: agentBio,
3615
+ }));
3239
3616
  }
3240
3617
  console.log('[openagent] mention stored:', CL.pendingMention);
3241
3618
 
@@ -3315,12 +3692,27 @@ function _setTextareaValue(textarea, value) {
3315
3692
  textarea.dispatchEvent(new Event('input', { bubbles: true }));
3316
3693
  }
3317
3694
 
3695
+ function _escapeRemoteAgentMarkerValue(value) {
3696
+ return String(value || '')
3697
+ .replace(/\s+/g, ' ')
3698
+ .trim()
3699
+ .replace(/"/g, "'");
3700
+ }
3701
+
3318
3702
  function _buildRemoteAgentMarker(mention, userText) {
3319
3703
  const hasChinese = /[\u4e00-\u9fff]/.test(userText || '');
3320
3704
  const instruction = hasChinese
3321
3705
  ? '请调用 openagent_call_remote_agent 工具将此请求转发给远端 Agent 处理'
3322
3706
  : '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}"}`;
3707
+ const attrs = [
3708
+ `agent_id="${_escapeRemoteAgentMarkerValue(mention.agent_id)}"`,
3709
+ `agent_name="${_escapeRemoteAgentMarkerValue(mention.name)}"`,
3710
+ ];
3711
+ if (mention.agent_bio) {
3712
+ attrs.push(`agent_bio="${_escapeRemoteAgentMarkerValue(mention.agent_bio)}"`);
3713
+ }
3714
+ attrs.push(`instruction="${_escapeRemoteAgentMarkerValue(instruction)}"`);
3715
+ return `{openagent_call_remote_agent:${attrs.join(',')}}`;
3324
3716
  }
3325
3717
 
3326
3718
  function _composeRemoteAgentMessage(textarea, mention) {
@@ -3562,13 +3954,13 @@ function tryInject() {
3562
3954
  console.log('[openagent] ✅ Agent Book UI injected (v3 hook-driven)');
3563
3955
 
3564
3956
  // ── 提示栏(Figma 141:3293):页面加载即显示 ──
3565
- _injectHintBar(inputContainer || textarea.parentElement);
3957
+ _injectHintBar(inputContainer || textarea.parentElement, toolbarRow);
3566
3958
 
3567
3959
  return true;
3568
3960
  }
3569
3961
 
3570
3962
  /** 注入提示栏到输入区域上方 */
3571
- function _injectHintBar(anchorEl) {
3963
+ function _injectHintBar(anchorEl, toolbarEl) {
3572
3964
  if (!anchorEl || document.querySelector('.openagent-hint-bar')) return;
3573
3965
 
3574
3966
  const hintBar = document.createElement('div');
@@ -3604,8 +3996,95 @@ function _injectHintBar(anchorEl) {
3604
3996
  hintBar.style.display = 'none';
3605
3997
  });
3606
3998
 
3999
+ // ── V2 版本兼容:≥ 2026.6.9 使用 absolute 定位,bottom 动态跟随输入区高度 ──
4000
+ var isV2 = typeof _clIsHostVersionGte === 'function' && _clIsHostVersionGte('2026.6.9');
4001
+ if (isV2) {
4002
+ hintBar.style.position = 'absolute';
4003
+ }
4004
+
3607
4005
  // 插入到 wrapper 外面、上方
3608
4006
  anchorEl.parentElement.insertBefore(hintBar, anchorEl);
4007
+
4008
+ function _findHintBarToolbar() {
4009
+ if (toolbarEl) return toolbarEl;
4010
+ var parentEl = anchorEl.parentElement;
4011
+ if (parentEl) {
4012
+ for (var i = 0; i < parentEl.children.length; i++) {
4013
+ var child = parentEl.children[i];
4014
+ if (child !== anchorEl && child.className && String(child.className).indexOf('agent-chat__toolbar') !== -1) {
4015
+ return child;
4016
+ }
4017
+ }
4018
+ }
4019
+ return anchorEl.closest && anchorEl.closest('.agent-chat__input')
4020
+ ? anchorEl.closest('.agent-chat__input').querySelector('.agent-chat__toolbar')
4021
+ : null;
4022
+ }
4023
+
4024
+ function _readElementHeight(el) {
4025
+ if (!el) return 0;
4026
+ var rect = el.getBoundingClientRect ? el.getBoundingClientRect() : null;
4027
+ if (rect && rect.height > 0) return rect.height;
4028
+ return typeof el.offsetHeight === 'number' ? el.offsetHeight : 0;
4029
+ }
4030
+
4031
+ // 跟随 composer wrapper 的实际尺寸。侧栏拖拽/布局重排不一定触发 window resize。
4032
+ function _syncHintBarLayout() {
4033
+ var rect = anchorEl.getBoundingClientRect();
4034
+ if (rect.width > 0) {
4035
+ hintBar.style.width = rect.width + 'px';
4036
+ var rootStyle = document.documentElement && document.documentElement.style;
4037
+ if (rootStyle) {
4038
+ rootStyle.setProperty('--openagent-input-wrapper-right-offset', Math.max(0, window.innerWidth - rect.right) + 'px');
4039
+ rootStyle.setProperty('--openagent-input-wrapper-right-edge', Math.max(0, rect.right) + 'px');
4040
+ rootStyle.setProperty('--openagent-input-wrapper-width', rect.width + 'px');
4041
+ }
4042
+ _syncSidebarRightEdge(rect);
4043
+ }
4044
+ if (isV2) {
4045
+ var toolbar = _findHintBarToolbar();
4046
+ var bottom = _readElementHeight(anchorEl) + _readElementHeight(toolbar) + 6;
4047
+ hintBar.style.bottom = bottom + 'px';
4048
+ }
4049
+ }
4050
+
4051
+ function _syncSidebarRightEdge(inputRect) {
4052
+ var sidebars = document.querySelectorAll('.chat-sidebar');
4053
+ for (var i = 0; i < sidebars.length; i++) {
4054
+ var sidebar = sidebars[i];
4055
+ var sidebarRect = sidebar.getBoundingClientRect();
4056
+ if (!sidebarRect || sidebarRect.width <= 0) continue;
4057
+ var left = Math.max(0, sidebarRect.left);
4058
+ var targetRight = Math.min(window.innerWidth, Math.max(0, inputRect.right));
4059
+ var targetWidth = Math.floor(targetRight - left);
4060
+ if (targetWidth <= 0) continue;
4061
+ sidebar.style.setProperty('--openagent-sidebar-target-width', targetWidth + 'px');
4062
+ sidebar.style.setProperty('width', targetWidth + 'px', 'important');
4063
+ sidebar.style.setProperty('max-width', targetWidth + 'px', 'important');
4064
+ sidebar.style.setProperty('flex-basis', targetWidth + 'px', 'important');
4065
+ sidebar.style.setProperty('margin-right', '0px', 'important');
4066
+ }
4067
+ }
4068
+
4069
+ function _scheduleHintBarLayoutSync() {
4070
+ window.requestAnimationFrame
4071
+ ? window.requestAnimationFrame(_syncHintBarLayout)
4072
+ : setTimeout(_syncHintBarLayout, 0);
4073
+ }
4074
+
4075
+ _syncHintBarLayout();
4076
+ _scheduleHintBarLayoutSync();
4077
+ window.addEventListener('resize', _scheduleHintBarLayoutSync);
4078
+ if (typeof ResizeObserver === 'function') {
4079
+ var hintBarResizeObserver = new ResizeObserver(_scheduleHintBarLayoutSync);
4080
+ hintBarResizeObserver.observe(anchorEl);
4081
+ var toolbarForResize = _findHintBarToolbar();
4082
+ if (toolbarForResize) hintBarResizeObserver.observe(toolbarForResize);
4083
+ }
4084
+ if (typeof MutationObserver === 'function' && document.body) {
4085
+ var sidebarLayoutObserver = new MutationObserver(_scheduleHintBarLayoutSync);
4086
+ sidebarLayoutObserver.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });
4087
+ }
3609
4088
  }
3610
4089
 
3611
4090
  // ════════════════════════════════════════════════════════════════
@@ -3952,10 +4431,12 @@ registerComponent('agent-card', async (data) => {
3952
4431
  function _clHandleTripDataSignal(payload, contextNode) {
3953
4432
  if (!payload) return;
3954
4433
  console.log('[trip-data] detected signal, payload:', payload.substring(0, 40));
4434
+ const hostTextContextSelector = (typeof CL !== 'undefined' && CL.hostAdapter && CL.hostAdapter.selectors && CL.hostAdapter.selectors.textContext)
4435
+ || '.chat-text';
3955
4436
 
3956
4437
  if (payload === 'file') {
3957
4438
  const chatText = contextNode && contextNode.closest
3958
- ? contextNode.closest('.chat-text, .chat-tool-card__detail, .chat-tools-collapse__body')
4439
+ ? contextNode.closest(hostTextContextSelector)
3959
4440
  : null;
3960
4441
  if (chatText) {
3961
4442
  chatText.dataset.clProcessed = '';
@@ -3972,7 +4453,7 @@ function _clHandleTripDataSignal(payload, contextNode) {
3972
4453
  }
3973
4454
  console.log('[trip-data] ✅ Card data from base64');
3974
4455
  const chatText = contextNode && contextNode.closest
3975
- ? contextNode.closest('.chat-text, .chat-tool-card__detail, .chat-tools-collapse__body')
4456
+ ? contextNode.closest(hostTextContextSelector)
3976
4457
  : null;
3977
4458
  if (chatText) {
3978
4459
  chatText.dataset.clProcessed = '';
@@ -4153,9 +4634,12 @@ if (document.readyState === 'loading') {
4153
4634
  // ── 1. CSS 注入 ──
4154
4635
 
4155
4636
  (function injectThoughtChainStyles() {
4156
- if (document.getElementById('cl-tools-collapse-css')) return;
4637
+ var oldStyle = document.getElementById('cl-tools-collapse-css');
4638
+ if (oldStyle) oldStyle.remove();
4157
4639
  const style = document.createElement('style');
4158
4640
  style.id = 'cl-tools-collapse-css';
4641
+ style.setAttribute('data-openagent-style', 'thought-chain');
4642
+ style.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
4159
4643
  style.textContent = `
4160
4644
  /* ── Agent Pill(通用身份标签) ── */
4161
4645
  .cl-agent-pill {
@@ -4359,7 +4843,12 @@ CL.handleDelegateWsEvent = function (msg) {
4359
4843
  // ════════════════════════════════════════════════════════════════
4360
4844
 
4361
4845
  // ── 1. CSS 注入 ──
4846
+ var _oldTripCSS = document.getElementById('openagent-trip-card-styles');
4847
+ if (_oldTripCSS) _oldTripCSS.remove();
4362
4848
  const _tripCSS = document.createElement('style');
4849
+ _tripCSS.id = 'openagent-trip-card-styles';
4850
+ _tripCSS.setAttribute('data-openagent-style', 'trip-card');
4851
+ _tripCSS.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
4363
4852
  _tripCSS.textContent = `
4364
4853
  /* ── 行程文字:普通文字灰色,特殊标注(粗体/链接/标题)黑色 ── */
4365
4854
  .trip-styled li, .trip-styled p { color: #888 !important; }
@@ -5783,20 +6272,32 @@ function _processCustomCards(bubble) {
5783
6272
 
5784
6273
  // CL.clScanCount lives on CL.clScanCount
5785
6274
 
6275
+ function _clIsInsideNativeToolHost(node) {
6276
+ var adapter = CL && CL.hostAdapter;
6277
+ var cur = node;
6278
+ var hops = 0;
6279
+ while (cur && cur !== document.body && hops < 12) {
6280
+ if (adapter && adapter.isToolLikeShell && adapter.isToolLikeShell(cur)) return true;
6281
+ cur = cur.parentElement;
6282
+ hops++;
6283
+ }
6284
+ return !!(node && node.closest && node.closest('details'));
6285
+ }
6286
+
5786
6287
  function _clScan() {
5787
6288
  CL.clScanCount++;
5788
6289
 
5789
6290
  // ── 0.5 清理标记 → 显示为 @agentName ──
5790
- // 新格式: {openagent_call_remote_agent:agent_id="...",agent_name="...",instruction="..."}
6291
+ // 新格式: {openagent_call_remote_agent:agent_id="...",agent_name="...",agent_bio="...",instruction="..."}
5791
6292
  // 旧格式: {openagent:agent_id="...",agent_name="..."}
5792
6293
  // 两种都要匹配清理;这里只处理普通聊天气泡,不处理 ToolCard。
5793
6294
  var CL_MENTION_STYLE = '';
5794
6295
  document.querySelectorAll('.chat-bubble').forEach(function(el) {
5795
6296
  if (el.dataset.clMarkerCleaned) return;
5796
- if (el.closest('.chat-tool-card, .chat-tools-collapse, details')) return;
6297
+ if (_clIsInsideNativeToolHost(el)) return;
5797
6298
 
5798
6299
  var text = el.textContent || '';
5799
- var rawRegex = /\{openagent(?:_call_remote_agent)?:agent_id="([^"]*)",agent_name="([^"]*)"(?:,instruction="[^"]*")?\}\s*/g;
6300
+ var rawRegex = /\{openagent(?:_call_remote_agent)?:agent_id="([^"]*)",agent_name="([^"]*)"(?:,[^{}]*)?\}\s*/g;
5800
6301
  if (!rawRegex.test(text)) return;
5801
6302
 
5802
6303
  if (el.querySelector('.cl-remote-agent-card')) {
@@ -5804,7 +6305,7 @@ function _clScan() {
5804
6305
  return; // 包含活 DOM,跳过 innerHTML 重写
5805
6306
  }
5806
6307
 
5807
- var htmlRegex = /\{openagent(?:_call_remote_agent)?:agent_id=(?:&quot;|")([^&"]*)(?:&quot;|"),agent_name=(?:&quot;|")([^&"]*)(?:&quot;|")(?:,instruction=(?:&quot;|")[^&"]*(?:&quot;|"))?\}\s*/g;
6308
+ var htmlRegex = /\{openagent(?:_call_remote_agent)?:agent_id=(?:&quot;|")([^&"]*)(?:&quot;|"),agent_name=(?:&quot;|")([^&"]*)(?:&quot;|")(?:,[^{}]*)?\}\s*/g;
5808
6309
  if (CL && typeof CL.diagHtmlRewrite === 'function') {
5809
6310
  CL.diagHtmlRewrite('scanner.marker.before', el, { scan: CL.clScanCount });
5810
6311
  }
@@ -5839,7 +6340,7 @@ function _clScan() {
5839
6340
  if (mentionedAgents.length > 0) {
5840
6341
  document.querySelectorAll('.chat-bubble').forEach(function(el) {
5841
6342
  if (el.dataset.clAgentStyled) return;
5842
- if (el.closest('.chat-tool-card, .chat-tools-collapse, details')) return;
6343
+ if (_clIsInsideNativeToolHost(el)) return;
5843
6344
 
5844
6345
  var text = el.textContent || '';
5845
6346
  var html = el.innerHTML;
@@ -5910,30 +6411,12 @@ function _clScan() {
5910
6411
 
5911
6412
  (function _clInitNativeStyleAdapter() {
5912
6413
  var _clNativeStyleSampled = false;
6414
+ var hostAdapter = CL.hostAdapter || {};
6415
+ var nativeStyle = hostAdapter.nativeStyle || {};
5913
6416
 
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
- ];
6417
+ var SHELL_SELECTORS = nativeStyle.shellSelectors || [];
6418
+ var SUMMARY_SELECTORS = nativeStyle.summarySelectors || [];
6419
+ var INDENT_SELECTORS = nativeStyle.indentSelectors || [];
5937
6420
 
5938
6421
  // Fallback 默认值(和当前 styles.js 折叠态写死值保持一致,避免跳变)
5939
6422
  var FALLBACKS = {
@@ -6069,62 +6552,75 @@ function _clScan() {
6069
6552
  if (oldStyle) oldStyle.remove();
6070
6553
  var style = document.createElement('style');
6071
6554
  style.id = 'cl-remote-agent-styles';
6555
+ style.setAttribute('data-openagent-style', 'remote-agent');
6556
+ style.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
6557
+ style.setAttribute('data-openagent-host-adapter', (CL.hostAdapter && CL.hostAdapter.id) || 'oc-unknown');
6558
+ var hostCss = (CL.hostAdapter && CL.hostAdapter.css) || {};
6559
+ function _clSelectorList(selectors) {
6560
+ if (!selectors) return '';
6561
+ if (Array.isArray(selectors)) return selectors.filter(Boolean).join(',\n');
6562
+ return String(selectors || '');
6563
+ }
6564
+ function _clRule(selectors, declarations) {
6565
+ var selectorText = _clSelectorList(selectors);
6566
+ if (!selectorText) return '';
6567
+ return selectorText + ' {\n' + declarations.join('\n') + '\n}';
6568
+ }
6072
6569
  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 {',
6570
+ // ── 隐藏宿主上下文用量提示 ──
6571
+ '.context-notice.context-notice--usage,',
6572
+ '.context-notice .context-notice--usage {',
6102
6573
  ' display: none !important;',
6103
6574
  '}',
6575
+
6576
+ // ── RenderHook 远端 Agent 卡片接管 native tool header ──
6577
+ _clRule(hostCss.remoteShell, [
6578
+ ' width: 100% !important;',
6579
+ ' max-width: 100% !important;',
6580
+ ' min-width: 0 !important;',
6581
+ ' box-sizing: border-box !important;',
6582
+ ' border: 0 !important;',
6583
+ ' background: transparent !important;',
6584
+ ' box-shadow: none !important;',
6585
+ ]),
6586
+ '/* Align output host shells with execution shells. Keep v4 msg-collapse',
6587
+ ' separate from newer tools-collapse so modern spacing never leaks into',
6588
+ ' the 2026.4 DOM. Move the host shell, not the inner OpenAgent card. */',
6589
+ _clRule(hostCss.outputHostMargin, [
6590
+ ' margin-left: 12px !important;',
6591
+ ]),
6592
+ _clRule(hostCss.outputHostMarginReset, [
6593
+ ' margin-left: 0 !important;',
6594
+ ]),
6595
+ _clRule(hostCss.summaryHidden, [
6596
+ ' display: none !important;',
6597
+ ]),
6598
+ _clRule(hostCss.hostShellRawText, [
6599
+ ' display: none !important;',
6600
+ ]),
6104
6601
  '.cl-remote-agent-raw-hidden > .chat-text,',
6105
6602
  '.cl-remote-agent-raw-hidden.chat-bubble > .chat-text {',
6106
6603
  ' display: none !important;',
6107
6604
  '}',
6108
6605
  '/* 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
- '}',
6606
+ _clRule(hostCss.rawTextCardHosts, [
6607
+ ' display: none !important;',
6608
+ ]),
6609
+ _clRule(hostCss.rawTextPlaceholderHosts, [
6610
+ ' display: none !important;',
6611
+ ]),
6612
+ _clRule(hostCss.hostBody, [
6613
+ ' border: 0 !important;',
6614
+ ' outline: 0 !important;',
6615
+ ' background: transparent !important;',
6616
+ ' box-shadow: none !important;',
6617
+ ' padding: 0 !important;',
6618
+ ' margin: 0 !important;',
6619
+ ' width: 100% !important;',
6620
+ ' max-width: 100% !important;',
6621
+ ' min-width: 0 !important;',
6622
+ ' box-sizing: border-box !important;',
6623
+ ]),
6128
6624
  '.chat-bubble:has(.cl-remote-agent-card) {',
6129
6625
  ' border: 0 !important;',
6130
6626
  ' background: transparent !important;',
@@ -6132,11 +6628,22 @@ function _clScan() {
6132
6628
  ' padding: 10px 0 !important;',
6133
6629
  ' width: 100%;',
6134
6630
  ' max-width: 100% !important;',
6631
+ ' min-width: 0 !important;',
6135
6632
  ' overflow: hidden !important;',
6633
+ ' box-sizing: border-box !important;',
6136
6634
  '}',
6137
- '.chat-tool-msg-collapse.chat-tool-msg-collapse--manual.is-open:has(.cl-remote-agent-card) {',
6138
- ' margin-left: 0 !important;',
6635
+ '.chat-split-container:has(.cl-output-card),',
6636
+ '.chat-main:has(.cl-output-card),',
6637
+ '.chat-sidebar:has(.cl-output-card),',
6638
+ '.chat-side-result:has(.cl-output-card),',
6639
+ '.chat-side-result__body:has(.cl-output-card) {',
6640
+ ' min-width: 0 !important;',
6641
+ ' max-width: 100% !important;',
6642
+ ' box-sizing: border-box !important;',
6139
6643
  '}',
6644
+ _clRule(hostCss.manualOpenReset, [
6645
+ ' margin-left: 0 !important;',
6646
+ ]),
6140
6647
  // ── 外层活动组容器 ──
6141
6648
  '.chat-activity-group__body:has(.cl-remote-agent-card) {',
6142
6649
  ' border-radius: 14px;',
@@ -6152,22 +6659,18 @@ function _clScan() {
6152
6659
  '.cl-remote-agent-host-shell {',
6153
6660
  ' width: min(100%, 912px) !important;',
6154
6661
  ' max-width: 100% !important;',
6662
+ ' min-width: 0 !important;',
6155
6663
  ' box-sizing: border-box !important;',
6156
6664
  '}',
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
- '}',
6665
+ _clRule(hostCss.hostShellReset, [
6666
+ ' border: 0 !important;',
6667
+ ' outline: 0 !important;',
6668
+ ' background: transparent !important;',
6669
+ ' box-shadow: none !important;',
6670
+ ]),
6671
+ _clRule(hostCss.hostShellSummary, [
6672
+ ' display: none !important;',
6673
+ ]),
6171
6674
  // ── 新卡片容器 ──
6172
6675
  // 覆盖 OpenClaw .chat-tool-card 的 max-height: 120px 限制
6173
6676
  '.cl-remote-agent-card {',
@@ -6180,9 +6683,14 @@ function _clScan() {
6180
6683
  ' background: #fff;',
6181
6684
  ' display: flex;',
6182
6685
  ' flex-direction: column;',
6183
- ' gap: 10px;',
6184
6686
  ' box-sizing: border-box;',
6185
6687
  '}',
6688
+ _clRule(hostCss.modernCardLayout ? ['.cl-remote-agent-card'] : [], [
6689
+ ' overflow: hidden;',
6690
+ ' min-width: 0;',
6691
+ ' gap: 0;',
6692
+ ' padding: 15px;',
6693
+ ]),
6186
6694
 
6187
6695
  // ── 顶部 OpenAgent 标题条 ──
6188
6696
  '.cl-openagent-header {',
@@ -6200,8 +6708,16 @@ function _clScan() {
6200
6708
  '}',
6201
6709
  '.cl-openagent-header:hover {',
6202
6710
  '}',
6711
+ _clRule(!hostCss.modernCardLayout ? ['.cl-openagent-header'] : [], [
6712
+ ' height: auto;',
6713
+ ' padding: 16px 25px;',
6714
+ ]),
6715
+ _clRule(hostCss.modernCardLayout ? ['.cl-openagent-header'] : [], [
6716
+ ' gap: 0;',
6717
+ ' height: auto;',
6718
+ ' padding: 15px;',
6719
+ ]),
6203
6720
  '/* Output mode (Figma 373:12082) */',
6204
- '.cl-openagent-header--output,',
6205
6721
  '.cl-exec-v2 .cl-openagent-header--output {',
6206
6722
  ' border-radius: 10px 10px 0 0 !important;',
6207
6723
  ' border: 1px solid rgba(229, 229, 234, 0.75) !important;',
@@ -6210,11 +6726,9 @@ function _clScan() {
6210
6726
  ' box-shadow: 0px 8px 11px rgba(0, 0, 0, 0.12);',
6211
6727
  ' padding: 8px 6px !important;',
6212
6728
  '}',
6213
- '.cl-openagent-header--output .cl-openagent-agent,',
6214
6729
  '.cl-exec-v2 .cl-openagent-header--output .cl-openagent-agent {',
6215
6730
  ' display: none;',
6216
6731
  '}',
6217
- '.cl-openagent-header--output:hover,',
6218
6732
  '.cl-exec-v2 .cl-openagent-header--output:hover {',
6219
6733
  ' border-color: rgba(0,0,0,0.1);',
6220
6734
  '}',
@@ -6234,10 +6748,14 @@ function _clScan() {
6234
6748
  ' width: 14px;',
6235
6749
  ' height: 14px;',
6236
6750
  ' border-radius: 14px;',
6237
- ' background: url(./icon.png) center/cover no-repeat;',
6751
+ ' background: url(./icon.png) center / contain no-repeat;',
6238
6752
  ' flex-shrink: 0;',
6239
6753
  ' overflow: hidden;',
6240
6754
  '}',
6755
+ _clRule(hostCss.modernCardLayout ? ['.cl-openagent-badge'] : [], [
6756
+ ' background: url(./icon.png) center/cover no-repeat;',
6757
+ ' margin: 0 6px;',
6758
+ ]),
6241
6759
  '.cl-openagent-text-row {',
6242
6760
  ' display: flex;',
6243
6761
  ' align-items: center;',
@@ -6268,7 +6786,20 @@ function _clScan() {
6268
6786
  ' display: flex;',
6269
6787
  ' flex-direction: column;',
6270
6788
  ' gap: 16px;',
6789
+ ' min-width: 0;',
6790
+ ' max-width: 100%;',
6791
+ ' box-sizing: border-box;',
6271
6792
  '}',
6793
+ _clRule(!hostCss.modernCardLayout ? ['.cl-thought-chain-content.cl-thought-chain-content--execution'] : [], [
6794
+ ' padding: 0 15px 15px;',
6795
+ ]),
6796
+ _clRule(hostCss.modernCardLayout ? ['.cl-thought-chain-content'] : [], [
6797
+ ' margin-left: 0;',
6798
+ ' width: 100%;',
6799
+ ' min-width: 0;',
6800
+ ' box-sizing: border-box;',
6801
+ ' overflow: hidden;',
6802
+ ]),
6272
6803
  '.cl-exec-detail-card {',
6273
6804
  ' padding: 8px 16px 8px 12px;',
6274
6805
  ' border-radius: 8px;',
@@ -6287,8 +6818,7 @@ function _clScan() {
6287
6818
  '.cl-exec-agent-avatar {',
6288
6819
  ' width: 68px;',
6289
6820
  ' height: 68px;',
6290
- ' border-radius: 50%;',
6291
- ' object-fit: cover;',
6821
+ ' object-fit: contain;',
6292
6822
  ' flex-shrink: 0;',
6293
6823
  '}',
6294
6824
  '.cl-exec-detail-info {',
@@ -6340,6 +6870,17 @@ function _clScan() {
6340
6870
  ' margin: 0;',
6341
6871
  ' line-height: 1;',
6342
6872
  '}',
6873
+ _clRule(!hostCss.modernCardLayout ? ['.cl-exec-agent-bio'] : [], [
6874
+ ' width: 250px;',
6875
+ ' max-width: 100%;',
6876
+ ' min-width: 0;',
6877
+ ' box-sizing: border-box;',
6878
+ ' overflow: hidden;',
6879
+ ' text-overflow: ellipsis;',
6880
+ ' display: -webkit-box;',
6881
+ ' -webkit-line-clamp: 2;',
6882
+ ' -webkit-box-orient: vertical;',
6883
+ ]),
6343
6884
 
6344
6885
  // ── Progress text (Figma 346:253) ──
6345
6886
  '.cl-thought-chain-content.cl-content-collapsed {',
@@ -6384,21 +6925,59 @@ function _clScan() {
6384
6925
  ' border: 1.2px solid rgba(47,47,51,0.1) !important;',
6385
6926
  ' border-radius: 24px !important;',
6386
6927
  ' padding: 10px 15px !important;',
6387
- ' gap: 10px !important;',
6928
+ ' width: 100% !important;',
6929
+ ' max-width: 100% !important;',
6930
+ ' min-width: 0 !important;',
6931
+ ' box-sizing: border-box !important;',
6932
+ ' overflow: hidden;',
6388
6933
  '}',
6934
+ _clRule(hostCss.modernCardLayout ? ['.cl-output-card'] : [], [
6935
+ ' gap: 10px !important;',
6936
+ ]),
6937
+ _clRule(!hostCss.modernCardLayout ? ['.cl-output-card'] : [], [
6938
+ ' border-radius: 14px !important;',
6939
+ ]),
6940
+ _clRule(!hostCss.modernCardLayout ? ['.cl-remote-agent-card.cl-thought-chain.cl-output-card'] : [], [
6941
+ ' padding: 0 !important;',
6942
+ ]),
6389
6943
  '.cl-output-card > .cl-thought-chain-content {',
6390
6944
  ' background: #fff;',
6391
6945
  ' border: 1px solid #f4f4f4;',
6392
6946
  ' border-radius: 12px;',
6393
6947
  ' padding: 20px 30px;',
6394
6948
  ' overflow: hidden;',
6949
+ ' width: 100%;',
6950
+ ' max-width: 100%;',
6951
+ ' min-width: 0;',
6952
+ ' box-sizing: border-box;',
6953
+ '}',
6954
+ _clRule(!hostCss.modernCardLayout ? ['.cl-output-card > .cl-thought-chain-content'] : [], [
6955
+ ' margin: 10px 15px;',
6956
+ ' width: calc(100% - 30px);',
6957
+ ]),
6958
+ '.cl-output-card .cl-output-result {',
6959
+ ' width: 100%;',
6395
6960
  ' max-width: 100%;',
6961
+ ' min-width: 0;',
6396
6962
  ' box-sizing: border-box;',
6963
+ ' overflow-wrap: anywhere;',
6964
+ ' word-break: break-word;',
6397
6965
  '}',
6398
6966
  '.cl-output-card > .cl-thought-chain-content * {',
6399
6967
  ' max-width: 100%;',
6968
+ ' min-width: 0;',
6400
6969
  ' box-sizing: border-box;',
6401
6970
  '}',
6971
+ '.cl-output-card > .cl-thought-chain-content p,',
6972
+ '.cl-output-card > .cl-thought-chain-content li,',
6973
+ '.cl-output-card > .cl-thought-chain-content a {',
6974
+ ' overflow-wrap: anywhere;',
6975
+ ' word-break: break-word;',
6976
+ '}',
6977
+ '.cl-output-card > .cl-thought-chain-content hr {',
6978
+ ' border: 0;',
6979
+ ' border-top: 1px solid #bdbdbd;',
6980
+ '}',
6402
6981
  '.cl-output-card > .cl-thought-chain-content pre,',
6403
6982
  '.cl-output-card > .cl-thought-chain-content code {',
6404
6983
  ' overflow-x: auto;',
@@ -6432,6 +7011,10 @@ function _clScan() {
6432
7011
  ' font-size: 14px;',
6433
7012
  ' color: #999;',
6434
7013
  '}',
7014
+ _clRule(!hostCss.modernCardLayout ? ['.cl-output-footer'] : [], [
7015
+ ' padding: 10px 15px;',
7016
+ ' line-height: 22px;',
7017
+ ]),
6435
7018
  '.cl-output-footer-text {',
6436
7019
  ' white-space: nowrap;',
6437
7020
  '}',
@@ -6452,6 +7035,9 @@ function _clScan() {
6452
7035
  ' border-radius: 14px !important;',
6453
7036
  ' padding: 16px 20px !important;',
6454
7037
  ' box-sizing: border-box !important;',
7038
+ ' min-width: 0 !important;',
7039
+ ' max-width: 100% !important;',
7040
+ ' overflow-x: hidden !important;',
6455
7041
  ' display: flex !important;',
6456
7042
  ' flex-direction: column !important;',
6457
7043
  ' gap: 16px !important;',
@@ -6461,6 +7047,10 @@ function _clScan() {
6461
7047
  ' flex-direction: column !important;',
6462
7048
  ' gap: 16px !important;',
6463
7049
  ' width: 100% !important;',
7050
+ ' min-width: 0 !important;',
7051
+ ' max-width: 100% !important;',
7052
+ ' overflow-x: hidden !important;',
7053
+ ' box-sizing: border-box !important;',
6464
7054
  ' background: transparent !important;',
6465
7055
  '}',
6466
7056
  '.chat-sidebar .sidebar-header {',
@@ -6496,7 +7086,12 @@ function _clScan() {
6496
7086
  ' line-height: 1.8 !important;',
6497
7087
  ' color: #333 !important;',
6498
7088
  ' width: 100% !important;',
7089
+ ' min-width: 0 !important;',
7090
+ ' max-width: 100% !important;',
6499
7091
  ' padding: 0 !important;',
7092
+ ' overflow-x: hidden !important;',
7093
+ ' box-sizing: border-box !important;',
7094
+ ' overflow-wrap: anywhere !important;',
6500
7095
  '}',
6501
7096
  '.chat-sidebar .sidebar-markdown {',
6502
7097
  ' font-family: "PingFang SC", sans-serif !important;',
@@ -6507,6 +7102,21 @@ function _clScan() {
6507
7102
  ' background: transparent !important;',
6508
7103
  ' border: none !important;',
6509
7104
  ' padding: 0 !important;',
7105
+ ' min-width: 0 !important;',
7106
+ ' max-width: 100% !important;',
7107
+ ' overflow-x: hidden !important;',
7108
+ ' box-sizing: border-box !important;',
7109
+ ' overflow-wrap: anywhere !important;',
7110
+ '}',
7111
+ '.chat-sidebar .sidebar-markdown * {',
7112
+ ' max-width: 100% !important;',
7113
+ ' min-width: 0 !important;',
7114
+ ' box-sizing: border-box !important;',
7115
+ '}',
7116
+ '.chat-sidebar .sidebar-markdown pre,',
7117
+ '.chat-sidebar .sidebar-markdown code {',
7118
+ ' white-space: pre-wrap !important;',
7119
+ ' word-break: break-word !important;',
6510
7120
  '}',
6511
7121
  // 隐藏宿主 sidebar 自带的 "Rendered Markdown / View Raw Text" 工具栏
6512
7122
  '.chat-sidebar .sidebar-markdown-shell__toolbar {',
@@ -6520,6 +7130,8 @@ function _clScan() {
6520
7130
  // ── V2 容器 ──
6521
7131
  '.cl-exec-v2 {',
6522
7132
  ' position: relative;',
7133
+ ' gap: 10px;',
7134
+ ' padding: 0;',
6523
7135
  '}',
6524
7136
 
6525
7137
  // ── V2 Header(Figma 371:6987 — 红晕渐变背景 + 独立边框)──
@@ -6532,6 +7144,7 @@ function _clScan() {
6532
7144
  ' border-radius: 10px 10px 0 0;',
6533
7145
  ' height: auto !important;',
6534
7146
  ' min-height: auto !important;',
7147
+ ' gap: 6px;',
6535
7148
  ' box-sizing: border-box;',
6536
7149
  '}',
6537
7150
  '.cl-exec-v2 .cl-openagent-header-v2:hover {',
@@ -6569,6 +7182,7 @@ function _clScan() {
6569
7182
  ' border-radius: 12px !important;',
6570
7183
  ' background: #f7f7f8 !important;',
6571
7184
  ' margin: 12px 14px 14px 14px !important;',
7185
+ ' margin-top: 0 !important;',
6572
7186
  ' margin-left: 0 !important;',
6573
7187
  ' position: relative;',
6574
7188
  ' overflow: hidden;',
@@ -6596,7 +7210,6 @@ function _clScan() {
6596
7210
 
6597
7211
  '.cl-exec-v2 .cl-exec-detail-row-v2 {',
6598
7212
  ' display: flex;',
6599
- ' align-items: flex-start;',
6600
7213
  ' gap: 16px;',
6601
7214
  '}',
6602
7215
 
@@ -6608,11 +7221,11 @@ function _clScan() {
6608
7221
  ' min-width: 0;',
6609
7222
  '}',
6610
7223
 
6611
- // ── V2 大头像 80×80 ──
7224
+ // ── V2 大头像 68×68 ──
6612
7225
  '.cl-exec-v2 .cl-exec-agent-avatar-v2 {',
6613
- ' width: 80px !important;',
6614
- ' height: 80px !important;',
6615
- ' border-radius: 16px !important;',
7226
+ ' width: 68px !important;',
7227
+ ' height: 68px !important;',
7228
+ ' border-radius: 50% !important;',
6616
7229
  ' object-fit: cover;',
6617
7230
  ' flex-shrink: 0;',
6618
7231
  '}',
@@ -6746,12 +7359,33 @@ function _clScan() {
6746
7359
  ' font-weight: 500;',
6747
7360
  ' white-space: nowrap;',
6748
7361
  '}',
7362
+
7363
+ // ── chat-text 下 p 标签样式 ──
7364
+ '.cl-remote-agent-card .chat-text p {',
7365
+ ' color: #2F2F33 !important;',
7366
+ ' text-align: justify;',
7367
+ ' font-family: "PingFang SC" !important;',
7368
+ ' font-size: 14px !important;',
7369
+ ' font-style: normal !important;',
7370
+ ' font-weight: 400 !important;',
7371
+ ' line-height: 132% !important;',
7372
+ '}',
7373
+
7374
+ // ── chat-text 下 code 标签样式(去背景、去边框、加粗)──
7375
+ '.chat-text code,',
7376
+ '.cl-remote-agent-card .chat-text code,',
7377
+ '.cl-remote-agent-card .chat-text p code {',
7378
+ ' background: transparent !important;',
7379
+ ' border: none !important;',
7380
+ ' font-weight: 700 !important;',
7381
+ '}',
6749
7382
  ].join('\n');
6750
7383
  document.head.appendChild(style);
6751
7384
  // ── 局部 host-shell 标记(不做全局扫描)──
6752
7385
  // 只处理当前 cardNode 的祖先链路,不 querySelectorAll 全局
6753
7386
  window._clMarkRemoteAgentHostShell = function _clMarkRemoteAgentHostShell(cardNode) {
6754
7387
  try {
7388
+ var hostAdapter = CL.hostAdapter || {};
6755
7389
  var node = cardNode && cardNode.parentElement;
6756
7390
  var hops = 0;
6757
7391
  while (node && node !== document.body && hops < 10) {
@@ -6764,17 +7398,8 @@ function _clScan() {
6764
7398
 
6765
7399
  var shouldMark = false;
6766
7400
  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
- );
7401
+ if (typeof hostAdapter.isMarkableHost === 'function') {
7402
+ shouldMark = hostAdapter.isMarkableHost(node);
6778
7403
  }
6779
7404
 
6780
7405
  if (shouldMark && node.classList) {
@@ -7367,6 +7992,73 @@ function _clInferToolCardKind(card) {
7367
7992
  return 'call';
7368
7993
  }
7369
7994
 
7995
+ function _clPickAgentDescription(source) {
7996
+ if (!source) return '';
7997
+ var keys = [
7998
+ 'agent_bio',
7999
+ 'agentBio',
8000
+ 'bio',
8001
+ 'description',
8002
+ 'desc',
8003
+ 'agent_description',
8004
+ 'agentDescription',
8005
+ 'MOM',
8006
+ 'mom',
8007
+ 'introduction',
8008
+ 'summary'
8009
+ ];
8010
+ for (var i = 0; i < keys.length; i++) {
8011
+ var value = source[keys[i]];
8012
+ if (typeof value === 'string' && value.trim()) return value.trim();
8013
+ }
8014
+ return '';
8015
+ }
8016
+
8017
+ function _clIsFailureStatusValue(value) {
8018
+ var normalized = String(value || '').trim().toLowerCase();
8019
+ return normalized === 'failed'
8020
+ || normalized === 'failure'
8021
+ || normalized === 'error'
8022
+ || normalized === 'errored'
8023
+ || normalized === 'rejected'
8024
+ || normalized === 'cancelled'
8025
+ || normalized === 'canceled';
8026
+ }
8027
+
8028
+ function _clLooksLikeRemoteFailureText(text) {
8029
+ var value = String(text || '').trim();
8030
+ if (!value || value.length > 300) return false;
8031
+ return /(^|[,。;\s])(调用失败|执行失败|任务失败|远端服务目前连不上|远端服务.*不可用|两次都返回了调用失败)([,。;\s]|$)/.test(value);
8032
+ }
8033
+
8034
+ function _clInferToolCardError(card, chunks, rawText) {
8035
+ if (chunks && chunks.some(function(c) { return c && c.type === 'error'; })) return true;
8036
+ if (!card) return _clLooksLikeRemoteFailureText(rawText);
8037
+ if (card.isError === true || card.error === true) return true;
8038
+ if (_clIsFailureStatusValue(card.status)
8039
+ || _clIsFailureStatusValue(card.state)
8040
+ || _clIsFailureStatusValue(card.resultStatus)) {
8041
+ return true;
8042
+ }
8043
+ if (card.error && typeof card.error === 'object') return true;
8044
+ return _clLooksLikeRemoteFailureText(rawText);
8045
+ }
8046
+
8047
+ function _clApplyAgentIdentityToModel(model) {
8048
+ if (!model || typeof CL === 'undefined' || !CL || typeof CL.getAgentIdentity !== 'function') return model;
8049
+ var identity = CL.getAgentIdentity(model.agentId, model.agentName);
8050
+ if (!identity) return model;
8051
+ model.agentId = model.agentId || identity.id || identity.agent_id;
8052
+ if (!model.agentName || model.agentName === 'Remote Agent') {
8053
+ model.agentName = identity.name || model.agentName;
8054
+ }
8055
+ model.agentAvatar = model.agentAvatar || identity.avatar || identity.avatar_url || identity.avatarUrl || null;
8056
+ if (!model.agentBio) {
8057
+ model.agentBio = _clPickAgentDescription(identity);
8058
+ }
8059
+ return model;
8060
+ }
8061
+
7370
8062
  function _clParseToolCardModel(card) {
7371
8063
  var inferredKind = _clInferToolCardKind(card);
7372
8064
 
@@ -7375,7 +8067,7 @@ function _clParseToolCardModel(card) {
7375
8067
  var agentId = args.agent_id || args.agentId || null;
7376
8068
  var agentName = args.agent_name || args.agentName || agentId || 'Remote Agent';
7377
8069
  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 || '';
8070
+ var agentBio = _clPickAgentDescription(args);
7379
8071
  var agentStars = args.agent_stars || args.agentStars || args.stars || args.claws || '3.2万';
7380
8072
  var taskText = args.task || args.message || args.instruction || '';
7381
8073
 
@@ -7386,7 +8078,7 @@ function _clParseToolCardModel(card) {
7386
8078
  rawText: rawText
7387
8079
  });
7388
8080
  var hasOutput = inferredKind === 'result' && rawText.trim().length > 0;
7389
- var isError = chunks.some(function(c) { return c.type === 'error'; });
8081
+ var isError = _clInferToolCardError(card, chunks, rawText);
7390
8082
 
7391
8083
  var model = {
7392
8084
  agentId: agentId,
@@ -7396,7 +8088,7 @@ function _clParseToolCardModel(card) {
7396
8088
  agentStars: agentStars,
7397
8089
  taskText: taskText,
7398
8090
  toolCallId: card.toolCallId || '',
7399
- status: hasOutput ? 'completed' : 'executing',
8091
+ status: isError ? 'failed' : (hasOutput ? 'completed' : 'executing'),
7400
8092
  rawText: rawText,
7401
8093
  text: rawText,
7402
8094
  outputText: rawText,
@@ -7404,8 +8096,9 @@ function _clParseToolCardModel(card) {
7404
8096
  isError: isError,
7405
8097
  inferredKind: inferredKind,
7406
8098
  };
8099
+ _clApplyAgentIdentityToModel(model);
7407
8100
 
7408
- console.log('[cl-model] parsed:', 'agent=' + agentName,
8101
+ console.log('[cl-model] parsed:', 'agent=' + model.agentName,
7409
8102
  'status=' + model.status,
7410
8103
  'chunks=' + chunks.length,
7411
8104
  'error=' + isError);
@@ -7477,9 +8170,10 @@ function _clRenderExecutionCard(model) {
7477
8170
  var avatarEl = container.querySelector('.cl-exec-agent-avatar');
7478
8171
  var nameEl = container.querySelector('.cl-exec-agent-name');
7479
8172
  var bioEl = container.querySelector('.cl-exec-agent-bio');
8173
+ var agentBio = _clGetAgentDescriptionText(agent);
7480
8174
  // avatar 保持 icon.png,不覆盖
7481
8175
  if (nameEl) nameEl.textContent = agent.name || model.agentName;
7482
- if (bioEl && (agent.bio || agent.description)) bioEl.textContent = agent.bio || agent.description;
8176
+ if (bioEl && agentBio) bioEl.textContent = agentBio;
7483
8177
  var starsEl = container.querySelector('.cl-exec-star-count');
7484
8178
  if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
7485
8179
  if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
@@ -7495,6 +8189,42 @@ function _clRenderExecutionCard(model) {
7495
8189
  return container;
7496
8190
  }
7497
8191
 
8192
+ function _clGetAgentDescriptionText(model) {
8193
+ if (typeof _clPickAgentDescription === 'function') {
8194
+ var direct = _clPickAgentDescription(model || {});
8195
+ if (direct) return direct;
8196
+ if (model && typeof CL !== 'undefined' && CL && typeof CL.getAgentIdentity === 'function') {
8197
+ var identity = CL.getAgentIdentity(
8198
+ model.agentId || model.agent_id || model.id || model.tag,
8199
+ model.agentName || model.agent_name || model.name
8200
+ );
8201
+ var identityBio = _clPickAgentDescription(identity || {});
8202
+ if (identityBio) return identityBio;
8203
+ }
8204
+ return '';
8205
+ }
8206
+ if (!model) return '';
8207
+ return model.agentBio || model.bio || model.description || model.desc || model.agentDescription || model.agent_description || model.MOM || '';
8208
+ }
8209
+
8210
+ function _clSyncOutputFooterVisibility(card, isCollapsed) {
8211
+ if (!card || !card.querySelector || !card.querySelector('.cl-openagent-header--output')) return;
8212
+ var footers = card.querySelectorAll('.cl-output-footer');
8213
+ for (var i = 0; i < footers.length; i++) {
8214
+ footers[i].style.display = isCollapsed ? 'none' : '';
8215
+ }
8216
+ }
8217
+
8218
+ function _clGetAgentStatusText(status) {
8219
+ if (status === 'completed') return '执行已完成';
8220
+ if (status === 'failed' || status === 'error') return '执行失败';
8221
+ return '正在执行任务';
8222
+ }
8223
+
8224
+ function _clIsAgentTerminalStatus(status) {
8225
+ return status === 'completed' || status === 'failed' || status === 'error';
8226
+ }
8227
+
7498
8228
  // ── Agent 详情卡片(Figma 266:11136) ──
7499
8229
  function _clCreateAgentDetailCard(model) {
7500
8230
  var card = document.createElement('div');
@@ -7527,7 +8257,7 @@ function _clCreateAgentDetailCard(model) {
7527
8257
  // 星级徽章
7528
8258
  var starBadge = document.createElement('div');
7529
8259
  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>';
8260
+ 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
8261
  starBadge.innerHTML = starSvgOutline +
7532
8262
  '<span class="cl-exec-star-count">' + (model.agentStars || '3.2万') + '</span>';
7533
8263
  nameRow.appendChild(starBadge);
@@ -7535,7 +8265,7 @@ function _clCreateAgentDetailCard(model) {
7535
8265
 
7536
8266
  var bioEl = document.createElement('p');
7537
8267
  bioEl.className = 'cl-exec-agent-bio';
7538
- bioEl.textContent = model.agentBio || '智能行程规划·定制每日行程·优化路线安排';
8268
+ bioEl.textContent = _clGetAgentDescriptionText(model);
7539
8269
  info.appendChild(bioEl);
7540
8270
 
7541
8271
  row.appendChild(info);
@@ -7564,8 +8294,6 @@ function _clCreateOpenAgentHeader(model) {
7564
8294
  // OASN 小图标
7565
8295
  var oasnBadge = document.createElement('span');
7566
8296
  oasnBadge.className = 'cl-openagent-badge';
7567
- oasnBadge.style.backgroundImage = "url(./icon.png)";
7568
- oasnBadge.style.backgroundSize = 'cover';
7569
8297
  header.appendChild(oasnBadge);
7570
8298
 
7571
8299
  // 文字行
@@ -7584,7 +8312,7 @@ function _clCreateOpenAgentHeader(model) {
7584
8312
 
7585
8313
  var labelStatus = document.createElement('span');
7586
8314
  labelStatus.className = 'cl-openagent-status';
7587
- labelStatus.textContent = (model.status === 'completed') ? '执行已完成' : '正在执行任务';
8315
+ labelStatus.textContent = _clGetAgentStatusText(model.status);
7588
8316
  textRow.appendChild(labelStatus);
7589
8317
 
7590
8318
  header.appendChild(textRow);
@@ -7597,6 +8325,7 @@ function _clCreateOpenAgentHeader(model) {
7597
8325
  var content = card.querySelector('.cl-thought-chain-content');
7598
8326
  if (!content) return;
7599
8327
  var isCollapsed = content.classList.toggle('cl-content-collapsed');
8328
+ _clSyncOutputFooterVisibility(card, isCollapsed);
7600
8329
  // 切换图标
7601
8330
  expandIcon.innerHTML = isCollapsed
7602
8331
  ? '<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 +8425,9 @@ function _clCreateStepElement(step, isLatest) {
7696
8425
  // ── 动态更新 header 状态文字 ──
7697
8426
  function _clUpdateAgentStatusText(cardNode, status) {
7698
8427
  var label = cardNode && cardNode.querySelector('.cl-openagent-status');
7699
- if (label) label.textContent = (status === 'completed') ? '执行已完成' : '正在执行任务';
8428
+ if (label) label.textContent = _clGetAgentStatusText(status);
7700
8429
  var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row');
7701
- if (progressRow) progressRow.style.display = (status === 'completed') ? 'none' : '';
8430
+ if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7702
8431
  }
7703
8432
 
7704
8433
  function _cl_formatStarCount(count) {
@@ -7780,8 +8509,9 @@ function _clRenderExecutionCardV2(model) {
7780
8509
  var avatarEl = container.querySelector('.cl-exec-agent-avatar-v2');
7781
8510
  var nameEl = container.querySelector('.cl-exec-agent-name-v2');
7782
8511
  var bioEl = container.querySelector('.cl-exec-agent-bio-v2');
8512
+ var agentBio = _clGetAgentDescriptionText(agent);
7783
8513
  if (nameEl) nameEl.textContent = agent.name || model.agentName;
7784
- if (bioEl && (agent.bio || agent.description)) bioEl.textContent = agent.bio || agent.description;
8514
+ if (bioEl && agentBio) bioEl.textContent = agentBio;
7785
8515
  var starsEl = container.querySelector('.cl-exec-star-count-v2');
7786
8516
  if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
7787
8517
  if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
@@ -7826,7 +8556,7 @@ function _clCreateOpenAgentHeaderV2(model) {
7826
8556
 
7827
8557
  var labelStatus = document.createElement('span');
7828
8558
  labelStatus.className = 'cl-openagent-status';
7829
- labelStatus.textContent = (model.status === 'completed') ? '执行已完成' : '正在执行任务';
8559
+ labelStatus.textContent = _clGetAgentStatusText(model.status);
7830
8560
  textRow.appendChild(labelStatus);
7831
8561
 
7832
8562
  header.appendChild(textRow);
@@ -7839,6 +8569,7 @@ function _clCreateOpenAgentHeaderV2(model) {
7839
8569
  var content = card.querySelector('.cl-thought-chain-content');
7840
8570
  if (!content) return;
7841
8571
  var isCollapsed = content.classList.toggle('cl-content-collapsed');
8572
+ _clSyncOutputFooterVisibility(card, isCollapsed);
7842
8573
  expandIcon.innerHTML = isCollapsed
7843
8574
  ? '<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
8575
  : expandedSvg;
@@ -7879,7 +8610,7 @@ function _clCreateAgentDetailCardV2(model) {
7879
8610
  // 描述文字
7880
8611
  var bioEl = document.createElement('p');
7881
8612
  bioEl.className = 'cl-exec-agent-bio cl-exec-agent-bio-v2';
7882
- bioEl.textContent = model.agentBio || '智能行程规划·定制每日行程·优化路线安排';
8613
+ bioEl.textContent = _clGetAgentDescriptionText(model);
7883
8614
  info.appendChild(bioEl);
7884
8615
 
7885
8616
  row.appendChild(info);
@@ -7888,7 +8619,7 @@ function _clCreateAgentDetailCardV2(model) {
7888
8619
  // 星级徽章右置到卡片右上角
7889
8620
  var starBadge = document.createElement('div');
7890
8621
  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>';
8622
+ 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
8623
  starBadge.innerHTML = starSvgOutline +
7893
8624
  '<span class="cl-exec-star-count cl-exec-star-count-v2">' + (model.agentStars || '3.2万') + '</span>';
7894
8625
  card.appendChild(starBadge);
@@ -7899,15 +8630,15 @@ function _clCreateAgentDetailCardV2(model) {
7899
8630
  // ── V2 状态文字更新 ──
7900
8631
  function _clUpdateAgentStatusTextV2(cardNode, status) {
7901
8632
  var label = cardNode && cardNode.querySelector('.cl-openagent-status');
7902
- if (label) label.textContent = (status === 'completed') ? '执行已完成' : '正在执行任务';
8633
+ if (label) label.textContent = _clGetAgentStatusText(status);
7903
8634
  // 进度文字行:完成后隐藏
7904
8635
  var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row-v2');
7905
- if (progressRow) progressRow.style.display = (status === 'completed') ? 'none' : '';
8636
+ if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7906
8637
  // 步骤列表:完成后隐藏
7907
8638
  var stepsBody = cardNode && cardNode.querySelector('.cl-tools-collapse-body-v2');
7908
- if (stepsBody) stepsBody.style.display = (status === 'completed') ? 'none' : '';
8639
+ if (stepsBody) stepsBody.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7909
8640
  var stepsHeader = cardNode && cardNode.querySelector('.cl-tools-collapse-header-v2');
7910
- if (stepsHeader) stepsHeader.style.display = (status === 'completed') ? 'none' : '';
8641
+ if (stepsHeader) stepsHeader.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
7911
8642
  }
7912
8643
 
7913
8644
  // ════════════════════════════════════════════════════════════════
@@ -8364,6 +9095,9 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8364
9095
  ? _clStripOpenagentMediaLines(chunk.text)
8365
9096
  : chunk.text;
8366
9097
  if (_clShouldRenderOutputText(textChunk)) resultTexts.push(textChunk);
9098
+ } else if (chunk.type === 'error') {
9099
+ var errorText = chunk.text || model.rawText || '远端 Agent 调用失败';
9100
+ if (_clShouldRenderOutputText(errorText)) resultTexts.push(errorText);
8367
9101
  }
8368
9102
  }
8369
9103
 
@@ -8408,13 +9142,13 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8408
9142
  }
8409
9143
 
8410
9144
  model._outputMode = true;
8411
- model.status = 'completed';
9145
+ model.status = model.isError ? 'failed' : 'completed';
8412
9146
  if (isV2) {
8413
9147
  var v2Header = _clCreateOpenAgentHeaderV2(model);
8414
9148
  v2Header.classList.remove('cl-openagent-header--output');
8415
9149
  container.appendChild(v2Header);
8416
9150
  if (typeof _clUpdateAgentStatusTextV2 === 'function') {
8417
- _clUpdateAgentStatusTextV2(container, 'completed');
9151
+ _clUpdateAgentStatusTextV2(container, model.status);
8418
9152
  }
8419
9153
  } else {
8420
9154
  var shellHeader = _clCreateOpenAgentHeader(model);
@@ -8509,8 +9243,11 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8509
9243
  var avatarElV2 = container.querySelector('.cl-exec-agent-avatar-v2');
8510
9244
  var nameElV2 = container.querySelector('.cl-exec-agent-name-v2');
8511
9245
  var bioElV2 = container.querySelector('.cl-exec-agent-bio-v2');
9246
+ var agentBioV2 = typeof _clGetAgentDescriptionText === 'function'
9247
+ ? _clGetAgentDescriptionText(agent)
9248
+ : (agent.bio || agent.description || '');
8512
9249
  if (nameElV2) nameElV2.textContent = agent.name || model.agentName;
8513
- if (bioElV2 && (agent.bio || agent.description)) bioElV2.textContent = agent.bio || agent.description;
9250
+ if (bioElV2 && agentBioV2) bioElV2.textContent = agentBioV2;
8514
9251
  var starsElV2 = container.querySelector('.cl-exec-star-count-v2');
8515
9252
  if (starsElV2 && agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.claws);
8516
9253
  if (starsElV2 && agent.stars && !agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.stars);
@@ -8520,10 +9257,6 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8520
9257
  }).catch(function() {});
8521
9258
  }
8522
9259
 
8523
- if (typeof _cl_applyCardUiState === 'function') {
8524
- _cl_applyCardUiState(container, model);
8525
- }
8526
-
8527
9260
  // ── Footer ──
8528
9261
  if (isV2) {
8529
9262
  var footerV2 = document.createElement('div');
@@ -8542,6 +9275,10 @@ function _clRenderOutputCard(model, onOpenSidebar) {
8542
9275
  container.appendChild(footer);
8543
9276
  }
8544
9277
 
9278
+ if (typeof _cl_applyCardUiState === 'function') {
9279
+ _cl_applyCardUiState(container, model);
9280
+ }
9281
+
8545
9282
  console.log('[cl-output] ✅ output card built: results=' + resultTexts.length + ' v2=' + isV2);
8546
9283
  return container;
8547
9284
  }
@@ -9189,6 +9926,15 @@ window.__openagentRenderToolCard = function(card, onOpenSidebar) {
9189
9926
 
9190
9927
  model.toolCallId = resTcid;
9191
9928
  model.cardKind = 'result';
9929
+ if (model.isError) {
9930
+ var executionNodeForResult = (resState && resState.cardNode)
9931
+ || (resTcid ? __cl_executionCardCache.get(resTcid) : null);
9932
+ if (executionNodeForResult && executionNodeForResult.classList && executionNodeForResult.classList.contains('cl-exec-v2')) {
9933
+ if (typeof _clUpdateAgentStatusTextV2 === 'function') _clUpdateAgentStatusTextV2(executionNodeForResult, 'failed');
9934
+ } else if (executionNodeForResult && typeof _clUpdateAgentStatusText === 'function') {
9935
+ _clUpdateAgentStatusText(executionNodeForResult, 'failed');
9936
+ }
9937
+ }
9192
9938
 
9193
9939
  // 缓存:同一 toolCallId 的 output card 只创建一次,Lit 重复调用时复用
9194
9940
  var cachedOutput = resTcid ? __cl_outputCardCache.get(resTcid) : null;
@@ -9313,26 +10059,32 @@ function _cl_isRemoteRawTextContent(text) {
9313
10059
  return false;
9314
10060
  }
9315
10061
 
10062
+ function _cl_getHostAdapter() {
10063
+ return (typeof CL !== 'undefined' && CL.hostAdapter) ? CL.hostAdapter : {};
10064
+ }
10065
+
9316
10066
  function _cl_collectRawTextHosts(node) {
9317
10067
  var hosts = [];
10068
+ var adapter = _cl_getHostAdapter();
10069
+ var selectors = adapter.selectors && adapter.selectors.rawTextHostClosest;
9318
10070
  function add(host) {
9319
10071
  if (!host || hosts.indexOf(host) !== -1) return;
9320
10072
  hosts.push(host);
9321
10073
  }
9322
10074
  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'));
10075
+ if (node.closest && Array.isArray(selectors)) {
10076
+ for (var i = 0; i < selectors.length; i++) {
10077
+ add(node.closest(selectors[i]));
10078
+ }
9328
10079
  }
9329
10080
  return hosts;
9330
10081
  }
9331
10082
 
9332
10083
  function _cl_hideRawTextInHost(host) {
9333
10084
  if (!host || !host.querySelectorAll) return;
10085
+ var adapter = _cl_getHostAdapter();
9334
10086
  host.classList.add('cl-remote-agent-raw-hidden');
9335
- if (host.classList.contains('chat-tools-collapse__body') || host.classList.contains('chat-tool-msg-body')) {
10087
+ if (adapter.isToolBody && adapter.isToolBody(host)) {
9336
10088
  host.classList.add('cl-remote-agent-host-shell');
9337
10089
  }
9338
10090
  var texts = host.querySelectorAll(':scope > .chat-text');
@@ -9343,16 +10095,11 @@ function _cl_hideRawTextInHost(host) {
9343
10095
  }
9344
10096
 
9345
10097
  function _cl_findRemoteNativeToolShell(node) {
10098
+ var adapter = _cl_getHostAdapter();
9346
10099
  var cur = node && (node.nodeType === 1 ? node : node.parentElement);
9347
10100
  var hops = 0;
9348
10101
  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
- )) {
10102
+ if (adapter.isRemoteNativeToolShellCandidate && adapter.isRemoteNativeToolShellCandidate(cur)) {
9356
10103
  if (_cl_isRemoteNativeToolShell(cur)) return cur;
9357
10104
  }
9358
10105
  cur = cur.parentElement;
@@ -9363,14 +10110,12 @@ function _cl_findRemoteNativeToolShell(node) {
9363
10110
 
9364
10111
  function _cl_isRemoteNativeToolShell(shell) {
9365
10112
  if (!shell) return false;
10113
+ var adapter = _cl_getHostAdapter();
10114
+ var summarySelector = adapter.selectors && adapter.selectors.summary;
9366
10115
  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
- );
10116
+ var summary = shell.querySelector && summarySelector
10117
+ ? shell.querySelector(summarySelector)
10118
+ : null;
9374
10119
  if (summary) summaryText = summary.textContent || '';
9375
10120
  if (_cl_isRemoteToolNameText(summaryText)) return true;
9376
10121
 
@@ -9411,27 +10156,23 @@ function _cl_tryHideRemoteRawTextNode(node) {
9411
10156
 
9412
10157
  var shell = _cl_findRemoteNativeToolShell(node);
9413
10158
  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]);
10159
+ var adapter = _cl_getHostAdapter();
10160
+ var hostSelector = adapter.selectors && adapter.selectors.rawTextHostsWithinShell;
10161
+ if (hostSelector) {
10162
+ var hosts = shell.querySelectorAll(hostSelector);
10163
+ for (var h = 0; h < hosts.length; h++) {
10164
+ _cl_hideRawTextInHost(hosts[h]);
10165
+ }
9417
10166
  }
9418
10167
  }
9419
10168
  }
9420
10169
 
9421
10170
  function _cl_findNearestToolLikeShell(node) {
10171
+ var adapter = _cl_getHostAdapter();
9422
10172
  var cur = node && (node.nodeType === 1 ? node : node.parentElement);
9423
10173
  var hops = 0;
9424
10174
  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
- )) {
10175
+ if (adapter.isToolLikeShell && adapter.isToolLikeShell(cur)) {
9435
10176
  return cur;
9436
10177
  }
9437
10178
  cur = cur.parentElement;
@@ -9480,15 +10221,11 @@ _cl_installRemoteRawTextObserver();
9480
10221
  // ── 局部打开最近宿主 wrapper(不做全局扫描)──
9481
10222
 
9482
10223
  function _cl_findNearestNativeToolShell(node) {
10224
+ var adapter = _cl_getHostAdapter();
9483
10225
  var cur = node && node.parentElement;
9484
10226
  var hops = 0;
9485
10227
  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
- )) {
10228
+ if (adapter.isNativeToolShell && adapter.isNativeToolShell(cur)) {
9492
10229
  return cur;
9493
10230
  }
9494
10231
  cur = cur.parentElement;
@@ -9516,7 +10253,9 @@ function _cl_forceOpenNativeToolDetails(node, source, tcid) {
9516
10253
 
9517
10254
  if (shell.classList && !shell.classList.contains('is-open')) {
9518
10255
  shell.classList.add('is-open');
9519
- var header = shell.querySelector('.chat-tool-msg-summary, .chat-tools-summary');
10256
+ var adapter = _cl_getHostAdapter();
10257
+ var headerSelector = (adapter.selectors && adapter.selectors.forceOpenHeader) || '';
10258
+ var header = headerSelector ? shell.querySelector(headerSelector) : null;
9520
10259
  if (header) header.setAttribute('aria-expanded', 'true');
9521
10260
  console.log('[cl-render] 🔓 opened native collapse source=' + source
9522
10261
  + ' tcid=' + String(tcid || '').substring(0, 8));
@@ -9592,6 +10331,9 @@ function _cl_applyCardUiState(container, modelOrNode) {
9592
10331
  content.classList.remove('cl-content-collapsed');
9593
10332
  if (caret) caret.textContent = '▼';
9594
10333
  }
10334
+ if (typeof _clSyncOutputFooterVisibility === 'function') {
10335
+ _clSyncOutputFooterVisibility(container, state.contentCollapsed);
10336
+ }
9595
10337
  }
9596
10338
 
9597
10339
  var body = container.querySelector('.cl-tools-collapse-body');
@@ -9622,7 +10364,9 @@ function _cl_applyStoredRecordToModel(model, record) {
9622
10364
  model.agentAvatar = args.agent_avatar || args.agentAvatar || args.avatar || args.avatar_url || args.avatarUrl || null;
9623
10365
  }
9624
10366
  if (!model.agentBio) {
9625
- model.agentBio = args.agent_bio || args.agentBio || '';
10367
+ model.agentBio = typeof _clPickAgentDescription === 'function'
10368
+ ? _clPickAgentDescription(args)
10369
+ : (args.agent_bio || args.agentBio || args.description || args.agent_description || args.MOM || '');
9626
10370
  }
9627
10371
  if (!model.agentStars) {
9628
10372
  model.agentStars = args.agent_stars || args.agentStars || '3.2万';
@@ -9634,6 +10378,11 @@ function _cl_applyStoredRecordToModel(model, record) {
9634
10378
  model.agentId = model.agentId || identity.id || identity.agent_id;
9635
10379
  model.agentName = (model.agentName && model.agentName !== 'Remote Agent') ? model.agentName : (identity.name || model.agentName);
9636
10380
  model.agentAvatar = model.agentAvatar || identity.avatar || null;
10381
+ if (!model.agentBio) {
10382
+ model.agentBio = typeof _clPickAgentDescription === 'function'
10383
+ ? _clPickAgentDescription(identity)
10384
+ : (identity.bio || identity.description || identity.agent_bio || identity.agentBio || identity.MOM || '');
10385
+ }
9637
10386
  }
9638
10387
  model.taskText = model.taskText || args.task || args.message || args.instruction || '';
9639
10388
  }