@pellux/goodvibes-tui 1.26.0 → 1.27.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -1
  3. package/docs/foundation-artifacts/operator-contract.json +3756 -1110
  4. package/package.json +8 -7
  5. package/scripts/postinstall.js +57 -1
  6. package/src/audio/activation-sound.ts +117 -0
  7. package/src/audio/capture.ts +112 -0
  8. package/src/audio/onnxruntime-assets.d.ts +24 -0
  9. package/src/audio/voice-capture-wiring.ts +119 -0
  10. package/src/audio/voice-input-session.ts +181 -0
  11. package/src/audio/wake-inference.ts +182 -0
  12. package/src/audio/wake-runtime.ts +341 -0
  13. package/src/cli/bundle-command.ts +4 -1
  14. package/src/cli/management-utils.ts +4 -1
  15. package/src/cli/tui-startup.ts +10 -1
  16. package/src/core/voice-capture-status.ts +53 -0
  17. package/src/core/voice-stt-gateway.ts +75 -0
  18. package/src/core/wake-provision-runner.ts +86 -0
  19. package/src/core/wake-provision-status.ts +170 -0
  20. package/src/daemon/cli.ts +117 -28
  21. package/src/daemon/fatal-boot-report.ts +111 -0
  22. package/src/daemon/provision-wake-model.ts +81 -0
  23. package/src/input/command-registry.ts +6 -0
  24. package/src/input/commands/experience-runtime.ts +37 -3
  25. package/src/input/handler-shortcuts.ts +8 -0
  26. package/src/input/keybindings.ts +10 -1
  27. package/src/input/onboarding/onboarding-feature-units.ts +5 -5
  28. package/src/input/settings-modal-types.ts +14 -1
  29. package/src/main.ts +12 -14
  30. package/src/renderer/process-indicator.ts +66 -0
  31. package/src/renderer/settings-modal-helpers.ts +4 -2
  32. package/src/renderer/shell-surface.ts +22 -3
  33. package/src/runtime/bootstrap-core.ts +7 -7
  34. package/src/runtime/bootstrap.ts +3 -3
  35. package/src/runtime/device-posture-composition.ts +110 -0
  36. package/src/runtime/disposal-wiring.ts +16 -0
  37. package/src/runtime/embedded-service-factories.ts +16 -0
  38. package/src/runtime/legacy-daemon-migration.ts +12 -1
  39. package/src/runtime/runtime-services-types.ts +17 -0
  40. package/src/runtime/services.ts +81 -4
  41. package/src/runtime/voice-setup-services.ts +50 -4
  42. package/src/shell/voice-capture-shell.ts +69 -0
  43. package/src/verification/verification-ledger.ts +59 -20
  44. package/src/version.ts +1 -1
