@g9tm/aiassistant 1.9.5 → 1.10.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/api.d.ts +5 -0
- package/dist/api.js +2 -0
- package/dist/assistant.d.ts +8 -2
- package/dist/assistant.js +6 -3
- package/dist/i18n.js +0 -16
- package/dist/pages.js +16 -0
- package/dist/types.d.ts +3 -2
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export interface SendInput {
|
|
|
25
25
|
id: string;
|
|
26
26
|
label?: string;
|
|
27
27
|
}[];
|
|
28
|
+
/** Blind mode: the conversation's last lines, which the server keeps only in memory. */
|
|
29
|
+
history?: {
|
|
30
|
+
role: string;
|
|
31
|
+
text: string;
|
|
32
|
+
}[];
|
|
28
33
|
}
|
|
29
34
|
export interface EventPage {
|
|
30
35
|
events: RawEvent[];
|
package/dist/api.js
CHANGED
|
@@ -82,6 +82,8 @@ export class AssistantApi {
|
|
|
82
82
|
body["model"] = input.model;
|
|
83
83
|
if (input.refs?.length)
|
|
84
84
|
body["refs"] = input.refs;
|
|
85
|
+
if (input.history)
|
|
86
|
+
body["history"] = input.history;
|
|
85
87
|
return this.request("POST", path, body).then((r) => ({ conversationId: str(obj(r)["conversationId"]), runId: str(obj(r)["runId"]) }));
|
|
86
88
|
}
|
|
87
89
|
async events(runId, after, wait) {
|
package/dist/assistant.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface AssistantOptions {
|
|
|
30
30
|
flows?: boolean;
|
|
31
31
|
/** How the conversation reads and writes (every renderer follows it). */
|
|
32
32
|
chat?: ChatOptions;
|
|
33
|
+
/**
|
|
34
|
+
* The server runs in blind mode: it keeps no conversation at rest, so the device keeps them. Each question carries the
|
|
35
|
+
* last six lines, and `open` takes the messages the host saved instead of asking the server.
|
|
36
|
+
*/
|
|
37
|
+
blind?: boolean;
|
|
33
38
|
}
|
|
34
39
|
/** How the conversation reads and writes; every option has a safe default for every host. */
|
|
35
40
|
export interface ChatOptions {
|
|
@@ -99,13 +104,14 @@ export declare class Assistant {
|
|
|
99
104
|
private readonly answeredCalls;
|
|
100
105
|
/** The conversation's reading and writing options as given (`chatOf` in "@g9tm/aiassistant/pages" resolves the defaults). */
|
|
101
106
|
readonly chat: ChatOptions;
|
|
107
|
+
private readonly blind;
|
|
102
108
|
constructor(host: AssistantHost, options?: AssistantOptions);
|
|
103
109
|
/** Listens to every change; returns the function that stops listening. */
|
|
104
110
|
subscribe(listener: (s: AssistantSnapshot) => void): () => void;
|
|
105
111
|
snapshot(): AssistantSnapshot;
|
|
106
112
|
private emit;
|
|
107
|
-
/** Opens a conversation from its history (from the end; history never animates). */
|
|
108
|
-
open(conversationId: string): Promise<void>;
|
|
113
|
+
/** Opens a conversation from its history (from the end; history never animates); blind: from `saved`, the host's copy. */
|
|
114
|
+
open(conversationId: string, saved?: readonly unknown[]): Promise<void>;
|
|
109
115
|
/** Counts fresh(): a send that returns after one is dropped. */
|
|
110
116
|
private generation;
|
|
111
117
|
/** A new conversation. */
|
package/dist/assistant.js
CHANGED
|
@@ -35,6 +35,7 @@ export class Assistant {
|
|
|
35
35
|
this.answeredCalls = new Set();
|
|
36
36
|
/** Counts fresh(): a send that returns after one is dropped. */
|
|
37
37
|
this.generation = 0;
|
|
38
|
+
this.blind = options.blind === true;
|
|
38
39
|
this.api = new AssistantApi(host, options.base);
|
|
39
40
|
this.texts = createTexts(host.locale, options.texts);
|
|
40
41
|
this.transport = pickTransport(this.api, host, options);
|
|
@@ -69,11 +70,11 @@ export class Assistant {
|
|
|
69
70
|
for (const l of this.listeners)
|
|
70
71
|
l(s);
|
|
71
72
|
}
|
|
72
|
-
/** Opens a conversation from its history (from the end; history never animates). */
|
|
73
|
-
async open(conversationId) {
|
|
73
|
+
/** Opens a conversation from its history (from the end; history never animates); blind: from `saved`, the host's copy. */
|
|
74
|
+
async open(conversationId, saved) {
|
|
74
75
|
this.follow(null);
|
|
75
76
|
this.store.reset(conversationId);
|
|
76
|
-
const r = await this.api.messages(conversationId);
|
|
77
|
+
const r = this.blind ? saved ?? [] : await this.api.messages(conversationId);
|
|
77
78
|
const raw = Array.isArray(r) ? r : Array.isArray(r.messages) ? r.messages : [];
|
|
78
79
|
const added = this.store.merge(raw);
|
|
79
80
|
this.watched.history(added.map((m) => m.id));
|
|
@@ -111,6 +112,8 @@ export class Assistant {
|
|
|
111
112
|
this.store.optimistic(trimmed, new Date(timer(this.host).now()).toISOString());
|
|
112
113
|
this.emit();
|
|
113
114
|
const input = { text: trimmed };
|
|
115
|
+
if (this.blind)
|
|
116
|
+
input.history = this.store.messages.filter((m) => !m.pending && m.role !== "system" && m.text).slice(-6).map((m) => ({ role: m.role, text: m.text.slice(0, 500) }));
|
|
114
117
|
if (this.store.id)
|
|
115
118
|
input.conversationId = this.store.id;
|
|
116
119
|
if (this.attachments.length > 0)
|
package/dist/i18n.js
CHANGED
|
@@ -51,14 +51,6 @@ const fa = {
|
|
|
51
51
|
"block.more_rows": "{count} ردیف دیگر",
|
|
52
52
|
"block.suggested": "پیشنهادی",
|
|
53
53
|
"block.few_data": "داده برای درصد و میانگین کافی نیست",
|
|
54
|
-
"history.today": "امروز",
|
|
55
|
-
"history.earlier": "قبلتر",
|
|
56
|
-
"history.pinned": "سنجاقشده",
|
|
57
|
-
"history.waiting": "منتظر",
|
|
58
|
-
"history.search": "جستوجو",
|
|
59
|
-
"csv.save": "ذخیره به CSV",
|
|
60
|
-
"csv.saved": "ذخیره شد",
|
|
61
|
-
"csv.not_saved": "ذخیره نشد",
|
|
62
54
|
"pdf.download": "دریافت PDF",
|
|
63
55
|
"pdf.busy": "در حال آمادهسازی PDF…",
|
|
64
56
|
"pdf.failed": "PDF ساخته نشد",
|
|
@@ -122,14 +114,6 @@ const en = {
|
|
|
122
114
|
"block.more_rows": "{count} more rows",
|
|
123
115
|
"block.suggested": "Suggested",
|
|
124
116
|
"block.few_data": "Too little data for percentages and averages",
|
|
125
|
-
"history.today": "Today",
|
|
126
|
-
"history.earlier": "Earlier",
|
|
127
|
-
"history.pinned": "Pinned",
|
|
128
|
-
"history.waiting": "Waiting",
|
|
129
|
-
"history.search": "Search",
|
|
130
|
-
"csv.save": "Save as CSV",
|
|
131
|
-
"csv.saved": "Saved",
|
|
132
|
-
"csv.not_saved": "Not saved",
|
|
133
117
|
"pdf.download": "Download PDF",
|
|
134
118
|
"pdf.busy": "Preparing the PDF…",
|
|
135
119
|
"pdf.failed": "Could not make the PDF",
|
package/dist/pages.js
CHANGED
|
@@ -67,6 +67,14 @@ const PAGE_FA = {
|
|
|
67
67
|
"composer.quick": "کارهای آماده",
|
|
68
68
|
"composer.pick": "انتخاب",
|
|
69
69
|
"history.tabs": "گفتوگوها",
|
|
70
|
+
"history.today": "امروز",
|
|
71
|
+
"history.earlier": "قبلتر",
|
|
72
|
+
"history.pinned": "سنجاقشده",
|
|
73
|
+
"history.waiting": "منتظر",
|
|
74
|
+
"history.search": "جستوجو",
|
|
75
|
+
"csv.save": "ذخیره به CSV",
|
|
76
|
+
"csv.saved": "ذخیره شد",
|
|
77
|
+
"csv.not_saved": "ذخیره نشد",
|
|
70
78
|
"history.empty": "چیزی اینجا نیست",
|
|
71
79
|
"history.untitled": "بینام",
|
|
72
80
|
"routine.list": "روالها",
|
|
@@ -141,6 +149,14 @@ const PAGE_EN = {
|
|
|
141
149
|
"composer.quick": "Ready requests",
|
|
142
150
|
"composer.pick": "Pick",
|
|
143
151
|
"history.tabs": "Conversations",
|
|
152
|
+
"history.today": "Today",
|
|
153
|
+
"history.earlier": "Earlier",
|
|
154
|
+
"history.pinned": "Pinned",
|
|
155
|
+
"history.waiting": "Waiting",
|
|
156
|
+
"history.search": "Search",
|
|
157
|
+
"csv.save": "Save as CSV",
|
|
158
|
+
"csv.saved": "Saved",
|
|
159
|
+
"csv.not_saved": "Not saved",
|
|
144
160
|
"history.empty": "Nothing here",
|
|
145
161
|
"history.untitled": "Untitled",
|
|
146
162
|
"routine.list": "Routines",
|
package/dist/types.d.ts
CHANGED
|
@@ -18,9 +18,10 @@ export declare const PARTS: readonly ["panel", "panel.header", "panel.body", "pa
|
|
|
18
18
|
* suggestion (`next`), a block's action (`action`), opening a page (`open`) or lighting a control in it (`show`), a
|
|
19
19
|
* draft's form (`draft`), a tour's steps (`tour`), a thing an answer named (`entity`), the message's small actions
|
|
20
20
|
* (`copy`, `again`, `edit`, `feedback`), the newest-message jump (`newest`), the composer's own (`send`, `stop`,
|
|
21
|
-
* `attach`, `quick`, `pick`), a card's (`confirm`, `refuse`, `card`)
|
|
21
|
+
* `attach`, `quick`, `pick`), a card's (`confirm`, `refuse`, `card`), a page's (`page`) and the Lynx model picker's
|
|
22
|
+
* (`model`, `effort`).
|
|
22
23
|
*/
|
|
23
|
-
export type ButtonRole = "next" | "action" | "open" | "show" | "draft" | "tour" | "entity" | "copy" | "again" | "edit" | "feedback" | "good" | "bad" | "reason" | "newest" | "send" | "stop" | "attach" | "mic" | "quick" | "pick" | "confirm" | "refuse" | "card" | "page";
|
|
24
|
+
export type ButtonRole = "next" | "action" | "open" | "show" | "draft" | "tour" | "entity" | "copy" | "again" | "edit" | "feedback" | "good" | "bad" | "reason" | "newest" | "send" | "stop" | "attach" | "mic" | "quick" | "pick" | "confirm" | "refuse" | "card" | "page" | "model" | "effort";
|
|
24
25
|
export type PartName = (typeof PARTS)[number];
|
|
25
26
|
/** Per-part classes and styles from the host (layer 3). */
|
|
26
27
|
export interface PartStyles {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/aiassistant",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.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.
|
|
36
|
+
"@g9tm/aiassistant-contracts": "1.10.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json",
|