MCPcopy
hub / github.com/codeaashu/claude-code / addCronTask

Function addCronTask

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

Source from the content-addressed store, hash-verified

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

Callers 1

callFunction · 0.85

Calls 4

addSessionCronTaskFunction · 0.85
readCronTasksFunction · 0.85
writeCronTasksFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected