MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / addCronTask

Function addCronTask

source code/utils/cronTasks.ts:196–221  ·  view source on GitHub ↗
(
  cron: string,
  prompt: string,
  recurring: boolean,
  durable: boolean,
  agentId?: string,
)

Source from the content-addressed store, hash-verified

194 * change event is needed.
195 */
196export async function addCronTask(
197 cron: string,
198 prompt: string,
199 recurring: boolean,
200 durable: boolean,
201 agentId?: string,
202): Promise<string> {
203 // Short ID — 8 hex chars is plenty for MAX_JOBS=50, avoids slice/prefix
204 // juggling between the tool layer (shows short IDs) and disk.
205 const id = randomUUID().slice(0, 8)
206 const task = {
207 id,
208 cron,
209 prompt,
210 createdAt: Date.now(),
211 ...(recurring ? { recurring: true } : {}),
212 }
213 if (!durable) {
214 addSessionCronTask({ ...task, ...(agentId ? { agentId } : {}) })
215 return id
216 }
217 const tasks = await readCronTasks()
218 tasks.push(task)
219 await writeCronTasks(tasks)
220 return id
221}
222
223/**
224 * Remove tasks by id. No-op if none match (e.g. another session raced us).

Callers 1

callFunction · 0.85

Calls 3

addSessionCronTaskFunction · 0.85
readCronTasksFunction · 0.85
writeCronTasksFunction · 0.85

Tested by

no test coverage detected