MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / cancelAutonomyFlowText

Function cancelAutonomyFlowText

src/cli/handlers/autonomy.ts:125–162  ·  view source on GitHub ↗
(
  flowId: string,
  options?: {
    removeQueuedInMemory?: boolean
    rootDir?: string
  },
)

Source from the content-addressed store, hash-verified

123}
124
125export async function cancelAutonomyFlowText(
126 flowId: string,
127 options?: {
128 removeQueuedInMemory?: boolean
129 rootDir?: string
130 },
131): Promise<string> {
132 const cancelled = await requestManagedAutonomyFlowCancel({
133 flowId,
134 rootDir: options?.rootDir,
135 })
136 if (!cancelled) {
137 return 'Autonomy flow not found.'
138 }
139 if (!cancelled.accepted) {
140 return `Autonomy flow ${flowId} is already terminal (${cancelled.flow.status}).`
141 }
142
143 let removedCount = 0
144 if (options?.removeQueuedInMemory) {
145 const removed = removeByFilter(cmd => cmd.autonomy?.flowId === flowId)
146 removedCount = removed.length
147 for (const command of removed) {
148 if (command.autonomy?.runId) {
149 await markAutonomyRunCancelled(command.autonomy.runId, options?.rootDir)
150 }
151 }
152 } else {
153 for (const runId of cancelled.queuedRunIds) {
154 await markAutonomyRunCancelled(runId, options?.rootDir)
155 }
156 removedCount = cancelled.queuedRunIds.length
157 }
158
159 return cancelled.flow.status === 'running'
160 ? `Cancellation requested for flow ${flowId}. The current step is still running, and no new steps will be started.`
161 : `Cancelled flow ${flowId}. Removed ${removedCount} queued step(s).`
162}
163
164export async function autonomyFlowCancelHandler(flowId: string): Promise<void> {
165 process.stdout.write(`${await cancelAutonomyFlowText(flowId)}\n`)

Callers 3

autonomy.test.tsFile · 0.90
getAutonomyCommandTextFunction · 0.85

Calls 3

removeByFilterFunction · 0.85
markAutonomyRunCancelledFunction · 0.85

Tested by

no test coverage detected