@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
56 lines • 2.47 kB
TypeScript
/**
* The spec requests of one session's jobs: decides when a job is due (`request-policy.ts`), sends
* the redacted request to the injected author, validates the answer with a dry run, retries once
* with the errors, and enforces the session's in-flight and hourly caps. No I/O of its own: the
* clock, the author and the line matcher are injected.
* Ported from oh-my-pi 9df0457b31 `job-widgets/registry.ts` (MIT, Copyright Can Boluk et al.).
*/
import { type JobWidgetObfuscator } from "./author-redact.ts";
import type { JobWidgetAuthor } from "./author-types.ts";
import type { LineMatcher } from "./matcher.ts";
import { type JobWidgetRequestJob, type JobWidgetRequestLimits } from "./request-policy.ts";
import type { JobWidgetSpec } from "./spec-types.ts";
export type JobWidgetRequestOutcome = {
readonly kind: "installed";
readonly spec: JobWidgetSpec;
} | {
readonly kind: "skipped";
readonly reason: string;
}
/** Invalid twice (or once with no request left for the retry); without a spec in place the job falls back. */
| {
readonly kind: "rejected";
readonly errors: readonly string[];
}
/**
* The author has no model: the call is not counted against the job or the hourly cap, and the
* session asks again once {@link JobWidgetRequestLimits.noModelRetryMs} has passed.
*/
| {
readonly kind: "unavailable";
} | {
readonly kind: "failed";
readonly error: unknown;
} | {
readonly kind: "aborted";
};
export interface JobWidgetRequestControllerOptions {
readonly author: JobWidgetAuthor;
readonly matcher: LineMatcher;
readonly now?: () => number;
readonly limits?: Partial<JobWidgetRequestLimits>;
/** The session's secret obfuscation, run before the built-in redaction. */
readonly obfuscate?: JobWidgetObfuscator;
}
export declare class JobWidgetRequestController {
#private;
constructor(options: JobWidgetRequestControllerOptions);
/** Settings re-read on a re-bind: they apply from the next request on; caps already spent stay spent. */
configure(options: Pick<JobWidgetRequestControllerOptions, "limits" | "obfuscate">): void;
get inFlight(): number;
/** Starts the request `job` is due, or returns `undefined` when none is (or a session cap holds it back). */
maybeRequest(job: JobWidgetRequestJob): Promise<JobWidgetRequestOutcome> | undefined;
forget(jobId: string): void;
dispose(): void;
}
//# sourceMappingURL=request-controller.d.ts.map