MCPcopy Create free account
hub / github.com/Noumena-Network/code / getTaskOutputData

Function getTaskOutputData

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

Source from the content-addressed store, hash-verified

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

Callers 1

callFunction · 0.85

Calls 4

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

Tested by

no test coverage detected