@tbox-dev-js/sdk 0.1.0

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.
@@ -0,0 +1,1415 @@
1
+ /**
2
+ * 百宝箱插件服务 SDK - 类型定义
3
+ */
4
+ /**
5
+ * SDK 统一响应包装
6
+ */
7
+ export interface SdkResponse<T = unknown> {
8
+ /** 是否成功 */
9
+ success: boolean;
10
+ /** 响应数据 */
11
+ data?: T;
12
+ /** 错误码 */
13
+ errorCode?: string;
14
+ /** 错误信息 */
15
+ errorMsg?: string;
16
+ }
17
+ /**
18
+ * 文字转语音请求
19
+ */
20
+ export interface TtsRequest {
21
+ /** 用户输入文案(必填) */
22
+ tts_text: string;
23
+ }
24
+ /**
25
+ * 文字转语音响应
26
+ */
27
+ export interface TtsResponse {
28
+ /** Base64 编码的音频数据 */
29
+ base64Audio?: string;
30
+ }
31
+ /**
32
+ * 语音转文字请求(Base64 输入)
33
+ */
34
+ export interface AsrRequest {
35
+ /** Base64 编码后的音频数据(必填) */
36
+ base64_audio: string;
37
+ /** 音频格式,pcm、wav、mp3、mp4,默认 pcm */
38
+ audio_format?: string;
39
+ }
40
+ /**
41
+ * 语音转文字响应
42
+ */
43
+ export interface AsrResponse {
44
+ /** 识别出的文本 */
45
+ text?: string;
46
+ }
47
+ /**
48
+ * 插件工具执行请求
49
+ */
50
+ export interface PluginToolExecRequest {
51
+ /** 工具输入参数(key-value 形式,服务端字段名:params) */
52
+ params?: Record<string, unknown>;
53
+ /** 扩展参数 */
54
+ [key: string]: unknown;
55
+ }
56
+ /**
57
+ * 插件工具执行结果(run 方法返回的 data 字段)
58
+ *
59
+ * 对应服务端 Java 类:
60
+ * ```java
61
+ * private Boolean success;
62
+ * private Object result; // 工具实际输出,结构因工具而异
63
+ * private long cost;
64
+ * private String traceId;
65
+ * ```
66
+ */
67
+ export interface PluginExecResult {
68
+ /** 工具执行是否成功 */
69
+ success?: boolean;
70
+ /** 工具实际输出数据(结构因工具而异) */
71
+ result?: unknown;
72
+ /** 执行耗时(毫秒) */
73
+ cost?: number;
74
+ /** 链路追踪 ID */
75
+ traceId?: string;
76
+ }
77
+ /**
78
+ * 插件工具信息
79
+ */
80
+ export interface PluginToolInfo {
81
+ /** 工具 ID */
82
+ pluginToolId?: string;
83
+ /** 工具名称 */
84
+ name?: string;
85
+ /** 工具描述 */
86
+ description?: string;
87
+ /** 工具请求参数定义 */
88
+ toolInputParams?: Array<Record<string, unknown>>;
89
+ /** 工具响应参数定义 */
90
+ toolOutputParams?: Array<Record<string, unknown>>;
91
+ }
92
+ /**
93
+ * 插件信息(含工具集)
94
+ */
95
+ export interface PluginInfo {
96
+ /** 插件名称 */
97
+ name?: string;
98
+ /** 插件描述 */
99
+ description?: string;
100
+ /** 插件下的工具列表 */
101
+ pluginToolList?: PluginToolInfo[];
102
+ }
103
+ /**
104
+ * 分页查询结果
105
+ * 服务端实际返回字段:currentPage / data / pageSize / totalCount
106
+ */
107
+ export interface PaginationResult<T> {
108
+ /** 数据列表(服务端字段名:data) */
109
+ data?: T[];
110
+ /** 总条数(服务端字段名:totalCount) */
111
+ totalCount?: number;
112
+ /** 当前页码(服务端字段名:currentPage) */
113
+ currentPage?: number;
114
+ /** 每页条数 */
115
+ pageSize?: number;
116
+ }
117
+ /**
118
+ * 创建会话请求
119
+ */
120
+ export interface ConversationCreateRequest {
121
+ /** 百宝箱应用 ID(agentId) */
122
+ agentId: string;
123
+ /** 用户 ID */
124
+ userId: string;
125
+ }
126
+ /**
127
+ * 查询会话列表请求
128
+ */
129
+ export interface ConversationQueryRequest {
130
+ /** 百宝箱应用 ID */
131
+ agentId?: string;
132
+ /** 用户 ID */
133
+ userId?: string;
134
+ /** 来源渠道(可选,默认 openapi) */
135
+ fromSource?: string;
136
+ /** 页码,从 1 开始(可选) */
137
+ pageNum?: number;
138
+ /** 每页条数(可选) */
139
+ pageSize?: number;
140
+ /** 扩展参数 */
141
+ [key: string]: unknown;
142
+ }
143
+ /**
144
+ * 会话信息
145
+ * 服务端实际返回字段:id / appId / fromEndUserId / fromSource / gmtCreate
146
+ */
147
+ export interface ConversationInfo {
148
+ /** 会话 ID(服务端字段名:id) */
149
+ id?: string;
150
+ /** 应用 ID */
151
+ appId?: string;
152
+ /** 用户 ID(服务端字段名:fromEndUserId) */
153
+ fromEndUserId?: string;
154
+ /** 来源渠道 */
155
+ fromSource?: string;
156
+ /** 创建时间(字符串格式,如 "2026-04-09 23:26:18",服务端字段名:gmtCreate) */
157
+ gmtCreate?: string;
158
+ /** 扩展字段 */
159
+ [key: string]: unknown;
160
+ }
161
+ /**
162
+ * 查询消息列表请求
163
+ */
164
+ export interface MessageQueryRequest {
165
+ /** 会话 ID */
166
+ conversationId?: string;
167
+ /** 百宝箱应用 ID(必填,服务端校验非空) */
168
+ agentId: string;
169
+ /** 用户 ID */
170
+ userId?: string;
171
+ /** 来源渠道(可选,默认 openapi) */
172
+ fromSource?: string;
173
+ /** 游标,上页最后一条消息 ID,第一页不填(可选) */
174
+ beforeId?: string;
175
+ /** 页码,从 1 开始(可选,服务端字段名:pageNo) */
176
+ pageNo?: number;
177
+ /** 每页条数(可选) */
178
+ pageSize?: number;
179
+ }
180
+ /**
181
+ * 消息信息
182
+ */
183
+ export interface MessageInfo {
184
+ /** 消息 ID */
185
+ messageId?: string;
186
+ /** 会话 ID */
187
+ conversationId?: string;
188
+ /** 用户提问内容 */
189
+ query?: string;
190
+ /** AI 回答内容 */
191
+ answer?: string;
192
+ /** 媒体类型 */
193
+ mediaType?: string;
194
+ /** 生成状态 */
195
+ generateState?: string;
196
+ /** 外部业务 ID */
197
+ outerBusinessId?: string;
198
+ /** 创建时间(时间戳) */
199
+ createTime?: number;
200
+ /** 扩展字段 */
201
+ [key: string]: unknown;
202
+ }
203
+ /**
204
+ * 保存会话消息请求
205
+ */
206
+ export interface MessageSaveRequest {
207
+ /** 百宝箱应用 ID(必填,服务端鉴权需要) */
208
+ agentId: string;
209
+ /** 会话 ID */
210
+ conversationId: string;
211
+ /** 用户提问内容 */
212
+ query?: string;
213
+ /** AI 回答内容 */
214
+ answer?: string;
215
+ /** 媒体类型(可选) */
216
+ mediaType?: string;
217
+ /** 生成状态(可选) */
218
+ generateState?: string;
219
+ /** 外部业务 ID(可选) */
220
+ outerBusinessId?: string;
221
+ /** 输入参数(可选) */
222
+ inputs?: Record<string, unknown>;
223
+ /** 多模态输入(可选) */
224
+ multiModalInputs?: Record<string, unknown>;
225
+ /** 额外参数(可选,字符串格式) */
226
+ extraParams?: string;
227
+ }
228
+ /**
229
+ * 用户信息条目(key-value 形式)
230
+ */
231
+ export interface UserInfo {
232
+ /**
233
+ * 信息类型,枚举值如:name、phone、email 等
234
+ * 对应服务端 InfoTypeEnum
235
+ */
236
+ infoType: string;
237
+ /** 信息值 */
238
+ infoValue: string;
239
+ }
240
+ /**
241
+ * 设备信息
242
+ */
243
+ export interface DeviceInfo {
244
+ /**
245
+ * 产品类型,如 APP、MINI_PROGRAM 等
246
+ * 对应服务端 ProductTypeEnum
247
+ */
248
+ productType?: string;
249
+ /** 应用名称 */
250
+ appName?: string;
251
+ /** 应用版本号 */
252
+ appVersion?: string;
253
+ /**
254
+ * 系统平台,如 IOS、Android、HarmonyOS 等
255
+ * 对应服务端 DevicePlatformEnum
256
+ */
257
+ platform?: string;
258
+ /** 系统平台版本号,如 iOS 版本号 */
259
+ system?: string;
260
+ /** 设备 ID */
261
+ deviceId?: string;
262
+ /** 设备名称 */
263
+ deviceName?: string;
264
+ /** 设备型号 */
265
+ model?: string;
266
+ /** 设备品牌 */
267
+ brand?: string;
268
+ }
269
+ /**
270
+ * 生成 Session 请求
271
+ */
272
+ export interface AppGenerateSessionRequest {
273
+ /** 百宝箱应用 ID */
274
+ appId: string;
275
+ /** 用户 ID */
276
+ userId: string;
277
+ /** 请求来源(可选) */
278
+ source?: string;
279
+ /** 发布渠道(可选) */
280
+ fromSource?: string;
281
+ /** 请求的链接类型(可选) */
282
+ type?: string;
283
+ /** 用户信息列表(可选,用于传递用户扩展属性) */
284
+ userInfo?: UserInfo[];
285
+ /** 设备信息(可选) */
286
+ deviceInfo?: DeviceInfo;
287
+ }
288
+ /**
289
+ * 生成 Session 响应
290
+ */
291
+ export interface AppSessionResult {
292
+ /** 会话 ID,用于免登录访问百宝箱应用 */
293
+ sessionId?: string;
294
+ /** 登录渠道,固定值 third_platform_sdk_login */
295
+ channel?: string;
296
+ }
297
+ /**
298
+ * 网络搜索请求
299
+ */
300
+ export interface WebSearchRequest {
301
+ /** 搜索关键词(必填) */
302
+ q: string;
303
+ }
304
+ /**
305
+ * 搜索结果条目的扩展信息
306
+ */
307
+ export interface WebSearchItemExtra {
308
+ /** 条目的备用 URL */
309
+ extraUrl?: string;
310
+ /** 来源域名,如 quark */
311
+ domain?: string;
312
+ /** 排序序号 */
313
+ sort?: number;
314
+ /** 备用标题 */
315
+ extraTitle?: string;
316
+ }
317
+ /**
318
+ * 单条搜索结果
319
+ */
320
+ export interface WebSearchItem {
321
+ /** 文章 ID */
322
+ articleId?: string;
323
+ /** 标题 */
324
+ title?: string;
325
+ /** 摘要描述 */
326
+ desc?: string;
327
+ /** 原始 URL */
328
+ url?: string;
329
+ /** 发布时间(Unix 时间戳字符串) */
330
+ publishTime?: string;
331
+ /** 来源渠道,如 quark */
332
+ channel?: string;
333
+ /** 扩展信息 */
334
+ extra?: WebSearchItemExtra;
335
+ }
336
+ /**
337
+ * 网络搜索响应
338
+ */
339
+ export interface WebSearchResponse {
340
+ /** 搜索结果列表 */
341
+ items?: WebSearchItem[];
342
+ }
343
+ /**
344
+ * TboxPluginClient 初始化配置
345
+ */
346
+ export interface TboxPluginClientConfig {
347
+ /**
348
+ * API Key(Bearer Token),通过 Authorization 头传递。
349
+ * 格式:直接传 key 字符串,SDK 内部会自动拼接 "Bearer " 前缀。
350
+ */
351
+ apiKey: string;
352
+ /**
353
+ * 自定义 base URL(可选)。
354
+ * 默认为 https://o.tbox.cn
355
+ */
356
+ baseUrl?: string;
357
+ /**
358
+ * 请求超时时间(毫秒,可选)。
359
+ * 默认不设置超时。
360
+ */
361
+ timeout?: number;
362
+ }
363
+ /**
364
+ * AmapClient 初始化配置
365
+ */
366
+ export interface AmapClientConfig {
367
+ /**
368
+ * API Key(Bearer Token),通过 Authorization 头传递。
369
+ * 格式:直接传 key 字符串,SDK 内部会自动拼接 "Bearer " 前缀。
370
+ */
371
+ apiKey: string;
372
+ /**
373
+ * 自定义 base URL(可选)。
374
+ * 默认为 https://o.tbox.cn
375
+ */
376
+ baseUrl?: string;
377
+ /**
378
+ * 请求超时时间(毫秒,可选)。
379
+ * 默认不设置超时。
380
+ */
381
+ timeout?: number;
382
+ }
383
+ /**
384
+ * 高德天气查询请求
385
+ */
386
+ export interface AmapWeatherRequest {
387
+ /**
388
+ * 查询指定城市或地点的天气(必填)。
389
+ * 可输入:省份名(如:浙江省)、市名(如:杭州市)、区/县/镇(如:西湖区)、
390
+ * 乡/村(如:西湖区古荡新村)、地点(如:四川省成都市锦江区春熙路街道)
391
+ */
392
+ city: string;
393
+ /**
394
+ * 查询气象类型(可选)。
395
+ * base:查询实况天气(默认);all:查询预报天气
396
+ */
397
+ extensions?: string;
398
+ }
399
+ /**
400
+ * 实况天气数据
401
+ */
402
+ export interface AmapWeatherLive {
403
+ /** 省份名 */
404
+ province?: string;
405
+ /** 城市名 */
406
+ city?: string;
407
+ /** 区域编码 */
408
+ adcode?: string;
409
+ /** 实时气温,单位:摄氏度 */
410
+ temperature?: string;
411
+ /** 实时气温(浮点数),单位:摄氏度 */
412
+ temperature_float?: string;
413
+ /** 空气湿度 */
414
+ humidity?: string;
415
+ /** 空气湿度(浮点数) */
416
+ humidity_float?: string;
417
+ /** 风力级别,单位:级 */
418
+ windpower?: string;
419
+ /** 风向描述 */
420
+ winddirection?: string;
421
+ /** 天气现象(汉字描述) */
422
+ weather?: string;
423
+ /** 数据发布的时间 */
424
+ reporttime?: string;
425
+ }
426
+ /**
427
+ * 单日天气预报
428
+ */
429
+ export interface AmapWeatherForecastCast {
430
+ /** 日期 */
431
+ date?: string;
432
+ /** 星期几 */
433
+ week?: string;
434
+ /** 白天天气现象 */
435
+ dayweather?: string;
436
+ /** 白天温度 */
437
+ daytemp?: string;
438
+ /** 白天气温(浮点数) */
439
+ daytemp_float?: string;
440
+ /** 白天风向 */
441
+ daywind?: string;
442
+ /** 白天风力 */
443
+ daypower?: string;
444
+ /** 晚上天气现象 */
445
+ nightweather?: string;
446
+ /** 晚上温度 */
447
+ nighttemp?: string;
448
+ /** 晚上气温(浮点数) */
449
+ nighttemp_float?: string;
450
+ /** 晚上风向 */
451
+ nightwind?: string;
452
+ /** 晚上风力 */
453
+ nightpower?: string;
454
+ }
455
+ /**
456
+ * 预报城市天气信息
457
+ */
458
+ export interface AmapWeatherForecast {
459
+ /** 省份名 */
460
+ province?: string;
461
+ /** 城市名 */
462
+ city?: string;
463
+ /** 区域编码 */
464
+ adcode?: string;
465
+ /** 数据发布的时间 */
466
+ reporttime?: string;
467
+ /** 逐日预报列表 */
468
+ casts?: AmapWeatherForecastCast[];
469
+ }
470
+ /**
471
+ * 高德天气查询响应
472
+ */
473
+ export interface AmapWeatherResponse {
474
+ /** 返回状态,1:成功;0:失败 */
475
+ status?: string;
476
+ /** 返回的状态信息 */
477
+ info?: string;
478
+ /** 返回状态说明,10000 代表正确 */
479
+ infocode?: string;
480
+ /** 返回结果总数目 */
481
+ count?: string;
482
+ /** 响应状态码 */
483
+ code?: number;
484
+ /** 实况天气数据信息(extensions=base 时返回) */
485
+ lives?: AmapWeatherLive[];
486
+ /** 预报天气信息数据(extensions=all 时返回) */
487
+ forecasts?: AmapWeatherForecast[];
488
+ }
489
+ /**
490
+ * 高德地址转经纬度请求
491
+ */
492
+ export interface AmapGeocodeRequest {
493
+ /**
494
+ * 详细地址信息(必填)。
495
+ * 可输入:国家、省份、城市、区县、城镇、乡村、街道、门牌号
496
+ */
497
+ address: string;
498
+ /**
499
+ * 查询的城市(可选)。
500
+ * 指定查询的城市,可提高查询精度
501
+ */
502
+ city?: string;
503
+ }
504
+ /**
505
+ * 地理编码信息
506
+ */
507
+ export interface AmapGeocode {
508
+ /** 格式化地址 */
509
+ formatted_address?: string;
510
+ /** 省份 */
511
+ province?: string;
512
+ /** 城市 */
513
+ city?: string;
514
+ /** 区县 */
515
+ district?: string;
516
+ /** 经纬度坐标 */
517
+ location?: string;
518
+ /** 区域编码 */
519
+ adcode?: string;
520
+ /** 匹配级别 */
521
+ level?: string;
522
+ }
523
+ /**
524
+ * 高德地址转经纬度响应
525
+ */
526
+ export interface AmapGeocodeResponse {
527
+ /** 响应状态码 */
528
+ code?: number;
529
+ /** 返回状态,1:成功;0:失败 */
530
+ status?: string;
531
+ /** 错误码 */
532
+ infocode?: string;
533
+ /** 返回结果数目 */
534
+ count?: string;
535
+ /** 地理编码信息列表 */
536
+ geocodes?: AmapGeocode[];
537
+ }
538
+ /**
539
+ * 骑行路线规划请求
540
+ */
541
+ export interface AmapCyclingRouteRequest {
542
+ /** 起点位置名称(必填) */
543
+ origin: string;
544
+ /** 终点位置名称(必填) */
545
+ destination: string;
546
+ }
547
+ /**
548
+ * 骑行路线方案
549
+ */
550
+ export interface AmapCyclingPath {
551
+ /** 路线距离(米) */
552
+ distance?: string;
553
+ /** 预计时间(秒) */
554
+ duration?: string;
555
+ /** 道路名列表 */
556
+ roads?: Array<{
557
+ /** 道路名称 */
558
+ name?: string;
559
+ /** 道路距离 */
560
+ distance?: string;
561
+ }>;
562
+ }
563
+ /**
564
+ * 骑行路线信息
565
+ */
566
+ export interface AmapCyclingRoute {
567
+ /** 起点经纬度 */
568
+ origin?: string;
569
+ /** 终点经纬度 */
570
+ destination?: string;
571
+ /** 算路方案详情列表 */
572
+ paths?: AmapCyclingPath[];
573
+ }
574
+ /**
575
+ * 骑行路线规划响应
576
+ */
577
+ export interface AmapCyclingRouteResponse {
578
+ /** 响应状态码 */
579
+ code?: number;
580
+ /** 返回状态 */
581
+ status?: string;
582
+ /** 错误码 */
583
+ infocode?: string;
584
+ /** 路径规划方案总数 */
585
+ count?: string;
586
+ /** 规划方案详情 */
587
+ route?: AmapCyclingRoute;
588
+ }
589
+ /**
590
+ * IP 定位请求
591
+ */
592
+ export interface AmapIpLocationRequest {
593
+ /** 需要搜索的 IP 地址(必填,暂不支持 IPv6) */
594
+ ip: string;
595
+ }
596
+ /**
597
+ * IP 定位响应
598
+ */
599
+ export interface AmapIpLocationResponse {
600
+ /** 响应状态码 */
601
+ code?: number;
602
+ /** 错误码 */
603
+ infocode?: string;
604
+ /** 省份名称 */
605
+ province?: string;
606
+ /** 城市名称 */
607
+ city?: string;
608
+ /** 城市的 adcode 编码 */
609
+ adcode?: string;
610
+ }
611
+ /**
612
+ * 周边搜索请求
613
+ */
614
+ export interface AmapPeripheralSearchRequest {
615
+ /** 中心点地址信息(必填) */
616
+ address: string;
617
+ /** 检索关键词(必填,景点、美食、游玩区域等,不超过 80 字符) */
618
+ keyword: string;
619
+ /** 返回条数(可选,默认 5) */
620
+ count?: number;
621
+ /** 搜索半径(米,可选,范围 0-50000) */
622
+ radius?: number;
623
+ }
624
+ /**
625
+ * POI 信息
626
+ */
627
+ export interface AmapPoi {
628
+ /** POI 的 ID */
629
+ id?: string;
630
+ /** 名称 */
631
+ name?: string;
632
+ /** 类型 */
633
+ type?: string;
634
+ /** 类型编码 */
635
+ typecode?: string;
636
+ /** 地址 */
637
+ address?: string;
638
+ /** 经纬度坐标 */
639
+ location?: string;
640
+ /** 距离中心点的距离(米) */
641
+ distance?: string;
642
+ /** 电话 */
643
+ tel?: string;
644
+ /** 扩展信息 */
645
+ [key: string]: unknown;
646
+ }
647
+ /**
648
+ * 周边搜索响应
649
+ */
650
+ export interface AmapPeripheralSearchResponse {
651
+ /** 响应状态码 */
652
+ code?: number;
653
+ /** 结果状态值,0 或 1 */
654
+ status?: string;
655
+ /** 错误码 */
656
+ infocode?: string;
657
+ /** 返回结果总数 */
658
+ count?: string;
659
+ /** POI 信息列表 */
660
+ pois?: AmapPoi[];
661
+ }
662
+ /**
663
+ * 步行路线规划请求
664
+ */
665
+ export interface AmapWalkingRouteRequest {
666
+ /** 起点地址(必填) */
667
+ origin: string;
668
+ /** 终点地址(必填) */
669
+ destination: string;
670
+ }
671
+ /**
672
+ * 步行路线方案
673
+ */
674
+ export interface AmapWalkingPath {
675
+ /** 路线距离(米) */
676
+ distance?: string;
677
+ /** 预计时间(秒) */
678
+ duration?: string;
679
+ /** 步行引导信息 */
680
+ steps?: Array<{
681
+ /** 指令 */
682
+ instruction?: string;
683
+ /** 道路名称 */
684
+ road?: string;
685
+ /** 距离 */
686
+ distance?: string;
687
+ }>;
688
+ }
689
+ /**
690
+ * 步行路线信息
691
+ */
692
+ export interface AmapWalkingRoute {
693
+ /** 起点坐标 */
694
+ origin?: string;
695
+ /** 终点坐标 */
696
+ destination?: string;
697
+ /** 算路方案详情列表 */
698
+ paths?: AmapWalkingPath[];
699
+ }
700
+ /**
701
+ * 步行路线规划响应
702
+ */
703
+ export interface AmapWalkingRouteResponse {
704
+ /** 响应状态码 */
705
+ code?: number;
706
+ /** 返回状态,1 成功,0 失败 */
707
+ status?: string;
708
+ /** 错误码 */
709
+ infocode?: string;
710
+ /** 路径规划方案总数 */
711
+ count?: string;
712
+ /** 规划方案详情 */
713
+ route?: AmapWalkingRoute;
714
+ }
715
+ /**
716
+ * 驾车路线规划请求
717
+ */
718
+ export interface AmapDrivingRouteRequest {
719
+ /** 起点地址或经纬度(必填) */
720
+ origin: string;
721
+ /** 终点地址或经纬度(必填) */
722
+ destination: string;
723
+ }
724
+ /**
725
+ * 驾车路线方案
726
+ */
727
+ export interface AmapDrivingPath {
728
+ /** 路线距离(米) */
729
+ distance?: string;
730
+ /** 预计时间(秒) */
731
+ duration?: string;
732
+ /** 预估策略 */
733
+ strategy?: string;
734
+ /** 高速费用(元) */
735
+ tolls?: string;
736
+ /** 高速距离(米) */
737
+ tollDistance?: string;
738
+ /** 步骤信息 */
739
+ steps?: unknown[];
740
+ }
741
+ /**
742
+ * 驾车路线信息
743
+ */
744
+ export interface AmapDrivingRoute {
745
+ /** 起点经纬度 */
746
+ origin?: string;
747
+ /** 终点经纬度 */
748
+ destination?: string;
749
+ /** 预计出租车费用(元) */
750
+ taxi_cost?: string;
751
+ /** 算路方案详情列表 */
752
+ paths?: AmapDrivingPath[];
753
+ }
754
+ /**
755
+ * 驾车路线规划响应
756
+ */
757
+ export interface AmapDrivingRouteResponse {
758
+ /** 响应状态码 */
759
+ code?: number;
760
+ /** 返回状态,1 成功,0 失败 */
761
+ status?: string;
762
+ /** 错误码 */
763
+ infocode?: string;
764
+ /** 路径规划方案总数 */
765
+ count?: string;
766
+ /** 规划方案详情 */
767
+ route?: AmapDrivingRoute;
768
+ }
769
+ /**
770
+ * 电动车路线规划请求
771
+ */
772
+ export interface AmapEbikeRouteRequest {
773
+ /** 起点地址或经纬度(必填) */
774
+ origin: string;
775
+ /** 终点地址或经纬度(必填) */
776
+ destination: string;
777
+ }
778
+ /**
779
+ * 电动车路线方案
780
+ */
781
+ export interface AmapEbikePath {
782
+ /** 路线距离(米) */
783
+ distance?: string;
784
+ /** 预计时间(秒) */
785
+ duration?: string;
786
+ /** 道路信息 */
787
+ roads?: unknown[];
788
+ }
789
+ /**
790
+ * 电动车路线信息
791
+ */
792
+ export interface AmapEbikeRoute {
793
+ /** 起点坐标 */
794
+ origin?: string;
795
+ /** 终点坐标 */
796
+ destination?: string;
797
+ /** 算路方案列表 */
798
+ paths?: AmapEbikePath[];
799
+ }
800
+ /**
801
+ * 电动车路线规划响应
802
+ */
803
+ export interface AmapEbikeRouteResponse {
804
+ /** 响应状态码 */
805
+ code?: number;
806
+ /** 返回状态,1 成功,0 失败 */
807
+ status?: string;
808
+ /** 错误码 */
809
+ infocode?: string;
810
+ /** 返回结果总数目 */
811
+ count?: string;
812
+ /** 路线信息 */
813
+ route?: AmapEbikeRoute;
814
+ }
815
+ /**
816
+ * 公交路线规划请求
817
+ */
818
+ export interface AmapTransitRouteRequest {
819
+ /** 起点地址或经纬度(必填) */
820
+ origin: string;
821
+ /** 终点地址或经纬度(必填) */
822
+ destination: string;
823
+ }
824
+ /**
825
+ * 公交换乘方案成本
826
+ */
827
+ export interface AmapTransitCost {
828
+ /** 票价(元) */
829
+ transitCost?: string;
830
+ }
831
+ /**
832
+ * 公交换乘方案
833
+ */
834
+ export interface AmapTransitItem {
835
+ /** 方案花费(元) */
836
+ cost?: string;
837
+ /** 方案预计时间(秒) */
838
+ duration?: string;
839
+ /** 步行距离(米) */
840
+ walkingDistance?: string;
841
+ /** 换乘详情 */
842
+ segments?: unknown[];
843
+ }
844
+ /**
845
+ * 公交路线信息
846
+ */
847
+ export interface AmapTransitRoute {
848
+ /** 起点坐标 */
849
+ origin?: string;
850
+ /** 终点坐标 */
851
+ destination?: string;
852
+ /** 起点和终点的步行距离 */
853
+ distance?: string;
854
+ /** 换乘方案价格 */
855
+ cost?: AmapTransitCost;
856
+ /** 公交换乘方案列表 */
857
+ transits?: AmapTransitItem[];
858
+ }
859
+ /**
860
+ * 公交路线规划响应
861
+ */
862
+ export interface AmapTransitRouteResponse {
863
+ /** 结果状态值,0 或 1 */
864
+ status?: string;
865
+ /** 错误码 */
866
+ infocode?: string;
867
+ /** 返回状态说明 */
868
+ info?: string;
869
+ /** 公交换乘方案数目 */
870
+ count?: string;
871
+ /** 路线信息 */
872
+ route?: AmapTransitRoute;
873
+ }
874
+ /**
875
+ * 行政区域查询请求
876
+ */
877
+ export interface AmapDistrictRequest {
878
+ /** 查询关键字(必填,行政区名称、citycode、adcode) */
879
+ keywords: string;
880
+ }
881
+ /**
882
+ * 行政区信息
883
+ */
884
+ export interface AmapDistrict {
885
+ /** 行政区编码 */
886
+ adcode?: string;
887
+ /** 城市编码 */
888
+ citycode?: string;
889
+ /** 行政区名称 */
890
+ name?: string;
891
+ /** 中心点坐标 */
892
+ center?: string;
893
+ /** 行政区级别 */
894
+ level?: string;
895
+ /** 下级行政区列表 */
896
+ districts?: AmapDistrict[];
897
+ }
898
+ /**
899
+ * 行政区建议信息
900
+ */
901
+ export interface AmapDistrictSuggestion {
902
+ /** 建议关键字列表 */
903
+ keywords?: string[];
904
+ /** 建议城市列表 */
905
+ cities?: string[];
906
+ }
907
+ /**
908
+ * 行政区域查询响应
909
+ */
910
+ export interface AmapDistrictResponse {
911
+ /** 响应状态码 */
912
+ code?: number;
913
+ /** 错误码 */
914
+ infocode?: string;
915
+ /** 一级行政区总数 */
916
+ count?: string;
917
+ /** 行政区列表 */
918
+ districts?: AmapDistrict[];
919
+ /** 建议结果列表 */
920
+ suggestion?: AmapDistrictSuggestion;
921
+ }
922
+ /**
923
+ * 经纬度转地址请求
924
+ */
925
+ export interface AmapRegeocodeRequest {
926
+ /** 经纬度坐标(必填,经度在前,纬度在后,英文逗号分隔) */
927
+ location: string;
928
+ /** 返回数据类型(可选):base(基本地址)/ all(详细信息) */
929
+ extensions?: string;
930
+ }
931
+ /**
932
+ * 地址组成元素
933
+ */
934
+ export interface AmapAddressComponent {
935
+ /** 省份 */
936
+ province?: string;
937
+ /** 城市 */
938
+ city?: string;
939
+ /** 城市编码 */
940
+ citycode?: string;
941
+ /** 区县 */
942
+ district?: string;
943
+ /** 区域编码 */
944
+ adcode?: string;
945
+ /** 街道 */
946
+ township?: string;
947
+ /** 门牌号 */
948
+ streetNumber?: string;
949
+ /** 扩展信息 */
950
+ [key: string]: unknown;
951
+ }
952
+ /**
953
+ * 逆地理编码结果
954
+ */
955
+ export interface AmapRegeocode {
956
+ /** 格式化后的地址信息 */
957
+ formatted_address?: string;
958
+ /** 地址元素列表 */
959
+ addressComponent?: AmapAddressComponent;
960
+ }
961
+ /**
962
+ * 经纬度转地址响应
963
+ */
964
+ export interface AmapRegeocodeResponse {
965
+ /** 响应状态码 */
966
+ code?: number;
967
+ /** 返回结果状态值 */
968
+ status?: string;
969
+ /** 返回状态说明 */
970
+ info?: string;
971
+ /** 逆地理编码结果 */
972
+ regeocode?: AmapRegeocode;
973
+ }
974
+ /**
975
+ * 坐标转换请求
976
+ */
977
+ export interface AmapConvertRequest {
978
+ /** 坐标点(必填,经纬度用逗号分隔,多个坐标用 "|" 分隔,最多 40 个) */
979
+ locations: string;
980
+ /** 原坐标系(必填):gps / mapbar / baidu / autonavi */
981
+ coordsys: string;
982
+ }
983
+ /**
984
+ * 坐标转换响应
985
+ */
986
+ export interface AmapConvertResponse {
987
+ /** 响应状态码 */
988
+ code?: number;
989
+ /** 返回状态,1 成功,0 失败 */
990
+ status?: string;
991
+ /** 返回的状态信息 */
992
+ info?: string;
993
+ /** 高德错误码 */
994
+ infocode?: string;
995
+ /** 转换后的坐标(多个用 ";" 分隔) */
996
+ locations?: string;
997
+ }
998
+ /**
999
+ * POI 关键字搜索请求
1000
+ */
1001
+ export interface AmapPoiSearchRequest {
1002
+ /** 查询关键字(可选) */
1003
+ keywords?: string;
1004
+ /** 指定地点类型(可选) */
1005
+ types?: string;
1006
+ /** 搜索区划(可选,默认全国) */
1007
+ region?: string;
1008
+ /** 是否限制在 region 内(可选):true / false */
1009
+ city_limit?: string;
1010
+ /** 每页数据条数(可选,1-25) */
1011
+ page_size?: string;
1012
+ /** 分页页码(可选,1-100) */
1013
+ page_num?: string;
1014
+ }
1015
+ /**
1016
+ * POI 关键字搜索响应
1017
+ */
1018
+ export interface AmapPoiSearchResponse {
1019
+ /** 响应状态码 */
1020
+ code?: number;
1021
+ /** 返回状态,1 成功,0 失败 */
1022
+ status?: string;
1023
+ /** 错误码 */
1024
+ infocode?: string;
1025
+ /** 单次请求返回的 POI 点个数 */
1026
+ count?: string;
1027
+ /** POI 完整集合 */
1028
+ pois?: AmapPoi[];
1029
+ }
1030
+ /**
1031
+ * KnowledgeClient 初始化配置
1032
+ */
1033
+ export interface KnowledgeClientConfig {
1034
+ /**
1035
+ * API Key(Bearer Token),通过 Authorization 头传递。
1036
+ * 格式:直接传 key 字符串,SDK 内部会自动拼接 "Bearer " 前缀。
1037
+ */
1038
+ apiKey: string;
1039
+ /**
1040
+ * 自定义 base URL(可选)。
1041
+ * 默认为 https://o.tbox.cn
1042
+ */
1043
+ baseUrl?: string;
1044
+ /**
1045
+ * 请求超时时间(毫秒,可选)。
1046
+ * 默认不设置超时。
1047
+ */
1048
+ timeout?: number;
1049
+ }
1050
+ /**
1051
+ * 表格列定义
1052
+ */
1053
+ export interface TableSchemaColumn {
1054
+ /** 数据类型:STRING, NUMBER, BOOLEAN 等 */
1055
+ dataType?: string;
1056
+ /** 字段描述 */
1057
+ description?: string;
1058
+ /** 是否字段索引 */
1059
+ fieldIndexed?: boolean;
1060
+ /** 是否索引 */
1061
+ indexed?: boolean;
1062
+ /** 字段名称 */
1063
+ name: string;
1064
+ /** 字段顺序 */
1065
+ order?: number;
1066
+ /** 是否主键 */
1067
+ primaryKey?: boolean;
1068
+ /** 是否必填 */
1069
+ required?: boolean;
1070
+ /** 前端组件类型 */
1071
+ 'x-component'?: string;
1072
+ /** 默认值 */
1073
+ default_value?: string;
1074
+ }
1075
+ /**
1076
+ * 表格 Schema 定义
1077
+ */
1078
+ export interface TableSchema {
1079
+ /** 列定义列表 */
1080
+ columns?: TableSchemaColumn[];
1081
+ /** 字段映射关系 */
1082
+ fieldMap?: Record<string, unknown>;
1083
+ /** Formily 表单 Schema */
1084
+ formilySchema?: Record<string, unknown>;
1085
+ /** 表格名称 */
1086
+ name?: string;
1087
+ /** 表格描述 */
1088
+ description?: string;
1089
+ }
1090
+ /**
1091
+ * 创建知识库请求
1092
+ */
1093
+ export interface KnowledgeCreateRequest {
1094
+ /**
1095
+ * 上传的文件(必填)。
1096
+ * 支持格式:.xlsx、.pdf 等
1097
+ */
1098
+ file: File | Blob;
1099
+ /**
1100
+ * 数据类型(必填)。
1101
+ * STRUCTURED:结构化数据;其他类型:非结构化数据
1102
+ */
1103
+ type: string;
1104
+ /**
1105
+ * 表格 Schema 定义(条件必填)。
1106
+ * 当 type = STRUCTURED 时必填
1107
+ */
1108
+ tableSchema?: TableSchema;
1109
+ /**
1110
+ * 索引列名列表(条件必填)。
1111
+ * 当 type = STRUCTURED 时必填
1112
+ */
1113
+ indexColumns?: string[];
1114
+ }
1115
+ /**
1116
+ * 创建知识库响应
1117
+ */
1118
+ export interface KnowledgeCreateResponse {
1119
+ /** 处理请求的主机名 */
1120
+ hostName?: string;
1121
+ /** 结果信息 */
1122
+ result?: {
1123
+ /** 错误类型 */
1124
+ errorType?: string;
1125
+ /** 响应详情 */
1126
+ response?: {
1127
+ /** 创建后的文档 ID(用于后续更新操作) */
1128
+ documentId?: string;
1129
+ };
1130
+ /** 业务处理是否成功 */
1131
+ success?: boolean;
1132
+ };
1133
+ /** 请求是否成功 */
1134
+ success?: boolean;
1135
+ /** 链路追踪 ID */
1136
+ traceId?: string;
1137
+ }
1138
+ /**
1139
+ * 更新知识库请求
1140
+ */
1141
+ export interface KnowledgeUpdateRequest {
1142
+ /**
1143
+ * 上传的文件(必填)。
1144
+ * 支持格式:.xlsx、.pdf 等
1145
+ */
1146
+ file: File | Blob;
1147
+ /**
1148
+ * 数据类型(必填)。
1149
+ * STRUCTURED:结构化数据;其他类型:非结构化数据
1150
+ */
1151
+ type: string;
1152
+ /**
1153
+ * 要更新的文档 ID(必填)。
1154
+ * 从创建响应中获取
1155
+ */
1156
+ documentId: string;
1157
+ /**
1158
+ * 表格 Schema 定义(可选)。
1159
+ * 结构化数据需要
1160
+ */
1161
+ tableSchema?: TableSchema;
1162
+ /**
1163
+ * 更新模式(可选)。
1164
+ * OVERWRITE:覆盖更新;UPSERT:增量更新(默认)
1165
+ */
1166
+ updateMode?: 'OVERWRITE' | 'UPSERT';
1167
+ }
1168
+ /**
1169
+ * 更新知识库响应
1170
+ */
1171
+ export interface KnowledgeUpdateResponse {
1172
+ /** 处理请求的主机名 */
1173
+ hostName?: string;
1174
+ /** 结果信息 */
1175
+ result?: {
1176
+ /** 错误类型 */
1177
+ errorType?: string;
1178
+ /** 响应详情 */
1179
+ response?: {
1180
+ /** 更新后的文档 ID */
1181
+ documentId?: string;
1182
+ };
1183
+ /** 业务处理是否成功 */
1184
+ success?: boolean;
1185
+ };
1186
+ /** 请求是否成功 */
1187
+ success?: boolean;
1188
+ /** 链路追踪 ID */
1189
+ traceId?: string;
1190
+ }
1191
+ /**
1192
+ * 查询知识库列表请求
1193
+ */
1194
+ export interface KnowledgeQueryListRequest {
1195
+ /**
1196
+ * 知识库名称(支持模糊查询)。
1197
+ */
1198
+ name?: string;
1199
+ /**
1200
+ * 页码,从 1 开始(可选,默认 1)
1201
+ */
1202
+ pageNo?: number;
1203
+ /**
1204
+ * 每页条数(可选,默认 10)
1205
+ */
1206
+ pageSize?: number;
1207
+ }
1208
+ /**
1209
+ * 知识库信息
1210
+ */
1211
+ export interface KnowledgeDatasetInfo {
1212
+ /** 知识库 ID */
1213
+ datasetId?: string;
1214
+ /** 知识库名称 */
1215
+ name?: string;
1216
+ /** 存储大小 */
1217
+ storeSize?: number;
1218
+ /** 数据类型:STRUCTURED / UNSTRUCTURED */
1219
+ type?: string;
1220
+ }
1221
+ /**
1222
+ * 查询知识库列表响应
1223
+ */
1224
+ export interface KnowledgeQueryListResponse {
1225
+ /** 当前页码 */
1226
+ currentPage?: number;
1227
+ /** 知识库列表 */
1228
+ datasets?: KnowledgeDatasetInfo[];
1229
+ /** 每页条数 */
1230
+ pageSize?: number;
1231
+ /** 总条数 */
1232
+ total?: number;
1233
+ }
1234
+ /**
1235
+ * 检索知识库请求
1236
+ */
1237
+ export interface KnowledgeRetrieveRequest {
1238
+ /**
1239
+ * 知识库名称(优先使用)。
1240
+ * 如果提供 name,SDK 会自动查询获取 datasetId。
1241
+ * name 和 datasetId 至少提供一个
1242
+ */
1243
+ name?: string;
1244
+ /**
1245
+ * 知识库 ID(可选)。
1246
+ * 如果同时提供 name 和 datasetId,优先使用 datasetId。
1247
+ * 如果只提供 name,SDK 会自动查询获取 datasetId
1248
+ */
1249
+ datasetId?: string;
1250
+ /**
1251
+ * 查询内容(必填)。
1252
+ * 自然语言描述
1253
+ */
1254
+ query: string;
1255
+ }
1256
+ /**
1257
+ * 检索结果条目
1258
+ */
1259
+ export interface KnowledgeRetrieveItem {
1260
+ /** 检索到的内容片段 */
1261
+ content?: string;
1262
+ /** 原始文件名 */
1263
+ originFileName?: string;
1264
+ /** 相关度分数(0-1,越高越相关) */
1265
+ score?: number;
1266
+ }
1267
+ /**
1268
+ * 检索知识库响应
1269
+ */
1270
+ export interface KnowledgeRetrieveResponse {
1271
+ /** 检索结果数组(直接作为 data 字段返回) */
1272
+ data?: KnowledgeRetrieveItem[];
1273
+ /** 错误码("0"表示成功) */
1274
+ errorCode?: string;
1275
+ /** 错误信息 */
1276
+ errorMsg?: string;
1277
+ /** 请求是否成功 */
1278
+ success?: boolean;
1279
+ /** 链路追踪 ID */
1280
+ traceId?: string;
1281
+ }
1282
+ /**
1283
+ * LlmClient 初始化配置
1284
+ */
1285
+ export interface LlmClientConfig {
1286
+ /**
1287
+ * API Key(Bearer Token),通过 Authorization 头传递。
1288
+ * 格式:直接传 key 字符串,SDK 内部会自动拼接 "Bearer " 前缀。
1289
+ */
1290
+ apiKey: string;
1291
+ /**
1292
+ * 自定义 base URL(可选)。
1293
+ * 默认为 https://o.tbox.cn
1294
+ */
1295
+ baseUrl?: string;
1296
+ /**
1297
+ * 请求超时时间(毫秒,可选)。
1298
+ * 默认不设置超时。
1299
+ */
1300
+ timeout?: number;
1301
+ }
1302
+ /**
1303
+ * 对话消息
1304
+ */
1305
+ export interface ChatMessage {
1306
+ /** 角色:system / user / assistant */
1307
+ role: 'system' | 'user' | 'assistant';
1308
+ /** 消息内容 */
1309
+ content: string;
1310
+ }
1311
+ /**
1312
+ * 流式选项
1313
+ */
1314
+ export interface StreamOptions {
1315
+ /** 是否在末尾 chunk 返回 token 用量 */
1316
+ include_usage?: boolean;
1317
+ }
1318
+ /**
1319
+ * Chat Completions 请求
1320
+ */
1321
+ export interface ChatCompletionRequest {
1322
+ /** 模型名称(必填) */
1323
+ model: string;
1324
+ /** 对话消息列表(必填) */
1325
+ messages: ChatMessage[];
1326
+ /** 是否流式输出,默认 false */
1327
+ stream?: boolean;
1328
+ /** 流式选项 */
1329
+ stream_options?: StreamOptions;
1330
+ /** 温度参数,范围 0~2 */
1331
+ temperature?: number;
1332
+ /** 核采样参数,范围 0~1,推荐 0.95 */
1333
+ top_p?: number;
1334
+ /** 最大输出 token 数,推荐 8000 */
1335
+ max_tokens?: number;
1336
+ }
1337
+ /**
1338
+ * Chat Completions 响应(非流式)
1339
+ */
1340
+ export interface ChatCompletionResponse {
1341
+ /** 响应 ID */
1342
+ id?: string;
1343
+ /** 选择列表 */
1344
+ choices?: ChatCompletionChoice[];
1345
+ /** 创建时间戳 */
1346
+ created?: number;
1347
+ /** 模型名称 */
1348
+ model?: string;
1349
+ /** 对象类型 */
1350
+ object?: string;
1351
+ /** Token 用量 */
1352
+ usage?: {
1353
+ /** 输入 token 数 */
1354
+ prompt_tokens?: number;
1355
+ /** 输出 token 数 */
1356
+ completion_tokens?: number;
1357
+ /** 总 token 数 */
1358
+ total_tokens?: number;
1359
+ };
1360
+ }
1361
+ /**
1362
+ * 非流式响应的选择项
1363
+ */
1364
+ export interface ChatCompletionChoice {
1365
+ /** 索引 */
1366
+ index?: number;
1367
+ /** 消息内容 */
1368
+ message?: ChatMessage;
1369
+ /** 结束原因:stop / length / content_filter 等 */
1370
+ finish_reason?: string | null;
1371
+ }
1372
+ /**
1373
+ * Chat Completions 流式响应块
1374
+ */
1375
+ export interface ChatCompletionChunk {
1376
+ /** 响应 ID */
1377
+ id?: string;
1378
+ /** 选择列表 */
1379
+ choices?: ChatCompletionChunkChoice[];
1380
+ /** 创建时间戳 */
1381
+ created?: number;
1382
+ /** 模型名称 */
1383
+ model?: string;
1384
+ /** 对象类型 */
1385
+ object?: string;
1386
+ /** 系统指纹 */
1387
+ system_fingerprint?: string;
1388
+ /** Token 用量(仅在 stream_options.include_usage=true 时,最后一个 chunk 携带) */
1389
+ usage?: {
1390
+ /** 输入 token 数 */
1391
+ prompt_tokens?: number;
1392
+ /** 输出 token 数 */
1393
+ completion_tokens?: number;
1394
+ /** 总 token 数 */
1395
+ total_tokens?: number;
1396
+ };
1397
+ }
1398
+ /**
1399
+ * 流式响应的选择项
1400
+ */
1401
+ export interface ChatCompletionChunkChoice {
1402
+ /** 索引 */
1403
+ index?: number;
1404
+ /** 增量内容 */
1405
+ delta?: {
1406
+ /** 角色(仅首个 chunk 包含) */
1407
+ role?: 'system' | 'user' | 'assistant';
1408
+ /** 文本片段 */
1409
+ content?: string;
1410
+ /** 推理内容片段(推理模型如 glm-5v-turbo 返回) */
1411
+ reasoning_content?: string;
1412
+ };
1413
+ /** 结束原因:stop / length / content_filter 等,正常结束为 stop */
1414
+ finish_reason?: string | null;
1415
+ }