@hackbuild/ai-views 0.1.1 → 0.1.5

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/llms.md CHANGED
@@ -66,6 +66,12 @@ interface ChatPaneOptions {
66
66
 
67
67
  Options for `mountChatPane`: the reply's name and the empty state's words.
68
68
 
69
+ ```ts
70
+ function chipWords(s: PickSnapshot): string
71
+ ```
72
+
73
+ The chip's words: the short name, then the download size, or the state once it moves.
74
+
69
75
  ```ts
70
76
  interface ComposerOptions {
71
77
  label?: string;
@@ -90,6 +96,12 @@ interface DefineTarget {
90
96
 
91
97
  The part of a custom element registry `define` uses; `customElements` satisfies it.
92
98
 
99
+ ```ts
100
+ function droppedFiles(dt: DataTransfer | null | undefined): Promise<File[]>
101
+ ```
102
+
103
+ The files of a drop, with dropped folders read through, media only.
104
+
93
105
  ```ts
94
106
  const ELEMENT_NAMES: readonly ["model-select", "model-jobs", "chat-pane", "chat-composer", "chat-list", "chat-context", "transcribe-drop", "transcript-view", "transcribe-queue", "transcript-exports", "mask-studio", "mask-tools", "mask-verbs", "mask-rack", "frame-view", "camera-feed", "memory-inspector"]
95
107
  ```
@@ -104,6 +116,7 @@ A tag name `define` registers, before any prefix.
104
116
 
105
117
  ```ts
106
118
  interface FoundMask {
119
+ box?: { h: number; w: number; x: number; y: number };
107
120
  label: string;
108
121
  mask: Uint8Array;
109
122
  score: number;
@@ -140,9 +153,32 @@ function gateWords(row: ModelRow | undefined): string
140
153
 
141
154
  The words of a gate's one pink button for a pick: "load, 1.7 gb", then "ready".
142
155
 
156
+ ```ts
157
+ function isMedia(f: { name: string; type: string }): boolean
158
+ ```
159
+
160
+ A file a speech run can read: audio or video by type or by name.
161
+
162
+ ```ts
163
+ function isProtected(it: StoredItem): boolean
164
+ ```
165
+
166
+ True when an item is kept out of cleanup: decay never drops it.
167
+
168
+ ```ts
169
+ interface MaskEverythingOptions {
170
+ confidence?: number;
171
+ iou?: number;
172
+ minArea?: number;
173
+ sigmoid?: boolean;
174
+ }
175
+ ```
176
+
177
+ Decode settings for a segment everything model (FastSAM): confidence, overlap, smallest area, sigmoid.
178
+
143
179
  ```ts
144
180
  interface MaskModels {
145
- everything?: (image: MaskPixels) => Promise<FoundMask[]>;
181
+ everything?: (image: MaskPixels, o?: MaskEverythingOptions) => Promise<FoundMask[]>;
146
182
  segment?: (image: MaskPixels, point: { x: number; y: number }) => Promise<Uint8Array<ArrayBufferLike> | null>;
147
183
  }
148
184
  ```
@@ -151,27 +187,37 @@ The segment models a mask studio calls: a click segment for one point and a segm
151
187
 
152
188
  ```ts
153
189
  interface MaskStudio extends Mounted {
190
+ canWant: boolean;
154
191
  hasEverything: boolean;
155
192
  hasSegment: boolean;
193
+ addFound(list: FoundMask[]): void;
156
194
  clear(): void;
195
+ clearFound(): void;
157
196
  cutAt(x: number, y: number, mode?: MaskMode): Promise<void>;
158
197
  dispose(): void;
159
- everything(): Promise<void>;
198
+ everything(o?: MaskEverythingOptions): Promise<void>;
160
199
  expand(px?: number): void;
161
- exportAs(kind: MaskOutput): Promise<Blob | null>;
200
+ exportAs(kind: MaskOutput | "inverse"): Promise<Blob | null>;
162
201
  forget(id: number): void;
163
202
  invert(): void;
164
203
  mask(kind?: MaskOutput): ImageData | null;
204
+ mergeFound(): void;
165
205
  pick(): void;
206
+ pixels(): MaskPixels | null;
166
207
  redo(): void;
208
+ removeFound(index: number): void;
167
209
  restore(id: number): void;
168
210
  save(name?: string): void;
211
+ setContiguous(on: boolean): void;
169
212
  setImage(src: string | HTMLImageElement | HTMLCanvasElement | ImageBitmap | MaskPixels): Promise<void>;
213
+ setMask(mask: ArrayLike<number>): void;
170
214
  setMode(m: MaskMode): void;
171
215
  setModels(m: MaskModels): void;
172
216
  setSize(px: number): void;
173
217
  setTolerance(pct: number): void;
174
218
  setTool(t: StudioTool): void;
219
+ setView(v: StudioView): void;
220
+ showFound(index: number, on: boolean): void;
175
221
  shrink(px?: number): void;
176
222
  smooth(r?: number): void;
177
223
  state(): StudioState;
@@ -179,6 +225,7 @@ interface MaskStudio extends Mounted {
179
225
  toggleFound(index: number): void;
180
226
  undo(): void;
181
227
  zoom(dir: -1 | 0 | 1): void;
228
+ zoomTo(z: number): void;
182
229
  }
183
230
  ```
184
231
 
@@ -190,6 +237,7 @@ interface MaskStudioOptions {
190
237
  name?: string;
191
238
  note?: string;
192
239
  onSample?: () => void;
240
+ onWant?: (kind: "segment" | "everything") => void;
193
241
  sampleLabel?: string;
194
242
  title?: string;
195
243
  }
@@ -206,6 +254,44 @@ interface MemoryInspector extends Mounted {
206
254
 
207
255
  A mounted memory inspector whose `set` shows a new recall.
208
256
 
257
+ ```ts
258
+ interface MemoryLike {
259
+ add(text: string, o?: { kind?: "note" | "episode" | "gist" | "lesson" | "fact" | "rule" | "lore" | "doc"; meta?: Record<string, unknown>; section?: string }): Promise<unknown>;
260
+ all(): StoredItem[];
261
+ edit(id: number, patch: EditPatch): Promise<unknown>;
262
+ export(): ExportData;
263
+ import(data: ExportData, o?: { replace?: boolean }): Promise<number>;
264
+ recall(q: string, o?: { k?: number }): Promise<Recall>;
265
+ remove(ids: number[]): Promise<void>;
266
+ }
267
+ ```
268
+
269
+ What a memory pane needs from a store; a `Memory` from @hackbuild/memory fits.
270
+
271
+ ```ts
272
+ interface MemoryPaneHandle extends Mounted {
273
+ dispose(): void;
274
+ refresh(): void;
275
+ used(labels: readonly string[]): void;
276
+ }
277
+ ```
278
+
279
+ A memory pane over a host: `refresh` after the store changes elsewhere, `used` to mark what the last reply used.
280
+
281
+ ```ts
282
+ interface MemoryPaneOptions {
283
+ acts?: readonly { id: string; label: string }[];
284
+ by?: "source" | "kind";
285
+ exportLabel?: string;
286
+ kinds?: Readonly<Record<string, string>>;
287
+ name?: string;
288
+ onAct?: (id: string) => void;
289
+ onChange?: () => void;
290
+ }
291
+ ```
292
+
293
+ Options of a memory pane.
294
+
209
295
  ```ts
210
296
  interface ModelSelectElement extends HTMLElement {
211
297
  env: Env | undefined;
@@ -256,6 +342,12 @@ function mountContextMeter(host: HTMLElement, thread: ChatThread, o?: { budget?:
256
342
 
257
343
  The context meter (hackbuild-ui `.hb-ctxmeter`): what the next request carries against the model's context.
258
344
 
345
+ ```ts
346
+ function mountExportMenu(host: HTMLElement, queue: TranscribeQueue, o?: { go?: boolean; save?: (name: string, data: string | Uint8Array<ArrayBufferLike>, type: string) => void; tool?: string }): Mounted
347
+ ```
348
+
349
+ ExportMenu: the selected transcript as txt, srt, vtt or json, a copy, and every finished transcript as one zip with a manifest, plus undo and redo of edits.
350
+
259
351
  ```ts
260
352
  function mountFrameView(host: HTMLElement, o?: FrameViewOptions): FrameView
261
353
  ```
@@ -263,7 +355,7 @@ function mountFrameView(host: HTMLElement, o?: FrameViewOptions): FrameView
263
355
  Draws a frame in a camera tile on a host, with boxes, landmarks, a corner tag and a caption over it.
264
356
 
265
357
  ```ts
266
- function mountMaskRack(host: HTMLElement, studio: MaskStudio, part: "found" | "mask" | "saved" | "export", o?: { name?: string }): Mounted
358
+ function mountMaskRack(host: HTMLElement, studio: MaskStudio, part: "export" | "found" | "mask" | "saved", o?: { name?: string }): Mounted
267
359
  ```
268
360
 
269
361
  The rack parts: what was found, the mask tools' settings, and the exports once there is a mask.
@@ -292,6 +384,12 @@ function mountMemoryInspector(host: HTMLElement, rec?: RecallLike | null): Memor
292
384
 
293
385
  Shows a recall trace as a table on a host.
294
386
 
387
+ ```ts
388
+ function mountMemoryPane(host: HTMLElement, mem: MemoryLike, o?: MemoryPaneOptions): MemoryPaneHandle
389
+ ```
390
+
391
+ The memory pane: counts, search, a source or kind filter, add a note, the list with protect and forget, export, import, erase.
392
+
295
393
  ```ts
296
394
  function mountModelJobs(host: HTMLElement, jobs: JobsPick, o?: { go?: boolean }): Mounted
297
395
  ```
@@ -304,6 +402,24 @@ function mountModelSelect(host: HTMLElement, pick: ModelPick, o?: ModelSelectOpt
304
402
 
305
403
  The closed picker over a host; pressing it opens the sheet.
306
404
 
405
+ ```ts
406
+ function mountPersonaRack(host: HTMLElement, rack: PersonaRack): Mounted
407
+ ```
408
+
409
+ The persona rack: presets one press away, name, the three parts with their cost, the template, save, and the persona as a file.
410
+
411
+ ```ts
412
+ function mountSessionMenu(host: HTMLElement, list: ChatList, o?: { onImport?: (n: number) => void }): Mounted
413
+ ```
414
+
415
+ The session menu of a chat list: clear the open chat, export it as markdown, every chat as json, and import.
416
+
417
+ ```ts
418
+ function mountSourcesDrop(host: HTMLElement, o: SourcesDropOptions): Mounted
419
+ ```
420
+
421
+ A drop zone for sources: files or a whole folder of text, pdf, docx, zip and mail go into memory; a line per file says what came in.
422
+
307
423
  ```ts
308
424
  function mountTranscribeDrop(host: HTMLElement, queue: TranscribeQueue, o?: TranscribeDropOptions): TranscribeDropHandle
309
425
  ```
@@ -328,27 +444,63 @@ function mountTranscriptView(host: HTMLElement, queue: TranscribeQueue, o?: Tran
328
444
 
329
445
  The selected channel's transcript over a host.
330
446
 
447
+ ```ts
448
+ function mountVoiceClone(host: HTMLElement, sp: Speaker, o?: { can?: () => boolean; hint?: string; seconds?: number }): Mounted
449
+ ```
450
+
451
+ The voice clone row of a speaker: clone from an audio file, record `seconds` of mic, download the clone as wav, clear it.
452
+
453
+ ```ts
454
+ function mountVoiceRow(host: HTMLElement, row: VoiceRow, o?: { test?: string }): Mounted
455
+ ```
456
+
457
+ The voice row: auto speak, voice, rate, pitch, test and stop.
458
+
331
459
  ```ts
332
460
  function pickSheet(pick: ModelPick): Mounted & { open(): void }
333
461
  ```
334
462
 
335
463
  The sheet of one pick, in a drawer on the body.
336
464
 
465
+ ```ts
466
+ function protect(mem: Pick<MemoryLike, "edit">, it: StoredItem, on: boolean): Promise<void>
467
+ ```
468
+
469
+ Protect an item from cleanup (it becomes lore, which never decays) or give it back its kind.
470
+
471
+ ```ts
472
+ function shortName(name: string): string
473
+ ```
474
+
475
+ A model name cut for the bar chip: filler words (instruct, chat, quant tags) go, and a name of more than three words keeps its first two and its last, which is usually the size: "hermes 3 llama 3.2 3b" reads "hermes 3 3b".
476
+
477
+ ```ts
478
+ interface SourcesDropOptions {
479
+ accept?: string;
480
+ ingest: (files: File[], o: { onFile: (e: { chunks: number; name: string; note?: string }) => void }) => Promise<{ chunks: number; files: number }>;
481
+ }
482
+ ```
483
+
484
+ Options for a sources drop: what reads the files into memory, and a line per file.
485
+
337
486
  ```ts
338
487
  interface StudioState {
339
488
  busy: string;
340
489
  canRedo: boolean;
341
490
  canUndo: boolean;
491
+ contiguous: boolean;
342
492
  coverage: number;
343
493
  error: string;
344
- found: (FoundMask & { colour: string; on: boolean })[];
494
+ found: (FoundMask & { colour: string; hidden: boolean; on: boolean })[];
345
495
  height: number;
496
+ hover: number;
346
497
  mode: MaskMode;
347
498
  ready: boolean;
348
499
  saved: { coverage: number; id: number; name: string; thumb: string }[];
349
500
  size: number;
350
501
  tolerance: number;
351
502
  tool: StudioTool;
503
+ view: StudioView;
352
504
  width: number;
353
505
  zoom: number;
354
506
  }
@@ -362,10 +514,17 @@ type StudioTool = "point" | MaskTool
362
514
 
363
515
  A mask studio tool: the click segment point or one of the hackbuild-ui mask tools.
364
516
 
517
+ ```ts
518
+ type StudioView = "composite" | "mask" | "instances"
519
+ ```
520
+
521
+ What the canvas shows: the picture with the mask, the mask alone, or every found object in its colour.
522
+
365
523
  ```ts
366
524
  interface TranscribeDropHandle extends Mounted {
367
525
  dispose(): void;
368
526
  pick(): void;
527
+ pickFolder(): void;
369
528
  }
370
529
  ```
371
530
 
@@ -374,6 +533,7 @@ A mounted drop zone whose `pick` opens the file picker.
374
533
  ```ts
375
534
  interface TranscribeDropOptions extends TranscriptViewOptions {
376
535
  accept?: string;
536
+ folders?: boolean;
377
537
  note?: string;
378
538
  onSample?: () => void;
379
539
  onSeek?: (seconds: number) => void;
@@ -417,6 +577,18 @@ const ALL_RECORDS: readonly ModelRecord[]
417
577
 
418
578
  Every record the views know, the running package's copy of a duplicate first.
419
579
 
580
+ ```ts
581
+ function asImage(img: unknown): unknown
582
+ ```
583
+
584
+ Pixels ({ width, height, data }) as a canvas, which every runtime reads; anything else passes through.
585
+
586
+ ```ts
587
+ type AskFn = (image: unknown, question?: string) => Promise<string>
588
+ ```
589
+
590
+ A vision language model as a page calls it: a question about an image (a caption without one), answered in words.
591
+
420
592
  ```ts
421
593
  function backendOf(r: ModelRecord, env?: Env): ModelBackend
422
594
  ```
@@ -429,6 +601,12 @@ function boxWords(b: FrameBox): string
429
601
 
430
602
  "cup 94%", or the label alone, or the score alone.
431
603
 
604
+ ```ts
605
+ function canClone(e: unknown): e is PocketEngine
606
+ ```
607
+
608
+ True when the engine clones a voice from reference audio.
609
+
432
610
  ```ts
433
611
  interface Channel {
434
612
  dropped: Dropped[];
@@ -440,8 +618,10 @@ interface Channel {
440
618
  model?: string;
441
619
  name: string;
442
620
  pct: number;
621
+ rail?: { db: number[]; kept: number[] };
443
622
  segments: Seg[];
444
623
  size: number;
624
+ stats?: { density: number; dur: number; forced: boolean; gainDb: number; loudDb: number; noiseDb: number; reels: number; rtf: number; snrDb: number; speechDb: number; thrDb: number; wall: number };
445
625
  status: StripStatus;
446
626
  }
447
627
  ```
@@ -458,9 +638,11 @@ Creates a list of chat threads, newest first, with one open; its `thread` always
458
638
  interface ChatList {
459
639
  readonly thread: ChatThread;
460
640
  create(): string;
641
+ dump(): ChatListData;
461
642
  open(id: string): void;
462
643
  remove(id: string): void;
463
644
  rename(id: string, title: string): void;
645
+ restore(data: ChatListData, o?: { replace?: boolean }): void;
464
646
  setEngine(engine: ChatEngine | null): void;
465
647
  snapshot(): ChatListSnapshot;
466
648
  subscribe(fn: (s: ChatListSnapshot) => void): () => void;
@@ -469,6 +651,17 @@ interface ChatList {
469
651
 
470
652
  Several chats: a list with the newest first, one open.
471
653
 
654
+ ```ts
655
+ interface ChatListData {
656
+ chats: { id: string; named?: boolean; title: string; turns: Turn[]; updated: number }[];
657
+ current?: string;
658
+ format: "hackbuild-chats";
659
+ version: 1;
660
+ }
661
+ ```
662
+
663
+ A chat list as plain data: format, version, the open chat and each chat's title and turns.
664
+
472
665
  ```ts
473
666
  interface ChatListItem {
474
667
  count: number;
@@ -498,6 +691,7 @@ Creates a chat thread that streams replies from an engine, with optional memory
498
691
  ```ts
499
692
  interface ChatThread {
500
693
  clear(): void;
694
+ load(turns: readonly Turn[]): void;
501
695
  markdown(title?: string): string;
502
696
  regenerate(): Promise<void>;
503
697
  remove(id: number): void;
@@ -523,12 +717,24 @@ function defaultPick(records: readonly ModelRecord[], env?: Env, estimate?: Stor
523
717
 
524
718
  The row a picker starts on: the first "start here" record that fits this machine, else the first that fits and is fast or steady, else the first that fits, else the first.
525
719
 
720
+ ```ts
721
+ type DepthFn = (image: unknown) => Promise<{ data: Float32Array; height: number; width: number }>
722
+ ```
723
+
724
+ A depth model as a page calls it: 0 to 1 per pixel, larger is nearer (relative inverse depth).
725
+
526
726
  ```ts
527
727
  function detailOf(r: ModelRecord): { label: string; value: string }[]
528
728
  ```
529
729
 
530
730
  The chevron detail: licence, source, context, quant, runtime, and where the size came from.
531
731
 
732
+ ```ts
733
+ type DetectFn = (image: unknown) => Promise<FrameBox[]>
734
+ ```
735
+
736
+ A detector as a page calls it: boxes in image pixels, best first.
737
+
532
738
  ```ts
533
739
  type ExportKind = "txt" | "srt" | "vtt" | "json"
534
740
  ```
@@ -593,6 +799,12 @@ function groupOf(r: ModelRecord, state?: ModelPickState): ModelRowGroup
593
799
 
594
800
  The group a row sits in.
595
801
 
802
+ ```ts
803
+ type ImageJob = ImageGenerator & { tokenize: ClipTokenize; make(o: FormOptions): Promise<Generated> }
804
+ ```
805
+
806
+ An image model with its CLIP tokenizer: `make` generates with the form's defaults filled in.
807
+
596
808
  ```ts
597
809
  function inspectorHtml(rec: RecallLike | null): string
598
810
  ```
@@ -651,6 +863,25 @@ interface JobLine {
651
863
 
652
864
  One line of a jobs rack: the job, its label, whether it is required, and the chosen row.
653
865
 
866
+ ```ts
867
+ function jobLoader<J extends Job>(job: J, o?: JobLoaderOptions): Loader
868
+ ```
869
+
870
+ A real Loader for a job.
871
+
872
+ ```ts
873
+ interface JobLoaderOptions {
874
+ allowGplPhonemizer?: boolean;
875
+ env?: Env;
876
+ fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
877
+ modules?: RuntimeModules;
878
+ rng?: () => number;
879
+ store?: WeightStore | Promise<WeightStore>;
880
+ }
881
+ ```
882
+
883
+ Options for jobLoader.
884
+
654
885
  ```ts
655
886
  function jobRecords(job: Job, records?: readonly ModelRecord[]): ModelRecord[]
656
887
  ```
@@ -673,12 +904,30 @@ interface JobsPick {
673
904
  presets(): { id: string; label: string; total: string }[];
674
905
  setPresets(p: readonly PickPreset[]): void;
675
906
  subscribe(fn: () => void): () => void;
676
- update(o: { env?: Env; estimate?: StorageEstimate | null; loader?: Loader; onRemove?: (rec: ModelRecord) => void | Promise<void>; records?: readonly ModelRecord[] }): void;
907
+ update(o: { env?: Env; estimate?: StorageEstimate | null; loader?: Loader; onRemove?: (rec: ModelRecord) => void | Promise<void>; records?: readonly ModelRecord[]; stored?: Iterable<string, any, any> }): void;
677
908
  }
678
909
  ```
679
910
 
680
911
  Several pickers as one rack: a line per job, presets with their totals, and load all.
681
912
 
913
+ ```ts
914
+ interface JobValues {
915
+ chat: ChatEngine;
916
+ depth: DepthFn;
917
+ detect: DetectFn;
918
+ embed: Embedder;
919
+ faceswap: unknown;
920
+ image: ImageJob;
921
+ landmarks: unknown;
922
+ masks: MaskModels;
923
+ transcribe: Transcriber;
924
+ vision: AskFn;
925
+ voice: Engine;
926
+ }
927
+ ```
928
+
929
+ What a jobLoader load resolves to, per job: chat a ChatEngine; transcribe a Transcriber; detect a DetectFn; masks MaskModels; depth a DepthFn; vision an AskFn; image an ImageJob; voice a loaded @hackbuild/speak Engine; embed an Embedder.
930
+
682
931
  ```ts
683
932
  function labelColour(label: string | undefined, palette: readonly string[]): string
684
933
  ```
@@ -725,7 +974,7 @@ interface ModelPick {
725
974
  result(id: string): unknown;
726
975
  snapshot(): PickSnapshot;
727
976
  subscribe(fn: (s: PickSnapshot) => void): () => void;
728
- update(o: { env?: Env; estimate?: StorageEstimate | null; loader?: Loader; onRemove?: (rec: ModelRecord) => void | Promise<void>; records?: readonly ModelRecord[] }): void;
977
+ update(o: { env?: Env; estimate?: StorageEstimate | null; loader?: Loader; onRemove?: (rec: ModelRecord) => void | Promise<void>; records?: readonly ModelRecord[]; stored?: Iterable<string, any, any> }): void;
729
978
  }
730
979
  ```
731
980
 
@@ -749,6 +998,47 @@ function ownRecord(job: Job, kind: OwnKind, v: Record<string, string>): ModelRec
749
998
 
750
999
  A record for a "your own" form.
751
1000
 
1001
+ ```ts
1002
+ interface Persona {
1003
+ first?: string;
1004
+ name: string;
1005
+ notes: string;
1006
+ profile: string;
1007
+ rules: string;
1008
+ }
1009
+ ```
1010
+
1011
+ A persona in three parts, highest priority first, with its name and first line.
1012
+
1013
+ ```ts
1014
+ interface PersonaPresetX {
1015
+ label: string;
1016
+ persona: Persona;
1017
+ }
1018
+ ```
1019
+
1020
+ A named persona a person can load in one press.
1021
+
1022
+ ```ts
1023
+ function personaRack(o?: { onSave?: (saved: PersonaPresetX[]) => void; persona?: Persona; presets?: readonly PersonaPresetX[]; saved?: readonly PersonaPresetX[] }): PersonaRack
1024
+ ```
1025
+
1026
+ Creates a persona rack with built in presets and any saved ones; `onSave` keeps the saved ones.
1027
+
1028
+ ```ts
1029
+ interface PersonaRack {
1030
+ load(i: number): void;
1031
+ removePreset(i: number): void;
1032
+ save(label: string): void;
1033
+ set(p: Partial<Persona>): void;
1034
+ snapshot(): { builtIn: number; on: number; persona: Persona; presets: readonly PersonaPresetX[] };
1035
+ subscribe(fn: (s: { builtIn: number; on: number; persona: Persona; presets: readonly PersonaPresetX[] }) => void): () => void;
1036
+ system(mem?: readonly MemoryUsed[], budgetTokens?: number): { dropped: string[]; text: string };
1037
+ }
1038
+ ```
1039
+
1040
+ The persona state: the current persona, presets, and the system prompt fitted to a budget.
1041
+
752
1042
  ```ts
753
1043
  interface PickOptions {
754
1044
  chosen?: string;
@@ -806,6 +1096,16 @@ type RecallLike = Pick<Recall, "trace" | "hits" | "query" | "mode">
806
1096
 
807
1097
  The parts of a memory recall the inspector shows: trace, hits, query and mode.
808
1098
 
1099
+ ```ts
1100
+ interface RepoCheck {
1101
+ note: string;
1102
+ ok: boolean;
1103
+ onnx: number;
1104
+ }
1105
+ ```
1106
+
1107
+ What a hub repo check found: whether it exists, whether it carries onnx files, and the words a row shows.
1108
+
809
1109
  ```ts
810
1110
  interface RowContext {
811
1111
  env?: Env;
@@ -829,6 +1129,7 @@ One record as one picker row.
829
1129
  ```ts
830
1130
  interface RunContext {
831
1131
  onProgress: (fraction: number) => void;
1132
+ options?: TranscribeRunOptions;
832
1133
  signal: AbortSignal;
833
1134
  }
834
1135
  ```
@@ -841,26 +1142,102 @@ interface RunResult {
841
1142
  duration?: number;
842
1143
  language?: string;
843
1144
  model?: string;
1145
+ rail?: { db: number[]; kept: number[] };
844
1146
  segments: Seg[];
1147
+ stats?: { density: number; dur: number; forced: boolean; gainDb: number; loudDb: number; noiseDb: number; reels: number; rtf: number; snrDb: number; speechDb: number; thrDb: number; wall: number };
845
1148
  }
846
1149
  ```
847
1150
 
848
1151
  What a transcriber returns: segments, dropped lines, duration, language and model.
849
1152
 
1153
+ ```ts
1154
+ const RUNTIME_URLS: { readonly bellows: readonly ["https://cdn.jsdelivr.net/npm/bellows-voice@0.8.0/engine/+esm"]; readonly kokoro: readonly ["https://cdn.jsdelivr.net/npm/kokoro-js@1.2.1/+esm"]; readonly webllm: readonly ["https://esm.run/@mlc-ai/web-llm@0.2.84", "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.84/+esm"] }
1155
+ ```
1156
+
1157
+ Pinned CDN modules jobLoader imports at load time.
1158
+
1159
+ ```ts
1160
+ interface RuntimeModules {
1161
+ bellows?: () => Promise<unknown>;
1162
+ dsp?: () => Promise<Dsp>;
1163
+ kokoro?: () => Promise<unknown>;
1164
+ ort?: () => Promise<OrtModule>;
1165
+ tasksVision?: () => Promise<unknown>;
1166
+ transformers?: () => Promise<TjsModule>;
1167
+ webllm?: () => Promise<unknown>;
1168
+ wllama?: () => Promise<unknown>;
1169
+ }
1170
+ ```
1171
+
1172
+ The runtime modules, each a function that imports it.
1173
+
850
1174
  ```ts
851
1175
  function sizeWords(r: ModelRecord): string | undefined
852
1176
  ```
853
1177
 
854
1178
  Download words: "1.7 gb".
855
1179
 
1180
+ ```ts
1181
+ function speaker(engine: () => Engine | null, o?: SpeakerOptions): Speaker
1182
+ ```
1183
+
1184
+ A speaker over the engine `engine()` returns at each line (null: text only, timed by `play`).
1185
+
1186
+ ```ts
1187
+ interface Speaker {
1188
+ readonly cloned: boolean;
1189
+ clearClone(): void;
1190
+ cloneFile(file: Blob): Promise<number>;
1191
+ cloneMic(seconds: number, onTick?: (left: number) => void): Promise<number>;
1192
+ cloneWav(): Blob | null;
1193
+ say(text: string): Promise<void>;
1194
+ stop(): void;
1195
+ subscribe(fn: () => void): () => void;
1196
+ }
1197
+ ```
1198
+
1199
+ Spoken lines in order, and the clone.
1200
+
1201
+ ```ts
1202
+ interface SpeakerOptions {
1203
+ config?: () => VoiceConfig;
1204
+ halt?: () => void;
1205
+ onLine?: (text: string) => void;
1206
+ play?: (line: SpokenLine) => Promise<void>;
1207
+ }
1208
+ ```
1209
+
1210
+ Options of `speaker`.
1211
+
1212
+ ```ts
1213
+ interface SpokenLine {
1214
+ audio?: AudioBuffer;
1215
+ phonemes?: readonly { phoneme?: string; t0: number; t1: number }[];
1216
+ text: string;
1217
+ words?: readonly { end?: number; start?: number; t0: number; t1: number; text?: string }[];
1218
+ }
1219
+ ```
1220
+
1221
+ One line ready to play: the text, and for a rendering engine the audio with its word and phoneme times.
1222
+
1223
+ ```ts
1224
+ function storedIds(store: Pick<WeightStore, "keys">, records: readonly ModelRecord[]): Promise<string[]>
1225
+ ```
1226
+
1227
+ The ids of records whose files are already in a weight store: the cache badge of a picker.
1228
+
856
1229
  ```ts
857
1230
  interface ThreadOptions {
858
1231
  engine?: ChatEngine | null;
1232
+ history?: () => number;
859
1233
  maxTokens?: number;
860
1234
  noEngine?: string;
861
1235
  now?: () => number;
1236
+ onReply?: (turn: Turn, said: string) => void;
862
1237
  recall?: (query: string) => Promise<MemoryUsed[]>;
863
- system?: string;
1238
+ stream?: () => Omit<StreamOptions, "signal">;
1239
+ system?: string | () => string;
1240
+ systemFor?: (mem: MemoryUsed[]) => string;
864
1241
  }
865
1242
  ```
866
1243
 
@@ -905,7 +1282,7 @@ function traceRows(r: Pick<Recall, "trace" | "hits">, maxText?: number): TraceRo
905
1282
  The rows of a recall trace as text, marking the hits handed to the model.
906
1283
 
907
1284
  ```ts
908
- function transcribeQueue(o: { autostart?: boolean; run: Transcriber }): TranscribeQueue
1285
+ function transcribeQueue(o: { autostart?: boolean; options?: () => TranscribeRunOptions; run: Transcriber }): TranscribeQueue
909
1286
  ```
910
1287
 
911
1288
  Creates a transcribe queue that runs each file through `run`, one at a time.
@@ -925,6 +1302,7 @@ interface TranscribeQueue {
925
1302
  stop(): void;
926
1303
  subscribe(fn: (s: QueueSnapshot) => void): () => void;
927
1304
  undo(): void;
1305
+ zip(o?: { date?: Date; tool?: string }): { data: Uint8Array; manifest: Manifest; name: string } | null;
928
1306
  }
929
1307
  ```
930
1308
 
@@ -936,6 +1314,23 @@ type Transcriber = (file: Blob & { name: string }, ctx: RunContext) => Promise<R
936
1314
 
937
1315
  Turns one file into a transcript.
938
1316
 
1317
+ ```ts
1318
+ interface TranscribeRunOptions extends FrontEndOptions {
1319
+ channel?: "auto" | "mix" | "L" | "R";
1320
+ denoise?: 0 | 1 | 2 | 3;
1321
+ halluc?: boolean;
1322
+ hp?: number;
1323
+ language?: string;
1324
+ maxGainDb?: number;
1325
+ perReelAgc?: boolean;
1326
+ skipSilence?: boolean;
1327
+ targetDb?: number;
1328
+ vadMargin?: number;
1329
+ }
1330
+ ```
1331
+
1332
+ Run settings a transcriber reads: the capture front end (target level, lift, denoise, gate margin, rumble filter, skip silence, re-level), the channel, the language and the phantom filter.
1333
+
939
1334
  ```ts
940
1335
  interface Turn {
941
1336
  at: number;
@@ -964,6 +1359,31 @@ function useModelPick(job: Job, o?: PickOptions): ModelPick
964
1359
 
965
1360
  Creates a model picker for a job, with rows that say whether each model fits this machine.
966
1361
 
1362
+ ```ts
1363
+ function verifyRepo(repo: string, o?: { fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>; host?: string }): Promise<RepoCheck>
1364
+ ```
1365
+
1366
+ Checks a hub repo id before it is used as your own model: it exists, it is public, and it carries onnx files transformers.js can run.
1367
+
1368
+ ```ts
1369
+ function voiceRow(engine: NativeEngine, o?: { auto?: boolean; onChange?: (s: { auto: boolean; pitch: number; rate: number; voice: string }) => void; pitch?: number; rate?: number; voice?: string }): VoiceRow
1370
+ ```
1371
+
1372
+ Creates the voice state over a native engine (`webSpeechEngine()` of @hackbuild/speak).
1373
+
1374
+ ```ts
1375
+ interface VoiceRow {
1376
+ reply(text: string): void;
1377
+ set(p: Partial<{ auto: boolean; pitch: number; rate: number; voice: string }>): void;
1378
+ snapshot(): { auto: boolean; error: string; pitch: number; rate: number; speaking: boolean; voice: string; voices: string[] };
1379
+ speak(text: string): Promise<void>;
1380
+ stop(): void;
1381
+ subscribe(fn: (s: { auto: boolean; error: string; pitch: number; rate: number; speaking: boolean; voice: string; voices: string[] }) => void): () => void;
1382
+ }
1383
+ ```
1384
+
1385
+ Spoken replies: auto speak, the voice, rate and pitch, speak and stop.
1386
+
967
1387
  ```ts
968
1388
  function weightKeys(rec: ModelRecord): string[]
969
1389
  ```
@@ -1014,6 +1434,12 @@ const ContextMeter: DefineComponent<{ budget: number; system: string; thread: Ch
1014
1434
 
1015
1435
  Vue component that shows what the next request carries against the context budget.
1016
1436
 
1437
+ ```ts
1438
+ const ExportMenu: DefineComponent<{ go: boolean; queue: TranscribeQueue; tool: string }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ go: boolean; queue: TranscribeQueue; tool: string }, {}>, { go: boolean; tool: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1439
+ ```
1440
+
1441
+ Vue component for the export menu of a transcribe queue: four formats, copy, all as zip, undo and redo.
1442
+
1017
1443
  ```ts
1018
1444
  const FrameView: DefineComponent<ExtractPropTypes<{ mirror: { default: boolean; type: BooleanConstructor }; results: { default: () => {}; type: PropType<FrameResults> }; source: { default: null; type: PropType<string | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | null> } }>, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "view"[], "view", PublicProps, ToResolvedProps<ExtractPropTypes<{ mirror: { default: boolean; type: BooleanConstructor }; results: { default: () => {}; type: PropType<FrameResults> }; source: { default: null; type: PropType<string | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | null> } }>, "view"[]>, { mirror: boolean; results: FrameResults; source: string | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | null }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1019
1445
  ```
@@ -1021,16 +1447,16 @@ const FrameView: DefineComponent<ExtractPropTypes<{ mirror: { default: boolean;
1021
1447
  Vue component that draws a frame with boxes, landmarks and a caption; emits `view` with the mounted view.
1022
1448
 
1023
1449
  ```ts
1024
- const MaskRack: DefineComponent<{ name: string; part: "found" | "mask" | "saved" | "export"; studio: MaskStudio }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ name: string; part: "found" | "mask" | "saved" | "export"; studio: MaskStudio }, {}>, { name: string; part: "found" | "mask" | "saved" | "export" }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1450
+ const MaskRack: DefineComponent<{ name: string; part: "export" | "found" | "mask" | "saved"; studio: MaskStudio }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ name: string; part: "export" | "found" | "mask" | "saved"; studio: MaskStudio }, {}>, { name: string; part: "export" | "found" | "mask" | "saved" }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1025
1451
  ```
1026
1452
 
1027
1453
  Vue component for one rack part of a mask studio: found, mask, saved or export.
1028
1454
 
1029
1455
  ```ts
1030
- const MaskStudio: DefineComponent<ExtractPropTypes<{ models: { default: () => {}; type: PropType<MaskModels> }; sampleLabel: { default: string; type: StringConstructor } }>, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("sample" | "studio")[], "sample" | "studio", PublicProps, ToResolvedProps<ExtractPropTypes<{ models: { default: () => {}; type: PropType<MaskModels> }; sampleLabel: { default: string; type: StringConstructor } }>, ("sample" | "studio")[]>, { models: MaskModels; sampleLabel: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1456
+ const MaskStudio: DefineComponent<ExtractPropTypes<{ demand: { default: boolean; type: BooleanConstructor }; models: { default: () => {}; type: PropType<MaskModels> }; sampleLabel: { default: string; type: StringConstructor } }>, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("sample" | "studio" | "want")[], "sample" | "studio" | "want", PublicProps, ToResolvedProps<ExtractPropTypes<{ demand: { default: boolean; type: BooleanConstructor }; models: { default: () => {}; type: PropType<MaskModels> }; sampleLabel: { default: string; type: StringConstructor } }>, ("sample" | "studio" | "want")[]>, { demand: boolean; models: MaskModels; sampleLabel: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1031
1457
  ```
1032
1458
 
1033
- Vue component for a mask studio; emits `studio` with the mounted studio and `sample` when the sample button is pressed.
1459
+ Vue component for a mask studio; emits `studio` with the mounted studio, `sample` when the sample button is pressed, and with `demand` set, `want` when a tool needs a model not loaded yet.
1034
1460
 
1035
1461
  ```ts
1036
1462
  const MaskTools: DefineComponent<{ studio: MaskStudio }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ studio: MaskStudio }, {}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
@@ -1050,6 +1476,12 @@ const MemoryInspector: DefineComponent<ExtractPropTypes<{ recall: { default: nul
1050
1476
 
1051
1477
  Vue component that shows a recall trace as a table.
1052
1478
 
1479
+ ```ts
1480
+ const MemoryPane: DefineComponent<{ acts?: readonly { id: string; label: string }[]; by: "source" | "kind"; exportLabel: string; kinds?: Record<string, string>; memory: MemoryLike; name: string }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("change" | "pane" | "act")[], "change" | "pane" | "act", PublicProps, ToResolvedProps<{ acts?: readonly { id: string; label: string }[]; by: "source" | "kind"; exportLabel: string; kinds?: Record<string, string>; memory: MemoryLike; name: string }, ("change" | "pane" | "act")[]>, { acts: readonly { id: string; label: string }[] | undefined; by: "source" | "kind"; exportLabel: string; kinds: Record<string, string>; name: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1481
+ ```
1482
+
1483
+ Vue component for a memory pane over a store; emits `pane` with the handle (refresh, used).
1484
+
1053
1485
  ```ts
1054
1486
  const ModelJobs: DefineComponent<{ go: boolean; jobs: JobsPick }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ go: boolean; jobs: JobsPick }, {}>, { go: boolean }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1055
1487
  ```
@@ -1063,10 +1495,28 @@ const ModelSelect: DefineComponent<{ env?: Env; go: boolean; job: Job; loader?:
1063
1495
  Vue component for a model picker of one job; emits `pick`, `choose`, `loaded` and `failed`.
1064
1496
 
1065
1497
  ```ts
1066
- const TranscribeDrop: DefineComponent<{ accept: string; queue: TranscribeQueue; sampleLabel: string }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "sample"[], "sample", PublicProps, ToResolvedProps<{ accept: string; queue: TranscribeQueue; sampleLabel: string }, "sample"[]>, { accept: string; sampleLabel: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1498
+ const PersonaRack: DefineComponent<{ rack: PersonaRack }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ rack: PersonaRack }, {}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1067
1499
  ```
1068
1500
 
1069
- Vue component for the drop zone that becomes the transcript; emits `sample`.
1501
+ Vue component for a persona rack.
1502
+
1503
+ ```ts
1504
+ const SessionMenu: DefineComponent<{ list: ChatList }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "import"[], "import", PublicProps, ToResolvedProps<{ list: ChatList }, "import"[]>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1505
+ ```
1506
+
1507
+ Vue component for the session menu of a chat list; emits `import` with the number of chats.
1508
+
1509
+ ```ts
1510
+ const SourcesDrop: DefineComponent<{ accept: string; ingest: (files: File[], o: { onFile: (e: { chunks: number; name: string; note?: string }) => void }) => Promise<{ chunks: number; files: number }> }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ accept: string; ingest: (files: File[], o: { onFile: (e: { chunks: number; name: string; note?: string }) => void }) => Promise<{ chunks: number; files: number }> }, {}>, { accept: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1511
+ ```
1512
+
1513
+ Vue component for a sources drop: files and folders into memory through `ingest`.
1514
+
1515
+ ```ts
1516
+ const TranscribeDrop: DefineComponent<{ accept: string; folders: boolean; note: string; queue: TranscribeQueue; sampleLabel: string; showDropped: boolean; title: string }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("drop" | "sample")[], "drop" | "sample", PublicProps, ToResolvedProps<{ accept: string; folders: boolean; note: string; queue: TranscribeQueue; sampleLabel: string; showDropped: boolean; title: string }, ("drop" | "sample")[]>, { accept: string; folders: boolean; note: string; sampleLabel: string; showDropped: boolean; title: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1517
+ ```
1518
+
1519
+ Vue component for the drop zone that becomes the transcript; emits `sample` and `drop` (the handle, whose `pick` opens the file picker).
1070
1520
 
1071
1521
  ```ts
1072
1522
  const TranscribeQueue: DefineComponent<{ queue: TranscribeQueue }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ queue: TranscribeQueue }, {}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
@@ -1080,6 +1530,18 @@ const TranscriptView: DefineComponent<{ exports: boolean; queue: TranscribeQueue
1080
1530
 
1081
1531
  Vue component for the selected transcript, or its export buttons when `exports` is set.
1082
1532
 
1533
+ ```ts
1534
+ const VoiceClone: DefineComponent<{ can: boolean; hint: string; seconds: number; speaker: Speaker }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ can: boolean; hint: string; seconds: number; speaker: Speaker }, {}>, { can: boolean; hint: string; seconds: number }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1535
+ ```
1536
+
1537
+ Vue component for the voice clone row of a speaker; `can` says the loaded voice clones.
1538
+
1539
+ ```ts
1540
+ const VoiceRow: DefineComponent<{ row: VoiceRow; test: string }, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, ToResolvedProps<{ row: VoiceRow; test: string }, {}>, { test: string }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
1541
+ ```
1542
+
1543
+ Vue component for a voice row.
1544
+
1083
1545
  ## Examples
1084
1546
 
1085
1547
  ### quick start