@siact/sime-x-vue 0.0.9 → 0.0.11
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/dist/sime-x-vue.mjs +874 -964
- package/dist/sime-x-vue.mjs.map +1 -1
- package/dist/sime-x-vue.umd.js +877 -966
- package/dist/sime-x-vue.umd.js.map +1 -1
- package/dist/style.css +373 -797
- package/package.json +6 -5
- package/types/DevApp.vue.d.ts +2 -2
- package/types/components/ai-chat.vue.d.ts +47 -0
- package/types/components/sime-provider.vue.d.ts +26 -49
- package/types/components/test.vue.d.ts +2 -2
- package/types/components/tool-card.vue.d.ts +12 -28
- package/types/components/voice-assistant.vue.d.ts +24 -44
- package/types/components/voice-status.vue.d.ts +8 -20
- package/types/composables/index.d.ts +6 -6
- package/types/composables/use-agent-invoke.d.ts +79 -79
- package/types/composables/use-bubble.d.ts +41 -41
- package/types/composables/use-tts.d.ts +18 -18
- package/types/composables/use-voice-recognition.d.ts +28 -28
- package/types/index.d.ts +7 -5
- package/types/injection-key.d.ts +6 -6
- package/types/lib/agent-chat-transport.d.ts +35 -0
- package/types/lib/data-stream-parser.d.ts +84 -84
- package/types/lib/utils.d.ts +14 -14
- package/types/main.d.ts +1 -1
- package/types/types.d.ts +45 -54
- package/types/utils/command-manager.d.ts +16 -0
- package/types/utils/command-types.d.ts +20 -0
- package/types/utils/index.d.ts +2 -0
- package/types/components/execution-status.vue.d.ts +0 -17
- package/types/components/sime-x.vue.d.ts +0 -43
- package/types/debug-page.vue.d.ts +0 -2
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import type { VoiceConfig } from '../types';
|
|
2
|
-
export type VoiceStatus = 'standby' | 'listening';
|
|
3
|
-
export interface UseVoiceRecognitionOptions {
|
|
4
|
-
modelPath?: string;
|
|
5
|
-
wakeWords?: string[];
|
|
6
|
-
getVoiceConfig: () => VoiceConfig | null;
|
|
7
|
-
/** 唤醒时回调 */
|
|
8
|
-
onWake?: () => void;
|
|
9
|
-
/** 转写完成(autoStop)时回调 */
|
|
10
|
-
onTranscriptionDone?: (text: string) => void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 语音识别 composable
|
|
14
|
-
*
|
|
15
|
-
* 管理唤醒词检测器 + 语音转写器的生命周期。
|
|
16
|
-
*/
|
|
17
|
-
export declare function useVoiceRecognition(options: UseVoiceRecognitionOptions): {
|
|
18
|
-
voiceStatus: import("vue").Ref<VoiceStatus, VoiceStatus>;
|
|
19
|
-
isTranscribing: import("vue").Ref<boolean, boolean>;
|
|
20
|
-
isInitializing: import("vue").Ref<boolean, boolean>;
|
|
21
|
-
transcriptionText: import("vue").Ref<string, string>;
|
|
22
|
-
wakeAnimating: import("vue").Ref<boolean, boolean>;
|
|
23
|
-
startTranscribing: () => Promise<void>;
|
|
24
|
-
stopTranscribing: () => Promise<void>;
|
|
25
|
-
abortTranscription: () => Promise<void>;
|
|
26
|
-
toggleVoiceMode: (targetState?: boolean) => Promise<void>;
|
|
27
|
-
destroy: () => Promise<void>;
|
|
28
|
-
};
|
|
1
|
+
import type { VoiceConfig } from '../types';
|
|
2
|
+
export type VoiceStatus = 'standby' | 'listening';
|
|
3
|
+
export interface UseVoiceRecognitionOptions {
|
|
4
|
+
modelPath?: string;
|
|
5
|
+
wakeWords?: string[];
|
|
6
|
+
getVoiceConfig: () => VoiceConfig | null;
|
|
7
|
+
/** 唤醒时回调 */
|
|
8
|
+
onWake?: () => void;
|
|
9
|
+
/** 转写完成(autoStop)时回调 */
|
|
10
|
+
onTranscriptionDone?: (text: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 语音识别 composable
|
|
14
|
+
*
|
|
15
|
+
* 管理唤醒词检测器 + 语音转写器的生命周期。
|
|
16
|
+
*/
|
|
17
|
+
export declare function useVoiceRecognition(options: UseVoiceRecognitionOptions): {
|
|
18
|
+
voiceStatus: import("vue").Ref<VoiceStatus, VoiceStatus>;
|
|
19
|
+
isTranscribing: import("vue").Ref<boolean, boolean>;
|
|
20
|
+
isInitializing: import("vue").Ref<boolean, boolean>;
|
|
21
|
+
transcriptionText: import("vue").Ref<string, string>;
|
|
22
|
+
wakeAnimating: import("vue").Ref<boolean, boolean>;
|
|
23
|
+
startTranscribing: () => Promise<void>;
|
|
24
|
+
stopTranscribing: () => Promise<void>;
|
|
25
|
+
abortTranscription: () => Promise<void>;
|
|
26
|
+
toggleVoiceMode: (targetState?: boolean) => Promise<void>;
|
|
27
|
+
destroy: () => Promise<void>;
|
|
28
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as AiChatbotVoiceAssistant } from './components/voice-assistant.vue';
|
|
4
|
-
export * from './injection-key';
|
|
5
|
-
export
|
|
1
|
+
export { default as AiChat } from './components/ai-chat.vue';
|
|
2
|
+
export { default as AiChatbotProvider } from './components/sime-provider.vue';
|
|
3
|
+
export { default as AiChatbotVoiceAssistant } from './components/voice-assistant.vue';
|
|
4
|
+
export * from './injection-key';
|
|
5
|
+
export { AgentChatTransport, createAgentChatTransport } from './lib/agent-chat-transport';
|
|
6
|
+
export type { AgentChatTransportOptions } from './lib/agent-chat-transport';
|
|
7
|
+
export * from './types';
|
package/types/injection-key.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { InjectionKey } from 'vue';
|
|
2
|
-
import type { AiChatbotXContext } from './types';
|
|
3
|
-
export declare const AiChatbotXKey: InjectionKey<AiChatbotXContext>;
|
|
4
|
-
export declare function injectStrict<T>(key: InjectionKey<T>): T;
|
|
5
|
-
export declare function injectStrict<T>(key: InjectionKey<T>, defaultValue: T, treatDefaultAsFactory?: false): T;
|
|
6
|
-
export declare function injectStrict<T>(key: InjectionKey<T>, defaultValue: T | (() => T), treatDefaultAsFactory: true): T;
|
|
1
|
+
import type { InjectionKey } from 'vue';
|
|
2
|
+
import type { AiChatbotXContext } from './types';
|
|
3
|
+
export declare const AiChatbotXKey: InjectionKey<AiChatbotXContext>;
|
|
4
|
+
export declare function injectStrict<T>(key: InjectionKey<T>): T;
|
|
5
|
+
export declare function injectStrict<T>(key: InjectionKey<T>, defaultValue: T, treatDefaultAsFactory?: false): T;
|
|
6
|
+
export declare function injectStrict<T>(key: InjectionKey<T>, defaultValue: T | (() => T), treatDefaultAsFactory: true): T;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { UIMessage } from 'ai';
|
|
2
|
+
import { DefaultChatTransport } from 'ai';
|
|
3
|
+
import type { DiscoveredCommand } from '../utils/command-types';
|
|
4
|
+
export interface AgentChatTransportOptions {
|
|
5
|
+
/** streamInvoke endpoint URL, e.g. http://host/agent/{id}/stream-invoke */
|
|
6
|
+
api: string;
|
|
7
|
+
/** 项目 ID */
|
|
8
|
+
projectId?: string;
|
|
9
|
+
/** 动态获取宿主命令 */
|
|
10
|
+
getCommands?: () => Promise<DiscoveredCommand[]>;
|
|
11
|
+
/** 额外 headers */
|
|
12
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
13
|
+
/** 额外 body 字段 */
|
|
14
|
+
body?: Record<string, unknown> | (() => Record<string, unknown>);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 基于 DefaultChatTransport 的自定义 Transport,
|
|
18
|
+
* 通过 prepareSendMessagesRequest 将 AI SDK 标准 messages 转换为 streamInvoke 接口格式。
|
|
19
|
+
*
|
|
20
|
+
* streamInvoke 期望:{ input, projectId, commands, messages }
|
|
21
|
+
* - input: 最后一条 user 消息的文本
|
|
22
|
+
* - messages: 历史对话(不含最后一条 user 消息)
|
|
23
|
+
* - commands: 宿主命令列表
|
|
24
|
+
* - projectId: 项目 ID
|
|
25
|
+
*/
|
|
26
|
+
export declare function createAgentChatTransport(options: AgentChatTransportOptions): DefaultChatTransport<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>;
|
|
27
|
+
/**
|
|
28
|
+
* 带命令注入的 AgentChatTransport 工厂函数
|
|
29
|
+
* 在每次发送前异步获取宿主命令并注入 body
|
|
30
|
+
*/
|
|
31
|
+
export declare class AgentChatTransport extends DefaultChatTransport<UIMessage> {
|
|
32
|
+
private agentOptions;
|
|
33
|
+
constructor(options: AgentChatTransportOptions);
|
|
34
|
+
sendMessages(options: Parameters<DefaultChatTransport<UIMessage>['sendMessages']>[0]): Promise<ReadableStream<import("ai").UIMessageChunk<unknown, import("ai").UIDataTypes>>>;
|
|
35
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI SDK Stream Protocol Parser for Vue
|
|
3
|
-
*
|
|
4
|
-
* Handles THREE possible response formats from the agent/chat service:
|
|
5
|
-
*
|
|
6
|
-
* Format A – UI Message Stream Protocol (pipeUIMessageStreamToResponse) ★ PRIMARY
|
|
7
|
-
* SSE format with JSON objects containing a "type" field:
|
|
8
|
-
* data: {"type":"start","messageId":"..."}
|
|
9
|
-
* data: {"type":"text-delta","id":"...","delta":"Hello"}
|
|
10
|
-
* data: {"type":"tool-input-start","toolCallId":"...","toolName":"..."}
|
|
11
|
-
* data: {"type":"tool-input-delta","toolCallId":"...","inputTextDelta":"..."}
|
|
12
|
-
* data: {"type":"tool-input-available","toolCallId":"...","toolName":"...","input":{...}}
|
|
13
|
-
* data: {"type":"tool-output-available","toolCallId":"...","output":{...}}
|
|
14
|
-
* data: {"type":"finish-step"}
|
|
15
|
-
* data: {"type":"finish"}
|
|
16
|
-
* data: [DONE]
|
|
17
|
-
*
|
|
18
|
-
* Format B – Legacy Data Stream Protocol (pipeDataStreamToResponse)
|
|
19
|
-
* Each line: CODE:JSON_VALUE\n
|
|
20
|
-
* 0:"text" 9:{toolCallId,toolName} c:{toolCallId,toolName,args} a:{toolCallId,result}
|
|
21
|
-
*
|
|
22
|
-
* Format C – Plain text stream (pipeTextStreamToResponse fallback)
|
|
23
|
-
* Raw UTF-8 text chunks with no protocol framing.
|
|
24
|
-
*
|
|
25
|
-
* The parser auto-detects the format from the first chunk.
|
|
26
|
-
*/
|
|
27
|
-
export type ToolState = 'partial-call' | 'call' | 'result' | 'error';
|
|
28
|
-
export interface TextPart {
|
|
29
|
-
type: 'text';
|
|
30
|
-
text: string;
|
|
31
|
-
}
|
|
32
|
-
export interface ToolCallPart {
|
|
33
|
-
type: 'tool-call';
|
|
34
|
-
toolCallId: string;
|
|
35
|
-
toolName: string;
|
|
36
|
-
args: any;
|
|
37
|
-
state: ToolState;
|
|
38
|
-
}
|
|
39
|
-
export interface ToolResultPart {
|
|
40
|
-
type: 'tool-result';
|
|
41
|
-
toolCallId: string;
|
|
42
|
-
toolName: string;
|
|
43
|
-
args: any;
|
|
44
|
-
result: any;
|
|
45
|
-
state: ToolState;
|
|
46
|
-
}
|
|
47
|
-
export type MessagePart = TextPart | ToolCallPart | ToolResultPart;
|
|
48
|
-
export interface StreamMessage {
|
|
49
|
-
id: string;
|
|
50
|
-
role: 'user' | 'assistant';
|
|
51
|
-
parts: MessagePart[];
|
|
52
|
-
createdAt: number;
|
|
53
|
-
}
|
|
54
|
-
interface ToolCallTracker {
|
|
55
|
-
toolCallId: string;
|
|
56
|
-
toolName: string;
|
|
57
|
-
argsText: string;
|
|
58
|
-
args: any;
|
|
59
|
-
result?: any;
|
|
60
|
-
state: ToolState;
|
|
61
|
-
}
|
|
62
|
-
export type StreamEventType = 'text-delta' | 'tool-call-start' | 'tool-call-delta' | 'tool-call-complete' | 'tool-result' | 'step-finish' | 'finish' | 'error';
|
|
63
|
-
export interface StreamEvent {
|
|
64
|
-
type: StreamEventType;
|
|
65
|
-
data: any;
|
|
66
|
-
}
|
|
67
|
-
export interface DataStreamCallbacks {
|
|
68
|
-
onTextDelta?: (text: string) => void;
|
|
69
|
-
onToolCallStart?: (toolCallId: string, toolName: string) => void;
|
|
70
|
-
onToolCallDelta?: (toolCallId: string, argsTextDelta: string) => void;
|
|
71
|
-
onToolCallComplete?: (toolCallId: string, toolName: string, args: any) => void;
|
|
72
|
-
onToolResult?: (toolCallId: string, result: any) => void;
|
|
73
|
-
onStepFinish?: (data: any) => void;
|
|
74
|
-
onFinish?: (data: any) => void;
|
|
75
|
-
onError?: (error: string) => void;
|
|
76
|
-
}
|
|
77
|
-
export declare function readDataStream(response: Response, callbacks: DataStreamCallbacks): Promise<void>;
|
|
78
|
-
export interface StreamParseResult {
|
|
79
|
-
textContent: string;
|
|
80
|
-
parts: MessagePart[];
|
|
81
|
-
toolCalls: Map<string, ToolCallTracker>;
|
|
82
|
-
}
|
|
83
|
-
export declare function parseDataStreamToMessage(response: Response, onUpdate: (result: StreamParseResult) => void): Promise<StreamParseResult>;
|
|
84
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK Stream Protocol Parser for Vue
|
|
3
|
+
*
|
|
4
|
+
* Handles THREE possible response formats from the agent/chat service:
|
|
5
|
+
*
|
|
6
|
+
* Format A – UI Message Stream Protocol (pipeUIMessageStreamToResponse) ★ PRIMARY
|
|
7
|
+
* SSE format with JSON objects containing a "type" field:
|
|
8
|
+
* data: {"type":"start","messageId":"..."}
|
|
9
|
+
* data: {"type":"text-delta","id":"...","delta":"Hello"}
|
|
10
|
+
* data: {"type":"tool-input-start","toolCallId":"...","toolName":"..."}
|
|
11
|
+
* data: {"type":"tool-input-delta","toolCallId":"...","inputTextDelta":"..."}
|
|
12
|
+
* data: {"type":"tool-input-available","toolCallId":"...","toolName":"...","input":{...}}
|
|
13
|
+
* data: {"type":"tool-output-available","toolCallId":"...","output":{...}}
|
|
14
|
+
* data: {"type":"finish-step"}
|
|
15
|
+
* data: {"type":"finish"}
|
|
16
|
+
* data: [DONE]
|
|
17
|
+
*
|
|
18
|
+
* Format B – Legacy Data Stream Protocol (pipeDataStreamToResponse)
|
|
19
|
+
* Each line: CODE:JSON_VALUE\n
|
|
20
|
+
* 0:"text" 9:{toolCallId,toolName} c:{toolCallId,toolName,args} a:{toolCallId,result}
|
|
21
|
+
*
|
|
22
|
+
* Format C – Plain text stream (pipeTextStreamToResponse fallback)
|
|
23
|
+
* Raw UTF-8 text chunks with no protocol framing.
|
|
24
|
+
*
|
|
25
|
+
* The parser auto-detects the format from the first chunk.
|
|
26
|
+
*/
|
|
27
|
+
export type ToolState = 'partial-call' | 'call' | 'result' | 'error';
|
|
28
|
+
export interface TextPart {
|
|
29
|
+
type: 'text';
|
|
30
|
+
text: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ToolCallPart {
|
|
33
|
+
type: 'tool-call';
|
|
34
|
+
toolCallId: string;
|
|
35
|
+
toolName: string;
|
|
36
|
+
args: any;
|
|
37
|
+
state: ToolState;
|
|
38
|
+
}
|
|
39
|
+
export interface ToolResultPart {
|
|
40
|
+
type: 'tool-result';
|
|
41
|
+
toolCallId: string;
|
|
42
|
+
toolName: string;
|
|
43
|
+
args: any;
|
|
44
|
+
result: any;
|
|
45
|
+
state: ToolState;
|
|
46
|
+
}
|
|
47
|
+
export type MessagePart = TextPart | ToolCallPart | ToolResultPart;
|
|
48
|
+
export interface StreamMessage {
|
|
49
|
+
id: string;
|
|
50
|
+
role: 'user' | 'assistant';
|
|
51
|
+
parts: MessagePart[];
|
|
52
|
+
createdAt: number;
|
|
53
|
+
}
|
|
54
|
+
interface ToolCallTracker {
|
|
55
|
+
toolCallId: string;
|
|
56
|
+
toolName: string;
|
|
57
|
+
argsText: string;
|
|
58
|
+
args: any;
|
|
59
|
+
result?: any;
|
|
60
|
+
state: ToolState;
|
|
61
|
+
}
|
|
62
|
+
export type StreamEventType = 'text-delta' | 'tool-call-start' | 'tool-call-delta' | 'tool-call-complete' | 'tool-result' | 'step-finish' | 'finish' | 'error';
|
|
63
|
+
export interface StreamEvent {
|
|
64
|
+
type: StreamEventType;
|
|
65
|
+
data: any;
|
|
66
|
+
}
|
|
67
|
+
export interface DataStreamCallbacks {
|
|
68
|
+
onTextDelta?: (text: string) => void;
|
|
69
|
+
onToolCallStart?: (toolCallId: string, toolName: string) => void;
|
|
70
|
+
onToolCallDelta?: (toolCallId: string, argsTextDelta: string) => void;
|
|
71
|
+
onToolCallComplete?: (toolCallId: string, toolName: string, args: any) => void;
|
|
72
|
+
onToolResult?: (toolCallId: string, result: any) => void;
|
|
73
|
+
onStepFinish?: (data: any) => void;
|
|
74
|
+
onFinish?: (data: any) => void;
|
|
75
|
+
onError?: (error: string, data?: any) => void;
|
|
76
|
+
}
|
|
77
|
+
export declare function readDataStream(response: Response, callbacks: DataStreamCallbacks): Promise<void>;
|
|
78
|
+
export interface StreamParseResult {
|
|
79
|
+
textContent: string;
|
|
80
|
+
parts: MessagePart[];
|
|
81
|
+
toolCalls: Map<string, ToolCallTracker>;
|
|
82
|
+
}
|
|
83
|
+
export declare function parseDataStreamToMessage(response: Response, onUpdate: (result: StreamParseResult) => void): Promise<StreamParseResult>;
|
|
84
|
+
export {};
|
package/types/lib/utils.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { DiscoveredCommand } from '
|
|
2
|
-
export declare const ensureMicrophonePermission: () => Promise<boolean>;
|
|
3
|
-
/**
|
|
4
|
-
* 语音命令匹配函数
|
|
5
|
-
* @param {string} userInput - 用户输入的原始语音文本
|
|
6
|
-
* @param {Array} commandList - 命令列表对象数组
|
|
7
|
-
* @param {number} threshold - 相似度阈值 (0-1),默认 0.5
|
|
8
|
-
*/
|
|
9
|
-
export declare function matchVoiceCommand(userInput: string, commandList: DiscoveredCommand[], threshold?: number): {
|
|
10
|
-
confidence: number;
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
parameters?: import("
|
|
14
|
-
} | null;
|
|
1
|
+
import { DiscoveredCommand } from '../utils/command-types';
|
|
2
|
+
export declare const ensureMicrophonePermission: () => Promise<boolean>;
|
|
3
|
+
/**
|
|
4
|
+
* 语音命令匹配函数
|
|
5
|
+
* @param {string} userInput - 用户输入的原始语音文本
|
|
6
|
+
* @param {Array} commandList - 命令列表对象数组
|
|
7
|
+
* @param {number} threshold - 相似度阈值 (0-1),默认 0.5
|
|
8
|
+
*/
|
|
9
|
+
export declare function matchVoiceCommand(userInput: string, commandList: DiscoveredCommand[], threshold?: number): {
|
|
10
|
+
confidence: number;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
parameters?: import("../utils/command-types").CommandParameter[];
|
|
14
|
+
} | null;
|
package/types/main.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/types/types.d.ts
CHANGED
|
@@ -1,54 +1,45 @@
|
|
|
1
|
-
import type { CommandDefinition, DiscoveredCommand } from '
|
|
2
|
-
export declare enum clientCommandKey {
|
|
3
|
-
SET_THEME = "SiMeAgent_setTheme",
|
|
4
|
-
APPEND_MESSAGE = "SiMeAgent_appendMessage",
|
|
5
|
-
WAKE = "SiMeAgent_wake",
|
|
6
|
-
TRANSITION = "SiMeAgent_transition",
|
|
7
|
-
TRANSITION_END = "SiMeAgent_transition_end",
|
|
8
|
-
START_NEW_CONVERSATION = "SiMeAgent_startNewConversation",
|
|
9
|
-
RECOGNITION = "SiMeAgent_recognition"
|
|
10
|
-
}
|
|
11
|
-
export interface VoiceConfig {
|
|
12
|
-
appId: string;
|
|
13
|
-
/** STT(语音转写)apiKey */
|
|
14
|
-
apiKey: string;
|
|
15
|
-
/** apiSecret,TTS 鉴权必需 */
|
|
16
|
-
apiSecret?: string;
|
|
17
|
-
/** STT(语音转写)WebSocket 地址 */
|
|
18
|
-
websocketUrl: string;
|
|
19
|
-
/** TTS apiKey(可选,不填则复用 apiKey) */
|
|
20
|
-
ttsApiKey?: string;
|
|
21
|
-
/** TTS(语音合成)WebSocket 地址 */
|
|
22
|
-
ttsWebsocketUrl?: string;
|
|
23
|
-
/** TTS 发音人,默认 xiaoyan */
|
|
24
|
-
ttsVcn?: string;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
toggleCollapse: () => Promise<void>;
|
|
47
|
-
openDialog: () => Promise<void>;
|
|
48
|
-
closeDialog: () => Promise<void>;
|
|
49
|
-
}) => void;
|
|
50
|
-
startNewConversation: () => Promise<void>;
|
|
51
|
-
setIframeElement: (iframe: HTMLIFrameElement) => void;
|
|
52
|
-
recognition: (message: string, commands: DiscoveredCommand[]) => Promise<any>;
|
|
53
|
-
executeCommand: (commandName: string, args?: any[]) => Promise<any>;
|
|
54
|
-
}
|
|
1
|
+
import type { CommandDefinition, DiscoveredCommand } from './utils/command-types';
|
|
2
|
+
export declare enum clientCommandKey {
|
|
3
|
+
SET_THEME = "SiMeAgent_setTheme",
|
|
4
|
+
APPEND_MESSAGE = "SiMeAgent_appendMessage",
|
|
5
|
+
WAKE = "SiMeAgent_wake",
|
|
6
|
+
TRANSITION = "SiMeAgent_transition",
|
|
7
|
+
TRANSITION_END = "SiMeAgent_transition_end",
|
|
8
|
+
START_NEW_CONVERSATION = "SiMeAgent_startNewConversation",
|
|
9
|
+
RECOGNITION = "SiMeAgent_recognition"
|
|
10
|
+
}
|
|
11
|
+
export interface VoiceConfig {
|
|
12
|
+
appId: string;
|
|
13
|
+
/** STT(语音转写)apiKey */
|
|
14
|
+
apiKey: string;
|
|
15
|
+
/** apiSecret,TTS 鉴权必需 */
|
|
16
|
+
apiSecret?: string;
|
|
17
|
+
/** STT(语音转写)WebSocket 地址 */
|
|
18
|
+
websocketUrl: string;
|
|
19
|
+
/** TTS apiKey(可选,不填则复用 apiKey) */
|
|
20
|
+
ttsApiKey?: string;
|
|
21
|
+
/** TTS(语音合成)WebSocket 地址 */
|
|
22
|
+
ttsWebsocketUrl?: string;
|
|
23
|
+
/** TTS 发音人,默认 xiaoyan */
|
|
24
|
+
ttsVcn?: string;
|
|
25
|
+
/** TTS 发音速度 */
|
|
26
|
+
speed?: number;
|
|
27
|
+
/** TTS 发音音量 */
|
|
28
|
+
volume?: number;
|
|
29
|
+
/** TTS 发音音调 */
|
|
30
|
+
pitch?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface AiChatbotXContext {
|
|
33
|
+
chatbotUrl: () => string;
|
|
34
|
+
appId: () => string;
|
|
35
|
+
appToken: () => string;
|
|
36
|
+
registerCommand: (cmd: CommandDefinition) => void;
|
|
37
|
+
unregisterCommand: (name: string) => void;
|
|
38
|
+
getCommads: () => Promise<DiscoveredCommand[]>;
|
|
39
|
+
/** 中止当前语音播报并关闭气泡 */
|
|
40
|
+
stopBroadcast: () => Promise<void>;
|
|
41
|
+
registerVoiceMethods: (methods: {
|
|
42
|
+
stopBroadcast?: () => Promise<void>;
|
|
43
|
+
}) => void;
|
|
44
|
+
executeCommand: (commandName: string, args?: any[]) => Promise<any>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CommandDefinition, DiscoveredCommand } from './command-types';
|
|
2
|
+
export interface CommandManagerOptions {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class CommandManager {
|
|
6
|
+
private commands;
|
|
7
|
+
private debug;
|
|
8
|
+
constructor(options?: CommandManagerOptions);
|
|
9
|
+
registerCommand(command: CommandDefinition): void;
|
|
10
|
+
unregisterCommand(name: string): void;
|
|
11
|
+
executeCommand(command: string, args?: any[]): Promise<any>;
|
|
12
|
+
getCommands(): DiscoveredCommand[];
|
|
13
|
+
hasCommand(name: string): boolean;
|
|
14
|
+
clear(): void;
|
|
15
|
+
private log;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface CommandHandler {
|
|
2
|
+
(...args: any[]): any | Promise<any>;
|
|
3
|
+
}
|
|
4
|
+
export interface CommandParameter {
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
8
|
+
required: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface CommandDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
handler: CommandHandler;
|
|
14
|
+
parameters?: CommandParameter[];
|
|
15
|
+
}
|
|
16
|
+
export interface DiscoveredCommand {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
parameters?: CommandParameter[];
|
|
20
|
+
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
visible: boolean;
|
|
3
|
-
text?: string | undefined;
|
|
4
|
-
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
5
|
-
visible: boolean;
|
|
6
|
-
text?: string | undefined;
|
|
7
|
-
}>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
-
export default _default;
|
|
9
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
10
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
11
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
12
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
13
|
-
} : {
|
|
14
|
-
type: import('vue').PropType<T[K]>;
|
|
15
|
-
required: true;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
interface XSize {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
}
|
|
5
|
-
interface xDialogSize {
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
10
|
-
xLogo?: string | undefined;
|
|
11
|
-
xSize?: XSize | undefined;
|
|
12
|
-
xTitle?: string | undefined;
|
|
13
|
-
xTheme?: "light" | "dark" | "system" | undefined;
|
|
14
|
-
xDialogSize?: xDialogSize | undefined;
|
|
15
|
-
wakeWords?: string[] | undefined;
|
|
16
|
-
modelPath?: string | undefined;
|
|
17
|
-
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
-
"start-transcribing": () => void;
|
|
19
|
-
"stop-transcribing": () => void;
|
|
20
|
-
wakeUp: (isWake: boolean) => void;
|
|
21
|
-
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
22
|
-
xLogo?: string | undefined;
|
|
23
|
-
xSize?: XSize | undefined;
|
|
24
|
-
xTitle?: string | undefined;
|
|
25
|
-
xTheme?: "light" | "dark" | "system" | undefined;
|
|
26
|
-
xDialogSize?: xDialogSize | undefined;
|
|
27
|
-
wakeWords?: string[] | undefined;
|
|
28
|
-
modelPath?: string | undefined;
|
|
29
|
-
}>>> & Readonly<{
|
|
30
|
-
"onStart-transcribing"?: (() => any) | undefined;
|
|
31
|
-
"onStop-transcribing"?: (() => any) | undefined;
|
|
32
|
-
onWakeUp?: ((isWake: boolean) => any) | undefined;
|
|
33
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
34
|
-
export default _default;
|
|
35
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
36
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
37
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
38
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
39
|
-
} : {
|
|
40
|
-
type: import('vue').PropType<T[K]>;
|
|
41
|
-
required: true;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
export default _default;
|