fix(sdk): add AgentErrorEvent to StreamPayload type

StreamPayload.event was missing the agent_error event type, causing
TypeScript errors in useGatewayChat and useLocalChat where the
comparison payload.event.type === "agent_error" had no type overlap.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Naiyuan Qing 2026-02-09 08:04:13 +08:00
parent 56ebe613db
commit 1819f4196d
2 changed files with 10 additions and 3 deletions

View file

@ -38,6 +38,7 @@ export {
type CompactionEvent,
type CompactionStartEvent,
type CompactionEndEvent,
type AgentErrorEvent,
type ContentBlock,
type TextContent,
type ThinkingContent,

View file

@ -45,16 +45,22 @@ export type CompactionEndEvent = {
/** Union of all compaction events */
export type CompactionEvent = CompactionStartEvent | CompactionEndEvent;
/** Emitted when the agent encounters an error (LLM failure, quota exceeded, etc.) */
export type AgentErrorEvent = {
type: "agent_error";
error: string;
};
// --- Stream event types ---
/**
* Hub forwards AgentEvent from pi-agent-core and CompactionEvent as-is.
* StreamPayload wraps them with routing metadata.
* Hub forwards AgentEvent from pi-agent-core, CompactionEvent,
* and AgentErrorEvent as-is. StreamPayload wraps them with routing metadata.
*/
export interface StreamPayload {
streamId: string;
agentId: string;
event: AgentEvent | CompactionEvent;
event: AgentEvent | CompactionEvent | AgentErrorEvent;
}
/** Extract thinking/reasoning content from an AgentEvent that carries a message */