diff --git a/cli/src/commands/client/cloud.ts b/cli/src/commands/client/cloud.ts index fdbcc76af82..56da8493160 100644 --- a/cli/src/commands/client/cloud.ts +++ b/cli/src/commands/client/cloud.ts @@ -8,6 +8,10 @@ import type { CompanyPortabilityFileEntry, InstanceExperimentalSettings, } from "@paperclipai/shared"; +import { + CLOUD_UPSTREAM_EXPORTER_VERSION, + CLOUD_UPSTREAM_SOURCE_SCHEMA_VERSION, +} from "@paperclipai/shared"; import { openUrl } from "../../client/board-auth.js"; import { resolvePaperclipInstanceId } from "../../config/home.js"; import { @@ -286,8 +290,8 @@ export async function buildBundleFromLocalCompany(input: { sourceInstanceId: input.connection.sourceInstanceId, sourceCompanyId: input.localCompanyId, sourceInstanceKeyFingerprint: input.connection.sourceInstanceFingerprint, - exporterVersion: "paperclipai-cli-cloud-v1", - sourceSchemaVersion: "paperclip-local-portability-v1", + exporterVersion: CLOUD_UPSTREAM_EXPORTER_VERSION, + sourceSchemaVersion: CLOUD_UPSTREAM_SOURCE_SCHEMA_VERSION, }; const target: UpstreamTransferManifestTarget = { targetStackId: input.discovery.stack.id, diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 958950f09a4..5052e187224 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -682,20 +682,22 @@ export { MAX_ISSUE_GRAPH_LIVENESS_AUTO_RECOVERY_LOOKBACK_HOURS, } from "./types/instance.js"; -export type { - CloudUpstreamConnectStartResponse, - CloudUpstreamActivationDecision, - CloudUpstreamActivationEntityType, - CloudUpstreamConnection, - CloudUpstreamConflict, - CloudUpstreamPreview, - CloudUpstreamRun, - CloudUpstreamRunEvent, - CloudUpstreamsState, - CloudUpstreamStep, - CloudUpstreamSummaryCount, - CloudUpstreamTarget, - CloudUpstreamWarning, +export { + CLOUD_UPSTREAM_EXPORTER_VERSION, + CLOUD_UPSTREAM_SOURCE_SCHEMA_VERSION, + type CloudUpstreamConnectStartResponse, + type CloudUpstreamActivationDecision, + type CloudUpstreamActivationEntityType, + type CloudUpstreamConnection, + type CloudUpstreamConflict, + type CloudUpstreamPreview, + type CloudUpstreamRun, + type CloudUpstreamRunEvent, + type CloudUpstreamsState, + type CloudUpstreamStep, + type CloudUpstreamSummaryCount, + type CloudUpstreamTarget, + type CloudUpstreamWarning, } from "./types/cloud-upstream.js"; export { diff --git a/packages/shared/src/types/cloud-upstream.ts b/packages/shared/src/types/cloud-upstream.ts index 211fa25d53d..e1aa2c320cb 100644 --- a/packages/shared/src/types/cloud-upstream.ts +++ b/packages/shared/src/types/cloud-upstream.ts @@ -4,6 +4,9 @@ export type CloudUpstreamRunStatus = "previewed" | "running" | "succeeded" | "fa export type CloudUpstreamActivationEntityType = "agents" | "routines" | "monitors"; +export const CLOUD_UPSTREAM_EXPORTER_VERSION = "paperclipai-cli-cloud-v1"; +export const CLOUD_UPSTREAM_SOURCE_SCHEMA_VERSION = "paperclip-local-portability-v1"; + export interface CloudUpstreamActivationDecision { entityType: CloudUpstreamActivationEntityType; count: number; diff --git a/server/src/services/cloud-upstreams.ts b/server/src/services/cloud-upstreams.ts index 1a6769ffdf2..c4787684cc0 100644 --- a/server/src/services/cloud-upstreams.ts +++ b/server/src/services/cloud-upstreams.ts @@ -9,6 +9,7 @@ import type { CloudUpstreamPreview, CloudUpstreamRun, CloudUpstreamRunEvent, + CloudUpstreamStep, CloudUpstreamsState, CloudUpstreamSummaryCount, CloudUpstreamTarget, @@ -16,6 +17,10 @@ import type { CompanyPortabilityExportResult, CompanyPortabilityFileEntry, } from "@paperclipai/shared"; +import { + CLOUD_UPSTREAM_EXPORTER_VERSION, + CLOUD_UPSTREAM_SOURCE_SCHEMA_VERSION, +} from "@paperclipai/shared"; import type { Db } from "@paperclipai/db"; import { agents, @@ -432,11 +437,13 @@ export function cloudUpstreamService(db: Db, options: { instanceId?: string } = }): Promise { let preview: CloudUpstreamPreview | null = null; let bundle: LocalUpstreamExportBundle | null = null; + let currentStep: CloudUpstreamStep = "scan"; try { preview = await localPreview(input.connection); if (!preview.schemaCompatible) { throw badRequest("Cloud stack schema is not compatible with this local Paperclip version"); } + currentStep = "preview"; await updateRun(input.runId, { activeStep: "preview", progressPercent: 25, @@ -451,6 +458,7 @@ export function cloudUpstreamService(db: Db, options: { instanceId?: string } = }); bundle = await buildBundle(input.connection, "apply"); + currentStep = "push"; await updateRun(input.runId, { activeStep: "push", progressPercent: 45, @@ -484,6 +492,7 @@ export function cloudUpstreamService(db: Db, options: { instanceId?: string } = for (const chunk of bundle.chunks) { await remotePost(input.connection, `/api/upstream-import-runs/${encodeURIComponent(remoteRunId)}/chunks`, chunk); } + currentStep = "verify"; await updateRun(input.runId, { activeStep: "verify", progressPercent: 82, @@ -536,7 +545,7 @@ export function cloudUpstreamService(db: Db, options: { instanceId?: string } = const failure = cloudUpstreamRemoteFailureReport(error); await updateRun(input.runId, { status: "failed", - activeStep: "push", + activeStep: currentStep, progressPercent: 100, ...(preview ? { summary: preview.summary, @@ -652,8 +661,8 @@ export function cloudUpstreamService(db: Db, options: { instanceId?: string } = sourceInstanceId: connection.sourceInstanceId, sourceCompanyId: connection.companyId, sourceInstanceKeyFingerprint: connection.sourceInstanceFingerprint, - exporterVersion: "paperclip-local-cloud-ui-v1", - sourceSchemaVersion: TRANSFER_SCHEMA.version, + exporterVersion: CLOUD_UPSTREAM_EXPORTER_VERSION, + sourceSchemaVersion: CLOUD_UPSTREAM_SOURCE_SCHEMA_VERSION, }; const target = { targetStackId: connection.targetStackId,