Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
29 lines
897 B
TypeScript
29 lines
897 B
TypeScript
import * as Base64Url from "effect/encoding/Base64Url";
|
|
import { CheckpointRef, ProjectId, type ThreadId } from "@t3tools/contracts";
|
|
|
|
const CHECKPOINT_REFS_PREFIX = "refs/t3/checkpoints";
|
|
|
|
export function checkpointRefForThreadTurn(threadId: ThreadId, turnCount: number): CheckpointRef {
|
|
return CheckpointRef.make(
|
|
`${CHECKPOINT_REFS_PREFIX}/${Base64Url.encode(threadId)}/turn/${turnCount}`,
|
|
);
|
|
}
|
|
|
|
function resolveThreadWorkspaceCwd(input: {
|
|
readonly thread: {
|
|
readonly projectId: ProjectId;
|
|
readonly worktreePath: string | null;
|
|
};
|
|
readonly projects: ReadonlyArray<{
|
|
readonly id: ProjectId;
|
|
readonly workspaceRoot: string;
|
|
}>;
|
|
}): string | undefined {
|
|
const worktreeCwd = input.thread.worktreePath ?? undefined;
|
|
if (worktreeCwd) {
|
|
return worktreeCwd;
|
|
}
|
|
|
|
return input.projects.find((project) => project.id === input.thread.projectId)?.workspaceRoot;
|
|
}
|