@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
64 lines • 3.87 kB
TypeScript
import type { AgentTool } from "@earendil-works/pi-agent-core";
import { type ReadFolder } from "@earendil-works/pi-agent-core/read-folders";
import type { ModelImageResizeOptions } from "@earendil-works/pi-ai";
import { type Static, Type } from "typebox";
import type { ProcessImageOptions, ProcessImageResult } from "../../utils/image-process.ts";
import type { FilesystemPolicyChecker, ToolDefinition } from "../extensions/types.ts";
import { type ToolPathCanonicalizer } from "./file-tool-host.ts";
import type { ToolMachine } from "./tool-machine.ts";
import { type ReadToolDetails } from "./read-text.ts";
declare const readSchema: Type.TObject<{
path: Type.TString;
offset: Type.TOptional<Type.TNumber>;
limit: Type.TOptional<Type.TNumber>;
}>;
export declare const readToolSystemPromptContribution: {
readonly snippet: "Read file contents";
readonly guidelines: readonly ["Files: read, not cat/sed."];
readonly fullGuidelines: readonly ["Use read to examine files instead of cat or sed."];
};
export type ReadToolInput = Static<typeof readSchema>;
export type { ReadToolDetails } from "./read-text.ts";
/**
* Pluggable operations for the read tool.
* Override these to delegate file reading to remote systems (for example SSH).
*/
export interface ReadOperations {
/** Read file contents */
readFile: (absolutePath: string) => Promise<Uint8Array>;
/** Check if file is readable (throw if not) */
access: (absolutePath: string) => Promise<void>;
/** Detect image MIME type, return null or undefined for non-images */
detectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;
}
/** Turns an image file's bytes into the inline image the model receives, or a note why it cannot. */
export type ReadImageProcessor = (bytes: Uint8Array, mimeType: string, options: ProcessImageOptions) => Promise<ProcessImageResult>;
export interface CoreReadToolOptions {
/** Operation layer and policy gate. */
machine: ToolMachine;
/** Structural folder. Default options select the measured folder; omit here for verbatim reads. */
folder?: ReadFolder;
/** Whether to auto-resize images. Default: true */
autoResizeImages?: boolean;
/** Fallback resize profile when the execution context has no model metadata. */
resizeOptions?: ModelImageResizeOptions;
/** Read the model from the execution context. False for a runtime without a session, whose context refuses `model` (senpi#5223). Default: true */
contextModel?: boolean;
/** Custom operations for file reading. Default: reads through `machine` */
operations?: ReadOperations;
/** Extension-registered filesystem policy checker. */
filesystemPolicy?: FilesystemPolicyChecker;
/** Resolves the model's path, trying spelling variants. Default: POSIX resolution, variants probed on `machine`. */
resolveReadPath?: (path: string, cwd: string) => Promise<string>;
/** The path `filesystemPolicy` judges. Default: the resolved path as is. */
canonicalizePath?: ToolPathCanonicalizer;
/** Image detection for the default operations. Default: the file's leading bytes read on `machine`. */
detectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;
/** Default: inline PNG, JPEG, GIF and WebP as they are; other formats are omitted with a note. */
processImage?: ReadImageProcessor;
}
export declare function createCoreReadToolDefinition(cwd: string, options: CoreReadToolOptions): ToolDefinition<typeof readSchema, ReadToolDetails | undefined>;
/** The read tool for a host whose only effect channel is `machine`; reads fold like the local tool's by default. */
export declare function createCoreReadTool(cwd: string, options: CoreReadToolOptions): AgentTool<typeof readSchema>;
export { readSchema };
//# sourceMappingURL=read-core.d.ts.map