Files
openclaw/src/agents/types.ts
2025-12-02 11:08:00 +00:00

42 lines
946 B
TypeScript

export type AgentKind = "claude" | "opencode" | "pi" | "codex";
export type AgentMeta = {
model?: string;
provider?: string;
stopReason?: string;
usage?: {
input?: number;
output?: number;
cacheRead?: number;
cacheWrite?: number;
total?: number;
};
extra?: Record<string, unknown>;
};
export type AgentParseResult = {
text?: string;
mediaUrls?: string[];
meta?: AgentMeta;
};
export type BuildArgsContext = {
argv: string[];
bodyIndex: number; // index of prompt/body argument in argv
isNewSession: boolean;
sessionId?: string;
sendSystemOnce: boolean;
systemSent: boolean;
identityPrefix?: string;
format?: "text" | "json";
sessionArgNew?: string[];
sessionArgResume?: string[];
};
export interface AgentSpec {
kind: AgentKind;
isInvocation: (argv: string[]) => boolean;
buildArgs: (ctx: BuildArgsContext) => string[];
parseOutput: (rawStdout: string) => AgentParseResult;
}