@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
104 lines • 3.12 kB
TypeScript
export type CursorCliSystemInitEvent = {
type: "system";
subtype: "init";
session_id: string;
model: string;
apiKeySource: string;
permissionMode: string;
cwd: string;
};
export type CursorCliThinkingEvent = {
type: "thinking";
subtype: "delta" | "completed";
text: string;
};
export type CursorCliAssistantEvent = {
type: "assistant";
message: {
content: Array<{
type: "text";
text: string;
}>;
};
};
export type CursorCliToolSuccess = {
success: {
exitCode: number;
stdout: string;
stderr: string;
executionTime: number;
};
};
export type CursorCliToolRejection = {
rejected: {
command: string;
reason: string;
isReadonly: boolean;
};
};
export type CursorCliToolResult = CursorCliToolSuccess | CursorCliToolRejection;
export type CursorCliToolCallDetails = {
args?: Record<string, unknown>;
result?: CursorCliToolResult;
};
export type CursorCliToolCallEvent = {
type: "tool_call";
subtype: "started" | "completed";
call_id: string;
tool_call: Partial<Record<`${string}ToolCall`, CursorCliToolCallDetails>>;
};
export type CursorCliUsage = {
inputTokens: number;
outputTokens: number;
cacheReadTokens: number;
cacheWriteTokens: number;
};
export type CursorCliResultEvent = {
type: "result";
subtype: "success" | "error";
result: unknown;
usage: CursorCliUsage;
request_id: string;
duration_ms: number;
is_error: boolean;
};
export type CursorCliMalformedStreamReason = "invalid_json" | "invalid_event" | "line_overflow" | "truncated_tail" | "incomplete_stream";
export type CursorCliMalformedStreamEvent = {
type: "malformed_stream";
kind: "malformed_stream";
reason: CursorCliMalformedStreamReason;
message: string;
};
export type CursorCliStreamEvent = CursorCliSystemInitEvent | CursorCliThinkingEvent | CursorCliAssistantEvent | CursorCliToolCallEvent | CursorCliResultEvent | CursorCliMalformedStreamEvent;
export type CursorCliStreamParserOptions = {
maxPendingBytes?: number;
maxDiagnostics?: number;
maxDiagnosticCharacters?: number;
};
/** Incrementally parses cursor-agent's stream-json NDJSON stdout dialect. */
export declare class CursorCliStreamParser {
readonly maxPendingBytes: number;
readonly maxDiagnostics: number;
readonly maxDiagnosticCharacters: number;
private decoder;
private readonly byteCounter;
private pending;
private pendingBytes;
private discardingOverflowLine;
private finalized;
private sawResult;
private diagnosticsRing;
private unknownCount;
constructor(options?: CursorCliStreamParserOptions);
get diagnostics(): readonly string[];
get unknownEventCount(): number;
push(chunk: Uint8Array): CursorCliStreamEvent[];
finish(): CursorCliStreamEvent[];
reset(): void;
private consumeDecoded;
private appendPending;
private parseLine;
private recordDiagnostic;
private clearPending;
}
//# sourceMappingURL=stream-parser.d.ts.map