MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / execute

Function execute

src/runtime/tools/manage-schedule-tool.ts:168–301  ·  view source on GitHub ↗
(
      _toolCallId,
      params: ManageScheduleInput,
      _signal,
      _onUpdate,
      _ctx,
    )

Source from the content-addressed store, hash-verified

166 ].join("\n"),
167 parameters: ManageScheduleParams,
168 async execute(
169 _toolCallId,
170 params: ManageScheduleInput,
171 _signal,
172 _onUpdate,
173 _ctx,
174 ): Promise<AgentToolResult<undefined>> {
175 const scheduler = schedulerRef.current;
176 if (!scheduler) {
177 return textResult(
178 "Error: Scheduler is not available. The scheduled task system may not be initialized.",
179 );
180 }
181
182 switch (params.action) {
183 case "list": {
184 const jobs = scheduler.listJobs();
185 if (jobs.length === 0) {
186 return textResult("No scheduled tasks configured.");
187 }
188 const lines = jobs.map(
189 (j) =>
190 `- **${j.name}**: \`${j.cron}\` → ${j.notify.adapter}:${j.notify.channelId} [${j.enabled ? "enabled" : "disabled"}]${j.running ? " (running)" : ""}${j.lastRunAt ? ` (last: ${j.lastRunAt})` : ""}`,
191 );
192 return textResult(
193 `Scheduled tasks (${jobs.length}):\n${lines.join("\n")}`,
194 );
195 }
196
197 case "add": {
198 if (!params.name || !params.prompt) {
199 return textResult(
200 "Error: 'name' and 'prompt' are required for adding a task.",
201 );
202 }
203
204 if (
205 (params.notifyAdapter && !params.notifyChannelId) ||
206 (!params.notifyAdapter && params.notifyChannelId)
207 ) {
208 return textResult(
209 "Error: 'notifyAdapter' and 'notifyChannelId' must be provided together when overriding the notification target.",
210 );
211 }
212
213 const notify = params.notifyAdapter && params.notifyChannelId
214 ? {
215 adapter: params.notifyAdapter,
216 channelId: params.notifyChannelId,
217 }
218 : getDefaultNotifyTarget(adapter, channelId);
219
220 if (!notify) {
221 return textResult(
222 "Error: No default notification target is available for this chat. Provide 'notifyAdapter' and 'notifyChannelId'.",
223 );
224 }
225

Callers

nothing calls this directly

Calls 8

textResultFunction · 0.85
getDefaultNotifyTargetFunction · 0.85
resolveJobIdFunction · 0.85
listJobsMethod · 0.80
addJobMethod · 0.80
removeJobMethod · 0.80
triggerJobMethod · 0.80
setEnabledMethod · 0.80

Tested by

no test coverage detected