2026-09-30 21:34:53 +00:00
|
|
|
/**
|
|
|
|
|
* Shared Giellie types (server + client). Message blocks follow the
|
|
|
|
|
* Anthropic content-block shape but are kept loose (`Block`) because
|
|
|
|
|
* MiniMax also returns `thinking` blocks that must round-trip untouched.
|
|
|
|
|
*/
|
|
|
|
|
export type Block = { type: string; [key: string]: unknown };
|
|
|
|
|
|
2026-09-30 22:36:54 +00:00
|
|
|
/** Synthetic tool_result text when a tool_use has no recorded result. */
|
|
|
|
|
export const RESULT_UNAVAILABLE_TEXT =
|
|
|
|
|
"Result unavailable — this action may or may not have executed. Verify the current state (read the record) before retrying.";
|
|
|
|
|
|
2026-09-30 21:34:53 +00:00
|
|
|
export interface StoredMessage {
|
|
|
|
|
role: "user" | "assistant";
|
|
|
|
|
content: Block[];
|
|
|
|
|
ts: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PendingToolUse {
|
|
|
|
|
id: string;
|
|
|
|
|
/** Dotted MCP name, e.g. `orders.update`. */
|
|
|
|
|
name: string;
|
|
|
|
|
input: Record<string, unknown>;
|
2026-09-30 22:36:54 +00:00
|
|
|
/** Sends, cancels/merges and contact-detail changes — the trust toggle never auto-approves these. */
|
2026-09-30 21:34:53 +00:00
|
|
|
confirmAlways: boolean;
|
2026-09-30 22:36:54 +00:00
|
|
|
/** Why this always asks (badge text). Absent on rows saved before it existed. */
|
|
|
|
|
confirmReason?: string;
|
2026-09-30 21:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PendingAction {
|
|
|
|
|
tool_uses: PendingToolUse[];
|
|
|
|
|
/** tool_result blocks already produced this turn (read tools). */
|
|
|
|
|
completed: Block[];
|
|
|
|
|
/** Every tool_use id of the assistant turn, in original order. */
|
|
|
|
|
order: string[];
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-30 22:36:54 +00:00
|
|
|
/**
|
|
|
|
|
* Identifies which pending approval a decision is for. Client and server
|
|
|
|
|
* compare it so a stale tab cannot approve a newer, different request.
|
|
|
|
|
*/
|
|
|
|
|
export function pendingFingerprint(p: PendingAction): string {
|
|
|
|
|
return p.order.join(",");
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-30 21:34:53 +00:00
|
|
|
export interface GielieChatSummary {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
updated: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface GielieChat extends GielieChatSummary {
|
|
|
|
|
messages: StoredMessage[];
|
|
|
|
|
pending_action: PendingAction | null;
|
|
|
|
|
attachments: string[];
|
|
|
|
|
}
|