@llmrtc/llmrtc-core 1.0.0 → 1.2.0
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/CHANGELOG.md +83 -0
- package/NOTICE +7 -0
- package/dist/async-event-queue.d.ts +24 -0
- package/dist/async-event-queue.js +104 -0
- package/dist/async-event-queue.js.map +1 -0
- package/dist/hooks.d.ts +10 -6
- package/dist/hooks.js +3 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logging-hooks.js +6 -1
- package/dist/logging-hooks.js.map +1 -1
- package/dist/orchestrator.d.ts +27 -7
- package/dist/orchestrator.js +233 -86
- package/dist/orchestrator.js.map +1 -1
- package/dist/playbook-engine.d.ts +6 -0
- package/dist/playbook-engine.js +8 -4
- package/dist/playbook-engine.js.map +1 -1
- package/dist/playbook-orchestrator.d.ts +22 -1
- package/dist/playbook-orchestrator.js +145 -29
- package/dist/playbook-orchestrator.js.map +1 -1
- package/dist/tool-executor.d.ts +0 -4
- package/dist/tool-executor.js +58 -43
- package/dist/tool-executor.js.map +1 -1
- package/dist/tools.d.ts +10 -2
- package/dist/tools.js +73 -26
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +26 -1
- package/package.json +13 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @llmrtc/llmrtc-core
|
|
2
|
+
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fd91344: Anthropic modernization and richer stop reasons.
|
|
8
|
+
- The StopReason union gains `refusal`, `content_filter`, `pause_turn`, and
|
|
9
|
+
`context_overflow`. Note for TypeScript consumers with exhaustive switches:
|
|
10
|
+
this widens the union. OpenAI-compatible providers now report
|
|
11
|
+
`content_filter` for filtered responses (previously mis-reported as
|
|
12
|
+
`stop_sequence`); Gemini safety blocks and Bedrock guardrail interventions
|
|
13
|
+
also map to `content_filter`.
|
|
14
|
+
- The Anthropic provider defaults to `claude-sonnet-5` and automatically
|
|
15
|
+
omits temperature/top_p for model families that reject them (Sonnet 5,
|
|
16
|
+
Opus 4.7+, Fable tier), with a `samplingParamsSupported` override. The
|
|
17
|
+
Bedrock provider applies the same guard for Claude models.
|
|
18
|
+
- Orchestrators log a warning when a turn ends with an unusual stop reason.
|
|
19
|
+
- CLI and example fallbacks move off retired model ids.
|
|
20
|
+
|
|
21
|
+
- 319bb47: OpenAI voice updates: steerable TTS and current transcription models.
|
|
22
|
+
- TTSConfig gains an optional `instructions` field for instructable TTS
|
|
23
|
+
models. OpenAITTSProvider accepts `instructions` at the constructor and
|
|
24
|
+
per call, sends them for gpt-\* models (e.g. gpt-4o-mini-tts), and
|
|
25
|
+
ignores them with a one-time warning on tts-1/tts-1-hd.
|
|
26
|
+
- OpenAITTSVoice widened to the current voice roster (adds ash, ballad,
|
|
27
|
+
coral, sage, verse) while accepting any string for forward
|
|
28
|
+
compatibility; TTS model accepts any string. Note: code doing
|
|
29
|
+
exhaustive switches over OpenAITTSVoice will need adjusting, matching
|
|
30
|
+
the same widening in the official openai SDK. ballad/verse require
|
|
31
|
+
gpt-4o-mini-tts; the other nine voices work on all TTS models.
|
|
32
|
+
- OpenAIWhisperProvider documents gpt-4o-transcribe /
|
|
33
|
+
gpt-4o-mini-transcribe support.
|
|
34
|
+
- CLI: new OPENAI_STT_MODEL, OPENAI_TTS_MODEL, and
|
|
35
|
+
OPENAI_TTS_INSTRUCTIONS environment variables.
|
|
36
|
+
|
|
37
|
+
- a7d1ecc: Streaming speech-to-text: live interim transcripts while the user speaks.
|
|
38
|
+
- New ElevenLabsScribeProvider: batch STT via Scribe v2 and realtime
|
|
39
|
+
streaming via the Scribe v2 Realtime WebSocket (sub-150ms partials).
|
|
40
|
+
- New OpenAIRealtimeSTTProvider: streaming transcription over the OpenAI
|
|
41
|
+
Realtime API (gpt-realtime-whisper by default; audio-duration billing).
|
|
42
|
+
- Opt-in server mode streamingSTT (CLI: STREAMING_STT=true) streams mic
|
|
43
|
+
audio to the STT provider from VAD speech start, relaying partial
|
|
44
|
+
transcripts to the client over the existing transcript/isFinal
|
|
45
|
+
protocol; falls back to buffered STT when the provider can't stream.
|
|
46
|
+
- Both orchestrators gain runTurnStreamFromAudioStream; STTProvider
|
|
47
|
+
gains an optional streamingInputSampleRate hint; core exports an
|
|
48
|
+
AsyncEventQueue utility. Buffered STT remains the default.
|
|
49
|
+
- Streaming sockets carry watchdog timeouts (connect/inactivity/final)
|
|
50
|
+
and surface early closes or transcription failures as turn errors
|
|
51
|
+
instead of silently dropping the utterance.
|
|
52
|
+
- Behavior notes: the onSpeechStart server hook now fires after barge-in
|
|
53
|
+
cancellation, so a slow hook can no longer delay interruptions;
|
|
54
|
+
STT_PROVIDER=elevenlabs now selects ElevenLabs Scribe (previously it
|
|
55
|
+
silently fell back to OpenAI Whisper).
|
|
56
|
+
|
|
57
|
+
## 1.1.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- 8ff3ea3: Correctness release: make the advertised behavior actually work end to end.
|
|
62
|
+
- Core: system prompt is always sent and pinned outside the history window;
|
|
63
|
+
runTurnStream accepts an AbortSignal (barge-in); onLLMEnd has real
|
|
64
|
+
guardrail semantics; concurrent turns serialize correctly; clearHistory
|
|
65
|
+
transitions clear conversation history; PlaybookHooks are wired; tool
|
|
66
|
+
executor abort/ordering fixes; deep tool-argument validation.
|
|
67
|
+
- Providers: multi-turn tool calling now works across OpenAI, Anthropic,
|
|
68
|
+
Gemini, Bedrock, OpenRouter, LMStudio, and Ollama (history replay,
|
|
69
|
+
parallel tool results, streaming accumulation); malformed tool arguments
|
|
70
|
+
are flagged instead of silently becoming {}; Bedrock defaults to an
|
|
71
|
+
invocable inference profile; Ollama NDJSON streaming is buffered
|
|
72
|
+
correctly; ElevenLabs format mapping fixed; Whisper uploads are named by
|
|
73
|
+
their actual container.
|
|
74
|
+
- Backend: turns serialize per connection and barge-in aborts the in-flight
|
|
75
|
+
turn in any phase; session reconnection binds the recovered history;
|
|
76
|
+
Metered TURN credentials refresh on a TTL; start()/stop() lifecycle
|
|
77
|
+
fixes; real-time audio pacing.
|
|
78
|
+
- Web client: vision frames are delivered in time to reach the turn;
|
|
79
|
+
session resume follows the protocol and actually restores history;
|
|
80
|
+
close()/failure releases the microphone and camera; frame capture works
|
|
81
|
+
outside Chromium; non-WebRTC fallback (sendAudio/ttsChunk) is usable.
|
|
82
|
+
- Packaging: packages resolve under require(), clean checkouts build first
|
|
83
|
+
try, and npm tarballs ship the NOTICE file.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async bridge between callback-style event sources (e.g. WebSocket
|
|
3
|
+
* message handlers) and an async generator: events are pushed as they
|
|
4
|
+
* arrive and pulled by the consumer.
|
|
5
|
+
*
|
|
6
|
+
* Semantics:
|
|
7
|
+
* - Items buffered before end()/fail() are always delivered first.
|
|
8
|
+
* - end() after fail() and fail() after end() are no-ops.
|
|
9
|
+
* - push() after end()/fail() is dropped.
|
|
10
|
+
* - fail() surfaces to the consumer as a throw on its next pull.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AsyncEventQueue<T> implements AsyncIterable<T> {
|
|
13
|
+
private items;
|
|
14
|
+
private waiter;
|
|
15
|
+
private rejecter;
|
|
16
|
+
private ended;
|
|
17
|
+
private error;
|
|
18
|
+
push(item: T): void;
|
|
19
|
+
end(): void;
|
|
20
|
+
fail(err: Error): void;
|
|
21
|
+
/** True once end() or fail() has been called. */
|
|
22
|
+
get done(): boolean;
|
|
23
|
+
[Symbol.asyncIterator](): AsyncGenerator<T, void, unknown>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async bridge between callback-style event sources (e.g. WebSocket
|
|
3
|
+
* message handlers) and an async generator: events are pushed as they
|
|
4
|
+
* arrive and pulled by the consumer.
|
|
5
|
+
*
|
|
6
|
+
* Semantics:
|
|
7
|
+
* - Items buffered before end()/fail() are always delivered first.
|
|
8
|
+
* - end() after fail() and fail() after end() are no-ops.
|
|
9
|
+
* - push() after end()/fail() is dropped.
|
|
10
|
+
* - fail() surfaces to the consumer as a throw on its next pull.
|
|
11
|
+
*/
|
|
12
|
+
export class AsyncEventQueue {
|
|
13
|
+
constructor() {
|
|
14
|
+
Object.defineProperty(this, "items", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: []
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "waiter", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: null
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "rejecter", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: null
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "ended", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: false
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "error", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: null
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
push(item) {
|
|
46
|
+
if (this.ended || this.error)
|
|
47
|
+
return;
|
|
48
|
+
if (this.waiter) {
|
|
49
|
+
const w = this.waiter;
|
|
50
|
+
this.waiter = null;
|
|
51
|
+
this.rejecter = null;
|
|
52
|
+
w({ value: item, done: false });
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.items.push(item);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
end() {
|
|
59
|
+
if (this.ended || this.error)
|
|
60
|
+
return;
|
|
61
|
+
this.ended = true;
|
|
62
|
+
if (this.waiter) {
|
|
63
|
+
const w = this.waiter;
|
|
64
|
+
this.waiter = null;
|
|
65
|
+
this.rejecter = null;
|
|
66
|
+
w({ value: undefined, done: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
fail(err) {
|
|
70
|
+
if (this.ended || this.error)
|
|
71
|
+
return;
|
|
72
|
+
this.error = err;
|
|
73
|
+
if (this.rejecter) {
|
|
74
|
+
const r = this.rejecter;
|
|
75
|
+
this.waiter = null;
|
|
76
|
+
this.rejecter = null;
|
|
77
|
+
r(err);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** True once end() or fail() has been called. */
|
|
81
|
+
get done() {
|
|
82
|
+
return this.ended || this.error !== null;
|
|
83
|
+
}
|
|
84
|
+
async *[Symbol.asyncIterator]() {
|
|
85
|
+
for (;;) {
|
|
86
|
+
if (this.items.length > 0) {
|
|
87
|
+
yield this.items.shift();
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (this.error)
|
|
91
|
+
throw this.error;
|
|
92
|
+
if (this.ended)
|
|
93
|
+
return;
|
|
94
|
+
const result = await new Promise((resolve, reject) => {
|
|
95
|
+
this.waiter = resolve;
|
|
96
|
+
this.rejecter = reject;
|
|
97
|
+
});
|
|
98
|
+
if (result.done)
|
|
99
|
+
return;
|
|
100
|
+
yield result.value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=async-event-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-event-queue.js","sourceRoot":"","sources":["../src/async-event-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IAA5B;QACU;;;;mBAAa,EAAE;WAAC;QAChB;;;;mBAAkD,IAAI;WAAC;QACvD;;;;mBAA0C,IAAI;WAAC;QAC/C;;;;mBAAQ,KAAK;WAAC;QACd;;;;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AAC;QACT,CAAC;IACH,CAAC;IAED,iDAAiD;IACjD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,SAAS,CAAC;YACR,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAG,CAAC;gBAC1B,SAAS;YACX,CAAC;YACD,IAAI,IAAI,CAAC,KAAK;gBAAE,MAAM,IAAI,CAAC,KAAK,CAAC;YACjC,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAO;YACvB,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACtE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;gBACtB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;YACzB,CAAC,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,IAAI;gBAAE,OAAO;YACxB,MAAM,MAAM,CAAC,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -123,8 +123,12 @@ export interface OrchestratorHooks {
|
|
|
123
123
|
*/
|
|
124
124
|
onLLMChunk?(ctx: TurnContext, chunk: LLMChunk, chunkIndex: number): void | Promise<void>;
|
|
125
125
|
/**
|
|
126
|
-
* Called when LLM inference completes successfully
|
|
127
|
-
* Use this hook for content guardrails
|
|
126
|
+
* Called when LLM inference completes successfully.
|
|
127
|
+
* Use this hook for content guardrails: throwing cancels the response -
|
|
128
|
+
* it is not committed to history, no further TTS is produced, and the
|
|
129
|
+
* turn fails with the thrown error. Note that with streaming TTS enabled,
|
|
130
|
+
* audio for sentences generated before the hook ran may already have been
|
|
131
|
+
* emitted.
|
|
128
132
|
* @param ctx - Turn context
|
|
129
133
|
* @param result - Complete LLM response
|
|
130
134
|
* @param timing - LLM operation duration
|
|
@@ -264,9 +268,7 @@ export interface PlaybookContext {
|
|
|
264
268
|
*
|
|
265
269
|
* @example
|
|
266
270
|
* ```typescript
|
|
267
|
-
* const orchestrator = new PlaybookOrchestrator({
|
|
268
|
-
* llm,
|
|
269
|
-
* playbook,
|
|
271
|
+
* const orchestrator = new PlaybookOrchestrator(llm, playbook, registry, {
|
|
270
272
|
* hooks: {
|
|
271
273
|
* onStageEnter(ctx, stage) {
|
|
272
274
|
* console.log(`Entered stage: ${stage.name}`);
|
|
@@ -338,7 +340,9 @@ export declare function createErrorContext(code: ErrorCode, component: ErrorCont
|
|
|
338
340
|
}): ErrorContext;
|
|
339
341
|
/**
|
|
340
342
|
* Safely call an async hook without blocking
|
|
341
|
-
* Errors are caught and logged but don't propagate
|
|
343
|
+
* Errors are caught and logged but don't propagate.
|
|
344
|
+
* Note: orchestrators intentionally do NOT use this for onLLMEnd - that hook
|
|
345
|
+
* has guardrail semantics and a throw from it aborts the turn.
|
|
342
346
|
* @param hook - The hook function to call
|
|
343
347
|
* @param args - Arguments to pass to the hook
|
|
344
348
|
*/
|
package/dist/hooks.js
CHANGED
|
@@ -34,7 +34,9 @@ export function createErrorContext(code, component, options) {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Safely call an async hook without blocking
|
|
37
|
-
* Errors are caught and logged but don't propagate
|
|
37
|
+
* Errors are caught and logged but don't propagate.
|
|
38
|
+
* Note: orchestrators intentionally do NOT use this for onLLMEnd - that hook
|
|
39
|
+
* has guardrail semantics and a throw from it aborts the turn.
|
|
38
40
|
* @param hook - The hook function to call
|
|
39
41
|
* @param args - Arguments to pass to the hook
|
|
40
42
|
*/
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+YH,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,OAAe;IACjE,OAAO;QACL,SAAS;QACT,OAAO;QACP,UAAU,EAAE,OAAO,GAAG,SAAS;KAChC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAe,EACf,SAAoC,EACpC,OAIC;IAED,OAAO;QACL,IAAI;QACJ,SAAS;QACT,SAAS,EAAE,OAAO,EAAE,SAAS;QAC7B,MAAM,EAAE,OAAO,EAAE,MAAM;QACvB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAwD,EACxD,GAAG,IAAO;IAEV,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
package/dist/logging-hooks.js
CHANGED
|
@@ -90,7 +90,12 @@ export function createLoggingHooks(config = {}) {
|
|
|
90
90
|
logger.debug(formatted);
|
|
91
91
|
break;
|
|
92
92
|
case 'info':
|
|
93
|
-
|
|
93
|
+
if (logger.info) {
|
|
94
|
+
logger.info(formatted);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
logger.log(formatted);
|
|
98
|
+
}
|
|
94
99
|
break;
|
|
95
100
|
case 'warn':
|
|
96
101
|
logger.warn(formatted);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging-hooks.js","sourceRoot":"","sources":["../src/logging-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA8DH,gFAAgF;AAChF,sBAAsB;AACtB,gFAAgF;AAEhF,MAAM,eAAe,GAA6B;IAChD,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,SAAS,SAAS,CAAC,WAAqB,EAAE,YAAsB;IAC9D,OAAO,eAAe,CAAC,YAAY,CAAC,IAAI,eAAe,CA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5B,gCAAgC;YAChC,KAAK,MAAM,CAAC;QACd,CAAC;QACD,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM;YAC5B,KAAK,MAAM,CAAC;QACd,CAAC;QACD,QAAQ,CAAC,IAAI,EAAE,MAAM;YACnB,KAAK,MAAM,CAAC;QACd,CAAC;QACD,SAAS,CAAC,IAAI,EAAE,MAAM;YACpB,KAAK,MAAM,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/orchestrator.d.ts
CHANGED
|
@@ -45,7 +45,27 @@ export declare class ConversationOrchestrator {
|
|
|
45
45
|
*
|
|
46
46
|
* Hooks and metrics are called throughout the turn lifecycle.
|
|
47
47
|
*/
|
|
48
|
-
runTurnStream(audio: Buffer, attachments?: VisionAttachment[]
|
|
48
|
+
runTurnStream(audio: Buffer, attachments?: VisionAttachment[], options?: {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
}): AsyncGenerator<OrchestratorYield, void, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Streaming-STT version of runTurnStream: consumes live audio frames
|
|
53
|
+
* (16kHz mono 16-bit PCM Buffers) through the STT provider's
|
|
54
|
+
* transcribeStream, yielding every interim STTResult as it arrives.
|
|
55
|
+
* Final results are concatenated into the transcript that drives the
|
|
56
|
+
* same LLM/TTS pipeline as runTurnStream. Requires a provider with
|
|
57
|
+
* transcribeStream support.
|
|
58
|
+
*/
|
|
59
|
+
runTurnStreamFromAudioStream(frames: AsyncIterable<Buffer>, attachments?: VisionAttachment[], options?: {
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
}): AsyncGenerator<OrchestratorYield, void, unknown>;
|
|
62
|
+
private runTurnStreamFromAudioStreamInternal;
|
|
63
|
+
private runTurnStreamInternal;
|
|
64
|
+
/**
|
|
65
|
+
* Everything after the transcript is known: history, LLM, TTS.
|
|
66
|
+
* Shared by the buffered and streaming STT entry points.
|
|
67
|
+
*/
|
|
68
|
+
private completeTurnFromTranscript;
|
|
49
69
|
/**
|
|
50
70
|
* Split text into sentences using custom chunker or default regex
|
|
51
71
|
*/
|
|
@@ -60,14 +80,14 @@ export declare class ConversationOrchestrator {
|
|
|
60
80
|
*/
|
|
61
81
|
private generateTTSWithHooks;
|
|
62
82
|
/**
|
|
63
|
-
*
|
|
64
|
-
* Stream TTS chunks for a sentence using PCM format.
|
|
83
|
+
* Ensure the system prompt is seeded as the first history message.
|
|
65
84
|
*/
|
|
66
|
-
private
|
|
85
|
+
private ensureSystemMessage;
|
|
67
86
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
87
|
+
* Build the message window for an LLM request.
|
|
88
|
+
* The system message is always included and does not consume history slots,
|
|
89
|
+
* so long conversations never lose the assistant's instructions.
|
|
70
90
|
*/
|
|
71
|
-
private
|
|
91
|
+
private buildRequestMessages;
|
|
72
92
|
private pushHistory;
|
|
73
93
|
}
|