@@ -0,0 +1,69 @@
1
+ /**
2
+ * voice-capture-shell.ts — the shell's side of microphone capture.
3
+ *
4
+ * Extracted from main() for the same reason the process-lifecycle wiring was:
5
+ * the entrypoint is a wiring file held under a source-line gate, and new shell
6
+ * composition gets its own module and a single call there.
7
+ *
8
+ * What this owns is only the shell-facing half — where a transcript lands (the
9
+ * composer draft, through the same public `prompt`/`cursorPos` fields the
10
+ * external-editor path writes), how a turn is submitted, which keybinding seam
11
+ * the Alt+V action hangs off, and the teardown registration that guarantees a
12
+ * live recorder subprocess dies with the process. Everything about audio itself
13
+ * lives in src/audio/voice-capture-wiring.ts, which must not (and does not)
14
+ * import shell-UI.
15
+ */
16
+
17
+ import type { ConfigManager } from '@pellux/goodvibes-sdk/platform/config';
18
+ import type { CommandContext } from '../input/command-registry.ts';
19
+ import type { ShellPathService } from '@/runtime/index.ts';
20
+ import type { VoiceCaptureIndicatorState } from '../core/voice-capture-status.ts';
21
+ import { wireVoiceCapture } from '../audio/voice-capture-wiring.ts';
22
+
23
+ export interface VoiceCaptureShellDeps {
24
+ readonly configManager: ConfigManager;
25
+ readonly shellPaths: Pick<ShellPathService, 'resolveUserPath'>;
26
+ readonly homeDirectory: string | (() => string);
27
+ /** Names retained wake clips so the SDK's sweeper reaps them when this session ends. */
28
+ readonly sessionId: string;
29
+ /** The Alt+V seam is hung here (commandContext.toggleVoiceInput). */
30
+ readonly commandContext: CommandContext;
31
+ /** The shell's teardown registry; the device release is appended to it. */
32
+ readonly unsubs: Array<() => void>;
33
+ /** The live composer buffer — InputHandler exposes public `prompt`/`cursorPos`. */
34
+ readonly buffer: { prompt: string; cursorPos: number };
35
+ readonly submitInput: (text: string) => void;
36
+ readonly notify: (message: string) => void;
37
+ readonly render: () => void;
38
+ }
39
+
40
+ /**
41
+ * Compose voice capture and hand back the footer-row reader.
42
+ *
43
+ * Opens no device: wake detection consults `voice.wake.*` and refuses without
44
+ * touching the capture opener when it is off, and push-to-talk opens one only on
45
+ * a keypress.
46
+ */
47
+ export function installVoiceCapture(deps: VoiceCaptureShellDeps): () => VoiceCaptureIndicatorState | null {
48
+ const capture = wireVoiceCapture({
49
+ configManager: deps.configManager,
50
+ // The same managed root `/voice setup` uses; the wake tree is `<root>/wake`.
51
+ managedVoiceRoot: deps.shellPaths.resolveUserPath('voice'),
52
+ // Surface-scoped: the extracted onnxruntime assets belong to this surface's
53
+ // own directory, beside its other managed state.
54
+ assetDirectory: deps.shellPaths.resolveUserPath('tui', 'onnxruntime'),
55
+ homeDirectory: deps.homeDirectory,
56
+ sessionId: deps.sessionId,
57
+ writeDraft: (text) => {
58
+ deps.buffer.prompt = text;
59
+ deps.buffer.cursorPos = text.length;
60
+ deps.render();
61
+ },
62
+ submitTurn: (text) => deps.submitInput(text),
63
+ notify: deps.notify,
64
+ render: deps.render,
65
+ });
66
+ deps.commandContext.toggleVoiceInput = capture.toggleVoiceInput;
67
+ deps.unsubs.push(...capture.unsubs);
68
+ return capture.status;
69
+ }
@@ -209,16 +209,16 @@ export const FEATURE_KNOB_LOCAL_SETTINGS = [
209
209
  * watchers.triggers.onExitMaxDurationMs persistence · live (on-exit trigger duration cap)
210
210
  * watchers.triggers.onExitStdin persistence · live (on-exit stdin posture)
211
211
  * watchers.triggers.outputTailBytes persistence · live (captured output tail)
212
- * device.capabilities.allowAlwaysOffer persistence · settings surface only in this build
213
- * device.capabilities.requestTimeoutSeconds persistence · settings surface only in this build
214
- * device.location.precision persistence · settings surface only in this build
215
- * device.clipboard.readMode persistence · settings surface only in this build
216
- * device.capture.retentionHours persistence · settings surface only in this build
217
- * device.capture.maxArtifacts persistence · settings surface only in this build
218
- * device.capture.sweepIntervalMinutes persistence · settings surface only in this build
219
- * device.grants.expiryDays persistence · settings surface only in this build
220
- * device.grants.maxPerNode persistence · settings surface only in this build
221
- * device.grants.auditRetentionDays persistence · settings surface only in this build
212
+ * device.capabilities.allowAlwaysOffer persistence · behavior (durable-grant offer by sensitivity)
213
+ * device.capabilities.requestTimeoutSeconds persistence · behavior (dispatch, wire payload and prompt deadline)
214
+ * device.location.precision persistence · behavior (precise fix refused / never granted)
215
+ * device.clipboard.readMode persistence · behavior (clipboard read refused / never granted)
216
+ * device.capture.retentionHours persistence · behavior (capture TTL, swept off disk at expiry)
217
+ * device.capture.maxArtifacts persistence · behavior (capture count cap at the sweep)
218
+ * device.capture.sweepIntervalMinutes persistence · behavior (period of the sweep that reaps)
219
+ * device.grants.expiryDays persistence · behavior (grant TTL, then asks again)
220
+ * device.grants.maxPerNode persistence · behavior (per-node grant cap at the sweep)
221
+ * device.grants.auditRetentionDays persistence · behavior (grant ledger retention)
222
222
  * device.nodes.maxPaired persistence · live (enforced at the pairing path)
223
223
  *
224
224
  * On `device.nodes.maxPaired`: the SDK enforces it where a device pairs —
@@ -235,17 +235,56 @@ export const FEATURE_KNOB_LOCAL_SETTINGS = [
235
235
  * in this column so the "how live is it" audit stays accurate, not to claim
236
236
  * coverage this repo did not write.
237
237
  *
238
- * On the other ten `device.*` rows: DeviceCapabilityService carries its own
239
- * policy struct whose defaults match those keys one for one, and names them in
240
- * its field comments and refusal messages, but no code path in either tree maps
241
- * configuration into that struct. Persistence is therefore the whole of what is
242
- * verified for them, and the settings-workspace description for the `device`
243
- * category says exactly that to the user rather than implying live knobs.
238
+ * On the other ten `device.*` rows: they are live now. This app composes the
239
+ * platform's device posture runtime (src/runtime/device-posture-composition.ts)
240
+ * on the same distributed runtime phones pair onto and the same approval broker
241
+ * every other confirmation rides, registers the `phone` tool on it, and binds the
242
+ * devices.* verbs to it — so each of these keys is read, per request and per
243
+ * sweep, by the DeviceCapabilityService / DeviceGrantStore /
244
+ * DeviceCaptureArtifactStore / DeviceHousekeeper that serve them. They were dark
245
+ * before that: the policy struct carried matching defaults and named the keys in
246
+ * its refusal messages, but nothing mapped configuration into it in either tree.
247
+ * The mapping now lives in the SDK, so every daemon host honours it rather than
248
+ * only whichever consumer had written its own.
244
249
  *
245
- * DELIBERATELY NOT COUNTED: the 24 non-enablement `voice.wake.*` keys from the
246
- * same release. `wake-word-detection` is declared `notOperable` — no surface
247
- * captures audio — so its rows stay in `total` and out of the numerator. That is
248
- * the honest reading, and it is why this list raises coverage by 29 and not 53.
250
+ * The second column above is upgraded to "behavior" on the strength of
251
+ * `src/test/verification/device-posture-behavior.test.ts`, which drives THIS
252
+ * app's composition with a real ConfigManager over a temp home and the platform's
253
+ * real stores, stubs only the peer transport and the approval bridge, and asserts
254
+ * per key at two values that the observable outcome differs — refusal code, how
255
+ * authority was established, what reached the transport, what the prompt was
256
+ * given, and what survives on disk after a sweep. It also invokes the `phone`
257
+ * tool and the devices.* verbs off the composed runtime graph, because a mapping
258
+ * nothing composes is the same defect in a different place.
259
+ *
260
+ * STILL NOT COUNTED, FOR A DIFFERENT REASON NOW: the 24 non-enablement
261
+ * `voice.wake.*` keys from the same release. When this list was written they were
262
+ * excluded because nothing captured audio at all. That is no longer true — this
263
+ * terminal opens a recorder subprocess (src/audio/capture.ts), runs the SDK
264
+ * detector over it through onnxruntime-web (src/audio/wake-inference.ts), and
265
+ * hands both a confirmed wake's utterance and a push-to-talk recording to the
266
+ * daemon's `voice.stt` verb. Every one of those rows is read by
267
+ * resolveWakeRuntimeSettings and reaches this surface's runtime.
268
+ *
269
+ * They stay out of the NUMERATOR here because this constant counts exactly one
270
+ * thing — keys whose four-part PERSISTENCE contract is exercised by
271
+ * device-and-trigger-settings-persistence.test.ts — and that test does not cover
272
+ * them. The behaviour they now drive is covered instead by the capture and wake
273
+ * tests under src/test/audio/, which assert the frame path, the detection
274
+ * chain, the disabled-means-no-capture rule, the supervisor's restart and latch,
275
+ * and the recorder argv. Counting them in both places would double-count; adding
276
+ * them here without writing their persistence round-trip would overclaim. So the
277
+ * number this list raises coverage by is unchanged, and the reason it excludes
278
+ * them is recorded above rather than left reading as "the feature does nothing".
279
+ *
280
+ * Every wake row is now in force on this surface, with one condition stated at
281
+ * every surfacing: `voice.wake.vadThreshold` above 0 needs the speech gate's own
282
+ * pinned artifact provisioned (`/voice wake setup` fetches it with the models),
283
+ * and until it is, startup BLOCKS with that reason rather than scoring frames
284
+ * ungated behind a row that says they are screened. `voice.wake.noiseSuppression:
285
+ * speex` runs here: the filter is a WebAssembly module the SDK carries, applied
286
+ * by the wrapper the listener and the push-to-talk session put around this
287
+ * surface's capture opener.
249
288
  */
250
289
  export const DEVICE_AND_TRIGGER_LOCAL_SETTINGS = [
251
290
  'watchers.triggers.backoffLadderMs',
package/src/version.ts CHANGED
@@ -6,7 +6,7 @@ import { join } from 'node:path';
6
6
  // The prebuild script updates the fallback value before compilation.
7
7
  // Uses import.meta.dir (Bun) to locate package.json relative to this file,
8
8
  // which is correct regardless of the process working directory.
9
- let _version = '1.26.0';
9
+ let _version = '1.27.1';
10
10
  try {
11
11
  const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', 'package.json'), 'utf-8'));
12
12
  // Only trust a version read from OUR OWN package.json. A Bun single-file