openclaw-openagent 1.0.13 → 1.0.14
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/src/messaging/executor.d.ts +2 -3
- package/dist/src/messaging/executor.js +4 -31
- package/dist/src/plugin-ui/assets/openagent-override.js +4 -5
- package/dist/src/runtime/update-checker.d.ts +1 -1
- package/dist/src/runtime/update-checker.js +9 -46
- package/package.json +1 -3
- package/src/app/channel-tools.ts +0 -249
- package/src/app/discovery-tools.ts +0 -273
- package/src/app/download-file-tool.ts +0 -133
- package/src/app/hooks.ts +0 -144
- package/src/app/index.ts +0 -84
- package/src/app/messaging-tools.ts +0 -79
- package/src/app/ops-tools.ts +0 -155
- package/src/app/remote-agent-tool.ts +0 -762
- package/src/app/types.ts +0 -68
- package/src/app/upload-file-tool.ts +0 -411
- package/src/app/verbose-preflight.ts +0 -190
- package/src/auth/config.ts +0 -266
- package/src/auth/credential-manager.ts +0 -146
- package/src/auth/index.ts +0 -24
- package/src/auth/verify.ts +0 -99
- package/src/channel.ts +0 -566
- package/src/compat.ts +0 -94
- package/src/config/config-schema.ts +0 -45
- package/src/messaging/aggregator.ts +0 -120
- package/src/messaging/collector.ts +0 -89
- package/src/messaging/executor.ts +0 -72
- package/src/messaging/inbound.ts +0 -150
- package/src/messaging/index.ts +0 -11
- package/src/messaging/mention-protocol.ts +0 -94
- package/src/messaging/process-c2c-request.ts +0 -564
- package/src/messaging/process-message.ts +0 -373
- package/src/messaging/scheduler.ts +0 -55
- package/src/messaging/types.ts +0 -38
- package/src/plugin-ui/adapters/oc-2026-04.js +0 -103
- package/src/plugin-ui/adapters/oc-2026-05.js +0 -125
- package/src/plugin-ui/adapters/oc-2026-06.js +0 -125
- package/src/plugin-ui/adapters/oc-unknown.js +0 -48
- package/src/plugin-ui/assets/agentbook-icon.svg +0 -5
- package/src/plugin-ui/assets/bg.png +0 -0
- package/src/plugin-ui/assets/icon.png +0 -0
- package/src/plugin-ui/assets/magic.svg +0 -5
- package/src/plugin-ui/assets/openagent-override.js +0 -11263
- package/src/plugin-ui/build.cjs +0 -463
- package/src/plugin-ui/index.ts +0 -18
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +0 -570
- package/src/plugin-ui/modules/agent-book/panel/agent-card.js +0 -170
- package/src/plugin-ui/modules/agent-book/panel/agent-data.js +0 -643
- package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +0 -665
- package/src/plugin-ui/modules/agent-book/panel/mention-state.js +0 -206
- package/src/plugin-ui/modules/agent-book/panel/styles.js +0 -832
- package/src/plugin-ui/modules/agent-book/panel/theme-adapter.js +0 -86
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +0 -295
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +0 -211
- package/src/plugin-ui/modules/agent-book/scanner.js +0 -131
- package/src/plugin-ui/modules/agent-book/travelcard/travel-cards.js +0 -500
- package/src/plugin-ui/modules/agent-book/travelcard/travel-engine.js +0 -652
- package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +0 -262
- package/src/plugin-ui/modules/loader/bootstrap.js +0 -133
- package/src/plugin-ui/modules/loader/shared-state.js +0 -838
- package/src/plugin-ui/modules/loader/ws-intercept.js +0 -199
- package/src/plugin-ui/modules/remote-agent/chunk-parser.js +0 -161
- package/src/plugin-ui/modules/remote-agent/execution-card.js +0 -530
- package/src/plugin-ui/modules/remote-agent/markdown-renderer.js +0 -256
- package/src/plugin-ui/modules/remote-agent/media-links.js +0 -151
- package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +0 -134
- package/src/plugin-ui/modules/remote-agent/output-card.js +0 -342
- package/src/plugin-ui/modules/remote-agent/progress-store.js +0 -363
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +0 -1700
- package/src/plugin-ui/modules/remote-agent/styles.js +0 -903
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +0 -130
- package/src/plugin-ui/postinstall-deploy.cjs +0 -52
- package/src/plugin-ui/ui-extension-loader/backup.ts +0 -92
- package/src/plugin-ui/ui-extension-loader/index.ts +0 -276
- package/src/plugin-ui/ui-extension-loader/locator.ts +0 -152
- package/src/plugin-ui/ui-extension-loader/manifest.ts +0 -57
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +0 -944
- package/src/plugin-ui/ui-extension-loader/removed-extensions.ts +0 -70
- package/src/plugin-ui/ui-extension-loader/types.ts +0 -72
- package/src/proxy/auth-proxy.ts +0 -414
- package/src/runtime/account.ts +0 -549
- package/src/runtime/index.ts +0 -7
- package/src/runtime/plugin-runtime.ts +0 -94
- package/src/runtime/registry.ts +0 -71
- package/src/runtime/update-checker.ts +0 -286
- package/src/sdk/CLASS_MAP.md +0 -143
- package/src/sdk/index.d.ts +0 -126
- package/src/sdk/index.js +0 -23990
- package/src/sdk/modules/cloud-search-module.js +0 -1117
- package/src/sdk/modules/follow-module.js +0 -1069
- package/src/sdk/modules/group-module.js +0 -7397
- package/src/sdk/modules/relationship-module.js +0 -2269
- package/src/sdk/modules/signaling-module.js +0 -1468
- package/src/sdk/modules/tim-upload-plugin.js +0 -730
- package/src/sdk/node-env/http-request.js +0 -90
- package/src/sdk/node-env/index.js +0 -57
- package/src/sdk/node-env/storage.js +0 -114
- package/src/sdk/package.json +0 -10
- package/src/sdk/tsconfig.json +0 -16
- package/src/state/pending-invocation-store.ts +0 -43
- package/src/state/store.ts +0 -756
- package/src/tim/c2c.ts +0 -451
- package/src/tim/channels.ts +0 -364
- package/src/tim/client.ts +0 -330
- package/src/tim/index.ts +0 -18
- package/src/tim/messages.ts +0 -166
- package/src/tim/sdk-logger-init.ts +0 -50
- package/src/tools.ts +0 -10
- package/src/transport/factory.ts +0 -95
- package/src/transport/oasn/index.ts +0 -17
- package/src/transport/oasn/oasn-agent-card.ts +0 -111
- package/src/transport/oasn/oasn-discovery.ts +0 -108
- package/src/transport/oasn/oasn-files.ts +0 -210
- package/src/transport/oasn/oasn-http.ts +0 -529
- package/src/transport/oasn/oasn-invocation.ts +0 -604
- package/src/transport/oasn/oasn-normalize.ts +0 -133
- package/src/transport/oasn/oasn-register.ts +0 -33
- package/src/transport/oasn/oasn-transport.ts +0 -318
- package/src/transport/oasn/oasn-types.ts +0 -404
- package/src/transport/tim/index.ts +0 -8
- package/src/transport/tim/tim-transport.ts +0 -515
- package/src/transport/types.ts +0 -538
- package/src/types/openclaw-plugin-sdk-media-store.d.ts +0 -9
- package/src/types/openclaw.d.ts +0 -97
- package/src/types/tencentcloud-chat.d.ts +0 -15
- package/src/util/http.ts +0 -113
- package/src/util/logger.ts +0 -131
- package/src/util/url-resolver.ts +0 -77
|
@@ -1,530 +0,0 @@
|
|
|
1
|
-
// ── OpenAgent Execution Card — Agent 执行态 UI ──
|
|
2
|
-
//
|
|
3
|
-
// 输入: OpenAgentCardModel (from tool-card-model.js)
|
|
4
|
-
// 输出: DOM Node (嵌入 Lit template)
|
|
5
|
-
//
|
|
6
|
-
// 显示内容:
|
|
7
|
-
// - Agent Pill(头像 + @名称)
|
|
8
|
-
// - 分隔线
|
|
9
|
-
// - 思考步骤列表(从 model.chunks 中提取 step 类型)
|
|
10
|
-
//
|
|
11
|
-
// UI 结构使用 shared thought-chain styles,数据来源是 RenderHook model。
|
|
12
|
-
|
|
13
|
-
function _clRenderExecutionCard(model) {
|
|
14
|
-
// ── V2 版本判断:≥ 2026.6.9 启用新版 UI ──
|
|
15
|
-
if (typeof _clIsHostVersionGte === 'function' && _clIsHostVersionGte('2026.6.9')) {
|
|
16
|
-
return _clRenderExecutionCardV2(model);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var container = document.createElement('div');
|
|
20
|
-
container.className = 'cl-remote-agent-card cl-thought-chain';
|
|
21
|
-
if (CL && typeof CL.diagMarkCard === 'function') {
|
|
22
|
-
CL.diagMarkCard(container, 'execution', { tcid: model.toolCallId || '' });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
container.appendChild(_clCreateOpenAgentHeader(model));
|
|
26
|
-
|
|
27
|
-
var content = document.createElement('div');
|
|
28
|
-
content.className = 'cl-thought-chain-content cl-thought-chain-content--execution cl-content-collapsed';
|
|
29
|
-
container.appendChild(content);
|
|
30
|
-
|
|
31
|
-
// ── Agent 详情卡片(Figma 346:181) ──
|
|
32
|
-
try {
|
|
33
|
-
var detailCard = _clCreateAgentDetailCard(model);
|
|
34
|
-
content.appendChild(detailCard);
|
|
35
|
-
} catch(e) {
|
|
36
|
-
console.warn('[cl-exec] detail card creation failed:', e);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ── 进度文字(Figma 346:253) — 动态读取 response.progress?.safe_status_message ──
|
|
40
|
-
var progressRow = document.createElement('div');
|
|
41
|
-
progressRow.className = 'cl-exec-progress-row';
|
|
42
|
-
var progressText = document.createElement('p');
|
|
43
|
-
progressText.className = 'cl-exec-progress-text';
|
|
44
|
-
progressText.textContent = (model.progressMessage || model.rawText || '').trim() || '思考中,正在了解你的需求';
|
|
45
|
-
progressRow.appendChild(progressText);
|
|
46
|
-
// 箭头图标
|
|
47
|
-
var arrowIcon = document.createElement('span');
|
|
48
|
-
arrowIcon.className = 'cl-exec-progress-arrow';
|
|
49
|
-
arrowIcon.innerHTML = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M5 4L9 7L5 10" stroke="#555" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
50
|
-
progressRow.appendChild(arrowIcon);
|
|
51
|
-
content.appendChild(progressRow);
|
|
52
|
-
if (model.status === 'completed') progressRow.style.display = 'none';
|
|
53
|
-
|
|
54
|
-
// ── 异步更新真实 Agent 身份 ──
|
|
55
|
-
if ((model.agentId || model.agentName) && typeof fetchAgentById === 'function') {
|
|
56
|
-
fetchAgentById(model.agentId, model.agentName).then(function(agent) {
|
|
57
|
-
if (!agent) return;
|
|
58
|
-
var avatarEl = container.querySelector('.cl-exec-agent-avatar');
|
|
59
|
-
var nameEl = container.querySelector('.cl-exec-agent-name');
|
|
60
|
-
var bioEl = container.querySelector('.cl-exec-agent-bio');
|
|
61
|
-
var agentBio = _clGetAgentDescriptionText(agent);
|
|
62
|
-
// avatar 保持 icon.png,不覆盖
|
|
63
|
-
if (nameEl) nameEl.textContent = agent.name || model.agentName;
|
|
64
|
-
if (bioEl && agentBio) bioEl.textContent = agentBio;
|
|
65
|
-
var starsEl = container.querySelector('.cl-exec-star-count');
|
|
66
|
-
if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
|
|
67
|
-
if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
|
|
68
|
-
_clSetOpenAgentHeaderAgent(container, agent.name || model.agentName);
|
|
69
|
-
}).catch(function() {});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (typeof _cl_applyCardUiState === 'function') {
|
|
73
|
-
_cl_applyCardUiState(container, model);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
console.log('[cl-exec] execution card built');
|
|
77
|
-
return container;
|
|
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
|
-
|
|
116
|
-
// ── Agent 详情卡片(Figma 266:11136) ──
|
|
117
|
-
function _clCreateAgentDetailCard(model) {
|
|
118
|
-
var card = document.createElement('div');
|
|
119
|
-
card.className = 'cl-exec-detail-card';
|
|
120
|
-
|
|
121
|
-
var row = document.createElement('div');
|
|
122
|
-
row.className = 'cl-exec-detail-row';
|
|
123
|
-
|
|
124
|
-
// 头像 68×68
|
|
125
|
-
var avatar = document.createElement('img');
|
|
126
|
-
avatar.className = 'cl-exec-agent-avatar';
|
|
127
|
-
avatar.alt = model.agentName || '';
|
|
128
|
-
avatar.src = './icon.png';
|
|
129
|
-
avatar.onerror = function() { this.style.visibility = 'hidden'; };
|
|
130
|
-
row.appendChild(avatar);
|
|
131
|
-
|
|
132
|
-
// 信息列
|
|
133
|
-
var info = document.createElement('div');
|
|
134
|
-
info.className = 'cl-exec-detail-info';
|
|
135
|
-
|
|
136
|
-
// 名称行:名称 + 星级徽章
|
|
137
|
-
var nameRow = document.createElement('div');
|
|
138
|
-
nameRow.className = 'cl-exec-name-row';
|
|
139
|
-
|
|
140
|
-
var nameEl = document.createElement('p');
|
|
141
|
-
nameEl.className = 'cl-exec-agent-name';
|
|
142
|
-
nameEl.textContent = model.agentName || 'Remote Agent';
|
|
143
|
-
nameRow.appendChild(nameEl);
|
|
144
|
-
|
|
145
|
-
// 星级徽章
|
|
146
|
-
var starBadge = document.createElement('div');
|
|
147
|
-
starBadge.className = 'cl-exec-star-badge';
|
|
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>';
|
|
149
|
-
starBadge.innerHTML = starSvgOutline +
|
|
150
|
-
'<span class="cl-exec-star-count">' + (model.agentStars || '3.2万') + '</span>';
|
|
151
|
-
nameRow.appendChild(starBadge);
|
|
152
|
-
info.appendChild(nameRow);
|
|
153
|
-
|
|
154
|
-
var bioEl = document.createElement('p');
|
|
155
|
-
bioEl.className = 'cl-exec-agent-bio';
|
|
156
|
-
bioEl.textContent = _clGetAgentDescriptionText(model);
|
|
157
|
-
info.appendChild(bioEl);
|
|
158
|
-
|
|
159
|
-
row.appendChild(info);
|
|
160
|
-
card.appendChild(row);
|
|
161
|
-
|
|
162
|
-
return card;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ── 共用 DOM 构建函数 ──
|
|
166
|
-
|
|
167
|
-
function _clCreateOpenAgentHeader(model) {
|
|
168
|
-
var header = document.createElement('div');
|
|
169
|
-
header.className = 'cl-openagent-header';
|
|
170
|
-
if (model._outputMode) header.classList.add('cl-openagent-header--output');
|
|
171
|
-
header.style.cursor = 'pointer';
|
|
172
|
-
|
|
173
|
-
// 展开/收起图标
|
|
174
|
-
var expandIcon = document.createElement('span');
|
|
175
|
-
expandIcon.className = 'cl-openagent-expand-icon';
|
|
176
|
-
// 收起态三角(向右)
|
|
177
|
-
expandIcon.innerHTML = '<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>';
|
|
178
|
-
// 展开态三角(向下)
|
|
179
|
-
var expandedSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none"><path d="M8.43313 8.98291C8.24068 9.31624 7.75955 9.31624 7.5671 8.98291L5.83505 5.98291C5.6426 5.64958 5.88316 5.23291 6.26806 5.23291L9.73216 5.23291C10.1171 5.23291 10.3576 5.64958 10.1652 5.98291L8.43313 8.98291Z" fill="#666666"/></svg>';
|
|
180
|
-
header.appendChild(expandIcon);
|
|
181
|
-
|
|
182
|
-
// OASN 小图标
|
|
183
|
-
var oasnBadge = document.createElement('span');
|
|
184
|
-
oasnBadge.className = 'cl-openagent-badge';
|
|
185
|
-
header.appendChild(oasnBadge);
|
|
186
|
-
|
|
187
|
-
// 文字行
|
|
188
|
-
var textRow = document.createElement('span');
|
|
189
|
-
textRow.className = 'cl-openagent-text-row';
|
|
190
|
-
|
|
191
|
-
var labelOpenAgent = document.createElement('span');
|
|
192
|
-
labelOpenAgent.className = 'cl-openagent-label';
|
|
193
|
-
labelOpenAgent.textContent = 'OpenAgent';
|
|
194
|
-
textRow.appendChild(labelOpenAgent);
|
|
195
|
-
|
|
196
|
-
var labelAgent = document.createElement('span');
|
|
197
|
-
labelAgent.className = 'cl-openagent-agent';
|
|
198
|
-
labelAgent.textContent = '@' + (model.agentName || 'Remote Agent');
|
|
199
|
-
textRow.appendChild(labelAgent);
|
|
200
|
-
|
|
201
|
-
var labelStatus = document.createElement('span');
|
|
202
|
-
labelStatus.className = 'cl-openagent-status';
|
|
203
|
-
labelStatus.textContent = _clGetAgentStatusText(model.status);
|
|
204
|
-
textRow.appendChild(labelStatus);
|
|
205
|
-
|
|
206
|
-
header.appendChild(textRow);
|
|
207
|
-
|
|
208
|
-
// 点击 header 折叠/展开卡片内容
|
|
209
|
-
header.addEventListener('click', function(e) {
|
|
210
|
-
e.stopPropagation();
|
|
211
|
-
var card = header.closest('.cl-remote-agent-card');
|
|
212
|
-
if (!card) return;
|
|
213
|
-
var content = card.querySelector('.cl-thought-chain-content');
|
|
214
|
-
if (!content) return;
|
|
215
|
-
var isCollapsed = content.classList.toggle('cl-content-collapsed');
|
|
216
|
-
_clSyncOutputFooterVisibility(card, isCollapsed);
|
|
217
|
-
// 切换图标
|
|
218
|
-
expandIcon.innerHTML = isCollapsed
|
|
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>'
|
|
220
|
-
: '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none"><path d="M8.43313 8.98291C8.24068 9.31624 7.75955 9.31624 7.5671 8.98291L5.83505 5.98291C5.6426 5.64958 5.88316 5.23291 6.26806 5.23291L9.73216 5.23291C10.1171 5.23291 10.3576 5.64958 10.1652 5.98291L8.43313 8.98291Z" fill="#666666"/></svg>';
|
|
221
|
-
if (typeof _cl_setCardUiState === 'function') {
|
|
222
|
-
_cl_setCardUiState(model, { contentCollapsed: isCollapsed });
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
return header;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function _clSetOpenAgentHeaderAgent(container, agentName) {
|
|
230
|
-
var label = container && container.querySelector('.cl-openagent-agent');
|
|
231
|
-
if (label) label.textContent = '@' + (agentName || 'Remote Agent');
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function _clCreateAgentPill(agentName, agentId, agentAvatar) {
|
|
235
|
-
var pill = document.createElement('div');
|
|
236
|
-
pill.className = 'cl-agent-pill';
|
|
237
|
-
|
|
238
|
-
var avatar = document.createElement('img');
|
|
239
|
-
avatar.className = 'cl-agent-pill-avatar';
|
|
240
|
-
avatar.alt = agentName || 'Agent';
|
|
241
|
-
var identity = CL && typeof CL.getAgentIdentity === 'function'
|
|
242
|
-
? CL.getAgentIdentity(agentId, agentName)
|
|
243
|
-
: null;
|
|
244
|
-
var avatarAgent = agentAvatar
|
|
245
|
-
? { name: agentName, avatar: agentAvatar }
|
|
246
|
-
: identity;
|
|
247
|
-
avatar.src = (avatarAgent && avatarAgent.avatar && typeof avatarUrl === 'function')
|
|
248
|
-
? avatarUrl(avatarAgent)
|
|
249
|
-
: 'https://ui-avatars.com/api/?name=' + encodeURIComponent(agentName || 'A') + '&background=7c3aed&color=fff&size=64';
|
|
250
|
-
console.log('[cl-diag][pill] create agentName=' + JSON.stringify(agentName || '')
|
|
251
|
-
+ ' agentId=' + JSON.stringify(agentId || '')
|
|
252
|
-
+ ' src=' + JSON.stringify(avatar.getAttribute('src')));
|
|
253
|
-
avatar.onerror = function() { this.style.visibility = 'hidden'; };
|
|
254
|
-
pill.appendChild(avatar);
|
|
255
|
-
|
|
256
|
-
var nameEl = document.createElement('span');
|
|
257
|
-
nameEl.className = 'cl-agent-pill-name';
|
|
258
|
-
var atEl = document.createElement('span');
|
|
259
|
-
atEl.className = 'cl-agent-pill-at';
|
|
260
|
-
atEl.textContent = '@';
|
|
261
|
-
var labelEl = document.createElement('span');
|
|
262
|
-
labelEl.className = 'cl-agent-pill-label';
|
|
263
|
-
labelEl.textContent = agentName || 'Remote Agent';
|
|
264
|
-
nameEl.appendChild(atEl);
|
|
265
|
-
nameEl.appendChild(labelEl);
|
|
266
|
-
pill.appendChild(nameEl);
|
|
267
|
-
|
|
268
|
-
return pill;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function _clSetAgentPillName(container, agentName) {
|
|
272
|
-
var label = container && container.querySelector('.cl-agent-pill-label');
|
|
273
|
-
if (label) {
|
|
274
|
-
label.textContent = agentName || 'Remote Agent';
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
var name = container && container.querySelector('.cl-agent-pill-name');
|
|
278
|
-
if (name) name.textContent = '@' + (agentName || 'Remote Agent');
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function _clCreateStepElement(step, isLatest) {
|
|
282
|
-
var item = document.createElement('div');
|
|
283
|
-
item.className = 'cl-tools-collapse-step';
|
|
284
|
-
|
|
285
|
-
var row = document.createElement('div');
|
|
286
|
-
row.className = 'cl-tools-collapse-step-row';
|
|
287
|
-
|
|
288
|
-
var iconWrap = document.createElement('div');
|
|
289
|
-
iconWrap.className = 'cl-tools-collapse-step-icon';
|
|
290
|
-
|
|
291
|
-
if (isLatest) {
|
|
292
|
-
var dot = document.createElement('div');
|
|
293
|
-
dot.className = 'cl-tools-collapse-step-dot cl-active';
|
|
294
|
-
iconWrap.appendChild(dot);
|
|
295
|
-
} else {
|
|
296
|
-
var check = document.createElement('div');
|
|
297
|
-
check.className = 'cl-tools-collapse-step-check';
|
|
298
|
-
iconWrap.appendChild(check);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
var titleEl = document.createElement('span');
|
|
302
|
-
titleEl.className = 'cl-tools-collapse-step-title';
|
|
303
|
-
titleEl.textContent = (step.title || '').replace(/[\u2705\u2611\uFE0F\u2714\uFE0F]/g, '').trim();
|
|
304
|
-
|
|
305
|
-
row.appendChild(iconWrap);
|
|
306
|
-
row.appendChild(titleEl);
|
|
307
|
-
item.appendChild(row);
|
|
308
|
-
|
|
309
|
-
return item;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// ── 动态更新 header 状态文字 ──
|
|
314
|
-
function _clUpdateAgentStatusText(cardNode, status) {
|
|
315
|
-
var label = cardNode && cardNode.querySelector('.cl-openagent-status');
|
|
316
|
-
if (label) label.textContent = _clGetAgentStatusText(status);
|
|
317
|
-
var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row');
|
|
318
|
-
if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function _cl_formatStarCount(count) {
|
|
322
|
-
var n = Number(count);
|
|
323
|
-
if (!isFinite(n)) return '3.2万';
|
|
324
|
-
if (n >= 10000) return (n / 10000).toFixed(1).replace(/.0$/, '') + '万';
|
|
325
|
-
if (n >= 1000) return (n / 1000).toFixed(1).replace(/.0$/, '') + 'k';
|
|
326
|
-
return String(Math.floor(n));
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// ═══════════════════════════════════════════════════════════════
|
|
330
|
-
// V2 执行卡片渲染(2026.6.9+ 新版 UI)
|
|
331
|
-
// ═══════════════════════════════════════════════════════════════
|
|
332
|
-
|
|
333
|
-
function _clRenderExecutionCardV2(model) {
|
|
334
|
-
var container = document.createElement('div');
|
|
335
|
-
container.className = 'cl-remote-agent-card cl-thought-chain cl-exec-v2';
|
|
336
|
-
if (CL && typeof CL.diagMarkCard === 'function') {
|
|
337
|
-
CL.diagMarkCard(container, 'execution', { tcid: model.toolCallId || '' });
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
container.appendChild(_clCreateOpenAgentHeaderV2(model));
|
|
341
|
-
|
|
342
|
-
var content = document.createElement('div');
|
|
343
|
-
content.className = 'cl-thought-chain-content cl-thought-chain-content--execution cl-content-collapsed';
|
|
344
|
-
container.appendChild(content);
|
|
345
|
-
|
|
346
|
-
// ── Agent 详情卡片 V2 ──
|
|
347
|
-
try {
|
|
348
|
-
var detailCard = _clCreateAgentDetailCardV2(model);
|
|
349
|
-
content.appendChild(detailCard);
|
|
350
|
-
} catch(e) {
|
|
351
|
-
console.warn('[cl-exec-v2] detail card creation failed:', e);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// ── 进度文字 V2 ──
|
|
355
|
-
var progressRow = document.createElement('div');
|
|
356
|
-
progressRow.className = 'cl-exec-progress-row cl-exec-progress-row-v2';
|
|
357
|
-
var progressText = document.createElement('p');
|
|
358
|
-
progressText.className = 'cl-exec-progress-text';
|
|
359
|
-
progressText.textContent = (model.progressMessage || model.rawText || '').trim() || '思考中,正在了解你的需求';
|
|
360
|
-
progressRow.appendChild(progressText);
|
|
361
|
-
var arrowIcon = document.createElement('span');
|
|
362
|
-
arrowIcon.className = 'cl-exec-progress-arrow';
|
|
363
|
-
arrowIcon.innerHTML = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M5 4L9 7L5 10" stroke="#555" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
364
|
-
progressRow.appendChild(arrowIcon);
|
|
365
|
-
content.appendChild(progressRow);
|
|
366
|
-
if (model.status === 'completed') progressRow.style.display = 'none';
|
|
367
|
-
|
|
368
|
-
// ── 步骤列表容器(供 _cl_updateCardSteps 使用)──
|
|
369
|
-
var stepsHeader = document.createElement('div');
|
|
370
|
-
stepsHeader.className = 'cl-tools-collapse-header cl-tools-collapse-header-v2';
|
|
371
|
-
var stepsHeaderIcon = document.createElement('span');
|
|
372
|
-
stepsHeaderIcon.className = 'cl-tools-collapse-header-icon';
|
|
373
|
-
stepsHeaderIcon.textContent = '▼';
|
|
374
|
-
stepsHeader.appendChild(stepsHeaderIcon);
|
|
375
|
-
var stepsHeaderTitle = document.createElement('span');
|
|
376
|
-
stepsHeaderTitle.className = 'cl-tools-collapse-header-title cl-tools-collapse-header-title-v2';
|
|
377
|
-
stepsHeaderTitle.textContent = '思考中...';
|
|
378
|
-
stepsHeader.appendChild(stepsHeaderTitle);
|
|
379
|
-
content.appendChild(stepsHeader);
|
|
380
|
-
|
|
381
|
-
var stepsBody = document.createElement('div');
|
|
382
|
-
stepsBody.className = 'cl-tools-collapse-body cl-tools-collapse-body-v2 cl-expanded';
|
|
383
|
-
content.appendChild(stepsBody);
|
|
384
|
-
|
|
385
|
-
// ─ Footer(Figma: -由xxx完成 + 星级)──
|
|
386
|
-
var footer = document.createElement('div');
|
|
387
|
-
footer.className = 'cl-output-footer cl-output-footer-v2';
|
|
388
|
-
footer.innerHTML = '<span class="cl-output-footer-text">-由' + (model.agentName || 'Remote Agent') + '完成</span>'
|
|
389
|
-
+ '<span class="cl-output-footer-star"><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></span>'
|
|
390
|
-
+ '<span class="cl-output-footer-count">' + (model.agentStars || '3.2万') + '</span>';
|
|
391
|
-
container.appendChild(footer);
|
|
392
|
-
|
|
393
|
-
// ── 异步更新真实 Agent 身份 ──
|
|
394
|
-
if ((model.agentId || model.agentName) && typeof fetchAgentById === 'function') {
|
|
395
|
-
fetchAgentById(model.agentId, model.agentName).then(function(agent) {
|
|
396
|
-
if (!agent) return;
|
|
397
|
-
var avatarEl = container.querySelector('.cl-exec-agent-avatar-v2');
|
|
398
|
-
var nameEl = container.querySelector('.cl-exec-agent-name-v2');
|
|
399
|
-
var bioEl = container.querySelector('.cl-exec-agent-bio-v2');
|
|
400
|
-
var agentBio = _clGetAgentDescriptionText(agent);
|
|
401
|
-
if (nameEl) nameEl.textContent = agent.name || model.agentName;
|
|
402
|
-
if (bioEl && agentBio) bioEl.textContent = agentBio;
|
|
403
|
-
var starsEl = container.querySelector('.cl-exec-star-count-v2');
|
|
404
|
-
if (starsEl && agent.claws) starsEl.textContent = _cl_formatStarCount(agent.claws);
|
|
405
|
-
if (starsEl && agent.stars && !agent.claws) starsEl.textContent = _cl_formatStarCount(agent.stars);
|
|
406
|
-
}).catch(function() {});
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (typeof _cl_applyCardUiState === 'function') {
|
|
410
|
-
_cl_applyCardUiState(container, model);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
console.log('[cl-exec-v2] execution card built');
|
|
414
|
-
return container;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// ── V2 Header(粉色背景 + 圆形头像 + 无 @agentName)──
|
|
418
|
-
function _clCreateOpenAgentHeaderV2(model) {
|
|
419
|
-
var header = document.createElement('div');
|
|
420
|
-
header.className = 'cl-openagent-header cl-openagent-header-v2';
|
|
421
|
-
if (model._outputMode) header.classList.add('cl-openagent-header--output');
|
|
422
|
-
header.style.cursor = 'pointer';
|
|
423
|
-
|
|
424
|
-
// 展开/收起图标
|
|
425
|
-
var expandIcon = document.createElement('span');
|
|
426
|
-
expandIcon.className = 'cl-openagent-expand-icon';
|
|
427
|
-
expandIcon.innerHTML = '<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>';
|
|
428
|
-
var expandedSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none"><path d="M8.43313 8.98291C8.24068 9.31624 7.75955 9.31624 7.5671 8.98291L5.83505 5.98291C5.6426 5.64958 5.88316 5.23291 6.26806 5.23291L9.73216 5.23291C10.1171 5.23291 10.3576 5.64958 10.1652 5.98291L8.43313 8.98291Z" fill="#666666"/></svg>';
|
|
429
|
-
header.appendChild(expandIcon);
|
|
430
|
-
|
|
431
|
-
// 圆形灰色头像(替代小徽章)
|
|
432
|
-
var avatar = document.createElement('span');
|
|
433
|
-
avatar.className = 'cl-openagent-avatar-v2';
|
|
434
|
-
header.appendChild(avatar);
|
|
435
|
-
|
|
436
|
-
// 文字行:OpenAgent + 状态文字(去掉 @agentName)
|
|
437
|
-
var textRow = document.createElement('span');
|
|
438
|
-
textRow.className = 'cl-openagent-text-row';
|
|
439
|
-
|
|
440
|
-
var labelOpenAgent = document.createElement('span');
|
|
441
|
-
labelOpenAgent.className = 'cl-openagent-label';
|
|
442
|
-
labelOpenAgent.textContent = 'OpenAgent';
|
|
443
|
-
textRow.appendChild(labelOpenAgent);
|
|
444
|
-
|
|
445
|
-
var labelStatus = document.createElement('span');
|
|
446
|
-
labelStatus.className = 'cl-openagent-status';
|
|
447
|
-
labelStatus.textContent = _clGetAgentStatusText(model.status);
|
|
448
|
-
textRow.appendChild(labelStatus);
|
|
449
|
-
|
|
450
|
-
header.appendChild(textRow);
|
|
451
|
-
|
|
452
|
-
// 点击 header 折叠/展开卡片内容
|
|
453
|
-
header.addEventListener('click', function(e) {
|
|
454
|
-
e.stopPropagation();
|
|
455
|
-
var card = header.closest('.cl-remote-agent-card');
|
|
456
|
-
if (!card) return;
|
|
457
|
-
var content = card.querySelector('.cl-thought-chain-content');
|
|
458
|
-
if (!content) return;
|
|
459
|
-
var isCollapsed = content.classList.toggle('cl-content-collapsed');
|
|
460
|
-
_clSyncOutputFooterVisibility(card, isCollapsed);
|
|
461
|
-
expandIcon.innerHTML = isCollapsed
|
|
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>'
|
|
463
|
-
: expandedSvg;
|
|
464
|
-
if (typeof _cl_setCardUiState === 'function') {
|
|
465
|
-
_cl_setCardUiState(model, { contentCollapsed: isCollapsed });
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
return header;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// ─ V2 Agent 详情卡片(大头像 + 右置星级 + 网格点背景)──
|
|
473
|
-
function _clCreateAgentDetailCardV2(model) {
|
|
474
|
-
var card = document.createElement('div');
|
|
475
|
-
card.className = 'cl-exec-detail-card cl-exec-detail-card-v2';
|
|
476
|
-
|
|
477
|
-
var row = document.createElement('div');
|
|
478
|
-
row.className = 'cl-exec-detail-row cl-exec-detail-row-v2';
|
|
479
|
-
|
|
480
|
-
// 大头像 80×80
|
|
481
|
-
var avatar = document.createElement('img');
|
|
482
|
-
avatar.className = 'cl-exec-agent-avatar cl-exec-agent-avatar-v2';
|
|
483
|
-
avatar.alt = model.agentName || '';
|
|
484
|
-
avatar.src = './icon.png';
|
|
485
|
-
avatar.onerror = function() { this.style.visibility = 'hidden'; };
|
|
486
|
-
row.appendChild(avatar);
|
|
487
|
-
|
|
488
|
-
// 信息列
|
|
489
|
-
var info = document.createElement('div');
|
|
490
|
-
info.className = 'cl-exec-detail-info cl-exec-detail-info-v2';
|
|
491
|
-
|
|
492
|
-
// 名称(无星级徽章,星级右置到卡片右上角)
|
|
493
|
-
var nameEl = document.createElement('p');
|
|
494
|
-
nameEl.className = 'cl-exec-agent-name cl-exec-agent-name-v2';
|
|
495
|
-
nameEl.textContent = model.agentName || 'Remote Agent';
|
|
496
|
-
info.appendChild(nameEl);
|
|
497
|
-
|
|
498
|
-
// 描述文字
|
|
499
|
-
var bioEl = document.createElement('p');
|
|
500
|
-
bioEl.className = 'cl-exec-agent-bio cl-exec-agent-bio-v2';
|
|
501
|
-
bioEl.textContent = _clGetAgentDescriptionText(model);
|
|
502
|
-
info.appendChild(bioEl);
|
|
503
|
-
|
|
504
|
-
row.appendChild(info);
|
|
505
|
-
card.appendChild(row);
|
|
506
|
-
|
|
507
|
-
// 星级徽章右置到卡片右上角
|
|
508
|
-
var starBadge = document.createElement('div');
|
|
509
|
-
starBadge.className = 'cl-exec-star-badge cl-exec-star-badge-v2';
|
|
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>';
|
|
511
|
-
starBadge.innerHTML = starSvgOutline +
|
|
512
|
-
'<span class="cl-exec-star-count cl-exec-star-count-v2">' + (model.agentStars || '3.2万') + '</span>';
|
|
513
|
-
card.appendChild(starBadge);
|
|
514
|
-
|
|
515
|
-
return card;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// ── V2 状态文字更新 ──
|
|
519
|
-
function _clUpdateAgentStatusTextV2(cardNode, status) {
|
|
520
|
-
var label = cardNode && cardNode.querySelector('.cl-openagent-status');
|
|
521
|
-
if (label) label.textContent = _clGetAgentStatusText(status);
|
|
522
|
-
// 进度文字行:完成后隐藏
|
|
523
|
-
var progressRow = cardNode && cardNode.querySelector('.cl-exec-progress-row-v2');
|
|
524
|
-
if (progressRow) progressRow.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
525
|
-
// 步骤列表:完成后隐藏
|
|
526
|
-
var stepsBody = cardNode && cardNode.querySelector('.cl-tools-collapse-body-v2');
|
|
527
|
-
if (stepsBody) stepsBody.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
528
|
-
var stepsHeader = cardNode && cardNode.querySelector('.cl-tools-collapse-header-v2');
|
|
529
|
-
if (stepsHeader) stepsHeader.style.display = _clIsAgentTerminalStatus(status) ? 'none' : '';
|
|
530
|
-
}
|