@kepoai/provider 1.0.7 → 1.0.9

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.
Files changed (2) hide show
  1. package/api/index.d.ts +83 -12
  2. package/package.json +2 -2
package/api/index.d.ts CHANGED
@@ -48,6 +48,24 @@ export interface OptionEvent {
48
48
  currentTarget: Options
49
49
  }
50
50
 
51
+ // 配置事件成功结果结构
52
+ export interface OptionEventSuccessResult {
53
+ success: true
54
+ data?: unknown
55
+ }
56
+
57
+ // 配置事件失败结果结构
58
+ export interface OptionEventFailureResult {
59
+ success: false
60
+ error: string
61
+ }
62
+
63
+ // 配置事件允许返回的结果类型
64
+ export type OptionEventResult = void | OptionEventSuccessResult | OptionEventFailureResult
65
+
66
+ // 配置事件处理函数签名
67
+ export type OptionEventHandler = (e: OptionEvent) => Promise<OptionEventResult> | OptionEventResult
68
+
51
69
  // 配置选项基础结构
52
70
  interface OptionBase<T> {
53
71
  key: string
@@ -64,10 +82,10 @@ interface OptionBase<T> {
64
82
  export interface InputOption extends OptionBase<string> {
65
83
  type: 'input';
66
84
  event?: { // 事件结构
67
- onLoad?: (e: OptionEvent) => void; // 加载事件
68
- onChange?: (e: OptionEvent) => void; // 改变事件
69
- onFocus?: (e: OptionEvent) => void; // 聚焦事件
70
- onBlur?: (e: OptionEvent) => void; // 失焦事件
85
+ onLoad?: OptionEventHandler; // 加载事件
86
+ onChange?: OptionEventHandler; // 改变事件
87
+ onFocus?: OptionEventHandler; // 聚焦事件
88
+ onBlur?: OptionEventHandler; // 失焦事件
71
89
  }
72
90
  }
73
91
 
@@ -80,9 +98,9 @@ export interface SelectOption extends OptionBase<string[]> {
80
98
  multiple: boolean;
81
99
  search?: string,
82
100
  event?: {
83
- onLoad?: (e: OptionEvent) => void;
84
- onSearch?: (e: OptionEvent) => void;
85
- onChange?: (e: OptionEvent) => void;
101
+ onLoad?: OptionEventHandler;
102
+ onSearch?: OptionEventHandler;
103
+ onChange?: OptionEventHandler;
86
104
  }
87
105
  }
88
106
 
@@ -90,9 +108,9 @@ export interface SelectOption extends OptionBase<string[]> {
90
108
  export interface SwitchOption extends OptionBase<boolean> {
91
109
  type: 'switch';
92
110
  event?: {
93
- onLoad?: (e: OptionEvent) => void;
111
+ onLoad?: OptionEventHandler;
94
112
 
95
- onChange?: (e: OptionEvent) => void;
113
+ onChange?: OptionEventHandler;
96
114
  }
97
115
  }
98
116
 
@@ -100,8 +118,8 @@ export interface SwitchOption extends OptionBase<boolean> {
100
118
  export interface ButtonOption extends OptionBase<string> {
101
119
  type: 'button';
102
120
  event: ?{
103
- onLoad?: (e: OptionEvent) => void;
104
- onClick: (e: OptionEvent) => void;
121
+ onLoad?: OptionEventHandler;
122
+ onClick: OptionEventHandler;
105
123
  }
106
124
  }
107
125
 
@@ -139,14 +157,68 @@ export interface EventProps {
139
157
  size: size;
140
158
  }
141
159
 
160
+ export interface PopupLayerEventProps {
161
+ event: 'popupLayer:opened' | 'popupLayer:closed';
162
+ popupLayerId: string;
163
+ type: 'browser' | 'custom';
164
+ source: 'widget' | 'panel';
165
+ widgetId?: string;
166
+ panelRequestId?: string;
167
+ }
168
+
169
+ export interface PopupLayerOpenedEventProps extends PopupLayerEventProps {
170
+ event: 'popupLayer:opened';
171
+ }
172
+
173
+ export interface PopupLayerClosedEventProps extends PopupLayerEventProps {
174
+ event: 'popupLayer:closed';
175
+ reason: 'user-close' | 'completed' | 'cancelled' | 'host-reset';
176
+ }
177
+
142
178
  // 系统事件类型
143
179
  export interface Events {
144
180
  onScheduled: (props: EventProps) => void; // 定时任务事件
145
181
  onCreated?: (props: EventProps) => void; // 创建事件
146
182
  onShow?: (props: EventProps) => void; // 显示事件
147
183
  onHide?: (props: EventProps) => void; // 隐藏事件
184
+ onPopupLayerOpened?: (props: PopupLayerOpenedEventProps) => void; // 弹出层打开完成事件
185
+ onPopupLayerClosed?: (props: PopupLayerClosedEventProps) => void; // 弹出层关闭完成事件
186
+ }
187
+
188
+ // 简化请求查询参数值
189
+ export type SimpleFetchQueryValue = string | number | boolean | null | undefined
190
+
191
+ // 简化请求选项
192
+ export interface SimpleFetchOptions {
193
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD'
194
+ baseURL?: string
195
+ query?: Record<string, SimpleFetchQueryValue>
196
+ params?: Record<string, SimpleFetchQueryValue>
197
+ headers?: Record<string, string>
198
+ body?: string | Record<string, unknown> | ArrayBuffer | Uint8Array
199
+ responseType?: 'json' | 'text' | 'arrayBuffer'
200
+ timeout?: number
201
+ ignoreResponseError?: boolean
148
202
  }
149
203
 
204
+ // 简化请求 raw 返回结构
205
+ export interface SimpleFetchRawResponse<T> {
206
+ status: number
207
+ statusText: string
208
+ ok: boolean
209
+ url: string
210
+ headers: Record<string, string>
211
+ data: T
212
+ }
213
+
214
+ // Build Mode / Provider 专用的会话感知简化请求能力
215
+ export interface SimpleFetch {
216
+ <T = unknown>(url: string, options?: SimpleFetchOptions): Promise<T>
217
+ raw<T = unknown>(url: string, options?: SimpleFetchOptions): Promise<SimpleFetchRawResponse<T>>
218
+ }
219
+
220
+ export const $fetch: SimpleFetch
221
+
150
222
  // AI 消息结构
151
223
  export interface AiMessage {
152
224
  role: 'system' | 'user' | 'assistant'
@@ -178,7 +250,6 @@ export interface AiCompleteResult {
178
250
  text: string
179
251
  usage: AiUsage
180
252
  quota: AiQuotaSnapshot
181
- model: string
182
253
  source: string
183
254
  requestId: string
184
255
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kepoai/provider",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "files": [
6
6
  "api"
@@ -21,6 +21,6 @@
21
21
  "@types/uuid": "^9.0.7",
22
22
  "puppeteer-core": "^22.4.1",
23
23
  "typescript": "^5.3.3",
24
- "@kepoai/types": "^0.0.11"
24
+ "@kepoai/types": "^0.0.12"
25
25
  }
26
26
  }