Routines

Schedules and triggers that start an agent or an automation, and one routine's detail.

Post the pipeline digest

Active
Schedule
Every weekday at 9Mon–Fri 09:00 (Europe/London)
Time zone
Europe/London
Next run
  • SucceededMon, Nov 30, 9:00 AM
  • FailedFri, Nov 27, 9:00 AM
  • SucceededThu, Nov 26, 9:00 AM

Sync the sales sheet

Paused
Schedule
Every 2 hoursevery 2 h
Time zone
America/New_York
Next run
Not while paused

Paused after 3 failures in a row.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/routine

Usage

import { RoutineCard } from "./ui/uicontext/components/kit/Routine.ts"
const Message = UiSchema.TaggedEnum({	PausedRoutine: { id: Schema.String },	ResumedRoutine: { id: Schema.String },	RescheduledRoutine: { id: Schema.String, text: Schema.String, timeZone: Schema.String },})export const DigestRoutine = (h: Html.H<typeof Message.Type>, state: "active" | "paused", nextRun: string | null) =>	RoutineCard(h, {		props: {			id: "digest",			title: "Post the pipeline digest",			trigger: { kind: "schedule", text: "Every weekday at 9", parsed: "Mon–Fri 09:00" },			state,			nextRun,			timeZone: "Europe/London",			can: ["pause", "resume", "reschedule"],		},		onEmit: {			RequestedPause: ({ id }) => Message.PausedRoutine({ id }),			RequestedResume: ({ id }) => Message.ResumedRoutine({ id }),			RequestedReschedule: ({ id, text, timeZone }) => Message.RescheduledRoutine({ id, text, timeZone }),			RequestedTest: () => undefined,			RequestedApprove: () => undefined,			RequestedDecline: () => undefined,			RequestedPreview: () => undefined,			RequestedDelete: () => undefined,		},	})

Examples

Proposed by an agent

An agent suggests a routine; it does nothing until a person approves it.

Triage new support tickets

Waiting for you
Trigger
When a ticket arrives in the Support inbox
Next run
Nothing scheduled

Routine detail

Turn it on or off, edit what it does and when, then Save or press ⌘S. A schedule without a time is refused with the reason. Test run adds to the history.

When to run

Run history

API reference

RoutineCardComponent

Props

RoutineCard props
NameTypeDescription
idrequiredstringThe routine's id, sent back with every request
titlerequiredstringWhat the routine does: "Summarize new support tickets"
triggerrequiredRoutineTriggerWhat starts it: a schedule, an event or a webhook
staterequiredRoutineStateWhether it's active, paused, proposed or ended
stateLabelstringThe product's word for the state: "On", "Turned off"
pausedReasonstringWhy it's paused: "Paused after 3 failures in a row"
nextRunstring | nullISO 8601, or null when nothing is scheduled
timeZonerequiredstringThe person's time zone (IANA), for every time shown
localestringThe locale dates are formatted in; the browser's by default
showYearbooleanInclude the year in next-run, schedule preview, and history timestamps.
timeZonesstring[]The time zones the editor offers; defaults to every zone the runtime knows
lastResultsRoutineResult[]The most recent runs, newest first, shown as a row of results
webhook{ url, secret }A webhook trigger's address and key, shown once
canrequiredRoutineAction[]What this person may do here; anything absent is hidden
labels{ test, delete }Labels the product uses: { test: "Run now", delete: "End routine" }
readOnlystringWhy this person can't change it: "Only the owner changes this routine"
outcomeOutcome | nullThe app's answer to the last request; its request is the action ("pause", "reschedule")
previewSchedulePreviewThe app's reading of the schedule being typed: its next runs, or why it can't be saved
requirePreviewbooleanRequire a successful preview tied to the current request before Save.
agentIdstringThis card's id for agents; defaults to routine:<id>

Events

RoutineCard events
EventPayloadDescription
RequestedPause{ id: string }Stop the routine from starting until it's resumed
RequestedResume{ id: string }Start the paused routine again
RequestedTest{ id: string }Run the routine once now
RequestedApprove{ id: string }Turn on a routine an agent proposed
RequestedDecline{ id: string }Turn down a routine an agent proposed
RequestedPreview{ id: string; text: string; timeZone: string; request?: string }The person is typing a schedule: answer with preview
RequestedReschedule{ id: string; text: string; timeZone: string }Save the schedule the person typed, in the time zone they chose
RequestedDelete{ id: string }End the routine for good, after the person confirmed

Agent actions

What agents can do with RoutineCard
ActionDescription
ClickedPausePause the routine
ClickedResumeResume the paused routine
ClickedTestRun the routine once now, as a test
ClickedApproveApprove the routine an agent proposed
ClickedDeclineDecline the routine an agent proposed
ClickedEditScheduleOpen the schedule editor
UpdatedScheduleType the schedule in plain words, as a person would: 'every weekday at 9am'
ChoseTimeZoneChoose the schedule's IANA time zone
SubmittedScheduleSave the schedule being edited
ClickedDeleteAsk to delete the routine (opens the confirmation)
ConfirmedDeleteasks firstDelete the routine. Name it as your target.

RoutineListView function

Options

RoutineList options
NameTypeDefaultDescription
statusrequired"loading" | "ready"—loading shows a placeholder while the routines load
labelstringRoutinesWhat the list is of, for screen readers; Routines by default
emptyrequired{ readonly title: string; readonly hint?: string }—"No routines yet", "Ask the agent to do something on a schedule"
childrenrequiredView.Children—The routine cards

RoutineEditorComponent

Props

RoutineEditor props
NameTypeDescription
idrequiredstring—
namerequiredstring—
instructionrequiredstringWhat the agent does when it runs, in its own words
schedulesrequiredstring[]When it runs, each in plain words: "Every day at 8:00 AM", "Weekdays at 6:00 PM"
activerequiredboolean—
runsrequiredRoutineResult[]Its runs, newest first
nowrequiredstringThe clock its runs are read in
timeZonerequiredstring—
localestring—
canrequired("edit" | "toggle" | "test" | "delete")[]What this person may do; anything absent is hidden
outcomeOutcome | nullThe app's answer to the last request: "save", "active", "test" or "delete"
agentIdstring—

Events

RoutineEditor events
EventPayloadDescription
RequestedSave{ id: string; name: string; instruction: string; schedules: string[] }—
RequestedActive{ id: string; active: boolean }—
RequestedTestRun{ id: string }—
RequestedDelete{ id: string }—

Agent actions

What agents can do with RoutineEditor
ActionDescription
RequestedChangeasks firstChange the routine's name, instruction or schedules (plain words, such as 'Every weekday at 9:00 AM') and save
ToggledActiveasks firstTurn the routine on or off
ClickedTestRunRun the routine once now

Accessibility

  • Each routine is a labelled card; its schedule, time zone and next run are a description list, and every time is a <time>.
  • Editing a schedule is a form: the app's reading of it and its next runs are announced as you type.
  • Deleting asks first, and agents must name the routine they end.

Source