@burdenoff/fe-libs 2026.1028.3 → 2026.1028.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.
Files changed (37) hide show
  1. package/dist/shared/assistant/appControls/grammar.d.ts +2 -0
  2. package/dist/shared/assistant/appControls/grammar.js +101 -93
  3. package/dist/shared/assistant/appControls/registry.d.ts +2 -0
  4. package/dist/shared/assistant/appControls/registry.js +20 -12
  5. package/dist/shared/assistant/commandCompletions.d.ts +9 -0
  6. package/dist/shared/assistant/commandCompletions.js +161 -0
  7. package/dist/shared/assistant/index.d.ts +3 -0
  8. package/dist/shared/assistant/localUiCommands.d.ts +16 -0
  9. package/dist/shared/assistant/localUiCommands.js +192 -105
  10. package/dist/shared/assistant/localeCommands/engine.d.ts +6 -0
  11. package/dist/shared/assistant/localeCommands/engine.js +212 -116
  12. package/dist/shared/assistant/turnTimeline.d.ts +18 -6
  13. package/dist/shared/assistant/turnTimeline.js +57 -39
  14. package/dist/shared/assistant/turnTimingReport.d.ts +10 -1
  15. package/dist/shared/assistant/turnTimingReport.js +19 -6
  16. package/dist/shared/assistant/ui/AssistantChatArea.js +1491 -1406
  17. package/dist/shared/assistant/ui/AssistantSpeechProvider.js +239 -237
  18. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +8 -0
  19. package/dist/shared/assistant/ui/composer/AssistantComposer.js +142 -131
  20. package/dist/shared/assistant/ui/draftCommandCheck.d.ts +7 -0
  21. package/dist/shared/assistant/ui/draftCommandCheck.js +17 -0
  22. package/dist/shared/assistant/ui/useVoiceSession.js +218 -202
  23. package/dist/shared/assistant/uiActions/backStack.d.ts +1 -0
  24. package/dist/shared/assistant/uiActions/backStack.js +13 -5
  25. package/dist/shared/assistant/uiActions/deixis.d.ts +2 -0
  26. package/dist/shared/assistant/uiActions/deixis.js +12 -1
  27. package/dist/shared/assistant/uiActions/draftPathname.d.ts +13 -0
  28. package/dist/shared/assistant/uiActions/draftPathname.js +31 -0
  29. package/dist/shared/assistant/uiActions/recordNames.js +33 -30
  30. package/dist/shared/assistant/voice/handsfree/handsFreeController.d.ts +3 -0
  31. package/dist/shared/assistant/voice/handsfree/handsFreeController.js +5 -1
  32. package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.d.ts +1 -0
  33. package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.js +1 -0
  34. package/dist/shared/assistant/voice/useVoiceInput.d.ts +3 -1
  35. package/dist/shared/assistant/voice/useVoiceInput.js +49 -43
  36. package/dist/shared-assistant.js +329 -326
  37. package/package.json +1 -1
@@ -0,0 +1,13 @@
1
+ /** The panel may live outside a Router; observe paths without polling. */
2
+ type PathSource = Pick<EventTarget, 'addEventListener' | 'removeEventListener'> & {
3
+ location: Pick<Location, 'pathname'>;
4
+ history?: Pick<History, 'pushState' | 'replaceState'>;
5
+ };
6
+ /**
7
+ * Only pathnames are compared. History arguments/state, query strings and
8
+ * hashes are passed through untouched and are never retained or emitted.
9
+ * Multiple panels share one observer; the last cleanup restores our wrappers
10
+ * only if another integration has not replaced them in the meantime.
11
+ */
12
+ export declare function subscribeDraftPathname(source: PathSource, listener: () => void): () => void;
13
+ export {};
@@ -0,0 +1,31 @@
1
+ //#region src/shared/assistant/uiActions/draftPathname.ts
2
+ var e = /* @__PURE__ */ new WeakMap();
3
+ function t(t, n) {
4
+ let r = e.get(t);
5
+ if (!r) {
6
+ let n = /* @__PURE__ */ new Set(), i = t.location.pathname, a = () => {
7
+ let e = t.location.pathname;
8
+ if (e !== i) {
9
+ i = e;
10
+ for (let e of [...n]) e();
11
+ }
12
+ }, o = t.history, s = o?.pushState, c = o?.replaceState, l = (e) => function(...t) {
13
+ let n = e.apply(this, t);
14
+ return queueMicrotask(a), n;
15
+ }, u = typeof s == "function" ? l(s) : void 0, d = typeof c == "function" ? l(c) : void 0;
16
+ o && u && (o.pushState = u), o && d && (o.replaceState = d), t.addEventListener("popstate", a), r = {
17
+ listeners: n,
18
+ dispose: () => {
19
+ t.removeEventListener("popstate", a), o && u && o.pushState === u && s && (o.pushState = s), o && d && o.replaceState === d && c && (o.replaceState = c);
20
+ }
21
+ }, e.set(t, r);
22
+ }
23
+ let i = r, a = () => n();
24
+ i.listeners.add(a);
25
+ let o = !0;
26
+ return () => {
27
+ o && (o = !1, i.listeners.delete(a), i.listeners.size === 0 && (i.dispose(), e.delete(t)));
28
+ };
29
+ }
30
+ //#endregion
31
+ export { t as subscribeDraftPathname };
@@ -2,55 +2,58 @@ import { canonical as e } from "../appControls/text.js";
2
2
  import { fillEntityRoute as t } from "./entityRoutes.js";
