@nanocollective/nanocoder
Version:
A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter
27 lines • 929 B
JavaScript
/**
* Create cancellation results for tool calls
* Used when user cancels tool execution to maintain conversation state integrity
*
* This utility eliminates duplication of cancellation result creation logic
*
* @param toolCalls - Array of tool calls that were cancelled
* @returns Array of tool results indicating cancellation
*
* @example
* const cancellationResults = createCancellationResults(pendingToolCalls);
* const toolMessages = cancellationResults.map(result => ({
* role: 'tool' as const,
* content: result.content,
* tool_call_id: result.tool_call_id,
* name: result.name,
* }));
*/
export function createCancellationResults(toolCalls) {
return toolCalls.map(toolCall => ({
tool_call_id: toolCall.id,
role: 'tool',
name: toolCall.function.name,
content: 'Tool execution was cancelled by the user.',
}));
}
//# sourceMappingURL=tool-cancellation.js.map