Skip to content

Commit 0765155

Browse files
committed
feat(scheduled-tasks): migrate jobs to scheduled tasks and add scheduled tasks as a resource
1 parent c8e96eb commit 0765155

11 files changed

Lines changed: 318 additions & 284 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/message-content/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const TOOL_ICONS: Record<string, IconComponent> = {
5151
knowledge: Database,
5252
knowledge_base: Database,
5353
table: TableIcon,
54+
scheduled_task: Calendar,
5455
job: Calendar,
5556
agent: AgentIcon,
5657
custom_tool: Wrench,

apps/sim/app/workspace/[workspaceId]/home/hooks/stream/stream-helpers.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import {
1818
ManageCredentialOperation,
1919
ManageCustomTool,
2020
ManageCustomToolOperation,
21-
ManageJob,
22-
ManageJobOperation,
2321
ManageMcpTool,
2422
ManageMcpToolOperation,
23+
ManageScheduledTask,
24+
ManageScheduledTaskOperation,
2525
ManageSkill,
2626
ManageSkillOperation,
2727
MoveFolder,
@@ -345,17 +345,17 @@ export function resolveToolDisplayTitle(
345345
)
346346
}
347347

348-
if (name === ManageJob.id) {
348+
if (name === ManageScheduledTask.id) {
349349
return resolveOperationDisplayTitle(
350350
args.operation,
351351
{
352-
[ManageJobOperation.create]: 'Creating job',
353-
[ManageJobOperation.get]: 'Getting job',
354-
[ManageJobOperation.update]: 'Updating job',
355-
[ManageJobOperation.delete]: 'Deleting job',
356-
[ManageJobOperation.list]: 'Listing jobs',
352+
[ManageScheduledTaskOperation.create]: 'Creating scheduled task',
353+
[ManageScheduledTaskOperation.get]: 'Getting scheduled task',
354+
[ManageScheduledTaskOperation.update]: 'Updating scheduled task',
355+
[ManageScheduledTaskOperation.delete]: 'Deleting scheduled task',
356+
[ManageScheduledTaskOperation.list]: 'Listing scheduled tasks',
357357
},
358-
'Job action'
358+
'Scheduled task action'
359359
)
360360
}
361361

@@ -496,17 +496,17 @@ export function resolveStreamingToolDisplayTitle(
496496
)
497497
}
498498

499-
if (name === ManageJob.id) {
499+
if (name === ManageScheduledTask.id) {
500500
return resolveOperationDisplayTitle(
501501
matchStreamingStringArg(streamingArgs, 'operation'),
502502
{
503-
[ManageJobOperation.create]: 'Creating job',
504-
[ManageJobOperation.get]: 'Getting job',
505-
[ManageJobOperation.update]: 'Updating job',
506-
[ManageJobOperation.delete]: 'Deleting job',
507-
[ManageJobOperation.list]: 'Listing jobs',
503+
[ManageScheduledTaskOperation.create]: 'Creating scheduled task',
504+
[ManageScheduledTaskOperation.get]: 'Getting scheduled task',
505+
[ManageScheduledTaskOperation.update]: 'Updating scheduled task',
506+
[ManageScheduledTaskOperation.delete]: 'Deleting scheduled task',
507+
[ManageScheduledTaskOperation.list]: 'Listing scheduled tasks',
508508
},
509-
'Job action'
509+
'Scheduled task action'
510510
)
511511
}
512512

apps/sim/app/workspace/[workspaceId]/home/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
GetPageContents,
1313
Glob,
1414
Grep,
15-
Job,
1615
Knowledge,
1716
KnowledgeBase,
1817
ManageMcpTool,
@@ -21,6 +20,7 @@ import {
2120
OpenResource,
2221
Read as ReadTool,
2322
Research,
23+
ScheduledTask,
2424
ScrapePage,
2525
SearchLibraryDocs,
2626
SearchOnline,
@@ -193,6 +193,8 @@ export const SUBAGENT_LABELS: Record<string, string> = {
193193
superagent: 'Superagent',
194194
run: 'Run Agent',
195195
agent: 'Tools Agent',
196+
scheduled_task: 'Scheduled Task Agent',
197+
// `job` retained as a backward-compat alias so historical transcripts still render a label.
196198
job: 'Job Agent',
197199
file: 'File Agent',
198200
media: 'Media Agent',
@@ -230,7 +232,8 @@ export const TOOL_UI_METADATA: Record<string, ToolTitleMetadata> = {
230232
[Knowledge.id]: { title: 'Knowledge Agent' },
231233
[KnowledgeBase.id]: { title: 'Managing knowledge base' },
232234
[Table.id]: { title: 'Table Agent' },
233-
[Job.id]: { title: 'Job Agent' },
235+
[ScheduledTask.id]: { title: 'Scheduled Task Agent' },
236+
job: { title: 'Job Agent' },
234237
[Agent.id]: { title: 'Tools Agent' },
235238
custom_tool: { title: 'Creating tool' },
236239
[Research.id]: { title: 'Research Agent' },

apps/sim/background/schedule-execution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,17 +1036,17 @@ function buildJobPrompt(jobRecord: {
10361036
}
10371037
parts.push('')
10381038
parts.push(
1039-
'Use this history to avoid duplicate work. After completing meaningful work this run, call update_job_history to record what you did.'
1039+
'Use this history to avoid duplicate work. After completing meaningful work this run, call update_scheduled_task_history to record what you did.'
10401040
)
10411041
} else if (jobRecord.runCount > 0) {
10421042
parts.push('')
10431043
parts.push(
1044-
'No previous run history recorded. After completing meaningful work, call update_job_history to record what you did for future runs.'
1044+
'No previous run history recorded. After completing meaningful work, call update_scheduled_task_history to record what you did for future runs.'
10451045
)
10461046
} else {
10471047
parts.push('')
10481048
parts.push(
1049-
'This is the first run. After completing meaningful work, call update_job_history to record what you did so future runs have context.'
1049+
'This is the first run. After completing meaningful work, call update_scheduled_task_history to record what you did so future runs have context.'
10501050
)
10511051
}
10521052

@@ -1055,7 +1055,7 @@ function buildJobPrompt(jobRecord: {
10551055
parts.push('COMPLETION PROTOCOL:')
10561056
parts.push('This is a poll-until-done job. After executing the task above:')
10571057
parts.push(
1058-
`- If the success condition is met, take the required action, then call complete_job(jobId: "${jobRecord.id}") to stop the job.`
1058+
`- If the success condition is met, take the required action, then call complete_scheduled_task(jobId: "${jobRecord.id}") to stop the scheduled task.`
10591059
)
10601060
parts.push(
10611061
'- If the success condition is NOT met, do nothing extra. The job will run again on schedule.'
@@ -1285,7 +1285,7 @@ export async function executeJobInline(payload: JobExecutionPayload) {
12851285
try {
12861286
responseBody = await response.json()
12871287
const toolCalls = responseBody?.toolCalls as Array<{ name?: string }> | undefined
1288-
wasCompletedByTool = toolCalls?.some((tc) => tc.name === 'complete_job') ?? false
1288+
wasCompletedByTool = toolCalls?.some((tc) => tc.name === 'complete_scheduled_task') ?? false
12891289
} catch {
12901290
if (timeoutController.isTimedOut()) {
12911291
throw new Error(getTimeoutErrorMessage(null, timeoutController.timeoutMs))

0 commit comments

Comments
 (0)