@fabric-harness/sdk 6.4.0 → 6.5.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/connector-spec/voice-telephony.md +120 -104
- package/dist/agent-route.d.ts +20 -2
- package/dist/agent-route.d.ts.map +1 -1
- package/dist/agent-route.js +31 -1
- package/dist/agent-route.js.map +1 -1
- package/dist/agent-router.d.ts +42 -0
- package/dist/agent-router.d.ts.map +1 -1
- package/dist/agent-router.js +49 -1
- package/dist/agent-router.js.map +1 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +3 -0
- package/dist/agent.js.map +1 -1
- package/dist/attachment-store.d.ts +69 -0
- package/dist/attachment-store.d.ts.map +1 -1
- package/dist/attachment-store.js +183 -14
- package/dist/attachment-store.js.map +1 -1
- package/dist/attachments.d.ts +136 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +332 -0
- package/dist/attachments.js.map +1 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +26 -3
- package/dist/channel.js.map +1 -1
- package/dist/conversation-history.d.ts +186 -0
- package/dist/conversation-history.d.ts.map +1 -0
- package/dist/conversation-history.js +481 -0
- package/dist/conversation-history.js.map +1 -0
- package/dist/conversation-ui.d.ts +43 -2
- package/dist/conversation-ui.d.ts.map +1 -1
- package/dist/conversation-ui.js +44 -14
- package/dist/conversation-ui.js.map +1 -1
- package/dist/cost-budget.d.ts +50 -0
- package/dist/cost-budget.d.ts.map +1 -1
- package/dist/cost-budget.js +74 -4
- package/dist/cost-budget.js.map +1 -1
- package/dist/cost-enforcement.d.ts +32 -0
- package/dist/cost-enforcement.d.ts.map +1 -0
- package/dist/cost-enforcement.js +116 -0
- package/dist/cost-enforcement.js.map +1 -0
- package/dist/delivered-message.d.ts +20 -6
- package/dist/delivered-message.d.ts.map +1 -1
- package/dist/delivered-message.js +37 -8
- package/dist/delivered-message.js.map +1 -1
- package/dist/events.d.ts +13 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/experimental.d.ts +2 -2
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +1 -1
- package/dist/experimental.js.map +1 -1
- package/dist/governed-voice.d.ts +6 -0
- package/dist/governed-voice.d.ts.map +1 -1
- package/dist/governed-voice.js +142 -35
- package/dist/governed-voice.js.map +1 -1
- package/dist/history.d.ts +3 -2
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +57 -23
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +21 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +25 -2
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +409 -60
- package/dist/loop.js.map +1 -1
- package/dist/model-pricing.d.ts +77 -4
- package/dist/model-pricing.d.ts.map +1 -1
- package/dist/model-pricing.js +259 -18
- package/dist/model-pricing.js.map +1 -1
- package/dist/model.d.ts +115 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +376 -57
- package/dist/model.js.map +1 -1
- package/dist/pi-document-attachments.d.ts +43 -0
- package/dist/pi-document-attachments.d.ts.map +1 -0
- package/dist/pi-document-attachments.js +155 -0
- package/dist/pi-document-attachments.js.map +1 -0
- package/dist/pi-loop-runtime.d.ts +103 -1
- package/dist/pi-loop-runtime.d.ts.map +1 -1
- package/dist/pi-loop-runtime.js +850 -109
- package/dist/pi-loop-runtime.js.map +1 -1
- package/dist/prompt-attachments.d.ts +98 -0
- package/dist/prompt-attachments.d.ts.map +1 -0
- package/dist/prompt-attachments.js +279 -0
- package/dist/prompt-attachments.js.map +1 -0
- package/dist/session.d.ts +52 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +410 -33
- package/dist/session.js.map +1 -1
- package/dist/stream-chunks.d.ts +15 -1
- package/dist/stream-chunks.d.ts.map +1 -1
- package/dist/stream-chunks.js +39 -18
- package/dist/stream-chunks.js.map +1 -1
- package/dist/strict.d.ts +23 -16
- package/dist/strict.d.ts.map +1 -1
- package/dist/strict.js +12 -8
- package/dist/strict.js.map +1 -1
- package/dist/submission-context.d.ts +7 -0
- package/dist/submission-context.d.ts.map +1 -1
- package/dist/submission-context.js.map +1 -1
- package/dist/submission-runner.d.ts +5 -0
- package/dist/submission-runner.d.ts.map +1 -1
- package/dist/submission-runner.js +11 -2
- package/dist/submission-runner.js.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/usage-completeness.d.ts +39 -0
- package/dist/usage-completeness.d.ts.map +1 -0
- package/dist/usage-completeness.js +135 -0
- package/dist/usage-completeness.js.map +1 -0
- package/dist/voice-openai-realtime.d.ts +24 -2
- package/dist/voice-openai-realtime.d.ts.map +1 -1
- package/dist/voice-openai-realtime.js +266 -49
- package/dist/voice-openai-realtime.js.map +1 -1
- package/dist/voice-pipeline.d.ts +81 -3
- package/dist/voice-pipeline.d.ts.map +1 -1
- package/dist/voice-pipeline.js +429 -60
- package/dist/voice-pipeline.js.map +1 -1
- package/dist/voice-stt-cartesia.d.ts +8 -0
- package/dist/voice-stt-cartesia.d.ts.map +1 -1
- package/dist/voice-stt-cartesia.js +77 -17
- package/dist/voice-stt-cartesia.js.map +1 -1
- package/dist/voice-stt-deepgram.d.ts +10 -2
- package/dist/voice-stt-deepgram.d.ts.map +1 -1
- package/dist/voice-stt-deepgram.js +78 -18
- package/dist/voice-stt-deepgram.js.map +1 -1
- package/dist/voice-stt.d.ts +13 -3
- package/dist/voice-stt.d.ts.map +1 -1
- package/dist/voice-tts-cartesia.d.ts +8 -0
- package/dist/voice-tts-cartesia.d.ts.map +1 -1
- package/dist/voice-tts-cartesia.js +48 -105
- package/dist/voice-tts-cartesia.js.map +1 -1
- package/dist/voice-tts-elevenlabs.d.ts +10 -1
- package/dist/voice-tts-elevenlabs.d.ts.map +1 -1
- package/dist/voice-tts-elevenlabs.js +50 -113
- package/dist/voice-tts-elevenlabs.js.map +1 -1
- package/dist/voice-ws-client.js +16 -3
- package/dist/voice-ws-client.js.map +1 -1
- package/dist/voice-ws-shared.d.ts +205 -6
- package/dist/voice-ws-shared.d.ts.map +1 -1
- package/dist/voice-ws-shared.js +510 -15
- package/dist/voice-ws-shared.js.map +1 -1
- package/dist/voice.d.ts +98 -4
- package/dist/voice.d.ts.map +1 -1
- package/dist/voice.js +71 -1
- package/dist/voice.js.map +1 -1
- package/package.json +3 -3
package/dist/voice.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import type { ToolDef } from './tools.js';
|
|
|
8
8
|
*
|
|
9
9
|
* Audio frames flow in raw bytes. The standard format is PCM 16-bit
|
|
10
10
|
* little-endian at 24kHz mono (OpenAI Realtime default). Telephony
|
|
11
|
-
* bridges (Twilio Media Streams
|
|
11
|
+
* bridges (Twilio Media Streams) run the whole session at `g711_ulaw`
|
|
12
|
+
* 8kHz mono instead, so no resampling happens at the edge.
|
|
12
13
|
*
|
|
13
14
|
* provider.connect() is a low-level transport: its caller owns tool dispatch.
|
|
14
15
|
* Application voice should use session.voice() for server-owned instructions,
|
|
@@ -41,6 +42,13 @@ export interface VoiceConnectOptions {
|
|
|
41
42
|
requestCostLimitApproval?: (ctx: CostLimitContext) => Promise<boolean>;
|
|
42
43
|
/** Abort signal — closes the session when fired. */
|
|
43
44
|
signal?: AbortSignal;
|
|
45
|
+
/**
|
|
46
|
+
* Also emit {@link VoiceSpeechStoppedEvent} (`speech_stopped`) when the
|
|
47
|
+
* provider's VAD detects the end of caller speech. Off by default so
|
|
48
|
+
* existing consumers of {@link VoiceEvent} never see an event type they do
|
|
49
|
+
* not handle. Iterate them with {@link voiceSessionEvents} when enabled.
|
|
50
|
+
*/
|
|
51
|
+
emitSpeechStopped?: boolean;
|
|
44
52
|
}
|
|
45
53
|
/**
|
|
46
54
|
* Events streamed from a `VoiceSession`. `audio_delta` carries raw audio
|
|
@@ -80,28 +88,114 @@ export type VoiceEvent = {
|
|
|
80
88
|
type: 'error';
|
|
81
89
|
message: string;
|
|
82
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Provider VAD detected the end of caller speech. Emitted only when the
|
|
93
|
+
* session was opened with `emitSpeechStopped: true`; telephony bridges use it
|
|
94
|
+
* for reply first-audio latency. Kept outside {@link VoiceEvent} so exhaustive
|
|
95
|
+
* switches over `VoiceEvent` keep compiling.
|
|
96
|
+
*/
|
|
97
|
+
export interface VoiceSpeechStoppedEvent {
|
|
98
|
+
type: 'speech_stopped';
|
|
99
|
+
}
|
|
100
|
+
/** Events a session opened with `emitSpeechStopped: true` may yield. */
|
|
101
|
+
export type VoiceSessionEvent = VoiceEvent | VoiceSpeechStoppedEvent;
|
|
83
102
|
export interface VoiceToolResultInput {
|
|
84
103
|
/** Tool-call id from the matching `tool_call` event. */
|
|
85
104
|
id: string;
|
|
86
105
|
/** JSON-serializable output — stringified before sending. */
|
|
87
106
|
output: unknown;
|
|
88
107
|
}
|
|
108
|
+
/** Barge-in context for {@link VoiceSession.cancelResponse}. */
|
|
109
|
+
export interface VoiceCancelOptions {
|
|
110
|
+
/**
|
|
111
|
+
* Milliseconds of the in-progress assistant audio the caller actually heard,
|
|
112
|
+
* as observed by the playback edge (for example Twilio `mark` echoes).
|
|
113
|
+
* Providers that keep a server-side conversation (OpenAI Realtime) truncate
|
|
114
|
+
* the assistant item to this point so the model's context matches what was
|
|
115
|
+
* played. Ignored by providers without server-side audio history.
|
|
116
|
+
*/
|
|
117
|
+
playedMs?: number;
|
|
118
|
+
/**
|
|
119
|
+
* The `speech_started` event this barge-in reacts to, exactly as yielded by
|
|
120
|
+
* `events()`. Built-in providers bind the cancel to the reply that was
|
|
121
|
+
* playing when that interruption arrived, so an interruption handled late
|
|
122
|
+
* (after the interrupted reply finished and a newer one started) never
|
|
123
|
+
* cancels or truncates the newer reply. Without it, or for an event the
|
|
124
|
+
* session did not yield, the reply playing when the cancel runs is targeted.
|
|
125
|
+
*/
|
|
126
|
+
interruption?: VoiceEvent;
|
|
127
|
+
}
|
|
89
128
|
export interface VoiceSession {
|
|
90
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Append a raw audio frame. Format matches `VoiceConnectOptions.audioFormat`.
|
|
131
|
+
* Built-in providers resolve once the frame is admitted to a bounded
|
|
132
|
+
* provider buffer, and reject with `VoiceBackpressureError` (closing the
|
|
133
|
+
* session) when the provider cannot keep up.
|
|
134
|
+
*/
|
|
91
135
|
sendAudio(frame: Uint8Array): Promise<void>;
|
|
92
136
|
/** Send a text turn (the model responds with audio + text). */
|
|
93
137
|
sendText(text: string): Promise<void>;
|
|
94
138
|
/** Submit a tool-call result back to the model after a `tool_call` event. */
|
|
95
139
|
submitToolResult(input: VoiceToolResultInput): Promise<void>;
|
|
96
140
|
/** Cancel the in-progress response (barge-in). */
|
|
97
|
-
cancelResponse(): Promise<void>;
|
|
98
|
-
/**
|
|
141
|
+
cancelResponse(options?: VoiceCancelOptions): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Async iterable of events. Closes when the session ends or aborts. With
|
|
144
|
+
* `emitSpeechStopped: true` it may also yield {@link VoiceSpeechStoppedEvent}.
|
|
145
|
+
*/
|
|
99
146
|
events(): AsyncIterable<VoiceEvent>;
|
|
100
147
|
/** Tear down the underlying connection. */
|
|
101
148
|
close(): Promise<void>;
|
|
102
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Internal hook a provider session may implement so a barge-in targets the
|
|
152
|
+
* response that was playing when the cancel was requested, not whatever is
|
|
153
|
+
* playing once asynchronous governance (authorization, ownership checks)
|
|
154
|
+
* finishes. Not exported from the package entry points.
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
export declare const CAPTURE_VOICE_CANCEL: unique symbol;
|
|
158
|
+
/** @internal A cancel bound to the response identity captured when it was created. */
|
|
159
|
+
export type VoiceCancelHandle = (options?: VoiceCancelOptions) => Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Capture, synchronously, the response a barge-in targets: the one stamped on
|
|
162
|
+
* `options.interruption` when this session stamped it, otherwise the one
|
|
163
|
+
* playing now. Providers without the internal hook fall back to cancelling
|
|
164
|
+
* whatever is in progress when the handle runs.
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
export declare function captureVoiceCancel(session: VoiceSession, options?: VoiceCancelOptions): VoiceCancelHandle;
|
|
168
|
+
/**
|
|
169
|
+
* Stamp a `speech_started` event with the reply it interrupts, captured when
|
|
170
|
+
* the provider received it.
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
export declare function stampVoiceInterruption<T extends object>(event: T, session: VoiceSession, cancel: VoiceCancelHandle): T;
|
|
174
|
+
/**
|
|
175
|
+
* Internal hook a provider session may implement so a wrapper that does its
|
|
176
|
+
* own cost accounting (governed voice) can hold client-requested
|
|
177
|
+
* continuations (`response.create` from `sendText` / `submitToolResult`) until
|
|
178
|
+
* it has accounted each reply. Once called, every provider `response_done`
|
|
179
|
+
* holds continuations until the returned `settle` is called once for it, in
|
|
180
|
+
* order. Not exported from the package entry points.
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
export declare const HOLD_VOICE_CONTINUATIONS: unique symbol;
|
|
184
|
+
/**
|
|
185
|
+
* Enable {@link HOLD_VOICE_CONTINUATIONS} on a session. Returns the `settle`
|
|
186
|
+
* callback, or `undefined` when the provider does not implement the hook.
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
export declare function holdVoiceContinuations(session: VoiceSession): (() => void) | undefined;
|
|
103
190
|
export interface VoiceProvider {
|
|
104
191
|
name: string;
|
|
105
192
|
connect(options: VoiceConnectOptions): Promise<VoiceSession>;
|
|
106
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Iterate a session's events including {@link VoiceSpeechStoppedEvent}. Use it
|
|
196
|
+
* for sessions opened with `emitSpeechStopped: true`, whose `events()` may yield
|
|
197
|
+
* `speech_stopped` even though `VoiceSession.events()` is typed as
|
|
198
|
+
* {@link VoiceEvent} for backward compatibility.
|
|
199
|
+
*/
|
|
200
|
+
export declare function voiceSessionEvents(session: Pick<VoiceSession, 'events'>): AsyncIterable<VoiceSessionEvent>;
|
|
107
201
|
//# sourceMappingURL=voice.d.ts.map
|
package/dist/voice.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice.d.ts","sourceRoot":"","sources":["../src/voice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"voice.d.ts","sourceRoot":"","sources":["../src/voice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;AAEnE,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,qEAAqE;IACrE,aAAa,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACtC,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B;;;OAGG;IACH,w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EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,GAAG,CAAC,CAGtH;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,EAAE,OAAO,MAAyD,CAAC;AAExG;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAGtF;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAE1G"}
|
package/dist/voice.js
CHANGED
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Internal hook a provider session may implement so a barge-in targets the
|
|
3
|
+
* response that was playing when the cancel was requested, not whatever is
|
|
4
|
+
* playing once asynchronous governance (authorization, ownership checks)
|
|
5
|
+
* finishes. Not exported from the package entry points.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export const CAPTURE_VOICE_CANCEL = Symbol('fabric-harness.voice.captureCancel');
|
|
9
|
+
/**
|
|
10
|
+
* Capture, synchronously, the response a barge-in targets: the one stamped on
|
|
11
|
+
* `options.interruption` when this session stamped it, otherwise the one
|
|
12
|
+
* playing now. Providers without the internal hook fall back to cancelling
|
|
13
|
+
* whatever is in progress when the handle runs.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function captureVoiceCancel(session, options) {
|
|
17
|
+
const interruption = options?.interruption;
|
|
18
|
+
if (interruption !== null && typeof interruption === 'object') {
|
|
19
|
+
// Only the session that stamped the event may act on its captured target.
|
|
20
|
+
const stamped = interruptionTargets.get(interruption);
|
|
21
|
+
if (stamped && stamped.session === session)
|
|
22
|
+
return stamped.cancel;
|
|
23
|
+
}
|
|
24
|
+
const capture = session[CAPTURE_VOICE_CANCEL];
|
|
25
|
+
if (typeof capture === 'function')
|
|
26
|
+
return capture.call(session);
|
|
27
|
+
return next => session.cancelResponse(next);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Interruption events a provider session stamped, at receipt, with the cancel
|
|
31
|
+
* bound to the reply playing then. A side map keeps the stamp unforgeable and
|
|
32
|
+
* off the event's enumerable shape.
|
|
33
|
+
*/
|
|
34
|
+
const interruptionTargets = new WeakMap();
|
|
35
|
+
/**
|
|
36
|
+
* Stamp a `speech_started` event with the reply it interrupts, captured when
|
|
37
|
+
* the provider received it.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export function stampVoiceInterruption(event, session, cancel) {
|
|
41
|
+
interruptionTargets.set(event, { session, cancel });
|
|
42
|
+
return event;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Internal hook a provider session may implement so a wrapper that does its
|
|
46
|
+
* own cost accounting (governed voice) can hold client-requested
|
|
47
|
+
* continuations (`response.create` from `sendText` / `submitToolResult`) until
|
|
48
|
+
* it has accounted each reply. Once called, every provider `response_done`
|
|
49
|
+
* holds continuations until the returned `settle` is called once for it, in
|
|
50
|
+
* order. Not exported from the package entry points.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export const HOLD_VOICE_CONTINUATIONS = Symbol('fabric-harness.voice.holdContinuations');
|
|
54
|
+
/**
|
|
55
|
+
* Enable {@link HOLD_VOICE_CONTINUATIONS} on a session. Returns the `settle`
|
|
56
|
+
* callback, or `undefined` when the provider does not implement the hook.
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export function holdVoiceContinuations(session) {
|
|
60
|
+
const hold = session[HOLD_VOICE_CONTINUATIONS];
|
|
61
|
+
return typeof hold === 'function' ? hold.call(session) : undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Iterate a session's events including {@link VoiceSpeechStoppedEvent}. Use it
|
|
65
|
+
* for sessions opened with `emitSpeechStopped: true`, whose `events()` may yield
|
|
66
|
+
* `speech_stopped` even though `VoiceSession.events()` is typed as
|
|
67
|
+
* {@link VoiceEvent} for backward compatibility.
|
|
68
|
+
*/
|
|
69
|
+
export function voiceSessionEvents(session) {
|
|
70
|
+
return session.events();
|
|
71
|
+
}
|
|
2
72
|
//# sourceMappingURL=voice.js.map
|
package/dist/voice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice.js","sourceRoot":"","sources":["../src/voice.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"voice.js","sourceRoot":"","sources":["../src/voice.ts"],"names":[],"mappings":"AAsIA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkB,MAAM,CAAC,oCAAoC,CAAC,CAAC;AAKhG;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAqB,EAAE,OAA4B;IACpF,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC;IAC3C,IAAI,YAAY,KAAK,IAAI,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC9D,0EAA0E;QAC1E,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC;IACpE,CAAC;IACD,MAAM,OAAO,GAAI,OAAgD,CAAC,oBAAoB,CAAC,CAAC;IACxF,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,OAAQ,OAAmC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7F,OAAO,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAgE,CAAC;AAExG;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAmB,KAAQ,EAAE,OAAqB,EAAE,MAAyB;IACjH,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkB,MAAM,CAAC,wCAAwC,CAAC,CAAC;AAExG;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAqB;IAC1D,MAAM,IAAI,GAAI,OAAoD,CAAC,wBAAwB,CAAC,CAAC;IAC7F,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAE,IAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3F,CAAC;AAOD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAqC;IACtE,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabric-harness/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "Headless TypeScript framework for building durable, deployable autonomous agents — core SDK.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Fabric",
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"test:watch": "vitest"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
|
-
"@earendil-works/pi-agent-core": "^0.
|
|
102
|
-
"@earendil-works/pi-ai": "^0.
|
|
101
|
+
"@earendil-works/pi-agent-core": "^0.87.1",
|
|
102
|
+
"@earendil-works/pi-ai": "^0.87.1",
|
|
103
103
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
104
104
|
"@opentelemetry/api": "^1.9.1",
|
|
105
105
|
"just-bash": "^2.14.4"
|