cc-viewer 1.7.13 → 1.7.15

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.
@@ -165,3 +165,30 @@ export function compactResultPreview(entry, opts = {}) {
165
165
  if (!hasImages && !text) return null;
166
166
  return { text, images: hasImages ? images : null };
167
167
  }
168
+
169
+ /**
170
+ * 简化模式是否应在消息流内联 tool_result 图片。
171
+ * 与 compactResultPreview 的跳过条件(isPermissionDenied / isInputValidationError)
172
+ * 保持同一语义;另外要求至少一张「可渲染」的图(有 src 的非 oversized),
173
+ * 纯 oversized 占位不内联(否则消息流里全是虚线占位噪音)。
174
+ *
175
+ * @param {object|null} entry - toolResultMap 条目(可能为 undefined:SubAgent 末轮
176
+ * tool_use 的 result 未到位 / WebSearch / 历史计数缺口等窗口)
177
+ * @returns {boolean}
178
+ */
179
+ export function shouldInlineToolImages(entry) {
180
+ if (!entry || typeof entry !== 'object') return false;
181
+ if (entry.isPermissionDenied || entry.isInputValidationError) return false;
182
+ if (!Array.isArray(entry.images) || entry.images.length === 0) return false;
183
+ return entry.images.some((img) => img && img.src && !img.oversized);
184
+ }
185
+
186
+ /**
187
+ * oversized 图片占位文案(3 处复用:ToolResultView / ChatMessage Popover / 内联块)。
188
+ * `[image png · 512 KB · too large to preview]`
189
+ */
190
+ export function formatOversizedImagePlaceholder(img) {
191
+ const mediaType = (img && img.mediaType ? String(img.mediaType).replace('image/', '') : 'image');
192
+ const sizeKB = img && typeof img.sizeBytes === 'number' ? Math.round(img.sizeBytes / 1024) : 0;
193
+ return `[image ${mediaType} · ${sizeKB} KB · too large to preview]`;
194
+ }