@qvac/harness 1.0.0-rc.19 → 1.0.0-rc.20

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 (59) hide show
  1. package/CHANGELOG.md +106 -2
  2. package/README.md +7 -0
  3. package/dist-lib/lib/capabilities/agent-ports.js +4 -3
  4. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +1 -0
  5. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +3 -1
  6. package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +5 -4
  7. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +5 -1
  8. package/dist-lib/lib/capabilities/completion-engine/driver.js +9 -2
  9. package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +3 -1
  10. package/dist-lib/lib/capabilities/sdk-tool.d.ts +2 -2
  11. package/dist-lib/lib/capabilities/sdk-tool.js +2 -2
  12. package/dist-lib/lib/capabilities/tool-turns.d.ts +1 -0
  13. package/dist-lib/lib/capabilities/tool-turns.js +2 -0
  14. package/dist-lib/lib/contract/agent.d.ts +2 -0
  15. package/dist-lib/lib/contract/media.d.ts +7 -0
  16. package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
  17. package/dist-lib/lib/helpers/run-outcome.js +6 -2
  18. package/dist-lib/lib/machine/completion/types.d.ts +1 -0
  19. package/dist-lib/lib/machine/index.d.ts +2 -0
  20. package/dist-lib/lib/machine/index.js +2 -0
  21. package/dist-lib/lib/media-wire.js +16 -1
  22. package/dist-lib/lib/models/context-choice.js +8 -1
  23. package/dist-lib/lib/models/llm-presets.js +27 -1
  24. package/dist-lib/lib/models/model-catalog-constants.d.ts +2 -2
  25. package/dist-lib/lib/models/model-catalog-constants.js +3 -4
  26. package/dist-lib/lib/models/model-catalog.d.ts +4 -2
  27. package/dist-lib/lib/models/model-catalog.js +29 -11
  28. package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
  29. package/dist-lib/lib/models/tts-model-default.js +8 -6
  30. package/dist-lib/lib/plugins/registry.d.ts +1 -0
  31. package/dist-lib/lib/plugins/registry.js +7 -4
  32. package/dist-lib/lib/prompt.d.ts +5 -4
  33. package/dist-lib/lib/prompt.js +68 -22
  34. package/dist-lib/lib/residency/completion-runtime.js +6 -1
  35. package/dist-lib/lib/residency/index.js +1 -0
  36. package/dist-lib/lib/tools/files/edit-file.d.ts +4 -1
  37. package/dist-lib/lib/tools/files/edit-file.js +220 -28
  38. package/dist-lib/lib/tools/files/index.js +3 -1
  39. package/dist-lib/lib/tools/fs/edit-match.d.ts +22 -0
  40. package/dist-lib/lib/tools/fs/edit-match.js +337 -45
  41. package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
  42. package/dist-lib/plugins/coding-guards/index.js +126 -0
  43. package/dist-lib/plugins/image/edit-image.d.ts +3 -22
  44. package/dist-lib/plugins/image/edit-image.js +13 -32
  45. package/dist-lib/plugins/image/fit.d.ts +31 -0
  46. package/dist-lib/plugins/image/fit.js +28 -0
  47. package/dist-lib/plugins/image/generate-image.d.ts +9 -2
  48. package/dist-lib/plugins/image/generate-image.js +23 -6
  49. package/dist-lib/plugins/image/index.js +4 -1
  50. package/dist-lib/plugins/ocr/index.d.ts +1 -1
  51. package/dist-lib/plugins/ocr/index.js +3 -1
  52. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  53. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  54. package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
  55. package/dist-lib/plugins/speech/speech-engine.js +10 -5
  56. package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
  57. package/dist-lib/plugins/speech/speech-text.js +9 -4
  58. package/dist-lib/plugins/speech/voice.js +7 -2
  59. package/package.json +5 -1
@@ -1,9 +1,9 @@
1
- import b4a from 'b4a';
2
1
  import fs from 'fs';
3
2
  import path from 'path';
4
3
  import { HarnessError } from '../../lib/errors.js';
5
4
  import { AbortedError } from '../../lib/helpers/race-abort.js';
6
5
  import { DIM_STEP, diffuse, effectiveSteps, generationPercentTick, normalizeClamps, parseCommonArgs } from './generate-image.js';
6
+ import { decodeFrame, fitFrame, loadFitter } from './fit.js';
7
7
  const DEFAULT_STRENGTH = 0.7;
8
8
  const FLUX2_GUIDANCE = 3.5;
9
9
  const FLUX2_CFG_SCALE = 1;
@@ -16,7 +16,7 @@ async function turnSources(turnImages) {
16
16
  if (!bytes) {
17
17
  return { error: `could not read attached image ${path.basename(image.path)}` };
18
18
  }
19
- sources.push({ bytes, fileName: path.basename(image.path) });
19
+ sources.push({ bytes, fileName: path.basename(image.path), path: image.path });
20
20
  }
21
21
  return sources;
22
22
  }
@@ -67,24 +67,12 @@ async function resolveSources(fetchAttachment, { ids, turnImages, signal }) {
67
67
  "tool results. Call again WITHOUT ids to edit the image(s) from the user's latest message"
68
68
  };
69
69
  }
70
- async function defaultLoadMedia() {
71
- try {
72
- return await import('bare-media');
73
- }
74
- catch {
75
- return null;
76
- }
77
- }
78
- async function defaultResample(rgba, width, height) {
79
- const { resize } = await import('bare-image-resample');
80
- return resize(rgba, width, height);
81
- }
82
70
  export async function loadMediaCodecs() {
83
71
  const media = await import('bare-media');
84
72
  const codecs = media.codecs;
85
73
  await Promise.all(Object.values(codecs).map((load) => load()));
86
74
  }
87
- export function createEditImageTool(runtime, { loadMedia = defaultLoadMedia, resample = defaultResample } = {}, clamps) {
75
+ export function createEditImageTool(runtime, deps = {}, clamps) {
88
76
  const cap = normalizeClamps(clamps);
89
77
  const stepsCap = clamps?.maxSteps ? cap.maxSteps : undefined;
90
78
  const snap = (n) => Math.min(cap.maxDim, Math.max(DIM_STEP, Math.round(n / DIM_STEP) * DIM_STEP));
@@ -195,36 +183,28 @@ export function createEditImageTool(runtime, { loadMedia = defaultLoadMedia, res
195
183
  const report = ctx.progress;
196
184
  const onTick = report && generationPercentTick((percentage) => report({ percentage }), sources.length);
197
185
  try {
198
- const media = await loadMedia();
199
- if (!media) {
186
+ const fitter = await loadFitter(deps);
187
+ if (!fitter) {
200
188
  return {
201
189
  error: 'image editing needs the native media codecs, unavailable on this device'
202
190
  };
203
191
  }
204
192
  const inits = [];
205
- let width = 0;
206
- let height = 0;
193
+ const refs = [];
207
194
  for (const source of sources) {
208
- let decoded;
195
+ let frame;
209
196
  try {
210
- decoded = await media.image.decode(b4a.from(source.bytes), { maxFrames: 1 });
197
+ frame = await decodeFrame(fitter, source.bytes);
211
198
  }
212
199
  catch {
213
200
  return { error: `could not decode ${source.fileName} as an image` };
214
201
  }
215
- const frame = decoded.frames?.length ? decoded.frames[0] : decoded;
216
202
  const scale = Math.min(1, cap.maxDim / Math.max(frame.width, frame.height));
217
- const fitWidth = snap(frame.width * scale);
218
- const fitHeight = snap(frame.height * scale);
219
- const fitted = frame.width === fitWidth && frame.height === fitHeight
220
- ? frame
221
- : await resample(frame, fitWidth, fitHeight);
222
- inits.push(b4a.from(await media.image.encode(fitted, { mimetype: 'image/png' })));
223
- if (!width) {
224
- width = fitWidth;
225
- height = fitHeight;
226
- }
203
+ const size = { width: snap(frame.width * scale), height: snap(frame.height * scale) };
204
+ inits.push(await fitFrame(fitter, frame, size));
205
+ refs.push({ attachmentId: source.id, path: source.path, ...size });
227
206
  }
207
+ const { width, height } = refs[0];
228
208
  const fusion = inits.length > 1;
229
209
  const image = await diffuse(runtime, ctx, {
230
210
  modelChoice: ctx.image?.modelChoice,
@@ -244,6 +224,7 @@ export function createEditImageTool(runtime, { loadMedia = defaultLoadMedia, res
244
224
  }
245
225
  : { init_image: inits[0], strength })
246
226
  },
227
+ sources: refs,
247
228
  signal: ctx.signal,
248
229
  onTick
249
230
  });
@@ -0,0 +1,31 @@
1
+ export interface Rgba {
2
+ width: number;
3
+ height: number;
4
+ data: Uint8Array;
5
+ frames?: Rgba[];
6
+ }
7
+ export interface Media {
8
+ image: {
9
+ decode(input: Uint8Array, opts?: {
10
+ maxFrames?: number;
11
+ }): Promise<Rgba>;
12
+ encode(rgba: Rgba, opts: {
13
+ mimetype: string;
14
+ }): Promise<Uint8Array>;
15
+ };
16
+ }
17
+ export interface FitDeps {
18
+ loadMedia?: () => Promise<Media | null>;
19
+ resample?: (rgba: Rgba, width: number, height: number) => Rgba | Promise<Rgba>;
20
+ }
21
+ export interface Fitter {
22
+ readonly media: Media;
23
+ readonly resample: NonNullable<FitDeps['resample']>;
24
+ }
25
+ export interface FitSize {
26
+ readonly width: number;
27
+ readonly height: number;
28
+ }
29
+ export declare function loadFitter({ loadMedia, resample }?: FitDeps): Promise<Fitter | null>;
30
+ export declare function decodeFrame(fitter: Fitter, bytes: Uint8Array): Promise<Rgba>;
31
+ export declare function fitFrame(fitter: Fitter, frame: Rgba, size: FitSize): Promise<Uint8Array>;
@@ -0,0 +1,28 @@
1
+ import b4a from 'b4a';
2
+ async function defaultLoadMedia() {
3
+ try {
4
+ return await import('bare-media');
5
+ }
6
+ catch {
7
+ return null;
8
+ }
9
+ }
10
+ async function defaultResample(rgba, width, height) {
11
+ const { resize } = await import('bare-image-resample');
12
+ return resize(rgba, width, height);
13
+ }
14
+ export async function loadFitter({ loadMedia = defaultLoadMedia, resample = defaultResample } = {}) {
15
+ const media = await loadMedia();
16
+ return media && { media, resample };
17
+ }
18
+ export async function decodeFrame(fitter, bytes) {
19
+ const decoded = await fitter.media.image.decode(b4a.from(bytes), { maxFrames: 1 });
20
+ return decoded.frames?.length ? decoded.frames[0] : decoded;
21
+ }
22
+ export async function fitFrame(fitter, frame, size) {
23
+ const { width, height } = size;
24
+ const fitted = frame.width === width && frame.height === height
25
+ ? frame
26
+ : await fitter.resample(frame, width, height);
27
+ return b4a.from(await fitter.media.image.encode(fitted, { mimetype: 'image/png' }));
28
+ }
@@ -1,10 +1,11 @@
1
1
  import { type AbortSignal as BareAbortSignal } from 'bare-abort-controller';
2
- import type { MediaRoundServer, ToolDefinition, ToolExecuteContext } from '../../lib/contract/index.ts';
2
+ import type { MediaRoundServer, MediaSourceRef, ToolDefinition, ToolExecuteContext } from '../../lib/contract/index.ts';
3
3
  import type { ModelSrc } from '../../lib/models/context.ts';
4
4
  import { type ImageClamps, type ImageModelSet } from '../../lib/models/model-catalog.ts';
5
5
  import type { LoadRequests, ModelHost, TrackedLoad } from '../../lib/contract/models.ts';
6
6
  import type { HoldFn } from '../../lib/contract/models.ts';
7
7
  import { type ModelRegistrySdk } from '../../lib/models/model-source.ts';
8
+ import { type FitDeps } from './fit.ts';
8
9
  export declare const MAX_DIM = 1024;
9
10
  export declare const DIM_STEP = 64;
10
11
  export declare const MAX_STEPS = 100;
@@ -101,12 +102,18 @@ export declare function runDiffusion(sdk: DiffusionSdk, { modelId, params, signa
101
102
  export interface DiffuseOptions {
102
103
  readonly modelChoice?: string | undefined;
103
104
  readonly params: DiffusionParams;
105
+ readonly sources?: MediaSourceRef[] | undefined;
104
106
  readonly signal?: BareAbortSignal | undefined;
105
107
  readonly onTick?: ((tick: DiffusionTick) => void) | undefined;
106
108
  }
107
109
  export declare function diffuse(runtime: DiffusionRuntime, ctx: ToolExecuteContext, options: DiffuseOptions): Promise<Uint8Array | ImageToolError>;
108
110
  export declare function diffuseHere(runtime: DiffusionRuntime, { modelChoice, params, signal, onTick }: DiffuseOptions): Promise<Uint8Array | ImageToolError>;
109
- export declare function diffusionServer(runtime: DiffusionRuntime, isCached: ModelHost['isCached'], clamps?: ImageClamps): MediaRoundServer;
111
+ export interface DiffusionServerOptions {
112
+ readonly isCached: ModelHost['isCached'];
113
+ readonly clamps?: ImageClamps | undefined;
114
+ readonly fit?: FitDeps | undefined;
115
+ }
116
+ export declare function diffusionServer(runtime: DiffusionRuntime, { isCached, clamps, fit }: DiffusionServerOptions): MediaRoundServer;
110
117
  export interface CommonImageArgs {
111
118
  prompt: string;
112
119
  steps?: number;
@@ -5,6 +5,7 @@ import { AbortedError, raceAbort } from '../../lib/helpers/race-abort.js';
5
5
  import { DIFFUSION_CATALOG, imageModelFor } from '../../lib/models/model-catalog.js';
6
6
  import { createLoadStall } from '../../lib/helpers/load-stall.js';
7
7
  import { resolveModelSrc } from '../../lib/models/model-source.js';
8
+ import { decodeFrame, fitFrame, loadFitter } from './fit.js';
8
9
  export const MAX_DIM = 1024;
9
10
  export const DIM_STEP = 64;
10
11
  const DEFAULT_DIM = 512;
@@ -236,15 +237,17 @@ export async function diffuseHere(runtime, { modelChoice, params, signal, onTick
236
237
  runtime.release();
237
238
  }
238
239
  }
239
- async function diffuseThere(port, runId, { modelChoice, prediction, params, signal, onTick }) {
240
+ async function diffuseThere(port, runId, { modelChoice, prediction, params, sources, signal, onTick }) {
240
241
  const { init_image: image, init_images: images, ...json } = params;
241
- const sources = images ?? (image ? [image] : undefined);
242
+ const inits = images ?? (image ? [image] : undefined);
243
+ const named = sources?.every((ref) => ref.attachmentId || ref.path) ? sources : undefined;
242
244
  const asked = port({
243
245
  kind: 'image',
244
246
  runId,
245
247
  modelChoice,
246
- params: { ...json, prediction, init: images ? 'images' : sources && 'image' },
247
- images: sources
248
+ params: { ...json, prediction, init: images ? 'images' : inits && 'image' },
249
+ images: inits,
250
+ sources: named
248
251
  }, {
249
252
  signal: signal ?? new AbortController().signal,
250
253
  tick: ({ step, total }) => onTick?.({ step, totalSteps: total, elapsedMs: 0 })
@@ -255,7 +258,7 @@ async function diffuseThere(port, runId, { modelChoice, prediction, params, sign
255
258
  }
256
259
  return result.kind === 'image' ? result.bytes : { error: 'the serving device sent no image' };
257
260
  }
258
- export function diffusionServer(runtime, isCached, clamps) {
261
+ export function diffusionServer(runtime, { isCached, clamps, fit }) {
259
262
  const cap = normalizeClamps(clamps);
260
263
  return {
261
264
  serve: async (request, io) => {
@@ -265,7 +268,11 @@ export function diffusionServer(runtime, isCached, clamps) {
265
268
  planned !== runtime.predictionFor(request.modelChoice)) {
266
269
  throw new HarnessError('MEDIA_MODEL_MISSING', ['image', name]);
267
270
  }
268
- const params = diffusionParamsFrom(request);
271
+ const images = await fittedSources(request, fit);
272
+ if (!images) {
273
+ return { error: 'this device cannot read the sources', code: 'sources' };
274
+ }
275
+ const params = diffusionParamsFrom({ ...request, images });
269
276
  if (Math.max(params.width ?? 0, params.height ?? 0) > cap.maxDim) {
270
277
  return { error: `this device generates images up to ${cap.maxDim}px`, code: 'too-large' };
271
278
  }
@@ -279,6 +286,16 @@ export function diffusionServer(runtime, isCached, clamps) {
279
286
  }
280
287
  };
281
288
  }
289
+ async function fittedSources({ images = [], sources }, deps) {
290
+ if (!sources?.length) {
291
+ return images;
292
+ }
293
+ const fitter = await loadFitter(deps);
294
+ if (!fitter || images.length !== sources.length) {
295
+ return null;
296
+ }
297
+ return Promise.all(sources.map(async (size, at) => fitFrame(fitter, await decodeFrame(fitter, images[at]), size)));
298
+ }
282
299
  function diffusionParamsFrom({ params, images = [] }) {
283
300
  const number = (key) => {
284
301
  const value = params[key];
@@ -81,7 +81,10 @@ export class Image {
81
81
  return {
82
82
  tools: [createGenerateImageTool(runtime, clamps), createEditImageTool(runtime, {}, clamps)],
83
83
  services: {
84
- 'image-rounds': diffusionServer(runtime, (name, addon) => models.isCached(name, addon), clamps)
84
+ 'image-rounds': diffusionServer(runtime, {
85
+ isCached: (name, addon) => models.isCached(name, addon),
86
+ clamps
87
+ })
85
88
  },
86
89
  unload: () => runtime.unload(),
87
90
  unloadIdle: () => runtime.unloadIdle()
@@ -5,7 +5,7 @@ export declare class Ocr implements HarnessPlugin {
5
5
  readonly provides: string[];
6
6
  readonly needs: string[];
7
7
  readonly addons: {
8
- 'ocr-ggml': () => Promise<typeof import("@qvac/ocr-ggml/addonLogging")>;
8
+ 'ocr-ggml': () => Promise<(callback: (priority: number, message: string) => void) => void>;
9
9
  };
10
10
  constructor();
11
11
  setup(ctx: PluginContext): PluginSetup;
@@ -5,7 +5,9 @@ export class Ocr {
5
5
  api = PluginRegistry.API_VERSION;
6
6
  provides = ['ocr'];
7
7
  needs = ['models'];
8
- addons = { 'ocr-ggml': () => import('@qvac/ocr-ggml/addonLogging') };
8
+ addons = {
9
+ 'ocr-ggml': async () => (await import('@qvac/ocr-ggml/addonLogging')).default.setLogger
10
+ };
9
11
  constructor() {
10
12
  PluginRegistry.requirePeers('ocr', {
11
13
  '@qvac/ocr-ggml': () => import.meta.resolve('@qvac/ocr-ggml/addonLogging')
@@ -1,5 +1,5 @@
1
1
  import { categoryModelConfig, type CapabilityProfile } from '../../lib/models/model-catalog.ts';
2
- export type TtsEngine = 'supertonic' | 'moss';
2
+ export type TtsEngine = 'audio8' | 'supertonic' | 'moss';
3
3
  export interface SpeechSpeaker {
4
4
  audio: string;
5
5
  transcript: string;
@@ -1,4 +1,4 @@
1
- import { categoryModelConfig, defaultTtsFor, defaultVoiceModel, MOSS_CODEC_ENCODER_SRC, MOSS_TTS } from '../../lib/models/model-catalog.js';
1
+ import { AUDIO8_TTS, categoryModelConfig, MOSS_CODEC_ENCODER_SRC, MOSS_TTS, supertonicFor } from '../../lib/models/model-catalog.js';
2
2
  const SUPERTONIC_CONFIG = {
3
3
  ttsEngine: 'supertonic',
4
4
  language: 'en',
@@ -22,15 +22,17 @@ export function defaultTts({ tts, dialogue }, profile) {
22
22
  if (tts === 'moss') {
23
23
  return dialogue ? dialogue.backbone : MOSS_TTS.asset.src;
24
24
  }
25
- return profile ? defaultTtsFor(profile).asset.src : defaultVoiceModel('tts');
25
+ return tts === 'supertonic' ? supertonicFor(profile).asset.src : AUDIO8_TTS.asset.src;
26
26
  }
27
27
  export function isDialogue({ dialogue }, src) {
28
28
  return dialogue !== undefined && src === dialogue.backbone;
29
29
  }
30
30
  export function engineOf(options, src) {
31
- return isDialogue(options, src) || categoryModelConfig(src)?.['ttsEngine'] === 'moss'
32
- ? 'moss'
33
- : 'supertonic';
31
+ if (isDialogue(options, src)) {
32
+ return 'moss';
33
+ }
34
+ const engine = categoryModelConfig(src)?.['ttsEngine'];
35
+ return engine === 'moss' || engine === 'audio8' ? engine : 'supertonic';
34
36
  }
35
37
  export function dialogueScript({ dialogue }, text) {
36
38
  const references = (dialogue?.speakers ?? []).map((speaker, index) => `[S${index + 1}] ${speaker.transcript}`);
@@ -46,6 +48,9 @@ export function loadConfig({ voice, dialogue }, modelSrc) {
46
48
  };
47
49
  }
48
50
  const tuned = categoryModelConfig(modelSrc);
51
+ if (tuned?.['ttsEngine'] === 'audio8') {
52
+ return tuned;
53
+ }
49
54
  if (tuned?.['ttsEngine'] !== 'moss') {
50
55
  return { ...SUPERTONIC_CONFIG, ...tuned };
51
56
  }
@@ -5,3 +5,4 @@ export interface SpeechText {
5
5
  }
6
6
  export declare function normalizeForSpeech(text: string, lang?: SpeechLang): SpeechText;
7
7
  export declare function normalizeForMoss(text: string, lang?: SpeechLang): SpeechText;
8
+ export declare function normalizeForAudio8(text: string, lang?: SpeechLang): SpeechText;
@@ -2,7 +2,7 @@ import { ascii } from 'asenion';
2
2
  import { CURRENCY_CODES, SPEECH_LEXICON } from './speech-lexicon.js';
3
3
  const EMOJI_MODIFIERS = /[\uFE0E\uFE0F\u200D\u{1F3FB}-\u{1F3FF}]/gu;
4
4
  const UNSPEAKABLE = /[^\nA-Za-z0-9 .,;:!?'"()\u002D_]/gu;
5
- const MOSS_UNSPEAKABLE = /\p{Extended_Pictographic}/gu;
5
+ const PICTOGRAPHS = /\p{Extended_Pictographic}/gu;
6
6
  const MOSS_DIRECTION = /(\[(?:pause[^\]]*|S\d)\]|(?<![\w/])\/[^/\s]+\/(?![\w/]))/;
7
7
  export function normalizeForSpeech(text, lang = 'en') {
8
8
  return filterUnspeakable(toSpokenText(text, lang), UNSPEAKABLE);
@@ -10,11 +10,16 @@ export function normalizeForSpeech(text, lang = 'en') {
10
10
  export function normalizeForMoss(text, lang = 'en') {
11
11
  const parts = stripMarkup(foldWhitespace(text)).split(MOSS_DIRECTION);
12
12
  const spoken = parts.map((part, index) => index % 2 ? part : verbalize(part.normalize('NFKC').replace(EMOJI_MODIFIERS, ''), lang));
13
- return filterUnspeakable(spoken.join(''), MOSS_UNSPEAKABLE);
13
+ return filterUnspeakable(spoken.join(''), PICTOGRAPHS);
14
+ }
15
+ export function normalizeForAudio8(text, lang = 'en') {
16
+ return filterUnspeakable(verbalize(unmarked(text), lang), PICTOGRAPHS);
14
17
  }
15
18
  function toSpokenText(text, lang) {
16
- const folded = stripMarkup(foldWhitespace(text)).normalize('NFKC').replace(EMOJI_MODIFIERS, '');
17
- return ascii(verbalize(folded, lang));
19
+ return ascii(verbalize(unmarked(text), lang));
20
+ }
21
+ function unmarked(text) {
22
+ return stripMarkup(foldWhitespace(text)).normalize('NFKC').replace(EMOJI_MODIFIERS, '');
18
23
  }
19
24
  function foldWhitespace(text) {
20
25
  return text.replace(/\r\n?/g, '\n').replace(/\t/g, ' ');
@@ -3,10 +3,15 @@ import { errorMessage } from '../../lib/guards.js';
3
3
  import { AbortedError } from '../../lib/helpers/race-abort.js';
4
4
  import { HarnessError } from '../../lib/errors.js';
5
5
  import { HarnessLog } from '../../lib/log.js';
6
- import { normalizeForMoss, normalizeForSpeech } from './speech-text.js';
6
+ import { normalizeForAudio8, normalizeForMoss, normalizeForSpeech } from './speech-text.js';
7
7
  import { buildWavBuffer } from './wav-encode.js';
8
- const NATIVE_SAMPLE_RATE = { supertonic: 44100, moss: 24000 };
8
+ const NATIVE_SAMPLE_RATE = {
9
+ audio8: 44100,
10
+ supertonic: 44100,
11
+ moss: 24000
12
+ };
9
13
  const NORMALIZE = {
14
+ audio8: normalizeForAudio8,
10
15
  supertonic: normalizeForSpeech,
11
16
  moss: normalizeForMoss
12
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/harness",
3
- "version": "1.0.0-rc.19",
3
+ "version": "1.0.0-rc.20",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "bare": ">=1.33.4",
@@ -320,6 +320,10 @@
320
320
  "types": "./dist-lib/plugins/coding/index.d.ts",
321
321
  "default": "./dist-lib/plugins/coding/index.js"
322
322
  },
323
+ "./plugins/coding-guards": {
324
+ "types": "./dist-lib/plugins/coding-guards/index.d.ts",
325
+ "default": "./dist-lib/plugins/coding-guards/index.js"
326
+ },
323
327
  "./plugins/command-hooks": {
324
328
  "types": "./dist-lib/plugins/command-hooks/index.d.ts",
325
329
  "default": "./dist-lib/plugins/command-hooks/index.js"