What the agent does
The agent reads the functions as they are before it renames a file. In a repository like firebase/functions-samples, Node/quickstarts/uppercase-firestore/functions/index.js starts with "use strict" and require calls: logger from firebase-functions, onRequest from firebase-functions/https, onDocumentCreated from firebase-functions/firestore, and initializeApp and getFirestore from firebase-admin. It exports two functions: addmessage, an HTTPS handler that reads req.query.text and adds a document to the messages collection, and makeuppercase, which listens on /messages/{documentId}, reads event.data.data().original, logs event.params.documentId and writes an uppercase field back with merge: true. package.json pins firebase-admin ^14.5.0 and firebase-functions ^7.4.0, has eslint with eslint-config-google, scripts for lint, serve, shell, deploy and logs, engines.node 24 and no main field, so Firebase loads index.js from the directory root. firebase.json names the codebase and configures the Firestore emulator on port 8080 and functions on 5001.
It also reads what the repository already does in TypeScript, because a conversion should match the house style. Node/test-functions-jest-ts/functions has src/index.ts with import {logger} from "firebase-functions", package.json with main set to lib/index.js, a build script running tsc, typescript ^6.0.3, ts-jest, @typescript-eslint/parser and @typescript-eslint/eslint-plugin ^8.71.0, and a tsconfig.json with module: commonjs, target: es2017, strict, noImplicitReturns, noUnusedLocals, outDir: lib, rootDir: ./src and sourceMap. Its firebase.json adds predeploy steps that run lint and build through npm --prefix "$RESOURCE_DIR", so a deploy never ships stale output. At the root, tsconfig.template.json is the repository's type-check-only config (allowJs, checkJs, noEmit, strictNullChecks off) that the compile-2nd-gen script sweeps over every sample with pnpm --recursive.
The conversion follows that pattern. index.js becomes src/index.ts with ES imports; the handler types come from the SDK, so event.data on an onDocumentCreated event is a QueryDocumentSnapshot | undefined and the strict compiler forces an explicit guard before .data(), and req.query.text is narrowed to a string before it is written. package.json gains main: lib/index.js, build and a lint that uses the TypeScript parser, typescript and the ESLint TypeScript packages as dev dependencies; .gitignore gains lib/; firebase.json gets the predeploy lint and build steps; eslint.config.js moves to the flat-config shape the TypeScript sample uses. The compile script that the root sweep depends on keeps working, since tsconfig.template.json already allows .ts input.
The proof is a build that passes under strict. The agent runs pnpm install in the function directory, npm run build and npm run lint, and includes the output. When firebase-tools installs in the sandbox, it starts the functions emulator against a demo project id, calls addmessage with curl and shows the compiled lib/index.js loading and answering; the Firestore trigger it describes rather than exercises, because the Firestore emulator needs a Java runtime the description notes it did not install. Every type error the compiler raised during the conversion is listed with the fix, since those are the bugs the JavaScript version had silently.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Convert the Cloud Functions in this repository from JavaScript to TypeScript. Read the functions directory, its package.json, firebase.json, the ESLint config and any TypeScript config already in the repository first, and follow the existing TypeScript conventions if there are any. Move the source to src/, use ES imports and the SDK's handler types, enable strict mode and fix every type error properly rather than with any. Add a build script, set main to the compiled output, ignore the output directory, add predeploy lint and build steps to firebase.json, and update the lint setup for TypeScript. Run the build and lint and include the output; start the functions emulator and call an HTTP function if the tools are available. Open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request that renames index.js to src/index.ts, adds tsconfig.json, changes package.json (main, build, lint, dev dependencies), updates firebase.json with the predeploy steps, updates the ESLint config and the lockfile, and adds lib/ to .gitignore. The exported function names are unchanged, so the deployed functions keep their URLs and triggers.
The description lists each type error the strict compiler raised, such as event.data being possibly undefined and the untyped req.query.text, with how each was resolved, and quotes the tsc and eslint output and the emulator call if one was made. The full commands and their output are in the transcript at GET /o/{org}/sessions/{id}/messages.
Before merging, a reviewer checks that no handler's behaviour changed where a type guard was added, decides whether the compiled lib/ should stay ignored or be committed, and runs firebase deploy --only functions from a branch to confirm the predeploy steps run. A follow-up message to the same session can convert a second function directory in the same repository.
Run it on every functions directory still in JavaScript
A monorepo with many function codebases, like the samples repository with one functions directory per example, is handled one directory per run: a script lists the directories whose package.json has no build script and sends one POST /o/{org}/sessions per directory, naming it in input. Each run opens its own pull request, so a reviewer merges them one at a time.
A key runs at most max_concurrent runs at once, four by default; a run past that answers 202 with status: "queued" and starts when a slot frees. Send a request_id, a UUID v5 of the directory path, so a retried call returns the run it already started.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A TypeScript conversion is where a function's latent bugs surface: the event payload that can be undefined, the query parameter that can be an array. Doing it well means reading the SDK's types, the repository's existing TypeScript style and the deploy hooks, then fixing each compiler error on its merits. The agent does that in a sandbox of its own and keeps every command's output.
The pull request carries the list of type errors and their fixes, the passing build and lint, and the emulator call when it ran, so the review is a read of one diff rather than a rerun. Several function directories can be converted at once, each in its own sandbox, each with its own pull request.
Frequently asked questions
Will the deployed function names or URLs change?
No. The exports keep their names, main points at the compiled file, and Firebase loads the same addmessage and makeuppercase it did before. The predeploy steps only make sure the compiled output is fresh before each deploy.
Why strict mode rather than a permissive tsconfig?
Because the point of the conversion is the errors strict mode finds: a Firestore event whose data is undefined on a delete, a query parameter that is not a string. The agent matches the strict settings the repository's own TypeScript sample uses and fixes each error with a guard or a narrower type, never with any.
Does it handle the ESLint setup?
Yes. The JavaScript config with eslint-config-google becomes a flat config with the TypeScript parser and plugin, as the repository's TypeScript sample already has, and npm run lint passes on the converted source before the pull request opens.
Can it test the Firestore trigger?
The HTTP function is called through the functions emulator when firebase-tools is available. The Firestore trigger needs the Firestore emulator, which needs a Java runtime; the agent says in the description whether it installed one and exercised the trigger, or compiled and lint-checked it only.