import * as React from 'react';
import { DIAMOND_FILLED, DIAMOND_OPEN } from '../../constants/figures.js';
import { NO_CONTENT_MESSAGE } from '../../constants/messages.js';
import { Box, Text } from '@anthropic/ink';
import { extractTag } from '../../utils/messages.js';
import { Markdown } from '../Markdown.js';
import { MessageResponse } from '../MessageResponse.js';
type Props = {
content: string;
};
export function UserLocalCommandOutputMessage({ content }: Props): React.ReactNode {
const stdout = extractTag(content, 'local-command-stdout');
const stderr = extractTag(content, 'local-command-stderr');
if (!stdout && !stderr) {
return (
{NO_CONTENT_MESSAGE}
);
}
const lines: React.ReactNode[] = [];
if (stdout?.trim()) {
lines.push({stdout.trim()});
}
if (stderr?.trim()) {
lines.push({stderr.trim()});
}
return lines;
}
function IndentedContent({ children }: { children: string }): React.ReactNode {
if (children.startsWith(`${DIAMOND_OPEN} `) || children.startsWith(`${DIAMOND_FILLED} `)) {
return {children};
}
return (
{' ⎿ '}
{children}
);
}
function CloudLaunchContent({ children }: { children: string }): React.ReactNode {
const diamond = children[0]!;
const nl = children.indexOf('\n');
const header = nl === -1 ? children.slice(2) : children.slice(2, nl);
const rest = nl === -1 ? '' : children.slice(nl + 1).trim();
const sep = header.indexOf(' · ');
const label = sep === -1 ? header : header.slice(0, sep);
const suffix = sep === -1 ? '' : header.slice(sep);
return (
{diamond}
{label}
{suffix && {suffix}}
{rest && (
{' ⎿ '}
{rest}
)}
);
}