MCPcopy Index your code
hub / github.com/simstudioai/sim / executeManageJob

Function executeManageJob

apps/sim/lib/copilot/tools/handlers/jobs.ts:144–353  ·  view source on GitHub ↗
(
  params: Record<string, unknown>,
  context: ExecutionContext
)

Source from the content-addressed store, hash-verified

142}
143
144export async function executeManageJob(
145 params: Record<string, unknown>,
146 context: ExecutionContext
147): Promise<ToolCallResult> {
148 const parsedParams = ManageJobParamsSchema.safeParse(params)
149 if (!parsedParams.success) {
150 return { success: false, error: 'Invalid manage job parameters' }
151 }
152
153 const rawParams: ManageJobParams = parsedParams.data
154 const { operation, args } = rawParams
155
156 if (!context.userId || !context.workspaceId) {
157 return { success: false, error: 'Missing user or workspace context' }
158 }
159
160 switch (operation) {
161 case 'create': {
162 return executeCreateJob(
163 {
164 title: args?.title,
165 prompt: args?.prompt,
166 cron: args?.cron,
167 time: args?.time,
168 timezone: args?.timezone,
169 lifecycle: args?.lifecycle,
170 successCondition: args?.successCondition,
171 maxRuns: args?.maxRuns,
172 } as Record<string, unknown>,
173 context
174 )
175 }
176
177 case 'list': {
178 try {
179 const jobs = await db
180 .select({
181 id: workflowSchedule.id,
182 jobTitle: workflowSchedule.jobTitle,
183 prompt: workflowSchedule.prompt,
184 cronExpression: workflowSchedule.cronExpression,
185 timezone: workflowSchedule.timezone,
186 status: workflowSchedule.status,
187 lifecycle: workflowSchedule.lifecycle,
188 successCondition: workflowSchedule.successCondition,
189 maxRuns: workflowSchedule.maxRuns,
190 runCount: workflowSchedule.runCount,
191 nextRunAt: workflowSchedule.nextRunAt,
192 lastRanAt: workflowSchedule.lastRanAt,
193 sourceTaskName: workflowSchedule.sourceTaskName,
194 createdAt: workflowSchedule.createdAt,
195 })
196 .from(workflowSchedule)
197 .where(ACTIVE_JOB_CONDITION(context.workspaceId))
198
199 return {
200 success: true,
201 output: {

Callers

nothing calls this directly

Calls 8

toErrorFunction · 0.90
performUpdateJobFunction · 0.90
performDeleteJobFunction · 0.90
executeCreateJobFunction · 0.85
ACTIVE_JOB_CONDITIONFunction · 0.85
errorMethod · 0.80
eqFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected