openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
53 lines (52 loc) • 1.84 kB
JavaScript
import { a as readCapturedSessionActorEntry, t as captureSessionActorStorageOwner } from "./session-actor-storage-binding-DMwpDsij.mjs";
import { t as withWorktreeGitConfig } from "./checkout-git-config-ClOP9WBP.mjs";
//#region src/agents/worktrees/checkout-policy.ts
/** Existing session custody also covers archive/restore before any execution projection exists. */
async function usesSourceOnlyWorktreeGit(e, t, n) {
if (e.ownerKind !== "session") return false;
if (!e.ownerId) return true;
const r = captureSessionActorStorageOwner({
sessionKey: e.ownerId,
env: t
}, {
assertCurrent() {},
authorize() {}
});
const [{ readSessionEntryReadOnlyInWorker: i }, { resolveSessionStorePathCore: a }, { resolveSessionAgentId: o }, { resolveSandboxRuntimeStatus: s }, { hasLocalWorkspaceProjection: c }] = await Promise.all([
import("./session-entry-read-runtime-24no1ay9.mjs"),
import("./paths-vnGHlSXy.mjs"),
import("./agent-scope-7S_X4gNj.mjs"),
import("./runtime-status-u7LbP1Hy.mjs"),
import("./local-workspace-store-DDmYl955.mjs")
]);
if (await c(e.id, t)) return true;
const l = n();
const u = o({
config: l,
sessionKey: e.ownerId
});
const d = r ? readCapturedSessionActorEntry(r, e.ownerId) : await i({
agentId: u,
sessionKey: e.ownerId,
env: t,
storePath: a(l.session?.store, {
agentId: u,
env: t
}),
clone: false
});
if (!d || d.worktree?.id !== e.id || d.sandbox === "required") return true;
return s({
cfg: l,
agentId: u,
sessionKey: e.ownerId,
preparedSessionEntry: d
}).sandboxed;
}
async function withManagedWorktreeGit(e, t) {
const n = await usesSourceOnlyWorktreeGit(e.record, e.env, e.getConfig);
e.beforeRun?.();
return await withWorktreeGitConfig(e.record.path, n, e, t);
}
//#endregion
export { withManagedWorktreeGit as n, usesSourceOnlyWorktreeGit as t };