@tbox.cn/app-agent-sdk-client 0.1.4 → 0.1.6
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.
|
@@ -18,7 +18,7 @@ interface AuthClientOptions {
|
|
|
18
18
|
interface AuthClient {
|
|
19
19
|
/** 获取鉴权态(幂等,pendingPromise 单例去重) */
|
|
20
20
|
ensureAuth(): Promise<AuthState>;
|
|
21
|
-
/** 强制重新解析(登出/切换用户后、401
|
|
21
|
+
/** 强制重新解析(登出/切换用户后、401 重登录);并发调用共享单例(去重) */
|
|
22
22
|
refreshAuth(): Promise<AuthState>;
|
|
23
23
|
/** 清空鉴权缓存(登出/切换用户:清 token + 缓存态;lastToken 保留——同用户重登续签语义) */
|
|
24
24
|
clearAuth(): void;
|
|
@@ -29,7 +29,7 @@ interface AuthClient {
|
|
|
29
29
|
}
|
|
30
30
|
declare function createAuthClient(options?: AuthClientOptions): AuthClient;
|
|
31
31
|
/**
|
|
32
|
-
* 应用级 authClient 单例读取(单一模板统一化
|
|
32
|
+
* 应用级 authClient 单例读取(单一模板统一化 域模块消费面)。
|
|
33
33
|
*
|
|
34
34
|
* 域模块(如 mall-core 的首屏数据加载)需要与宿主应用同一 authClient 实例
|
|
35
35
|
* (实例分裂免疫——token/scope 状态单份)。应用装配(agent-runtime)先建单例,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TboxCardPayload, CardComponent, UiAction } from '@tbox.cn/app-contracts';
|
|
2
|
-
import { A as AuthClient } from '../auth-client-
|
|
2
|
+
import { A as AuthClient } from '../auth-client-DtSZ8ejL.js';
|
|
3
3
|
import { TboxCardPreviewCard, TboxCardPreviewSample, TboxCardPreviewCatalog } from '@tbox.cn/app-sdk-core';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/client/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { InferModuleCards } from '@tbox.cn/app-sdk-core';
|
|
|
3
3
|
import { TboxSessionData, HostEffect, Adapters, IASRAdapter, IFeedbackAdapter, ITTSAdapter, IUploadAdapter, HelloAckChatConfig, TboxCardPayload, UiAction, CardSnapshot, SkillRecord, PreToolRecord, HostEffectResult, UploadProgressCallback, UploadOptions, UploadResult } from '@tbox.cn/app-contracts';
|
|
4
4
|
export { Adapters, ChatUiSettings, IASRAdapter, IFeedbackAdapter, ITTSAdapter, IUploadAdapter, UploadOptions, UploadProgressCallback, UploadResult } from '@tbox.cn/app-contracts';
|
|
5
5
|
import { UseBoundStore, StoreApi } from 'zustand';
|
|
6
|
-
import { A as AuthClient } from '../auth-client-
|
|
7
|
-
export { a as AuthClientOptions, b as AuthIdentity, c as AuthState, d as createAuthClient, g as getAuthClient } from '../auth-client-
|
|
6
|
+
import { A as AuthClient } from '../auth-client-DtSZ8ejL.js';
|
|
7
|
+
export { a as AuthClientOptions, b as AuthIdentity, c as AuthState, d as createAuthClient, g as getAuthClient } from '../auth-client-DtSZ8ejL.js';
|
|
8
8
|
import * as react from 'react';
|
|
9
9
|
|
|
10
10
|
/** 媒体 / 消息类型(SDK 核心 chat 协议类型) */
|
|
@@ -83,7 +83,7 @@ interface ListMessagesOptions {
|
|
|
83
83
|
}
|
|
84
84
|
interface PlatformApi {
|
|
85
85
|
/**
|
|
86
|
-
* 获取平台能力凭证(006
|
|
86
|
+
* 获取平台能力凭证(006 tboxSessionId,区别于 auth token)。
|
|
87
87
|
* 身份恒取 token(服务端 401/403 收口)。
|
|
88
88
|
*/
|
|
89
89
|
getTboxSession(forceRefresh?: boolean): Promise<TboxSessionData>;
|
|
@@ -110,14 +110,14 @@ interface CoreChatStoreDeps {
|
|
|
110
110
|
/** toast 函数(app 侧注入) */
|
|
111
111
|
toast: ToastFunction;
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* 宿主效果执行(/V1:缺省 SDK 内置 bridge-aware runner;
|
|
114
114
|
* 注入可测——store 零 jsapi import)。contextToken 去重已在 store 层完成。
|
|
115
115
|
*/
|
|
116
116
|
onHostEffect?: (effect: HostEffect) => void;
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* 卡片事件埋点(可选注入;模板零默认装配):
|
|
119
119
|
* 打点位在 store 写入动作(upsertCard=render / updateCardData 命中=update /
|
|
120
|
-
* sendToServer=click)——WS 事件流单线触发,StrictMode
|
|
120
|
+
* sendToServer=click)——WS 事件流单线触发,StrictMode 双调免疫。
|
|
121
121
|
*/
|
|
122
122
|
onCardEvent?: (event: CardEventData) => void;
|
|
123
123
|
/**
|
|
@@ -126,18 +126,18 @@ interface CoreChatStoreDeps {
|
|
|
126
126
|
*/
|
|
127
127
|
onSessionCredentialsRefreshed?: (reason?: string) => void;
|
|
128
128
|
/**
|
|
129
|
-
* 平台 API
|
|
129
|
+
* 平台 API(会话泳道下沉:initConversation/loadMoreHistory 消费
|
|
130
130
|
* createConversation/listMessages)。可选注入——缺席时调用会话泳道方法 fail-loud
|
|
131
131
|
* (旧形态自持实现的应用不走 SDK 泳道)。
|
|
132
132
|
*/
|
|
133
133
|
platformApi?: PlatformApi;
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
135
|
+
* 鉴权客户端(会话泳道下沉:resolveUserId/getAuthState/clearAuth/ensureAuth 消费)。
|
|
136
136
|
* 可选注入——与 platformApi 成对;缺席同上 fail-loud。
|
|
137
137
|
*/
|
|
138
138
|
authClient?: AuthClient;
|
|
139
139
|
}
|
|
140
|
-
/**
|
|
140
|
+
/** 卡片事件(埋点:render 曝光 / update 原地更新命中 / click 卡内动作上行) */
|
|
141
141
|
interface CardEventData {
|
|
142
142
|
type: 'render' | 'update' | 'click';
|
|
143
143
|
cardId: string;
|
|
@@ -182,13 +182,13 @@ declare function sendCardAction(surfaceId: string, action: UiAction, formData?:
|
|
|
182
182
|
* (可能是 undefined——应用 store 未创建时)。dev 卡片预览页挂载时接管
|
|
183
183
|
* sendCardAction、卸载时还原应用通道;guard 语义(仅当当前仍是本绑定才还原)
|
|
184
184
|
* 使嵌套绑定与 React StrictMode 双 effect 天然幂等。
|
|
185
|
-
* createCoreChatState
|
|
185
|
+
* createCoreChatState 构造期经此注册保底绑定(语义不变)。
|
|
186
186
|
*/
|
|
187
187
|
declare function bindCardActionChannel(dispatch: (surfaceId: string, action: UiAction, formData?: Record<string, unknown>) => void): () => void;
|
|
188
188
|
|
|
189
189
|
interface CoreChatState {
|
|
190
190
|
userId: string;
|
|
191
|
-
/**
|
|
191
|
+
/** HELLO_ACK 载荷(mallScope + chatConfig;服务端下发单一真源) */
|
|
192
192
|
helloAck: HelloAckState | null;
|
|
193
193
|
/** 连接终态阻断(4001 耗尽 / 4002 / mall 匿名跳建连):非 null 时 UI 禁用对话;
|
|
194
194
|
* 恢复唯一真源 = HELLO_ACK。纯展示态,不参与发送判定(发送判定归 isWsOpen 咽喉)。 */
|
|
@@ -247,7 +247,7 @@ interface CoreChatState {
|
|
|
247
247
|
scheduleSessionUpgrade: () => Promise<void>;
|
|
248
248
|
}
|
|
249
249
|
type CoreChatStore<T = CoreChatState> = UseBoundStore<StoreApi<T>>;
|
|
250
|
-
/**
|
|
250
|
+
/** HELLO_ACK 状态形状(chat-store 单一消费点) */
|
|
251
251
|
interface HelloAckState {
|
|
252
252
|
mallScope?: Record<string, string>;
|
|
253
253
|
chatConfig: HelloAckChatConfig;
|
|
@@ -263,7 +263,7 @@ declare function createCoreChatState(deps: CoreChatStoreDeps, set: {
|
|
|
263
263
|
(updater: (state: CoreChatState) => Partial<CoreChatState>): void;
|
|
264
264
|
}, get: () => CoreChatState): CoreChatState;
|
|
265
265
|
/**
|
|
266
|
-
*
|
|
266
|
+
* 凭证升级排水订阅:生成中排队的升级在 isGenerating true→false 跃迁时执行
|
|
267
267
|
* (订阅模块级双标志;scheduleSessionUpgrade in-flight/排队守卫防重入重放)。
|
|
268
268
|
* 应用在 create() 之后调用一次(返回退订函数;mall 模板薄壳装配位)。
|
|
269
269
|
*/
|
|
@@ -411,7 +411,7 @@ interface CallActionOptions {
|
|
|
411
411
|
sessionId?: string;
|
|
412
412
|
/** API base(默认同源 '') */
|
|
413
413
|
baseUrl?: string;
|
|
414
|
-
/** 鉴权 token(
|
|
414
|
+
/** 鉴权 token(Authorization: Bearer;缺省经 configureAuthToken 注入) */
|
|
415
415
|
token?: string;
|
|
416
416
|
}
|
|
417
417
|
/** 注入鉴权 token getter(auth-client 调用;与 ws.ts 共享同一 getter 语义) */
|
|
@@ -445,7 +445,7 @@ declare function hideCard(state: CardStoreState, cardId: string): CardStoreState
|
|
|
445
445
|
* - blockAll:可选的应用级总闸(返回 true 丢弃一切动作);SDK chat-store 缺省不注入——
|
|
446
446
|
* 原 B2「历史卡全禁」已收窄为只禁写通道。
|
|
447
447
|
*
|
|
448
|
-
*
|
|
448
|
+
* 修复(顺带,既有缺口):moduleAction 此前无分支被静默丢弃——卡按钮 token 点击链路
|
|
449
449
|
* (CardRenderer 默认按钮条/模块 sendCardAction)经 sendUiAction 全部断裂。
|
|
450
450
|
*/
|
|
451
451
|
interface CardActionHandlerDeps {
|
|
@@ -464,13 +464,13 @@ type CardActionHandler = (surfaceId: string, action: UiAction, formData?: Record
|
|
|
464
464
|
declare function createCardActionHandler(deps: CardActionHandlerDeps): CardActionHandler;
|
|
465
465
|
|
|
466
466
|
/**
|
|
467
|
-
*
|
|
467
|
+
* 宿主效果执行器:tbox:effect CUSTOM 事件 → 宿主能力调用 → 结果回传。
|
|
468
468
|
*
|
|
469
469
|
* 分发表(E1 闭合):
|
|
470
470
|
* - payment → requestPayment(9000→success / 6001→cancel / 其他→failure / 桥不可用→unavailable)
|
|
471
471
|
* - authorization.alipay-user-profile → getAuthCode(成功→success+authCode / CANCEL→cancel / 空码→failure / 桥不可用→unavailable)
|
|
472
472
|
* - session.credentials-refreshed → onSessionCredentialsRefreshed 通知钩子(宿主清缓存重登重连;无回传)
|
|
473
|
-
* - navigation.open / share / download / 未知类型 → no-op + warn
|
|
473
|
+
* - navigation.open / share / download / 未知类型 → no-op + warn(不 throw 不回传)
|
|
474
474
|
*
|
|
475
475
|
* 回传:仅 effect.callback 存在时经 sendModuleAction(UI_ACTION moduleAction 通道,零新协议),
|
|
476
476
|
* formData = HostEffectResult(服务端回调动作 inputSchema 校验)。
|
|
@@ -522,9 +522,9 @@ declare function createHostEffectRunner(depsOverride?: Partial<HostEffectRunnerD
|
|
|
522
522
|
|
|
523
523
|
/**
|
|
524
524
|
* CardHistoryLoader:客户端历史快照加载 + 恢复(001 §8.1 / 003 §4.2)。
|
|
525
|
-
*
|
|
526
|
-
* 完整 schema 迁移(meta.migrate)在服务端 restoreCardSnapshot
|
|
527
|
-
* 006 评审
|
|
525
|
+
* 提供接口 + 内存实现与 restoreCardSnapshot(isHistory 感知)。
|
|
526
|
+
* 完整 schema 迁移(meta.migrate)在服务端 restoreCardSnapshot 执行(完整持久化)。
|
|
527
|
+
* 006 评审 `sessionId` 键语义 = 会话键(conversationId);接口名保留兼容。
|
|
528
528
|
*/
|
|
529
529
|
interface CardHistoryLoader {
|
|
530
530
|
load(sessionId: string): Promise<TboxCardPayload[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-agent-sdk-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "tbox agent 应用框架 client 轴:chat-store 状态域、WS、卡片运行时、能力适配器(asr/tts/upload/feedback)、历史/深链自动发送。通用底座(runtime/http/logger/bridge/卡片渲染基元)在 @tbox.cn/app-sdk-client。",
|
|
6
6
|
"exports": {
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
26
|
"platform",
|
|
27
|
-
"README.md",
|
|
28
27
|
"LICENSE"
|
|
29
28
|
],
|
|
30
29
|
"engines": {
|
|
@@ -34,9 +33,9 @@
|
|
|
34
33
|
"access": "public"
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@tbox.cn/app-contracts": "0.
|
|
38
|
-
"@tbox.cn/app-sdk-client": "0.21.
|
|
39
|
-
"@tbox.cn/app-sdk-core": "0.20.
|
|
36
|
+
"@tbox.cn/app-contracts": "0.13.0",
|
|
37
|
+
"@tbox.cn/app-sdk-client": "0.21.3",
|
|
38
|
+
"@tbox.cn/app-sdk-core": "0.20.4",
|
|
40
39
|
"react": "18.3.1",
|
|
41
40
|
"react-dom": "18.3.1",
|
|
42
41
|
"zustand": "4.5.7"
|