Sprites
Swamp models for Fly.io Sprites. Run commands, read and write files, manage services and checkpoints, and control network access.
Installation
Install the extension in your Swamp repository:
swamp extension pull @josh/spritesUsage
You need a Sprites organization token and an existing Swamp vault. These examples
use a vault named sprites-secrets. The vault put command prompts for the token.
The create method below creates a remote Sprite; provider charges apply.
To use an existing Sprite, set name to its name and run lookup instead.
swamp vault put sprites-secrets API_TOKEN
swamp model create @josh/sprites/sprite build-sprite \
--global-arg name=build-worker \
--global-arg 'token=${{ vault.get("sprites-secrets", "API_TOKEN") }}'
swamp model method run build-sprite createThe token determines the organization. Use separate model instances and vault keys for different organizations.
Check the Python version on the Sprite:
swamp model method run build-sprite exec --input '{"cmd":["python3","--version"]}'
swamp data get build-sprite execStdoutDefine an HTTP service using the Sprite's saved name:
swamp model create @josh/sprites/service build-web \
--global-arg 'sprite=${{ data.latest("build-sprite", "state").attributes.name }}' \
--global-arg service_name=web \
--global-arg 'token=${{ vault.get("sprites-secrets", "API_TOKEN") }}'
swamp model method run build-web put --input '{"service":{"cmd":"python3","args":["-m","http.server","8080"],"http_port":8080}}'Check that the service responds at the Sprite's URL:
swamp model method run build-sprite probeUrl
swamp data get build-sprite probeUrlprobeUrl requires an HTTP 200 response and saves the response size and SHA-256 hash.
The Sprite model saves the remote ID during create or lookup. Later changes
check that ID and refuse to act on a replacement Sprite with the same name.
When you are done, inspect the saved ID and name before deleting the Sprite:
swamp model get build-sprite --json
swamp model method run build-sprite deleteModels
| Model type | Manages |
|---|---|
@josh/sprites/checkpoint |
A Sprite checkpoint: create, look up, and restore. |
@josh/sprites/connector |
A provider connection and its Sprite access policy. |
@josh/sprites/organization |
Sprite and connector lists, plus operations across multiple Sprites. |
@josh/sprites/service |
One service on a Sprite: configuration, start and stop, logs, and signals. |
@josh/sprites/sprite |
One named Sprite: commands, files, policies, and networking. |
@josh/sprites/task |
A hold that keeps a Sprite awake until it expires. |
Inspect any model type's methods, arguments, and output schemas:
swamp model type describe @josh/sprites/sprite --jsonFile writes, command input (stdin), and HTTP gateway request bodies accept
{"kind":"text","text":"hello\n"} or {"kind":"base64","base64":"AP8="}.
Supply the contents directly; these methods do not read files from the Swamp host.
Sprite exec saves an exec record and binary execStdout and execStderr
files. By default, a nonzero exit fails the method before it saves output. Set
failOnNonZero: false to save the exit code and output instead.
Operational limits
Stored data and request limits
Store credentials in vaults and restrict access to the Swamp repository and server. Binary output files may contain application secrets and expire after seven days. A failed method can leave some files or records saved and others missing.
Responses have a default 64 MiB cap. Organization requests default to a 30-second
timeout per request; other models default to five minutes. Set timeoutMs and
maxResponseBytes in model global arguments to change these limits. After a
failed change, check the remote resource before retrying.
Services and runtime changes
A successful Sprite upgrade or restart only means that the API accepted the request.
Check the runtime to confirm the change took effect. After a service startup
event, check that the application is ready to handle requests.
A stopped service can start again after reboot. Delete its definition to prevent
that. To resume an explicitly stopped HTTP service, run service start; an
incoming HTTP request alone will not start it.
Commands inside the Sprite
Some methods require programs inside the Sprite:
- Service
signal, SpritelistTasks, and task methods require/usr/bin/curl. - Sprite
proxy,gatewayList, andgatewayRequestrequire/.sprite/bin/python3. - Starting a TTY session with an explicit terminal size through
execorcontrolExecalso requires/.sprite/bin/python3.
Service, checkpoint, and task models save the Sprite's ID and reject a replacement with the same name on later calls. The organization token stays outside the Sprite.
Checkpoints, tasks, and connectors
Restoring a checkpoint replaces the writable filesystem overlay and leaves
/tmp unchanged. Before restoring, inspect the checkpoint model and verify its
saved Sprite ID and checkpoint ID.
Checkpoint creation saves the newest checkpoint returned by the API. Avoid concurrent checkpoint creation on the same Sprite: the model could save a checkpoint created by another caller.
Task holds expire after at most one hour. Reading a task or saving its state does
not extend the hold. Use refresh to renew it or delete to release it early.
Connector policy updates replace the whole policy. Provisioning a connection alone does not grant Sprite access; an empty policy denies access.
Operations across multiple Sprites
Organization methods that act on multiple Sprites select them by prefix or
labels when called. They process one Sprite at a time and continue after
recording a failure. They use the current inventory without checking IDs saved
by individual Sprite models. Before a bulk restart, service deletion, or policy
change, run listSprites and verify the target names and IDs.
Each method saves its summary under the method name. Per-Sprite results use
<method>-<sprite-id>, including service methods. Service results also store
serviceName. Organization exec saves execStdout-<sprite-id> and
execStderr-<sprite-id>. It records nonzero exits rather than failing the whole run.
Each command gets the organization model's timeoutMs, which defaults to 30
seconds. Raise it for slow commands; it limits each command, not the full run.
Inline every public model schema so registry extraction sees complete global arguments, methods, resources, and files. Add a source-level gate that rejects shared schema references in exported contracts.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| token | string | Organization token; use a vault reference. |
| baseUrl? | url | |
| timeoutMs? | number | |
| maxResponseBytes? | number | |
| sprite | string | Name of the Sprite this belongs to. |
| name | string | Local slot name for a saved checkpoint id. |
| Argument | Type | Description |
|---|---|---|
| comment? | string |
| Argument | Type | Description |
|---|---|---|
| checkpoint_id | string |
Global Arguments
| Argument | Type | Description |
|---|---|---|
| token | string | Organization token; use a vault reference. |
| baseUrl? | url | |
| timeoutMs? | number | |
| maxResponseBytes? | number | |
| name | string | Local instance name for this connection. |
| provider | string |
| Argument | Type | Description |
|---|---|---|
| api_key | string | Use a vault reference for the provider credential. |
| access_policy? | object | Grant every Sprite access; this overrides sprite_labels and name_prefix. |
| Argument | Type | Description |
|---|---|---|
| scopes? | string | Comma-separated scopes API field that replaces the provider defaults. |
| add_scopes? | string | Comma-separated add_scopes API field added to an existing grant. |
| redirect_uri? | string | |
| state? | string | Optional OAuth state API field. Sprites generates one when omitted. |
| Argument | Type | Description |
|---|---|---|
| code | string | |
| redirect_uri? | string | |
| access_policy? | object | Grant every Sprite access; this overrides sprite_labels and name_prefix. |
| Argument | Type | Description |
|---|---|---|
| access_policy? | object | Grant every Sprite access; this overrides sprite_labels and name_prefix. |
| Argument | Type | Description |
|---|---|---|
| id | string |
Global Arguments
| Argument | Type | Description |
|---|---|---|
| token | string | Organization token; use a vault reference. |
| baseUrl? | url | |
| timeoutMs? | number | |
| maxResponseBytes? | number |
| Argument | Type | Description |
|---|---|---|
| cmd | array | Program and argv, encoded as repeated cmd parameters. |
| path? | string | |
| dir? | string | |
| env? | record | |
| input? | discriminatedUnion | |
| select? | object | Every Sprite in the organization. |
| Argument | Type | Description |
|---|---|---|
| prefix? | string | Only include Sprite names with this prefix. |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| policy? | object |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| policy? | object |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| policy? | object |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| version? | string |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| comment? | string |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| service_name | string | |
| service? | object | |
| duration? | string |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| service_name | string | |
| duration? | string |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| service_name | string | |
| timeout? | string |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| service_name | string | |
| duration? | string |
| Argument | Type | Description |
|---|---|---|
| select? | object | Every Sprite in the organization. |
| service_name | string |
| Argument | Type | Description |
|---|---|---|
| provider? | string |
Files
Global Arguments
| Argument | Type | Description |
|---|---|---|
| token | string | Organization token; use a vault reference. |
| baseUrl? | url | |
| timeoutMs? | number | |
| maxResponseBytes? | number | |
| sprite | string | Name of the Sprite this belongs to. |
| service_name | string | Service name on that Sprite. |
| Argument | Type | Description |
|---|---|---|
| service? | object | |
| duration? | string |
| Argument | Type | Description |
|---|---|---|
| duration? | string |
| Argument | Type | Description |
|---|---|---|
| timeout? | string |
| Argument | Type | Description |
|---|---|---|
| duration? | string |
| Argument | Type | Description |
|---|---|---|
| lines? | number | |
| duration? | string |
| Argument | Type | Description |
|---|---|---|
| signal | string |
Global Arguments
| Argument | Type | Description |
|---|---|---|
| token | string | Organization token; use a vault reference. |
| baseUrl? | url | |
| timeoutMs? | number | |
| maxResponseBytes? | number | |
| name | string | Sprite name within the token's organization. |
| Argument | Type | Description |
|---|---|---|
| config? | object | |
| environment? | record | |
| url_settings? | object | |
| labels? | array | |
| wait_for_capacity? | boolean | |
| runtime? | enum |
| Argument | Type | Description |
|---|---|---|
| url_settings? | object | |
| labels? | array |
| Argument | Type | Description |
|---|---|---|
| version? | string |
| Argument | Type | Description |
|---|---|---|
| operations? | array | Program and argv, encoded as repeated cmd parameters. |
| Argument | Type | Description |
|---|---|---|
| cmd | array | Program and argv, encoded as repeated cmd parameters. |
| path? | string | |
| dir? | string | |
| env? | record | |
| input? | discriminatedUnion | |
| failOnNonZero? | boolean | |
| tty? | boolean | |
| rows? | number | |
| cols? | number | |
| detachable? | boolean | |
| cc? | boolean | |
| max_run_after_disconnect? | string | |
| closeStdin? | boolean | |
| actions? | array | |
| detachAfterMs? | number | Save session identity and disconnect after this duration instead of waiting for exit. |
| Argument | Type | Description |
|---|---|---|
| session_id | string | |
| input? | discriminatedUnion | |
| failOnNonZero? | boolean | |
| tty? | boolean | |
| rows? | number | |
| cols? | number | |
| detachable? | boolean | |
| cc? | boolean | |
| max_run_after_disconnect? | string | |
| closeStdin? | boolean | |
| actions? | array | |
| detachAfterMs? | number | Save session identity and disconnect after this duration instead of waiting for exit. |
| Argument | Type | Description |
|---|---|---|
| cmd | array | Program and argv, encoded as repeated cmd parameters. |
| path? | string | |
| dir? | string | |
| env? | record | |
| input? | discriminatedUnion | |
| failOnNonZero? | boolean |
| Argument | Type | Description |
|---|---|---|
| session_id | string | |
| signal? | string | |
| timeout? | string |
| Argument | Type | Description |
|---|---|---|
| workingDir? | string | |
| path | string | |
| recursive? | boolean | |
| pattern? | string |
| Argument | Type | Description |
|---|---|---|
| workingDir? | string | |
| path | string |
| Argument | Type | Description |
|---|---|---|
| workingDir? | string | |
| path | string | |
| content | discriminatedUnion | |
| mode? | string | |
| mkdir? | boolean |
| Argument | Type | Description |
|---|---|---|
| workingDir? | string | |
| path | string | |
| recursive? | boolean | |
| asRoot? | boolean |
| Argument | Type | Description |
|---|---|---|
| source | string | |
| dest | string | |
| preserveAttrs? | boolean | |
| workingDir? | string | |
| recursive? | boolean | |
| asRoot? | boolean |
| Argument | Type | Description |
|---|---|---|
| source | string | |
| dest | string | |
| workingDir? | string | |
| asRoot? | boolean |
| Argument | Type | Description |
|---|---|---|
| workingDir? | string | |
| path | string | |
| recursive? | boolean | |
| asRoot? | boolean | |
| mode | string |
| Argument | Type | Description |
|---|---|---|
| workingDir? | string | |
| path | string | |
| recursive? | boolean | |
| asRoot? | boolean | |
| uid? | number | |
| gid? | number |
| Argument | Type | Description |
|---|---|---|
| paths | array | |
| recursive? | boolean | |
| workingDir? | string | |
| durationMs | number | |
| maxEvents? | number |
| Argument | Type | Description |
|---|---|---|
| rules? | array |
| Argument | Type | Description |
|---|---|---|
| profile? | enum | |
| devices? | array | |
| noNewPrivileges? | boolean |
| Argument | Type | Description |
|---|---|---|
| memory? | object |
| Argument | Type | Description |
|---|---|---|
| durationMs | number | |
| maxEvents? | number | Maximum incremental notifications; initial snapshot entries do not count toward this limit. |
| Argument | Type | Description |
|---|---|---|
| localPort | number | Required port bound only on the IPv4 loopback interface. |
| host | string | Remote host reached from inside the Sprite. |
| port | number | Remote TCP port reached from inside the Sprite. |
| durationMs | number | |
| maxConnections? | number |
| Argument | Type | Description |
|---|---|---|
| provider | string | |
| connection_id | string | |
| providerPath? | string |
Files
Global Arguments
| Argument | Type | Description |
|---|---|---|
| token | string | Organization token; use a vault reference. |
| baseUrl? | url | |
| timeoutMs? | number | |
| maxResponseBytes? | number | |
| sprite | string | Name of the Sprite this belongs to. |
| name | string |
| Argument | Type | Description |
|---|---|---|
| expire | union |
| Argument | Type | Description |
|---|---|---|
| expire | union |
Added 1, removed 6 models
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License declared1/1earned
- Verified public repository2/2earned