Undo my change
Revert the newest Change you merged to the definition, such as a price or a page, as a new Change you can revert in turn.
Change.revert puts back every value your newest merged Change set, as a new Change the Version history keeps, and your agent reads it back first. To reverse an agent's Action instead, undo what the agent did.
What you get
- 1reverting Change that puts back every value your Change setChange
- 1new Version of the Startup, with the reverted one kept in its historyVersion
Your agent does
You, to your agent
Undo the price change I made yesterday.
Put back what I changed.
Revert my last change.
# Look up the Change: Change.list
RUN= $(uuidgen) # once per request; reuse it only to retry this request
CHANGE_MATCHES= $(curl "https: //api.sb/ leaseline.app/ changes? where= status%20%3D%20Merged& limit= 1" \
-H "Authorization: Bearer $SB_TOKEN")
[ "$(echo "$CHANGE_MATCHES" | jq '.changes | length')" = 1 ] || { echo "No Change matches: tell the founder"; exit 1; }
CHANGE= $(echo "$CHANGE_MATCHES" | jq -r '.changes[0]["$id"] | split("/ ") | last')
# Change.revert
curl -X POST https: //api.sb/ leaseline.app/ changes/ $CHANGE/ revert \
-H "Authorization: Bearer $SB_TOKEN" \
-H "Idempotency-Key: undo-my-change-leaseline.app-$RUN-1" \
-H "Content-Type: application/ json" \
-d '{"reason": "Changed by mistake."}'
RUN= $(uuidgen) # once per request; reuse it only to retry this request
CHANGE_MATCHES= $(npx startup-builder do Change.list --data '{"where": "status = Merged", "limit": 1}' --json)
[ "$(echo "$CHANGE_MATCHES" | jq '.changes | length')" = 1 ] || { echo "No Change matches: tell the founder"; exit 1; }
CHANGE= $(echo "$CHANGE_MATCHES" | jq -r '.changes[0]["$id"] | split("/ ") | last')
npx startup-builder do Change.revert --data '{"change": "'"$CHANGE"'", "reason": "Changed by mistake."}' --idempotency-key undo-my-change-leaseline.app-$RUN-1
{
"name": "do",
"arguments": {
"code": "const [change] = await $.Change.list({ where: 'status = Merged', limit: 1 })\nif (!change) throw new Error('No Change matches: tell the founder')\nreturn await $.Change.revert({ change: change.$id, reason: 'Changed by mistake.' })",
"idempotencyKey": "undo-my-change-leaseline.app-<run>"
}
}
import { $ } from 'startup-builder'
const run = crypto.randomUUID() // once per request; reuse it only to retry this request
const [change] = await $.Change.list({ where: 'status = Merged', limit: 1 })
if (!change) throw new Error('No Change matches: tell the founder')
await $.Change.revert({ change: change.$id, reason: 'Changed by mistake.' }, { idempotencyKey: `undo-my-change-leaseline.app-${run}-1` })
Change it
- Revert only the price, keep the new name.
- Show me what I changed this week.
- Undo what the agent did instead.
Under the hood
- Systems
- Work queue
- Nouns
- Change, Version
- Events
Change.reverted