@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
60 lines • 2.01 kB
JavaScript
/** The header fields a new call starts from before its creating record fills its own. */
export const FRESH_CALL = {
owningMessageId: null,
contentIndex: null,
parentKey: null,
join: "pending",
startSequence: null,
startedAtMs: null,
requestedName: null,
resolvedName: null,
seed: null,
raw: null,
input: { announced: null, started: null, prepared: null },
correlation: null,
hook: null,
progress: null,
result: null,
outcome: null,
};
export const TERMINAL_PHASE = "completed-awaiting-entry";
/** Execution, hook and boundary records the lane folds into the calls component. */
export const CALL_RECORDS = new Set([
"tool_execution_start",
"tool_execution_update",
"tool_execution_end",
"tool_hook_status",
"turn_end",
"agent_settled",
"message_end",
]);
/** Records whose only lane effect is a call transition: ignored, they take no sequence (RULING-13 Q9). */
export const CALL_ONLY_RECORDS = new Set([
"tool_execution_update",
"tool_execution_end",
"tool_hook_status",
"agent_settled",
]);
export function runtimeItemKey(scope, creationSequence, k) {
return `${scope.sessionEpoch}:${creationSequence}.${k}`;
}
export const CALL_UNKNOWN = Object.freeze({ callUnknown: true });
export function callIdentity(call) {
return call ? { runtimeItemKey: call.runtimeItemKey } : CALL_UNKNOWN;
}
/** Fixed-width tree ordinal so the root orders calls by creation, independent of the epoch string. */
export function callOrder(creationSequence, k) {
return `${String(creationSequence).padStart(16, "0")}.${String(k).padStart(4, "0")}`;
}
export function callLeaves(call) {
return [
call.hook?.owner ?? 0,
call.progress?.owner ?? 0,
call.result?.owner ?? 0,
...(call.raw?.kind === "owned" ? [call.raw.root, call.raw.tailRoot] : []),
];
}
export function terminal(call) {
return call.phase === TERMINAL_PHASE;
}
//# sourceMappingURL=compact-call-model.js.map