agent-yes 1.303.1 → 1.304.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 (184) hide show
  1. package/README.md +54 -0
  2. package/default.config.yaml +5 -5
  3. package/dist/{JsonlStore-BpYZZTap.js → JsonlStore-CB_0sfdT.js} +5 -4
  4. package/dist/{SUPPORTED_CLIS-Dq9Lq9WJ.js → SUPPORTED_CLIS-C_1IiOj3.js} +2 -2
  5. package/dist/SUPPORTED_CLIS-Do3GHAY1.js +12 -0
  6. package/dist/{agentShare-suB6yPgO.js → agentShare-BvpEm-Fr.js} +10 -9
  7. package/dist/{askCli-BU3CNCLU.js → askCli-KmMf-3wA.js} +6 -6
  8. package/dist/{browser-BmxN1Ur9.js → browser-BAFPmEvN.js} +2 -2
  9. package/dist/{callback-Ctj3_Wxp.js → callback-BiSUhjw7.js} +6 -6
  10. package/dist/callback-SqLD2mMX.js +17 -0
  11. package/dist/{callbackCore-DSJWhqAe.js → callbackCore-BZ_10zyc.js} +1 -1
  12. package/dist/{callbackCore-BesbQ6-Z.js → callbackCore-Deve5pv3.js} +1 -1
  13. package/dist/{channels-j5nWuzlQ.js → channels-Y36S0ccW.js} +2 -2
  14. package/dist/cli.js +118 -13
  15. package/dist/{cmdDsh-2LP0grim.js → cmdDsh-DZ8bLsH7.js} +1 -1
  16. package/dist/cmdKill-CzSBfWmx.js +116 -0
  17. package/dist/{cmdPs-wc1j85fi.js → cmdPs-DBt23Qz0.js} +11 -10
  18. package/dist/{cwdConflictWarn-skQSMwEh.js → cwdConflictWarn-y-epQyOj.js} +21 -5
  19. package/dist/{cwdPassthroughHint-BUbWMoz0.js → cwdPassthroughHint-CzWh0hrw.js} +1 -1
  20. package/dist/{expose-Dawq1LxC.js → expose-Bhsn5yUz.js} +2 -2
  21. package/dist/forceKill-BDqxx4uQ.js +44 -0
  22. package/dist/{forkNested-CavHyWzA.js → forkNested-3heLs5XC.js} +45 -5
  23. package/dist/{globalPidIndex-CRB5KtyL.js → globalPidIndex-BsjlId-h.js} +6 -5
  24. package/dist/{globalPidIndex-BftWlg2V.js → globalPidIndex-uoz8Esqz.js} +2 -2
  25. package/dist/{hist-Cs0KFSUW.js → hist-DY16wm7g.js} +1 -1
  26. package/dist/{identity-DA7YI9km.js → identity-C0MxfwI2.js} +1 -1
  27. package/dist/{identity-Bk-aG_xl.js → identity-Ckav3-Up.js} +1 -1
  28. package/dist/index.js +7 -7
  29. package/dist/{initMsg-CcTqFtsp.js → initMsg-BEVDWYnv.js} +1 -1
  30. package/dist/{initMsg-D9KJnfgC.js → initMsg-GPU52N-j.js} +1 -1
  31. package/dist/liagent/box-BSIrRRc_.js +2320 -0
  32. package/dist/liagent/box-DloywR57.d.ts +409 -0
  33. package/dist/liagent/box.d.ts +3 -0
  34. package/dist/liagent/box.js +3 -0
  35. package/dist/liagent/cli.d.ts +1 -0
  36. package/dist/liagent/cli.js +908 -0
  37. package/dist/liagent/client.d.ts +28 -0
  38. package/dist/liagent/client.js +240 -0
  39. package/dist/liagent/echo-BvzPSI0x.js +86 -0
  40. package/dist/liagent/echo-W2RcMEny.d.ts +38 -0
  41. package/dist/liagent/hub.d.ts +405 -0
  42. package/dist/liagent/hub.js +1831 -0
  43. package/dist/liagent/index.d.ts +14 -0
  44. package/dist/liagent/index.js +10 -0
  45. package/dist/liagent/liagent.js +339 -0
  46. package/dist/liagent/mic-audio-C3Shud_F.js +754 -0
  47. package/dist/liagent/mic-audio-DMCWtEI-.d.ts +317 -0
  48. package/dist/liagent/mic-button-CtZHFBSG.js +651 -0
  49. package/dist/liagent/mic-button-Y0ioPetQ.d.ts +248 -0
  50. package/dist/liagent/mic.d.ts +3 -0
  51. package/dist/liagent/mic.js +4 -0
  52. package/dist/liagent/progress-CJs08bXb.js +473 -0
  53. package/dist/liagent/progress-CfE-meHr.d.ts +205 -0
  54. package/dist/liagent/progress.d.ts +2 -0
  55. package/dist/liagent/progress.js +3 -0
  56. package/dist/liagent/protocol.d.ts +324 -0
  57. package/dist/liagent/protocol.js +504 -0
  58. package/dist/liagent/speech-rate-DXeJjRTc.js +42 -0
  59. package/dist/liagent/state-tree-BZCmAknI.js +353 -0
  60. package/dist/liagent/tree-BrR7NwMf.js +710 -0
  61. package/dist/liagent/tree-HB9RhX_H.d.ts +295 -0
  62. package/dist/liagent/tree.d.ts +2 -0
  63. package/dist/liagent/tree.js +4 -0
  64. package/dist/liagent/ui-strings-B03le3fh.d.ts +27 -0
  65. package/dist/liagent/ui-strings-CJIwW5Gf.js +794 -0
  66. package/dist/liagent/ui.d.ts +394 -0
  67. package/dist/liagent/ui.js +5 -0
  68. package/dist/liagent/voice-D7yeS9VM.js +802 -0
  69. package/dist/liagent/voice-Qo7SCgi8.d.ts +308 -0
  70. package/dist/liagent/voice.d.ts +3 -0
  71. package/dist/liagent/voice.js +4 -0
  72. package/dist/{notifyDaemon-C7GlfJ1E.js → notifyDaemon-DkUB7GV2.js} +10 -9
  73. package/dist/{openBrowser-1cIo4dJL.js → openBrowser-CQAOIrD6.js} +1 -1
  74. package/dist/oxmgrService-DlYHmqyI.js +37 -0
  75. package/dist/oxmgrService-o9L3I6FX.js +3 -0
  76. package/dist/{parentLink-DoEWVGld.js → parentLink-BcAYcO9L.js} +2 -2
  77. package/dist/{parentLink-B58V1RVd.js → parentLink-MBUD3oY2.js} +2 -2
  78. package/dist/{parentPingLoop-C73bbmCE.js → parentPingLoop-DDO592Wh.js} +5 -5
  79. package/dist/{pidStore-433kvh9D.js → pidStore-C50VPk3E.js} +3 -3
  80. package/dist/pidStore-COkPjpW8.js +6 -0
  81. package/dist/{procStats-BvmrBrOs.js → procStats-DwTxj3rs.js} +1 -1
  82. package/dist/{remotes-MfdV9M8u.js → remotes-BqLoB5GR.js} +2 -2
  83. package/dist/{remotes-DevcBeLl.js → remotes-BsMGvAay.js} +3 -3
  84. package/dist/{roomReplyAlias-DFqg_6IU.js → roomReplyAlias-B-v76TA8.js} +3 -3
  85. package/dist/roomReplyAlias-BzWUBkQy.js +6 -0
  86. package/dist/{rustBinary-7VK7oLlW.js → rustBinary-BrJ2p8wy.js} +2 -2
  87. package/dist/{rustBinary-BV4LxMMn.js → rustBinary-vpfpWj1q.js} +2 -2
  88. package/dist/{schedule-Dp0qkNO1.js → schedule-Bzjhl6-h.js} +15 -44
  89. package/dist/schedulesCli-CLqieyQZ.js +784 -0
  90. package/dist/senderAncestry-CVHeKk1Y.js +173 -0
  91. package/dist/senderAncestry-KhAUPCQs.js +3 -0
  92. package/dist/{serve-BpOIIOVc.js → serve-XwFYE0cE.js} +67 -69
  93. package/dist/{serveRust-CbBrcUrg.js → serveRust-BfWkeL6T.js} +31 -4
  94. package/dist/{setup-DdIBk6Iv.js → setup-D4-s2VZw.js} +5 -5
  95. package/dist/{share-w5oRbvlj.js → share-CbFetL5H.js} +1 -1
  96. package/dist/{share-DrS3LYqf.js → share-_TPYAGWC.js} +1 -1
  97. package/dist/{shareCmd-DDENkBW2.js → shareCmd-DUBsVI3e.js} +10 -10
  98. package/dist/spawnGate-Dfj9V76w.js +5 -0
  99. package/dist/{spawnGate-lr3tvA6U.js → spawnGate-Dj_WaS29.js} +3 -3
  100. package/dist/{subcommands-DxgvDmZX.js → subcommands-B7YZJL8n.js} +471 -307
  101. package/dist/subcommands-BZPxFgkT.js +15 -0
  102. package/dist/{systemPathLink-SjUzgSiq.js → systemPathLink-Y3iC7bYV.js} +1 -1
  103. package/dist/{terminal-C2h7tpe0.js → terminal-13cGj3h6.js} +2 -2
  104. package/dist/terminal.js +1 -1
  105. package/dist/{todoAutomation-TTp_Qz9G.js → todoAutomation-CKlrxuZv.js} +2 -2
  106. package/dist/{todoCli-BWm5nZE0.js → todoCli-CU9vSJSJ.js} +6 -6
  107. package/dist/{todoIdentity-BvXZKWJI.js → todoIdentity-CzS1e7VL.js} +2 -2
  108. package/dist/{todoStore-C9RTz0Vs.js → todoStore-msRCEUi1.js} +2 -2
  109. package/dist/{tray-BeRSozJz.js → tray-CLktEN3G.js} +1 -1
  110. package/dist/{trayApp-QQjqhDv1.js → trayApp-5_OlvQcz.js} +2 -2
  111. package/dist/trayApp-DkAPo0m6.js +5 -0
  112. package/dist/{ts-6LF7f4fx.js → ts-njuddXQz.js} +126 -57
  113. package/dist/{versionChecker-Bc62HNf6.js → versionChecker-BJycAanp.js} +2 -2
  114. package/dist/{webrtcLink-va_gAR77.js → webrtcLink-DcvacEci.js} +1 -1
  115. package/dist/{webrtcLink-SsInrVHU.js → webrtcLink-WxS1nTIs.js} +1 -1
  116. package/dist/{webrtcRemote-BlGyNZDC.js → webrtcRemote-C3xQyf3u.js} +2 -2
  117. package/dist/{widget-Crb5zeHL.js → widget-DmRwOlco.js} +3 -3
  118. package/dist/widgets.js +1 -1
  119. package/dist/{workspaceConfig-BLWB5Wu9.js → workspaceConfig-DBgsu81B.js} +1 -1
  120. package/dist/{ws-DIbwNz8Z.js → ws-ByO6JO6m.js} +3 -3
  121. package/dist/{ws-BRhPG1Vy.js → ws-D0-Jg88z.js} +9 -8
  122. package/lab/ui/index.html +1 -1
  123. package/lab/ui/lab/posts/2026-08-11-slack-term-safe-writes.md +1 -1
  124. package/package.json +73 -8
  125. package/ts/JsonlStore.ts +10 -3
  126. package/ts/cli-idle.bun.spec.ts +1 -1
  127. package/ts/cli-idle.spec.ts +1 -1
  128. package/ts/cli.ts +35 -0
  129. package/ts/cmdKill.bun.spec.ts +155 -0
  130. package/ts/cmdKill.spec.ts +155 -0
  131. package/ts/cmdKill.ts +183 -0
  132. package/ts/composerGuard.edges.spec.ts +91 -0
  133. package/ts/composerGuard.spec.ts +53 -6
  134. package/ts/composerGuard.ts +42 -13
  135. package/ts/conptyModeFilter.spec.ts +30 -0
  136. package/ts/conptyModeFilter.ts +53 -0
  137. package/ts/copyLiagent.ts +42 -0
  138. package/ts/cwdConflictWarn.io.spec.ts +50 -0
  139. package/ts/cwdConflictWarn.spec.ts +34 -1
  140. package/ts/cwdConflictWarn.ts +43 -5
  141. package/ts/cwdGuard.spec.ts +110 -0
  142. package/ts/cwdGuard.ts +118 -0
  143. package/ts/forceKill.ts +52 -0
  144. package/ts/forkNested.bun.spec.ts +41 -0
  145. package/ts/forkNested.spec.ts +41 -0
  146. package/ts/forkNested.ts +48 -1
  147. package/ts/globalPidIndex.edges.spec.ts +125 -0
  148. package/ts/globalPidIndex.ts +6 -2
  149. package/ts/index.ts +13 -1
  150. package/ts/interruptSend.bun.spec.ts +99 -0
  151. package/ts/interruptSend.spec.ts +99 -0
  152. package/ts/interruptSend.ts +51 -0
  153. package/ts/lockRegistry.spec.ts +49 -0
  154. package/ts/lsRenderCache.spec.ts +58 -0
  155. package/ts/needsInput.edges.spec.ts +23 -0
  156. package/ts/parseCliArgs.ts +7 -0
  157. package/ts/pushGatePlan.spec.ts +147 -0
  158. package/ts/roomReplyAlias.io.spec.ts +81 -0
  159. package/ts/schedule.ts +5 -1
  160. package/ts/schedules.bun.spec.ts +397 -0
  161. package/ts/schedules.spec.ts +397 -0
  162. package/ts/schedules.ts +517 -0
  163. package/ts/schedulesCli.ts +386 -0
  164. package/ts/sendControl.bun.spec.ts +12 -0
  165. package/ts/senderAncestry.ts +1 -3
  166. package/ts/serve.ts +22 -33
  167. package/ts/serveRust.spec.ts +29 -2
  168. package/ts/serveRust.ts +27 -2
  169. package/ts/sizeNego.bun.spec.ts +9 -2
  170. package/ts/sizeNego.spec.ts +9 -2
  171. package/ts/sizeNego.ts +10 -5
  172. package/ts/subcommands.spec.ts +348 -9
  173. package/ts/subcommands.ts +513 -93
  174. package/ts/suggestAgents.spec.ts +33 -0
  175. package/ts/terminal/browser.ts +1 -1
  176. package/ts/todoParse.spec.ts +22 -1
  177. package/ts/todoParse.ts +19 -0
  178. package/dist/SUPPORTED_CLIS-ByO5twge.js +0 -12
  179. package/dist/callback-D7qfh_7p.js +0 -16
  180. package/dist/pidStore-BRlKRHXY.js +0 -6
  181. package/dist/roomReplyAlias-DuEkSSDI.js +0 -6
  182. package/dist/spawnGate-DeQBTX-o.js +0 -5
  183. package/dist/subcommands-DmiswRy4.js +0 -14
  184. package/dist/trayApp-C4TAvRvU.js +0 -5
