Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ IMAGE_QUEUE_SETTINGS_SECRET=
IMAGE_QUEUE_MCP_TOKEN=
IMAGE_QUEUE_CF_ACCESS_TEAM_DOMAIN=
IMAGE_QUEUE_CF_ACCESS_AUDIENCE=
IMAGE_QUEUE_ACCESS_ALLOWED_EMAILS=
# Platform path separator between allowed reference directories.
IMAGE_QUEUE_REFERENCE_ROOTS=
IMAGE_QUEUE_OPENAI_API_KEY=
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
cache: pnpm
- uses: actions/setup-python@v5
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.12'
- run: pnpm install --frozen-lockfile
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ on:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
Expand All @@ -26,28 +24,34 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
pages: read
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
cache: pnpm
- uses: actions/configure-pages@v5
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
id: pages
- run: pnpm install --frozen-lockfile
- run: pnpm build:website
env:
WEBSITE_BASE_PATH: ${{ steps.pages.outputs.base_path }}
- uses: actions/upload-pages-artifact@v3
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with:
path: dist/website
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/deploy-pages@v4
- uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
id: deployment
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ dist/

__pycache__/
*.pyc
wrangler.deploy.jsonc
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.2.0 — 2026-11-20

- Deploy image-queue to your own Cloudflare account with `pnpm cloudflare:setup`: D1, R2, a generation queue, a custom domain, Cloudflare Access with Managed OAuth and the Worker secrets in one repeatable command. See [docs/cloudflare.md](docs/cloudflare.md) and [ADR-0020](docs/decisions/0020-remote-mcp-behind-cloudflare-access.md).
- Connect the hosted MCP endpoint from Claude on the web, desktop and phone, Claude Code or Codex. Every request needs a Cloudflare Access sign-in from an allowed address; other signed-in accounts get 403, and the local static MCP token is not accepted there. API generation runs from the queue, one attempt per job without automatic retries.
- Hosted deployments generate through the OpenAI API by default. `refresh_models` loads the model list with the server's key, `view_image` returns a finished image, and the inline request, image and gallery views work on the stateless endpoint. Reading tools are marked read-only so hosts can run them without asking.
- Inline views follow the host's font and colours, show a loading state, download the full file and play GIFs as a light animated preview. On a phone a swipe scrolls the conversation and a tap selects a place for a change. The Next version form explains what it does.
- The next version of a generated GIF is generated again from its prompt with the requested changes, keeping its model, size, frame count and frame duration.
- Every OpenAI image model has its own profile: GPT Image 2.6 Sunburst (the new default) and Flare, 2.5 Sunburst and Flare, GPT Image 2, 1.5 and 1 mini, with documented custom sizes, `quality` and, for 2.6, `complexity`. `list_models` and `get_generation_source` report each model's capabilities.
- API requests can ask for PNG, WebP, JPEG, GIF or SVG when the model lists that format. GIF requests set frame count and duration and are checked against the frame sheet the model can render before submission. One submission can create up to 10 jobs.
- A definite provider rejection, including an account with no credits, is stored as failed with the provider's reason. A corrected request may reuse the idempotency key of a failed or cancelled one.
- The sidebar shows the generation source in use and lets you switch it. Connect an agent shows the remote MCP steps on a hosted workspace. Dark theme selects, fields and checkboxes read as one system.

## 0.1.5 — 2026-11-17

- Send the first prompt directly to Inbox. Opening a project or topic sets the destination for the next image. A paused queue shows its status on mobile before submission.
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ Choose the default for new requests in **Settings → Default source**, or use M

The optional [image-queue skill](skills/image-queue/SKILL.md) explains references, source selection and error recovery for agents. Reference images must be PNG, JPEG or WebP; style documents belong in text instructions. Before retrying an uncertain result, inspect the retained output and the recovery details returned by MCP.

### Use it from your phone: deploy to Cloudflare

You can also run your own private copy on Cloudflare and add it as a remote MCP server in the Claude apps (web, desktop and phone), Claude Code or Codex. Cloudflare Access protects the panel and the MCP endpoint, and generation uses your image API key. It costs 5 USD per month for Workers Paid plus API usage. `pnpm cloudflare:setup --domain app.example.com --email you@example.com` sets everything up; see [Cloudflare deployment](docs/cloudflare.md).

