Skip to main content

Module cron

Module cron 

Source
Expand description

Cron MCP - durable scheduled prompts (mcp__forge__cron__*).

A forge cron fires a prompt into the session that owns it, on a schedule, and survives forge restarts (persisted to the machine-local redb store; see crate::store::cron). Unlike the cloud routines (create_trigger / CronCreate), which fire into cloud-hosted sessions, these durably target the local forge process.

The tools (cron__create / cron__list / cron__delete) are ANY-CALLER and owner-scoped: create stamps the caller as the new entry’s owner, and list / delete narrow to the crons the caller owns. Mirrors agents__list, not the lead-only agents__spawn. Cron-list mutations are direct Workspace methods (state writes), not Command-bus dispatches.

  • schedule - pure due-check, next-fire, and boot catch-up math.
  • facade - the CronFacade seam (prod over Weak<Workspace> + a mock for tool tests).

Re-exportsΒ§

use std::sync::Arc; πŸ”’
use std::time::SystemTime; πŸ”’
use forge_sdk::mcp::server::McpServerBuilder; πŸ”’
use forge_sdk::mcp::tool::Tool; πŸ”’
use forge_sdk::mcp::tool::ToolInput; πŸ”’
use forge_sdk::mcp::tool::ToolOutput; πŸ”’
use forge_primitives::cron::CronEntry; πŸ”’
use forge_primitives::cron::CronId; πŸ”’
use forge_primitives::cron::CronKind; πŸ”’
use crate::SessionSlot; πŸ”’
use crate::mcp::cron::facade::CronCreateError; πŸ”’
use crate::mcp::cron::facade::CronDeleteError; πŸ”’
use crate::mcp::cron::facade::CronFacade; πŸ”’
use crate::mcp::cron::facade::CronListError; πŸ”’

ModulesΒ§

facade πŸ”’
CronFacade - the seam between the cron MCP tools and workspace state. The production impl (ProdCronFacade) resolves the caller’s project and drives the direct Workspace cron methods; the mock records calls for tool tests.
schedule πŸ”’
Cron schedule math: expression parsing, next-fire, and due-check.

StructsΒ§

Create πŸ”’
CreateArgs πŸ”’
Delete πŸ”’
DeleteArgs πŸ”’
List πŸ”’

FunctionsΒ§

add_tools πŸ”’
Attach the three cron-coordination tools to an existing McpServerBuilder. Called for BOTH lead and worker sessions (crons are any-caller), so build_forge_server invokes this unconditionally.
cron_to_json πŸ”’
Readable JSON for one cron entry (the tool-output shape the LLM sees).
fmt_rfc3339 πŸ”’
Format a SystemTime as a UTC RFC3339 string for tool output.
format_create_error πŸ”’
parse_rfc3339 πŸ”’
Parse an RFC3339 timestamp to a SystemTime via the time crate (chrono stays confined to the schedule module).
tool_error πŸ”’