@@ -0,0 +1,317 @@
1
+ //#region src/mic.d.ts
2
+ /**
3
+ * The mic, without the browser: a listening mode in which a voice-activity
4
+ * detector cuts speech into utterances, each one sent to the host's STT
5
+ * endpoint as soon as it ends. Requests run in parallel; transcripts are
6
+ * appended in the order spoken. A long utterance also sends rolling partial
7
+ * chunks, whose text shows dimmed until the final one replaces it. Nothing is
8
+ * sent as a chat message here: the text lands in the draft, and the rules
9
+ * below (appendDictation) say when it goes out. The VAD, the upload and the
10
+ * timers are injected, so all of this is tested with fakes (test/mic.test.ts);
11
+ * src/mic-audio.ts has the browser pieces and src/mic-button.ts the element.
12
+ */
13
+ /** Longest utterance: past this it is cut and sent, and listening goes on. */
14
+ declare const MAX_UTTERANCE_MS = 30000;
15
+ /** The VADs hand over 16 kHz mono. */
16
+ declare const RATE = 16000;
17
+ /** Partials: one every PARTIAL_EVERY_MS of speech, once it is PARTIAL_MIN_MS long… */
18
+ declare const PARTIAL_EVERY_MS = 2500;
19
+ declare const PARTIAL_MIN_MS = 3000;
20
+ /** …each chunk overlapping the one before by this much, so a word cut at its edge is heard whole. */
21
+ declare const PARTIAL_OVERLAP_MS = 1500;
22
+ /** Shown in the input for an utterance still being transcribed. */
23
+ declare const PENDING_MARK = "\u2026";
24
+ type MicState = "off" | "loading" | "listening" | "capturing";
25
+ /** What the button shows, from the state and the transcripts still out. */
26
+ type MicStatus = "idle" | "loading" | "listening" | "capturing" | "transcribing" | "speaking";
27
+ /**
28
+ * `speaking`: the agent's reply is being read while the mic is on. Capturing
29
+ * wins: with echo cancellation the user can talk over the agent.
30
+ */
31
+ declare function micStatus(state: MicState, pending: number, speaking?: boolean): MicStatus;
32
+ /** What a VAD must do. `flush` ends the current utterance now (the 30 s cap). */
33
+ type Vad = {
34
+ start(): Promise<void> | void;
35
+ pause(): Promise<void> | void;
36
+ flush(): Promise<void> | void;
37
+ destroy(): Promise<void> | void;
38
+ };
39
+ type VadEvents = {
40
+ onSpeechStart(): void; /** One utterance, 16 kHz mono samples in [-1, 1]. */
41
+ onSpeechEnd(samples: Float32Array): void; /** Speech seemed to start but was too short to keep. */
42
+ onMisfire(): void;
43
+ /**
44
+ * Every frame heard (16 kHz), for the partials; only those while capturing
45
+ * are kept. `prob`: the VAD's speech probability for it (Silero only).
46
+ */
47
+ onFrame?(frame: Float32Array, prob?: number): void;
48
+ };
49
+ type VadFactory = (ev: VadEvents) => Promise<Vad>;
50
+ /** A non-2xx answer from the STT endpoint. */
51
+ declare class SttError extends Error {
52
+ readonly status: number;
53
+ constructor(status: number, message: string);
54
+ }
55
+ /** getUserMedia refused or found nothing: the fallback needs the mic too, so it is not tried. */
56
+ declare function isMicDenied(e: unknown): boolean;
57
+ /** The notes' wording; a host can translate it (`<liagent-mic>.strings`). */
58
+ type MicErrorStrings = {
59
+ denied: string;
60
+ noMic: string;
61
+ signIn: string;
62
+ tooMuch: string; /** `{status}` is replaced by the HTTP status. */
63
+ failed: string; /** `{message}` is replaced by the error's message. */
64
+ other: string;
65
+ };
66
+ declare const MIC_ERROR_STRINGS_EN: MicErrorStrings;
67
+ /** The short note by the button for an error. */
68
+ declare function micErrorNote(e: unknown, t?: Partial<MicErrorStrings>): string;
69
+ /**
70
+ * Utterances in flight, in the order they were spoken. `take()` hands back
71
+ * the text of every finished one that has nothing unfinished before it.
72
+ */
73
+ declare class UtteranceQueue {
74
+ private next;
75
+ private head;
76
+ private done;
77
+ private partials;
78
+ add(): number;
79
+ resolve(seq: number, text: string | null): void;
80
+ /** Interim text for one not yet resolved (ignored once it is). */
81
+ partial(seq: number, text: string): void;
82
+ getPartial(seq: number): string;
83
+ /** Text now in order (failed ones are skipped), joined with joinText. */
84
+ take(): string;
85
+ /** Utterances still being transcribed. */
86
+ pending(): number;
87
+ /**
88
+ * What the input shows, dimmed, after the draft: for each utterance not yet
89
+ * taken, its text (done, waiting on an earlier one), its partial, or
90
+ * PENDING_MARK (one mark for a run of them).
91
+ */
92
+ interim(): string;
93
+ }
94
+ /** Append `b` to `a`: a space between them, except between CJK characters or at a line start. */
95
+ declare function joinText(a: string, b: string): string;
96
+ /** A draft ending a sentence (any script's full stop, ! or ?). */
97
+ declare const ENDS_SENTENCE: RegExp;
98
+ /**
99
+ * Spoken (or IME-dictated) sentences go out at once from this many characters
100
+ * (trimmed): typing arrives a character at a time, so 3 at once is dictation.
101
+ */
102
+ declare const AUTO_SEND_MIN = 3;
103
+ /**
104
+ * Typed text that arrived at once (an outside dictation IME): AUTO_SEND_MIN
105
+ * or more characters since the draft last settled, and the draft now ends a
106
+ * sentence. Then it is sent at once.
107
+ */
108
+ declare function isDictationBurst(settledLen: number, draft: string): boolean;
109
+ /**
110
+ * Spoken text always ends a sentence ("auto-punctuate, then commit"): Whisper
111
+ * usually adds the stop itself; when it doesn't, add one that fits the text —
112
+ * 。/? for CJK, ./? otherwise, a question by its particle or opening word.
113
+ * Text that already ends in any punctuation (…, ~, quotes) is left alone.
114
+ */
115
+ declare function punctuate(text: string): string;
116
+ /**
117
+ * A final transcript lands in the draft, punctuated, and is committed at once
118
+ * (shown, then sent) whenever it carries any words — a short "好" or "OK"
119
+ * too. Partials never come here; typing never does (see isDictationBurst).
120
+ */
121
+ declare function appendDictation(draft: string, text: string): {
122
+ draft: string;
123
+ send: boolean;
124
+ };
125
+ /**
126
+ * Two overlapping chunks' transcripts as one: the longest run of words that
127
+ * ends `a` and starts `b` is kept once ("the quick brown" + "brown fox" →
128
+ * "the quick brown fox"). With no overlap they are just joined.
129
+ */
130
+ declare function mergeOverlap(a: string, b: string): string;
131
+ /** Linear resampling to `to` Hz (the fallback VAD records at the device's rate). */
132
+ declare function resample(input: Float32Array, from: number, to: number): Float32Array;
133
+ /** 16-bit PCM WAV, mono: what every STT model takes, and every browser can make. */
134
+ declare function encodeWav(samples: Float32Array, rate?: number): Uint8Array;
135
+ /** The RMS level of a frame, for the energy fallback. */
136
+ declare function rms(frame: Float32Array): number;
137
+ /**
138
+ * The energy-threshold VAD the mic falls back to when Silero is not given or
139
+ * cannot load: feed it frames; it says when speech starts (two frames over
140
+ * `on`) and ends (`hangMs` under `off`), keeping a frame of audio from before
141
+ * the start.
142
+ */
143
+ declare function energyGate(opts: {
144
+ rate: number;
145
+ on?: number;
146
+ off?: number;
147
+ hangMs?: number;
148
+ minMs?: number;
149
+ }): {
150
+ /** null: nothing happened; "start"; or the finished utterance (or "misfire"). */push(frame: Float32Array): null | "start" | "misfire" | Float32Array; /** End the utterance now (the cap, or listening turned off). */
151
+ flush(): null | "misfire" | Float32Array;
152
+ };
153
+ type UploadInfo = {
154
+ seq: number;
155
+ durationMs: number;
156
+ partial: boolean;
157
+ };
158
+ /**
159
+ * Listening mode. `toggle()` turns it on (loading the VAD, or the fallback if
160
+ * that fails, unless the mic itself was refused) and off. Each utterance is
161
+ * encoded and uploaded at once; its transcript (in order) goes to `onText`,
162
+ * and `onPending` counts those still out, with the interim text to show
163
+ * dimmed. A capture longer than MAX_UTTERANCE_MS is cut and sent. A 401 turns
164
+ * listening off; a 429 on a partial stops partials until the next turn-on.
165
+ */
166
+ declare function createMic(d: {
167
+ load: VadFactory;
168
+ fallback?: VadFactory;
169
+ upload: (wav: Uint8Array, info: UploadInfo) => Promise<string>;
170
+ onState: (s: MicState) => void;
171
+ onText: (text: string) => void;
172
+ onPending: (n: number, interim: string) => void;
173
+ onError?: (e: unknown) => void; /** Each frame's speech probability while capturing (a voice output's barge-in judge). */
174
+ onProb?: (prob: number) => void; /** Rolling partial chunks for long utterances (on unless false). */
175
+ partials?: boolean;
176
+ setTimer?: (f: () => void, ms: number) => unknown;
177
+ clearTimer?: (t: unknown) => void;
178
+ }): {
179
+ toggle: () => Promise<void>;
180
+ hold: (on: boolean) => void;
181
+ held: () => boolean;
182
+ off: () => Promise<void>;
183
+ state: () => MicState;
184
+ };
185
+ /** What the STT endpoint answers: JSON with the transcript, and anything else it likes. */
186
+ type SttResult = {
187
+ text: string;
188
+ model?: string;
189
+ ms?: number;
190
+ language?: string;
191
+ };
192
+ /** Where and how to POST an utterance (docs/embed.md, "Voice input"). */
193
+ type SttRequest = {
194
+ /** The endpoint, absolute or relative to the page, e.g. "/api/stt". */url: string; /** A language hint, sent as `?lang=` (none: the endpoint detects it). */
195
+ lang?: string; /** Extra request headers (an API key, a CSRF token…). */
196
+ headers?: Record<string, string>; /** fetch's credentials mode (default "same-origin"; "include" for a cookie on another origin). */
197
+ credentials?: RequestCredentials; /** The audio's type (default "audio/wav"). */
198
+ type?: string;
199
+ };
200
+ /** The URL with `lang` added to its query, when a hint is given. */
201
+ declare function sttUrl(url: string, lang?: string): string;
202
+ /**
203
+ * POST one recording to the host's STT endpoint: the raw audio as the body
204
+ * (16 kHz mono 16-bit PCM WAV) and its type as `content-type`. Answers the
205
+ * endpoint's JSON (`text` defaults to ""). Throws SttError on non-2xx, with
206
+ * the JSON's `error` as its message when there is one.
207
+ */
208
+ declare function postStt(wav: Uint8Array, req: SttRequest | string, f?: typeof fetch): Promise<SttResult>;
209
+ /** The send tick: two soft sine tones, this loud at their peak, this long in all. */
210
+ declare const TICK_GAIN = 0.08;
211
+ declare const TICK_MS = 80;
212
+ /** The slice of an AudioContext the tick uses (a fake in the tests). */
213
+ type TickContext = {
214
+ currentTime: number;
215
+ destination: unknown;
216
+ createOscillator(): {
217
+ type: string;
218
+ frequency: {
219
+ setValueAtTime(v: number, t: number): unknown;
220
+ };
221
+ connect(n: unknown): unknown;
222
+ start(t: number): void;
223
+ stop(t: number): void;
224
+ };
225
+ createGain(): {
226
+ gain: {
227
+ setValueAtTime(v: number, t: number): unknown;
228
+ linearRampToValueAtTime(v: number, t: number): unknown;
229
+ exponentialRampToValueAtTime(v: number, t: number): unknown;
230
+ };
231
+ connect(n: unknown): unknown;
232
+ };
233
+ };
234
+ /**
235
+ * A short, soft "tick" when a spoken sentence goes out (opt-in on the
236
+ * element: the `tick` attribute): two sine tones (the second a fifth up,
237
+ * 30 ms later) through one gain with a 5 ms attack and an exponential decay,
238
+ * TICK_MS long, peaking at TICK_GAIN. Web Audio only — no <audio> element —
239
+ * so iOS keeps it silent when the ringer is muted.
240
+ */
241
+ declare function scheduleTick(ctx: TickContext, at?: number): number;
242
+ //#endregion
243
+ //#region src/mic-audio.d.ts
244
+ /** The mic with echo cancellation on (the default: the user may talk over the agent). */
245
+ declare const AEC_CONSTRAINTS: {
246
+ readonly echoCancellation: true;
247
+ readonly noiseSuppression: true;
248
+ readonly autoGainControl: true;
249
+ readonly channelCount: 1;
250
+ };
251
+ /** Echo cancellation's "off" mode: capture is held while the agent speaks; no auto gain. */
252
+ declare const LEGACY_CONSTRAINTS: {
253
+ readonly echoCancellation: true;
254
+ readonly noiseSuppression: true;
255
+ readonly channelCount: 1;
256
+ };
257
+ declare const micConstraints: (aec?: boolean) => MediaTrackConstraints;
258
+ declare function noteTrack(stream: {
259
+ getAudioTracks(): {
260
+ getSettings?(): object;
261
+ }[];
262
+ }): void;
263
+ declare const appliedSettings: () => Record<string, unknown> | null;
264
+ declare function audioCtx(): AudioContext | null;
265
+ /** The AudioContext if one was made (never makes one). */
266
+ declare const existingCtx: () => AudioContext | null;
267
+ /** The browser can capture: getUserMedia and Web Audio. */
268
+ declare const canCapture: () => boolean;
269
+ /** The mic stream, with the constraints for `aec`; what was applied is noted. */
270
+ declare function micStream(aec?: boolean): Promise<MediaStream>;
271
+ /** The slice of vad-web's MicVAD the mic uses. */
272
+ type MicVADLike = {
273
+ start(): Promise<void> | void;
274
+ pause(): Promise<void> | void;
275
+ destroy(): Promise<void> | void;
276
+ };
277
+ /** vad-web's module (or its UMD global, `window.vad`). */
278
+ type VadWebModule = {
279
+ MicVAD: {
280
+ new: (o: Record<string, unknown>) => Promise<MicVADLike>;
281
+ };
282
+ };
283
+ /** Hands over vad-web: `() => import("@ricky0123/vad-web")`, or anything resolving to its module. */
284
+ type VadLoader = () => Promise<VadWebModule | {
285
+ default: VadWebModule;
286
+ }>;
287
+ /** Silero VAD's source: a loader and where its model and onnxruntime's wasm are served from. */
288
+ type VadConfig = {
289
+ load: VadLoader; /** vad-web's `baseAssetPath`: the directory with silero_vad_*.onnx and the worklet. */
290
+ baseAssetPath?: string; /** vad-web's `onnxWASMBasePath`: the directory with onnxruntime-web's .wasm files. */
291
+ onnxWASMBasePath?: string; /** Silero's model (default "v5"). */
292
+ model?: "v5" | "legacy"; /** More MicVAD options (thresholds, redemption frames…), passed through. */
293
+ options?: Record<string, unknown>;
294
+ };
295
+ type VadSource = VadLoader | VadConfig;
296
+ /**
297
+ * vad-web from its UMD builds, by <script> tags: `vadBase` is vad-web's dist
298
+ * directory (bundle.min.js, the model, the worklet) and `ortBase`
299
+ * onnxruntime-web's (ort.wasm.min.js and the wasm). E.g. pinned on a CDN:
300
+ *
301
+ * vadFromScripts("https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.30/dist/",
302
+ * "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/")
303
+ *
304
+ * The page's CSP must allow both origins (script-src, connect-src, and
305
+ * 'wasm-unsafe-eval').
306
+ */
307
+ declare function vadFromScripts(vadBase: string, ortBase: string): VadConfig;
308
+ /**
309
+ * Silero on the session's stream (never stops it): ends an utterance after
310
+ * ~0.8 s of silence; each frame's speech probability goes to onFrame.
311
+ */
312
+ declare function sileroVad(ev: VadEvents, stream: MediaStream, src: VadSource): Promise<Vad>;
313
+ /** The fallback: an energy threshold on the raw signal (energyGate), on the session's stream. */
314
+ declare function energyVad(ev: VadEvents, stream: MediaStream): Promise<Vad>;
315
+ //#endregion
316
+ export { resample as $, SttError as A, VadFactory as B, MicState as C, PARTIAL_OVERLAP_MS as D, PARTIAL_MIN_MS as E, TickContext as F, isDictationBurst as G, createMic as H, UploadInfo as I, mergeOverlap as J, isMicDenied as K, UtteranceQueue as L, SttResult as M, TICK_GAIN as N, PENDING_MARK as O, TICK_MS as P, punctuate as Q, Vad as R, MicErrorStrings as S, PARTIAL_EVERY_MS as T, encodeWav as U, appendDictation as V, energyGate as W, micStatus as X, micErrorNote as Y, postStt as Z, vadFromScripts as _, VadLoader as a, MAX_UTTERANCE_MS as b, appliedSettings as c, energyVad as d, rms as et, existingCtx as f, sileroVad as g, noteTrack as h, VadConfig as i, SttRequest as j, RATE as k, audioCtx as l, micStream as m, LEGACY_CONSTRAINTS as n, sttUrl as nt, VadSource as o, micConstraints as p, joinText as q, MicVADLike as r, VadWebModule as s, AEC_CONSTRAINTS as t, scheduleTick as tt, canCapture as u, AUTO_SEND_MIN as v, MicStatus as w, MIC_ERROR_STRINGS_EN as x, ENDS_SENTENCE as y, VadEvents as z };
317
+ //# sourceMappingURL=mic-audio-DMCWtEI-.d.ts.map