@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
42 lines • 2.54 kB
TypeScript
/**
* A {@link JobWidgetAuthor} backed by one model: a single one-shot request with the respond tool
* forced where the wire allows it, reasoning off and output capped. The model and the completion
* function are injected, so nothing here reaches a network on its own and tests use fixed outputs.
* Ported from oh-my-pi 9df0457b31 `job-widgets/author.ts` (MIT, Copyright Can Boluk et al.).
*/
import type { Api, AssistantMessage, Context, Model, SimpleStreamOptions } from "@earendil-works/pi-ai/compat";
import type { JobWidgetAuthor } from "./author-types.ts";
/** Output cap of a spec request: the largest valid spec stays well under it, a runaway answer does not. */
export declare const MAX_SPEC_TOKENS = 3000;
export type JobWidgetComplete = (model: Model<Api>, context: Context, options: SimpleStreamOptions) => Promise<AssistantMessage>;
export type JobWidgetModelResolver = () => Model<Api> | undefined;
export interface JobWidgetModelSources {
/** The explicit `jobWidgets.model` setting. */
readonly setting?: JobWidgetModelResolver;
/** A host-injected route to a cheap model (omo: its `quick` category). */
readonly host?: JobWidgetModelResolver;
readonly session?: JobWidgetModelResolver;
}
/**
* Model resolution order: the explicit setting, then the host-injected resolver, then the
* session's current model. The first that yields a model wins; none means no request is made.
*/
export declare function jobWidgetModelResolver(sources: JobWidgetModelSources): JobWidgetModelResolver;
export interface ModelJobWidgetAuthorOptions {
readonly resolveModel: JobWidgetModelResolver;
/** Defaults to `completeSimple`; a host wraps it to add the session's credentials. */
readonly complete?: JobWidgetComplete;
}
export declare class JobWidgetAuthorError extends Error {
readonly stopReason: AssistantMessage["stopReason"];
constructor(message: string, stopReason: AssistantMessage["stopReason"]);
}
/**
* The payload with `tool_choice` naming `respond`, or `undefined` to leave it as is: the model must
* accept a named choice, the payload must carry none of its own, and Anthropic extended thinking
* (which rejects forced tool use) must be off. Elsewhere the prompt asks for the call and a JSON
* text answer is parsed instead.
*/
export declare function forceRespondChoice(payload: unknown, model: Model<Api>): unknown;
export declare function createModelJobWidgetAuthor(options: ModelJobWidgetAuthorOptions): JobWidgetAuthor;
//# sourceMappingURL=model-author.d.ts.map