@alexkroman1/aai-ui 2.0.0 → 3.0.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 (45) hide show
  1. package/dist/_module-url-C_4gRVL0.js +15 -0
  2. package/dist/audio.d.ts +42 -6
  3. package/dist/audio.js +79 -69
  4. package/dist/{chat-view-DKFhxMAT.js → chat-view-C1oJxsWz.js} +4 -4
  5. package/dist/client-config.d.ts +5 -6
  6. package/dist/components/chat-view.js +1 -1
  7. package/dist/components/console-shell.d.ts +2 -2
  8. package/dist/components/controls.js +1 -1
  9. package/dist/components/url-chips.d.ts +0 -3
  10. package/dist/context.d.ts +1 -1
  11. package/dist/context.js +1 -4
  12. package/dist/{controls-4OJoekj6.js → controls-DV368uhb.js} +1 -4
  13. package/dist/default-client/assets/_module-url-BX0RuRU2.js +1 -0
  14. package/dist/default-client/assets/audio-BGHiiDY_.js +1 -0
  15. package/dist/default-client/assets/{capture-processor-DLHxAIfT.js → capture-processor-BLPsqnGl.js} +4 -4
  16. package/dist/default-client/assets/index-DXf7-M0Q.js +244 -0
  17. package/dist/default-client/assets/index-Dv-Q5VRL.css +2 -0
  18. package/dist/default-client/assets/{playback-processor-bMTdFp-8.js → playback-processor-B_T_1KQP.js} +28 -21
  19. package/dist/default-client/index.html +2 -5
  20. package/dist/define-client-Cyf1jqAl.js +150 -0
  21. package/dist/define-client.js +1 -1
  22. package/dist/index.d.ts +1 -3
  23. package/dist/index.js +7 -6
  24. package/dist/{session-core-BLhiQ18c.js → session-core-BM3WHeoY.js} +30 -128
  25. package/dist/session-core-messages.d.ts +0 -4
  26. package/dist/session-core-types.d.ts +1 -27
  27. package/dist/session-core.js +1 -1
  28. package/dist/types.d.ts +1 -1
  29. package/dist/types.js +2 -2
  30. package/dist/worklets/_module-url.d.ts +10 -0
  31. package/dist/worklets/capture-processor.d.ts +2 -2
  32. package/dist/worklets/capture-processor.js +5 -5
  33. package/dist/worklets/playback-processor.d.ts +3 -3
  34. package/dist/worklets/playback-processor.js +31 -24
  35. package/package.json +2 -2
  36. package/dist/components/workflow-view.d.ts +0 -13
  37. package/dist/default-client/assets/audio-Cgviqo9t.js +0 -1
  38. package/dist/default-client/assets/index-BgbIWnfG.css +0 -2
  39. package/dist/default-client/assets/index-DbKKR3UE.js +0 -62
  40. package/dist/default-client/assets/rolldown-runtime-BpQH8Ho1.js +0 -1
  41. package/dist/default-client/assets/types-Bpg3ZIZK.js +0 -64
  42. package/dist/define-client-yoGybEYR.js +0 -710
  43. package/dist/session-core-upload.d.ts +0 -16
  44. package/dist/sync-mic.d.ts +0 -61
  45. package/dist/sync-session.d.ts +0 -49
