openclaw-openagent 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -1
- package/dist/src/app/remote-agent-tool.js +110 -14
- package/dist/src/app/types.d.ts +2 -2
- package/dist/src/config/config-schema.d.ts +9 -0
- package/dist/src/config/config-schema.js +6 -0
- package/dist/src/plugin-ui/adapters/adapters/oc-2026-04.js +103 -0
- package/dist/src/plugin-ui/adapters/adapters/oc-2026-05.js +125 -0
- package/dist/src/plugin-ui/adapters/adapters/oc-2026-06.js +125 -0
- package/dist/src/plugin-ui/adapters/adapters/oc-unknown.js +48 -0
- package/dist/src/plugin-ui/adapters/oc-2026-04.js +103 -0
- package/dist/src/plugin-ui/adapters/oc-2026-05.js +125 -0
- package/dist/src/plugin-ui/adapters/oc-2026-06.js +125 -0
- package/dist/src/plugin-ui/adapters/oc-unknown.js +48 -0
- package/dist/src/plugin-ui/assets/openagent-override.js +1129 -273
- package/dist/src/plugin-ui/index.d.ts +1 -1
- package/dist/src/plugin-ui/index.js +2 -2
- package/dist/src/plugin-ui/ui-extension-loader/index.d.ts +2 -1
- package/dist/src/plugin-ui/ui-extension-loader/index.js +5 -5
- package/dist/src/plugin-ui/ui-extension-loader/registry-regex.js +75 -8
- package/dist/src/plugin-ui/ui-extension-loader/types.d.ts +4 -1
- package/dist/src/proxy/auth-proxy.js +5 -0
- package/dist/src/runtime/update-checker.d.ts +18 -0
- package/dist/src/runtime/update-checker.js +253 -0
- package/dist/src/state/store.d.ts +21 -0
- package/dist/src/state/store.js +54 -0
- package/dist/src/transport/oasn/oasn-invocation.d.ts +3 -0
- package/dist/src/transport/oasn/oasn-invocation.js +28 -12
- package/dist/src/transport/oasn/oasn-types.d.ts +8 -4
- package/index.ts +4 -1
- package/package.json +4 -3
- package/src/app/remote-agent-tool.ts +131 -16
- package/src/app/types.ts +2 -2
- package/src/config/config-schema.ts +6 -0
- package/src/plugin-ui/adapters/oc-2026-04.js +103 -0
- package/src/plugin-ui/adapters/oc-2026-05.js +125 -0
- package/src/plugin-ui/adapters/oc-2026-06.js +125 -0
- package/src/plugin-ui/adapters/oc-unknown.js +48 -0
- package/src/plugin-ui/assets/openagent-override.js +1129 -273
- package/src/plugin-ui/build.cjs +249 -38
- package/src/plugin-ui/index.ts +2 -2
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +102 -12
- package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +105 -3
- package/src/plugin-ui/modules/agent-book/panel/styles.js +54 -48
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +4 -2
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +4 -1
- package/src/plugin-ui/modules/agent-book/scanner.js +17 -5
- package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +12 -1
- package/src/plugin-ui/modules/loader/bootstrap.js +95 -0
- package/src/plugin-ui/modules/loader/shared-state.js +244 -20
- package/src/plugin-ui/modules/remote-agent/execution-card.js +54 -16
- package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +5 -23
- package/src/plugin-ui/modules/remote-agent/output-card.js +13 -7
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +53 -41
- package/src/plugin-ui/modules/remote-agent/styles.js +238 -89
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +72 -4
- package/src/plugin-ui/postinstall-deploy.cjs +52 -0
- package/src/plugin-ui/ui-extension-loader/index.ts +6 -6
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +81 -9
- package/src/plugin-ui/ui-extension-loader/types.ts +5 -1
- package/src/proxy/auth-proxy.ts +5 -0
- package/src/runtime/update-checker.ts +286 -0
- package/src/state/store.ts +80 -0
- package/src/transport/oasn/oasn-invocation.ts +47 -12
- package/src/transport/oasn/oasn-types.ts +6 -2
- package/src/types/openclaw-plugin-sdk-media-store.d.ts +9 -0
|
@@ -34,6 +34,9 @@ const CL = {
|
|
|
34
34
|
// ── Host 版本(构建时注入,fallback 运行时检测)──
|
|
35
35
|
hostVersion: '__OPENCLAW_HOST_VERSION__',
|
|
36
36
|
|
|
37
|
+
// ── Override 构建标识(构建时注入,用于缓存自检)──
|
|
38
|
+
buildId: '__OPENAGENT_BUILD_ID__',
|
|
39
|
+
|
|
37
40
|
// ── 配置 ──
|
|
38
41
|
OPENAGENT_API: 'https://api.openagent.club',
|
|
39
42
|
AUTH_API: '/plugins/openagent', // Proxied via Gateway registerHttpRoute (see src/proxy/auth-proxy.ts)
|
|
@@ -42,6 +45,98 @@ const CL = {
|
|
|
42
45
|
CACHE_TTL: 30000,
|
|
43
46
|
};
|
|
44
47
|
|
|
48
|
+
function _clFindOverrideScript() {
|
|
49
|
+
try {
|
|
50
|
+
var scripts = document.querySelectorAll('script[src*="openagent-override.js"]');
|
|
51
|
+
return scripts.length ? scripts[scripts.length - 1] : null;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _clReadOverrideScriptVersionFromDocument() {
|
|
58
|
+
try {
|
|
59
|
+
var script = _clFindOverrideScript();
|
|
60
|
+
if (!script) return '';
|
|
61
|
+
var src = script.getAttribute('src') || '';
|
|
62
|
+
var url = new URL(src, window.location.href);
|
|
63
|
+
return url.searchParams.get('v') || '';
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function _clResolveControlUiIndexUrl() {
|
|
70
|
+
try {
|
|
71
|
+
var script = _clFindOverrideScript();
|
|
72
|
+
if (script) {
|
|
73
|
+
var scriptUrl = new URL(script.src || script.getAttribute('src'), window.location.href);
|
|
74
|
+
return new URL('./', scriptUrl.href).href;
|
|
75
|
+
}
|
|
76
|
+
} catch (e) {}
|
|
77
|
+
try {
|
|
78
|
+
var url = new URL(window.location.href);
|
|
79
|
+
url.hash = '';
|
|
80
|
+
url.search = '';
|
|
81
|
+
return url.href;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return '/';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _clExtractOverrideScriptVersionFromHtml(html) {
|
|
88
|
+
var match = String(html || '').match(/openagent-override\.js\?v=([A-Za-z0-9._-]+)/);
|
|
89
|
+
return match ? match[1] : '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function _clInstallOverrideUpdateCheck() {
|
|
93
|
+
if (window.__openagentOverrideUpdateCheckInstalled) return;
|
|
94
|
+
window.__openagentOverrideUpdateCheckInstalled = true;
|
|
95
|
+
|
|
96
|
+
var currentVersion = _clReadOverrideScriptVersionFromDocument() || CL.buildId || '';
|
|
97
|
+
var storageKey = 'openagent.overrideScriptVersion.v1';
|
|
98
|
+
var reloadKey = 'openagent.overrideReloadedVersion.v1';
|
|
99
|
+
try {
|
|
100
|
+
document.documentElement.setAttribute('data-openagent-build-id', CL.buildId || 'unknown');
|
|
101
|
+
if (currentVersion) document.documentElement.setAttribute('data-openagent-script-version', currentVersion);
|
|
102
|
+
} catch (e) {}
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
if (window.localStorage && currentVersion) {
|
|
106
|
+
window.localStorage.setItem(storageKey, currentVersion);
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {}
|
|
109
|
+
|
|
110
|
+
function reloadForVersion(nextVersion) {
|
|
111
|
+
if (!nextVersion || nextVersion === currentVersion) return;
|
|
112
|
+
try {
|
|
113
|
+
if (window.sessionStorage && window.sessionStorage.getItem(reloadKey) === nextVersion) return;
|
|
114
|
+
if (window.sessionStorage) window.sessionStorage.setItem(reloadKey, nextVersion);
|
|
115
|
+
} catch (e) {}
|
|
116
|
+
console.info('[openagent] override updated, reloading Control UI', currentVersion, '→', nextVersion);
|
|
117
|
+
window.location.reload();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function checkLatestOverrideVersion() {
|
|
121
|
+
if (document.visibilityState && document.visibilityState === 'hidden') return;
|
|
122
|
+
try {
|
|
123
|
+
var res = await fetch(_clResolveControlUiIndexUrl(), { cache: 'no-store' });
|
|
124
|
+
if (!res || !res.ok) return;
|
|
125
|
+
var latestVersion = _clExtractOverrideScriptVersionFromHtml(await res.text());
|
|
126
|
+
reloadForVersion(latestVersion);
|
|
127
|
+
} catch (e) {}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setTimeout(checkLatestOverrideVersion, 3000);
|
|
131
|
+
setInterval(checkLatestOverrideVersion, 60000);
|
|
132
|
+
window.addEventListener('focus', checkLatestOverrideVersion);
|
|
133
|
+
document.addEventListener('visibilitychange', function() {
|
|
134
|
+
if (!document.hidden) checkLatestOverrideVersion();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
_clInstallOverrideUpdateCheck();
|
|
139
|
+
|
|
45
140
|
// ── 版本解析与比较(供 execution-card V2 分支使用)──
|
|
46
141
|
|
|
47
142
|
function _clParseHostVersion(v) {
|
|
@@ -57,6 +152,9 @@ function _clParseHostVersion(v) {
|
|
|
57
152
|
}
|
|
58
153
|
|
|
59
154
|
function _clIsHostVersionGte(minVer) {
|
|
155
|
+
if (CL.hostVersionSource !== 'exact' && CL.hostVersionSource !== 'script' && CL.hostVersionSource !== 'runtime') {
|
|
156
|
+
_clRefreshHostVersionFromRuntime();
|
|
157
|
+
}
|
|
60
158
|
var cur = _clParseHostVersion(CL.hostVersion || '');
|
|
61
159
|
var min = _clParseHostVersion(minVer);
|
|
62
160
|
for (var i = 0; i < 3; i++) {
|
|
@@ -66,31 +164,131 @@ function _clIsHostVersionGte(minVer) {
|
|
|
66
164
|
return true;
|
|
67
165
|
}
|
|
68
166
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (
|
|
167
|
+
function _clResolveHostProfile(version) {
|
|
168
|
+
var parsed = _clParseHostVersion(version || '');
|
|
169
|
+
if (parsed[0] === 2026 && parsed[1] === 4) return 'oc-2026-04';
|
|
170
|
+
if (parsed[0] === 2026 && parsed[1] === 5) return 'oc-2026-05';
|
|
171
|
+
if (parsed[0] === 2026 && parsed[1] === 6) return 'oc-2026-06';
|
|
172
|
+
return 'oc-unknown';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function _clNormalizeHostVersion(value) {
|
|
176
|
+
var match = String(value || '').match(/20\d{2}\.\d{1,2}\.\d{1,2}(?:-[A-Za-z0-9._-]+)?/);
|
|
177
|
+
return match ? match[0] : '';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function _clGetByPath(root, path) {
|
|
181
|
+
var cur = root;
|
|
182
|
+
for (var i = 0; i < path.length; i++) {
|
|
183
|
+
if (!cur) return '';
|
|
184
|
+
cur = cur[path[i]];
|
|
185
|
+
}
|
|
186
|
+
return cur;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function _clReadHostVersionFromRuntime() {
|
|
73
190
|
try {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
191
|
+
var scripts = document.querySelectorAll('script[data-openagent-host-version]');
|
|
192
|
+
for (var i = scripts.length - 1; i >= 0; i--) {
|
|
193
|
+
var scriptVersion = _clNormalizeHostVersion(scripts[i].getAttribute('data-openagent-host-version'));
|
|
194
|
+
if (scriptVersion) return { version: scriptVersion, source: 'script' };
|
|
195
|
+
}
|
|
196
|
+
} catch (e) {}
|
|
197
|
+
|
|
198
|
+
var globals = [
|
|
199
|
+
window.__OPENCLAW_HOST_VERSION__,
|
|
200
|
+
window.__OPENCLAW_VERSION__,
|
|
201
|
+
window.__openclawVersion,
|
|
202
|
+
window.openclawVersion,
|
|
203
|
+
];
|
|
204
|
+
for (var g = 0; g < globals.length; g++) {
|
|
205
|
+
var globalVersion = _clNormalizeHostVersion(globals[g]);
|
|
206
|
+
if (globalVersion) return { version: globalVersion, source: 'runtime' };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
var metaVersion = _clNormalizeHostVersion(
|
|
211
|
+
document.querySelector('meta[name="openclaw-version"],meta[name="openclaw:version"]')?.getAttribute('content')
|
|
212
|
+
);
|
|
213
|
+
if (metaVersion) return { version: metaVersion, source: 'runtime' };
|
|
214
|
+
} catch (e) {}
|
|
215
|
+
|
|
216
|
+
try {
|
|
217
|
+
var app = document.querySelector('openclaw-app');
|
|
218
|
+
if (app) {
|
|
219
|
+
var paths = [
|
|
220
|
+
['runtime', 'version'],
|
|
221
|
+
['hello', 'server', 'version'],
|
|
222
|
+
['hello', 'version'],
|
|
223
|
+
['client', 'hello', 'server', 'version'],
|
|
224
|
+
['client', 'version'],
|
|
225
|
+
['version'],
|
|
226
|
+
['appVersion'],
|
|
227
|
+
];
|
|
228
|
+
for (var p = 0; p < paths.length; p++) {
|
|
229
|
+
var appVersion = _clNormalizeHostVersion(_clGetByPath(app, paths[p]));
|
|
230
|
+
if (appVersion) return { version: appVersion, source: 'runtime' };
|
|
88
231
|
}
|
|
89
232
|
}
|
|
90
|
-
|
|
233
|
+
} catch (e) {}
|
|
234
|
+
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function _clApplyHostVersion(version, source) {
|
|
239
|
+
CL.hostVersion = version || '2026.3.0';
|
|
240
|
+
CL.hostVersionSource = source || 'fallback';
|
|
241
|
+
CL.hostProfile = _clResolveHostProfile(CL.hostVersion);
|
|
242
|
+
try {
|
|
243
|
+
document.documentElement.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
|
|
244
|
+
document.documentElement.setAttribute('data-openagent-host-profile', CL.hostProfile);
|
|
245
|
+
document.documentElement.setAttribute('data-openagent-host-version-source', CL.hostVersionSource);
|
|
246
|
+
} catch (e) {}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function _clRefreshHostVersionFromRuntime() {
|
|
250
|
+
var detected = _clReadHostVersionFromRuntime();
|
|
251
|
+
if (!detected) return false;
|
|
252
|
+
if (detected.version !== CL.hostVersion || detected.source !== CL.hostVersionSource) {
|
|
253
|
+
_clApplyHostVersion(detected.version, detected.source);
|
|
254
|
+
console.log('[cl-version] detected via ' + detected.source + ': ' + detected.version);
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function _clScheduleHostVersionRefresh() {
|
|
260
|
+
var attempts = 0;
|
|
261
|
+
var timer = setInterval(function() {
|
|
262
|
+
attempts++;
|
|
263
|
+
if (_clRefreshHostVersionFromRuntime() || attempts >= 20) {
|
|
264
|
+
clearInterval(timer);
|
|
265
|
+
}
|
|
266
|
+
}, 500);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
var _clInitialExactVersion = _clNormalizeHostVersion(CL.hostVersion);
|
|
270
|
+
if (_clInitialExactVersion) {
|
|
271
|
+
_clApplyHostVersion(_clInitialExactVersion, 'exact');
|
|
272
|
+
} else if (!_clRefreshHostVersionFromRuntime()) {
|
|
273
|
+
// ─ 运行时 fallback:只做版本族保守判断,避免把 2026.5 误判为 2026.6.9 ──
|
|
274
|
+
// v5.x (2026.5+) 有 data-theme / --glass-*;v4.x 有 data-theme-mode / --vscode-*。
|
|
275
|
+
try {
|
|
276
|
+
var cs = getComputedStyle(document.documentElement);
|
|
277
|
+
if (document.documentElement.hasAttribute('data-theme-mode')
|
|
278
|
+
|| cs.getPropertyValue('--vscode-editor-background').trim()) {
|
|
279
|
+
_clApplyHostVersion('2026.4.0', 'feature-fallback');
|
|
280
|
+
} else if (document.documentElement.hasAttribute('data-theme')
|
|
281
|
+
|| cs.getPropertyValue('--glass-surface').trim()
|
|
282
|
+
|| cs.getPropertyValue('--kn-bg-primary').trim()) {
|
|
283
|
+
_clApplyHostVersion('2026.5.0', 'feature-fallback');
|
|
284
|
+
} else {
|
|
285
|
+
_clApplyHostVersion('2026.3.0', 'feature-fallback');
|
|
286
|
+
}
|
|
287
|
+
console.log('[cl-version] fallback via DOM/CSS features: ' + CL.hostVersion);
|
|
91
288
|
} catch (e) {
|
|
92
|
-
|
|
289
|
+
_clApplyHostVersion('2026.3.0', 'feature-fallback');
|
|
93
290
|
}
|
|
291
|
+
_clScheduleHostVersionRefresh();
|
|
94
292
|
}
|
|
95
293
|
|
|
96
294
|
// 暴露到 window 供控制台调试/测试
|
|
@@ -126,6 +324,28 @@ CL._saveAgentIdentityCache = function() {
|
|
|
126
324
|
} catch (err) {}
|
|
127
325
|
};
|
|
128
326
|
|
|
327
|
+
CL.pickAgentIdentityDescription = function(agent) {
|
|
328
|
+
if (!agent || typeof agent !== 'object') return '';
|
|
329
|
+
var keys = [
|
|
330
|
+
'agent_bio',
|
|
331
|
+
'agentBio',
|
|
332
|
+
'bio',
|
|
333
|
+
'description',
|
|
334
|
+
'desc',
|
|
335
|
+
'agent_description',
|
|
336
|
+
'agentDescription',
|
|
337
|
+
'MOM',
|
|
338
|
+
'mom',
|
|
339
|
+
'introduction',
|
|
340
|
+
'summary'
|
|
341
|
+
];
|
|
342
|
+
for (var i = 0; i < keys.length; i++) {
|
|
343
|
+
var value = agent[keys[i]];
|
|
344
|
+
if (typeof value === 'string' && value.trim()) return value.trim();
|
|
345
|
+
}
|
|
346
|
+
return '';
|
|
347
|
+
};
|
|
348
|
+
|
|
129
349
|
CL.storeAgentIdentity = function(agent, fallbackName) {
|
|
130
350
|
if (!agent || typeof agent !== 'object') return null;
|
|
131
351
|
CL._loadAgentIdentityCache();
|
|
@@ -134,12 +354,16 @@ CL.storeAgentIdentity = function(agent, fallbackName) {
|
|
|
134
354
|
agent.user_id || agent.userId || agent.identifier || agent.tim_user_id || agent.timUserId || '';
|
|
135
355
|
var name = agent.name || agent.agent_name || agent.agentName || fallbackName || '';
|
|
136
356
|
var avatar = agent.avatar || agent.avatar_url || agent.avatarUrl || agent.image || agent.logo || agent.photo || '';
|
|
357
|
+
var bio = CL.pickAgentIdentityDescription(agent);
|
|
137
358
|
var record = {
|
|
138
359
|
id: id,
|
|
139
360
|
agent_id: id,
|
|
140
361
|
tag: agent.tag || id,
|
|
141
362
|
name: name,
|
|
142
363
|
avatar: avatar || null,
|
|
364
|
+
bio: bio,
|
|
365
|
+
description: agent.description || bio || '',
|
|
366
|
+
MOM: agent.MOM || agent.mom || '',
|
|
143
367
|
};
|
|
144
368
|
|
|
145
369
|
var keys = [id, record.tag, name, fallbackName].filter(Boolean);
|
|
@@ -58,9 +58,10 @@ function _clRenderExecutionCard(model) {
|
|
|
58
58
|
var avatarEl = container.querySelector('.cl-exec-agent-avatar');
|
|
59
59
|
var nameEl = container.querySelector('.cl-exec-agent-name');
|
|
60
60
|
var bioEl = container.querySelector('.cl-exec-agent-bio');
|
|
61
|
+
var agentBio = _clGetAgentDescriptionText(agent);
|
|
61
62
|
// avatar 保持 icon.png,不覆盖
|
|
62
63
|
if (nameEl) nameEl.textContent = agent.name || model.agentName;
|
|
63
|
-
if (bioEl &&
|
|
64
|
+
if (bioEl && agentBio) bioEl.textContent = agentBio;
|
|
64
65
|
var starsEl = container.querySelector('.cl-exec-star-count');
|
|
65
66
|
if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
|
|
66
67
|
if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
|
|
@@ -76,6 +77,42 @@ function _clRenderExecutionCard(model) {
|
|
|
76
77
|
return container;
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
function _clGetAgentDescriptionText(model) {
|
|
81
|
+
if (typeof _clPickAgentDescription === 'function') {
|
|
82
|
+
var direct = _clPickAgentDescription(model || {});
|
|
83
|
+
if (direct) return direct;
|
|
84
|
+
if (model && typeof CL !== 'undefined' && CL && typeof CL.getAgentIdentity === 'function') {
|
|
85
|
+
var identity = CL.getAgentIdentity(
|
|
86
|
+
model.agentId || model.agent_id || model.id || model.tag,
|
|
87
|
+
model.agentName || model.agent_name || model.name
|
|
88
|
+
);
|
|
89
|
+
var identityBio = _clPickAgentDescription(identity || {});
|
|
90
|
+
if (identityBio) return identityBio;
|
|
91
|
+
}
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
if (!model) return '';
|
|
95
|
+
return model.agentBio || model.bio || model.description || model.desc || model.agentDescription || model.agent_description || model.MOM || '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function _clSyncOutputFooterVisibility(card, isCollapsed) {
|
|
99
|
+
if (!card || !card.querySelector || !card.querySelector('.cl-openagent-header--output')) return;
|
|
100
|
+
var footers = card.querySelectorAll('.cl-output-footer');
|
|
101
|
+
for (var i = 0; i < footers.length; i++) {
|
|
102
|
+
footers[i].style.display = isCollapsed ? 'none' : '';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function _clGetAgentStatusText(status) {
|
|
107
|
+
if (status === 'completed') return '执行已完成';
|
|
108
|
+
if (status === 'failed' || status === 'error') return '执行失败';
|
|
109
|
+
return '正在执行任务';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function _clIsAgentTerminalStatus(status) {
|
|
113
|
+
return status === 'completed' || status === 'failed' || status === 'error';
|
|
114
|
+
}
|
|
115
|
+
|
|
79
116
|
// ── Agent 详情卡片(Figma 266:11136) ──
|
|
80
117
|
function _clCreateAgentDetailCard(model) {
|
|
81
118
|
var card = document.createElement('div');
|
|
@@ -108,7 +145,7 @@ function _clCreateAgentDetailCard(model) {
|
|
|
108
145
|
// 星级徽章
|
|
109
146
|
var starBadge = document.createElement('div');
|
|
110
147
|
starBadge.className = 'cl-exec-star-badge';
|
|
111
|
-
var starSvgOutline = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="
|
|
148
|
+
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>';
|
|
112
149
|
starBadge.innerHTML = starSvgOutline +
|
|
113
150
|
'<span class="cl-exec-star-count">' + (model.agentStars || '3.2万') + '</span>';
|
|
114
151
|
nameRow.appendChild(starBadge);
|
|
@@ -116,7 +153,7 @@ function _clCreateAgentDetailCard(model) {
|
|
|
116
153
|
|
|
117
154
|
var bioEl = document.createElement('p');
|
|
118
155
|
bioEl.className = 'cl-exec-agent-bio';
|
|
119
|
-
bioEl.textContent = model
|
|
156
|
+
bioEl.textContent = _clGetAgentDescriptionText(model);
|
|
120
157
|
info.appendChild(bioEl);
|
|
121
158
|
|
|
122
159
|
row.appendChild(info);
|
|
@@ -145,8 +182,6 @@ function _clCreateOpenAgentHeader(model) {
|
|
|
145
182
|
// OASN 小图标
|
|
146
183
|
var oasnBadge = document.createElement('span');
|
|
147
184
|
oasnBadge.className = 'cl-openagent-badge';
|
|
148
|
-
oasnBadge.style.backgroundImage = "url(./icon.png)";
|
|
149
|
-
oasnBadge.style.backgroundSize = 'cover';
|
|
150
185
|
header.appendChild(oasnBadge);
|
|
151
186
|
|
|
152
187
|
// 文字行
|
|
@@ -165,7 +200,7 @@ function _clCreateOpenAgentHeader(model) {
|
|
|
165
200
|
|
|
166
201
|
var labelStatus = document.createElement('span');
|
|
167
202
|
labelStatus.className = 'cl-openagent-status';
|
|
168
|
-
labelStatus.textContent = (model.status
|
|
203
|
+
labelStatus.textContent = _clGetAgentStatusText(model.status);
|
|
169
204
|
textRow.appendChild(labelStatus);
|
|
170
205
|
|
|
171
206
|
header.appendChild(textRow);
|
|
@@ -178,6 +213,7 @@ function _clCreateOpenAgentHeader(model) {
|
|
|
178
213
|
var content = card.querySelector('.cl-thought-chain-content');
|
|
179
214
|
if (!content) return;
|
|
180
215
|
var isCollapsed = content.classList.toggle('cl-content-collapsed');
|
|
216
|
+
_clSyncOutputFooterVisibility(card, isCollapsed);
|
|
181
217
|
// 切换图标
|
|
182
218
|
expandIcon.innerHTML = isCollapsed
|
|
183
219
|
? '<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>'
|
|
@@ -277,9 +313,9 @@ function _clCreateStepElement(step, isLatest) {
|
|
|
277
313
|
// ── 动态更新 header 状态文字 ──
|
|
278
314
|
function _clUpdateAgentStatusText(cardNode, status) {
|
|
279
315
|
var label = cardNode && cardNode.querySelector('.cl-openagent-status');
|
|
280
|
-
if (label) label.textContent = (status
|
|
316
|
+
if (label) label.textContent = _clGetAgentStatusText(status);
|
|
281
317
|
var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row');
|
|
282
|
-
if (progressRow) progressRow.style.display = (status
|
|
318
|
+
if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
283
319
|
}
|
|
284
320
|
|
|
285
321
|
function _cl_formatStarCount(count) {
|
|
@@ -361,8 +397,9 @@ function _clRenderExecutionCardV2(model) {
|
|
|
361
397
|
var avatarEl = container.querySelector('.cl-exec-agent-avatar-v2');
|
|
362
398
|
var nameEl = container.querySelector('.cl-exec-agent-name-v2');
|
|
363
399
|
var bioEl = container.querySelector('.cl-exec-agent-bio-v2');
|
|
400
|
+
var agentBio = _clGetAgentDescriptionText(agent);
|
|
364
401
|
if (nameEl) nameEl.textContent = agent.name || model.agentName;
|
|
365
|
-
if (bioEl &&
|
|
402
|
+
if (bioEl && agentBio) bioEl.textContent = agentBio;
|
|
366
403
|
var starsEl = container.querySelector('.cl-exec-star-count-v2');
|
|
367
404
|
if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
|
|
368
405
|
if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
|
|
@@ -407,7 +444,7 @@ function _clCreateOpenAgentHeaderV2(model) {
|
|
|
407
444
|
|
|
408
445
|
var labelStatus = document.createElement('span');
|
|
409
446
|
labelStatus.className = 'cl-openagent-status';
|
|
410
|
-
labelStatus.textContent = (model.status
|
|
447
|
+
labelStatus.textContent = _clGetAgentStatusText(model.status);
|
|
411
448
|
textRow.appendChild(labelStatus);
|
|
412
449
|
|
|
413
450
|
header.appendChild(textRow);
|
|
@@ -420,6 +457,7 @@ function _clCreateOpenAgentHeaderV2(model) {
|
|
|
420
457
|
var content = card.querySelector('.cl-thought-chain-content');
|
|
421
458
|
if (!content) return;
|
|
422
459
|
var isCollapsed = content.classList.toggle('cl-content-collapsed');
|
|
460
|
+
_clSyncOutputFooterVisibility(card, isCollapsed);
|
|
423
461
|
expandIcon.innerHTML = isCollapsed
|
|
424
462
|
? '<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>'
|
|
425
463
|
: expandedSvg;
|
|
@@ -460,7 +498,7 @@ function _clCreateAgentDetailCardV2(model) {
|
|
|
460
498
|
// 描述文字
|
|
461
499
|
var bioEl = document.createElement('p');
|
|
462
500
|
bioEl.className = 'cl-exec-agent-bio cl-exec-agent-bio-v2';
|
|
463
|
-
bioEl.textContent = model
|
|
501
|
+
bioEl.textContent = _clGetAgentDescriptionText(model);
|
|
464
502
|
info.appendChild(bioEl);
|
|
465
503
|
|
|
466
504
|
row.appendChild(info);
|
|
@@ -469,7 +507,7 @@ function _clCreateAgentDetailCardV2(model) {
|
|
|
469
507
|
// 星级徽章右置到卡片右上角
|
|
470
508
|
var starBadge = document.createElement('div');
|
|
471
509
|
starBadge.className = 'cl-exec-star-badge cl-exec-star-badge-v2';
|
|
472
|
-
var starSvgOutline = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="
|
|
510
|
+
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>';
|
|
473
511
|
starBadge.innerHTML = starSvgOutline +
|
|
474
512
|
'<span class="cl-exec-star-count cl-exec-star-count-v2">' + (model.agentStars || '3.2万') + '</span>';
|
|
475
513
|
card.appendChild(starBadge);
|
|
@@ -480,13 +518,13 @@ function _clCreateAgentDetailCardV2(model) {
|
|
|
480
518
|
// ── V2 状态文字更新 ──
|
|
481
519
|
function _clUpdateAgentStatusTextV2(cardNode, status) {
|
|
482
520
|
var label = cardNode && cardNode.querySelector('.cl-openagent-status');
|
|
483
|
-
if (label) label.textContent = (status
|
|
521
|
+
if (label) label.textContent = _clGetAgentStatusText(status);
|
|
484
522
|
// 进度文字行:完成后隐藏
|
|
485
523
|
var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row-v2');
|
|
486
|
-
if (progressRow) progressRow.style.display = (status
|
|
524
|
+
if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
487
525
|
// 步骤列表:完成后隐藏
|
|
488
526
|
var stepsBody = cardNode && cardNode.querySelector('.cl-tools-collapse-body-v2');
|
|
489
|
-
if (stepsBody) stepsBody.style.display = (status
|
|
527
|
+
if (stepsBody) stepsBody.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
490
528
|
var stepsHeader = cardNode && cardNode.querySelector('.cl-tools-collapse-header-v2');
|
|
491
|
-
if (stepsHeader) stepsHeader.style.display = (status
|
|
529
|
+
if (stepsHeader) stepsHeader.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
492
530
|
}
|
|
@@ -8,30 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
(function _clInitNativeStyleAdapter() {
|
|
10
10
|
var _clNativeStyleSampled = false;
|
|
11
|
+
var hostAdapter = CL.hostAdapter || {};
|
|
12
|
+
var nativeStyle = hostAdapter.nativeStyle || {};
|
|
11
13
|
|
|
12
|
-
var SHELL_SELECTORS = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'.chat-tools-collapse:not(:has(.cl-remote-agent-card))',
|
|
16
|
-
// v5.x+ variants
|
|
17
|
-
'.tool-card:not(:has(.cl-remote-agent-card))',
|
|
18
|
-
'.chat-tool-card__wrapper:not(:has(.cl-remote-agent-card))'
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
var SUMMARY_SELECTORS = [
|
|
22
|
-
'.chat-tool-card__header',
|
|
23
|
-
'.chat-tool-card__title',
|
|
24
|
-
'.chat-tool-msg-summary:not(.cl-remote-agent-host-shell *)',
|
|
25
|
-
'.chat-tools-summary:not(.cl-remote-agent-host-shell *)',
|
|
26
|
-
// v5.x+ variants
|
|
27
|
-
'.tool-card__header',
|
|
28
|
-
'.tool-card__title'
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
var INDENT_SELECTORS = [
|
|
32
|
-
'.chat-group.tool:not(:has(.cl-remote-agent-card))',
|
|
33
|
-
'.chat-bubble:not(:has(.cl-remote-agent-card))'
|
|
34
|
-
];
|
|
14
|
+
var SHELL_SELECTORS = nativeStyle.shellSelectors || [];
|
|
15
|
+
var SUMMARY_SELECTORS = nativeStyle.summarySelectors || [];
|
|
16
|
+
var INDENT_SELECTORS = nativeStyle.indentSelectors || [];
|
|
35
17
|
|
|
36
18
|
// Fallback 默认值(和当前 styles.js 折叠态写死值保持一致,避免跳变)
|
|
37
19
|
var FALLBACKS = {
|
|
@@ -31,6 +31,9 @@ function _clRenderOutputCard(model, onOpenSidebar) {
|
|
|
31
31
|
? _clStripOpenagentMediaLines(chunk.text)
|
|
32
32
|
: chunk.text;
|
|
33
33
|
if (_clShouldRenderOutputText(textChunk)) resultTexts.push(textChunk);
|
|
34
|
+
} else if (chunk.type === 'error') {
|
|
35
|
+
var errorText = chunk.text || model.rawText || '远端 Agent 调用失败';
|
|
36
|
+
if (_clShouldRenderOutputText(errorText)) resultTexts.push(errorText);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -75,13 +78,13 @@ function _clRenderOutputCard(model, onOpenSidebar) {
|
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
model._outputMode = true;
|
|
78
|
-
model.status = 'completed';
|
|
81
|
+
model.status = model.isError ? 'failed' : 'completed';
|
|
79
82
|
if (isV2) {
|
|
80
83
|
var v2Header = _clCreateOpenAgentHeaderV2(model);
|
|
81
84
|
v2Header.classList.remove('cl-openagent-header--output');
|
|
82
85
|
container.appendChild(v2Header);
|
|
83
86
|
if (typeof _clUpdateAgentStatusTextV2 === 'function') {
|
|
84
|
-
_clUpdateAgentStatusTextV2(container,
|
|
87
|
+
_clUpdateAgentStatusTextV2(container, model.status);
|
|
85
88
|
}
|
|
86
89
|
} else {
|
|
87
90
|
var shellHeader = _clCreateOpenAgentHeader(model);
|
|
@@ -176,8 +179,11 @@ function _clRenderOutputCard(model, onOpenSidebar) {
|
|
|
176
179
|
var avatarElV2 = container.querySelector('.cl-exec-agent-avatar-v2');
|
|
177
180
|
var nameElV2 = container.querySelector('.cl-exec-agent-name-v2');
|
|
178
181
|
var bioElV2 = container.querySelector('.cl-exec-agent-bio-v2');
|
|
182
|
+
var agentBioV2 = typeof _clGetAgentDescriptionText === 'function'
|
|
183
|
+
? _clGetAgentDescriptionText(agent)
|
|
184
|
+
: (agent.bio || agent.description || '');
|
|
179
185
|
if (nameElV2) nameElV2.textContent = agent.name || model.agentName;
|
|
180
|
-
if (bioElV2 &&
|
|
186
|
+
if (bioElV2 && agentBioV2) bioElV2.textContent = agentBioV2;
|
|
181
187
|
var starsElV2 = container.querySelector('.cl-exec-star-count-v2');
|
|
182
188
|
if (starsElV2 && agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.claws);
|
|
183
189
|
if (starsElV2 && agent.stars && !agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.stars);
|
|
@@ -187,10 +193,6 @@ function _clRenderOutputCard(model, onOpenSidebar) {
|
|
|
187
193
|
}).catch(function() {});
|
|
188
194
|
}
|
|
189
195
|
|
|
190
|
-
if (typeof _cl_applyCardUiState === 'function') {
|
|
191
|
-
_cl_applyCardUiState(container, model);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
196
|
// ── Footer ──
|
|
195
197
|
if (isV2) {
|
|
196
198
|
var footerV2 = document.createElement('div');
|
|
@@ -209,6 +211,10 @@ function _clRenderOutputCard(model, onOpenSidebar) {
|
|
|
209
211
|
container.appendChild(footer);
|
|
210
212
|
}
|
|
211
213
|
|
|
214
|
+
if (typeof _cl_applyCardUiState === 'function') {
|
|
215
|
+
_cl_applyCardUiState(container, model);
|
|
216
|
+
}
|
|
217
|
+
|
|
212
218
|
console.log('[cl-output] ✅ output card built: results=' + resultTexts.length + ' v2=' + isV2);
|
|
213
219
|
return container;
|
|
214
220
|
}
|