(commit: StreamCommit, raw: string)
| 1418 | } |
| 1419 | |
| 1420 | export function toolEntryBody(commit: StreamCommit, raw: string): RunEntryBody | undefined { |
| 1421 | if (commit.shell) { |
| 1422 | if (commit.phase === "start") { |
| 1423 | return textBody(`$ ${commit.shell.command}`) |
| 1424 | } |
| 1425 | |
| 1426 | if (commit.phase === "progress") { |
| 1427 | return textBody(shellOutput(commit.shell.command, raw) ?? "") |
| 1428 | } |
| 1429 | |
| 1430 | return undefined |
| 1431 | } |
| 1432 | |
| 1433 | const ctx = toolFrame(commit, raw) |
| 1434 | const view = toolView(ctx.name) |
| 1435 | |
| 1436 | if (ctx.name === "task") { |
| 1437 | if (commit.phase === "start") { |
| 1438 | return undefined |
| 1439 | } |
| 1440 | |
| 1441 | if (commit.phase === "final" && ctx.status === "completed") { |
| 1442 | const result = taskResult(text(ctx.state.output)) |
| 1443 | if (result) { |
| 1444 | return markdownBody(result) |
| 1445 | } |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | if (commit.phase === "progress" && !view.output) { |
| 1450 | return undefined |
| 1451 | } |
| 1452 | |
| 1453 | if (commit.phase === "final") { |
| 1454 | if (ctx.status === "error") { |
| 1455 | return textBody(toolScroll("final", ctx)) |
| 1456 | } |
| 1457 | |
| 1458 | if (!view.final) { |
| 1459 | return undefined |
| 1460 | } |
| 1461 | |
| 1462 | if (ctx.status && ctx.status !== "completed") { |
| 1463 | return textBody(ctx.raw.trim()) |
| 1464 | } |
| 1465 | |
| 1466 | if (toolStructuredFinal(commit)) { |
| 1467 | return structuredBody(commit, raw) ?? textBody(toolScroll("final", ctx)) |
| 1468 | } |
| 1469 | } |
| 1470 | |
| 1471 | return textBody(toolScroll(commit.phase, ctx)) |
| 1472 | } |
| 1473 | |
| 1474 | export function toolFiletype(input?: string): string | undefined { |
| 1475 | if (!input) { |
no test coverage detected