@burdenoff/fe-libs 2026.903.10 → 2026.904.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/i18n.d.ts +62 -0
- package/dist/shared/assistant/i18n.d.ts.map +1 -0
- package/dist/shared/assistant/i18n.js +32 -0
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared-assistant.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Assistant copy, namespaced by product.
|
|
4
|
+
*
|
|
5
|
+
* The assistant UI is shared but its translations are not: every product seeds
|
|
6
|
+
* its own keys, and HealthyBowl already has hundreds of `healthybowl.assistant.*`
|
|
7
|
+
* keys live in production. So a shared component cannot hardcode a key prefix —
|
|
8
|
+
* it must ask for a RELATIVE key and let the product decide the namespace.
|
|
9
|
+
*
|
|
10
|
+
* ★★ The shape below is chosen to be byte-compatible with what HealthyBowl
|
|
11
|
+
* already ships. `assistantTranslationKey('healthybowl', 'header.title')` is
|
|
12
|
+
* exactly `'healthybowl.assistant.header.title'`, which is the key already
|
|
13
|
+
* seeded and already translated. Any other shape would silently drop every
|
|
14
|
+
* non-English user back to the English fallback while every test still passed —
|
|
15
|
+
* the migration would look clean and quietly un-translate the product.
|
|
16
|
+
*
|
|
17
|
+
* Products other than HealthyBowl simply have no keys yet, so they get the
|
|
18
|
+
* English fallback until they seed theirs. That is a known, visible gap rather
|
|
19
|
+
* than a regression.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* How a relative key becomes a full translation key.
|
|
23
|
+
*
|
|
24
|
+
* Pure and exported precisely so the compatibility claim above is testable
|
|
25
|
+
* without rendering anything.
|
|
26
|
+
*/
|
|
27
|
+
export declare function assistantTranslationKey(namespace: string, key: string): string;
|
|
28
|
+
export interface AssistantI18nValue {
|
|
29
|
+
/** Product id, e.g. `healthybowl`. Matches the id in shared/config/products. */
|
|
30
|
+
namespace: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AssistantI18nProviderProps {
|
|
33
|
+
namespace: string;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Supplies the product namespace to every assistant component beneath it.
|
|
38
|
+
*
|
|
39
|
+
* Mount it once, as high as the assistant goes — the same product id the
|
|
40
|
+
* transport already needs for `AI_ASSISTANT_PRODUCT`, so there is one answer to
|
|
41
|
+
* "which product is this?" rather than two that can disagree.
|
|
42
|
+
*/
|
|
43
|
+
export declare function AssistantI18nProvider({ namespace, children, }: AssistantI18nProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
/** The namespace in force, or null when no provider is mounted. */
|
|
45
|
+
export declare function useAssistantI18nNamespace(): string | null;
|
|
46
|
+
export type AssistantTr = (key: string, fallback: string, params?: Record<string, string | number>) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Translate a RELATIVE assistant key, e.g. `tr('header.title', 'Assistant')`.
|
|
49
|
+
*
|
|
50
|
+
* Fallback semantics match the products' existing `useTr`: the I18n provider
|
|
51
|
+
* returns the key itself when it has no translation, and the caller's English
|
|
52
|
+
* string is used instead so a raw key never reaches the UI.
|
|
53
|
+
*
|
|
54
|
+
* ★ With no provider mounted this returns the English fallback rather than
|
|
55
|
+
* throwing. A missing provider is a configuration mistake, but a thrown error
|
|
56
|
+
* inside render is a white screen, and English copy is strictly better than
|
|
57
|
+
* that. It complains once to the console so the mistake is still findable — the
|
|
58
|
+
* failure this guards against is the assistant silently rendering English in
|
|
59
|
+
* every locale, which is exactly what happened to the fe-libs shell.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useAssistantTr(): AssistantTr;
|
|
62
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/i18n.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,MAAM,CAER;AAED,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAQ,GACT,EAAE,0BAA0B,2CAO5B;AAED,mEAAmE;AACnE,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,IAAI,CAEzD;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACrC,MAAM,CAAC;AAIZ;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,IAAI,WAAW,CA4B5C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useI18n as e } from "../providers/shell/I18nProvider.js";
|
|
2
|
+
import { createContext as t, useCallback as n, useContext as r, useMemo as i } from "react";
|
|
3
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
4
|
+
//#region src/shared/assistant/i18n.tsx
|
|
5
|
+
function o(e, t) {
|
|
6
|
+
return `${e}.assistant.${t}`;
|
|
7
|
+
}
|
|
8
|
+
var s = t(null);
|
|
9
|
+
function c({ namespace: e, children: t }) {
|
|
10
|
+
let n = i(() => ({ namespace: e }), [e]);
|
|
11
|
+
return /* @__PURE__ */ a(s.Provider, {
|
|
12
|
+
value: n,
|
|
13
|
+
children: t
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function l() {
|
|
17
|
+
return r(s)?.namespace ?? null;
|
|
18
|
+
}
|
|
19
|
+
var u = !1;
|
|
20
|
+
function d() {
|
|
21
|
+
let { t } = e(), r = l();
|
|
22
|
+
return r === null && !u && (u = !0, console.error("[assistant] No AssistantI18nProvider mounted — assistant copy will render in English for every locale. Wrap the assistant in <AssistantI18nProvider namespace=\"<product>\">.")), n((e, n, i) => {
|
|
23
|
+
if (r === null) return f(n, i);
|
|
24
|
+
let a = o(r, e), s = t(a);
|
|
25
|
+
return f(s === a ? n : s, i);
|
|
26
|
+
}, [t, r]);
|
|
27
|
+
}
|
|
28
|
+
function f(e, t) {
|
|
29
|
+
return t ? Object.entries(t).reduce((e, [t, n]) => e.replace(RegExp(`\\{\\{${t}\\}\\}`, "g"), String(n)), e) : e;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { c as AssistantI18nProvider, o as assistantTranslationKey, l as useAssistantI18nNamespace, d as useAssistantTr };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AAGxB,cAAc,wBAAwB,CAAC;AAKvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAA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cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAG3C,cAAc,QAAQ,CAAC"}
|
package/dist/shared-assistant.js
CHANGED
|
@@ -26,4 +26,5 @@ import { toCaptionText as kt } from "./shared/assistant/voice/captionText.js";
|
|
|
26
26
|
import { ASSISTANT_LANGUAGES as At, DEFAULT_SPEECH_RATE as jt, findAssistantLanguage as Mt, resolveAssistantLanguage as Nt } from "./shared/assistant/voice/languages.js";
|
|
27
27
|
import { replyFollowsInput as Pt, resolveLanguagePair as Ft } from "./shared/assistant/voice/languagePair.js";
|
|
28
28
|
import { findPendingWrite as It, parseConfirmationRefusal as Lt } from "./shared/assistant/pendingWrite.js";
|
|
29
|
-
|
|
29
|
+
import { AssistantI18nProvider as Rt, assistantTranslationKey as zt, useAssistantI18nNamespace as Bt, useAssistantTr as Vt } from "./shared/assistant/i18n.js";
|
|
30
|
+
export { p as ASSISTANT_API_AUTH_STRATEGY, At as ASSISTANT_LANGUAGES, Rt as AssistantI18nProvider, U as AssistantRuntimeManager, i as CHECK_AI_CREDITS, a as CREATE_SANDBOX, dt as DEFAULT_SPEAKABLE_LABELS, jt as DEFAULT_SPEECH_RATE, Re as ENDPOINT_GRACE_MS, o as EXTEND_SANDBOX_TTL, s as GET_ACTIVE_SANDBOXES, c as GET_SANDBOX, me as HOSTED_TTS_MAX_CHARS, ue as HOSTED_TTS_TIER, de as HOSTED_VOICES, ze as INITIAL_SESSION, Be as INTERRUPT_MAX_MS, Ve as INTERRUPT_MIN_MS, ft as MAX_SPEAKABLE_CHARS, pt as MAX_SPOKEN_TABLE_ROWS, Ct as POLL_FAST_MS, wt as POLL_FAST_UNTIL_MS, Tt as POLL_SLOW_MS, Et as POLL_STEADY_MS, Dt as POLL_STEADY_UNTIL_MS, xt as PREVIEW_LANGUAGES, l as PROXY_SANDBOX_REQUEST, u as REPORT_AI_TOKEN_USAGE, He as SILENCE_SUBMIT_MS, he as SPEAKING_RATE_MAX, ge as SPEAKING_RATE_MAX_STREAMING, _e as SPEAKING_RATE_MAX_SYNC, ve as SPEAKING_RATE_MIN, mt as SPEECH_CHUNK_CHARS, ht as SPEECH_CHUNK_CJK_CHARS, Xe as SPEECH_LANG, d as STOP_ASSISTANT_SANDBOX, Ze as VOICE_LIST_TIMEOUT_MS, f as WAIT_FOR_SANDBOX_RUNNING, zt as assistantTranslationKey, ye as base64ToBytes, le as browserSpeechEngine, C as buildAssistantSandboxEnv, ct as buildContinuedFromVoiceNote, W as buildProgress, w as buildPromptRequestBody, be as buildRequest, t as buildSandboxContextInput, lt as buildVoiceTranscriptMarkdown, ne as chatTurns, T as checkAssistantAiCredits, gt as chunkForSpeech, xe as classifyHttpFailure, De as configureSpeechEngine, _t as containsCjk, E as createAssistantSandbox, D as createAssistantSession, Te as createHostedTtsEngine, Ee as createRoutingSpeechEngine, ee as createSandboxAssistantTransport, Oe as createSpeechEngines, Se as decodeAudioResponse, O as downloadAssistantArtifact, n as executeSandboxGraphQL, k as extendAssistantSandboxTTL, Mt as findAssistantLanguage, A as findExistingSandbox, It as findPendingWrite, j as getAssistantArtifacts, G as getAssistantMedia, M as getAssistantMessages, N as getAssistantSession, P as getAssistantStreamAccess, K as getAssistantText, y as getCapability, m as getImageForMode, h as getImageTagForMode, q as getRawMessageCreatedAt, g as getResourcesForMode, _ as getSandboxImageRegistry, ke as getSpeechEngine, J as getToolProgress, re as groupBySession, ie as groupConsecutiveBySession, fe as hostedLocaleFor, pe as hostedSupportsLanguage, Ue as isCapturing, We as isEcho, r as isQuotaExhaustedError, Y as isReapedSandboxConnectionError, X as isRecoverable, Qe as isSpeechBlocked, Ge as isSubmittable, b as isUnknownFieldError, ae as isVoiceTurn, $e as languageDisplayName, Z as mapSessionToHistory, x as markSupported, S as markUnsupported, Q as mergeMessagesById, Me as micIsInterrupt, F as modeRequiresConfirmWrites, et as normalizeLangTag, Ke as orbMode, Lt as parseConfirmationRefusal, qe as planReplyConsumption, Ot as pollDelayMs, tt as primaryLanguageSubtag, Ae as readSpeechEngineConfig, Pt as replyFollowsInput, I as reportAssistantAiTokenUsage, je as resetSpeechEngine, Nt as resolveAssistantLanguage, Ft as resolveLanguagePair, v as resolveSandboxAssistantMode, $ as sanitize, L as selectExistingAssistantSandbox, nt as selectVoiceForLocale, R as sendAssistantPromptAsync, z as sendHeartbeat, Ce as shouldDisableEngine, Ne as showsAssistantCaption, Pe as showsUserCaption, vt as speakableEmail, rt as speechGate, it as speechLangForLocale, we as splitForVendor, yt as splitTableRow, Je as spokenSoFar, B as stopReapedAssistantSandbox, kt as toCaptionText, bt as toSpeakableText, Bt as useAssistantI18nNamespace, Vt as useAssistantTr, te as useSandboxAssistantTransport, e as useVoiceInput, at as voiceAvailability, oe as voiceMarker, St as voicePreviewText, ot as voiceQualityRank, se as voiceSessionIdOf, Ye as voiceSessionReducer, Fe as voiceStageState, ut as voiceTranscriptFilename, ce as voiceTurnsOnly, st as voicesForLocale, V as waitForAssistantServiceReady, H as waitForSandboxRunning, Ie as waveformIsActive, Le as waveformIsSettled };
|