```sh
claude mcp add --transport http image-queue https://app.example.com/api/mcp
codex mcp add image-queue --url https://app.example.com/api/mcp && codex mcp login image-queue
```

In claude.ai or Claude Desktop, add the same URL under **Settings → Connectors → Add custom connector**; it also appears in the Claude mobile app.

### Set up with an agent

Give a local agent terminal access to the folder where you want image-queue, then paste:
Expand Down Expand Up @@ -121,11 +132,12 @@ The supported deployment is local on macOS (Apple silicon). Cloudflare deploymen
- Only models with a verified size profile appear in the model list.
- References: PNG, JPEG or WebP, up to 20 MB.
- Interrupted paid requests are not retried automatically.
- The Cloudflare deployment runs API generation only; the Codex queue stays local.
- Not included yet: multi-machine sync, video, Windows and Linux support.
- Some OpenAI accounts need [organization verification](https://developers.openai.com/api/docs/guides/image-generation) before using image models.

## More

[Configuration](docs/configuration.md) · [Codex workers](docs/codex-workers.md) · [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md)
[Configuration](docs/configuration.md) · [Cloudflare deployment](docs/cloudflare.md) · [Codex workers](docs/codex-workers.md) · [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md)

Licensed under [Apache 2.0](LICENSE).
38 changes: 37 additions & 1 deletion cloudflare-worker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
// @ts-ignore OpenNext generates this module during the Cloudflare build.
import handler from "./.open-next/worker.js";
// @ts-ignore OpenNext generates this module during the Cloudflare build.
import { runWithCloudflareRequestContext } from "./.open-next/cloudflare/init.js";
import { busyRetryDelaySeconds, maxBusyAttempts } from "./src/core/generation-queue";
import { maintainTrash } from "./src/core/maintenance";
import { abandonQueuedJob, runQueuedJob } from "./src/core/runtime";
import { CloudflareStorage } from "./src/storage/cloudflare";

type StorageBindings = ConstructorParameters<typeof CloudflareStorage>;
type Environment = { DB: StorageBindings[0]; BLOBS: StorageBindings[1] };
type GenerationQueue = { send(body: GenerationBody, options?: { delaySeconds?: number }): Promise<unknown> };
type GenerationBody = { jobId: string; attempt?: number };
type Environment = { DB: StorageBindings[0]; BLOBS: StorageBindings[1]; GENERATION_QUEUE?: GenerationQueue };
type ExecutionContext = { waitUntil(promise: Promise<unknown>): void };
type GenerationMessage = { body: unknown; ack(): void };

/** Internal origin for queue work; it never receives network traffic. */
const queueOrigin = "https://generation-queue.invalid/";

export default {
fetch: handler.fetch,
async scheduled(event: { scheduledTime: number }, env: Environment) {
await maintainTrash(new CloudflareStorage(env.DB, env.BLOBS), event.scheduledTime);
},
/**
* Runs provider generation outside the request that created the job, so a
* remote MCP client's time limit cannot cut an attempt short. Messages are
* acknowledged after each attempt and never retried: a second delivery
* could charge the provider twice.
*/
async queue(batch: { messages: readonly GenerationMessage[] }, env: Environment, ctx: ExecutionContext) {
for (const message of batch.messages) {
const body = message.body as Partial<GenerationBody> | null;
if (typeof body?.jobId === "string") {
const jobId = body.jobId;
const attempt = Number.isInteger(body.attempt) ? body.attempt! : 0;
const inContext = <T>(work: () => Promise<T>) =>
runWithCloudflareRequestContext(new Request(queueOrigin), env, ctx, work) as Promise<T>;
if ((await inContext(() => runQueuedJob(jobId))) === "busy") {
// Another operation holds the job. Nothing was sent to the provider,
// so offering it again later cannot charge twice.
if (attempt < maxBusyAttempts && env.GENERATION_QUEUE)
await env.GENERATION_QUEUE.send({ jobId, attempt: attempt + 1 }, { delaySeconds: busyRetryDelaySeconds });
else await inContext(() => abandonQueuedJob(jobId));
}
}
message.ack();
}
},
};
Loading
Loading