openclaw-openagent 1.0.12 → 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/index.js +2 -0
- package/dist/src/config/config-schema.d.ts +9 -0
- package/dist/src/config/config-schema.js +6 -0
- 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 +124 -18
- 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 +216 -0
- package/index.ts +3 -0
- 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 -39
- 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 -11156
- 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 -833
- 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 -256
- package/src/plugin-ui/modules/loader/bootstrap.js +0 -38
- 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 -896
- 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 -409
- 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/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,342 +0,0 @@
|
|
|
1
|
-
// ── OpenAgent Output Card — Agent 完成态 UI ──
|
|
2
|
-
//
|
|
3
|
-
// 输入: OpenAgentCardModel (from tool-card-model.js), onOpenSidebar callback
|
|
4
|
-
// 输出: DOM Node (嵌入 Lit template)
|
|
5
|
-
//
|
|
6
|
-
// 显示内容:
|
|
7
|
-
// - Agent Pill(头像 + @名称)
|
|
8
|
-
// - 分隔线
|
|
9
|
-
// - 最终结果(如有)
|
|
10
|
-
//
|
|
11
|
-
// UI 结构复用 shared thought-chain styles;数据来源是 RenderHook model。
|
|
12
|
-
|
|
13
|
-
function _clRenderOutputCard(model, onOpenSidebar) {
|
|
14
|
-
var mediaLinks = typeof _clExtractOpenagentMediaLinksFromModel === 'function'
|
|
15
|
-
? _clExtractOpenagentMediaLinksFromModel(model)
|
|
16
|
-
: [];
|
|
17
|
-
|
|
18
|
-
// ── 从 chunks 提取最终结果。SSE 思考链只由 call/execution card 展示,避免重复。──
|
|
19
|
-
var resultTexts = [];
|
|
20
|
-
for (var i = 0; i < model.chunks.length; i++) {
|
|
21
|
-
var chunk = model.chunks[i];
|
|
22
|
-
if (chunk.type === 'result') {
|
|
23
|
-
var resultText = typeof _clStripOpenagentMediaLines === 'function'
|
|
24
|
-
? _clStripOpenagentMediaLines(chunk.text)
|
|
25
|
-
: chunk.text;
|
|
26
|
-
if (_clShouldRenderOutputText(resultText)) resultTexts.push(resultText);
|
|
27
|
-
} else if (chunk.type === 'text') {
|
|
28
|
-
// 远端 Agent 最终回复是普通文本(toolResult(reply.content)),
|
|
29
|
-
// chunk-parser 归为 type='text',也应作为最终结果显示
|
|
30
|
-
var textChunk = typeof _clStripOpenagentMediaLines === 'function'
|
|
31
|
-
? _clStripOpenagentMediaLines(chunk.text)
|
|
32
|
-
: chunk.text;
|
|
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);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// ── V2 版本判断 ──
|
|
41
|
-
var isV2 = typeof _clIsHostVersionGte === 'function' && _clIsHostVersionGte('2026.6.9');
|
|
42
|
-
|
|
43
|
-
if (resultTexts.length === 0 && mediaLinks.length === 0) {
|
|
44
|
-
var placeholder = document.createElement('span');
|
|
45
|
-
placeholder.className = 'cl-remote-agent-card cl-remote-agent-output-placeholder';
|
|
46
|
-
placeholder.style.display = 'none';
|
|
47
|
-
placeholder.__clEmptyOutput = true;
|
|
48
|
-
// 防止 OpenClaw native 代码读 .textContent 报 undefined.trim()
|
|
49
|
-
var hiddenText = document.createElement('span');
|
|
50
|
-
hiddenText.className = 'chat-text';
|
|
51
|
-
hiddenText.style.display = 'none';
|
|
52
|
-
hiddenText.textContent = '';
|
|
53
|
-
placeholder.appendChild(hiddenText);
|
|
54
|
-
if (model.toolCallId) {
|
|
55
|
-
placeholder.dataset.clCardTcid = model.toolCallId;
|
|
56
|
-
}
|
|
57
|
-
console.log('[cl-output] hidden empty output tcid=' + String(model.toolCallId || '').substring(0, 8));
|
|
58
|
-
return placeholder;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var container = document.createElement('div');
|
|
62
|
-
var cardClasses = 'cl-remote-agent-card cl-thought-chain cl-output-card'
|
|
63
|
-
+ (resultTexts.length > 0 ? ' cl-output-card--pending' : '');
|
|
64
|
-
if (isV2) cardClasses += ' cl-exec-v2';
|
|
65
|
-
container.className = cardClasses;
|
|
66
|
-
container.dataset.clCardRole = 'output';
|
|
67
|
-
// 防止 OpenClaw native 代码读 .textContent 报 undefined.trim()
|
|
68
|
-
var safetyText = document.createElement('div');
|
|
69
|
-
safetyText.className = 'chat-text';
|
|
70
|
-
safetyText.style.display = 'none';
|
|
71
|
-
safetyText.textContent = '';
|
|
72
|
-
container.appendChild(safetyText);
|
|
73
|
-
if (model.toolCallId) container.dataset.clCardTcid = model.toolCallId;
|
|
74
|
-
// 阻止点击冒泡到原生 tool card handler
|
|
75
|
-
container.addEventListener('click', function(e) { e.stopPropagation(); });
|
|
76
|
-
if (CL && typeof CL.diagMarkCard === 'function') {
|
|
77
|
-
CL.diagMarkCard(container, 'output', { tcid: model.toolCallId || '' });
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
model._outputMode = true;
|
|
81
|
-
model.status = model.isError ? 'failed' : 'completed';
|
|
82
|
-
if (isV2) {
|
|
83
|
-
var v2Header = _clCreateOpenAgentHeaderV2(model);
|
|
84
|
-
v2Header.classList.remove('cl-openagent-header--output');
|
|
85
|
-
container.appendChild(v2Header);
|
|
86
|
-
if (typeof _clUpdateAgentStatusTextV2 === 'function') {
|
|
87
|
-
_clUpdateAgentStatusTextV2(container, model.status);
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
var shellHeader = _clCreateOpenAgentHeader(model);
|
|
91
|
-
container.appendChild(shellHeader);
|
|
92
|
-
if (typeof _clSetOpenAgentHeaderAgent === 'function') {
|
|
93
|
-
_clSetOpenAgentHeaderAgent(container, model.agentName || model.agentId || 'Remote Agent');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var content = document.createElement('div');
|
|
98
|
-
content.className = 'cl-thought-chain-content';
|
|
99
|
-
container.appendChild(content);
|
|
100
|
-
|
|
101
|
-
// ── V2 Agent 详情卡片 ──
|
|
102
|
-
if (isV2) {
|
|
103
|
-
try {
|
|
104
|
-
var detailCard = _clCreateAgentDetailCardV2(model);
|
|
105
|
-
content.appendChild(detailCard);
|
|
106
|
-
} catch(e) {
|
|
107
|
-
console.warn('[cl-output-v2] detail card creation failed:', e);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// ── 附件下载链接 ──
|
|
112
|
-
if (mediaLinks.length > 0 && typeof _clCreateOpenagentMediaLinksSection === 'function') {
|
|
113
|
-
var mediaSection = _clCreateOpenagentMediaLinksSection(mediaLinks);
|
|
114
|
-
if (mediaSection) content.appendChild(mediaSection);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// ── 最终结果展示 ──
|
|
118
|
-
if (resultTexts.length > 0) {
|
|
119
|
-
var resultSection = document.createElement('div');
|
|
120
|
-
resultSection.className = 'cl-output-result cl-output-result--pending';
|
|
121
|
-
resultSection.dataset.clRenderState = 'pending';
|
|
122
|
-
var resultText = resultTexts.join('\n\n');
|
|
123
|
-
resultSection.dataset.clToolCallId = model.toolCallId || '';
|
|
124
|
-
|
|
125
|
-
if (CL && typeof CL.extractTripCardRefsFromText === 'function') {
|
|
126
|
-
var refs = CL.extractTripCardRefsFromText(resultText);
|
|
127
|
-
resultSection.dataset.clRouteIds = refs.routeIds.join(',');
|
|
128
|
-
resultSection.dataset.clCardRefs = refs.cardRefs.join(',');
|
|
129
|
-
resultSection.dataset.clCardIds = refs.cardIds.join(',');
|
|
130
|
-
resultSection.dataset.clUnitIds = refs.unitIds.join(',');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// 使用 OpenAgent 自有 markdown renderer(不依赖宿主 marked.js)
|
|
134
|
-
if (typeof _clRenderOutputMarkdown === 'function') {
|
|
135
|
-
try {
|
|
136
|
-
resultSection.innerHTML = _clRenderOutputMarkdown(resultText);
|
|
137
|
-
} catch (e) {
|
|
138
|
-
resultSection.textContent = resultText;
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
resultSection.textContent = resultText;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
content.appendChild(resultSection);
|
|
145
|
-
_clScheduleOutputCardProcessing(resultSection, model);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// ── 错误状态 ──
|
|
149
|
-
if (model.isError) {
|
|
150
|
-
container.classList.add('cl-remote-agent-card--error');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// ── onOpenSidebar 支持:点击展开到侧边栏 ──
|
|
154
|
-
// 宿主 sidebar 渲染器要求 content 为 { kind: 'markdown', content, rawText } 对象,
|
|
155
|
-
// kind 必须为 'markdown' 才会进入 markdown 渲染路径,否则显示 "No previewable markdown content."。
|
|
156
|
-
// travel card 标签(<sh_card>等)sidebar 原生 markdown 解析不认,先 strip 再传。
|
|
157
|
-
var sidebarRaw = resultText || model.rawText || '';
|
|
158
|
-
var sidebarText = String(sidebarRaw).replace(/<\/?[a-z]+_card[^>]*>/gi, '');
|
|
159
|
-
if (typeof _clStripSuppressedTravelTags === 'function') {
|
|
160
|
-
sidebarText = _clStripSuppressedTravelTags(sidebarText);
|
|
161
|
-
}
|
|
162
|
-
if (onOpenSidebar && sidebarText.trim()) {
|
|
163
|
-
container.style.cursor = 'pointer';
|
|
164
|
-
container.addEventListener('click', function(e) {
|
|
165
|
-
if (e.target.closest('.cl-tools-collapse-header')) return;
|
|
166
|
-
onOpenSidebar({ kind: 'markdown', content: sidebarText, rawText: sidebarText });
|
|
167
|
-
setTimeout(function() {
|
|
168
|
-
var titleEl = document.querySelector('.chat-sidebar .sidebar-title');
|
|
169
|
-
if (titleEl) titleEl.textContent = 'OpenAgent @' + (model.agentName || 'Remote Agent');
|
|
170
|
-
}, 100);
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// ── 异步更新真实 Agent 身份 ──
|
|
175
|
-
if ((model.agentId || model.agentName) && typeof fetchAgentById === 'function') {
|
|
176
|
-
fetchAgentById(model.agentId, model.agentName).then(function(agent) {
|
|
177
|
-
if (!agent) return;
|
|
178
|
-
if (isV2) {
|
|
179
|
-
var avatarElV2 = container.querySelector('.cl-exec-agent-avatar-v2');
|
|
180
|
-
var nameElV2 = container.querySelector('.cl-exec-agent-name-v2');
|
|
181
|
-
var bioElV2 = container.querySelector('.cl-exec-agent-bio-v2');
|
|
182
|
-
var agentBioV2 = typeof _clGetAgentDescriptionText === 'function'
|
|
183
|
-
? _clGetAgentDescriptionText(agent)
|
|
184
|
-
: (agent.bio || agent.description || '');
|
|
185
|
-
if (nameElV2) nameElV2.textContent = agent.name || model.agentName;
|
|
186
|
-
if (bioElV2 && agentBioV2) bioElV2.textContent = agentBioV2;
|
|
187
|
-
var starsElV2 = container.querySelector('.cl-exec-star-count-v2');
|
|
188
|
-
if (starsElV2 && agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.claws);
|
|
189
|
-
if (starsElV2 && agent.stars && !agent.claws) starsElV2.textContent = _cl_formatStarCount(agent.stars);
|
|
190
|
-
} else {
|
|
191
|
-
_clSetOpenAgentHeaderAgent(container, agent.name || model.agentName);
|
|
192
|
-
}
|
|
193
|
-
}).catch(function() {});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// ── Footer ──
|
|
197
|
-
if (isV2) {
|
|
198
|
-
var footerV2 = document.createElement('div');
|
|
199
|
-
footerV2.className = 'cl-output-footer cl-output-footer-v2';
|
|
200
|
-
footerV2.innerHTML = '<span class="cl-output-footer-text">-由' + (model.agentName || 'Remote Agent') + '完成</span>'
|
|
201
|
-
+ '<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>'
|
|
202
|
-
+ '<span class="cl-output-footer-count">' + (model.agentStars || '3.2万') + '</span>';
|
|
203
|
-
container.appendChild(footerV2);
|
|
204
|
-
} else {
|
|
205
|
-
// ── Footer(Figma 131:2091) ──
|
|
206
|
-
var footer = document.createElement('div');
|
|
207
|
-
footer.className = 'cl-output-footer';
|
|
208
|
-
footer.innerHTML = '<span class="cl-output-footer-text">-由' + (model.agentName || 'Remote Agent') + '完成</span>'
|
|
209
|
-
+ '<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>'
|
|
210
|
-
+ '<span class="cl-output-footer-count">' + (model.agentStars || '3.2万') + '</span>';
|
|
211
|
-
container.appendChild(footer);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (typeof _cl_applyCardUiState === 'function') {
|
|
215
|
-
_cl_applyCardUiState(container, model);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
console.log('[cl-output] ✅ output card built: results=' + resultTexts.length + ' v2=' + isV2);
|
|
219
|
-
return container;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function _clShouldRenderOutputText(text) {
|
|
223
|
-
var value = String(text || '').trim();
|
|
224
|
-
if (!value) return false;
|
|
225
|
-
|
|
226
|
-
if (_clLooksLikeStructuredDataFragment(value)) return false;
|
|
227
|
-
|
|
228
|
-
// output 卡片只展示给用户看的最终内容。远端 SSE 的 data/think 事件
|
|
229
|
-
// 是旅行卡片原料或执行过程,不应该作为正文出现在 output 里。
|
|
230
|
-
if (/"msgType"\s*:/.test(value) && /"dataType"\s*:\s*"(data|think)"/.test(value)) {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (value.charAt(0) === '{' && value.charAt(value.length - 1) === '}') {
|
|
235
|
-
try {
|
|
236
|
-
var obj = JSON.parse(value);
|
|
237
|
-
if (obj && (obj.dataType === 'data' || obj.dataType === 'think')) return false;
|
|
238
|
-
if (obj && obj.msgType != null && obj.dataType && obj.dataType !== 'result') return false;
|
|
239
|
-
} catch (e) {}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return true;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function _clLooksLikeStructuredDataFragment(value) {
|
|
246
|
-
value = String(value || '').trim();
|
|
247
|
-
if (!value) return false;
|
|
248
|
-
|
|
249
|
-
// Pretty/truncated JSON payloads may be split into text chunks before they can
|
|
250
|
-
// be parsed as full objects. Those fragments are data source material, not UI
|
|
251
|
-
// output. Keep this narrow to Trip/itinerary-style payload keys.
|
|
252
|
-
if (/^[,}\]\s]+$/.test(value)) return true;
|
|
253
|
-
if (/^\.\.\.\s*\(truncated\)\s*\.\.\.$/.test(value)) return true;
|
|
254
|
-
|
|
255
|
-
var dataKeyRe = /"(?:msgType|dataType|sessionId|queryMsgId|itineraryId|itineraryVersionInfo|unitList|unitType|unitContexts?|dayList|trafficInfo|trafficPlanInfo|poiInfo|hotelInfo|foodData|budgetData|rankName|hotScore|remarkText|keywords|sourceType|departure|arrival)"\s*:/;
|
|
256
|
-
if (!dataKeyRe.test(value)) return false;
|
|
257
|
-
|
|
258
|
-
var structuralChars = (value.match(/[{}\[\]",:]/g) || []).length;
|
|
259
|
-
if (structuralChars >= 6) return true;
|
|
260
|
-
|
|
261
|
-
// Some split lines start midway through an object, for example
|
|
262
|
-
// `"trafficPlanInfo":{...` or `,"arrival":{...`.
|
|
263
|
-
if (/^\s*,?\s*"(?:unitType|trafficInfo|trafficPlanInfo|poiInfo|hotelInfo|remarkText|keywords|departure|arrival)"\s*:/.test(value)) {
|
|
264
|
-
return true;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function _clRevealOutputResult(resultSection, reason) {
|
|
271
|
-
if (!resultSection) return;
|
|
272
|
-
resultSection.classList.remove('cl-output-result--pending');
|
|
273
|
-
var card = resultSection.closest && resultSection.closest('.cl-output-card');
|
|
274
|
-
if (card) {
|
|
275
|
-
card.classList.remove('cl-output-card--pending');
|
|
276
|
-
}
|
|
277
|
-
if (resultSection.dataset) {
|
|
278
|
-
resultSection.dataset.clRenderState = 'ready';
|
|
279
|
-
resultSection.dataset.clRenderReadyReason = reason || 'ready';
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function _clHasTripCardContent(el) {
|
|
284
|
-
if (!el) return false;
|
|
285
|
-
var html = el.innerHTML || '';
|
|
286
|
-
var text = el.textContent || '';
|
|
287
|
-
// Raw card tags (HTML-encoded or literal)
|
|
288
|
-
if (/(?:<|<)(?:sh_card|tr_card|i_card|bg_card|fr_card|time_data_card)(?:>|>)/.test(html)) return true;
|
|
289
|
-
if (text.includes('<sh_card>') || text.includes('<tr_card>') || text.includes('<i_card>') ||
|
|
290
|
-
text.includes('<bg_card>') || text.includes('<fr_card>') ||
|
|
291
|
-
text.includes('<time_data_card>')) return true;
|
|
292
|
-
// Ready marker
|
|
293
|
-
if (html.includes('[TRIP_CARDS_READY]')) return true;
|
|
294
|
-
// Unprocessed travel links
|
|
295
|
-
if (el.querySelector && el.querySelector('a[href*="poi_"], a[href*="hotel_"], a[href*="lodgingArea_"], a[href*="ctx_"]')) return true;
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function _clScheduleOutputCardProcessing(resultSection, model) {
|
|
300
|
-
if (!resultSection) return;
|
|
301
|
-
|
|
302
|
-
var attempts = 0;
|
|
303
|
-
function run() {
|
|
304
|
-
attempts++;
|
|
305
|
-
|
|
306
|
-
// Only process if the output actually contains travel card content.
|
|
307
|
-
// This prevents non-travel remote-agent outputs from triggering
|
|
308
|
-
// trip-card-data.json fetches and polluting CL.tripCardDataFetchFailed.
|
|
309
|
-
if (!_clHasTripCardContent(resultSection)) {
|
|
310
|
-
_clRevealOutputResult(resultSection, 'plain-output');
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (typeof _processCustomCards === 'function') {
|
|
315
|
-
try {
|
|
316
|
-
if (model && model.toolCallId && resultSection.dataset) {
|
|
317
|
-
resultSection.dataset.clToolCallId = resultSection.dataset.clToolCallId || model.toolCallId;
|
|
318
|
-
}
|
|
319
|
-
_processCustomCards(resultSection);
|
|
320
|
-
} catch (err) {
|
|
321
|
-
console.warn('[cl-output] trip card processing failed:', err && err.message);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
var processed = resultSection.dataset && resultSection.dataset.clProcessed;
|
|
326
|
-
if (processed === '1') {
|
|
327
|
-
_clRevealOutputResult(resultSection, 'trip-rendered');
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
if (attempts >= 20) {
|
|
331
|
-
_clRevealOutputResult(resultSection, processed === 'partial' ? 'trip-partial-timeout' : 'trip-timeout');
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
var delay = attempts < 4 ? 250 : 1000;
|
|
336
|
-
setTimeout(run, delay);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
setTimeout(run, 0);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// ── Sidebar Figma 145:5712 内联样式 ──
|