feat: add the agent transcript client and hydrated turn and block types used to rehydrate a reopened assistant conversation

This commit is contained in:
Matthew Meszaros
2026-07-15 17:54:16 +02:00
parent a3e27c77da
commit 684152d699
2 changed files with 41 additions and 0 deletions
@@ -0,0 +1,14 @@
import type { AgentTranscript } from "@/lib/api/models/app/agent/Agent";
import Request from "../../Request";
// Loads a session's hydrated transcript so a reopened workspace tab rehydrates
// its conversation (and any pending approval) from the server.
export default async function getAgentMessages(
sessionId: string,
): Promise<AgentTranscript> {
return await Request<AgentTranscript>({
method: "GET",
url: `/ai/sessions/${sessionId}/messages`,
authorization: true,
});
}
+27
View File
@@ -27,6 +27,33 @@ export interface AgentSessionsPage {
pagination: { next_cursor: string | null; has_more: boolean };
}
// A persisted transcript block, hydrated server-side into the same shape the
// live stream renders (see internal/app/aiagent HydratedBlock).
export interface AgentHydratedBlock {
kind: "text" | "tool";
text?: string;
tool?: string;
args_summary?: string;
result?: string;
entity_type?: string;
entity_id?: string;
open_url?: string;
done: boolean;
}
export interface AgentHydratedTurn {
role: "user" | "assistant";
blocks: AgentHydratedBlock[];
}
// GET /ai/sessions/:id/messages — a reopened session's history + any pending
// approval, so a tab rehydrates identically to a live run.
export interface AgentTranscript {
title: string;
turns: AgentHydratedTurn[];
pending: PendingAgentTool | null;
}
// AgentStreamEvent is one SSE step from a message/approval run.
export interface AgentStreamEvent {
type: