@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
72 lines • 3.78 kB
TypeScript
import type { QuestionRequest, QuestionResponse } from "../../core/extensions/types.ts";
import type { RpcExtensionUIResponse } from "./rpc-types.ts";
import type { UiAnswerLedger } from "./ui-answer-ledger.ts";
/** Only a named grant-selection request takes the worker's grant-dialog routing path. */
export declare function isGrantSelectRequest(record: object): record is object & {
id: string;
};
/**
* An `extension_ui_response` carries two ids: `id`, the frame's own correlation id that its reply
* echoes, and `uiRequestId`, the extension UI request it answers. The short form every older client
* sends has no `uiRequestId`; its `id` names both. Hosts and terminal control endpoints read it here.
*/
export declare function answeredUiRequestId(frame: {
readonly id?: unknown;
readonly uiRequestId?: unknown;
}): string | undefined;
/**
* How a `question` answer settles, identically on a host and a terminal control endpoint: it reads
* `answers` and `comment` (a `value` or `confirmed` beside them belongs to the other dialogs and is
* ignored). A non-blank comment settles it `comment-submitted`, the status that carries the comment
* to the model; otherwise any answer settles it `answered`; neither leaves it unsettled
* (`question_incomplete`).
*/
export declare function settledQuestionStatus(answers: QuestionResponse["answers"], comment: string | undefined): "answered" | "comment-submitted" | undefined;
/** The questions an answer leaves without a selection or text, reported back to the model. */
export declare function unansweredQuestionIds(questions: QuestionRequest["questions"], answers: QuestionResponse["answers"]): string[];
export type ExtensionUiResponseReply = {
readonly id: string;
readonly type: "response";
readonly command: "extension_ui_response";
/** The answer's outcome for its request; absent when a malformed answer was refused before settling anything. */
readonly disposition?: "applied" | "replay" | "already_answered" | "unknown";
} & ({
readonly success: true;
} | {
readonly success: false;
readonly error: string;
});
type QuestionAnswers = {
respond(response: RpcExtensionUIResponse, beforeAnswer?: () => void): boolean | "question_incomplete" | "question_already_resolved";
};
type DialogAnswers = {
resolve(response: RpcExtensionUIResponse, beforeAnswer?: () => void): boolean;
};
/**
* Settles one response on a host connection and returns its reply, keyed by the frame `id`.
* `undefined` only on an unrouted (single-session stdio) connection for an unnamed response no
* request here matches: that connection has always ignored such a response, and still does. A named
* response (`answerId`) asks for a receipt, so every connection answers it.
*/
export declare function settleExtensionUiResponse(response: RpcExtensionUIResponse, targets: {
readonly questions: QuestionAnswers;
readonly dialogs: DialogAnswers;
readonly routed: boolean;
readonly ledger?: UiAnswerLedger;
readonly beforeAnswer?: () => void;
}): ExtensionUiResponseReply | undefined;
/** The one correlated reply to an `extension_ui_progress` record, keyed by its `id` (senpi#5761). */
export type ExtensionUiProgressReply = {
readonly id: string;
readonly type: "response";
readonly command: "extension_ui_progress";
} & ({
readonly success: true;
} | {
readonly success: false;
readonly error: string;
});
export declare function extensionUiProgressReply(id: string, outcome: "applied" | "question_already_resolved" | "unknown_extension_ui_request"): ExtensionUiProgressReply;
export declare function refusedExtensionUiResponse(id: string, error: string): ExtensionUiResponseReply;
export {};
//# sourceMappingURL=extension-ui-response.d.ts.map