{"version":3,"file":"ToolCard.mjs","names":[],"sources":["../../../../src/web/features/session/ToolCard.tsx"],"sourcesContent":["import {\n  t,\n  type ToolMessageRenderProps,\n  type ToolOutputDescriptor,\n  useT,\n  type WebPluginSlotProps,\n} from '@agimon-ai/po-core/web';\nimport {\n  collapseLines,\n  MessageItem,\n  MessageItemBody,\n  MessageItemHeader,\n  MessageItemHeaderAccessoryContext,\n  StatusBadge,\n  MessageItemStatus,\n  PathText,\n  type StatusTone,\n  ViewableImage,\n} from '@agimon-ai/po-web-components';\nimport { memo, type ReactNode, useMemo } from 'react';\n\nimport { pluginToolRenderer } from '../../lib/pluginRegistry';\nimport { imagesFromContent, textFromContent, type ToolEntry } from '../../lib/sessionModel';\nimport { toolMessageProps } from '../../lib/toolMessageProps';\nimport { ToolRendererBoundary } from '../../lib/ToolRendererBoundary';\nimport { useImageRefs } from '../../stores/imageRefStore';\n\nconst MAX_PREVIEW_LINES = 12;\n\ntype AttachmentKind = 'image' | 'audio' | 'video' | 'pdf' | 'text' | 'file';\n\ninterface HostAttachment {\n  kind: AttachmentKind;\n  mimeType: string;\n  name: string;\n  data?: string;\n  text?: string;\n  uri?: string;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction attachmentKind(mimeType: string): AttachmentKind {\n  if (mimeType.startsWith('image/')) return 'image';\n  if (mimeType.startsWith('audio/')) return 'audio';\n  if (mimeType.startsWith('video/')) return 'video';\n  if (mimeType === 'application/pdf') return 'pdf';\n  if (mimeType.startsWith('text/')) return 'text';\n  return 'file';\n}\n\nfunction attachmentName(block: Record<string, unknown>, index: number): string {\n  for (const key of ['title', 'name', 'filename', 'fileName']) {\n    if (typeof block[key] === 'string' && block[key].length > 0) return block[key];\n  }\n  if (typeof block.uri === 'string' && block.uri.length > 0) return block.uri.split('/').at(-1) || block.uri;\n  return `attachment-${String(index + 1)}`;\n}\n\n/** Binary and linked result blocks a tool returned outside its ordinary text. */\nfunction hostAttachments(entry: ToolEntry): HostAttachment[] {\n  const content = entry.result?.content ?? [];\n  // An image sent by reference shows once its entry is read; until then it has no data to draw.\n  const images = imagesFromContent(content).map((image, index): HostAttachment => ({\n    kind: 'image',\n    mimeType: image.mimeType,\n    name: `${entry.name}-result-${String(index + 1)}`,\n    data: image.data,\n  }));\n  const details = isRecord(entry.result?.details) ? entry.result.details : undefined;\n  const blocks = [...content, ...(Array.isArray(details?.blocks) ? details.blocks : [])];\n  const other = blocks.flatMap((candidate, index): HostAttachment[] => {\n    if (!isRecord(candidate) || candidate.type === 'text' || candidate.type === 'image') return [];\n    const resource = candidate.type === 'resource' && isRecord(candidate.resource) ? candidate.resource : candidate;\n    const mimeType = typeof resource.mimeType === 'string' ? resource.mimeType : 'application/octet-stream';\n    const data =\n      typeof resource.data === 'string' ? resource.data : typeof resource.blob === 'string' ? resource.blob : undefined;\n    const text = typeof resource.text === 'string' ? resource.text : undefined;\n    const uri = typeof resource.uri === 'string' ? resource.uri : undefined;\n    if (data === undefined && text === undefined && uri === undefined) return [];\n    return [{ kind: attachmentKind(mimeType), mimeType, name: attachmentName(resource, index), data, text, uri }];\n  });\n  return [...images, ...other];\n}\n\nconst VISUAL_MIME = /^(?:image|video)\\/|^text\\/html\\b/u;\nconst VISUAL_SCAN_DEPTH = 8;\nconst VISUAL_SCAN_NODES = 2000;\n\n/**\n * Whether a call's result carries something to look at: an image, a video, or an HTML widget (an MCP App's `ui://`\n * resource). It also looks inside the calls a tool made for the agent, such as exec's, since those render nested.\n * Bounded, because it runs on every grouped row.\n */\nexport function hasVisualOutput(entry: ToolEntry): boolean {\n  let nodes = VISUAL_SCAN_NODES;\n  const visit = (value: unknown, depth: number): boolean => {\n    if (depth > VISUAL_SCAN_DEPTH || --nodes < 0) return false;\n    if (Array.isArray(value)) return value.some((item) => visit(item, depth + 1));\n    if (!isRecord(value)) return false;\n    if (value.type === 'image') return true;\n    if (typeof value.mimeType === 'string' && VISUAL_MIME.test(value.mimeType)) return true;\n    if (typeof value.resourceUri === 'string' && value.resourceUri.startsWith('ui://')) return true;\n    return Object.values(value).some((child) => visit(child, depth + 1));\n  };\n  return visit(entry.result, 0);\n}\n\nfunction attachmentUrl(attachment: HostAttachment): string | undefined {\n  if (attachment.data !== undefined) return `data:${attachment.mimeType};base64,${attachment.data}`;\n  if (attachment.uri === undefined) return undefined;\n  return /^(?:https?):\\/\\//u.test(attachment.uri) ? attachment.uri : undefined;\n}\n\nfunction HostAttachmentView({ attachment, index }: { attachment: HostAttachment; index: number }) {\n  const url = attachmentUrl(attachment);\n  if (attachment.kind === 'text' && attachment.text !== undefined) {\n    return (\n      <pre\n        data-testid=\"tool-output-text-file\"\n        className=\"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border border-po-border-soft p-2\"\n      >\n        {attachment.text}\n      </pre>\n    );\n  }\n  if (url !== undefined && attachment.kind === 'image') {\n    return (\n      <ViewableImage\n        src={url}\n        alt={attachment.name}\n        data-testid=\"tool-output-image\"\n        className=\"h-auto max-h-96 max-w-full rounded-md border border-po-border-soft object-contain\"\n      />\n    );\n  }\n  if (url !== undefined && attachment.kind === 'video') {\n    return (\n      <video\n        src={url}\n        controls\n        preload=\"metadata\"\n        data-testid=\"tool-output-video\"\n        className=\"max-h-96 max-w-full self-start rounded-md border border-po-border-soft\"\n      >\n        <track kind=\"captions\" />\n      </video>\n    );\n  }\n  if (url !== undefined && attachment.kind === 'audio') {\n    return (\n      <audio src={url} controls preload=\"metadata\" data-testid=\"tool-output-audio\" className=\"w-full\">\n        <track kind=\"captions\" />\n      </audio>\n    );\n  }\n  if (url !== undefined && attachment.kind === 'pdf') {\n    return (\n      <iframe\n        src={url}\n        title={attachment.name}\n        data-testid=\"tool-output-pdf\"\n        className=\"h-[480px] w-full rounded-md border border-po-border-soft bg-po-deep\"\n      />\n    );\n  }\n  return url !== undefined ? (\n    <a\n      href={url}\n      download={attachment.name}\n      target=\"_blank\"\n      rel=\"noreferrer\"\n      data-testid=\"tool-output-file\"\n      className=\"self-start rounded-md border border-po-border px-3 py-2 text-po-blue hover:border-po-blue/60\"\n    >\n      {attachment.name} · {attachment.mimeType}\n    </a>\n  ) : (\n    <span\n      key={index}\n      data-testid=\"tool-output-file\"\n      className=\"self-start rounded-md border border-po-border px-3 py-2 text-base text-po-dim\"\n    >\n      {attachment.name} · {attachment.mimeType}\n    </span>\n  );\n}\n\nfunction toneOf(entry: ToolEntry): StatusTone {\n  return entry.running ? 'running' : entry.isError ? 'error' : 'ok';\n}\n\n/**\n * The host's own item for a tool no plugin claims: the argument summary in\n * the header and the result's text and safe browser previews, with long text\n * clipped until expanded, on the same shell every plugin message is built from.\n */\nfunction HostToolMessage({\n  entry,\n  slotProps,\n  suppressOutputs,\n}: {\n  entry: ToolEntry;\n  slotProps: WebPluginSlotProps;\n  suppressOutputs?: boolean;\n}) {\n  const t = useT();\n  const lines = entry.output.length > 0 ? entry.output.split('\\n') : [];\n  const attachments = suppressOutputs\n    ? []\n    : hostAttachments(entry).filter(\n        (attachment) => attachment.kind !== 'image' || attachment.data !== undefined || attachment.uri !== undefined,\n      );\n  return (\n    <MessageItem tone={toneOf(entry)} expandable={lines.length > MAX_PREVIEW_LINES}>\n      {({ expanded }) => {\n        const { shown, hidden } = collapseLines(lines, MAX_PREVIEW_LINES, expanded);\n        return (\n          <>\n            <MessageItemHeader title={entry.name}>\n              <span className=\"min-w-0 flex-1 truncate\">{entry.argSummary}</span>\n            </MessageItemHeader>\n            {shown.length > 0 || attachments.length > 0 ? (\n              <MessageItemBody className=\"flex flex-col gap-2\">\n                {shown.length > 0 ? (\n                  <pre data-testid=\"tool-output\" className=\"whitespace-pre-wrap break-words\">\n                    <PathText\n                      text={shown.join('\\n')}\n                      onFileLink={(path) => {\n                        const tab = slotProps.fileTabFor(path);\n                        return tab && (() => slotProps.openTransientTab(tab));\n                      }}\n                    />\n                  </pre>\n                ) : null}\n                {attachments.map((attachment, index) => (\n                  <HostAttachmentView\n                    key={`${attachment.mimeType}:${attachment.name}:${String(index)}`}\n                    attachment={attachment}\n                    index={index}\n                  />\n                ))}\n                {hidden > 0 ? (\n                  <MessageItemStatus expands>\n                    {t('webDashboard.session.showMoreLines', 'show {count} more line(s)', { count: hidden })}\n                  </MessageItemStatus>\n                ) : null}\n              </MessageItemBody>\n            ) : null}\n          </>\n        );\n      }}\n    </MessageItem>\n  );\n}\n\n/** Resolves sealed transcript image references only when an output is actually mounted. */\nfunction ToolOutputContent({\n  entry,\n  slotProps,\n  statuses,\n  id,\n  index,\n}: {\n  entry: ToolEntry;\n  slotProps: WebPluginSlotProps;\n  statuses: Readonly<Record<string, string>>;\n  id: string;\n  index: number;\n}) {\n  const result = useImageRefs(entry.result);\n  const resolved = result === entry.result ? entry : { ...entry, result };\n  const renderer = pluginToolRenderer(entry.name, statuses, result?.details);\n  if (renderer?.outputs) {\n    return renderer.outputs(outputProps(slotProps, resolved, statuses)).find((output) => output.id === id)?.content;\n  }\n  const attachment = hostAttachments(resolved)[index];\n  return attachment ? <HostAttachmentView attachment={attachment} index={index} /> : null;\n}\n\n/** Pure, opt-in collection. Existing message rendering never calls this or mounts a second output. */\nexport function toolOutputDescriptors(\n  entry: ToolEntry,\n  slotProps: WebPluginSlotProps,\n  statuses: Readonly<Record<string, string>>,\n): readonly ToolOutputDescriptor[] {\n  try {\n    const renderer = pluginToolRenderer(entry.name, statuses, entry.result?.details);\n    const outputs = renderer?.outputs\n      ? renderer.outputs(outputProps(slotProps, entry, statuses))\n      : hostAttachments(entry).map((attachment, index) => ({\n          id: `attachment:${String(index)}`,\n          title: attachment.name,\n        }));\n    return outputs.map((output, index) => ({\n      id: `${entry.toolCallId}:${output.id}`,\n      title: output.title,\n      content: (\n        <ToolRendererBoundary key={`${entry.toolCallId}:${output.id}`} toolName={entry.name}>\n          {(failed) =>\n            failed ? (\n              <p role=\"alert\">\n                {t(\n                  'webDashboard.session.outputDisplayFailed',\n                  'This output could not be displayed. View activity for tool details.',\n                )}\n              </p>\n            ) : (\n              <ToolOutputContent entry={entry} slotProps={slotProps} statuses={statuses} id={output.id} index={index} />\n            )\n          }\n        </ToolRendererBoundary>\n      ),\n    }));\n  } catch {\n    // A faulty output provider must not take down the transcript or lose its original result.\n    return [\n      {\n        id: `${entry.toolCallId}:output-unavailable`,\n        title: t('webDashboard.session.outputUnavailable', 'Output unavailable'),\n        content: (\n          <div>\n            <p role=\"alert\">\n              {t(\n                'webDashboard.session.outputSeparateFailed',\n                'This output could not be separated from its tool details.',\n              )}\n            </p>\n            <ToolCard entry={entry} slotProps={slotProps} statuses={statuses} />\n          </div>\n        ),\n      },\n    ];\n  }\n}\n\n/** Collects one-line summaries without mounting the tool card. */\nexport function toolActivitySummaries(\n  entry: ToolEntry,\n  slotProps: WebPluginSlotProps,\n  statuses: Readonly<Record<string, string>>,\n): readonly string[] {\n  try {\n    const renderer = pluginToolRenderer(entry.name, statuses, entry.result?.details);\n    return (\n      renderer?.activity?.({\n        ...toolMessageProps(slotProps, entry, statuses),\n        toolActivity: (call) => {\n          try {\n            const nested = pluginToolRenderer(call.toolName, statuses, call.result?.details);\n            return nested?.activity?.(nestedProps(entry, call, slotProps, statuses)) ?? [];\n          } catch {\n            return [];\n          }\n        },\n      }) ?? []\n    );\n  } catch {\n    return [];\n  }\n}\n\ntype NestedCall = Parameters<NonNullable<ToolMessageRenderProps['renderTool']>>[0];\n\n/** The props a nested tool's renderer gets: the call as the parent recorded it, settled, and no nesting of its own. */\nfunction nestedProps(\n  parent: ToolEntry,\n  call: NestedCall,\n  slotProps: WebPluginSlotProps,\n  statuses: Readonly<Record<string, string>>,\n  suppressOutputs?: boolean,\n): ToolMessageRenderProps {\n  return {\n    ...slotProps,\n    suppressOutputs,\n    toolCallId: `${parent.toolCallId}:${call.toolName}`,\n    toolName: call.toolName,\n    args: call.args,\n    statuses,\n    result: call.result,\n    output: textFromContent(call.result?.content),\n    running: false,\n    isError: call.isError,\n  };\n}\n\n/** What the nested call's own tool collects as outputs; empty when no plugin claims it or it collects nothing. */\nfunction nestedToolOutputs(\n  parent: ToolEntry,\n  call: NestedCall,\n  slotProps: WebPluginSlotProps,\n  statuses: Readonly<Record<string, string>>,\n): readonly ToolOutputDescriptor[] {\n  const renderer = pluginToolRenderer(call.toolName, statuses, call.result?.details);\n  return renderer?.outputs?.(nestedProps(parent, call, slotProps, statuses)) ?? [];\n}\n\n/** A tool's props for output collection, reaching the outputs of calls it made on the agent's behalf. */\nfunction outputProps(\n  slotProps: WebPluginSlotProps,\n  entry: ToolEntry,\n  statuses: Readonly<Record<string, string>>,\n): ToolMessageRenderProps {\n  return {\n    ...toolMessageProps(slotProps, entry, statuses),\n    toolOutputs: (call) => nestedToolOutputs(entry, call, slotProps, statuses),\n  };\n}\n\n/**\n * Another tool's own card for a call made on its behalf, with the call's recorded args and result. Null when no\n * plugin claims the tool. It gets no `renderTool` itself, so a card inside a card cannot nest further. It follows\n * the parent's `suppressOutputs`, since a view that lifts outputs out also lifts the nested ones.\n */\nexport function nestedToolCard(\n  parent: ToolEntry,\n  call: NestedCall,\n  slotProps: WebPluginSlotProps,\n  statuses: Readonly<Record<string, string>>,\n  suppressOutputs?: boolean,\n): ReactNode {\n  const renderer = pluginToolRenderer(call.toolName, statuses, call.result?.details);\n  if (!renderer) return null;\n  const props = nestedProps(parent, call, slotProps, statuses, suppressOutputs);\n  return (\n    <ToolRendererBoundary toolName={call.toolName}>\n      {(failed) =>\n        failed ? (\n          <pre className=\"whitespace-pre-wrap break-words text-sm\">{props.output}</pre>\n        ) : (\n          <renderer.message {...props} />\n        )\n      }\n    </ToolRendererBoundary>\n  );\n}\n\n/**\n * One tool call in the timeline. The plugin that registered the tool owns\n * the whole item through its `message` renderer, the web half of the TUI's\n * renderShell 'self'; the host only marks the row, catches a renderer that\n * throws, and stands in for a tool nobody claims.\n */\nexport const ToolCard = memo(function ToolCard({\n  entry: shown,\n  slotProps,\n  statuses,\n  suppressOutputs,\n}: {\n  entry: ToolEntry;\n  slotProps: WebPluginSlotProps;\n  statuses: Readonly<Record<string, string>>;\n  suppressOutputs?: boolean;\n}) {\n  const t = useT();\n  // Renderers read result images inline, so one the transcript sent by reference is filled in once read.\n  const result = useImageRefs(shown.result);\n  const entry = useMemo(() => (result === shown.result ? shown : { ...shown, result }), [shown, result]);\n  const renderer = pluginToolRenderer(entry.name, statuses, entry.result?.details);\n  const state = toneOf(entry);\n  const props: ToolMessageRenderProps = {\n    ...toolMessageProps(slotProps, entry, statuses),\n    suppressOutputs,\n    renderTool: (call) => nestedToolCard(entry, call, slotProps, statuses, suppressOutputs),\n  };\n  // ponytail: mirrors po-hook's status key; share a constant if another consumer needs it.\n  const hookStatus = statuses[`repository-hooks:${entry.toolCallId}:post`]?.trim();\n  const hookBadge = hookStatus ? (\n    <StatusBadge tone=\"running\" title={hookStatus} aria-label={hookStatus} data-testid=\"tool-hook-status\">\n      {t('webDashboard.session.hookBadge', 'HOOK')}\n    </StatusBadge>\n  ) : null;\n  return (\n    <ToolRendererBoundary key={entry.toolCallId} toolName={entry.name}>\n      {(failed) => (\n        <div\n          data-testid=\"entry-tool\"\n          data-tool-name={entry.name}\n          data-tool-state={state}\n          data-tool-renderer={failed ? 'failed' : renderer ? 'plugin' : 'host'}\n        >\n          <MessageItemHeaderAccessoryContext value={hookBadge}>\n            {renderer && !failed ? (\n              <renderer.message {...props} />\n            ) : (\n              <HostToolMessage entry={entry} slotProps={slotProps} suppressOutputs={suppressOutputs} />\n            )}\n          </MessageItemHeaderAccessoryContext>\n        </div>\n      )}\n    </ToolRendererBoundary>\n  );\n});\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,oBAAoB;AAa1B,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,eAAe,UAAkC;CACxD,IAAI,SAAS,WAAW,QAAQ,GAAG,OAAO;CAC1C,IAAI,SAAS,WAAW,QAAQ,GAAG,OAAO;CAC1C,IAAI,SAAS,WAAW,QAA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