@pmate/chat-sdk 0.2.1 → 0.2.2

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/lib/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export * from "./hooks/useChatInputState";
15
15
  export * from "./hooks/useTranscriptComposer";
16
16
  export * from "./hooks/useVoiceInputController";
17
17
  export * from "./services/functionASRClient";
18
+ export * from "./services/agentSdkASRClient";
18
19
  export * from "./services/authTokenResolver";
19
20
  export * from "./runtime/botAuth";
20
21
  export * from "./runtime/botKey";
package/lib/index.js CHANGED
@@ -15,6 +15,7 @@ export * from "./hooks/useChatInputState";
15
15
  export * from "./hooks/useTranscriptComposer";
16
16
  export * from "./hooks/useVoiceInputController";
17
17
  export * from "./services/functionASRClient";
18
+ export * from "./services/agentSdkASRClient";
18
19
  export * from "./services/authTokenResolver";
19
20
  export * from "./runtime/botAuth";
20
21
  export * from "./runtime/botKey";
@@ -0,0 +1,29 @@
1
+ import { AsyncStream } from "./AsyncStream";
2
+ export type AgentSdkStreamLike = {
3
+ stream<TFinal = unknown, TChunk = Blob>(request: {
4
+ agentId: string;
5
+ stream: AsyncStream<TChunk>;
6
+ params?: Record<string, unknown>;
7
+ minChunkSizeBytes?: number;
8
+ }): {
9
+ finish(): Promise<TFinal | null>;
10
+ };
11
+ };
12
+ export type AgentSdkASRClientOptions = {
13
+ client: AgentSdkStreamLike;
14
+ agentId: string;
15
+ tokenResolver?: {
16
+ getToken(): string;
17
+ };
18
+ minChunkSizeBytes?: number;
19
+ };
20
+ /** Compatibility adapter for streaming audio through @pmate/agent-sdk. */
21
+ export declare class AgentSdkASRClient {
22
+ private readonly options;
23
+ constructor(options: AgentSdkASRClientOptions);
24
+ transcribe(blob: Blob, input?: {
25
+ lang?: string;
26
+ }): Promise<{
27
+ text: string;
28
+ }>;
29
+ }
@@ -0,0 +1,21 @@
1
+ import { AsyncStream } from "./AsyncStream";
2
+ /** Compatibility adapter for streaming audio through @pmate/agent-sdk. */
3
+ export class AgentSdkASRClient {
4
+ options;
5
+ constructor(options) {
6
+ this.options = options;
7
+ }
8
+ async transcribe(blob, input) {
9
+ const token = this.options.tokenResolver?.getToken() ?? "";
10
+ const stream = new AsyncStream();
11
+ const task = this.options.client.stream({
12
+ agentId: this.options.agentId,
13
+ stream,
14
+ params: { lang: input?.lang ?? "auto", token },
15
+ minChunkSizeBytes: this.options.minChunkSizeBytes ?? 0,
16
+ });
17
+ stream.push(blob);
18
+ stream.end();
19
+ return { text: String((await task.finish()) ?? "").trim() };
20
+ }
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/chat-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Cross-platform PMate chat input components, voice input primitives, and ASR helpers",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",