Files
sausage/extensions/automations/README.md
T

61 lines
2.8 KiB
Markdown

# Automations
The `automation` tool admits schedules, domain events, context conditions, and shell scripts.
The ledger stores durable deadlines and fire counts.
A fire creates its subscriber deliveries in the same transaction.
Each delivery uses a stable request id, so a restart does not duplicate the subscriber input.
Prompt runs use owned subagent conversations.
## Definitions and scripts
Each automation occupies `/src/sausage/automations/A<n>/` in the world.
The tool writes `automation.json` there as a readable copy of its definition.
The durable ledger remains authoritative.
The extension does not import manual changes to this copy.
Deletion retains the files.
A script uses `script.sh` in that directory.
If the file exists, the extension executes it with world `sh`.
Otherwise, a watcher writes it from the `ask` request before execution.
The watcher inherits the creator's agent configuration.
The script receives a one-hour timeout.
The host cancels execution when the task aborts.
Only stdout lines with `FIRE` trigger deliveries.
An optional message follows `FIRE`.
Stderr lines never trigger deliveries.
`DONE` takes effect after a successful exit.
The extension retains a bounded log in `log`.
Script tasks deduplicate their fire sequence across restarts.
External script effects can repeat after a crash.
## Credentials
The conversation that creates an automation remains its execution conversation.
Every script launch uses `host.chain(creator)`.
The host delegates to `conversationChains` in `host/js/environment.ts`.
The host appends the branch starter's chain after the ownership or fork ancestry.
The host removes duplicate ids without changing their order.
Subscribe and unsubscribe change notification recipients only.
They never change the execution conversation.
Built-in automations without a creator use an empty chain.
No secret value enters a definition, script environment, or watcher prompt.
## Triggers
Schedules accept `cron`, `at`, `in`, and `every` forms.
The five imported schedule cases verify IANA zones, leap days, and daylight-saving transitions in V8.
Events use the durable event service and its reactor cursor.
Conditions use measured prompt tokens and the model's context window.
A decrease of ten percentage points below the threshold re-arms a condition.
The cooldown starts with a condition fire, not a manual fire.
For `idleFor`, admitted conversation inputs reset the idle period.
## Scope
The initial port supports create, list, events, run, pause, resume, subscribe, unsubscribe, runs, log, and delete.
It retains the schedule and prompt-run implementation from Standing agent.
It replaces native process groups with host Exec.
Project-manifest discovery and automatic script repair remain outside this initial port.
Credentials use grants, not named secret files.