sync: Agent Architecture Overhaul - AI SDK 6 + workflow optimization

Synced from private repo (feature/ai-sdk-6-upgrade):
- Upgrade AI SDK 5 → 6 (packages + API changes)
- Add sqliteQuery tool for flexible read-only queries
- New WorkflowExecutor with workflow-specific tools
- 83% token reduction for workflow execution
- Remove mini-rah dead code (simplified architecture)
- Add context management usage endpoint
- Fix Connect workflow instructions
- Clickable node references in workflow UI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
“BeeRad”
2026-01-12 20:59:27 +11:00
co-authored by Claude Opus 4.5
parent f9271aeeb4
commit 3f0426ecf4
27 changed files with 3607 additions and 2279 deletions
+15 -1
View File
@@ -32,11 +32,17 @@ interface SendParams {
mode: 'easy' | 'hard';
}
interface UsageData {
inputTokens: number;
outputTokens: number;
}
interface UseSSEChatOptions {
getAuthToken?: () => string | null | undefined;
beforeRequest?: () => boolean;
onRequestError?: (error: unknown, response?: Response) => boolean | void;
onStreamComplete?: () => void | Promise<void>;
onUsageUpdate?: (usage: UsageData) => void;
}
export function useSSEChat(
@@ -44,7 +50,7 @@ export function useSSEChat(
setMessages: (updater: (prev: ChatMessage[]) => ChatMessage[]) => void,
options: UseSSEChatOptions = {}
) {
const { getAuthToken, beforeRequest, onRequestError, onStreamComplete } = options;
const { getAuthToken, beforeRequest, onRequestError, onStreamComplete, onUsageUpdate } = options;
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const abortControllerRef = useRef<AbortController | null>(null);
@@ -182,6 +188,14 @@ export function useSSEChat(
setMessages((prev) => [...prev, newAssistantMessage]);
}
}
// Capture usage data from finish event (if AI SDK sends it)
if (data.type === 'finish' && data.usage) {
onUsageUpdate?.({
inputTokens: data.usage.promptTokens ?? data.usage.inputTokens ?? 0,
outputTokens: data.usage.completionTokens ?? data.usage.outputTokens ?? 0
});
}
} catch {
// ignore malformed lines
}