WIP preserve large chat history recovery

This commit is contained in:
2026-10-18 15:03:18 +01:00
parent f91145001a
commit 998da0e7af
21 changed files with 1088 additions and 75 deletions
+15
View File
@@ -193,6 +193,18 @@ type ChatAdoptRequest struct {
type ChatQuery struct {
SessionID string `json:"session_id"`
Limit int `json:"limit,omitempty"`
// Cursor is the opaque continuation returned by OpenCode's descending
// message listing. It is deliberately not interpreted by the broker.
Cursor string `json:"cursor,omitempty"`
}
// ChatHistoryPage describes the bounded slice returned by chat_messages. The
// newest page has an empty Cursor request; NextCursor remains opaque and is
// supplied unchanged to fetch older turns.
type ChatHistoryPage struct {
Messages []ChatMessage `json:"messages"`
NextCursor string `json:"next_cursor,omitempty"`
HasMore bool `json:"has_more,omitempty"`
}
// ChatPromptRequest is the chat_prompt request body: the text to send, with an
@@ -266,6 +278,9 @@ type ChatToolState struct {
Content []ChatToolContent `json:"content,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Error *ChatError `json:"error,omitempty"`
// Truncated says Content is a bounded preview of a larger stored result.
// The turn remains usable; callers must not present the preview as complete.
Truncated bool `json:"truncated,omitempty"`
}
// ChatToolContent is one returned tool result: either text or a file/uri pair
+1
View File
@@ -169,6 +169,7 @@ type Message struct {
ChatQuery *ChatQuery `json:"chat_query,omitempty"`
ChatPrompt *ChatPromptRequest `json:"chat_prompt,omitempty"`
ChatMessages []ChatMessage `json:"chat_messages,omitempty"`
ChatHistory *ChatHistoryPage `json:"chat_history,omitempty"`
ChatEvent *ChatEventFrame `json:"chat_event,omitempty"`
ChatPermission *ChatPermissionFrame `json:"chat_permission,omitempty"`
ChatReply *ChatReplyRequest `json:"chat_reply,omitempty"`