@g9tm/aiassistant 1.9.2 → 1.9.3
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/assistant.js +5 -1
- package/dist/flows.d.ts +8 -0
- package/dist/flows.js +3 -1
- package/package.json +2 -2
package/dist/assistant.js
CHANGED
|
@@ -167,9 +167,13 @@ export class Assistant {
|
|
|
167
167
|
const online = this.host.online ? this.host.online() : true;
|
|
168
168
|
const hit = this.devices?.match(trimmed, this.host.locale) ?? null;
|
|
169
169
|
if (hit && this.devices) {
|
|
170
|
+
const r = await this.devices.run(hit.flow, hit.slots, !online);
|
|
171
|
+
// The step would rather the model answered (a name it could not resolve): online, the question goes on as if no
|
|
172
|
+
// flow had matched.
|
|
173
|
+
if (!r.ok && r.escalate === true && online)
|
|
174
|
+
return (await this.send(trimmed, page, refs)) ? "server" : "refused";
|
|
170
175
|
this.store.local("user", trimmed, at());
|
|
171
176
|
this.emit();
|
|
172
|
-
const r = await this.devices.run(hit.flow, hit.slots, !online);
|
|
173
177
|
const say = r.say || (r.ok ? "" : this.texts.t(r.code === "refused" ? "device.refused" : "device.flow_failed"));
|
|
174
178
|
this.store.local("assistant", say, at(), r.blocks, "device", r.ok ? "text" : "error");
|
|
175
179
|
this.host.onAnswerShown?.();
|
package/dist/flows.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export interface DeviceResult {
|
|
|
32
32
|
made?: string;
|
|
33
33
|
say?: string;
|
|
34
34
|
blocks?: unknown[];
|
|
35
|
+
/**
|
|
36
|
+
* A flow step that could not answer and would rather the model did (a name it could not resolve, a question that only
|
|
37
|
+
* looked like the flow's shape): online, `ask()` sends the question to the server as if no flow had matched — the
|
|
38
|
+
* device's own failure line is not shown. Offline the step's `say` stays the answer. Ignored for a run's `client.call`.
|
|
39
|
+
*/
|
|
40
|
+
escalate?: boolean;
|
|
35
41
|
}
|
|
36
42
|
/** The host's device tools. */
|
|
37
43
|
export interface DeviceTools {
|
|
@@ -87,6 +93,8 @@ export interface FlowRunResult {
|
|
|
87
93
|
blocks: unknown[];
|
|
88
94
|
code: string | null;
|
|
89
95
|
ms: number;
|
|
96
|
+
/** A step asked the model to take the question (see {@link DeviceResult.escalate}). */
|
|
97
|
+
escalate?: boolean;
|
|
90
98
|
}
|
|
91
99
|
/**
|
|
92
100
|
* The device's flow pack: kept in the host's storage (it works offline from the first open after a sync), refreshed with
|
package/dist/flows.js
CHANGED
|
@@ -279,6 +279,7 @@ export class DeviceFlows {
|
|
|
279
279
|
const says = [];
|
|
280
280
|
const blocks = [];
|
|
281
281
|
let code = null;
|
|
282
|
+
let escalate = false;
|
|
282
283
|
for (const step of flow.steps) {
|
|
283
284
|
this.seq++;
|
|
284
285
|
const input = obj(fillTemplate(step.input, slots));
|
|
@@ -295,12 +296,13 @@ export class DeviceFlows {
|
|
|
295
296
|
blocks.push(...r.blocks);
|
|
296
297
|
if (!r.ok) {
|
|
297
298
|
code = r.error ?? "device_error";
|
|
299
|
+
escalate = r.escalate === true;
|
|
298
300
|
break;
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
303
|
const ms = Math.max(0, t.now() - started);
|
|
302
304
|
this.note({ flowId: flow.id, version: this.version, ok: code === null, code, ms, offline, at: new Date(t.now()).toISOString() });
|
|
303
|
-
return { ok: code === null, flowId: flow.id, say: says.join("\n"), blocks, code, ms };
|
|
305
|
+
return { ok: code === null, flowId: flow.id, say: says.join("\n"), blocks, code, ms, ...(escalate ? { escalate: true } : {}) };
|
|
304
306
|
}
|
|
305
307
|
/** Unsent outcomes. */
|
|
306
308
|
get pending() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/aiassistant",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
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.9.
|
|
36
|
+
"@g9tm/aiassistant-contracts": "1.9.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json",
|