UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

39 lines • 1.76 kB
import { readCompactBlocks } from "./compact-text-view.js"; import { CompactValues } from "./compact-values.js"; /** Whole-view assembly of the calls at a cut; a streaming call's raw prefix is read through the active message. */ export async function readCalls(frozen, owner, valid) { const values = new CompactValues(owner.store); const slot = async (ref) => (ref ? await values.read(ref, valid) : null); const raw = async (address) => { if (!address) return null; if (address.kind === "owned") { let text = ""; for await (const chunk of owner.store.text.chunks(address.root, valid)) text += chunk; for await (const chunk of owner.store.text.chunks(address.tailRoot, valid)) text += chunk; return text; } for await (const [, row] of owner.messageRoots.entries(frozen.active, valid)) { if (row.messageId !== address.messageId) continue; for await (const [, block] of owner.blockRoots.entries(row.blocks, valid)) if (block.contentIndex === address.contentIndex) return (await readCompactBlocks(owner.store.text, [block], valid))[0].text; } return null; }; const calls = []; for await (const [, call] of owner.calls.entries(frozen.calls.ref, valid)) calls.push({ ...call, raw: await raw(call.raw), hook: await slot(call.hook), progress: await slot(call.progress), result: await slot(call.result), }); valid(); return { sequence: frozen.calls.sequence, calls, counters: frozen.calls.counters }; } //# sourceMappingURL=compact-call-view.js.map