mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 08:22:20 +02:00
Serialize native workspace finalization, validate streamed archives within bounded limits, and quietly recover unsafe exports from saved results. Preserve exact allocations for exhausted transient failures and provide export-only retry without rerunning the provider. Consolidates #14314, #14315, #14329, and #14334 while preserving the already-merged finalization label changes. Co-Authored-By: Paperclip <noreply@paperclip.ing>
23 lines
1.1 KiB
TypeScript
23 lines
1.1 KiB
TypeScript
import { classifyWorkspaceRestoreFailure } from "@paperclipai/adapter-utils/workspace-restore-merge";
|
|
|
|
export type NativeWorkspaceFailureCode =
|
|
| "workspace_sync_out_failed"
|
|
| "workspace_sync_out_unrecoverable"
|
|
| "workspace_sync_out_unsafe_archive";
|
|
|
|
/** Keep initial and recovered copy-back failures on the same retry policy. */
|
|
export function classifyNativeWorkspaceFailure(error: unknown): {
|
|
code: NativeWorkspaceFailureCode;
|
|
failureCode: `native_${NativeWorkspaceFailureCode}`;
|
|
permanent: boolean;
|
|
} {
|
|
const message = error instanceof Error ? error.message.trim() : "";
|
|
const code: NativeWorkspaceFailureCode =
|
|
message === "workspace_sync_out_unrecoverable" || message.includes("daytona_sandbox_not_found")
|
|
? "workspace_sync_out_unrecoverable"
|
|
: message === "workspace_sync_out_unsafe_archive" || classifyWorkspaceRestoreFailure(error) === "restore_unsafe_archive"
|
|
? "workspace_sync_out_unsafe_archive"
|
|
: "workspace_sync_out_failed";
|
|
return { code, failureCode: `native_${code}`, permanent: code !== "workspace_sync_out_failed" };
|
|
}
|