/** * Pi System-Prompt Transform Adapter — `src/platform/adapters/pi/system-transform.ts` * * Runs the opencode system-prompt transform pipeline * (`src/hooks/system-transform.ts` — `handleSystemTransform`) against the Pi * `before_agent_start` event shape, so the full rolebox prompt augmentation * works on the Pi platform without an opencode hook host: * * - pending correction injection (`state.pendingCorrections`, consumed by * `appendCorrection` from the S6 hook pipeline's event handlers) * - `` block (`buildAvailableFunctionsBlock`) * - `` block (`MemoryStore.create(deps.dir)` + the role's * `config.memory` block, per system-transform.ts:87-110) * - gate/transition evaluation (`evaluateGateAndTransitions` + * `functionSessionState.activate`/`deactivate`), the function kernel's * turn increment, and the priority-ordered `` block * (`buildFunctionBlock`) * - artifact consumption blocks (`buildActiveArtifactBlock`) * - `` engine-v2 graph orientation block * * The adapter is intentionally thin: it extracts the session id and acting * agent from the loosely-typed Pi event / extension ctx / active-agent ref, * seeds `output.system` with `[currentSystemPrompt + baseSection]` (the * static available_roles/loop_tool guidance the caller already built), and * delegates the rest to the shared pipeline. It returns `undefined` when no * session id can be resolved so the caller falls back to the static prompt. * * @module */ import type { HookDeps } from "../../../hooks/deps.ts"; import type { HookState } from "../../../hooks/state.ts"; /** * Extract the session id from a Pi `before_agent_start` event with a * fallback chain mirroring `extractSessionId` (pi-extension.ts): direct * `sessionID` / `sessionId` fields, `info.sessionID` / `info.sessionId` / * `info.id`, then the extension context's `sessionManager.getSessionId()`. */ export declare function extractPiSessionId(event: Record, ctx?: Record | undefined): string | undefined; /** * Extract the acting rolebox agent from the event, extension context, or the * Pi active-agent ref (the role-switcher source of truth — Pi never * populates `context.agent` itself, per pi-extension.ts). Returns * `undefined` when unresolved; `handleSystemTransform` then falls back to * `state.sessionAgentRegistry`. */ export declare function extractPiAgent(event: Record, activeAgent?: { get(): string | null; } | undefined, ctx?: Record | undefined): string | undefined; export interface PiSystemTransformOptions { /** * Raw Pi `before_agent_start` event (loosely typed). Reads * `systemPrompt` (the current system prompt), plus session/agent * identifiers via `extractPiSessionId` / `extractPiAgent`. */ event: Record; /** * Pi extension context — `sessionManager.getSessionId()` resolves the * session id; `ctx.agent` is an agent fallback. */ ctx?: Record | undefined; /** * Static guidance appended verbatim after the base system prompt * (the existing `` / `` block). The * transform pipeline pushes its own blocks AFTER this section. */ baseSection?: string; /** Pi active-agent ref (role switcher) used as the agent fallback. */ activeAgent?: { get(): string | null; } | undefined; } /** * Run the shared `handleSystemTransform` pipeline against a Pi * `before_agent_start` event. * * Seeds `output.system` with `[currentSystemPrompt + baseSection]`, then * lets the pipeline append the correction, available-functions, memory, * active-functions, artifact-consumption, and graph-state blocks. Returns * the joined augmented prompt, or `undefined` when no session id can be * resolved (the caller then keeps the static prompt unchanged). Transform * failures are caught and logged — the base prompt is always returned so a * pipeline defect can never break an agent start on Pi. */ export declare function runPiSystemTransform(options: PiSystemTransformOptions, state: HookState, deps: HookDeps): Promise; //# sourceMappingURL=system-transform.d.ts.map