/** * fusion-app — server helpers for driving the Builder Fusion app-building * backend (ai-services) from agent-native apps. * * Fusion projects/branches are full running apps: a cloud container runs the * dev server (preview URL) and an in-container coding agent applies edits. * These helpers cover the lifecycle an app template needs: * * - `ensureFusionContainer` — boot/attach the branch container, resolve the * iframe-able dev-server preview URL. * - `sendFusionBranchMessage` — send a prompt to the branch's coding agent * (fire-and-forget by default so callers stay * within hosted action budgets). * - `pushFusionBranch` — push the branch's code to its git remote. * - `reserveFusionHostingSlug` — reserve a `.builder.cloud` hosting slug. * - `deployFusionProject` — trigger a hosted deploy of the project. * - `getFusionDeploys` — list deploys (poll deploy status). * * All calls use the shared Builder authorization resolver. OAuth tokens use * bearer authentication alone; legacy private keys also require the * space/public key as the `apiKey` query param. * * Endpoints match ai-services `packages/service/main.ts`; streaming endpoints * respond with newline-delimited JSON over chunked HTTP. */ import { z } from "zod"; import { type BuilderReferralInfo } from "../shared/builder-referrals.js"; export interface FusionBranchRef { projectId: string; branchName: string; } export interface EnsureFusionContainerResult { status: "ready" | "provisioning" | "error"; url?: string; message?: string; } export interface SendFusionMessageResult { sent: boolean; /** * True only when the app agent's run finished without an error. A message * can be sent (dispatched) and still not complete: it timed out, failed * afterwards, or was fire-and-forget. */ completed?: boolean; /** * True when the message was dispatched but this call stopped hearing from * the run before it ended (timed out or the stream was cut off): Builder * may still be applying it, so it must not be treated as failed-and-safe * to resend, nor as done. */ unconfirmed?: boolean; response?: string; error?: string; } declare const builderCreditUsageSchema: z.ZodObject<{ plan: z.ZodEnum<{ free: "free"; paid: "paid"; }>; balance: z.ZodNumber; quota: z.ZodObject<{ period: z.ZodEnum<{ daily: "daily"; monthly: "monthly"; }>; limit: z.ZodNumber; used: z.ZodNumber; remaining: z.ZodNumber; }, z.core.$strip>; }, z.core.$strip>; export type BuilderCreditUsage = z.infer; export declare function getBuilderCreditUsage(): Promise; export declare function getBuilderReferralInfo(): Promise; export declare function getFusionBranchEditorUrl(ref: FusionBranchRef): string; export declare function getFusionHostingUrl(slug: string): string; export declare function ensureFusionContainer(args: FusionBranchRef & { timeoutMs?: number; }): Promise; export declare function sendFusionBranchMessage(args: FusionBranchRef & { prompt: string; fireAndForget?: boolean; timeoutMs?: number; userEmail?: string; /** * Every coding-agent step as it streams (`GenerateCompletionStep`: * text, thinking, tool, tool_result, file, diff, done, error, ...), so a * delegating agent can show the Builder agent's work live instead of only * its final message. Pair with `fireAndForget: false`. */ onEvent?: (step: Record) => void; }): Promise; export declare function pushFusionBranch(ref: FusionBranchRef): Promise>; export declare function reserveFusionHostingSlug(args: { projectId: string; slug: string; }): Promise<{ slug: string; }>; export declare function deployFusionProject(args: { projectId: string; checkoutBranch?: string; }): Promise<{ deployId: string; status: string; }>; export declare function getFusionDeploys(args: { projectId: string; deployId?: string; }): Promise>>; export {};