MCPcopy Create free account
hub / github.com/TanStack/ai / finish

Function finish

packages/ai-opencode/src/stream/translate.ts:358–387  ·  view source on GitHub ↗
(message: OpencodeAssistantMessage)

Source from the content-addressed store, hash-verified

356 }
357
358 function* finish(message: OpencodeAssistantMessage): Generator<StreamChunk> {
359 yield* startRun()
360 yield* closeText()
361 yield* closeReasoning()
362 yield* synthesizeUnresolvedResults()
363
364 const error = messageError(message)
365 if (error) {
366 yield {
367 type: EventType.RUN_ERROR,
368 model,
369 timestamp: now(),
370 message: error.message,
371 error,
372 }
373 return
374 }
375
376 const usage = buildUsage(message.tokens)
377 const finishReason = message.finish === 'length' ? 'length' : 'stop'
378 yield {
379 type: EventType.RUN_FINISHED,
380 runId,
381 threadId,
382 model,
383 timestamp: now(),
384 finishReason,
385 ...(usage !== undefined && { usage }),
386 }
387 }
388
389 try {
390 for await (const streamEvent of events) {

Callers 2

translateOpencodeStreamFunction · 0.70
execMethod · 0.50

Calls 7

messageErrorFunction · 0.85
startRunFunction · 0.70
closeTextFunction · 0.70
closeReasoningFunction · 0.70
nowFunction · 0.70
buildUsageFunction · 0.70

Tested by

no test coverage detected