Skip to content

feat(fly): Sprite filesystem Op activities (read/write/list/remove) #848

Closed

Description

@lex00

Context

The fly lexicon models Sprites as imperative Op activities (#762): spriteCreate / spriteExec / spriteCheckpoint / spriteRestore / spriteDestroy. Sprites also expose a full filesystem API that chant does not wrap. Today an Op that needs to stage an input file into a Sprite or read a result out has to shell it through spriteExec + cat / tee, which is brittle (quoting, binary data, exit handling).

Sprites filesystem endpoints (from the API docs):

Op Method Path Key params
read GET /v1/sprites/{name}/fs/read path, workingDir
write PUT /v1/sprites/{name}/fs/write path, workingDir, mode, mkdir
list GET /v1/sprites/{name}/fs/list path, workingDir
delete DELETE /v1/sprites/{name}/fs/delete path, recursive, asRoot
rename POST /v1/sprites/{name}/fs/rename source, dest, asRoot
copy POST /v1/sprites/{name}/fs/copy source, dest, recursive, preserveAttrs, asRoot
chmod POST /v1/sprites/{name}/fs/chmod path, mode, recursive, asRoot
chown POST /v1/sprites/{name}/fs/chown path, uid, gid, recursive, asRoot
watch WSS /v1/sprites/{name}/fs/watch paths[], recursive

Read/write use raw file bytes in the body.

Proposal

Add filesystem Op activities alongside the existing sprite activities, same category (imperative runtime-orchestration primitives, no desired state):

  • spriteWriteFile({ id, path, content, mode?, mkdir? })
  • spriteReadFile({ id, path }) → bytes/string
  • spriteListDir({ id, path })
  • spriteRemove({ id, path, recursive? })
  • (rename/copy/chmod/chown as needed; watch deferred — WSS, no obvious Op use yet)

Same conventions as the current activities: injectable HTTP client, endpoint resolution via SPRITES_BASE_URL then the real base, Authorization: Bearer when a token is set. Pure helpers for URL building kept unit-testable. Emulator parity in createSpritesFake() so CI exercises them offline.

Driver

#847 (Managed Agents worker) uses the Filesystem API to stage the runner env-contract file and to inspect/retrieve session outputs. These activities are the clean way to express that instead of spriteExec + shell redirection.

Acceptance criteria

  • spriteWriteFile / spriteReadFile / spriteListDir / spriteRemove implemented as fly Op activities against the real fs endpoints.
  • createSpritesFake() implements the same endpoints; unit + integration tests pass offline.
  • Round-trip test: write bytes, read them back, list the dir, remove, confirm gone — against the fake.
  • Exported from @intentius/chant-lexicon-fly op-activities barrel; documented in the Sprites Op skill.
  • Stays in the fly lexicon (one lexicon per product).

Parent epic: #736 (Fly.io apply path). Builds on #762.

Activity

  1. added
    enhancement
    on Jul 13, 2026
  2. lex00 commented on Jul 13, 2026

    @lex00
    ContributorAuthor

    Demo plan — no new example

    Do not add a dedicated example for these activities. Fold them into the existing examples/sprites-agent-task.

    The current Run phase does echo hello > /work/output then cat via spriteExec. Replace that with the filesystem activities: spriteWriteFile to stage an input file, spriteExec to process it, spriteReadFile to collect the result. Same demo, sharper primitives, still runs green offline against createSpritesFake().

    So the AC's round-trip test stays, and the example update is the showcase — no separate tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions