Reference
?

TaskEvent

Type
One event from a streaming run, delivered to the onEvent callback.

The event passed to runTask's onEvent callback when you stream a run instead of polling. text and thinking carry the model's output as it forms, tool_call_start and tool_call_result bracket each tool call, done carries the final structured output, and error reports a failure. The shape past type varies by event, so branch on type. Without onEvent, a run resolves silently when complete.

TaskEvent.ts
interface TaskEvent {
  type: 'text' | 'thinking' | 'thinking_complete'
      | 'tool_use' | 'tool_input_delta' | 'tool_input_args'
      | 'tool_call_start' | 'tool_call_result' | 'error' | 'done'
  [key: string]: unknown
}
Fields
type
enum (10 values)
Which event this is. The rest of the payload depends on it, so branch on type.
Stream a run
await mindstudio.runTask({
  /* ... */
  onEvent: (e) => {
    if (e.type === 'tool_call_start') showActivity(e.name);
    if (e.type === 'text') append(e.text);
  },
});