@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
40 lines • 1.95 kB
JavaScript
import { EMPTY_SESSION_CONTEXT } from "../../core/extensions/types.js";
export class RpcSessionRegistryError extends Error {
constructor(code, reason, detail) {
super(code === "open_failed" && reason ? `${code}: ${reason}` : code);
this.code = code;
this.name = "RpcSessionRegistryError";
if (detail)
this.detail = detail;
}
}
/** Freezes an open's launch inputs, including the nested objects a client supplied. */
export function frozenProfile(profile) {
return Object.freeze({
...profile,
...(profile.holderEndpoint ? { holderEndpoint: Object.freeze({ ...profile.holderEndpoint }) } : {}),
...(profile.creationModel ? { creationModel: Object.freeze({ ...profile.creationModel }) } : {}),
...(profile.sessionContext ? { sessionContext: Object.freeze({ ...profile.sessionContext }) } : {}),
...(profile.sessionEnv ? { sessionEnv: Object.freeze({ ...profile.sessionEnv }) } : {}),
...(profile.retryFallback
? {
retryFallback: Object.freeze({
modelFallback: profile.retryFallback.modelFallback,
fallbackChains: Object.freeze(Object.fromEntries(Object.entries(profile.retryFallback.fallbackChains).map(([key, entries]) => [
key,
Object.freeze([...entries]),
]))),
}),
}
: {}),
});
}
/**
* The visibility class and labels an entry keeps for its life, normalized once here so no
* lifecycle, listing or delivery decision has to re-apply the defaults. Reads the already
* frozen profile, so the entry and the runtime share one frozen context object.
*/
export function sessionIdentity(profile) {
return { kind: profile.sessionKind ?? "interactive", context: profile.sessionContext ?? EMPTY_SESSION_CONTEXT };
}
//# sourceMappingURL=session-registry-types.js.map