@moureau/pipeflow 0.0.1
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 +201 -0
- package/README.md +833 -0
- package/dist/cjs/agents/agent.js +2 -0
- package/dist/cjs/agents/agent.js.map +7 -0
- package/dist/cjs/agents/index.js +2 -0
- package/dist/cjs/agents/index.js.map +7 -0
- package/dist/cjs/agents/tools/index.js +2 -0
- package/dist/cjs/agents/tools/index.js.map +7 -0
- package/dist/cjs/agents/tools/tools.js +2 -0
- package/dist/cjs/agents/tools/tools.js.map +7 -0
- package/dist/cjs/conversations/conversation/conversation.js +2 -0
- package/dist/cjs/conversations/conversation/conversation.js.map +7 -0
- package/dist/cjs/conversations/conversation/index.js +2 -0
- package/dist/cjs/conversations/conversation/index.js.map +7 -0
- package/dist/cjs/conversations/conversations.js +2 -0
- package/dist/cjs/conversations/conversations.js.map +7 -0
- package/dist/cjs/conversations/index.js +2 -0
- package/dist/cjs/conversations/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/index.js +2 -0
- package/dist/cjs/conversations/orchestration/orchestrator/index.js.map +7 -0
- package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js +3 -0
- package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js.map +7 -0
- package/dist/cjs/conversations/transcription/index.js +2 -0
- package/dist/cjs/conversations/transcription/index.js.map +7 -0
- package/dist/cjs/conversations/transcription/transcription.js +2 -0
- package/dist/cjs/conversations/transcription/transcription.js.map +7 -0
- package/dist/cjs/conversations/types.js +2 -0
- package/dist/cjs/conversations/types.js.map +7 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/persistence/adapters/index.js +2 -0
- package/dist/cjs/persistence/adapters/index.js.map +7 -0
- package/dist/cjs/persistence/adapters/memory/index.js +2 -0
- package/dist/cjs/persistence/adapters/memory/index.js.map +7 -0
- package/dist/cjs/persistence/adapters/memory/memory.js +2 -0
- package/dist/cjs/persistence/adapters/memory/memory.js.map +7 -0
- package/dist/cjs/persistence/adapters/sqlite/index.js +2 -0
- package/dist/cjs/persistence/adapters/sqlite/index.js.map +7 -0
- package/dist/cjs/persistence/adapters/sqlite/sqlite.js +58 -0
- package/dist/cjs/persistence/adapters/sqlite/sqlite.js.map +7 -0
- package/dist/cjs/persistence/index.js +2 -0
- package/dist/cjs/persistence/index.js.map +7 -0
- package/dist/cjs/persistence/persistence.js +2 -0
- package/dist/cjs/persistence/persistence.js.map +7 -0
- package/dist/cjs/providers/index.js +2 -0
- package/dist/cjs/providers/index.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js +2 -0
- package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/deepseek/index.js +2 -0
- package/dist/cjs/providers/llm/adapters/deepseek/index.js.map +7 -0
- package/dist/cjs/providers/llm/adapters/index.js +2 -0
- package/dist/cjs/providers/llm/adapters/index.js.map +7 -0
- package/dist/cjs/providers/llm/index.js +2 -0
- package/dist/cjs/providers/llm/index.js.map +7 -0
- package/dist/cjs/providers/llm/types.js +2 -0
- package/dist/cjs/providers/llm/types.js.map +7 -0
- package/dist/cjs/providers/shared.js +2 -0
- package/dist/cjs/providers/shared.js.map +7 -0
- package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js +2 -0
- package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js.map +7 -0
- package/dist/cjs/providers/stt/adapters/deepgram/index.js +2 -0
- package/dist/cjs/providers/stt/adapters/deepgram/index.js.map +7 -0
- package/dist/cjs/providers/stt/adapters/index.js +2 -0
- package/dist/cjs/providers/stt/adapters/index.js.map +7 -0
- package/dist/cjs/providers/stt/index.js +2 -0
- package/dist/cjs/providers/stt/index.js.map +7 -0
- package/dist/cjs/providers/stt/types.js +2 -0
- package/dist/cjs/providers/stt/types.js.map +7 -0
- package/dist/cjs/providers/tts/adapters/index.js +2 -0
- package/dist/cjs/providers/tts/adapters/index.js.map +7 -0
- package/dist/cjs/providers/tts/adapters/kokoro/index.js +2 -0
- package/dist/cjs/providers/tts/adapters/kokoro/index.js.map +7 -0
- package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js +2 -0
- package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js.map +7 -0
- package/dist/cjs/providers/tts/index.js +2 -0
- package/dist/cjs/providers/tts/index.js.map +7 -0
- package/dist/cjs/providers/tts/types.js +2 -0
- package/dist/cjs/providers/tts/types.js.map +7 -0
- package/dist/cjs/transport/adapters/index.js +2 -0
- package/dist/cjs/transport/adapters/index.js.map +7 -0
- package/dist/cjs/transport/adapters/memory/index.js +2 -0
- package/dist/cjs/transport/adapters/memory/index.js.map +7 -0
- package/dist/cjs/transport/adapters/memory/memory.js +2 -0
- package/dist/cjs/transport/adapters/memory/memory.js.map +7 -0
- package/dist/cjs/transport/index.js +2 -0
- package/dist/cjs/transport/index.js.map +7 -0
- package/dist/cjs/transport/types.js +2 -0
- package/dist/cjs/transport/types.js.map +7 -0
- package/dist/esm/agents/agent.js +2 -0
- package/dist/esm/agents/agent.js.map +7 -0
- package/dist/esm/agents/index.js +2 -0
- package/dist/esm/agents/index.js.map +7 -0
- package/dist/esm/agents/tools/index.js +2 -0
- package/dist/esm/agents/tools/index.js.map +7 -0
- package/dist/esm/agents/tools/tools.js +2 -0
- package/dist/esm/agents/tools/tools.js.map +7 -0
- package/dist/esm/conversations/conversation/conversation.js +2 -0
- package/dist/esm/conversations/conversation/conversation.js.map +7 -0
- package/dist/esm/conversations/conversation/index.js +2 -0
- package/dist/esm/conversations/conversation/index.js.map +7 -0
- package/dist/esm/conversations/conversations.js +2 -0
- package/dist/esm/conversations/conversations.js.map +7 -0
- package/dist/esm/conversations/index.js +2 -0
- package/dist/esm/conversations/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/index.js +2 -0
- package/dist/esm/conversations/orchestration/orchestrator/index.js.map +7 -0
- package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js +3 -0
- package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js.map +7 -0
- package/dist/esm/conversations/transcription/index.js +2 -0
- package/dist/esm/conversations/transcription/index.js.map +7 -0
- package/dist/esm/conversations/transcription/transcription.js +2 -0
- package/dist/esm/conversations/transcription/transcription.js.map +7 -0
- package/dist/esm/conversations/types.js +2 -0
- package/dist/esm/conversations/types.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/persistence/adapters/index.js +2 -0
- package/dist/esm/persistence/adapters/index.js.map +7 -0
- package/dist/esm/persistence/adapters/memory/index.js +2 -0
- package/dist/esm/persistence/adapters/memory/index.js.map +7 -0
- package/dist/esm/persistence/adapters/memory/memory.js +2 -0
- package/dist/esm/persistence/adapters/memory/memory.js.map +7 -0
- package/dist/esm/persistence/adapters/sqlite/index.js +2 -0
- package/dist/esm/persistence/adapters/sqlite/index.js.map +7 -0
- package/dist/esm/persistence/adapters/sqlite/sqlite.js +58 -0
- package/dist/esm/persistence/adapters/sqlite/sqlite.js.map +7 -0
- package/dist/esm/persistence/index.js +2 -0
- package/dist/esm/persistence/index.js.map +7 -0
- package/dist/esm/persistence/persistence.js +1 -0
- package/dist/esm/persistence/persistence.js.map +7 -0
- package/dist/esm/providers/index.js +2 -0
- package/dist/esm/providers/index.js.map +7 -0
- package/dist/esm/providers/llm/adapters/deepseek/deepseek.js +2 -0
- package/dist/esm/providers/llm/adapters/deepseek/deepseek.js.map +7 -0
- package/dist/esm/providers/llm/adapters/deepseek/index.js +2 -0
- package/dist/esm/providers/llm/adapters/deepseek/index.js.map +7 -0
- package/dist/esm/providers/llm/adapters/index.js +2 -0
- package/dist/esm/providers/llm/adapters/index.js.map +7 -0
- package/dist/esm/providers/llm/index.js +2 -0
- package/dist/esm/providers/llm/index.js.map +7 -0
- package/dist/esm/providers/llm/types.js +1 -0
- package/dist/esm/providers/llm/types.js.map +7 -0
- package/dist/esm/providers/shared.js +1 -0
- package/dist/esm/providers/shared.js.map +7 -0
- package/dist/esm/providers/stt/adapters/deepgram/deepgram.js +2 -0
- package/dist/esm/providers/stt/adapters/deepgram/deepgram.js.map +7 -0
- package/dist/esm/providers/stt/adapters/deepgram/index.js +2 -0
- package/dist/esm/providers/stt/adapters/deepgram/index.js.map +7 -0
- package/dist/esm/providers/stt/adapters/index.js +2 -0
- package/dist/esm/providers/stt/adapters/index.js.map +7 -0
- package/dist/esm/providers/stt/index.js +2 -0
- package/dist/esm/providers/stt/index.js.map +7 -0
- package/dist/esm/providers/stt/types.js +1 -0
- package/dist/esm/providers/stt/types.js.map +7 -0
- package/dist/esm/providers/tts/adapters/index.js +2 -0
- package/dist/esm/providers/tts/adapters/index.js.map +7 -0
- package/dist/esm/providers/tts/adapters/kokoro/index.js +2 -0
- package/dist/esm/providers/tts/adapters/kokoro/index.js.map +7 -0
- package/dist/esm/providers/tts/adapters/kokoro/kokoro.js +2 -0
- package/dist/esm/providers/tts/adapters/kokoro/kokoro.js.map +7 -0
- package/dist/esm/providers/tts/index.js +2 -0
- package/dist/esm/providers/tts/index.js.map +7 -0
- package/dist/esm/providers/tts/types.js +1 -0
- package/dist/esm/providers/tts/types.js.map +7 -0
- package/dist/esm/transport/adapters/index.js +2 -0
- package/dist/esm/transport/adapters/index.js.map +7 -0
- package/dist/esm/transport/adapters/memory/index.js +2 -0
- package/dist/esm/transport/adapters/memory/index.js.map +7 -0
- package/dist/esm/transport/adapters/memory/memory.js +2 -0
- package/dist/esm/transport/adapters/memory/memory.js.map +7 -0
- package/dist/esm/transport/index.js +2 -0
- package/dist/esm/transport/index.js.map +7 -0
- package/dist/esm/transport/types.js +1 -0
- package/dist/esm/transport/types.js.map +7 -0
- package/dist/types/agents/agent.d.ts +60 -0
- package/dist/types/agents/index.d.ts +4 -0
- package/dist/types/agents/tools/index.d.ts +2 -0
- package/dist/types/agents/tools/tools.d.ts +22 -0
- package/dist/types/conversations/conversation/conversation.d.ts +138 -0
- package/dist/types/conversations/conversation/index.d.ts +2 -0
- package/dist/types/conversations/conversations.d.ts +23 -0
- package/dist/types/conversations/index.d.ts +10 -0
- package/dist/types/conversations/orchestration/orchestrator/index.d.ts +2 -0
- package/dist/types/conversations/orchestration/orchestrator/orchestrator.d.ts +98 -0
- package/dist/types/conversations/transcription/index.d.ts +2 -0
- package/dist/types/conversations/transcription/transcription.d.ts +59 -0
- package/dist/types/conversations/types.d.ts +63 -0
- package/dist/types/index.d.ts +45 -0
- package/dist/types/persistence/adapters/index.d.ts +2 -0
- package/dist/types/persistence/adapters/memory/index.d.ts +1 -0
- package/dist/types/persistence/adapters/memory/memory.d.ts +27 -0
- package/dist/types/persistence/adapters/sqlite/index.d.ts +2 -0
- package/dist/types/persistence/adapters/sqlite/sqlite.d.ts +31 -0
- package/dist/types/persistence/index.d.ts +2 -0
- package/dist/types/persistence/persistence.d.ts +38 -0
- package/dist/types/providers/index.d.ts +6 -0
- package/dist/types/providers/llm/adapters/deepseek/deepseek.d.ts +24 -0
- package/dist/types/providers/llm/adapters/deepseek/index.d.ts +2 -0
- package/dist/types/providers/llm/adapters/index.d.ts +1 -0
- package/dist/types/providers/llm/index.d.ts +10 -0
- package/dist/types/providers/llm/types.d.ts +55 -0
- package/dist/types/providers/shared.d.ts +8 -0
- package/dist/types/providers/stt/adapters/deepgram/deepgram.d.ts +57 -0
- package/dist/types/providers/stt/adapters/deepgram/index.d.ts +2 -0
- package/dist/types/providers/stt/adapters/index.d.ts +1 -0
- package/dist/types/providers/stt/index.d.ts +2 -0
- package/dist/types/providers/stt/types.d.ts +30 -0
- package/dist/types/providers/tts/adapters/index.d.ts +1 -0
- package/dist/types/providers/tts/adapters/kokoro/index.d.ts +2 -0
- package/dist/types/providers/tts/adapters/kokoro/kokoro.d.ts +34 -0
- package/dist/types/providers/tts/index.d.ts +2 -0
- package/dist/types/providers/tts/types.d.ts +16 -0
- package/dist/types/transport/adapters/index.d.ts +1 -0
- package/dist/types/transport/adapters/memory/index.d.ts +1 -0
- package/dist/types/transport/adapters/memory/memory.d.ts +20 -0
- package/dist/types/transport/index.d.ts +2 -0
- package/dist/types/transport/types.d.ts +49 -0
- package/package.json +82 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Agent } from "../../../agents/agent.js";
|
|
2
|
+
import type { Conversation } from "../../conversation/conversation.js";
|
|
3
|
+
import type { Persistence } from "../../../persistence/persistence.js";
|
|
4
|
+
import type { LLM } from "../../../providers/llm/types.js";
|
|
5
|
+
import type { STT } from "../../../providers/stt/types.js";
|
|
6
|
+
import type { TTS } from "../../../providers/tts/types.js";
|
|
7
|
+
export interface OrchestratorOptions {
|
|
8
|
+
conversation: Conversation;
|
|
9
|
+
/**
|
|
10
|
+
* The agent driving the realtime loop. Omit it for transcription-only
|
|
11
|
+
* mode (audio in, turns and transcripts out — no LLM or TTS required).
|
|
12
|
+
*/
|
|
13
|
+
agent?: Agent;
|
|
14
|
+
/** Defaults to the agent's LLM. */
|
|
15
|
+
llm?: LLM;
|
|
16
|
+
stt: STT;
|
|
17
|
+
/** Required when an agent is attached. */
|
|
18
|
+
tts?: TTS;
|
|
19
|
+
/** Used to rehydrate conversation history on start. */
|
|
20
|
+
persistence?: Persistence;
|
|
21
|
+
/** How long to wait for the application to resolve a tool call. */
|
|
22
|
+
toolTimeoutMs?: number;
|
|
23
|
+
/** Safety bound on tool-call round trips per generation. */
|
|
24
|
+
maxToolIterations?: number;
|
|
25
|
+
temperature?: number;
|
|
26
|
+
maxTokens?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The realtime conversation state machine.
|
|
30
|
+
*
|
|
31
|
+
* Wires the conversation to the providers:
|
|
32
|
+
*
|
|
33
|
+
* ```text
|
|
34
|
+
* audio-in ──► STT ──► turn ──► LLM ──► TTS ──► audio-out
|
|
35
|
+
* │
|
|
36
|
+
* └─► tool-call ──► app resolves ──► resume
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Deltas stream to TTS immediately (so the agent can narrate while a tool
|
|
40
|
+
* runs), tool calls pause the generation until the application resolves
|
|
41
|
+
* them, and interruptions cancel the current generation — discarding any
|
|
42
|
+
* stale tool results or audio via a generation epoch.
|
|
43
|
+
*/
|
|
44
|
+
export declare class Orchestrator {
|
|
45
|
+
private readonly conversation;
|
|
46
|
+
private readonly agent;
|
|
47
|
+
private readonly llm;
|
|
48
|
+
private readonly stt;
|
|
49
|
+
private readonly tts;
|
|
50
|
+
private readonly persistence;
|
|
51
|
+
private readonly toolTimeoutMs;
|
|
52
|
+
private readonly maxToolIterations;
|
|
53
|
+
private readonly temperature;
|
|
54
|
+
private readonly maxTokens;
|
|
55
|
+
private started;
|
|
56
|
+
private generating;
|
|
57
|
+
private epoch;
|
|
58
|
+
private readonly unsubscribers;
|
|
59
|
+
private readonly sttSessions;
|
|
60
|
+
private readonly history;
|
|
61
|
+
private readonly toolWaiters;
|
|
62
|
+
private generationChain;
|
|
63
|
+
private speechChain;
|
|
64
|
+
private speechBuffer;
|
|
65
|
+
private pendingTurns;
|
|
66
|
+
private pendingGenerations;
|
|
67
|
+
private audioSequence;
|
|
68
|
+
private turnSequence;
|
|
69
|
+
constructor(options: OrchestratorOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Attach to the conversation: rehydrate history from persistence and
|
|
72
|
+
* subscribe to conversation events.
|
|
73
|
+
*/
|
|
74
|
+
start(): Promise<void>;
|
|
75
|
+
stop(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve once every queued and in-flight turn and generation has
|
|
78
|
+
* finished processing. Useful for tests and graceful shutdown.
|
|
79
|
+
*/
|
|
80
|
+
whenIdle(): Promise<void>;
|
|
81
|
+
private onAudioIn;
|
|
82
|
+
private onPartial;
|
|
83
|
+
private onFinal;
|
|
84
|
+
private processTurn;
|
|
85
|
+
private onInterrupt;
|
|
86
|
+
private onToolCallResult;
|
|
87
|
+
private onProviderError;
|
|
88
|
+
private queueGeneration;
|
|
89
|
+
private generate;
|
|
90
|
+
private runGeneration;
|
|
91
|
+
private resolveToolCalls;
|
|
92
|
+
private waitForToolResult;
|
|
93
|
+
private cancelToolWaiters;
|
|
94
|
+
private feedDelta;
|
|
95
|
+
private flushSpeech;
|
|
96
|
+
/** Synthesize a sentence and push the audio chunks out to the app. */
|
|
97
|
+
private speak;
|
|
98
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ConversationId } from "../types.js";
|
|
2
|
+
export type TranscriptSpeakerKind = "participant" | "agent";
|
|
3
|
+
export interface TranscriptEntryInput {
|
|
4
|
+
conversationId: ConversationId;
|
|
5
|
+
speaker: string;
|
|
6
|
+
speakerKind: TranscriptSpeakerKind;
|
|
7
|
+
text: string;
|
|
8
|
+
timestamp?: number;
|
|
9
|
+
sequence?: number;
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A single line of a conversation transcript.
|
|
14
|
+
*
|
|
15
|
+
* `toString()` renders the entry as `speaker: text` so transcript arrays can
|
|
16
|
+
* be joined directly into a readable dump.
|
|
17
|
+
*/
|
|
18
|
+
export declare class TranscriptEntry {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly conversationId: ConversationId;
|
|
21
|
+
readonly speaker: string;
|
|
22
|
+
readonly speakerKind: TranscriptSpeakerKind;
|
|
23
|
+
readonly text: string;
|
|
24
|
+
readonly timestamp: number;
|
|
25
|
+
readonly sequence: number;
|
|
26
|
+
constructor(input: TranscriptEntryInput);
|
|
27
|
+
/** Rebuild an entry from plain (e.g. persisted) data. */
|
|
28
|
+
static fromPlain(plain: TranscriptEntry): TranscriptEntry;
|
|
29
|
+
toString(): string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* In-memory transcript state for a single conversation.
|
|
33
|
+
*
|
|
34
|
+
* Entries are appended in order and assigned monotonically increasing
|
|
35
|
+
* sequence numbers. The orchestrator appends entries as speech is finalized
|
|
36
|
+
* and generations complete; persistence mirrors these entries.
|
|
37
|
+
*/
|
|
38
|
+
export declare class Transcription {
|
|
39
|
+
private readonly conversationId;
|
|
40
|
+
private readonly entries;
|
|
41
|
+
private readonly ids;
|
|
42
|
+
private nextSequence;
|
|
43
|
+
constructor(conversationId: ConversationId);
|
|
44
|
+
get length(): number;
|
|
45
|
+
get isEmpty(): boolean;
|
|
46
|
+
/** Append a participant speech entry. */
|
|
47
|
+
appendSpeech(speaker: string, text: string, timestamp?: number): TranscriptEntry;
|
|
48
|
+
/** Append an agent generation entry. */
|
|
49
|
+
appendGeneration(agentName: string, text: string, timestamp?: number): TranscriptEntry;
|
|
50
|
+
append(input: Omit<TranscriptEntryInput, "conversationId" | "sequence" | "id"> & {
|
|
51
|
+
id?: string;
|
|
52
|
+
sequence?: number;
|
|
53
|
+
}): TranscriptEntry;
|
|
54
|
+
list(): TranscriptEntry[];
|
|
55
|
+
get(id: string): TranscriptEntry | null;
|
|
56
|
+
getBySequence(sequence: number): TranscriptEntry | null;
|
|
57
|
+
last(): TranscriptEntry | null;
|
|
58
|
+
clear(): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core domain types shared across Pipeflow modules.
|
|
3
|
+
*/
|
|
4
|
+
export type ConversationId = string;
|
|
5
|
+
export type UserId = string;
|
|
6
|
+
export type TurnId = string;
|
|
7
|
+
export interface ParticipantInput {
|
|
8
|
+
userId: UserId;
|
|
9
|
+
aliases?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface Participant {
|
|
12
|
+
userId: UserId;
|
|
13
|
+
aliases: string[];
|
|
14
|
+
joinedAt: number;
|
|
15
|
+
}
|
|
16
|
+
export interface Turn {
|
|
17
|
+
id: TurnId;
|
|
18
|
+
conversationId: ConversationId;
|
|
19
|
+
participantId: UserId;
|
|
20
|
+
participantName: string;
|
|
21
|
+
text: string;
|
|
22
|
+
sequence: number;
|
|
23
|
+
startedAt: number;
|
|
24
|
+
endedAt: number;
|
|
25
|
+
}
|
|
26
|
+
export type GenerationStatus = "streaming" | "completed" | "cancelled";
|
|
27
|
+
export interface Generation {
|
|
28
|
+
id: string;
|
|
29
|
+
conversationId: ConversationId;
|
|
30
|
+
agentName: string;
|
|
31
|
+
text: string;
|
|
32
|
+
status: GenerationStatus;
|
|
33
|
+
startedAt: number;
|
|
34
|
+
endedAt?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ToolCall {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
/** Parsed arguments, or the raw JSON string if parsing failed. */
|
|
40
|
+
arguments: unknown;
|
|
41
|
+
}
|
|
42
|
+
export type ToolCallResult = {
|
|
43
|
+
id: string;
|
|
44
|
+
result: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
id: string;
|
|
47
|
+
error: string;
|
|
48
|
+
};
|
|
49
|
+
export interface AudioChunk {
|
|
50
|
+
data: Uint8Array;
|
|
51
|
+
timestamp: number;
|
|
52
|
+
sequence: number;
|
|
53
|
+
}
|
|
54
|
+
export type ConversationStatus = "created" | "started" | "stopped";
|
|
55
|
+
export interface ConversationState {
|
|
56
|
+
status: ConversationStatus;
|
|
57
|
+
participants: Map<UserId, Participant>;
|
|
58
|
+
floor: UserId | null;
|
|
59
|
+
currentTurn: Turn | null;
|
|
60
|
+
currentGeneration: Generation | null;
|
|
61
|
+
transcriptCount: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function createConversationState(status?: ConversationStatus): ConversationState;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Agent, type AgentOptions } from "./agents/agent.js";
|
|
2
|
+
import { Conversations } from "./conversations/conversations.js";
|
|
3
|
+
import type { Persistence } from "./persistence/persistence.js";
|
|
4
|
+
import type { LLM } from "./providers/llm/types.js";
|
|
5
|
+
import type { STT } from "./providers/stt/types.js";
|
|
6
|
+
import type { TTS } from "./providers/tts/types.js";
|
|
7
|
+
export interface PipeflowOptions {
|
|
8
|
+
llm?: LLM;
|
|
9
|
+
stt?: STT;
|
|
10
|
+
tts?: TTS;
|
|
11
|
+
persistence?: Persistence;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The Pipeflow entry point.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* const pipeflow = new Pipeflow({ llm });
|
|
18
|
+
* const agent = pipeflow.agent({ name: "Jarvis", context: "..." });
|
|
19
|
+
* const conversation = await pipeflow.conversations.create({ agents: [agent] });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class Pipeflow {
|
|
23
|
+
readonly llm: LLM | undefined;
|
|
24
|
+
readonly stt: STT | undefined;
|
|
25
|
+
readonly tts: TTS | undefined;
|
|
26
|
+
readonly conversations: Conversations;
|
|
27
|
+
constructor(options?: PipeflowOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Create an agent. Agents inherit the Pipeflow instance's LLM provider so
|
|
30
|
+
* `agent.run()` works out of the box.
|
|
31
|
+
*/
|
|
32
|
+
agent(options: Omit<AgentOptions, "llm"> & {
|
|
33
|
+
llm?: LLM;
|
|
34
|
+
}): Agent;
|
|
35
|
+
}
|
|
36
|
+
export { Agent };
|
|
37
|
+
export type { AgentOptions, AgentRunRequest, AgentRunResult, ExecutedToolCall, } from "./agents/agent.js";
|
|
38
|
+
export { Tool, Tool as PipeflowTool } from "./agents/tools/tools.js";
|
|
39
|
+
export type { ToolOptions } from "./agents/tools/tools.js";
|
|
40
|
+
export { Conversation, Conversations, Orchestrator, Transcription, TranscriptEntry, } from "./conversations/index.js";
|
|
41
|
+
export type { AudioChunk, ConversationEvents, ConversationId, ConversationOptions, ConversationState, ConversationStatus, CreateConversationOptions, Generation, GenerationStatus, OrchestratorOptions, Participant, ParticipantInput, ToolCall, ToolCallResult, TranscriptEntryInput, TranscriptSpeakerKind, Turn, TurnId, UserId, } from "./conversations/index.js";
|
|
42
|
+
export type { LLM, LLMMessage } from "./providers/llm/types.js";
|
|
43
|
+
export type { STT } from "./providers/stt/types.js";
|
|
44
|
+
export type { TTS } from "./providers/tts/types.js";
|
|
45
|
+
export type { Persistence } from "./persistence/persistence.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MemoryPersistence } from "./memory.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ConversationId, Generation, Participant, Turn } from "../../../conversations/types.js";
|
|
2
|
+
import type { TranscriptEntry } from "../../../conversations/transcription/transcription.js";
|
|
3
|
+
import type { ConversationRecord, NewConversation, Persistence } from "../../persistence.js";
|
|
4
|
+
/**
|
|
5
|
+
* In-memory persistence adapter. Useful for tests and development: data is
|
|
6
|
+
* lost when the process exits.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MemoryPersistence implements Persistence {
|
|
9
|
+
private readonly conversations;
|
|
10
|
+
private readonly participants;
|
|
11
|
+
private readonly transcript;
|
|
12
|
+
private readonly turns;
|
|
13
|
+
private readonly generations;
|
|
14
|
+
createConversation(input?: NewConversation): Promise<ConversationRecord>;
|
|
15
|
+
getConversation(id: ConversationId): Promise<ConversationRecord | null>;
|
|
16
|
+
listConversations(): Promise<ConversationRecord[]>;
|
|
17
|
+
finalizeConversation(id: ConversationId, endedAt?: number): Promise<ConversationRecord | null>;
|
|
18
|
+
deleteConversation(id: ConversationId): Promise<boolean>;
|
|
19
|
+
addParticipant(conversationId: ConversationId, participant: Participant): Promise<void>;
|
|
20
|
+
listParticipants(conversationId: ConversationId): Promise<Participant[]>;
|
|
21
|
+
appendTranscript(conversationId: ConversationId, entry: TranscriptEntry): Promise<void>;
|
|
22
|
+
listTranscript(conversationId: ConversationId): Promise<TranscriptEntry[]>;
|
|
23
|
+
appendTurn(conversationId: ConversationId, turn: Turn): Promise<void>;
|
|
24
|
+
listTurns(conversationId: ConversationId): Promise<Turn[]>;
|
|
25
|
+
appendGeneration(conversationId: ConversationId, generation: Generation): Promise<void>;
|
|
26
|
+
listGenerations(conversationId: ConversationId): Promise<Generation[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ConversationId, Generation, Participant, Turn } from "../../../conversations/types.js";
|
|
2
|
+
import { TranscriptEntry } from "../../../conversations/transcription/transcription.js";
|
|
3
|
+
import type { ConversationRecord, NewConversation, Persistence } from "../../persistence.js";
|
|
4
|
+
export interface SQLitePersistenceOptions {
|
|
5
|
+
/** Database filename. Defaults to an in-memory database. */
|
|
6
|
+
filename?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* SQLite-backed persistence adapter (via bun:sqlite).
|
|
10
|
+
*
|
|
11
|
+
* A lightweight persistent backend for local applications and early
|
|
12
|
+
* deployments.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SQLitePersistence implements Persistence {
|
|
15
|
+
private readonly db;
|
|
16
|
+
constructor(options?: SQLitePersistenceOptions);
|
|
17
|
+
close(): void;
|
|
18
|
+
createConversation(input?: NewConversation): Promise<ConversationRecord>;
|
|
19
|
+
getConversation(id: ConversationId): Promise<ConversationRecord | null>;
|
|
20
|
+
listConversations(): Promise<ConversationRecord[]>;
|
|
21
|
+
finalizeConversation(id: ConversationId, endedAt?: number): Promise<ConversationRecord | null>;
|
|
22
|
+
deleteConversation(id: ConversationId): Promise<boolean>;
|
|
23
|
+
addParticipant(conversationId: ConversationId, participant: Participant): Promise<void>;
|
|
24
|
+
listParticipants(conversationId: ConversationId): Promise<Participant[]>;
|
|
25
|
+
appendTranscript(conversationId: ConversationId, entry: TranscriptEntry): Promise<void>;
|
|
26
|
+
listTranscript(conversationId: ConversationId): Promise<TranscriptEntry[]>;
|
|
27
|
+
appendTurn(conversationId: ConversationId, turn: Turn): Promise<void>;
|
|
28
|
+
listTurns(conversationId: ConversationId): Promise<Turn[]>;
|
|
29
|
+
appendGeneration(conversationId: ConversationId, generation: Generation): Promise<void>;
|
|
30
|
+
listGenerations(conversationId: ConversationId): Promise<Generation[]>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ConversationId, Generation, Participant, Turn, UserId } from "../conversations/types.js";
|
|
2
|
+
import type { TranscriptEntry } from "../conversations/transcription/transcription.js";
|
|
3
|
+
export interface ConversationRecord {
|
|
4
|
+
id: ConversationId;
|
|
5
|
+
agentNames: string[];
|
|
6
|
+
createdAt: number;
|
|
7
|
+
endedAt: number | null;
|
|
8
|
+
}
|
|
9
|
+
export interface NewConversation {
|
|
10
|
+
id?: ConversationId;
|
|
11
|
+
agentNames?: string[];
|
|
12
|
+
createdAt?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Storage contract for the conversation domain.
|
|
16
|
+
*
|
|
17
|
+
* Persistence is provider-independent: memory and SQLite are the built-in
|
|
18
|
+
* adapters, and other backends can implement the same interface.
|
|
19
|
+
*/
|
|
20
|
+
export interface Persistence {
|
|
21
|
+
createConversation(input?: NewConversation): Promise<ConversationRecord>;
|
|
22
|
+
getConversation(id: ConversationId): Promise<ConversationRecord | null>;
|
|
23
|
+
listConversations(): Promise<ConversationRecord[]>;
|
|
24
|
+
/** Mark a conversation as ended. Returns null if it does not exist. */
|
|
25
|
+
finalizeConversation(id: ConversationId, endedAt?: number): Promise<ConversationRecord | null>;
|
|
26
|
+
deleteConversation(id: ConversationId): Promise<boolean>;
|
|
27
|
+
addParticipant(conversationId: ConversationId, participant: Participant): Promise<void>;
|
|
28
|
+
listParticipants(conversationId: ConversationId): Promise<Participant[]>;
|
|
29
|
+
/** Upsert a transcript entry (entries are immutable in practice). */
|
|
30
|
+
appendTranscript(conversationId: ConversationId, entry: TranscriptEntry): Promise<void>;
|
|
31
|
+
listTranscript(conversationId: ConversationId): Promise<TranscriptEntry[]>;
|
|
32
|
+
appendTurn(conversationId: ConversationId, turn: Turn): Promise<void>;
|
|
33
|
+
listTurns(conversationId: ConversationId): Promise<Turn[]>;
|
|
34
|
+
/** Upsert a generation so status updates (e.g. completed) overwrite. */
|
|
35
|
+
appendGeneration(conversationId: ConversationId, generation: Generation): Promise<void>;
|
|
36
|
+
listGenerations(conversationId: ConversationId): Promise<Generation[]>;
|
|
37
|
+
}
|
|
38
|
+
export type { ConversationId, UserId };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { LLM, LLMEvent, LLMMessage, LLMRole, LLMToolCall, LLMToolDefinition, LLMRequest } from "./llm/index.js";
|
|
2
|
+
export type { STT, STTOptions, STTSession } from "./stt/index.js";
|
|
3
|
+
export type { TTS, TTSRequest } from "./tts/index.js";
|
|
4
|
+
export { complete, streamText, DeepSeekLLM } from "./llm/index.js";
|
|
5
|
+
export { DeepgramSTT } from "./stt/index.js";
|
|
6
|
+
export { KokoroTTS } from "./tts/index.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LLM, LLMEvent, LLMRequest } from "../../types.js";
|
|
2
|
+
import type { FetchLike } from "../../../shared.js";
|
|
3
|
+
export interface DeepSeekOptions {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
/** Defaults to `deepseek-chat`. */
|
|
6
|
+
model?: string;
|
|
7
|
+
/** Defaults to `https://api.deepseek.com`. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Injectable fetch implementation, mainly for tests. */
|
|
10
|
+
fetch?: FetchLike;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* DeepSeek LLM adapter (OpenAI-compatible chat completions over SSE).
|
|
14
|
+
*/
|
|
15
|
+
export declare class DeepSeekLLM implements LLM {
|
|
16
|
+
private readonly apiKey;
|
|
17
|
+
private readonly model;
|
|
18
|
+
private readonly baseUrl;
|
|
19
|
+
private readonly fetchImpl;
|
|
20
|
+
private abort;
|
|
21
|
+
constructor(options: DeepSeekOptions);
|
|
22
|
+
stop(): void;
|
|
23
|
+
stream(request: LLMRequest): AsyncGenerator<LLMEvent>;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DeepSeekLLM } from "./deepseek/deepseek.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LLM, LLMRequest } from "./types.js";
|
|
2
|
+
export type { LLM, LLMEvent, LLMMessage, LLMRole, LLMToolCall, LLMToolDefinition, LLMRequest, } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Stream only the text deltas of an LLM generation, rethrowing any
|
|
5
|
+
* streamed error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function streamText(llm: LLM, request: LLMRequest): AsyncGenerator<string>;
|
|
8
|
+
/** Collect an entire LLM generation into a single string. */
|
|
9
|
+
export declare function complete(llm: LLM, request: LLMRequest): Promise<string>;
|
|
10
|
+
export { DeepSeekLLM } from "./adapters/index.js";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type LLMRole = "system" | "user" | "assistant" | "tool";
|
|
2
|
+
export interface LLMToolCall {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
/** JSON-encoded arguments for the tool. */
|
|
6
|
+
arguments: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LLMMessage {
|
|
9
|
+
role: LLMRole;
|
|
10
|
+
content: string;
|
|
11
|
+
/** Tool name, for `tool` role messages. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Tool call id this message answers, for `tool` role messages. */
|
|
14
|
+
toolCallId?: string;
|
|
15
|
+
/** Tool calls announced by the assistant, for `assistant` role messages. */
|
|
16
|
+
toolCalls?: LLMToolCall[];
|
|
17
|
+
}
|
|
18
|
+
export interface LLMToolDefinition {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
/** JSON schema describing the tool arguments. */
|
|
22
|
+
parameters: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface LLMRequest {
|
|
25
|
+
messages: LLMMessage[];
|
|
26
|
+
tools?: LLMToolDefinition[];
|
|
27
|
+
temperature?: number;
|
|
28
|
+
maxTokens?: number;
|
|
29
|
+
}
|
|
30
|
+
export type LLMEvent = {
|
|
31
|
+
type: "delta";
|
|
32
|
+
content: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "tool_call";
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
arguments: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "done";
|
|
40
|
+
} | {
|
|
41
|
+
type: "error";
|
|
42
|
+
error: Error;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Vendor-independent language model interface.
|
|
46
|
+
*
|
|
47
|
+
* `stream()` produces deltas as they arrive plus optional tool calls, and
|
|
48
|
+
* terminates with `done`. Transport-level failures (network, HTTP status)
|
|
49
|
+
* are thrown from the generator rather than emitted.
|
|
50
|
+
*/
|
|
51
|
+
export interface LLM {
|
|
52
|
+
stream(request: LLMRequest): AsyncGenerator<LLMEvent>;
|
|
53
|
+
/** Cancel the currently in-flight generation, if any. */
|
|
54
|
+
stop(): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fetch surface used by provider adapters.
|
|
3
|
+
*
|
|
4
|
+
* Defined separately from `typeof fetch` because Bun's fetch adds static
|
|
5
|
+
* members (e.g. `preconnect`) that plain functions cannot satisfy, which
|
|
6
|
+
* makes test doubles awkward.
|
|
7
|
+
*/
|
|
8
|
+
export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { STT, STTOptions, STTSession } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The minimal WebSocket surface used by the Deepgram adapter. Both the global
|
|
4
|
+
* `WebSocket` (Bun) and test fakes satisfy this shape.
|
|
5
|
+
*/
|
|
6
|
+
export interface STTSocket {
|
|
7
|
+
send(data: string | ArrayBuffer | ArrayBufferView): void;
|
|
8
|
+
close(code?: number, reason?: string): void;
|
|
9
|
+
addEventListener(type: string, listener: (event: {
|
|
10
|
+
data?: unknown;
|
|
11
|
+
error?: unknown;
|
|
12
|
+
}) => void): void;
|
|
13
|
+
}
|
|
14
|
+
export interface DeepgramOptions extends STTOptions {
|
|
15
|
+
apiKey: string;
|
|
16
|
+
/** Defaults to `wss://api.deepgram.com/v1/listen`. */
|
|
17
|
+
endpoint?: string;
|
|
18
|
+
/** Injectable socket factory, mainly for tests. */
|
|
19
|
+
createSocket?: (url: string) => STTSocket;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Deepgram streaming STT adapter (WebSocket).
|
|
23
|
+
*
|
|
24
|
+
* Audio written before the socket opens is queued and flushed on connect.
|
|
25
|
+
* `end()` sends a `CloseStream` frame and resolves once the server closes
|
|
26
|
+
* the socket.
|
|
27
|
+
*/
|
|
28
|
+
export declare class DeepgramSTT implements STT {
|
|
29
|
+
private readonly options;
|
|
30
|
+
private readonly sessions;
|
|
31
|
+
constructor(options: DeepgramOptions);
|
|
32
|
+
start(options?: STTOptions): STTSession;
|
|
33
|
+
cancel(): void;
|
|
34
|
+
}
|
|
35
|
+
export declare class DeepgramSession implements STTSession {
|
|
36
|
+
private readonly socket;
|
|
37
|
+
private readonly listeners;
|
|
38
|
+
private opened;
|
|
39
|
+
private closed;
|
|
40
|
+
private ended;
|
|
41
|
+
private readonly pendingClose;
|
|
42
|
+
private readonly queued;
|
|
43
|
+
private readonly endPromise;
|
|
44
|
+
private resolveEnd;
|
|
45
|
+
constructor(socket: STTSocket);
|
|
46
|
+
write(audio: Uint8Array): void;
|
|
47
|
+
end(): Promise<void>;
|
|
48
|
+
/** Force-close the session without waiting for the server. */
|
|
49
|
+
abort(): void;
|
|
50
|
+
on(event: "partial", listener: (transcript: string) => void): void;
|
|
51
|
+
on(event: "final", listener: (transcript: string) => void): void;
|
|
52
|
+
on(event: "error", listener: (error: Error) => void): void;
|
|
53
|
+
on(event: "close", listener: () => void): void;
|
|
54
|
+
private handleResult;
|
|
55
|
+
private sendCloseStream;
|
|
56
|
+
private emit;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DeepgramSTT } from "./deepgram/deepgram.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface STTOptions {
|
|
2
|
+
model?: string;
|
|
3
|
+
language?: string;
|
|
4
|
+
/** Whether interim (partial) transcripts are reported. */
|
|
5
|
+
interimResults?: boolean;
|
|
6
|
+
/** Audio encoding, e.g. `linear16`. */
|
|
7
|
+
encoding?: string;
|
|
8
|
+
/** Audio sample rate in Hz. */
|
|
9
|
+
sampleRate?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface STTSession {
|
|
12
|
+
/** Feed an audio chunk into the recognizer. */
|
|
13
|
+
write(audio: Uint8Array): void;
|
|
14
|
+
/** Signal the end of the audio stream and wait for the session to close. */
|
|
15
|
+
end(): Promise<void>;
|
|
16
|
+
on(event: "partial", listener: (transcript: string) => void): void;
|
|
17
|
+
on(event: "final", listener: (transcript: string) => void): void;
|
|
18
|
+
on(event: "error", listener: (error: Error) => void): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Vendor-independent speech-to-text interface.
|
|
22
|
+
*
|
|
23
|
+
* `start()` opens a streaming session; audio is fed in with `write()` and
|
|
24
|
+
* transcripts are reported via `partial`/`final` events.
|
|
25
|
+
*/
|
|
26
|
+
export interface STT {
|
|
27
|
+
start(options?: STTOptions): STTSession;
|
|
28
|
+
/** Cancel all active sessions. */
|
|
29
|
+
cancel(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KokoroTTS } from "./kokoro/kokoro.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { TTS, TTSRequest } from "../../types.js";
|
|
2
|
+
import type { FetchLike } from "../../../shared.js";
|
|
3
|
+
export interface KokoroOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Base URL of a Kokoro TTS server exposing the OpenAI-compatible
|
|
6
|
+
* `/v1/audio/speech` endpoint. Defaults to a local kokoro-fastapi server.
|
|
7
|
+
*/
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Default voice, e.g. `af_heart`. */
|
|
10
|
+
voice?: string;
|
|
11
|
+
model?: string;
|
|
12
|
+
apiKey?: string;
|
|
13
|
+
/** Size of the audio chunks yielded from the response stream. */
|
|
14
|
+
chunkSize?: number;
|
|
15
|
+
/** Injectable fetch implementation, mainly for tests. */
|
|
16
|
+
fetch?: FetchLike;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Kokoro TTS adapter. Consumes a Kokoro server's OpenAI-compatible speech
|
|
20
|
+
* endpoint and re-chunks the returned audio so it can be played as it
|
|
21
|
+
* arrives.
|
|
22
|
+
*/
|
|
23
|
+
export declare class KokoroTTS implements TTS {
|
|
24
|
+
private readonly baseUrl;
|
|
25
|
+
private readonly voice;
|
|
26
|
+
private readonly model;
|
|
27
|
+
private readonly apiKey;
|
|
28
|
+
private readonly chunkSize;
|
|
29
|
+
private readonly fetchImpl;
|
|
30
|
+
private abort;
|
|
31
|
+
constructor(options?: KokoroOptions);
|
|
32
|
+
stop(): void;
|
|
33
|
+
stream(request: TTSRequest): AsyncGenerator<Uint8Array>;
|
|
34
|
+
}
|