MCPcopy
hub / github.com/codeaashu/claude-code / getTaskOutputData

Function getTaskOutputData

src/tools/TaskOutputTool/TaskOutputTool.tsx:60–115  ·  view source on GitHub ↗
(task: TaskState)

Source from the content-addressed store, hash-verified

58
59// Get output for any task type
60async function getTaskOutputData(task: TaskState): Promise<TaskOutput> {
61 let output: string;
62 if (task.type === 'local_bash') {
63 const bashTask = task as LocalShellTaskState;
64 const taskOutputObj = bashTask.shellCommand?.taskOutput;
65 if (taskOutputObj) {
66 const stdout = await taskOutputObj.getStdout();
67 const stderr = taskOutputObj.getStderr();
68 output = [stdout, stderr].filter(Boolean).join('\n');
69 } else {
70 output = await getTaskOutput(task.id);
71 }
72 } else {
73 output = await getTaskOutput(task.id);
74 }
75 const baseOutput: TaskOutput = {
76 task_id: task.id,
77 task_type: task.type,
78 status: task.status,
79 description: task.description,
80 output
81 };
82
83 // Add type-specific fields
84 if (task.type === 'local_bash') {
85 const bashTask = task as LocalShellTaskState;
86 return {
87 ...baseOutput,
88 exitCode: bashTask.result?.code ?? null
89 };
90 }
91 if (task.type === 'local_agent') {
92 const agentTask = task as LocalAgentTaskState;
93 // Prefer the clean final answer from the in-memory result over the raw
94 // JSONL transcript on disk. The disk output is a symlink to the full
95 // session transcript (every message, tool use, etc.), not just the
96 // subagent's answer. The in-memory result contains only the final
97 // assistant text content blocks.
98 const cleanResult = agentTask.result ? extractTextContent(agentTask.result.content, '\n') : undefined;
99 return {
100 ...baseOutput,
101 prompt: agentTask.prompt,
102 result: cleanResult || output,
103 output: cleanResult || output,
104 error: agentTask.error
105 };
106 }
107 if (task.type === 'remote_agent') {
108 const remoteTask = task as RemoteAgentTaskState;
109 return {
110 ...baseOutput,
111 prompt: remoteTask.command
112 };
113 }
114 return baseOutput;
115}
116
117// Wait for task to complete

Callers 1

callFunction · 0.85

Calls 4

getStdoutMethod · 0.80
getStderrMethod · 0.80
getTaskOutputFunction · 0.50
extractTextContentFunction · 0.50

Tested by

no test coverage detected