@tbox.cn/app-contracts 0.1.2 → 0.1.3

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tbox.cn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @tbox.cn/app-contracts
2
+
3
+ 平台契约(TIER0,types-only 为主 + 协议常量运行时值):卡片协议 / SDK adapter / 平台 DTO。
4
+
5
+ ## 安装
6
+
7
+ ```sh
8
+ pnpm add @tbox.cn/app-contracts
9
+ ```
10
+
11
+ ## 说明
12
+
13
+ 平台契约类型真源包,供 app-sdk 与业务模块共享;模块只经 `@tbox.cn/app-contracts` 公开入口引用。
@@ -0,0 +1,55 @@
1
+ /**
2
+ * 能力适配层接口(双端共享)。
3
+ *
4
+ * 每个能力两套实现:
5
+ * - browser/ 浏览器原生(MediaRecorder / <input> / fetch / WebAudio)
6
+ * - alipay/ 支付宝壳走桥(src/bridge)
7
+ * 运行时由 adapters/index.ts 按 isInAlipayShell() 选择。
8
+ */
9
+ export interface IASRAdapter {
10
+ checkPermission?(): Promise<boolean>;
11
+ startRecording(): Promise<void>;
12
+ stopRecording(): Promise<string>;
13
+ cancelRecording(): void;
14
+ onInterimResult?(cb: (text: string) => void): void;
15
+ }
16
+ export interface ITTSAdapter {
17
+ speak(text: string, id?: string): Promise<void>;
18
+ pause(): void;
19
+ resume(): void;
20
+ stop(): void;
21
+ onStateChange(cb: (state: 'idle' | 'loading' | 'playing' | 'paused') => void): (() => void) | void;
22
+ /** 流式接口(自动播放:边生成边送)。startStreaming → 多次 sendText → finishStreaming。 */
23
+ startStreaming?(): Promise<void>;
24
+ sendText?(text: string): void;
25
+ finishStreaming?(): void;
26
+ }
27
+ export interface UploadOptions {
28
+ type: 'image' | 'video' | 'audio' | 'file';
29
+ name?: string;
30
+ }
31
+ export interface UploadResult {
32
+ fileId: string;
33
+ url: string;
34
+ /** 服务端返回的 MIME 类型,如 "image/png" */
35
+ mimeType?: string;
36
+ /** 内容审核结果;false = 未过审(illegal)。SDK 可能不返回,则视为已过审。 */
37
+ safed?: boolean;
38
+ }
39
+ export type UploadProgressCallback = (progress: number) => void;
40
+ export interface IUploadAdapter {
41
+ upload(file: File | string, options?: UploadOptions): Promise<UploadResult>;
42
+ onProgress?: UploadProgressCallback;
43
+ cancel?(): void;
44
+ }
45
+ export interface IFeedbackAdapter {
46
+ addTag(requestId: string, feedback: 'LIKE' | 'DISLIKE' | 'CANCEL'): Promise<{
47
+ success: boolean;
48
+ }>;
49
+ }
50
+ export interface Adapters {
51
+ asr?: IASRAdapter;
52
+ tts?: ITTSAdapter;
53
+ upload?: IUploadAdapter;
54
+ feedback?: IFeedbackAdapter;
55
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * 卡片协议层类型定义(双端共享)。
3
+ *
4
+ * 合并自原 server/src/cards/types.ts 和 client/src/cards/types.ts,
5
+ * 消除双份镜像,作为唯一数据源。
6
+ */
7
+ import type { ComponentType } from 'react';
8
+ import type { ZodTypeAny, infer as zInfer } from 'zod';
9
+ /**
10
+ * 单张卡片的元数据形状。每张卡片的 meta.ts 的 default export 必须满足此 interface。
11
+ *
12
+ * TSchema 泛型把 `dataSchema` 和 `sampleData` 的类型关联起来——
13
+ * 编译期就能保证 sampleData 是 dataSchema 校验通过的形状,避免漂移。
14
+ */
15
+ export interface CardMeta<TSchema extends ZodTypeAny = ZodTypeAny> {
16
+ /** 卡片类型唯一标识,作为 CARD_REGISTRY 的 key */
17
+ cardType: string;
18
+ /** 卡片预期接收的数据形状(zod schema) */
19
+ dataSchema: TSchema;
20
+ /** 允许哪些 tool 触发此卡片(白名单;SDK 依此自动生成 tool→card 绑定,声明即绑定) */
21
+ allowedTools: readonly string[];
22
+ /** 显示名(给开发者看的) */
23
+ displayName: string;
24
+ /** 卡片功能描述(给开发者文档 / IDE hover / AGENTS.md 自动列表用) */
25
+ description: string;
26
+ /**
27
+ * 示例数据(必填)。
28
+ * - 必须通过 dataSchema 校验
29
+ * - 用于:未来 tbox-ai-coding 卡片画廊渲染、单测、本地预览
30
+ * - 选一组"看起来漂亮"的数据,让画廊呈现最佳状态
31
+ */
32
+ sampleData: zInfer<TSchema>;
33
+ /** 卡片数据契约版本(一期启用;缺省视为 1) */
34
+ schemaVersion?: number;
35
+ /** 历史快照 schema 迁移:oldData → 新版本数据(001 §7.4) */
36
+ migrate?: (oldData: unknown, oldVersion: number) => Record<string, unknown>;
37
+ }
38
+ /**
39
+ * AG-UI CUSTOM('tbox:card') 事件的 value 形状。
40
+ * server 下发 { cardType, data },client React 组件渲染。
41
+ * 一期:整卡下发 + HTTP 交互 + isHistory;二期预留 lifecycle/interactions(001 §7.2)。
42
+ */
43
+ export interface TboxCardPayload {
44
+ /** 卡片实例唯一 id */
45
+ id: string;
46
+ /** 关联的 assistant 消息(业务旁路 emit 可不传) */
47
+ messageId?: string;
48
+ /** 卡片类型,对应 CARD_REGISTRY key */
49
+ cardType: string;
50
+ /** 按 dataSchema 校验 / 默认值兜底后的数据 */
51
+ data: Record<string, unknown>;
52
+ status: 'ready' | 'error';
53
+ error?: string;
54
+ /** 历史恢复卡片标志(true=历史恢复,禁交互;false/缺省=实时下发) */
55
+ isHistory?: boolean;
56
+ /** 数据契约版本(恢复时用于迁移) */
57
+ schemaVersion?: number;
58
+ /** 卡片元信息 */
59
+ meta?: {
60
+ createdAt: number;
61
+ updatedAt?: number;
62
+ businessNo?: string;
63
+ };
64
+ lifecycle?: unknown;
65
+ interactions?: unknown[];
66
+ }
67
+ /** 卡片持久化快照(001 §7.4) */
68
+ export interface CardSnapshot {
69
+ id: string;
70
+ cardType: string;
71
+ data: Record<string, unknown>;
72
+ status: 'ready' | 'error';
73
+ schemaVersion: number;
74
+ /** 关联的 assistant 消息(消息 ↔ 卡片关联,P3 新增) */
75
+ messageId?: string;
76
+ meta?: {
77
+ createdAt: number;
78
+ businessNo?: string;
79
+ };
80
+ }
81
+ /** AG-UI CUSTOM 事件 name(卡片通道) */
82
+ export declare const TBOX_CARD_EVENT_NAME = "tbox:card";
83
+ /** 单张卡片组件:data(各卡自己定具体类型)+ cardId(交互卡用作 sendUiAction 的 surfaceId)+ isHistory(历史恢复标志) */
84
+ export type CardComponent<T = unknown> = ComponentType<{
85
+ data: T;
86
+ cardId: string;
87
+ isHistory: boolean;
88
+ }>;
89
+ /**
90
+ * 卡片反向通道动作(client 侧,与 protocol.ts 的 UiClientAction 对齐)。
91
+ * 由卡片 React 组件直接调 chatStore.sendUiAction 触发。
92
+ */
93
+ export type UiAction = {
94
+ type: 'sendMessage';
95
+ value: string;
96
+ visible?: boolean;
97
+ } | {
98
+ type: 'submitForm';
99
+ formId: string;
100
+ } | {
101
+ type: 'openLink';
102
+ url: string;
103
+ } | {
104
+ type: 'toast';
105
+ content: string;
106
+ tone?: 'info' | 'success' | 'error';
107
+ } | {
108
+ type: 'closeCard';
109
+ };
@@ -0,0 +1,79 @@
1
+ /**
2
+ * 统一用户授权鉴权契约(006):身份 / Token / 换发 / 运行上下文。
3
+ * TIER0 types-only(+ 错误码常量),双端共享:服务端签发/校验、客户端消费。
4
+ *
5
+ * 设计要点(006 §2 / D1-D4):
6
+ * - 自有 JWT 唯一形态;外部一律内置换发(三态收敛),原始 token 嵌 `external` claim。
7
+ * - userId 命名(006 D4 修订):local/dev 由模板生成,前缀 local_/dev_;**external 原样保留
8
+ * (外部系统自管命名空间,不加前缀/不归一化)**;anonymous 服务端生成、不签发 JWT。
9
+ * - RequestContext 单一运行上下文(identity + conversationId + credentials + attributes),
10
+ * 经 ctx.auth.getContext() 无参读取(当前运行上下文,无 ALS)。
11
+ */
12
+ export type UserIdSource = 'local' | 'external' | 'dev' | 'anonymous';
13
+ export interface Identity {
14
+ /** 全局唯一 userId,四前缀命名空间(见文件头) */
15
+ userId: string;
16
+ /** 来源(主区分;local/external/dev 都可能带名字与头像) */
17
+ source: UserIdSource;
18
+ displayName?: string;
19
+ avatar?: string;
20
+ }
21
+ /** 外部原始凭据(嵌自有 JWT 的 external claim;组件经 ctx.auth.getContext().credentials 取用) */
22
+ export interface ExternalCredentials {
23
+ /** 外部原始 token(JWT / opaque / session) */
24
+ token: string;
25
+ /** 外部 provider 标识(如 alipay-iap / mall-gateway) */
26
+ provider: string;
27
+ /** 外部 token 过期时间(ms epoch;未知则不传) */
28
+ expiresAt?: number;
29
+ }
30
+ /** 换发结果:身份 +(可选)外部原始凭据,成对流动 */
31
+ export interface ExchangeResult {
32
+ identity: Identity;
33
+ credentials?: ExternalCredentials;
34
+ }
35
+ export interface TokenPayload {
36
+ /** subject = identity.userId */
37
+ sub: string;
38
+ iss: string;
39
+ iat: number;
40
+ exp: number;
41
+ /** identity.source 冗余(避免反查),校验时与 sub 前缀一致性核对 */
42
+ source: UserIdSource;
43
+ /** 外部原始 token(门控 AUTH_EMBED_EXTERNAL_TOKEN=true 时签发;HTTP/WS 校验后可读) */
44
+ external?: ExternalCredentials;
45
+ jti?: string;
46
+ }
47
+ export interface RequestContext {
48
+ identity: Identity;
49
+ conversationId?: string;
50
+ /** 外部原始凭据(external claim 解析出;无则缺省) */
51
+ credentials?: ExternalCredentials;
52
+ /** 业务侧额外属性(不进 JWT,体积约束) */
53
+ attributes?: Record<string, unknown>;
54
+ }
55
+ /**
56
+ * 换码器接口:code → ExchangeResult(identity + 可选外部凭据)。
57
+ * 本地实现(支付宝/微信)与外部实现(ExternalIdentityExchange)均实现本接口。
58
+ */
59
+ export interface IdentityExchange {
60
+ readonly provider: string;
61
+ exchangeByCode(code: string, platform?: string): Promise<ExchangeResult>;
62
+ }
63
+ export declare const AUTH_ERROR_CODES: {
64
+ /** 401:凭证缺失/非法 */
65
+ readonly UNAUTHORIZED: "AUTH_UNAUTHORIZED";
66
+ /** 401:token 过期(客户端应重登录后重试) */
67
+ readonly TOKEN_EXPIRED: "AUTH_TOKEN_EXPIRED";
68
+ /** 403:身份不足以执行(匿名写操作 / dev-login 关闭等) */
69
+ readonly FORBIDDEN: "AUTH_FORBIDDEN";
70
+ /** 403:dev-login 在生产/关闭态被禁 */
71
+ readonly DEV_LOGIN_DISABLED: "AUTH_DEV_LOGIN_DISABLED";
72
+ /** 502:外部 provider 错误 */
73
+ readonly EXTERNAL_ERROR: "AUTH_EXTERNAL_ERROR";
74
+ /** 503:密钥链缺失(prod fail-fast) */
75
+ readonly MISSING_SECRET: "AUTH_MISSING_SECRET";
76
+ };
77
+ export type AuthErrorCode = (typeof AUTH_ERROR_CODES)[keyof typeof AUTH_ERROR_CODES];
78
+ /** 错误码 → HTTP 状态(客户端行为映射:401 重登录 / 403 提示 / 502 重试 / 503 配置) */
79
+ export declare function authCodeToStatus(code: AuthErrorCode): number;
@@ -0,0 +1,6 @@
1
+ export * from './protocol';
2
+ export * from './cards';
3
+ export * from './adapters';
4
+ export * from './identity';
5
+ export * from './session';
6
+ export * from './tts';
@@ -0,0 +1,90 @@
1
+ /**
2
+ * WebSocket 通信协议
3
+ * 基于 AG-UI (@ag-ui/core) 事件模型扩展,传输层走 WebSocket
4
+ */
5
+ import { EventType } from '@ag-ui/core';
6
+ import type { RunStartedEvent, RunFinishedEvent, RunErrorEvent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallResultEvent, ReasoningStartEvent, ReasoningMessageStartEvent, ReasoningMessageContentEvent, ReasoningMessageEndEvent, ReasoningEndEvent, StateSnapshotEvent, StateDeltaEvent, CustomEvent } from '@ag-ui/core';
7
+ export { EventType };
8
+ export type { RunStartedEvent, RunFinishedEvent, RunErrorEvent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallResultEvent, ReasoningStartEvent, ReasoningMessageStartEvent, ReasoningMessageContentEvent, ReasoningMessageEndEvent, ReasoningEndEvent, StateSnapshotEvent, StateDeltaEvent, CustomEvent, };
9
+ type RunScopedErrorEvent = RunErrorEvent & {
10
+ threadId?: string;
11
+ runId?: string;
12
+ };
13
+ /** 所有服务端 → 客户端事件 */
14
+ export type ServerEvent = RunStartedEvent | RunFinishedEvent | RunScopedErrorEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent | ReasoningStartEvent | ReasoningMessageStartEvent | ReasoningMessageContentEvent | ReasoningMessageEndEvent | ReasoningEndEvent | StateSnapshotEvent | StateDeltaEvent | CustomEvent;
15
+ export interface SendMessageMediaItem {
16
+ fileId: string;
17
+ type: 'image' | 'video' | 'audio' | 'file';
18
+ name?: string;
19
+ mimeType?: string;
20
+ }
21
+ /**
22
+ * 客户端 → 服务端会话键:conversationId 是唯一会话键(006 D5,运行+持久化统一)。
23
+ * - 有会话(local/external/dev):携带 /api/conversation/create 返回的 conversationId;
24
+ * - 匿名(optional 模式,未签发 JWT、不可建会话):缺省该字段,服务端按连接级
25
+ * fallback 键(连接级身份 + 本轮 run)处理,不落库。
26
+ */
27
+ export interface SendMessageEvent {
28
+ type: 'SEND_MESSAGE';
29
+ content: string;
30
+ /** 会话 ID(唯一会话键,运行 + 持久化统一);匿名对话可缺省 */
31
+ conversationId?: string;
32
+ /** 用户上传的媒体文件(仅携带 fileId,SDK 直传后的引用) */
33
+ mediaItems?: SendMessageMediaItem[];
34
+ /** 输入方式 */
35
+ inputMethod?: string;
36
+ }
37
+ export interface CancelRunEvent {
38
+ type: 'CANCEL_RUN';
39
+ /** 会话 ID(同 SEND_MESSAGE.conversationId);匿名对话可缺省(服务端按连接最近 run 定位) */
40
+ conversationId?: string;
41
+ /** 当前 runId,用于避免迟到的取消事件误取消同会话的下一轮回答 */
42
+ runId?: string;
43
+ }
44
+ /**
45
+ * WS 连接握手事件。客户端在 onOpen 时发送一次,**只做鉴权**(006 D6/D12):
46
+ * - 携带自有 JWT(消息体传输,不拼 URL,防泄漏);
47
+ * - 服务端校验后绑定连接级身份(Identity + 可选外部凭据);
48
+ * - optional 模式下无 token 的 HELLO → 服务端生成匿名身份并绑定;
49
+ * - 业务事件(SEND_MESSAGE/UI_ACTION/CANCEL_RUN)必须发生在身份绑定之后(顺序门控)。
50
+ */
51
+ export interface HelloEvent {
52
+ type: 'HELLO';
53
+ token?: string;
54
+ }
55
+ /**
56
+ * 卡片反向通道动作。
57
+ * - sendMessage value 作为用户消息走 chat 流程;visible=false 时不显示在聊天历史
58
+ * - submitForm formData 由 client React 卡片通过 sendUiAction 收集,作为虚拟 tool result 注入 Agent 上下文
59
+ * - openLink 客户端本地处理,不应发到服务端
60
+ * - toast 客户端本地轻提示,不应发到服务端
61
+ * - closeCard 客户端本地关闭卡片,不应发到服务端
62
+ */
63
+ export type UiClientAction = {
64
+ type: 'sendMessage';
65
+ value: string;
66
+ visible?: boolean;
67
+ } | {
68
+ type: 'submitForm';
69
+ formId: string;
70
+ } | {
71
+ type: 'openLink';
72
+ url: string;
73
+ } | {
74
+ type: 'toast';
75
+ content: string;
76
+ tone?: 'info' | 'success' | 'error';
77
+ } | {
78
+ type: 'closeCard';
79
+ };
80
+ export interface UiActionEvent {
81
+ type: 'UI_ACTION';
82
+ /** 会话 ID(同 SEND_MESSAGE.conversationId) */
83
+ conversationId?: string;
84
+ /** 卡片实例 id(协议字段名沿用历史 surfaceId) */
85
+ surfaceId: string;
86
+ action: UiClientAction;
87
+ /** submitForm 时携带的表单数据(由 client React 卡片构造) */
88
+ formData?: Record<string, unknown>;
89
+ }
90
+ export type ClientEvent = SendMessageEvent | CancelRunEvent | UiActionEvent | HelloEvent;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 契约包协议常量(004 D5:契约包允许协议常量级运行时值)。
3
+ * .d.ts 为主(tsc emitDeclarationOnly);本文件为唯一运行时 JS(经 tsup/esbuild 出 dist/runtime.js)。
4
+ * 修订 001 §2.6"契约包 types-only"表述:types-only 为主,允许协议常量级运行时值。
5
+ */
6
+ export { EventType } from '@ag-ui/core';
7
+ export { TBOX_CARD_EVENT_NAME } from './cards';
8
+ export { AUTH_ERROR_CODES, authCodeToStatus } from './identity';
@@ -0,0 +1,43 @@
1
+ // src/runtime.ts
2
+ import { EventType } from "@ag-ui/core";
3
+
4
+ // src/cards.ts
5
+ var TBOX_CARD_EVENT_NAME = "tbox:card";
6
+
7
+ // src/identity.ts
8
+ var AUTH_ERROR_CODES = {
9
+ /** 401:凭证缺失/非法 */
10
+ UNAUTHORIZED: "AUTH_UNAUTHORIZED",
11
+ /** 401:token 过期(客户端应重登录后重试) */
12
+ TOKEN_EXPIRED: "AUTH_TOKEN_EXPIRED",
13
+ /** 403:身份不足以执行(匿名写操作 / dev-login 关闭等) */
14
+ FORBIDDEN: "AUTH_FORBIDDEN",
15
+ /** 403:dev-login 在生产/关闭态被禁 */
16
+ DEV_LOGIN_DISABLED: "AUTH_DEV_LOGIN_DISABLED",
17
+ /** 502:外部 provider 错误 */
18
+ EXTERNAL_ERROR: "AUTH_EXTERNAL_ERROR",
19
+ /** 503:密钥链缺失(prod fail-fast) */
20
+ MISSING_SECRET: "AUTH_MISSING_SECRET"
21
+ };
22
+ function authCodeToStatus(code) {
23
+ switch (code) {
24
+ case AUTH_ERROR_CODES.UNAUTHORIZED:
25
+ case AUTH_ERROR_CODES.TOKEN_EXPIRED:
26
+ return 401;
27
+ case AUTH_ERROR_CODES.FORBIDDEN:
28
+ case AUTH_ERROR_CODES.DEV_LOGIN_DISABLED:
29
+ return 403;
30
+ case AUTH_ERROR_CODES.EXTERNAL_ERROR:
31
+ return 502;
32
+ case AUTH_ERROR_CODES.MISSING_SECRET:
33
+ return 503;
34
+ default:
35
+ return 401;
36
+ }
37
+ }
38
+ export {
39
+ AUTH_ERROR_CODES,
40
+ EventType,
41
+ TBOX_CARD_EVENT_NAME,
42
+ authCodeToStatus
43
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 平台能力凭证 DTO(006 D10 命名消歧:tboxSessionId,区别于已移除的 auth session)。
3
+ * TIER0 types-only;server 签发(GET /api/tbox/session),client 消费并缓存。
4
+ */
5
+ export interface TboxSessionData {
6
+ /** 平台能力会话 id(TTS/ASR 等能力凭证,区别于 auth token) */
7
+ tboxSessionId: string;
8
+ /** 能力通道(如 'web' / 'alipay') */
9
+ channel: string;
10
+ /** 应用 id(平台侧标识) */
11
+ appId: string;
12
+ }
package/dist/tts.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * TTS 协议类型(TIER0 types-only,双端共享)。
3
+ *
4
+ * 服务端 TTS 代理(app-sdk/server/tts)与客户端 TTS 适配器(app-sdk/client/adapters)
5
+ * 经 WS 传输的消息形态;`config` 随 START_TTS 下发,透传给 @tbox-dev-js/sdk 的 TboxTtsClient。
6
+ *
7
+ * 注意:TtsVoiceConfig 为 contracts 自有类型(开放索引,不依赖 @tbox-dev-js/sdk),
8
+ * 常见字段显式声明便于双端使用,其余字段透传。
9
+ */
10
+ export interface TtsVoiceConfig {
11
+ voiceCode?: string;
12
+ /** 发音人类型(如 "SYSTEM") */
13
+ voiceType?: string;
14
+ sampleRate?: number;
15
+ volume?: number;
16
+ speechRate?: number;
17
+ pitchRate?: number;
18
+ [key: string]: unknown;
19
+ }
20
+ /** Client -> Server WebSocket message types */
21
+ export type TtsClientMessage = {
22
+ type: 'START_TTS';
23
+ config?: TtsVoiceConfig;
24
+ } | {
25
+ type: 'TTS_TEXT';
26
+ text: string;
27
+ } | {
28
+ type: 'TTS_FINISH';
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-contracts",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "平台契约(TIER0,types-only 为主 + 协议常量运行时值):卡片协议 / SDK adapter / 平台 DTO。",
6
6
  "exports": {