π File detail
utils/task/sdkProgress.ts
π§© .tsπ 37 linesπΎ 1,153 bytesπ text
β Back to All Filesπ― Use case
This file lives under βutils/β, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, β¦). On the API surface it exposes emitTaskProgress β mainly functions, hooks, or classes. It composes internal code from types and sdkEventQueue (relative imports).
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
import type { SdkWorkflowProgress } from '../../types/tools.js' import { enqueueSdkEvent } from '../sdkEventQueue.js' /** * Emit a `task_progress` SDK event. Shared by background agents (per tool_use
π€ Exports (heuristic)
emitTaskProgress
π₯οΈ Source preview
import type { SdkWorkflowProgress } from '../../types/tools.js'
import { enqueueSdkEvent } from '../sdkEventQueue.js'
/**
* Emit a `task_progress` SDK event. Shared by background agents (per tool_use
* in runAsyncAgentLifecycle) and workflows (per flushProgress batch). Accepts
* already-computed primitives so callers can derive them from their own state
* shapes (ProgressTracker for agents, LocalWorkflowTaskState for workflows).
*/
export function emitTaskProgress(params: {
taskId: string
toolUseId: string | undefined
description: string
startTime: number
totalTokens: number
toolUses: number
lastToolName?: string
summary?: string
workflowProgress?: SdkWorkflowProgress[]
}): void {
enqueueSdkEvent({
type: 'system',
subtype: 'task_progress',
task_id: params.taskId,
tool_use_id: params.toolUseId,
description: params.description,
usage: {
total_tokens: params.totalTokens,
tool_uses: params.toolUses,
duration_ms: Date.now() - params.startTime,
},
last_tool_name: params.lastToolName,
summary: params.summary,
workflow_progress: params.workflowProgress,
})
}