Operations Reference
The operation types available for superpower definitions.
Operations are the building blocks of superpowers. Each operation runs sequentially within an action. Results from one operation are available to the next via {{$op.output_name}}.
Fields available on every operation
| Field | Description |
|---|---|
type | The operation type (required) |
output | Name to store the result under — reference it later as {{$op.name}} |
enabled_if | Condition — the operation is skipped unless it holds |
id, label, description, comment | Optional documentation annotations |
enabled_if
Any operation can carry enabled_if. When the condition is false the operation
is skipped entirely and its output is set to null. This is the idiomatic way
to make a single step conditional without wrapping it in a conditional block —
and it's required for conditional conversation_flow, which must stay at the
top level (see conversation_flow).
# Only ask for a city on the first run — skipped once state has one
- type: conversation_flow
output: user_city
prompt: "What city should I check?"
enabled_if: "{{$state.city == null || $state.city == ''}}"
- type: state_update
data: { city: "{{$op.user_city}}" }
enabled_if: "{{$state.city == null || $state.city == ''}}"Accepted aliases
The canonical field names below are preferred, but these aliases are accepted and normalized automatically:
| Canonical | Accepted aliases | Where |
|---|---|---|
output | output_field, output_key | Any operation |
expression | formula | calculate |
then_ops | then, if_true | conditional |
else_ops | else, if_false | conditional |
then_ops (loop body) | operation (a single-op dict) | loop |
options | allowed_values | conversation_flow prompt entries |
Definitions are validated when generated and when published: unknown config
keys, unsupported template syntax, unknown filters, and misplaced
conversation_flow are reported as errors. See
Validation.
AI Operations
llm_generate
Generate free-form text using an LLM.
- type: llm_generate
output: summary
prompt: "Summarize this: {{$input.text}}"llm_extract
Extract structured data from text.
- type: llm_extract
output: city
input: "{{$input.text}}"
output_schema:
type: object
properties:
name:
type: string
description: "City name"Fields: prompt (extraction instruction), input (source text, defaults to
the user's message), and output_schema (the expected structure — schema is
accepted as an alias).
vision_analysis
Analyze images with Gemini Vision.
- type: vision_analysis
output: analysis
prompt: "Describe what's in this image"Fields: prompt, input (a specific image or list of images — when omitted,
the images attached to the user's message are analyzed), output_schema /
schema (optional structured output).
Integration Operations
http_request
Call external REST APIs. Domain must be on the allowlist.
- type: http_request
output: weather
method: GET
url: "https://api.openweathermap.org/data/2.5/weather?q={{$state.city}}&units=imperial"
platform_key_ref: openweathermap # Sprites provides the API key
response_path: main # Extract nested JSON fieldFields: url, method (GET/POST/PUT/PATCH/DELETE), headers, params (query parameters, template-interpolated), body, response_path (dot-path to extract from the response), timeout.
Auth options:
platform_key_ref— Sprites-owned API key (free for listed integrations)auth_token_ref— the user's OAuth token for a connected provider (e.g.strava,whoop,oura,spotify), injected as a Bearer header- Manual
headers.Authorization— Your own API key
Platform key injection is configurable to match the API's style:
| Field | Default | Description |
|---|---|---|
platform_key_in | "query" | "query" adds the key as a URL parameter; "header" sends it as Authorization: Bearer (Yelp-style) |
platform_key_param | "appid" | The query-parameter name when platform_key_in is "query" (e.g. app_id for Open Exchange Rates, api_key for NASA) |
# Google-style key param
- type: http_request
output: rates
url: "https://openexchangerates.org/api/latest.json"
platform_key_ref: open_exchange_rates
platform_key_param: app_idSecurity: an auth_token_ref token is only ever sent to that provider's own
API domains. A request that would send, say, a Strava token to any other host is
blocked.
gmail_search
Search the user's Gmail. Requires oauth_required: [gmail].
- type: gmail_search
output: emails
query: "is:unread from:{{$state.sender}}"
max_results: 5Fields: query (Gmail search-bar syntax), max_results (default 10),
include_body (include message bodies, not just snippets).
calendar_query
Query Google Calendar. Requires oauth_required: [calendar].
- type: calendar_query
output: events
time_min: today # ISO timestamp, or relative: "now", "today"
time_max: "+1d" # ISO timestamp, or relative: "+7d" (days from time_min)The time bounds can also be nested in a query dict — both forms are
equivalent:
- type: calendar_query
output: todays_events
query:
time_min: "{{$today.start}}"
time_max: "{{$today.end}}"
order_by: startTime
single_events: trueFields: time_min (default now), time_max (default +7d),
max_results (default 50), single_events (expand recurring events, default
true), order_by.
web_search
Search the web. Two search models available:
| Model | Speed | Best for |
|---|---|---|
sonar (default) | ~1-2s | General queries, quick lookups |
sonar-pro | ~3-5s | Competitive analysis, market research, multi-source synthesis |
# Fast general search (default)
- type: web_search
output: results
query: "{{$input.text}}"
max_results: 10
# Deep research with sonar-pro
- type: web_search
output: competitor_data
query: "competitors to {{$op.idea.product}}, pricing, features, market share"
model: sonar-pro
max_results: 5Fields: query, model (sonar default), max_results (default 5).
memory_read
Search the user's memories.
- type: memory_read
output: memories
query: "user's favorite restaurants"memory_write
Store a memory for the user. Uses the text field (NOT content or prompt).
- type: memory_write
text: "User logged a run: {{$op.distance}}km in {{$op.duration}} minutes"Data Operations
state_update
Update session state. The fields to set go under data (or updates — both
are accepted).
- type: state_update
data:
status: "active"
last_checked: "{{$now.iso}}"Values are template-interpolated, not computed — use a calculate operation for
arithmetic (e.g. incrementing a counter), then store its output.
data_store
Structured CRUD storage that persists beyond the 24h session timeout. Records are
scoped to (user_id, superpower_id, collection) and stored as JSONB — use it for
data that accumulates over time (expenses, deals, runs, sleep logs) and needs
filtering, sorting, or aggregation.
Actions: insert, query, update, upsert, archive, count, sum
Versioned, lifetime-bound records (opt-in per operation; existing definitions are unchanged):
| Field | On | Meaning |
|---|---|---|
expires_in | insert, upsert (create) | "30d", "12h", "45m", "2w" or seconds. Expired rows vanish from query / count / sum at once and are archived nightly. |
expires_at | insert, upsert (create) | ISO timestamp alternative to expires_in. |
tags | insert, upsert (create) | up to 10 short lowercase tags; query takes tag to filter. |
history | update, upsert | keep this many prior versions (max 20): each change supersedes the row with version + 1 in the same lineage instead of overwriting. |
history: true | query | return every version of the matching records, newest first; superseded ones carry superseded: true. |
query results include latest (the newest record, or newest version) and each record carries version, tags, expires_at. "Your rent went up vs last month" is {{$op.rent.latest.data.amount}} against {{$op.rent.records.1.data.amount}} after a query with history: true.
# Insert — add a new record
- type: data_store
action: insert
collection: expenses
record:
amount: "{{$op.extracted.amount}}"
category: "{{$op.extracted.category}}"
logged_at: "{{$now_iso}}"
# Query — retrieve records with filtering and sorting
- type: data_store
action: query
output: recent_runs
collection: runs
filter:
distance_km: { $gte: "5" }
sort: { logged_at: desc }
limit: 10
# Update — set fields on records matching a filter
- type: data_store
action: update
collection: deals
filter: { brand_name: "{{$op.extracted.brand_name}}" }
set: { stage: "{{$op.extracted.stage}}" }
# Upsert — update if a match exists, insert otherwise
- type: data_store
action: upsert
collection: deals
record:
brand_name: "{{$op.extracted.brand_name}}"
stage: "{{$op.extracted.stage}}"
filter: { brand_name: "{{$op.extracted.brand_name}}" }
# Archive — soft-delete records matching a filter
- type: data_store
action: archive
collection: watches
filter: { active: "false" }
# Count / Sum — aggregate over a collection
- type: data_store
action: count
output: total_runs
collection: runs
- type: data_store
action: sum
output: total_spent
collection: expenses
field: amount
filter: { category: food }Filter operators: $ne, $gt, $lt, $gte, $lte, $in, $exists
Result shapes. Read actions return structured results — note that a queried
record's user data lives under its data key:
# query → {"records": [{"id", "data", "created_at", "updated_at"}], "count": N}
{{$op.recent_runs.records}} # the record list
{{$op.recent_runs.records[0].data.distance_km}} # a field of the newest record
{{$op.recent_runs.count}} # how many were returned
# count → {"count": N}
{{$op.total_runs.count}}
# sum → {"sum": <number>}
{{$op.total_spent.sum}}Limits: 1,000 records per collection · 10 collections per superpower · 16 KB per record · 5,000 total records per user across all superpowers · query returns max 100 results (default 20).
When to use which storage:
| Operation | Use for | Lifetime |
|---|---|---|
state_update | Session counters, preferences, transient UI state | 24h session |
memory_write | Narrative facts the persona should recall conversationally | Long-term, semantic search |
data_store | Structured records you filter, sort, and aggregate | Indefinite |
read_document
Read the content of a user's document as markdown. Provide a document_id or a
query to search by title.
- type: read_document
output: doc_content
document_id: "{{$state.active_doc_id}}"update_document
Update a document's content (markdown) and/or title. Requires document_id and at
least one of content or title.
- type: update_document
document_id: "{{$state.active_doc_id}}"
content: "{{$op.revised_content}}"calculate
Safe math operations (no eval).
- type: calculate
output: per_person
expression: "{{$state.total}} / {{$op.num_people}}"
round_to: 2Supports: +, -, *, /, %, **, round(), ceil(), floor(), min(), max(), sum(), len(), abs()
build_url
Construct URLs with encoded parameters.
- type: build_url
output: payment_url
base_url: "https://venmo.com/pay"
params:
amount: "{{$op.per_person}}"
note: "{{$state.merchant}}"
url_encode: trueemit_event
Emit a single event to the event store (event sourcing pattern).
- type: emit_event
event_type: item_added
payload:
name: "{{$input.text}}"
output: resultFlow Control
conditional
If/then/else branching. The branches are named then_ops and else_ops.
- type: conditional
condition: "{{$state.total}} > 50"
then_ops:
- type: state_update
data: { discount: 10 }
else_ops:
- type: state_update
data: { discount: 0 }The condition uses the full
condition grammar:
comparisons (==, !=, >=, <=, >, <), contains, boolean logic
(||/&&), literals (null/true/false/numbers/quoted strings), and
filters on operands. Both "{{$state.total}} > 50" and "{{$state.total > 50}}"
work. Nested branches can contain further conditional/loop operations up to
3 levels deep — but never a conversation_flow (see below). To skip a single
operation, prefer enabled_if over a one-op branch.
loop
Iterate over a collection (max 50 iterations). The loop body is a then_ops
list; inside it, {{$loop.item}} and {{$loop.index}} refer to the current
element.
- type: loop
items: "{{$state.participants}}"
then_ops:
- type: send_message
recipient: "{{$loop.item.phone}}"
message: "Your share: {{$loop.item.amount}}"A single-operation body may also be written as operation: {...} — it's
normalized to a one-element then_ops. conversation_flow is not allowed
inside loop bodies.
conversation_flow
Ask the user one or more questions and pause execution until they respond.
Single question:
- type: conversation_flow
output: user_input
prompt: "How many people?"
options: ["2", "3", "4", "5+"]
timeout_seconds: 120
default_on_timeout: "2"Multiple questions, collected one at a time via a prompts list — each answer
is stored under its entry's field name and can be referenced later
({{threshold}} or {{$state.threshold}}):
- type: conversation_flow
prompts:
- field: from_currency
ask: "Which currency do you want to watch? (e.g. USD, EUR)"
parse_as: string
transform: uppercase
- field: threshold
ask: "What rate should I alert you at? (e.g. 0.95)"
parse_as: number
- field: direction
ask: "Alert when the rate goes above or below? (above / below)"
parse_as: string
options: [above, below]Prompt-entry keys: field, ask, parse_as (string | number |
boolean), options (choice list), transform (uppercase | lowercase).
optional and unit_hint are tolerated as annotations but not enforced.
min/max are not supported — fold ranges into the ask text
("enter 1–10").
conversation_flow must be a top-level operation in the action's
operations list — never inside conditional or loop branches, where the
pause would be silently swallowed. This is a validation error. To ask
conditionally, hoist the operation to the top level and gate it with
enabled_if:
- type: conversation_flow
output: user_city
prompt: "What city should I check?"
enabled_if: "{{$state.city == null || $state.city == ''}}"Communication
send_message
Send a DM to another user (max 5 per action).
- type: send_message
recipient: "{{$state.participants[0].phone}}"
message: "You owe {{$op.per_person}}"notify
Send a proactive notification.
- type: notify
message: "{{$op.alert_message}}"Scheduling
schedule
Schedule delayed or recurring execution.
# One-time delay
- type: schedule
mode: once
delay_hours: 24
action_id: send_reminder
# Recurring cron
- type: schedule
mode: recurring
cron: "0 9 * * *" # 9 AM daily
action_id: daily_digestRecurring schedules require a paid plan. See billing for limits.
schedule_task
Schedule a future action with context.
- type: schedule_task
delay_hours: 24
action_id: send_reminder
context:
merchant: "{{$state.merchant}}"
max_retries: 2Document
generate_document
Generate a document via the Document Service.
- type: generate_document
document_type: essay
document_title: "Weekly Report"
document_prompt: "Generate a report based on: {{$state.activities}}"