3
3
  import { ENTITY_TARGET_PREFIX as n } from "./resolveTarget.js";
4
4
  //#region src/shared/assistant/uiActions/recordNames.ts
5
- var r = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = new Set(/* @__PURE__ */ "it.that.this.there.here.back.them.those.one.link.page.screen.list.tab.section.view.all.my.the.new.first.second.third.fourth.last.next.previous.settings".split(".")), a = /(?:^| )(?:page|screen|list|tab|section|view|settings|menu)$/, o = 60, s = "(?:open|go to|take me to|pull up|bring up|navigate to|switch to|show me)", c = "(?:open|go to|take me to|pull up|bring up|navigate to)";
6
- function l(e, t) {
5
+ var r = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = new Set(/* @__PURE__ */ "it.that.this.there.here.back.them.those.one.link.page.screen.list.tab.section.view.all.my.the.new.first.second.third.fourth.last.next.previous.settings".split(".")), a = /(?:^| )(?:page|screen|list|tab|section|view|settings|menu)$/, o = 60, s = "(?:open|go to|take me to|pull up|bring up|navigate to|switch to|show me)", c = /* @__PURE__ */ RegExp("^(?:open|go to|take me to|pull up|bring up|navigate to) (?:the |my )?(.+)$");
6
+ function l(e) {
7
+ return [RegExp(`^${s} (?:the |my )?(${e}) (?:(?:called|named) )?(.+)$`), RegExp(`^${s} (?:the |my )?(.+?) (${e})$`)];
8
+ }
9
+ function u(e, t) {
7
10
  if (t.length === 0) return null;
8
- let n = (e) => t.filter((t) => t.nouns.includes(e)).map((e) => e.id), l = [...new Set(t.flatMap((e) => e.nouns))].sort((e, t) => t.length - e.length), u = (e) => {
11
+ let n = (e) => t.filter((t) => t.nouns.includes(e)).map((e) => e.id), s = [...new Set(t.flatMap((e) => e.nouns))].sort((e, t) => t.length - e.length), u = (e) => {
9
12
  let t = e.trim();
10
13
  return t.length >= 2 && t.length <= o && !i.has(t) && !a.test(t);
11
14
  };
12
- if (l.length > 0) {
13
- let t = l.map((e) => r(e)).join("|"), i = RegExp(`^${s} (?:the |my )?(${t}) (?:(?:called|named) )?(.+)$`).exec(e);
14
- if (i && u(i[2] ?? "")) {
15
- let e = n(i[1] ?? "");
15
+ if (s.length > 0) {
16
+ let [t, i] = l(s.map((e) => r(e)).join("|")), a = t.exec(e);
17
+ if (a && u(a[2] ?? "")) {
18
+ let e = n(a[1] ?? "");
16
19
  if (e.length > 0) return {
17
- name: (i[2] ?? "").trim(),
20
+ name: (a[2] ?? "").trim(),
18
21
  adapterIds: e
19
22
  };
20
23
  }
21
- let a = RegExp(`^${s} (?:the |my )?(.+?) (${t})$`).exec(e);
22
- if (a && u(a[1] ?? "")) {
23
- let e = n(a[2] ?? "");
24
+ let o = i.exec(e);
25
+ if (o && u(o[1] ?? "")) {
26
+ let e = n(o[2] ?? "");
24
27
  if (e.length > 0) return {
25
- name: (a[1] ?? "").trim(),
28
+ name: (o[1] ?? "").trim(),
26
29
  adapterIds: e
27
30
  };
28
31
  }
29
32
  }
30
- let d = RegExp(`^${c} (?:the |my )?(.+)$`).exec(e);
33
+ let d = c.exec(e);
31
34
  return d && u(d[1] ?? "") && (d[1] ?? "").length >= 3 ? {
32
35
  name: (d[1] ?? "").trim(),
33
36
  adapterIds: []
34
37
  } : null;
35
38
  }
36
- var u = 4;
37
- function d(t) {
39
+ var d = 4;
40
+ function f(t) {
38
41
  return e(t);
39
42
  }
40
- var f = d;
41
- function p(e, t) {
43
+ var p = f;
44
+ function m(e, t) {
42
45
  let n = t.split(" ");
43
46
  return e.split(" ").every((e) => n.some((t) => t.startsWith(e)));
44
47
  }
45
- function m(e, r) {
46
- let i = f(e);
48
+ function h(e, r) {
49
+ let i = p(e);
47
50
  if (!i) return { kind: "none" };
48
51
  let a = [];
49
52
  for (let e of r) for (let r of e.matches) {
50
53
  let o = t(e.route, r.params);
51
54
  if (o === null) continue;
52
- let s = f(r.name), c = s === i;
53
- !c && !p(i, s) || a.some((e) => e.destination.path === o) || a.push({
55
+ let s = p(r.name), c = s === i;
56
+ !c && !m(i, s) || a.some((e) => e.destination.path === o) || a.push({
54
57
  adapterId: e.adapter.id,
55
58
  noun: e.noun,
56
59
  exact: c,
@@ -76,23 +79,23 @@ function m(e, r) {
76
79
  nouns: [...new Set(l.map((e) => e.noun))]
77
80
  };
78
81
  }
79
- var h = 2500, g = 50, _ = 200;
80
- function v(e) {
82
+ var g = 2500, _ = 50, v = 200;
83
+ function y(e) {
81
84
  if (typeof e != "object" || !e) return !1;
82
85
  let { name: t, params: n } = e;
83
86
  if (typeof t != "string") return !1;
84
87
  let r = t.trim();
85
- if (r.length === 0 || r.length > _ || typeof n != "object" || !n || Array.isArray(n)) return !1;
88
+ if (r.length === 0 || r.length > v || typeof n != "object" || !n || Array.isArray(n)) return !1;
86
89
  let i = Object.values(n);
87
90
  return i.length > 0 && i.every((e) => typeof e == "string");
88
91
  }
89
- function y(e) {
92
+ function b(e) {
90
93
  if (!Array.isArray(e)) return [];
91
94
  let t = [];
92
- for (let n of e) if (v(n) && t.push(n), t.length >= 50) break;
95
+ for (let n of e) if (y(n) && t.push(n), t.length >= 50) break;
93
96
  return t;
94
97
  }
95
- async function b(e) {
98
+ async function x(e) {
96
99
  let t = new AbortController(), n, r = new Promise((r) => {
97
100
  n = setTimeout(() => {
98
101
  t.abort(), r(null);
@@ -116,10 +119,10 @@ async function b(e) {
116
119
  adapter: n,
117
120
  route: i,
118
121
  noun: s,
119
- matches: y(o)
122
+ matches: b(o)
120
123
  };
121
124
  }));
122
- return m(e.name, n);
125
+ return h(e.name, n);
123
126
  } catch {
124
127
  return { kind: "none" };
125
128
  } finally {
@@ -127,4 +130,4 @@ async function b(e) {
127
130
  }
128
131
  }
129
132
  //#endregion
130
- export { u as RECORD_CHOICE_MAX, h as RECORD_LOOKUP_TIMEOUT_MS, g as RECORD_MATCHES_MAX, v as isRecordMatch, b as lookupNamedRecords, d as normaliseRecordName, l as parseRecordRequest, m as planRecordResolution, y as sanitizeRecordMatches };
133
+ export { d as RECORD_CHOICE_MAX, g as RECORD_LOOKUP_TIMEOUT_MS, _ as RECORD_MATCHES_MAX, y as isRecordMatch, x as lookupNamedRecords, f as normaliseRecordName, u as parseRecordRequest, h as planRecordResolution, b as sanitizeRecordMatches };
@@ -33,6 +33,9 @@ export interface ControllerDeps {
33
33
  onFallback: (reason: FallbackReason) => void;
34
34
  /** A barge-in that produced no words within `NOTHING_HEARD_MS`. */
35
35
  onNothingHeard?: () => void;
36
+ /** Timing only: end of the latest echo-approved voiced capture frame. */
37
+ onSpeechFrame?: (at: number) => void;
38
+ now?: () => number;
36
39
  isEnabled: () => boolean;
37
40
  prerollMs?: number;
38
41
  setTimer?: (fn: () => void, ms: number) => ReturnType<typeof setTimeout>;
@@ -66,7 +66,11 @@ function u(u) {
66
66
  rmsDb: e.rmsDb,
67
67
  zcr: e.zcr
68
68
  }, t.pass);
69
- r.event === "onset" ? M(t.reason) : b && r.inSegment && u.transport.pushFrame(n), r.event === "end" && j();
69
+ if (r.event === "onset" && M(t.reason), b && r.voiced && t.pass) {
70
+ let t = u.now?.() ?? performance.now(), n = _?.context ? Math.max(0, (_.context.currentTime - e.ctxTime) * 1e3) : 0;
71
+ u.onSpeechFrame?.(t - n);
72
+ }
73
+ r.event !== "onset" && b && r.inSegment && u.transport.pushFrame(n), r.event === "end" && j();
70
74
  }, P = () => {
71
75
  if (!v && !_) return;
72
76
  v = !1, k(), b && u.transport.cancelUtterance(b.id), b = null, g.invalidate(), u.transport.stop(), h.clear(), p.reset(), m.reset();
@@ -24,6 +24,7 @@ export interface UseHandsFreeInterruptOptions {
24
24
  language: string;
25
25
  /** The user's voice started while the assistant was audible. */
26
26
  onBargeIn: () => void;
27
+ onSpeechFrame?: (at: number) => void;
27
28
  onTranscript: (text: string, final: boolean, language: string | undefined) => void;
28
29
  /**
29
30
  * The backend stream's privacy-notice version this person accepted (it is
@@ -57,6 +57,7 @@ function b(s) {
57
57
  onTranscript: (e, t, n) => {
58
58
  D(!1), C.current.onTranscript(e, t, n);
59
59
  },
60
+ onSpeechFrame: (e) => C.current.onSpeechFrame?.(e),
60
61
  onFallback: T,
61
62
  onNothingHeard: () => D(!0),
62
63
  isEnabled: () => C.current.enabled
@@ -94,6 +94,8 @@ export interface UseVoiceInputOptions {
94
94
  * here) means the user can freely edit while dictation continues.
95
95
  */
96
96
  onFinalize: (text: string) => void;
97
+ /** Browser endpoint notification time; not an acoustic timestamp. */
98
+ onSpeechEnd?: (at: number) => void;
97
99
  /**
98
100
  * BCP-47 tag to listen for. Omit to follow the app locale, which is what this
99
101
  * hook did unconditionally before (BOFF-7108).
@@ -137,4 +139,4 @@ export interface UseVoiceInputResult {
137
139
  toggle: () => void;
138
140
  clearError: () => void;
139
141
  }
140
- export declare function useVoiceInput({ onFinalize, language: requested, }: UseVoiceInputOptions): UseVoiceInputResult;
142
+ export declare function useVoiceInput({ onFinalize, onSpeechEnd, language: requested, }: UseVoiceInputOptions): UseVoiceInputResult;
@@ -35,72 +35,78 @@ function d(e) {
35
35
  default: return "unknown";
36
36
  }
37
37
  }
38
- function f({ onFinalize: s, language: c }) {
39
- let { locale: f } = e(), [p, m] = i(!1), [h, g] = i(!1), [_, v] = i(""), [y, b] = i(null), x = r(null), S = r(0), C = r(-Infinity), w = r(0), T = r(s);
38
+ function f({ onFinalize: s, onSpeechEnd: c, language: f }) {
39
+ let { locale: p } = e(), [m, h] = i(!1), [g, _] = i(!1), [v, y] = i(""), [b, x] = i(null), S = r(null), C = r(0), w = r(-Infinity), T = r(0), E = r(c);
40
40
  n(() => {
41
- T.current = s;
41
+ E.current = c;
42
+ }, [c]);
43
+ let D = r(s);
44
+ n(() => {
45
+ D.current = s;
42
46
  }, [s]);
43
- let E = o() !== null, D = c ?? a[f] ?? "en-US";
47
+ let O = o() !== null, k = f ?? a[p] ?? "en-US";
44
48
  n(() => () => {
45
- x.current?.abort(), x.current = null;
49
+ S.current?.abort(), S.current = null;
46
50
  }, []);
47
- let O = t((e = "manual") => {
51
+ let A = t((e = "manual") => {
48
52
  let t = o();
49
- if (!t || x.current || e === "auto" && u(C.current, performance.now())) return;
53
+ if (!t || S.current || e === "auto" && u(w.current, performance.now())) return;
50
54
  let n = new t();
51
- n.continuous = !0, n.interimResults = !0, n.lang = D;
52
- let r = S.current;
53
- n.onresult = (e) => {
54
- if (r !== S.current) return;
55
+ n.continuous = !0, n.interimResults = !0, n.lang = k;
56
+ let r = C.current;
57
+ n.onspeechend = () => {
58
+ r === C.current && E.current?.(performance.now());
59
+ }, n.onresult = (e) => {
60
+ if (r !== C.current) return;
55
61
  let t = "", n = "";
56
62
  for (let r = e.resultIndex; r < e.results.length; r += 1) {
57
63
  let i = e.results[r], a = i[0]?.transcript ?? "";
58
64
  i.isFinal ? t += a : n += a;
59
65
  }
60
- t.trim() && T.current(t.trim()), v(n.trim());
66
+ t.trim() && D.current(t.trim()), y(n.trim());
61
67
  }, n.onerror = (e) => {
62
- if (r !== S.current) return;
68
+ if (r !== C.current) return;
63
69
  let t = d(e.error);
64
- t !== "no-speech" && b(t);
70
+ t !== "no-speech" && x(t);
65
71
  }, n.onend = () => {
66
- r === S.current && (x.current = null, g(!1), m(!1), v(""));
72
+ r === C.current && (S.current = null, _(!1), h(!1), y(""));
67
73
  }, n.onstart = () => {
68
- r === S.current && (g(!1), m(!0));
69
- }, g(!0);
74
+ r === C.current && (_(!1), h(!0));
75
+ }, _(!0);
70
76
  try {
71
77
  n.start();
72
78
  } catch {
73
- C.current = performance.now(), w.current += 1, w.current >= l && b("unknown"), x.current = null, g(!1), m(!1);
79
+ w.current = performance.now(), T.current += 1, T.current >= l && x("unknown"), S.current = null, _(!1), h(!1);
74
80
  return;
75
81
  }
76
- x.current = n, w.current = 0, b(null), v("");
77
- }, [D]), k = t(() => {
78
- let e = x.current;
79
- x.current = null, S.current += 1, e?.stop(), g(!1), m(!1), v("");
80
- }, []), A = r(D);
82
+ S.current = n, T.current = 0, x(null), y("");
83
+ }, [k]), j = t(() => {
84
+ let e = S.current;
85
+ S.current = null, C.current += 1, e?.stop(), _(!1), h(!1), y("");
86
+ }, []), M = r(k);
81
87
  n(() => {
82
- A.current !== D && (A.current = D, k(), b(null));
83
- }, [D, k]);
84
- let j = t(() => {
85
- p || h ? k() : O();
88
+ M.current !== k && (M.current = k, j(), x(null));
89
+ }, [k, j]);
90
+ let N = t(() => {
91
+ m || g ? j() : A();
86
92
  }, [
87
- p,
88
- h,
89
- O,
90
- k
91
- ]), M = t(() => b(null), []);
93
+ m,
94
+ g,
95
+ A,
96
+ j
97
+ ]), P = t(() => x(null), []);
92
98
  return {
93
- isSupported: E,
94
- isListening: p,
95
- isStarting: h,
96
- isActive: p || h,
97
- interim: _,
98
- error: y,
99
- language: D,
100
- start: O,
101
- stop: k,
102
- toggle: j,
103
- clearError: M
99
+ isSupported: O,
100
+ isListening: m,
101
+ isStarting: g,
102
+ isActive: m || g,
103
+ interim: v,
104
+ error: b,
105
+ language: k,
106
+ start: A,
107
+ stop: j,
108
+ toggle: N,
109
+ clearError: P
104
110
  };
105
111
  }
106
112
  //#endregion