email view

This commit is contained in:
Arjun 2026-05-13 12:36:37 +05:30
parent e4244a8ce5
commit 296f7c75b7
7 changed files with 1065 additions and 47 deletions

View file

@ -31,6 +31,15 @@ export interface GmailThreadSnapshot {
date?: string;
latest_email?: string;
past_summary?: string;
messages: Array<{
id?: string;
from?: string;
to?: string;
cc?: string;
date?: string;
subject?: string;
body?: string;
}>;
}
function summarizeGmailSync(threads: SyncedThread[]): string {
@ -158,8 +167,10 @@ export async function fetchThreadSnapshot(threadId: string): Promise<GmailThread
const parsed = messages.map((msg) => {
const headers = msg.payload?.headers || [];
return {
id: msg.id || undefined,
from: headerValue(headers, 'From') || 'Unknown',
to: headerValue(headers, 'To'),
cc: headerValue(headers, 'Cc'),
date: headerValue(headers, 'Date'),
subject: headerValue(headers, 'Subject') || '(No Subject)',
body: msg.payload ? normalizeBody(getBody(msg.payload)) : '',
@ -186,6 +197,7 @@ export async function fetchThreadSnapshot(threadId: string): Promise<GmailThread
date: latest.date,
latest_email: latest.body,
past_summary: earlierSummary || undefined,
messages: parsed,
};
}

View file

@ -102,6 +102,26 @@ export const EmailBlockSchema = z.object({
export type EmailBlock = z.infer<typeof EmailBlockSchema>;
export const GmailThreadMessageSchema = z.object({
id: z.string().optional(),
from: z.string().optional(),
to: z.string().optional(),
cc: z.string().optional(),
date: z.string().optional(),
subject: z.string().optional(),
body: z.string().optional(),
});
export type GmailThreadMessage = z.infer<typeof GmailThreadMessageSchema>;
export const GmailThreadSchema = EmailBlockSchema.extend({
threadId: z.string(),
threadUrl: z.string().url(),
messages: z.array(GmailThreadMessageSchema),
});
export type GmailThread = z.infer<typeof GmailThreadSchema>;
export const EmailsBlockSchema = z.object({
title: z.string().optional(),
emails: z.array(EmailBlockSchema),

View file

@ -17,7 +17,7 @@ import { UserMessageContent } from './message.js';
import { RowboatApiConfig } from './rowboat-account.js';
import { ZListToolkitsResponse } from './composio.js';
import { BrowserStateSchema } from './browser-control.js';
import { EmailBlockSchema } from './blocks.js';
import { GmailThreadSchema } from './blocks.js';
// ============================================================================
// Runtime Validation Schemas (Single Source of Truth)
@ -128,7 +128,7 @@ const ipcSchemas = {
threadId: z.string().min(1),
}),
res: z.object({
thread: EmailBlockSchema.nullable(),
thread: GmailThreadSchema.nullable(),
error: z.string().optional(),
}),
},