Add get_messages RPC command

This commit is contained in:
Mario Zechner 2025-12-09 14:35:09 +01:00
parent 2b0aa5ed8e
commit 3c8ab0280e
3 changed files with 25 additions and 3 deletions

View file

@ -6,7 +6,7 @@
import { type ChildProcess, spawn } from "node:child_process";
import * as readline from "node:readline";
import type { AgentEvent, Attachment, ThinkingLevel } from "@mariozechner/pi-agent-core";
import type { AgentEvent, AppMessage, Attachment, ThinkingLevel } from "@mariozechner/pi-agent-core";
import type { CompactionResult, SessionStats } from "../../core/agent-session.js";
import type { BashResult } from "../../core/bash-executor.js";
import type { RpcCommand, RpcResponse, RpcSessionState } from "./rpc-types.js";
@ -326,6 +326,14 @@ export class RpcClient {
return this.getData<{ text: string | null }>(response).text;
}
/**
* Get all messages in the session.
*/
async getMessages(): Promise<AppMessage[]> {
const response = await this.send({ type: "get_messages" });
return this.getData<{ messages: AppMessage[] }>(response).messages;
}
// =========================================================================
// Helpers
// =========================================================================