feat: cron job system for Inara (remind + note types)
- cron_runner.py: job storage (CRONS.json), schedule parsing, execution - tools/cron.py: cron_list/add/remove/toggle + reminders_clear tools - scheduler.py: load user crons at startup, expose get_scheduler() for live add/remove without restarts - context_loader.py: auto-include REMINDERS.md in system prompt (tier 2+) so cron reminders surface automatically without Inara having to poll - inara/CRONS.json + REMINDERS.md: backing files (initially empty) Schedule formats: hourly | daily | daily:HH:MM | weekly:DOW | weekly:DOW:HH:MM Job types: remind (→ REMINDERS.md) | note (→ SCRATCH.md) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,13 @@ from tools.files import file_read as _file_read
|
||||
from tools.system import claude_allow_dir as _claude_allow_dir
|
||||
from tools.tasks import task_list as _task_list, task_create as _task_create
|
||||
from tools.tasks import task_update as _task_update, task_complete as _task_complete
|
||||
from tools.cron import (
|
||||
cron_list as _cron_list,
|
||||
cron_add as _cron_add,
|
||||
cron_remove as _cron_remove,
|
||||
cron_toggle as _cron_toggle,
|
||||
reminders_clear as _reminders_clear,
|
||||
)
|
||||
from tools.scratch import (
|
||||
scratch_read as _scratch_read,
|
||||
scratch_write as _scratch_write,
|
||||
@@ -185,6 +192,11 @@ _CALLABLES: dict[str, callable] = {
|
||||
"task_create": _task_create,
|
||||
"task_update": _task_update,
|
||||
"task_complete": _task_complete,
|
||||
"cron_list": _cron_list,
|
||||
"cron_add": _cron_add,
|
||||
"cron_remove": _cron_remove,
|
||||
"cron_toggle": _cron_toggle,
|
||||
"reminders_clear": _reminders_clear,
|
||||
"scratch_read": _scratch_read,
|
||||
"scratch_write": _scratch_write,
|
||||
"scratch_append": _scratch_append,
|
||||
@@ -315,6 +327,98 @@ _task_complete_declaration = types.FunctionDeclaration(
|
||||
),
|
||||
)
|
||||
|
||||
_cron_list_declaration = types.FunctionDeclaration(
|
||||
name="cron_list",
|
||||
description=(
|
||||
"List all scheduled cron jobs — their ID, label, schedule, type, and last run time. "
|
||||
"Use this to see what's scheduled before adding or removing jobs."
|
||||
),
|
||||
parameters=types.Schema(type=types.Type.OBJECT, properties={}),
|
||||
)
|
||||
|
||||
_cron_add_declaration = types.FunctionDeclaration(
|
||||
name="cron_add",
|
||||
description=(
|
||||
"Create a new scheduled cron job and register it immediately (no restart needed). "
|
||||
"Two types: 'remind' writes to the pending reminders queue (Inara sees it automatically "
|
||||
"in context next session); 'note' appends to the scratchpad. "
|
||||
"Schedule formats: 'hourly' | 'daily' | 'daily:HH:MM' | 'weekly:DOW' | 'weekly:DOW:HH:MM'. "
|
||||
"Example: schedule='daily:09:00', type='remind', payload='Check in with Scott.'"
|
||||
),
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"label": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="Short human-readable name for this job (e.g. 'Morning check-in')",
|
||||
),
|
||||
"schedule": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description=(
|
||||
"When to run. Formats: hourly | daily | daily:HH:MM | "
|
||||
"weekly:DOW | weekly:DOW:HH:MM (e.g. 'weekly:mon:09:00')"
|
||||
),
|
||||
),
|
||||
"job_type": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="'remind' (→ REMINDERS.md, auto-surfaced in context) or 'note' (→ SCRATCH.md)",
|
||||
),
|
||||
"payload": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="The text to write when the job fires",
|
||||
),
|
||||
},
|
||||
required=["label", "schedule", "job_type", "payload"],
|
||||
),
|
||||
)
|
||||
|
||||
_cron_remove_declaration = types.FunctionDeclaration(
|
||||
name="cron_remove",
|
||||
description=(
|
||||
"Permanently delete a scheduled cron job. Use cron_list first to get the ID. "
|
||||
"To temporarily disable without deleting, use cron_toggle instead."
|
||||
),
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"cron_id": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="Job ID (e.g. c_abc123) — get from cron_list",
|
||||
),
|
||||
},
|
||||
required=["cron_id"],
|
||||
),
|
||||
)
|
||||
|
||||
_cron_toggle_declaration = types.FunctionDeclaration(
|
||||
name="cron_toggle",
|
||||
description=(
|
||||
"Pause a running cron job, or resume a paused one. "
|
||||
"The job stays in the list and can be re-enabled later. "
|
||||
"Use cron_list to see current enabled/paused state."
|
||||
),
|
||||
parameters=types.Schema(
|
||||
type=types.Type.OBJECT,
|
||||
properties={
|
||||
"cron_id": types.Schema(
|
||||
type=types.Type.STRING,
|
||||
description="Job ID (e.g. c_abc123) — get from cron_list",
|
||||
),
|
||||
},
|
||||
required=["cron_id"],
|
||||
),
|
||||
)
|
||||
|
||||
_reminders_clear_declaration = types.FunctionDeclaration(
|
||||
name="reminders_clear",
|
||||
description=(
|
||||
"Erase all pending reminders from REMINDERS.md. "
|
||||
"Use this after you have acknowledged and acted on the reminders shown in your context."
|
||||
),
|
||||
parameters=types.Schema(type=types.Type.OBJECT, properties={}),
|
||||
)
|
||||
|
||||
|
||||
_scratch_read_declaration = types.FunctionDeclaration(
|
||||
name="scratch_read",
|
||||
description=(
|
||||
@@ -386,6 +490,11 @@ TOOL_DECLARATIONS = [
|
||||
_task_create_declaration,
|
||||
_task_update_declaration,
|
||||
_task_complete_declaration,
|
||||
_cron_list_declaration,
|
||||
_cron_add_declaration,
|
||||
_cron_remove_declaration,
|
||||
_cron_toggle_declaration,
|
||||
_reminders_clear_declaration,
|
||||
_scratch_read_declaration,
|
||||
_scratch_write_declaration,
|
||||
_scratch_append_declaration,
|
||||
|
||||
Reference in New Issue
Block a user