MCPcopy Index your code
hub / github.com/anomalyco/opencode / toolEntryBody

Function toolEntryBody

packages/opencode/src/cli/cmd/run/tool.ts:1420–1472  ·  view source on GitHub ↗
(commit: StreamCommit, raw: string)

Source from the content-addressed store, hash-verified

1418}
1419
1420export 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
1474export function toolFiletype(input?: string): string | undefined {
1475 if (!input) {

Callers 1

entryBodyFunction · 0.90

Calls 10

shellOutputFunction · 0.85
toolFrameFunction · 0.85
toolViewFunction · 0.85
taskResultFunction · 0.85
toolScrollFunction · 0.85
toolStructuredFinalFunction · 0.85
structuredBodyFunction · 0.85
textBodyFunction · 0.70
textFunction · 0.70
markdownBodyFunction · 0.70

Tested by

no test coverage detected