@@ -1,16 +0,0 @@
1
- import type { ClientMessage } from "@alexkroman1/aai/protocol";
2
- import type { ConnState, SessionSnapshot } from "./session-core-types.ts";
3
- /** Handle to the upload pipeline, owned by one session core. */
4
- export type UploadSender = {
5
- /** See {@link SessionCore.sendAudioFile}. */
6
- sendAudioFile(file: Blob): Promise<void>;
7
- /** True while an upload is decoding or streaming — the mic must stay off. */
8
- inFlight(): boolean;
9
- /** Invalidate any in-flight upload (reset / close / reconnect). */
10
- discard(): void;
11
- };
12
- export declare function createUploadSender(deps: {
13
- conn: ConnState;
14
- getSnapshot: () => SessionSnapshot;
15
- sendJson: (msg: ClientMessage) => void;
16
- }): UploadSender;
@@ -1,61 +0,0 @@
1
- /**
2
- * WebRTC push-to-talk capture for the workflow run surface.
3
- *
4
- * Captures voice through `getUserMedia` under
5
- * {@link VOICE_CAPTURE_CONSTRAINTS} — echo cancellation only — and runs an
6
- * AudioWorklet that batches raw frames to the main thread; the caller's
7
- * button is the endpointing. Each recording becomes one `POST /sync` run.
8
- * No WebSocket anywhere on the path.
9
- *
10
- * The worklet module ships inline as a blob URL (same pattern as the
11
- * WebSocket path's worklets), so this path needs no separately-served
12
- * processor file. A blob URL rather than a data URI because the agent
13
- * page's CSP allows `script-src blob:` but not `data:` — a data-URI
14
- * module fails `addModule` with "Unable to load a worklet's module".
15
- */
16
- /** Default capture rate — what the STT providers expect. */
17
- export declare const DEFAULT_SYNC_MIC_SAMPLE_RATE = 16000;
18
- /** ~128 ms at 16 kHz: few messages per second, fine-enough VAD granularity. */
19
- export declare const CAPTURE_BATCH_SAMPLES = 2048;
20
- /**
21
- * The capture processor: coalesces 128-sample render quanta into
22
- * {@link CAPTURE_BATCH_SAMPLES} batches and posts them (transferred, so no
23
- * per-batch copy). Inlined as source because it must be stringified into a
24
- * blob URL.
25
- *
26
- * `batch` is held as a field rather than re-read from the posted view:
27
- * `postMessage` with a transfer list detaches the buffer, so `out.length` is
28
- * 0 by the time the next buffer is allocated. Allocating a zero-length `buf`
29
- * from it made `n` 0 forever, so `read` stopped advancing and the render
30
- * thread spun inside `process()` posting empty chunks — the mic went
31
- * permanently deaf on its first flush.
32
- *
33
- * Exported for the worklet unit tests (`sync-mic-worklet.test.ts`), which
34
- * evaluate this source directly; it is not part of the package surface.
35
- */
36
- export declare const CAPTURE_PROCESSOR_SRC = "\nregisterProcessor(\"aai-sync-capture\", class extends AudioWorkletProcessor {\n constructor(options) {\n super();\n const batch = (options && options.processorOptions && options.processorOptions.batchSamples) || 2048;\n this.batch = batch;\n this.buf = new Float32Array(batch);\n this.len = 0;\n }\n process(inputs) {\n const ch = inputs[0] && inputs[0][0];\n if (!ch) return true;\n let read = 0;\n while (read < ch.length) {\n const n = Math.min(ch.length - read, this.buf.length - this.len);\n this.buf.set(ch.subarray(read, read + n), this.len);\n this.len += n;\n read += n;\n if (this.len === this.batch) {\n const out = this.buf;\n // Size the next buffer from this.batch, never from `out`: the\n // transfer below detaches out.buffer, so out.length reads 0 here.\n this.buf = new Float32Array(this.batch);\n this.len = 0;\n this.port.postMessage({ event: \"chunk\", samples: out }, [out.buffer]);\n }\n }\n return true;\n }\n});\n";
37
- /**
38
- * Blob-URL module for the capture processor (no served asset). Satisfies the
39
- * agent page's `script-src blob:` CSP, which rejects data-URI modules.
40
- */
41
- export declare const CAPTURE_WORKLET_MODULE_URL: string;
42
- /** Clamp-and-convert one Float32 capture batch to PCM16. */
43
- export declare function floatToPcm16(samples: Float32Array): Int16Array;
44
- /** Hold-to-record handle returned by {@link createPttRecorder}. */
45
- export type PttRecorder = {
46
- /** Open the mic (first call) and start collecting frames. */
47
- start(): Promise<void>;
48
- /** Stop collecting and return everything recorded since `start()` as PCM16. */
49
- stop(): Promise<Int16Array>;
50
- /** Release the mic and the AudioContext. */
51
- close(): Promise<void>;
52
- };
53
- /**
54
- * Push-to-talk recorder: `getUserMedia` voice capture feeding the capture
55
- * worklet, with the caller's button as the endpointing. Recording runs
56
- * exactly between `start()` and `stop()`; the mic stays open across presses
57
- * until `close()`.
58
- *
59
- * @public
60
- */
61
- export declare function createPttRecorder(sampleRate?: number): PttRecorder;
@@ -1,49 +0,0 @@
1
- /**
2
- * Sync-mode browser session — HTTP turns, no WebSocket.
3
- *
4
- * The client half of the server's `POST /sync` endpoint (see
5
- * `host/sync-turn.ts` in `@alexkroman1/aai`): each turn is one request
6
- * carrying committed text or one endpointed utterance of PCM16 audio plus
7
- * the conversation history, answered with the transcript, the reply text,
8
- * and (when the agent's TTS provider supports one-shot synthesis) the
9
- * spoken reply. The server holds no session state — this object owns the
10
- * history and replays it every turn.
11
- *
12
- * Microphone capture and utterance endpointing live in `sync-mic.ts` /
13
- * `sync-vad.ts`; this module is transport only, so it also runs in
14
- * non-browser clients that bring their own audio.
15
- */
16
- import { type SyncHistoryMessage, type SyncTurnResponse } from "@alexkroman1/aai/protocol";
17
- /** Base64-encode PCM16 samples (chunked — `btoa` takes a binary string). */
18
- export declare function pcm16ToBase64(pcm: Int16Array): string;
19
- /** Decode base64 PCM16LE (the sync response's `audio` field) into samples. */
20
- export declare function base64ToPcm16(base64: string): Int16Array;
21
- /** One completed sync turn: the wire response plus decoded reply audio. */
22
- export type SyncTurnResult = SyncTurnResponse & {
23
- /** Decoded reply audio (PCM16 at `sampleRate`), when the server spoke. */
24
- pcm: Int16Array | null;
25
- };
26
- /** Configuration for {@link createSyncSession}. */
27
- export type SyncSessionOptions = {
28
- /** The agent server's sync endpoint, e.g. `http://localhost:3000/sync`. */
29
- url: string;
30
- /** Fetch override (tests / custom transports). */
31
- fetch?: typeof globalThis.fetch | undefined;
32
- /** Called after every completed turn (text and voice alike). */
33
- onTurn?: ((turn: SyncTurnResult) => void) | undefined;
34
- /** Called when a turn fails; the rejection still propagates to the caller. */
35
- onError?: ((err: Error) => void) | undefined;
36
- };
37
- /** Sync-mode session handle. */
38
- export type SyncSession = {
39
- /** Conversation so far, oldest first — replayed to the server each turn. */
40
- readonly history: readonly SyncHistoryMessage[];
41
- /** Run one turn from committed text. */
42
- sendText(text: string): Promise<SyncTurnResult>;
43
- /** Run one turn from one utterance of mono PCM16 audio. */
44
- sendPcm16(pcm: Int16Array, sampleRate: number): Promise<SyncTurnResult>;
45
- /** Forget the conversation. */
46
- reset(): void;
47
- };
48
- /** Create a {@link SyncSession} against a sync-mode agent server. */
49
- export declare function createSyncSession(opts: SyncSessionOptions): SyncSession;