@g9tm/aiassistant 1.2.0 → 1.4.0

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/pages.d.ts CHANGED
@@ -32,3 +32,14 @@ export declare function runCapability(assistant: Assistant, id: string, options?
32
32
  export declare function pageTexts(texts: Texts): Texts;
33
33
  /** Every key the pages add (for hosts that translate to another language). */
34
34
  export declare function pageKeys(): string[];
35
+ /**
36
+ * The host's own words (`GET texts`: its `AssistantSetup.Texts` for the locale), read once by a renderer's root. An older
37
+ * server without the endpoint gives none: nothing changes.
38
+ */
39
+ export declare function loadHostTexts(assistant: Assistant): Promise<Readonly<Record<string, string>>>;
40
+ /**
41
+ * The assistant's texts with the host's server words under them: a key the client knows (the host's client overrides,
42
+ * the library's words) keeps its words; a host key it does not know (a card's fact, a finding's title, a tool's name)
43
+ * shows the host's server words. `own` is read at every call, so texts loaded later apply at the next render.
44
+ */
45
+ export declare function withHostTexts(texts: Texts, own: () => Readonly<Record<string, string>>): Texts;
package/dist/pages.js CHANGED
@@ -31,7 +31,7 @@ export async function runCapability(assistant, id, options = {}) {
31
31
  assistant.follow(runId);
32
32
  return runId;
33
33
  }
34
- /** The words of the person's pages (history, routine wizard), both languages, kept out of the core every surface loads. */
34
+ /** The words of the person's pages (history, routine wizard) and of a refused confirmation, both languages, kept out of the core every surface loads. */
35
35
  const PAGE_FA = {
36
36
  "history.tabs": "گفت‌وگوها",
37
37
  "history.empty": "چیزی اینجا نیست",
@@ -52,6 +52,22 @@ const PAGE_FA = {
52
52
  "routine.missing": "لازم است",
53
53
  "routine.invalid": "درست نیست",
54
54
  "routine.done": "انجام شد",
55
+ "confirm.code_wrong": "کد درست نیست",
56
+ "confirm.code_missing": "کد را وارد کنید",
57
+ "confirm.locked": "تلاش‌ها زیاد شد؛ کمی بعد دوباره امتحان کنید",
58
+ "confirm.expired": "زمان این کارت گذشته است",
59
+ "confirm.not_pending": "این کارت دیگر منتظر نیست",
60
+ "confirm.plan_changed": "این کار عوض شده است؛ کارت تازه را ببینید",
61
+ "confirm.nothing_left": "کاری برای انجام نماند",
62
+ "confirm.no_gate": "تأیید با کد اینجا راه نیفتاده است",
63
+ "confirm.failed": "تأیید نشد",
64
+ "plan.locked": "این کارت بسته شد",
65
+ "error": "کار انجام نشد",
66
+ "page.abilities.empty": "هنوز توانایی‌ای نیست",
67
+ "page.knowledge.empty": "هنوز نکته‌ای نیست",
68
+ "page.learned.empty": "هنوز چیزی آموخته نشده است",
69
+ "page.findings.empty": "چیزی نیاز به توجه ندارد",
70
+ "page.actions.empty": "هنوز کاری انجام نشده است",
55
71
  };
56
72
  const PAGE_EN = {
57
73
  "history.tabs": "Conversations",
@@ -73,6 +89,22 @@ const PAGE_EN = {
73
89
  "routine.missing": "Required",
74
90
  "routine.invalid": "Not right",
75
91
  "routine.done": "Done",
92
+ "confirm.code_wrong": "The code is not right",
93
+ "confirm.code_missing": "Enter the code",
94
+ "confirm.locked": "Too many tries; try again a little later",
95
+ "confirm.expired": "This card's time is over",
96
+ "confirm.not_pending": "This card is no longer waiting",
97
+ "confirm.plan_changed": "This work changed; see the new card",
98
+ "confirm.nothing_left": "Nothing is left to do",
99
+ "confirm.no_gate": "Confirming with a code is not set up here",
100
+ "confirm.failed": "Not confirmed",
101
+ "plan.locked": "This card was closed",
102
+ "error": "It did not go through",
103
+ "page.abilities.empty": "No abilities yet",
104
+ "page.knowledge.empty": "No notes yet",
105
+ "page.learned.empty": "Nothing learned yet",
106
+ "page.findings.empty": "Nothing needs attention",
107
+ "page.actions.empty": "No actions yet",
76
108
  };
77
109
  /** The pages' texts over the assistant's: the host's texts and the core's win, then the pages' own. */
78
110
  export function pageTexts(texts) {
@@ -89,3 +121,31 @@ export function pageTexts(texts) {
89
121
  export function pageKeys() {
90
122
  return Object.keys(PAGE_EN).sort();
91
123
  }
124
+ /**
125
+ * The host's own words (`GET texts`: its `AssistantSetup.Texts` for the locale), read once by a renderer's root. An older
126
+ * server without the endpoint gives none: nothing changes.
127
+ */
128
+ export async function loadHostTexts(assistant) {
129
+ try {
130
+ const own = (await assistant.api.get("texts?locale=" + enc(assistant.texts.locale))).texts;
131
+ return typeof own === "object" && own !== null ? own : {};
132
+ }
133
+ catch {
134
+ return {};
135
+ }
136
+ }
137
+ /**
138
+ * The assistant's texts with the host's server words under them: a key the client knows (the host's client overrides,
139
+ * the library's words) keeps its words; a host key it does not know (a card's fact, a finding's title, a tool's name)
140
+ * shows the host's server words. `own` is read at every call, so texts loaded later apply at the next render.
141
+ */
142
+ export function withHostTexts(texts, own) {
143
+ return {
144
+ locale: texts.locale,
145
+ t(key, args) {
146
+ const v = texts.t(key, args);
147
+ const words = own()[key];
148
+ return v !== key || words === undefined ? v : createTexts(texts.locale, { [key]: words }).t(key, args);
149
+ },
150
+ };
151
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/aiassistant",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Headless client of the G9 AI assistant: API client, run state, transports, block view models, safe text and Persian helpers. No DOM, no framework.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@g9tm/aiassistant-contracts": "1.2.0"
36
+ "@g9tm/aiassistant-contracts": "1.4.0"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsc -p tsconfig.json",