@codehz/ai 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,8 @@
7
7
  */
8
8
 
9
9
  import type { ContentBlock } from "./content.js";
10
- import type { MessageItem, ReasoningItem, ToolCallItem } from "./items.js";
11
- import type { AIResponse, Usage, BillingInfo, AuxiliaryInfo } from "./response.js";
10
+ import type { Usage, BillingInfo, AuxiliaryInfo, BackendTrace, StopReason } from "./response.js";
11
+ import type { OpaqueItem, ReplayItem } from "./items.js";
12
12
 
13
13
  // ── 事件基类 ──────────────────────────────────────────────────
14
14
 
@@ -45,7 +45,14 @@ export type ResponseAuxiliaryEvent = StreamEventBase & {
45
45
 
46
46
  export type ResponseCompletedEvent = StreamEventBase & {
47
47
  type: "response.completed";
48
- response: AIResponse;
48
+ replay: ReplayItem[];
49
+ stopReason?: StopReason;
50
+ usage?: Usage;
51
+ billing?: BillingInfo;
52
+ auxiliary?: AuxiliaryInfo;
53
+ warnings?: string[];
54
+ opaqueOutput?: OpaqueItem[];
55
+ trace?: Partial<BackendTrace>;
49
56
  };
50
57
 
51
58
  // ── 消息流事件 ────────────────────────────────────────────────
@@ -61,15 +68,12 @@ export type MessageStartedEvent = StreamEventBase & {
61
68
  export type MessageDeltaEvent = StreamEventBase & {
62
69
  type: "message.delta";
63
70
  itemId: string;
64
- delta: {
65
- type: "text";
66
- text: string;
67
- };
71
+ delta: ContentBlock;
68
72
  };
69
73
 
70
74
  export type MessageCompletedEvent = StreamEventBase & {
71
75
  type: "message.completed";
72
- item: MessageItem;
76
+ itemId: string;
73
77
  };
74
78
 
75
79
  // ── 思维链流事件 ──────────────────────────────────────────────
@@ -90,7 +94,7 @@ export type ReasoningDeltaEvent = StreamEventBase & {
90
94
 
91
95
  export type ReasoningCompletedEvent = StreamEventBase & {
92
96
  type: "reasoning.completed";
93
- item: ReasoningItem;
97
+ itemId: string;
94
98
  };
95
99
 
96
100
  // ── 工具调用流事件 ────────────────────────────────────────────
@@ -113,7 +117,7 @@ export type ToolCallDeltaEvent = StreamEventBase & {
113
117
 
114
118
  export type ToolCallCompletedEvent = StreamEventBase & {
115
119
  type: "tool_call.completed";
116
- item: ToolCallItem;
120
+ itemId: string;
117
121
  };
118
122
 
119
123
  // ── 统一事件联合 ──────────────────────────────────────────────
@@ -46,4 +46,12 @@ export type {
46
46
  } from "./events.js";
47
47
 
48
48
  // Adapter 协议和 client 类型
49
- export type { BackendAdapter, FetchFn, NormalizedRequest, CreateAIClientOptions, AIClient } from "./adapter.js";
49
+ export type {
50
+ AdapterCapabilities,
51
+ StreamingCapability,
52
+ BackendAdapter,
53
+ FetchFn,
54
+ NormalizedRequest,
55
+ CreateAIClientOptions,
56
+ AIClient,
57
+ } from "./adapter.js";
@@ -24,7 +24,6 @@ export type Usage = {
24
24
  cachedInputTokens?: number;
25
25
  /** Tokens written to prompt cache (Anthropic cache_creation_input_tokens) */
26
26
  cacheWriteInputTokens?: number;
27
-
28
27
  };
29
28
 
30
29
  export type BillingInfo = {