@archboard/codex-realtime-voice 0.5.0 → 0.6.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.
Files changed (34) hide show
  1. package/README.md +32 -41
  2. package/dist/browser.d.mts +1 -3
  3. package/dist/browser.mjs +67 -66
  4. package/dist/{contract-CDS04znV.d.mts → contract-B2ILifH5.d.mts} +3 -3
  5. package/dist/{contract-qg6q9-vH.d.mts → contract-CkitFygd.d.mts} +97 -3054
  6. package/dist/{contract-DkiXnfc8.d.mts → contract-D9_WuSxD.d.mts} +3 -3
  7. package/dist/contract.d.mts +1 -1
  8. package/dist/controllers.d.mts +221 -6
  9. package/dist/controllers.mjs +3 -3
  10. package/dist/{gateway-envelope-DRBUhFx9.d.mts → gateway-envelope-O67wCRD7.d.mts} +3 -2
  11. package/dist/{realtime-state-CTBmCjt1.mjs → gateway-envelope-jUP82Pq1.mjs} +71 -3
  12. package/dist/identity-capabilities-3Q_2tJiT.d.mts +147 -0
  13. package/dist/instructions-B-6HVmoD.mjs +1024 -0
  14. package/dist/{contract-JI3xv17m.d.mts → instructions-C6TkBWcp.d.mts} +14 -998
  15. package/dist/{model-DnitkA24.mjs → model-MSyAviwx.mjs} +1652 -85
  16. package/dist/react.d.mts +1 -1
  17. package/dist/{realtime-contract-wHmSyUIe.d.mts → realtime-contract-C-1bMn-F.d.mts} +1 -22
  18. package/dist/realtime.d.mts +2 -3
  19. package/dist/realtime.mjs +1 -3
  20. package/dist/runtime.d.mts +3 -18
  21. package/dist/runtime.mjs +2 -2
  22. package/dist/schemas.d.mts +3 -13
  23. package/dist/schemas.mjs +1 -1
  24. package/dist/server.d.mts +977 -217
  25. package/dist/server.mjs +17771 -10076
  26. package/dist/{snapshot-BCrCORmt.d.mts → snapshot-DCl2vsJl.d.mts} +9 -154
  27. package/dist/{transport-Bqb8KE5T.mjs → transport-DVUz3EK0.mjs} +17 -13
  28. package/package.json +1 -1
  29. package/dist/app-server-contract-D4E5bibD.mjs +0 -177
  30. package/dist/gateway-envelope-DXTRMB3q.mjs +0 -45
  31. package/dist/instructions-8ACs49yJ.mjs +0 -8980
  32. package/dist/media-state-CNkFo93s.d.mts +0 -215
  33. package/dist/realtime-contract-DwkCluo2.mjs +0 -1167
  34. package/dist/realtime-state-DT4uvrIV.d.mts +0 -16
