MCPcopy
hub / github.com/claude-code-best/claude-code / dispatchHeadlessCronCommand

Function dispatchHeadlessCronCommand

src/cli/print.ts:2845–2876  ·  view source on GitHub ↗
(params: {
      basePrompt: string
      sourceId: string
      sourceLabel: string
      logSuffix: string
      onSuccess: (command: QueuedCommand) => void | Promise<void>
    })

Source from the content-addressed store, hash-verified

2843 // dispatch. onSuccess receives the claimed QueuedCommand and decides
2844 // whether to enqueue it (normal path) or mark the run failed (agent path).
2845 const dispatchHeadlessCronCommand = (params: {
2846 basePrompt: string
2847 sourceId: string
2848 sourceLabel: string
2849 logSuffix: string
2850 onSuccess: (command: QueuedCommand) => void | Promise<void>
2851 }): void => {
2852 if (inputClosed) return
2853 void (async () => {
2854 const command = await createAutonomyQueuedPromptIfNoActiveSource({
2855 basePrompt: params.basePrompt,
2856 trigger: 'scheduled-task',
2857 currentDir: cwd(),
2858 sourceId: params.sourceId,
2859 sourceLabel: params.sourceLabel,
2860 workload: WORKLOAD_CRON,
2861 shouldCreate: () => !inputClosed,
2862 })
2863 if (!command) return
2864 if (inputClosed) {
2865 await cancelQueuedAutonomyCommands({ commands: [command] })
2866 return
2867 }
2868 await params.onSuccess(command)
2869 })().catch(error => {
2870 logError(error)
2871 logForDebugging(
2872 `[ScheduledTasks] failed to enqueue headless task${params.logSuffix}: ${error}`,
2873 { level: 'error' },
2874 )
2875 })
2876 }
2877
2878 const enqueueAndRun = (command: QueuedCommand): void => {
2879 enqueue({

Callers 1

runHeadlessStreamingFunction · 0.85

Calls 5

cwdFunction · 0.85
logErrorFunction · 0.50
logForDebuggingFunction · 0.50

Tested by

no test coverage detected