@burdenoff/fe-libs 2026.1009.1 → 2026.1010.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/assistant/appControls/copy.js +1 -0
- package/dist/shared/assistant/appControls/grammar.d.ts +2 -0
- package/dist/shared/assistant/appControls/grammar.js +43 -41
- package/dist/shared/assistant/appControls/languages.d.ts +2 -0
- package/dist/shared/assistant/appControls/languages.js +8 -5
- package/dist/shared/assistant/appControls/plan.d.ts +4 -0
- package/dist/shared/assistant/appControls/plan.js +135 -118
- package/dist/shared/assistant/appControls/types.d.ts +23 -1
- package/dist/shared/assistant/i18nManifest.d.ts +1 -0
- package/dist/shared/assistant/i18nManifest.js +1 -0
- package/dist/shared/assistant/index.d.ts +18 -0
- package/dist/shared/assistant/localUiCommands.d.ts +33 -0
- package/dist/shared/assistant/localUiCommands.js +159 -88
- package/dist/shared/assistant/localeCommands/active.d.ts +19 -0
- package/dist/shared/assistant/localeCommands/active.js +25 -0
- package/dist/shared/assistant/localeCommands/assent.d.ts +25 -0
- package/dist/shared/assistant/localeCommands/assent.js +78 -0
- package/dist/shared/assistant/localeCommands/engine.d.ts +89 -0
- package/dist/shared/assistant/localeCommands/engine.js +351 -0
- package/dist/shared/assistant/localeCommands/evaluate.d.ts +77 -0
- package/dist/shared/assistant/localeCommands/evaluate.js +180 -0
- package/dist/shared/assistant/localeCommands/fold.d.ts +17 -0
- package/dist/shared/assistant/localeCommands/fold.js +66 -0
- package/dist/shared/assistant/localeCommands/frames.d.ts +23 -0
- package/dist/shared/assistant/localeCommands/frames.js +150 -0
- package/dist/shared/assistant/localeCommands/gate.d.ts +37 -0
- package/dist/shared/assistant/localeCommands/gate.js +137 -0
- package/dist/shared/assistant/localeCommands/languageNames.d.ts +11 -0
- package/dist/shared/assistant/localeCommands/languageNames.js +53 -0
- package/dist/shared/assistant/localeCommands/nameForms.d.ts +21 -0
- package/dist/shared/assistant/localeCommands/nameForms.js +44 -0
- package/dist/shared/assistant/localeCommands/normalise.d.ts +49 -0
- package/dist/shared/assistant/localeCommands/normalise.js +87 -0
- package/dist/shared/assistant/localeCommands/symbols.d.ts +8 -0
- package/dist/shared/assistant/localeCommands/symbols.js +6 -0
- package/dist/shared/assistant/localeCommands/tables/ar.d.ts +10 -0
- package/dist/shared/assistant/localeCommands/tables/ar.js +343 -0
- package/dist/shared/assistant/localeCommands/tables/en.d.ts +12 -0
- package/dist/shared/assistant/localeCommands/tables/en.js +28 -0
- package/dist/shared/assistant/localeCommands/tables/es.d.ts +7 -0
- package/dist/shared/assistant/localeCommands/tables/es.js +356 -0
- package/dist/shared/assistant/localeCommands/tables/hi.d.ts +9 -0
- package/dist/shared/assistant/localeCommands/tables/hi.js +495 -0
- package/dist/shared/assistant/localeCommands/tables/ta.d.ts +10 -0
- package/dist/shared/assistant/localeCommands/tables/ta.js +429 -0
- package/dist/shared/assistant/localeCommands/tables/zh.d.ts +9 -0
- package/dist/shared/assistant/localeCommands/tables/zh.js +402 -0
- package/dist/shared/assistant/localeCommands/types.d.ts +172 -0
- package/dist/shared/assistant/localeCommands/types.js +19 -0
- package/dist/shared/assistant/ui/AIAssistantPanel.js +5 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +1340 -1330
- package/dist/shared/assistant/uiActions/linkContext.d.ts +20 -1
- package/dist/shared/assistant/uiActions/linkContext.js +39 -21
- package/dist/shared/assistant/uiActions/offerYesOnSurface.d.ts +6 -0
- package/dist/shared/assistant/uiActions/offerYesOnSurface.js +1 -1
- package/dist/shared/assistant/writeReplyBinder.d.ts +1 -1
- package/dist/shared/assistant/writeReplySend.d.ts +16 -0
- package/dist/shared/assistant/writeReplySend.js +23 -1
- package/dist/shared-assistant.js +55 -37
- package/package.json +1 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { effectiveManifest as e, isEnabled as t } from "./gate.js";
|
|
2
|
+
import { foldText as n, foldWords as r } from "./fold.js";
|
|
3
|
+
import { closedSlot as i, compileFrame as a, matchFrame as o } from "./frames.js";
|
|
4
|
+
import { buildPrep as s, isQuestionText as c, normaliseSaid as l } from "./normalise.js";
|
|
5
|
+
import { languageNameMap as u } from "./languageNames.js";
|
|
6
|
+
import { LOCALE_TABLES as d, activeCommandLocales as f } from "./active.js";
|
|
7
|
+
import { ENGLISH_COMMAND_ADDITIONS as p } from "./tables/en.js";
|
|
8
|
+
//#region src/shared/assistant/localeCommands/engine.ts
|
|
9
|
+
var m = {
|
|
10
|
+
maxLength: 80,
|
|
11
|
+
courtesy: {
|
|
12
|
+
prefix: [
|
|
13
|
+
"please",
|
|
14
|
+
"pls",
|
|
15
|
+
"kindly",
|
|
16
|
+
"hey",
|
|
17
|
+
"hi"
|
|
18
|
+
],
|
|
19
|
+
suffix: [
|
|
20
|
+
"please",
|
|
21
|
+
"pls",
|
|
22
|
+
"thanks",
|
|
23
|
+
"thank you",
|
|
24
|
+
"now"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
fillers: [
|
|
28
|
+
"um",
|
|
29
|
+
"uh",
|
|
30
|
+
"erm",
|
|
31
|
+
"er",
|
|
32
|
+
"hmm"
|
|
33
|
+
],
|
|
34
|
+
compound: []
|
|
35
|
+
};
|
|
36
|
+
function h(e, t, n) {
|
|
37
|
+
let r = { p: i([[e.places, "place"]], n) };
|
|
38
|
+
if (t) {
|
|
39
|
+
let { pick: e, controls: a } = t;
|
|
40
|
+
r.o = i([...e.ordinals.map((e, t) => [e, t + 1]), [e.last, "last"]], n), r.n = i(e.numbers.map((e, t) => [e, t + 1]), n), r.d = i([[a.directions.asc, "asc"], [a.directions.desc, "desc"]], n);
|
|
41
|
+
}
|
|
42
|
+
return r;
|
|
43
|
+
}
|
|
44
|
+
var g = /* @__PURE__ */ new Map();
|
|
45
|
+
function _(e, t, r, i, o, c) {
|
|
46
|
+
let l = g.get(c);
|
|
47
|
+
if (l) return l;
|
|
48
|
+
let u = h(t, e, o), d = (e) => e.map((e) => a(e, o, u)), f = (e) => e.map((e) => ({
|
|
49
|
+
frame: a(e.template, o, u),
|
|
50
|
+
weak: e.weak === !0
|
|
51
|
+
})), p = () => [], m = e?.controls, _ = {
|
|
52
|
+
fold: o,
|
|
53
|
+
zh: o === "zh",
|
|
54
|
+
prep: s(i, o),
|
|
55
|
+
closed: u,
|
|
56
|
+
goto: {
|
|
57
|
+
go: d(t.go),
|
|
58
|
+
open: d(t.open),
|
|
59
|
+
show: d(t.show)
|
|
60
|
+
},
|
|
61
|
+
ambiguous: new Set(t.ambiguous.map((e) => b(n(e, o), o))),
|
|
62
|
+
there: d(e?.there ?? []),
|
|
63
|
+
back: d(e?.back ?? []),
|
|
64
|
+
pick: d(e?.pick.frames ?? []),
|
|
65
|
+
language: d(r),
|
|
66
|
+
theme: (e?.theme ?? []).map((e) => ({
|
|
67
|
+
frame: a(e.template, o, u),
|
|
68
|
+
family: e.family,
|
|
69
|
+
invert: e.invert === !0,
|
|
70
|
+
saysTheme: e.saysTheme === !0
|
|
71
|
+
})),
|
|
72
|
+
controls: {
|
|
73
|
+
phrases: {
|
|
74
|
+
history: m ? f(m.history) : p(),
|
|
75
|
+
transcript: m ? f(m.transcript) : p(),
|
|
76
|
+
previewOpen: m ? f(m.previewOpen) : p(),
|
|
77
|
+
previewClose: m ? f(m.previewClose) : p(),
|
|
78
|
+
newConversation: m ? f(m.newConversation) : p(),
|
|
79
|
+
notifications: m ? f(m.notifications) : p(),
|
|
80
|
+
help: m ? f(m.help) : p(),
|
|
81
|
+
sidebarCollapse: m ? f(m.sidebarCollapse) : p(),
|
|
82
|
+
sidebarExpand: m ? f(m.sidebarExpand) : p()
|
|
83
|
+
},
|
|
84
|
+
tab: d(m?.tab ?? []),
|
|
85
|
+
filter: d(m?.filter ?? []),
|
|
86
|
+
filterClear: d(m?.filterClear ?? []),
|
|
87
|
+
sort: d(m?.sort ?? []),
|
|
88
|
+
sortDirection: d(m?.sortDirection ?? []),
|
|
89
|
+
search: d(m?.search ?? []),
|
|
90
|
+
searchVerbOnly: d((m?.search ?? []).map((e) => e.replace(/\s*\{q\}\s*/g, "")).filter((e) => e.length > 0)),
|
|
91
|
+
searchClear: d(m?.searchClear ?? [])
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return g.set(c, _), _;
|
|
95
|
+
}
|
|
96
|
+
function v(e) {
|
|
97
|
+
return _(e, e.goto, e.language, e, e.locale, `native:${e.locale}`);
|
|
98
|
+
}
|
|
99
|
+
function y(e) {
|
|
100
|
+
let t = e?.locale ?? "en", n = e ?? m;
|
|
101
|
+
return _(null, p.goto, p.language, {
|
|
102
|
+
...n,
|
|
103
|
+
polite: void 0
|
|
104
|
+
}, t, `english:${t}`);
|
|
105
|
+
}
|
|
106
|
+
function b(e, t) {
|
|
107
|
+
return t === "es" ? e.replace(/^(?:el|la|los|las|un|una|unos|unas) (?=\S)/, "") : t === "ar" ? e.replace(/^(?:لل|ال)(?=\S{2})/, "") : e;
|
|
108
|
+
}
|
|
109
|
+
function x(e, t, r) {
|
|
110
|
+
let i = /* @__PURE__ */ new Map(), a = (e, r) => {
|
|
111
|
+
let a = b(n(e, t), t);
|
|
112
|
+
if (!a) return;
|
|
113
|
+
let o = i.get(a) ?? [];
|
|
114
|
+
o.some((e) => e.path === r.path) || o.push(r), i.set(a, o);
|
|
115
|
+
};
|
|
116
|
+
for (let t of e) {
|
|
117
|
+
a(t.label, t), t.context && a(`${t.context} ${t.label}`, t);
|
|
118
|
+
for (let e of r?.(t.label) ?? []) a(e, t);
|
|
119
|
+
}
|
|
120
|
+
return i;
|
|
121
|
+
}
|
|
122
|
+
function S(e, t, r) {
|
|
123
|
+
let i = b(e, r), a = t.filter((e) => b(n(e.label, r), r) === i);
|
|
124
|
+
return a.length === 1 ? a[0] ?? null : null;
|
|
125
|
+
}
|
|
126
|
+
function C(e, t) {
|
|
127
|
+
let n = b(e, t.fold);
|
|
128
|
+
if (t.zh) return [...t.ambiguous].some((e) => n.endsWith(e));
|
|
129
|
+
let r = n.split(" "), i = r[r.length - 1] ?? "", a = r.slice(-2).join(" ");
|
|
130
|
+
return t.ambiguous.has(i) || t.ambiguous.has(a);
|
|
131
|
+
}
|
|
132
|
+
function w(e, t, r) {
|
|
133
|
+
let i = /* @__PURE__ */ new Map(), a = "";
|
|
134
|
+
for (let s of [
|
|
135
|
+
"go",
|
|
136
|
+
"open",
|
|
137
|
+
"show"
|
|
138
|
+
]) for (let c of e.goto[s]) for (let l of o(c, t)) {
|
|
139
|
+
let t = l.x;
|
|
140
|
+
if (!t) continue;
|
|
141
|
+
let o = r.get(b(t, e.fold));
|
|
142
|
+
if (o && !(s === "open" && l.p === void 0 && (C(t, e) || o.some((t) => C(n(t.label, e.fold), e))))) {
|
|
143
|
+
for (let e of o) i.set(e.path, e);
|
|
144
|
+
a = t;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return i.size === 0 ? null : {
|
|
148
|
+
destinations: [...i.values()],
|
|
149
|
+
query: a
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function T(e, t, n) {
|
|
153
|
+
for (let r of e.theme) if (!(n === "mode-only" && r.saysTheme) && o(r.frame, t).length !== 0) return {
|
|
154
|
+
kind: "family",
|
|
155
|
+
family: r.invert ? r.family === "dark" ? "light" : "dark" : r.family
|
|
156
|
+
};
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
function E(e, t) {
|
|
160
|
+
let n = [];
|
|
161
|
+
for (let r of e.pick) for (let i of o(r, t)) {
|
|
162
|
+
let t = i.o ?? i.n, r = i.o === void 0 ? "n" : "o", a = t === void 0 ? void 0 : e.closed[r]?.get(t);
|
|
163
|
+
a === "last" ? n.push({ kind: "last" }) : typeof a == "number" && n.push({
|
|
164
|
+
kind: "ordinal",
|
|
165
|
+
position: a
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
let [r] = n;
|
|
169
|
+
return r && n.every((e) => JSON.stringify(e) === JSON.stringify(r)) ? r : null;
|
|
170
|
+
}
|
|
171
|
+
var D = (e, t) => e.some((e) => o(e, t).length > 0);
|
|
172
|
+
function O(e, t) {
|
|
173
|
+
let n = e.filter((e) => o(e.frame, t).length > 0);
|
|
174
|
+
return n.length === 0 ? null : { weak: n.every((e) => e.weak) };
|
|
175
|
+
}
|
|
176
|
+
var k = 60, A = 4;
|
|
177
|
+
function j(e, t, n) {
|
|
178
|
+
if (n.zh) return t;
|
|
179
|
+
let i = r(e, n.fold), a = i.flatMap((e, t) => e.folded.map((e) => ({
|
|
180
|
+
token: e,
|
|
181
|
+
owner: t
|
|
182
|
+
}))), o = t.split(" ");
|
|
183
|
+
for (let e = a.length - o.length; e >= 0; --e) {
|
|
184
|
+
if (!o.every((t, n) => a[e + n]?.token === t)) continue;
|
|
185
|
+
let t = a[e]?.owner, n = a[e + o.length - 1]?.owner;
|
|
186
|
+
if (t === void 0 || n === void 0 || a.filter((e) => e.owner >= t && e.owner <= n).length !== o.length) break;
|
|
187
|
+
return i.slice(t, n + 1).map((e) => e.said).join(" ");
|
|
188
|
+
}
|
|
189
|
+
return t;
|
|
190
|
+
}
|
|
191
|
+
function M(e, t) {
|
|
192
|
+
let n = t === void 0 ? void 0 : e.closed.d?.get(t);
|
|
193
|
+
return n === "asc" || n === "desc" ? n : null;
|
|
194
|
+
}
|
|
195
|
+
function N(e, t, r, i, a, s) {
|
|
196
|
+
let { registered: c } = i;
|
|
197
|
+
if (e.prep.compound.some((n) => e.zh ? t.includes(n) : ` ${t} `.includes(` ${n} `))) return null;
|
|
198
|
+
let l = [], u = (e, t) => l.push({
|
|
199
|
+
request: e,
|
|
200
|
+
weak: t
|
|
201
|
+
}), { phrases: d } = e.controls, f = (e, n, r) => {
|
|
202
|
+
if (!n) return;
|
|
203
|
+
let i = O(d[e], t);
|
|
204
|
+
i && u(r, i.weak);
|
|
205
|
+
};
|
|
206
|
+
if (f("notifications", c["header.notifications"], { control: "header.notifications" }), f("help", c["header.help"], { control: "header.help" }), f("sidebarCollapse", c.sidebar, {
|
|
207
|
+
control: "sidebar",
|
|
208
|
+
collapsed: !0
|
|
209
|
+
}), f("sidebarExpand", c.sidebar, {
|
|
210
|
+
control: "sidebar",
|
|
211
|
+
collapsed: !1
|
|
212
|
+
}), f("history", c["assistant.history"], { control: "assistant.history" }), f("transcript", c["assistant.transcript"], { control: "assistant.transcript" }), f("previewOpen", c["assistant.preview"], { control: "assistant.preview" }), f("previewClose", c["assistant.preview"], { control: "assistant.preview.close" }), f("newConversation", c["assistant.conversation.new"], { control: "assistant.conversation.new" }), c.language && e.language.length > 0) {
|
|
213
|
+
let r = new Set(a.map((t) => b(n(t.label, e.fold), e.fold)));
|
|
214
|
+
for (let n of e.language) for (let i of o(n, t)) {
|
|
215
|
+
let t = i.lang, n = t === void 0 ? void 0 : s.get(t);
|
|
216
|
+
n && t !== void 0 && !r.has(b(t, e.fold)) && u({
|
|
217
|
+
control: "language",
|
|
218
|
+
code: n
|
|
219
|
+
}, !1);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
let p = i.page;
|
|
223
|
+
if (p) {
|
|
224
|
+
if (p.tabs.length > 0) for (let n of e.controls.tab) for (let r of o(n, t)) {
|
|
225
|
+
let t = r.x ? S(r.x, p.tabs, e.fold) : null;
|
|
226
|
+
t && u({
|
|
227
|
+
control: "page.tab",
|
|
228
|
+
name: t.label
|
|
229
|
+
}, !1);
|
|
230
|
+
}
|
|
231
|
+
if (p.filters.length > 0) {
|
|
232
|
+
D(e.controls.filterClear, t) && u({
|
|
233
|
+
control: "page.filter.clear",
|
|
234
|
+
filter: null
|
|
235
|
+
}, !1);
|
|
236
|
+
for (let n of e.controls.filter) for (let r of o(n, t)) {
|
|
237
|
+
if (!r.x) continue;
|
|
238
|
+
let t = p.filters.filter((t) => S(r.x, t.options, e.fold) !== null), [n] = t;
|
|
239
|
+
if (!n) continue;
|
|
240
|
+
let i = S(r.x, n.options, e.fold);
|
|
241
|
+
i && u({
|
|
242
|
+
control: "page.filter",
|
|
243
|
+
filter: t.length === 1 ? n.label : null,
|
|
244
|
+
option: i.label
|
|
245
|
+
}, !1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (p.sorts.length > 0) {
|
|
249
|
+
for (let n of e.controls.sort) for (let r of o(n, t)) {
|
|
250
|
+
let t = r.x ? S(r.x, p.sorts, e.fold) : null;
|
|
251
|
+
t && u({
|
|
252
|
+
control: "page.sort",
|
|
253
|
+
field: t.label,
|
|
254
|
+
direction: M(e, r.d)
|
|
255
|
+
}, !1);
|
|
256
|
+
}
|
|
257
|
+
for (let n of e.controls.sortDirection) for (let r of o(n, t)) {
|
|
258
|
+
let t = M(e, r.d);
|
|
259
|
+
t && u({
|
|
260
|
+
control: "page.sort",
|
|
261
|
+
field: null,
|
|
262
|
+
direction: t
|
|
263
|
+
}, !1);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (p.searchable) {
|
|
267
|
+
D(e.controls.searchClear, t) && u({ control: "page.search.clear" }, !1);
|
|
268
|
+
let n = null, i = D(e.controls.searchVerbOnly, t);
|
|
269
|
+
for (let r of i ? [] : e.controls.search) for (let i of o(r, t)) {
|
|
270
|
+
let t = i.q?.trim() ?? "", r = e.zh ? 0 : t.split(" ").length;
|
|
271
|
+
!t || t.length > k || r > A || (n === null || t.length < n.length) && (n = t);
|
|
272
|
+
}
|
|
273
|
+
n !== null && u({
|
|
274
|
+
control: "page.search",
|
|
275
|
+
query: j(r, n, e)
|
|
276
|
+
}, !1);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
let m = l.filter((e) => !e.weak), h = m.length > 0 ? m : l, [g] = h;
|
|
280
|
+
return g && h.every((e) => JSON.stringify(e) === JSON.stringify(g)) ? g : null;
|
|
281
|
+
}
|
|
282
|
+
function P(e, t, n, r, i, a, o) {
|
|
283
|
+
let s = {};
|
|
284
|
+
if (i.enabled("theme")) {
|
|
285
|
+
let n = T(e, r, t.themeWords);
|
|
286
|
+
n && (s.theme = n);
|
|
287
|
+
}
|
|
288
|
+
if (i.enabled("back") && t.backRunnable && D(e.back, r) && (s.back = !0), i.enabled("pick") && t.navigation) {
|
|
289
|
+
let t = E(e, r);
|
|
290
|
+
t && (s.pick = t);
|
|
291
|
+
}
|
|
292
|
+
if (i.enabled("there") && t.navigation && D(e.there, r) && (s.there = !0), i.enabled("goto")) {
|
|
293
|
+
let t = w(e, r, o);
|
|
294
|
+
t && (s.goto = t);
|
|
295
|
+
}
|
|
296
|
+
if (t.controls && (i.enabled("controls") || i.enabled("language"))) {
|
|
297
|
+
let o = N(e, r, n, t.controls, t.destinations, a);
|
|
298
|
+
o && (o.request.control === "language" ? i.enabled("language") : i.enabled("controls")) && (s.control = o);
|
|
299
|
+
}
|
|
300
|
+
return s;
|
|
301
|
+
}
|
|
302
|
+
function F(n) {
|
|
303
|
+
let r = e(n.manifest), i = f({
|
|
304
|
+
ui: n.uiLocale,
|
|
305
|
+
input: n.inputLocale,
|
|
306
|
+
narrow: n.commandLocales,
|
|
307
|
+
manifest: r
|
|
308
|
+
}), a = i.length > 0 && t(r, "en", "goto"), o = t(r, "en", "language");
|
|
309
|
+
if (i.length === 0 && !o) return [];
|
|
310
|
+
let s = c(n.said), p = i.map((e) => d[e]), m = n.controls?.languages ?? [], h = [], g = (e) => u({
|
|
311
|
+
tables: p,
|
|
312
|
+
appLanguages: m,
|
|
313
|
+
fold: e
|
|
314
|
+
});
|
|
315
|
+
for (let e of p) {
|
|
316
|
+
let i = v(e), a = l(n.said, i.prep, s);
|
|
317
|
+
if (a === null) continue;
|
|
318
|
+
let o = P(i, n, n.said, a, { enabled: (n) => t(r, e.locale, n) }, g(e.locale), x(n.destinations, e.locale, e.nameForms));
|
|
319
|
+
Object.keys(o).length > 0 && h.push({
|
|
320
|
+
source: e.locale,
|
|
321
|
+
intents: o
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (!s && (a || o)) {
|
|
325
|
+
let e = i.length > 0 ? p : [null];
|
|
326
|
+
for (let t of e) {
|
|
327
|
+
let e = y(t), r = l(n.said, e.prep, !1);
|
|
328
|
+
if (r === null) continue;
|
|
329
|
+
let i = P(e, n, n.said, r, { enabled: (e) => e === "goto" ? a : e === "language" ? o : !1 }, g(e.fold), x(n.destinations, e.fold));
|
|
330
|
+
Object.keys(i).length > 0 && h.push({
|
|
331
|
+
source: "en",
|
|
332
|
+
intents: i
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return h;
|
|
337
|
+
}
|
|
338
|
+
function I(n) {
|
|
339
|
+
let r = e(n.manifest), i = f({
|
|
340
|
+
ui: n.uiLocale,
|
|
341
|
+
input: n.inputLocale,
|
|
342
|
+
narrow: n.commandLocales,
|
|
343
|
+
manifest: r
|
|
344
|
+
}), a = c(n.said);
|
|
345
|
+
return i.some((e) => {
|
|
346
|
+
let i = d[e], o = v(i), s = l(n.said, o.prep, a);
|
|
347
|
+
return s === null ? !1 : t(r, e, "there") && D(o.there, s) || t(r, e, "pick") && E(o, s) !== null;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
351
|
+
export { v as compileNative, F as matchLocaleIntents, I as mayBeThereOrPick };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ControlSnapshot } from '../appControls/snapshot';
|
|
2
|
+
import { UiLanguage } from '../appControls/types';
|
|
3
|
+
import { LocalDestination, LocalUiCommand } from '../localUiCommands';
|
|
4
|
+
import { UiOfferYesState } from '../uiActions/uiOffers';
|
|
5
|
+
import { CommandManifest } from './types';
|
|
6
|
+
export interface EvalControls {
|
|
7
|
+
registered?: readonly string[];
|
|
8
|
+
languages?: readonly UiLanguage[];
|
|
9
|
+
sidebarEntries?: ControlSnapshot["sidebarEntries"];
|
|
10
|
+
page?: Partial<NonNullable<ControlSnapshot["page"]>> | null;
|
|
11
|
+
}
|
|
12
|
+
export interface EvalNavigation {
|
|
13
|
+
links?: readonly LocalDestination[];
|
|
14
|
+
unresolved?: number;
|
|
15
|
+
list?: readonly string[];
|
|
16
|
+
offered?: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export interface EvalYes {
|
|
19
|
+
offer?: UiOfferYesState;
|
|
20
|
+
pending?: number;
|
|
21
|
+
attachments?: boolean;
|
|
22
|
+
leaveGuard?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface EvalItem {
|
|
25
|
+
id: string;
|
|
26
|
+
text: string;
|
|
27
|
+
uiLocale: string;
|
|
28
|
+
inputLocale?: string;
|
|
29
|
+
origin?: "typed" | "spoken";
|
|
30
|
+
family?: string;
|
|
31
|
+
sidebar?: readonly LocalDestination[];
|
|
32
|
+
controls?: EvalControls;
|
|
33
|
+
backRunnable?: boolean;
|
|
34
|
+
navigation?: EvalNavigation | null;
|
|
35
|
+
yes?: EvalYes;
|
|
36
|
+
themeWords?: "any" | "mode-only";
|
|
37
|
+
expected?: string | Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export type EvalActual = {
|
|
40
|
+
result: "model";
|
|
41
|
+
plannedAs?: string;
|
|
42
|
+
} | ({
|
|
43
|
+
result: "command";
|
|
44
|
+
kind: string;
|
|
45
|
+
} & Record<string, unknown>);
|
|
46
|
+
export type EvalVerdict = "pass" | "false-match" | "wrong" | "miss" | "unscored";
|
|
47
|
+
export interface EvalResult {
|
|
48
|
+
id: string;
|
|
49
|
+
locale: string;
|
|
50
|
+
family: string;
|
|
51
|
+
actual: EvalActual;
|
|
52
|
+
expected?: string | Record<string, unknown>;
|
|
53
|
+
verdict: EvalVerdict;
|
|
54
|
+
}
|
|
55
|
+
/** A command as a flat, comparable record. */
|
|
56
|
+
export declare function describeCommand(command: LocalUiCommand | null): EvalActual;
|
|
57
|
+
/** What the shipping composition does with one item. */
|
|
58
|
+
export declare function actualOf(item: EvalItem, manifest: CommandManifest): EvalActual;
|
|
59
|
+
export declare function verdictOf(actual: EvalActual, expected: EvalItem["expected"]): EvalVerdict;
|
|
60
|
+
export declare function evaluateCommandItem(item: EvalItem, manifest?: CommandManifest): EvalResult;
|
|
61
|
+
export interface EvalCell {
|
|
62
|
+
locale: string;
|
|
63
|
+
family: string;
|
|
64
|
+
items: number;
|
|
65
|
+
positives: number;
|
|
66
|
+
negatives: number;
|
|
67
|
+
truePositives: number;
|
|
68
|
+
misses: number;
|
|
69
|
+
wrong: number;
|
|
70
|
+
falseMatches: number;
|
|
71
|
+
precision: number | null;
|
|
72
|
+
recall: number | null;
|
|
73
|
+
}
|
|
74
|
+
/** The scoreboard: per locale and family. `falseMatches` counts a wrong target too (G1). */
|
|
75
|
+
export declare function scoreboard(results: readonly EvalResult[]): EvalCell[];
|
|
76
|
+
/** The family names an item may be labelled with. */
|
|
77
|
+
export declare const EVAL_FAMILIES: readonly string[];
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { planWriteReply as e } from "../writeReplySend.js";
|
|
2
|
+
import { COMMAND_FAMILIES as t } from "./types.js";
|
|
3
|
+
import { allOnManifest as n } from "./gate.js";
|
|
4
|
+
import { matchLocalUiCommand as r } from "../localUiCommands.js";
|
|
5
|
+
import { offerAssentFor as i } from "./assent.js";
|
|
6
|
+
import { EMPTY_CONTROL_SNAPSHOT as a } from "../appControls/snapshot.js";
|
|
7
|
+
//#region src/shared/assistant/localeCommands/evaluate.ts
|
|
8
|
+
var o = (e) => e.id;
|
|
9
|
+
function s(e) {
|
|
10
|
+
if (!e) return;
|
|
11
|
+
let t = { ...a.registered };
|
|
12
|
+
for (let n of e.registered ?? []) t[n] = !0;
|
|
13
|
+
let n = e.page ? {
|
|
14
|
+
name: e.page.name ?? "Page",
|
|
15
|
+
tabs: e.page.tabs ?? [],
|
|
16
|
+
filters: e.page.filters ?? [],
|
|
17
|
+
sorts: e.page.sorts ?? [],
|
|
18
|
+
searchable: e.page.searchable ?? !1,
|
|
19
|
+
openers: e.page.openers ?? []
|
|
20
|
+
} : null;
|
|
21
|
+
return {
|
|
22
|
+
...a,
|
|
23
|
+
registered: t,
|
|
24
|
+
languages: e.languages ?? [],
|
|
25
|
+
sidebarEntries: e.sidebarEntries ?? [],
|
|
26
|
+
page: n
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function c(e) {
|
|
30
|
+
if (!e) return null;
|
|
31
|
+
let t = e.links ?? [], n = e.list, r = new Set(e.offered ?? []);
|
|
32
|
+
return {
|
|
33
|
+
links: {
|
|
34
|
+
targets: [...t],
|
|
35
|
+
unresolved: e.unresolved ?? 0
|
|
36
|
+
},
|
|
37
|
+
pendingChoice: n ? {
|
|
38
|
+
candidates: n.map((e) => t.find((t) => t.id === e) ?? null),
|
|
39
|
+
candidateIds: [...n]
|
|
40
|
+
} : null,
|
|
41
|
+
...r.size > 0 ? { offers: t.filter((e) => r.has(e.id)).map((e) => ({
|
|
42
|
+
path: e.path,
|
|
43
|
+
offerId: `uo_${e.id.padEnd(32, "0").slice(0, 32)}`
|
|
44
|
+
})) } : {}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function l(e) {
|
|
48
|
+
if (!e) return { result: "model" };
|
|
49
|
+
switch (e.kind) {
|
|
50
|
+
case "navigate": return {
|
|
51
|
+
result: "command",
|
|
52
|
+
kind: "navigate",
|
|
53
|
+
destinationId: e.destination.id,
|
|
54
|
+
...e.via ? { via: e.via } : {},
|
|
55
|
+
...e.via === "offer" ? { trigger: e.trigger } : {}
|
|
56
|
+
};
|
|
57
|
+
case "choose-destination":
|
|
58
|
+
case "choose-linked": return {
|
|
59
|
+
result: "command",
|
|
60
|
+
kind: e.kind,
|
|
61
|
+
candidateIds: e.candidates.map(o)
|
|
62
|
+
};
|
|
63
|
+
case "theme": return {
|
|
64
|
+
result: "command",
|
|
65
|
+
kind: "theme",
|
|
66
|
+
family: e.request.kind === "family" ? e.request.family : e.request.theme
|
|
67
|
+
};
|
|
68
|
+
case "app-control": return {
|
|
69
|
+
result: "command",
|
|
70
|
+
kind: "app-control",
|
|
71
|
+
control: e.request.control,
|
|
72
|
+
request: e.request
|
|
73
|
+
};
|
|
74
|
+
case "pick-from-list": return {
|
|
75
|
+
result: "command",
|
|
76
|
+
kind: "pick-from-list"
|
|
77
|
+
};
|
|
78
|
+
default: return {
|
|
79
|
+
result: "command",
|
|
80
|
+
kind: e.kind
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function u(t, n) {
|
|
85
|
+
let a = t.inputLocale ?? t.uiLocale, o = t.origin === "spoken", u = o ? a : t.uiLocale;
|
|
86
|
+
if (t.yes) {
|
|
87
|
+
let r = t.yes, s = e({
|
|
88
|
+
text: t.text,
|
|
89
|
+
locale: u,
|
|
90
|
+
origin: o ? "spoken" : "typed",
|
|
91
|
+
hasAttachments: r.attachments === !0,
|
|
92
|
+
live: {
|
|
93
|
+
count: r.pending ?? 0,
|
|
94
|
+
execution: "enabled"
|
|
95
|
+
},
|
|
96
|
+
matchesLocalCommand: () => !1,
|
|
97
|
+
offer: r.offer ?? "none",
|
|
98
|
+
offerAssent: i({
|
|
99
|
+
text: t.text,
|
|
100
|
+
uiLocale: t.uiLocale,
|
|
101
|
+
inputLocale: a,
|
|
102
|
+
manifest: n,
|
|
103
|
+
leaveGuard: r.leaveGuard === !0
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
return s.kind === "accept_offer" ? {
|
|
107
|
+
result: "command",
|
|
108
|
+
kind: "accept_offer"
|
|
109
|
+
} : s.kind === "local_reply" ? {
|
|
110
|
+
result: "model",
|
|
111
|
+
plannedAs: "local_reply"
|
|
112
|
+
} : { result: "model" };
|
|
113
|
+
}
|
|
114
|
+
let d = s(t.controls), f = c(t.navigation), p = {
|
|
115
|
+
...t.backRunnable === void 0 ? {} : { backRunnable: t.backRunnable },
|
|
116
|
+
...f ? { navigation: f } : {},
|
|
117
|
+
...d ? { controls: d } : {}
|
|
118
|
+
};
|
|
119
|
+
return l(r(t.text, t.sidebar ?? [], {
|
|
120
|
+
locale: u,
|
|
121
|
+
uiLocale: t.uiLocale,
|
|
122
|
+
inputLocale: a,
|
|
123
|
+
commandManifest: n,
|
|
124
|
+
...t.themeWords ? { themeWords: t.themeWords } : {}
|
|
125
|
+
}, p));
|
|
126
|
+
}
|
|
127
|
+
function d(e, t) {
|
|
128
|
+
return typeof t == "string" ? e.result === t : Object.entries(t).every(([t, n]) => {
|
|
129
|
+
let r = e[t];
|
|
130
|
+
return JSON.stringify(r) === JSON.stringify(n);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function f(e, t) {
|
|
134
|
+
return t === void 0 ? "unscored" : (typeof t == "string" ? t === "model" : t.result === "model") ? e.result === "model" ? "pass" : "false-match" : e.result === "model" ? "miss" : d(e, t) ? "pass" : "wrong";
|
|
135
|
+
}
|
|
136
|
+
function p(e, t = n()) {
|
|
137
|
+
let r = u(e, t);
|
|
138
|
+
return {
|
|
139
|
+
id: e.id,
|
|
140
|
+
locale: e.uiLocale.toLowerCase().split(/[-_]/)[0] ?? e.uiLocale,
|
|
141
|
+
family: e.family ?? "unlabelled",
|
|
142
|
+
actual: r,
|
|
143
|
+
...e.expected === void 0 ? {} : { expected: e.expected },
|
|
144
|
+
verdict: f(r, e.expected)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function m(e) {
|
|
148
|
+
let t = /* @__PURE__ */ new Map();
|
|
149
|
+
for (let n of e) {
|
|
150
|
+
if (n.verdict === "unscored") continue;
|
|
151
|
+
let e = `${n.locale}\u0000${n.family}`, r = t.get(e) ?? {
|
|
152
|
+
locale: n.locale,
|
|
153
|
+
family: n.family,
|
|
154
|
+
items: 0,
|
|
155
|
+
positives: 0,
|
|
156
|
+
negatives: 0,
|
|
157
|
+
truePositives: 0,
|
|
158
|
+
misses: 0,
|
|
159
|
+
wrong: 0,
|
|
160
|
+
falseMatches: 0,
|
|
161
|
+
precision: null,
|
|
162
|
+
recall: null
|
|
163
|
+
};
|
|
164
|
+
r.items += 1;
|
|
165
|
+
let i = typeof n.expected == "string" ? n.expected === "model" : n.expected?.result === "model";
|
|
166
|
+
i ? r.negatives += 1 : r.positives += 1, n.verdict === "pass" && !i && (r.truePositives += 1), n.verdict === "miss" && (r.misses += 1), n.verdict === "wrong" && (r.wrong += 1), n.verdict === "false-match" && (r.falseMatches += 1), t.set(e, r);
|
|
167
|
+
}
|
|
168
|
+
return [...t.values()].map((e) => {
|
|
169
|
+
let t = e.falseMatches + e.wrong, n = e.truePositives + t;
|
|
170
|
+
return {
|
|
171
|
+
...e,
|
|
172
|
+
falseMatches: t,
|
|
173
|
+
precision: n === 0 ? null : e.truePositives / n,
|
|
174
|
+
recall: e.positives === 0 ? null : e.truePositives / e.positives
|
|
175
|
+
};
|
|
176
|
+
}).sort((e, t) => `${e.locale}${e.family}`.localeCompare(`${t.locale}${t.family}`));
|
|
177
|
+
}
|
|
178
|
+
var h = [...t];
|
|
179
|
+
//#endregion
|
|
180
|
+
export { h as EVAL_FAMILIES, u as actualOf, l as describeCommand, p as evaluateCommandItem, m as scoreboard, f as verdictOf };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommandLocale } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The fold: lower-case, punctuation-free, single-spaced — and, for `zh`, with no
|
|
4
|
+
* space at all. Idempotent.
|
|
5
|
+
*/
|
|
6
|
+
export declare function foldText(text: string, locale: CommandLocale | "en"): string;
|
|
7
|
+
/** One word of a sentence, as said and as folded (a word may fold to several, or to none). */
|
|
8
|
+
export interface FoldedWord {
|
|
9
|
+
said: string;
|
|
10
|
+
folded: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The sentence split at its spaces, each word with its folded form(s), so a
|
|
14
|
+
* free-text slot can hand back the person's OWN words (case, inner
|
|
15
|
+
* punctuation) rather than the fold of them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function foldWords(text: string, locale: CommandLocale | "en"): FoldedWord[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/shared/assistant/localeCommands/fold.ts
|
|
2
|
+
var e = /\p{Cf}/gu, t = [
|
|
3
|
+
1632,
|
|
4
|
+
1776,
|
|
5
|
+
2406,
|
|
6
|
+
3046
|
|
7
|
+
];
|
|
8
|
+
function n(e) {
|
|
9
|
+
return e.replace(/\p{Nd}/gu, (e) => {
|
|
10
|
+
let n = e.codePointAt(0) ?? 0;
|
|
11
|
+
for (let e of t) if (n >= e && n <= e + 9) return String(n - e);
|
|
12
|
+
return e;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
var r = /़/g, i = /ँ/g, a = [
|
|
16
|
+
[/ङ्(?=[क-घ])/g, "ं"],
|
|
17
|
+
[/ञ्(?=[च-झ])/g, "ं"],
|
|
18
|
+
[/ण्(?=[ट-ढ])/g, "ं"],
|
|
19
|
+
[/न्(?=[त-ध])/g, "ं"],
|
|
20
|
+
[/म्(?=[प-भ])/g, "ं"]
|
|
21
|
+
];
|
|
22
|
+
function o(e) {
|
|
23
|
+
let t = e.replace(r, "").replace(i, "ं");
|
|
24
|
+
for (let [e, n] of a) t = t.replace(e, n);
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
var s = /[ً-ٰٟـ]/g, c = [
|
|
28
|
+
[/[أإآٱ]/g, "ا"],
|
|
29
|
+
[/ى/g, "ي"],
|
|
30
|
+
[/ة/g, "ه"],
|
|
31
|
+
[/ؤ/g, "و"],
|
|
32
|
+
[/ئ/g, "ي"],
|
|
33
|
+
[/ی/g, "ي"],
|
|
34
|
+
[/ک/g, "ك"]
|
|
35
|
+
];
|
|
36
|
+
function l(e) {
|
|
37
|
+
let t = e.replace(s, "");
|
|
38
|
+
for (let [e, n] of c) t = t.replace(e, n);
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
function u(e) {
|
|
42
|
+
return e.replace(/\p{Script=Latin}\p{M}*/gu, (e) => {
|
|
43
|
+
let t = e.normalize("NFC");
|
|
44
|
+
return t === "ñ" ? t : e.normalize("NFD").replace(/[̀-ͯ]/g, "");
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
var d = {
|
|
48
|
+
en: (e) => e,
|
|
49
|
+
hi: o,
|
|
50
|
+
ta: (e) => e,
|
|
51
|
+
ar: l,
|
|
52
|
+
es: u,
|
|
53
|
+
zh: (e) => e
|
|
54
|
+
};
|
|
55
|
+
function f(t, r) {
|
|
56
|
+
let i = n(t.normalize("NFKC").replace(e, "").toLowerCase().normalize("NFKC")), a = d[r](i).replace(/&/g, " and ").replace(/[^\p{L}\p{N}\p{M}\s]/gu, " ").replace(/\s+/g, " ").trim();
|
|
57
|
+
return r === "zh" ? a.replace(/\s+/g, "") : a;
|
|
58
|
+
}
|
|
59
|
+
function p(t, n) {
|
|
60
|
+
return t.normalize("NFKC").replace(e, "").split(/\s+/).filter(Boolean).map((e) => ({
|
|
61
|
+
said: e.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, ""),
|
|
62
|
+
folded: f(e, n).split(" ").filter(Boolean)
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { f as foldText, p as foldWords };
|