@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
14 lines • 950 B
JavaScript
export function withOpenRetention(command, delegated, machineOwned) {
const retainedAgainst = (asked) => delegated ? asked !== true : machineOwned && asked === undefined;
if (command.type === "open_session" || command.type === "claim_session")
return retainedAgainst(command.retain_on_disconnect) ? { ...command, retain_on_disconnect: true } : command;
if (command.type !== "move_session" || command.op !== "import")
return command;
const { open } = command;
// The line is not parsed yet: an `open` that is neither `true` nor an object is left for the import to refuse.
const fields = open === true ? {} : typeof open === "object" && open !== null && !Array.isArray(open) ? open : undefined;
return fields !== undefined && retainedAgainst(fields.retain_on_disconnect)
? { ...command, open: { ...fields, retain_on_disconnect: true } }
: command;
}
//# sourceMappingURL=open-retention.js.map