import { type FunnelContractDiagnosticCode } from '@funnelsgrove/runtime'; import type { SourceCandidateOperation } from './localSync.js'; import type { AgentExperimentSpec, ExperimentCreateResponse } from './experimentCreate.js'; type FetchFn = typeof fetch; type TrpcProcedureType = 'query' | 'mutation'; export type TrpcCallInput = { apiUrl: string; path: string; type: TrpcProcedureType; input?: unknown; token?: string | null; fetchFn?: FetchFn; signal?: AbortSignal; }; export type FunnelSourceCandidateApiContext = { apiUrl: string; token?: string | null; fetchFn?: FetchFn; signal?: AbortSignal; }; export type DraftPatchFile = { path: string; content: string; contentType?: string; }; export type ApplyDraftPatchInput = { workspaceId: string; funnelId: string; baseDraftVersionId: string | null; idempotencyKey: string; message?: string; changedFiles: DraftPatchFile[]; deletedPaths: string[]; }; export type ApplyDraftPatchResult = { funnelId: string; previousDraftVersionId: string | null; draftVersionId: string; draftVersionSeq: number; rebasedFromVersionId: string | null; changedPaths: string[]; deletedPaths: string[]; changedContentBytes: number; idempotent: boolean; }; export type DirectAssetUploadDescription = { workspaceId: string; funnelId: string; path: string; contentType: string; sizeBytes: number; sha256: string; }; export type PreparedDirectAssetUpload = Omit & { uploadKey: string; uploadUrl: string; uploadHeaders: Record; }; export type FinalizeDirectAssetUploadInput = DirectAssetUploadDescription & { uploadKey: string; }; export type CreateFunnelExperimentFromSpecInput = { workspaceId: string; funnelId: string; expectedDraftVersionId: string; spec: AgentExperimentSpec; }; export type FunnelSourceCandidateStatus = 'staging' | 'validating' | 'committed' | 'aborted' | 'expired' | 'failed'; export type BeginFunnelSourceCandidateInput = { workspaceId: string; funnelId: string; baseDraftVersionId: string | null; idempotencyKey: string; }; export type StageFunnelSourceCandidateInput = { workspaceId: string; candidateId: string; idempotencyKey: string; operations: SourceCandidateOperation[]; }; export type FinishFunnelSourceCandidateInput = { workspaceId: string; candidateId: string; }; export type FinalizeFunnelSourceCandidateInput = FinishFunnelSourceCandidateInput & { message?: string; }; export type FunnelSourceCandidateSummary = { candidateId: string; status: FunnelSourceCandidateStatus; baseDraftVersionId: string | null; fileCount?: number; byteCount?: number; batchCount?: number; }; export type StageFunnelSourceCandidateResult = { candidateId: string; stageId: string; batchIndex: number; operationCount: number; fileCount: number; byteCount: number; totalOperationCount: number; idempotent: boolean; }; export type FinalizeFunnelSourceCandidateResult = { candidateId: string; projectId: string; funnelId: string; versionId: string; status: 'committed'; idempotent: boolean; diagnostics: readonly FunnelContractApiDiagnostic[]; }; export declare const FUNNEL_CONTRACT_API_INGRESSES: readonly ["cli-sync", "github-sync", "builder-authoring", "preview-publish", "production-publish", "published-artifact-serving"]; export type FunnelContractApiIngress = (typeof FUNNEL_CONTRACT_API_INGRESSES)[number]; export type FunnelContractApiDiagnostic = { code: FunnelContractDiagnosticCode; severity: 'error'; ingress: FunnelContractApiIngress; file: string | null; stepId: string | null; expected: unknown; received: unknown; reason: string; guide: string; repair: string; }; export type FunnelContractApiErrorData = { schemaVersion: 1; contractVersion: number; ingress: FunnelContractApiIngress; diagnostics: readonly FunnelContractApiDiagnostic[]; }; export declare const formatFunnelContractApiError: (message: string, funnelContract: FunnelContractApiErrorData) => string; export declare class FunnelContractApiError extends Error { readonly funnelContract: FunnelContractApiErrorData; constructor(message: string, funnelContract: FunnelContractApiErrorData); } export declare class TrpcApiError extends Error { readonly code: string | null; readonly httpStatus: number | null; constructor(message: string, code: string | null, httpStatus: number | null); } export declare const isMissingTrpcProcedureError: (error: unknown) => boolean; export declare const parseFunnelContractApiErrorData: (value: unknown) => FunnelContractApiErrorData | null; export declare function parseTrpcJsonResponse(response: unknown): T; export declare function callTrpcProcedure(input: TrpcCallInput): Promise; export declare const beginFunnelSourceCandidate: (context: FunnelSourceCandidateApiContext, input: BeginFunnelSourceCandidateInput) => Promise; export declare const stageFunnelSourceCandidate: (context: FunnelSourceCandidateApiContext, input: StageFunnelSourceCandidateInput) => Promise; export declare const finalizeFunnelSourceCandidate: (context: FunnelSourceCandidateApiContext, input: FinalizeFunnelSourceCandidateInput) => Promise; export declare const abortFunnelSourceCandidate: (context: FunnelSourceCandidateApiContext, input: FinishFunnelSourceCandidateInput) => Promise; export declare const applyFunnelDraftPatch: (context: FunnelSourceCandidateApiContext, input: ApplyDraftPatchInput) => Promise; export declare const prepareFunnelDirectAssetUpload: (context: FunnelSourceCandidateApiContext, input: DirectAssetUploadDescription) => Promise; export declare const finalizeFunnelDirectAssetUpload: (context: FunnelSourceCandidateApiContext, input: FinalizeDirectAssetUploadInput) => Promise; export declare const createFunnelExperimentFromSpec: (context: FunnelSourceCandidateApiContext, input: CreateFunnelExperimentFromSpecInput) => Promise; export {};