@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
29 lines • 1.4 kB
JavaScript
/**
* What a predecessor sends about a routed session is parsed here, not trusted structurally: a version-skewed
* generation's row is relayed to clients and its park drives a local reopen (cwd, profile, retention).
*/
import { isHandoverParkedEntry } from "./host-handover-parked.js";
import { authRecord } from "./rpc-auth-proof.js";
const ROW_STATES = ["opening", "open", "closing"];
export function isRoutedSessionRow(value) {
const row = authRecord(value);
return (row !== undefined &&
typeof row.sessionId === "string" &&
typeof row.cwd === "string" &&
ROW_STATES.includes(row.status) &&
typeof row.attachments === "number" &&
typeof row.retain_on_disconnect === "boolean" &&
typeof row.kind === "string" &&
authRecord(row.context) !== undefined &&
(row.sessionPath === undefined || typeof row.sessionPath === "string") &&
(row.durableSessionId === undefined || typeof row.durableSessionId === "string"));
}
/** The routed attach's `routeRow` / `routePark`: each is kept only when it has the shape its reader needs. */
export function routedAttachExtras(data) {
const { routeRow, routePark } = data;
return {
...(isRoutedSessionRow(routeRow) ? { row: routeRow } : {}),
...(isHandoverParkedEntry(routePark) ? { park: routePark } : {}),
};
}
//# sourceMappingURL=predecessor-wire.js.map