@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
34 lines • 2.59 kB
TypeScript
/**
* What the device route sends (row CK9; custody design 2.3 options hygiene, 4.5 hook rules). The admitted request is
* built once from the loop's context and the wire allowlist of its options, stored as JSON text, and every attempt
* sends the parse of that stored text, so a reissue is byte-for-byte the admitted request. Request hooks run once per
* step: on the hand itself (`hooks: "enabled"`, reported back by `hooked`), or over V5 before a non-hand server. Hook
* output is filtered through the same allowlist before it is stored, and every parse filters again: a hook that adds
* `env` or `headers` must not reach another device, where `env` can move the dial under that device's credential.
*/
import type { DeviceId, EgressRouteDecision } from "@earendil-works/pi-agent-core";
import type { Api, AssistantMessage, Model, SimpleStreamOptions, TranscriptContext, Usage } from "@earendil-works/pi-ai";
import { type ProviderCallRequest } from "./wire.ts";
export declare const admittedRequestJson: (context: TranscriptContext, options: SimpleStreamOptions | undefined) => string;
/** The JSON text the ledger stores for a request that came back from a hook (`hooked`, V5). */
export declare const storedRequestJson: (request: ProviderCallRequest) => string;
export declare function parseStoredRequest(json: string): ProviderCallRequest;
export interface StoredRequest {
readonly requestJson: string;
readonly hooksApplied: boolean;
}
export interface DispatchPlan extends StoredRequest {
readonly hooks: "enabled" | "disabled";
}
export type RequestHookRunner = (hand: DeviceId, request: ProviderCallRequest) => Promise<ProviderCallRequest>;
/**
* The hook rules of 4.5: to the hand, `hooks` is `enabled` exactly when the stored request does not carry them yet;
* to any other server, a request-hooked provider without applied hooks runs them on the hand first and stores the
* post-hook request with `hooksApplied: true`; everything else goes with `hooks: "disabled"`.
*/
export declare function planDispatch(decision: EgressRouteDecision, stored: StoredRequest, runRequestHooks: RequestHookRunner): Promise<DispatchPlan>;
/** The terminal message the loop receives when the hand refused or failed the call, or the step was aborted. */
export declare function failureMessage(model: Model<Api>, stopReason: "error" | "aborted", errorMessage: string, usage?: Usage): AssistantMessage;
export declare const ABORT_TEXT = "Request was aborted";
export declare const idleTimeoutText: (idleMs: number) => string;
//# sourceMappingURL=device-proxy-request.d.ts.map