@g9tm/aiassistant-svelte 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.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// All the library's styling is here, under .g9a-styled, from theme tokens; unstyled leaves structure and classes only.
|
|
4
4
|
import type { Snippet } from "svelte";
|
|
5
5
|
import type { Assistant, PartStyles } from "@g9tm/aiassistant";
|
|
6
|
+
import { loadHostTexts, withHostTexts } from "@g9tm/aiassistant/pages";
|
|
6
7
|
import { provideUi, type Overrides } from "./context.js";
|
|
7
8
|
import { themeVars } from "./theme.js";
|
|
8
9
|
|
|
@@ -10,10 +11,14 @@
|
|
|
10
11
|
assistant: Assistant; styles?: PartStyles; unstyled?: boolean; components?: Overrides; children: Snippet;
|
|
11
12
|
} = $props();
|
|
12
13
|
|
|
14
|
+
// The host's server words (its AssistantSetup.Texts), read once: a host key the client does not know shows in words.
|
|
15
|
+
let own = $state<Readonly<Record<string, string>>>({});
|
|
16
|
+
$effect(() => { void loadHostTexts(assistant).then((o) => { own = o; }); });
|
|
17
|
+
|
|
13
18
|
// Getters, not copies: a host that switches unstyled, styles or a replaced component sees it at once.
|
|
14
19
|
provideUi({
|
|
15
20
|
get assistant() { return assistant; },
|
|
16
|
-
get texts() { return assistant.texts; },
|
|
21
|
+
get texts() { return withHostTexts(assistant.texts, () => own); },
|
|
17
22
|
get styles() { return styles; },
|
|
18
23
|
get unstyled() { return unstyled; },
|
|
19
24
|
get components() { return components; },
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// (click, PinPad, code), the taint warning. Confirming always goes through the core, bound to the plan's hash.
|
|
4
4
|
import type { PlanView } from "@g9tm/aiassistant";
|
|
5
5
|
import { needsCode } from "@g9tm/aiassistant";
|
|
6
|
+
import { pageTexts } from "@g9tm/aiassistant/pages";
|
|
6
7
|
import { cls, override, useUi } from "../context.js";
|
|
7
8
|
import PinPad from "../slots/PinPad.svelte";
|
|
8
9
|
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
<Pin bind:value={code} label={t("card.code")} />
|
|
46
47
|
{/if}
|
|
47
48
|
{#if plan.failCode === "confirm.waiting"}<p class="g9a-note" role="status">{t("card.waiting")}</p>
|
|
48
|
-
{:else if plan.failCode}<p class="g9a-note" role="alert">{plan.failCode}{#if plan.triesLeft !== null} · {t("card.tries_left", { count: plan.triesLeft })}{/if}</p>{/if}
|
|
49
|
+
{:else if plan.failCode}<p class="g9a-note" role="alert">{pageTexts(ui.texts).t(plan.failCode)}{#if plan.triesLeft !== null} · {t("card.tries_left", { count: plan.triesLeft })}{/if}</p>{/if}
|
|
49
50
|
<div class="g9a-row">
|
|
50
51
|
<button type="button" class={cls(ui, "card.approval.confirm")} disabled={busy || (needsCode(plan.method) && code.length === 0)} onclick={confirm}>{t("card.confirm")}</button>
|
|
51
52
|
<button type="button" class={cls(ui, "card.approval.refuse")} disabled={busy} onclick={() => ui.assistant.refuse(plan.id)}>{t("card.refuse")}</button>
|
package/dist/pages/Page.svelte
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
// The assistant's pages, each from its own endpoint, read with type checks only.
|
|
7
7
|
import { arr, num, obj, str } from "@g9tm/aiassistant";
|
|
8
|
+
import { pageTexts } from "@g9tm/aiassistant/pages";
|
|
8
9
|
import { cls, override, useUi } from "../context.js";
|
|
9
10
|
import History from "./History.svelte";
|
|
10
11
|
import RoutineWizard from "./RoutineWizard.svelte";
|
|
@@ -15,6 +16,8 @@
|
|
|
15
16
|
const api = ui.assistant.api;
|
|
16
17
|
let data = $state<Record<string, unknown>>({});
|
|
17
18
|
let error = $state<string | null>(null);
|
|
19
|
+
let loaded = $state(false); // an empty page says so only once its answer came
|
|
20
|
+
const empty = $derived(pageTexts(ui.texts).t("page." + kind + ".empty"));
|
|
18
21
|
let purpose = $state("");
|
|
19
22
|
let code = $state("");
|
|
20
23
|
let token = $state<string | null>(null);
|
|
@@ -31,6 +34,7 @@
|
|
|
31
34
|
} catch (e) {
|
|
32
35
|
error = e instanceof Error ? e.message : "error.network";
|
|
33
36
|
}
|
|
37
|
+
loaded = true;
|
|
34
38
|
}
|
|
35
39
|
// History and the routine wizard are their own (replaceable) pages and read their own data.
|
|
36
40
|
const Own = $derived(kind === "history" ? override(ui, "History") ?? History : kind === "routines" ? override(ui, "RoutineWizard") ?? RoutineWizard : null);
|
|
@@ -52,11 +56,12 @@
|
|
|
52
56
|
<ul>{#each arr(g["tools"]).map(obj) as tool (str(tool["name"]))}<li>{str(tool["title"], str(tool["name"]))}</li>{/each}</ul>
|
|
53
57
|
{/each}
|
|
54
58
|
{#each arr(data["closed"]).map(obj) as c (str(c["name"]))}<p class="g9a-note">{str(c["name"])} · {str(c["layer"])}</p>{/each}
|
|
59
|
+
{#if loaded && arr(data["groups"]).length === 0 && arr(data["closed"]).length === 0}<p class="g9a-note g9a-empty">{empty}</p>{/if}
|
|
55
60
|
{:else if kind === "knowledge"}
|
|
56
|
-
<ul>{#each arr(data["notes"] ?? data["items"]).map(obj) as n, i (i)}<li>{str(n["text"], str(n["name"]))}</li>{/each}</ul>
|
|
61
|
+
<ul>{#each arr(data["notes"] ?? data["items"]).map(obj) as n, i (i)}<li>{str(n["text"], str(n["name"]))}</li>{:else}{#if loaded}<li class="g9a-note g9a-empty">{empty}</li>{/if}{/each}</ul>
|
|
57
62
|
{:else if kind === "learned"}
|
|
58
63
|
<p>{Math.round(num(data["modelFreeRate"]) * 100)}% · {num(data["tokensSaved"])}</p>
|
|
59
|
-
<ul>{#each arr(data["items"]).map(obj) as it, i (i)}<li data-status={str(it["status"])}>{str(it["signature"])} · {str(it["status"])} · {num(it["hits"])}</li>{/each}</ul>
|
|
64
|
+
<ul>{#each arr(data["items"]).map(obj) as it, i (i)}<li data-status={str(it["status"])}>{str(it["signature"])} · {str(it["status"])} · {num(it["hits"])}</li>{:else}{#if loaded}<li class="g9a-note g9a-empty">{empty}</li>{/if}{/each}</ul>
|
|
60
65
|
{:else if kind === "findings"}
|
|
61
66
|
<ul>
|
|
62
67
|
{#each arr(data["findings"]).map(obj) as f (str(f["id"]))}
|
|
@@ -65,10 +70,12 @@
|
|
|
65
70
|
<button type="button" onclick={() => act("findings/" + encodeURIComponent(str(f["id"])) + "/fixed")}>✓</button>
|
|
66
71
|
<button type="button" onclick={() => act("findings/" + encodeURIComponent(str(f["id"])) + "/dismiss", { reason: "—" })}>{t("no")}</button>
|
|
67
72
|
</li>
|
|
73
|
+
{:else}
|
|
74
|
+
{#if loaded}<li class="g9a-note g9a-empty">{empty}</li>{/if}
|
|
68
75
|
{/each}
|
|
69
76
|
</ul>
|
|
70
77
|
{:else if kind === "actions"}
|
|
71
|
-
<ul>{#each [...ui.assistant.snapshot().plans.values()].filter((p) => p.answered === "confirmed") as p (p.id)}<li>{p.title} <button type="button" onclick={() => ui.assistant.undo(p.id)}>{t("undo.all")}</button></li>{/each}</ul>
|
|
78
|
+
<ul>{#each [...ui.assistant.snapshot().plans.values()].filter((p) => p.answered === "confirmed") as p (p.id)}<li>{p.title} <button type="button" onclick={() => ui.assistant.undo(p.id)}>{t("undo.all")}</button></li>{:else}<li class="g9a-note g9a-empty">{empty}</li>{/each}</ul>
|
|
72
79
|
{:else if kind === "admin"}
|
|
73
80
|
<form onsubmit={async (e) => { e.preventDefault(); const r = obj(await api.post("gates", { purpose, code }).catch(() => null)); token = str(r["token"]) || null; purpose = ""; code = ""; await load(); }}>
|
|
74
81
|
<input bind:value={purpose} placeholder="purpose" aria-label="purpose" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/aiassistant-svelte",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Svelte 5 components for the G9 AI assistant, fully customisable (layouts, tokens, per-part classes, overrides, parts).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@g9tm/aiassistant": "1.
|
|
34
|
+
"@g9tm/aiassistant": "1.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@sveltejs/package": "2.5.8",
|