sdkProgress.ts
utils/task/sdkProgress.ts
No strong subsystem tag
37
Lines
1153
Bytes
1
Exports
2
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with general runtime concerns. It contains 37 lines, 2 detected imports, and 1 detected exports.
Important relationships
Detected exports
emitTaskProgress
Keywords
paramsdescriptionsummarysdkworkflowprogressenqueuesdkeventtask_progressagentsworkflowstaskidtooluseid
Detected imports
../../types/tools.js../sdkEventQueue.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
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,
})
}