@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
29 lines • 1.53 kB
JavaScript
import { isSessionArchived } from "../../core/session-archived.js";
import { readSessionSettled, settledFields } from "../../core/session-settled.js";
import { liveSessionWritePaths } from "../../core/session-write-reservation.js";
import { buildRpcSessionState } from "./connection-handler.js";
import { isHandoffBusy } from "./handoff-activity.js";
import { canonicalSessionPath } from "./session-path-key.js";
/** The worker isolate's whole-state snapshot of its one session, built only when a message carries it. */
export function workerSnapshot(entry) {
if (!entry?.runtime)
throw new Error("Session runtime is not ready");
const session = entry.runtime.session;
const sessionPath = session.sessionFile ? canonicalSessionPath(session.sessionFile) : undefined;
// The host releases every granted path this list omits, so it must name each writer
// still alive in this isolate, plus the session the runtime currently writes.
const live = new Set(liveSessionWritePaths().map(canonicalSessionPath));
if (sessionPath)
live.add(sessionPath);
return {
state: buildRpcSessionState(session),
sessionPath,
liveSessionPaths: [...live],
busy: session.isSessionBusy,
handoffBusy: isHandoffBusy(session.activitySnapshot),
streaming: session.isStreaming,
archived: isSessionArchived(session.sessionManager),
...settledFields(readSessionSettled(session.sessionManager)),
};
}
//# sourceMappingURL=session-worker-snapshot.js.map