@@ -1,215 +0,0 @@
1
- import { b as VoiceNarrative } from "./snapshot-BCrCORmt.mjs";
2
- import { d as RealtimeState, i as RealtimeCorrelation, l as RealtimeServer, n as AppendOutcome, p as RealtimeUnsubscribe } from "./realtime-contract-wHmSyUIe.mjs";
3
- import "./realtime-state-DT4uvrIV.mjs";
4
- import { i as BrowserWorkbenchTransport } from "./contract-CDS04znV.mjs";
5
- /** A playback stream is anything carrying audio tracks: a MediaStream, or the realtime module's remote stream port. */
6
- interface VoiceOutputPlayback {
7
- readonly getAudioTracks: () => ReadonlyArray<Pick<MediaStreamTrack, "readyState">>;
8
- }
9
- /** Whether the audio graph behind a meter is producing samples. */
10
- type VoiceOutputPlaybackState = "running" | "suspended" | "closed";
11
- /** One measured playback stream. `read` is called once per animation frame. */
12
- interface VoiceOutputMeter {
13
- /** The playback state right now; `suspended` means autoplay policy holds the graph. */
14
- readonly playback: () => VoiceOutputPlaybackState;
15
- /** Asks the graph to run; resolves whatever the resulting state is. */
16
- readonly resume: () => Promise<void>;
17
- /** The root-mean-square level of the latest output frame, 0..1. */
18
- readonly read: () => number;
19
- /** Releases the graph. Idempotent. */
20
- readonly close: () => void;
21
- }
22
- /** Builds a meter over one playback stream, or null when the browser cannot analyse audio. */
23
- type VoiceOutputMeterFactory = (playback: VoiceOutputPlayback) => VoiceOutputMeter | null;
24
- /** The RMS level at or above which the model counts as speaking. */
25
- declare const VOICE_OUTPUT_SPEAKING_LEVEL = 0.02;
26
- /** Frame scheduling, injectable so a test can step frames by hand. */
27
- interface VoiceOutputFrameScheduler {
28
- readonly requestFrame: (callback: () => void) => number;
29
- readonly cancelFrame: (handle: number) => void;
30
- }
31
- /** Receives every published level. */
32
- type VoiceOutputLevelListener = (level: number) => void;
33
- /** The measured model output level as an external store. */
34
- interface VoiceOutputLevelSource {
35
- /** The latest published level, 0..1. */
36
- readonly current: () => number;
37
- readonly subscribe: (listener: VoiceOutputLevelListener) => () => void;
38
- /** Follows one playback meter, releasing any previous one. */
39
- readonly follow: (meter: VoiceOutputMeter) => void;
40
- /** Stops following, closes the meter, and settles the level to 0. */
41
- readonly settle: () => void;
42
- /** Settles and refuses further followers and subscribers. */
43
- readonly dispose: () => void;
44
- }
45
- /** Something that raises named events; the DOM's EventTarget satisfies it. */
46
- interface RealtimeEventSource {
47
- addEventListener(type: string, listener: () => void): void;
48
- removeEventListener(type: string, listener: () => void): void;
49
- }
50
- /** One captured or received audio track. */
51
- interface RealtimeMediaTrack extends Pick<MediaStreamTrack, "enabled" | "readyState" | "stop">, RealtimeEventSource {}
52
- /** A stream of tracks: the captured microphone, or the remote playback. */
53
- interface RealtimeMediaStream {
54
- getTracks(): readonly RealtimeMediaTrack[];
55
- getAudioTracks(): readonly RealtimeMediaTrack[];
56
- }
57
- /** The realtime events channel. */
58
- interface RealtimeDataChannel extends RealtimeEventSource {
59
- readonly readyState: RTCDataChannelState;
60
- close(): void;
61
- }
62
- /** One outbound sender on the peer. */
63
- interface RealtimeSender {
64
- readonly track: RealtimeMediaTrack | null;
65
- replaceTrack(track: null): Promise<void>;
66
- }
67
- /** One inbound receiver on the peer. */
68
- interface RealtimeReceiver {
69
- readonly track: RealtimeMediaTrack;
70
- }
71
- /** The peer connection. */
72
- interface RealtimePeer extends RealtimeEventSource {
73
- readonly connectionState: RTCPeerConnectionState;
74
- readonly iceConnectionState: RTCIceConnectionState;
75
- readonly localDescription: Pick<RTCSessionDescription, "sdp"> | null;
76
- addTransceiver(track: RealtimeMediaTrack, stream: RealtimeMediaStream): void;
77
- createDataChannel(label: string): RealtimeDataChannel;
78
- createOffer(): Promise<RTCSessionDescriptionInit>;
79
- setLocalDescription(description: RTCSessionDescriptionInit): Promise<void>;
80
- setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>;
81
- getSenders(): readonly RealtimeSender[];
82
- getReceivers(): readonly RealtimeReceiver[];
83
- removeTrack(sender: RealtimeSender): void;
84
- close(): void;
85
- }
86
- /** The microphone source. */
87
- interface RealtimeMediaDevices extends RealtimeEventSource {
88
- getUserMedia(constraints: MediaStreamConstraints): Promise<RealtimeMediaStream>;
89
- }
90
- /** One scheduled timer; cancelling one that already fired is harmless. */
91
- interface RealtimeTimer {
92
- readonly cancel: () => void;
93
- }
94
- /** Everything the media session needs from the browser. */
95
- interface RealtimeMediaEnvironment {
96
- /** Null when the browser cannot request a microphone at all. */
97
- readonly mediaDevices: () => RealtimeMediaDevices | null;
98
- /** True when WebRTC, MediaStream, Web Audio and animation frames all exist. */
99
- readonly realtimeSupported: () => boolean;
100
- readonly createPeerConnection: () => RealtimePeer;
101
- readonly createMediaStream: (tracks: readonly RealtimeMediaTrack[]) => RealtimeMediaStream;
102
- /** Makes the remote stream the element's source; the one place a stream meets an element. */
103
- readonly attachPlayback: (element: HTMLMediaElement, stream: RealtimeMediaStream) => void;
104
- /** Builds the output meter over the remote playback stream. */
105
- readonly analysePlayback: VoiceOutputMeterFactory;
106
- readonly frames: VoiceOutputFrameScheduler;
107
- /** A monotonic clock in milliseconds. */
108
- readonly now: () => number;
109
- readonly schedule: (callback: () => void, delayMs: number) => RealtimeTimer;
110
- }
111
- /** The published view of the session: which run, and where it stands. */
112
- interface RealtimeMediaSnapshot {
113
- readonly correlation: RealtimeCorrelation | null;
114
- readonly state: RealtimeState;
115
- }
116
- /** Receives every published snapshot. */
117
- type RealtimeMediaListener = (snapshot: RealtimeMediaSnapshot) => void;
118
- /** The session. There is one per media owner and no second voice backend. */
119
- interface RealtimeMediaSession {
120
- readonly getSnapshot: () => RealtimeMediaSnapshot;
121
- readonly subscribe: (listener: RealtimeMediaListener) => RealtimeUnsubscribe;
122
- readonly start: (correlation: RealtimeCorrelation) => Promise<RealtimeMediaSnapshot>;
123
- /**
124
- * Silences the captured microphone without touching the negotiated
125
- * connection: every local audio track is disabled and the run publishes
126
- * `muted`. The server receives nothing. A run that is not `listening` is left
127
- * exactly as it is.
128
- */
129
- readonly mute: () => Promise<RealtimeMediaSnapshot>;
130
- /** The exact inverse of `mute`, from `muted` only. */
131
- readonly unmute: () => Promise<RealtimeMediaSnapshot>;
132
- readonly stop: () => Promise<RealtimeMediaSnapshot>;
133
- readonly dispose: () => Promise<void>;
134
- /** The measured model output level, on its own channel. Never the microphone. */
135
- readonly outputLevel: VoiceOutputLevelSource;
136
- }
137
- /** Construction options; the browser environment is the default. */
138
- interface RealtimeMediaSessionOptions {
139
- readonly environment?: RealtimeMediaEnvironment;
140
- /**
141
- * Hears the voice's receivers once its remote audio is built, so a host can tune or measure
142
- * how the voice is received: a recording buffers more of it than a conversation can.
143
- */
144
- readonly receivers?: (receivers: readonly RealtimeReceiver[]) => void;
145
- }
146
- /**
147
- * Creates the session.
148
- * @param server The neutral realtime server.
149
- * @param options The environment, when not the browser's own, and who hears the voice's receivers.
150
- * @returns The session.
151
- */
152
- declare function createRealtimeMediaSession(server: RealtimeServer, options?: RealtimeMediaSessionOptions): RealtimeMediaSession;
153
- /** Where the owner stands: installing, ready to start, or why it cannot. */
154
- type BrowserWorkbenchMediaState = {
155
- readonly state: "attaching";
156
- } | {
157
- readonly state: "ready";
158
- } | {
159
- readonly state: "unavailable";
160
- readonly reason: "detached" | "socket_closed" | "media_api_unavailable" | "permission_denied" | "negotiation_failed";
161
- readonly message: string;
162
- };
163
- /** Owns local realtime media while the workbench transport owns the server socket. */
164
- interface BrowserWorkbenchMediaOwner {
165
- readonly attach: (transport: BrowserWorkbenchTransport) => Promise<BrowserWorkbenchMediaState>;
166
- readonly detach: (transport: BrowserWorkbenchTransport) => Promise<void>;
167
- /**
168
- * Starts realtime media, as an ordinary session or one that presents a host narrative.
169
- * @param narrative The narrative the session presents, when there is one.
170
- */
171
- readonly start: (narrative?: VoiceNarrative | null) => Promise<RealtimeMediaSnapshot>;
172
- readonly appendText: (text: string) => Promise<AppendOutcome>;
173
- /**
174
- * Silences and restores the captured microphone. Neither claims a lease nor
175
- * sends a command: the realtime session disables the local audio track it
176
- * already owns, so there is no wire operation to authorize. The forwarded
177
- * subscription is what publishes the resulting phase.
178
- */
179
- readonly mute: () => Promise<RealtimeMediaSnapshot>;
180
- readonly unmute: () => Promise<RealtimeMediaSnapshot>;
181
- readonly stop: () => Promise<RealtimeMediaSnapshot>;
182
- readonly snapshot: () => RealtimeMediaSnapshot | null;
183
- readonly state: () => BrowserWorkbenchMediaState;
184
- /** The active session's measured model output level, or null between sessions. */
185
- readonly outputLevel: () => RealtimeMediaSession["outputLevel"] | null;
186
- /**
187
- * Fires whenever `snapshot()` or `state()` may have changed, including the
188
- * browser-originated realtime publications that reach only the inner
189
- * realtime session: a lost microphone, a dropped ICE connection, a closed
190
- * data channel, and every in-start phase.
191
- */
192
- readonly subscribe: (listener: () => void) => () => void;
193
- readonly dispose: () => Promise<void>;
194
- }
195
- /** Construction options; every default is the real browser. */
196
- interface BrowserWorkbenchMediaOwnerOptions {
197
- readonly createMediaSession?: typeof createRealtimeMediaSession;
198
- readonly environment?: RealtimeMediaEnvironment;
199
- /** Where the remote audio element comes from and is mounted. */
200
- readonly audioElements?: BrowserAudioElementPort;
201
- /** Hears the voice's receivers once its remote audio is built. */
202
- readonly receivers?: RealtimeMediaSessionOptions["receivers"];
203
- /** Whether this browser can carry realtime media at all. */
204
- readonly mediaSupported?: () => boolean;
205
- }
206
- /** Creates and mounts the remote audio element. */
207
- interface BrowserAudioElementPort {
208
- readonly create: () => HTMLAudioElement;
209
- }
210
- /**
211
- * The real browser's audio elements.
212
- * @returns The port.
213
- */
214
- declare function browserAudioElements(): BrowserAudioElementPort;
215
- export { VOICE_OUTPUT_SPEAKING_LEVEL as a, browserAudioElements as i, BrowserWorkbenchMediaOwner as n, VoiceOutputLevelSource as o, BrowserWorkbenchMediaOwnerOptions as r, BrowserAudioElementPort as t };