MCPcopy Index your code
hub / github.com/TanStack/ai / handleEvent

Function handleEvent

packages/ai-opencode/src/stream/translate.ts:333–356  ·  view source on GitHub ↗
(event: OpencodeEvent)

Source from the content-addressed store, hash-verified

331 }
332
333 function* handleEvent(event: OpencodeEvent): Generator<StreamChunk> {
334 if (event.type === 'message.part.updated') {
335 const { part, delta } = event.properties
336 if (isTextPart(part)) {
337 yield* handleTextPart(part, delta)
338 } else if (isReasoningPart(part)) {
339 yield* handleReasoningPart(part, delta)
340 } else if (isToolPart(part)) {
341 yield* handleToolPart(part)
342 }
343 // Other part kinds (file, step-start/finish, snapshot, ...) carry no
344 // state the chunk stream needs.
345 } else if (event.type === 'todo.updated') {
346 yield {
347 type: EventType.CUSTOM,
348 model,
349 timestamp: now(),
350 name: TODO_EVENT,
351 value: { todos: event.properties.todos },
352 }
353 }
354 // session.idle / session.status / message.updated are redundant with the
355 // terminal `done` event and are ignored.
356 }
357
358 function* finish(message: OpencodeAssistantMessage): Generator<StreamChunk> {
359 yield* startRun()

Callers 1

translateOpencodeStreamFunction · 0.85

Calls 7

handleTextPartFunction · 0.85
isReasoningPartFunction · 0.85
handleReasoningPartFunction · 0.85
isToolPartFunction · 0.85
handleToolPartFunction · 0.85
isTextPartFunction · 0.70
nowFunction · 0.70

Tested by

no test coverage detected