UNPKG

@code-yeongyu/senpi

Version:

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

40 lines • 1.62 kB
/** Own only the current branch's in-flight handoff, never a persisted request. */ export function createReductionHandoff(pi, customInstructions) { let active; return { isPending: () => active !== undefined, reset: () => { active = undefined; }, request: (ctx) => { if (active) { ctx.abort("system"); return; } const request = { sessionId: ctx.sessionManager.getSessionId(), leaf: ctx.sessionManager.getLeafId() }; active = request; ctx.compact({ customInstructions, onError: () => { if (active === request) active = undefined; }, onComplete: () => { if (active !== request) return; active = undefined; if (ctx.sessionManager.getSessionId() !== request.sessionId || (request.leaf && !ctx.sessionManager.getBranch().some((entry) => entry.id === request.leaf)) || ctx.hasPendingMessages()) return; pi.sendMessage({ customType: "senpi.context-reduction.resume", content: "Continue the current task using the compacted context.", display: false, }, { triggerTurn: true, deliverAs: "followUp" }); }, }); }, }; } //# sourceMappingURL=context-reduction-handoff.js.map