@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
42 lines • 3.05 kB
TypeScript
import type { Api, Model } from "@earendil-works/pi-ai";
import type { SessionEntry } from "../../../session-manager.ts";
import type { TodoFirstTurnPlan } from "../../../settings-shapes.ts";
import type { BeforeAgentStartEvent, ExtensionMode } from "../../types.ts";
export declare const FIRST_TURN_CUSTOM_TYPE = "senpi.todo-first-turn";
export declare const FIRST_TURN_REMINDER = "<system-reminder>\nThis is the first request of the session. Before continuing, call the todo tool with op \"init\" and a phased list covering the whole request end to end, with only the phases this request needs - a question is one task, and its reply is the answer itself, with no handoff block. Give every task a unique 5-10 word label; phase names are short noun phrases. Then continue the request in this same turn - the init is not a turn by itself.\n</system-reminder>";
export type FirstTurnGateInput = {
preview: boolean | undefined;
trigger: BeforeAgentStartEvent["trigger"];
prompt: string;
branchEntries: readonly SessionEntry[];
todoActive: boolean;
setting: TodoFirstTurnPlan;
mode: ExtensionMode;
};
/**
* Arms the first-turn plan opener only for a session's first work request, whether it is a prompt or
* a session-control delivery: never in a preview, never on another extension-triggered turn
* (senpi#2137), never once any request is on the branch (`before_agent_start` fires before the
* current one is persisted), never for a question or an exclamation, and never in print/json runs.
* An ask-user answer frame is a reply to a question asked on an earlier turn, not a request
* (senpi#2419): it never arms, and an earlier prompt or delivery answer on the branch does not count
* as the first request. Before the first request a list can only come from an extension-triggered
* turn, so an existing list does not block the first request.
*/
export declare function shouldArmFirstTurn(input: FirstTurnGateInput): boolean;
/**
* Whether the request wire can name one tool in `tool_choice`: the model declares it can (Anthropic
* reads the RESOLVED compat, since catalog models carry no `compat` and the resolver applies the
* Fable / Mythos / Opus 5.5 forced-choice default; OpenAI reads `compat.supportsForcedToolChoice`)
* and has not refused a forced choice earlier in this process (senpi#2218).
*/
export declare function supportsNamedToolChoice(model: Model<Api> | undefined): boolean;
/** Wire shape of a `tool_choice` that forces `toolName`, or `undefined` for an unsupported api. */
export declare function namedToolChoicePayload(api: Api | undefined, toolName: string): Record<string, unknown> | undefined;
/**
* The payload with a forced `todo` tool_choice, or `undefined` to leave it untouched: the
* request must declare `todo`, carry no tool_choice of its own, and (Anthropic) not run
* extended thinking, which rejects any forced tool use.
*/
export declare function withForcedTodoChoice(payload: unknown, model: Model<Api> | undefined): unknown;
//# sourceMappingURL=first-turn.d.ts.map