MCPcopy Create free account
hub / github.com/freecodexyz/free-code / kill

Function kill

src/tasks/DreamTask/DreamTask.ts:136–156  ·  view source on GitHub ↗
(taskId, setAppState)

Source from the content-addressed store, hash-verified

134 type: 'dream',
135
136 async kill(taskId, setAppState) {
137 let priorMtime: number | undefined
138 updateTaskState<DreamTaskState>(taskId, setAppState, task => {
139 if (task.status !== 'running') return task
140 task.abortController?.abort()
141 priorMtime = task.priorMtime
142 return {
143 ...task,
144 status: 'killed',
145 endTime: Date.now(),
146 notified: true,
147 abortController: undefined,
148 }
149 })
150 // Rewind the lock mtime so the next session can retry. Same path as the
151 // fork-failure catch in autoDream.ts. If updateTaskState was a no-op
152 // (already terminal), priorMtime stays undefined and we skip.
153 if (priorMtime !== undefined) {
154 await rollbackConsolidationLock(priorMtime)
155 }
156 },
157}

Callers

nothing calls this directly

Calls 2

updateTaskStateFunction · 0.50

Tested by

no test coverage detected