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

Function toolResultOutput

packages/opencode/src/session/processor.ts:255–274  ·  view source on GitHub ↗
(
        value: Extract<StreamEvent, { type: "tool-result" }>,
      )

Source from the content-addressed store, hash-verified

253 const isFilePart = (value: unknown): value is SessionV1.FilePart => Schema.is(SessionV1.FilePart)(value)
254
255 const toolResultOutput = (
256 value: Extract<StreamEvent, { type: "tool-result" }>,
257 ): { title: string; metadata: Record<string, any>; output: string; attachments?: SessionV1.FilePart[] } => {
258 if (isRecord(value.result.value) && typeof value.result.value.output === "string") {
259 return {
260 title: typeof value.result.value.title === "string" ? value.result.value.title : value.name,
261 metadata: isRecord(value.result.value.metadata) ? value.result.value.metadata : {},
262 output: value.result.value.output,
263 attachments: Array.isArray(value.result.value.attachments)
264 ? value.result.value.attachments.filter(isFilePart)
265 : undefined,
266 }
267 }
268 return {
269 title: value.name,
270 metadata: value.result.type === "json" && isRecord(value.result.value) ? value.result.value : {},
271 output:
272 typeof value.result.value === "string" ? value.result.value : (JSON.stringify(value.result.value) ?? ""),
273 }
274 }
275
276 const handleEvent = Effect.fnUntraced(function* (value: StreamEvent) {
277 switch (value.type) {

Callers 1

processor.tsFile · 0.85

Calls 1

isRecordFunction · 0.90

Tested by

no test coverage detected