@g9tm/aiassistant-svelte 1.8.1 → 1.9.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/AssistantRoot.svelte +143 -135
- package/dist/blocks/BlockView.svelte +110 -84
- package/dist/blocks/BlockView.svelte.d.ts +1 -0
- package/dist/blocks/TourCard.svelte +34 -0
- package/dist/blocks/TourCard.svelte.d.ts +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/parts/Composer.svelte +50 -3
- package/dist/parts/Message.svelte +8 -5
- package/dist/parts/Message.svelte.d.ts +1 -0
- package/dist/parts/MessageList.svelte +16 -5
- package/dist/parts/WorkCard.svelte +2 -0
- package/package.json +2 -2
|
@@ -1,135 +1,143 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
// The root of one assistant: shares the core, texts, part styles, overrides and theme with every component inside.
|
|
3
|
-
// All the library's styling is here, under .g9a-styled, from theme tokens; unstyled leaves structure and classes only.
|
|
4
|
-
import type { Snippet } from "svelte";
|
|
5
|
-
import type { Assistant, PartStyles } from "@g9tm/aiassistant";
|
|
6
|
-
import { loadHostTexts, withHostTexts } from "@g9tm/aiassistant/pages";
|
|
7
|
-
import { provideUi, type Overrides } from "./context.js";
|
|
8
|
-
import { themeVars } from "./theme.js";
|
|
9
|
-
|
|
10
|
-
let { assistant, styles = {}, unstyled = false, components = {}, children }: {
|
|
11
|
-
assistant: Assistant; styles?: PartStyles; unstyled?: boolean; components?: Overrides; children: Snippet;
|
|
12
|
-
} = $props();
|
|
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
|
-
|
|
18
|
-
// Getters, not copies: a host that switches unstyled, styles or a replaced component sees it at once.
|
|
19
|
-
provideUi({
|
|
20
|
-
get assistant() { return assistant; },
|
|
21
|
-
get texts() { return withHostTexts(assistant.texts, () => own); },
|
|
22
|
-
get styles() { return styles; },
|
|
23
|
-
get unstyled() { return unstyled; },
|
|
24
|
-
get components() { return components; },
|
|
25
|
-
get layer() { return (assistant.host.sheetLayer ?? 1000) + 1; },
|
|
26
|
-
});
|
|
27
|
-
const vars = $derived(unstyled ? "" : themeVars(assistant.host.theme));
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<div class={unstyled ? "g9a-root" : "g9a-root g9a-styled"} dir={assistant.host.dir} lang={assistant.host.locale} style={vars}>
|
|
31
|
-
{@render children()}
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
<style>
|
|
35
|
-
.g9a-root { display: contents; }
|
|
36
|
-
.g9a-styled { font-family: var(--g9a-font); font-size: var(--g9a-font-size); color: var(--g9a-ink); line-height: 1.6; }
|
|
37
|
-
.g9a-styled :global(button) { font: inherit; cursor: pointer; min-block-size: 38px; padding: 0 12px; border-radius: var(--g9a-radius-s); border: 1px solid var(--g9a-line); background: var(--g9a-surface); color: var(--g9a-ink); }
|
|
38
|
-
.g9a-styled :global(input), .g9a-styled :global(textarea) { font: inherit; padding: 8px 10px; border: 1px solid var(--g9a-line); border-radius: var(--g9a-radius-s); background: var(--g9a-surface); color: var(--g9a-ink); }
|
|
39
|
-
.g9a-styled :global(.g9a-panel) { box-sizing: border-box; display: flex; flex-direction: column; background: var(--g9a-surface); color: var(--g9a-ink); box-shadow: var(--g9a-shadow); overflow: hidden; }
|
|
40
|
-
.g9a-styled :global(.g9a-panel[data-layout="side"]) { position: fixed; inset-block: 0; inset-inline-end: 0; inline-size: min(420px, 100%); border-inline-start: 1px solid var(--g9a-line); }
|
|
41
|
-
.g9a-styled :global(.g9a-panel[data-layout="sheet"]) { position: fixed; inset-inline: 0; inset-block-end: 0; block-size: 85vh; border-start-start-radius: 16px; border-start-end-radius: 16px; }
|
|
42
|
-
.g9a-styled :global(.g9a-panel[data-layout="fullscreen"]) { position: fixed; inset: 0; }
|
|
43
|
-
.g9a-styled :global(.g9a-panel[data-layout="inline"]) { inline-size: 100%; block-size: 100%; box-shadow: none; border: 1px solid var(--g9a-line); border-radius: var(--g9a-radius); }
|
|
44
|
-
.g9a-styled :global(.g9a-panel[data-layout="card"]) { border-radius: var(--g9a-radius); border: 1px solid var(--g9a-line); max-block-size: 520px; }
|
|
45
|
-
.g9a-styled :global(.g9a-panel[data-layout="compact"]) { box-shadow: none; }
|
|
46
|
-
.g9a-styled :global(.g9a-panel__header) { display: flex; align-items: center; gap: var(--g9a-gap); padding: var(--g9a-pad); border-bottom: 1px solid var(--g9a-line); }
|
|
47
|
-
.g9a-styled :global(.g9a-panel__header > strong) { flex: 1; min-inline-size: 0; }
|
|
48
|
-
.g9a-styled :global(.g9a-panel__body), .g9a-styled :global(.g9a-chat) { display: flex; flex-direction: column; flex: 1; min-block-size: 0; }
|
|
49
|
-
.g9a-styled :global(.g9a-messages) { flex: 1; overflow-y: auto; padding: var(--g9a-pad); display: flex; flex-direction: column; gap: var(--g9a-gap); }
|
|
50
|
-
.g9a-styled :global(.g9a-
|
|
51
|
-
.g9a-styled :global(.g9a-
|
|
52
|
-
.g9a-styled :global(.g9a-
|
|
53
|
-
.g9a-styled :global(.g9a-
|
|
54
|
-
.g9a-styled :global(.g9a-
|
|
55
|
-
.g9a-styled :global(.g9a-
|
|
56
|
-
.g9a-styled :global(.g9a-
|
|
57
|
-
.g9a-styled :global(.g9a-
|
|
58
|
-
.g9a-styled :global(
|
|
59
|
-
.g9a-styled :global(
|
|
60
|
-
.g9a-styled :global(.g9a-
|
|
61
|
-
.g9a-styled :global(.g9a-
|
|
62
|
-
.g9a-styled :global(.g9a-
|
|
63
|
-
.g9a-styled :global(.g9a-
|
|
64
|
-
.g9a-styled :global(
|
|
65
|
-
.g9a-styled :global(
|
|
66
|
-
.g9a-styled :global(
|
|
67
|
-
.g9a-styled :global(.g9a-
|
|
68
|
-
.g9a-styled :global(.g9a-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.g9a-styled :global(.g9a-
|
|
72
|
-
.g9a-styled :global(.g9a-
|
|
73
|
-
.g9a-styled :global(.g9a-
|
|
74
|
-
.g9a-styled :global(.g9a-
|
|
75
|
-
|
|
76
|
-
.g9a-styled :global(.g9a-
|
|
77
|
-
.g9a-styled :global(.g9a-
|
|
78
|
-
.g9a-styled :global(.g9a-
|
|
79
|
-
.g9a-styled :global(.g9a-
|
|
80
|
-
.g9a-styled :global(.g9a-
|
|
81
|
-
.g9a-styled :global(.g9a-
|
|
82
|
-
.g9a-styled :global(.g9a-
|
|
83
|
-
.g9a-styled :global(.g9a-
|
|
84
|
-
.g9a-styled :global(.g9a-
|
|
85
|
-
.g9a-styled :global(.g9a-
|
|
86
|
-
.g9a-styled :global(.g9a-
|
|
87
|
-
|
|
88
|
-
.g9a-styled :global(.g9a-
|
|
89
|
-
.g9a-styled :global(.g9a-
|
|
90
|
-
.g9a-styled :global(.g9a-
|
|
91
|
-
.g9a-styled :global(.g9a-
|
|
92
|
-
.g9a-styled :global(
|
|
93
|
-
|
|
94
|
-
.g9a-styled :global(.g9a-
|
|
95
|
-
.g9a-styled :global(.g9a-
|
|
96
|
-
|
|
97
|
-
.g9a-styled :global(
|
|
98
|
-
.g9a-styled :global(.g9a-
|
|
99
|
-
.g9a-styled :global(.g9a-
|
|
100
|
-
.g9a-styled :global(.g9a-
|
|
101
|
-
.g9a-styled :global(.g9a-
|
|
102
|
-
.g9a-styled :global(.g9a-
|
|
103
|
-
.g9a-styled :global(.g9a-
|
|
104
|
-
.g9a-styled :global(.g9a-
|
|
105
|
-
.g9a-styled :global(.g9a-
|
|
106
|
-
.g9a-styled :global(.g9a-
|
|
107
|
-
.g9a-styled :global(.g9a-
|
|
108
|
-
.g9a-styled :global(.g9a-
|
|
109
|
-
.g9a-styled :global(.g9a-
|
|
110
|
-
.g9a-styled :global(.g9a-
|
|
111
|
-
.g9a-styled :global(.g9a-
|
|
112
|
-
.g9a-styled :global(.g9a-
|
|
113
|
-
.g9a-styled :global(
|
|
114
|
-
.g9a-styled :global(.g9a-
|
|
115
|
-
.g9a-styled :global(.g9a-
|
|
116
|
-
.g9a-styled :global(.g9a-
|
|
117
|
-
.g9a-styled :global(.g9a-
|
|
118
|
-
.g9a-styled :global(.g9a-
|
|
119
|
-
.g9a-styled :global(.g9a-
|
|
120
|
-
.g9a-styled :global(.g9a-
|
|
121
|
-
.g9a-styled :global(.g9a-
|
|
122
|
-
.g9a-styled :global(.g9a-
|
|
123
|
-
.g9a-styled :global(.g9a-
|
|
124
|
-
.g9a-styled :global(.g9a-
|
|
125
|
-
.g9a-styled :global(.g9a-
|
|
126
|
-
.g9a-styled :global(.g9a-
|
|
127
|
-
.g9a-styled :global(.g9a-
|
|
128
|
-
.g9a-styled :global(.g9a-
|
|
129
|
-
.g9a-styled :global(.g9a-
|
|
130
|
-
.g9a-styled :global(.g9a-
|
|
131
|
-
.g9a-styled :global(.g9a-
|
|
132
|
-
.g9a-styled :global(.g9a-
|
|
133
|
-
.g9a-styled :global(.g9a-
|
|
134
|
-
.g9a-styled :global(.g9a-
|
|
135
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// The root of one assistant: shares the core, texts, part styles, overrides and theme with every component inside.
|
|
3
|
+
// All the library's styling is here, under .g9a-styled, from theme tokens; unstyled leaves structure and classes only.
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
import type { Assistant, PartStyles } from "@g9tm/aiassistant";
|
|
6
|
+
import { loadHostTexts, withHostTexts } from "@g9tm/aiassistant/pages";
|
|
7
|
+
import { provideUi, type Overrides } from "./context.js";
|
|
8
|
+
import { themeVars } from "./theme.js";
|
|
9
|
+
|
|
10
|
+
let { assistant, styles = {}, unstyled = false, components = {}, children }: {
|
|
11
|
+
assistant: Assistant; styles?: PartStyles; unstyled?: boolean; components?: Overrides; children: Snippet;
|
|
12
|
+
} = $props();
|
|
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
|
+
|
|
18
|
+
// Getters, not copies: a host that switches unstyled, styles or a replaced component sees it at once.
|
|
19
|
+
provideUi({
|
|
20
|
+
get assistant() { return assistant; },
|
|
21
|
+
get texts() { return withHostTexts(assistant.texts, () => own); },
|
|
22
|
+
get styles() { return styles; },
|
|
23
|
+
get unstyled() { return unstyled; },
|
|
24
|
+
get components() { return components; },
|
|
25
|
+
get layer() { return (assistant.host.sheetLayer ?? 1000) + 1; },
|
|
26
|
+
});
|
|
27
|
+
const vars = $derived(unstyled ? "" : themeVars(assistant.host.theme));
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<div class={unstyled ? "g9a-root" : "g9a-root g9a-styled"} dir={assistant.host.dir} lang={assistant.host.locale} style={vars}>
|
|
31
|
+
{@render children()}
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.g9a-root { display: contents; }
|
|
36
|
+
.g9a-styled { font-family: var(--g9a-font); font-size: var(--g9a-font-size); color: var(--g9a-ink); line-height: 1.6; }
|
|
37
|
+
.g9a-styled :global(button) { font: inherit; cursor: pointer; min-block-size: 38px; padding: 0 12px; border-radius: var(--g9a-radius-s); border: 1px solid var(--g9a-line); background: var(--g9a-surface); color: var(--g9a-ink); }
|
|
38
|
+
.g9a-styled :global(input), .g9a-styled :global(textarea) { font: inherit; padding: 8px 10px; border: 1px solid var(--g9a-line); border-radius: var(--g9a-radius-s); background: var(--g9a-surface); color: var(--g9a-ink); }
|
|
39
|
+
.g9a-styled :global(.g9a-panel) { box-sizing: border-box; display: flex; flex-direction: column; background: var(--g9a-surface); color: var(--g9a-ink); box-shadow: var(--g9a-shadow); overflow: hidden; }
|
|
40
|
+
.g9a-styled :global(.g9a-panel[data-layout="side"]) { position: fixed; inset-block: 0; inset-inline-end: 0; inline-size: min(420px, 100%); border-inline-start: 1px solid var(--g9a-line); }
|
|
41
|
+
.g9a-styled :global(.g9a-panel[data-layout="sheet"]) { position: fixed; inset-inline: 0; inset-block-end: 0; block-size: 85vh; border-start-start-radius: 16px; border-start-end-radius: 16px; }
|
|
42
|
+
.g9a-styled :global(.g9a-panel[data-layout="fullscreen"]) { position: fixed; inset: 0; }
|
|
43
|
+
.g9a-styled :global(.g9a-panel[data-layout="inline"]) { inline-size: 100%; block-size: 100%; box-shadow: none; border: 1px solid var(--g9a-line); border-radius: var(--g9a-radius); }
|
|
44
|
+
.g9a-styled :global(.g9a-panel[data-layout="card"]) { border-radius: var(--g9a-radius); border: 1px solid var(--g9a-line); max-block-size: 520px; }
|
|
45
|
+
.g9a-styled :global(.g9a-panel[data-layout="compact"]) { box-shadow: none; }
|
|
46
|
+
.g9a-styled :global(.g9a-panel__header) { display: flex; align-items: center; gap: var(--g9a-gap); padding: var(--g9a-pad); border-bottom: 1px solid var(--g9a-line); }
|
|
47
|
+
.g9a-styled :global(.g9a-panel__header > strong) { flex: 1; min-inline-size: 0; }
|
|
48
|
+
.g9a-styled :global(.g9a-panel__body), .g9a-styled :global(.g9a-chat) { display: flex; flex-direction: column; flex: 1; min-block-size: 0; }
|
|
49
|
+
.g9a-styled :global(.g9a-messages) { flex: 1; overflow-y: auto; padding: var(--g9a-pad); display: flex; flex-direction: column; gap: var(--g9a-gap); }
|
|
50
|
+
.g9a-styled :global(.g9a-messages-frame) { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
|
|
51
|
+
.g9a-styled :global(.g9a-messages[data-selectable="true"]) { user-select: text; -webkit-user-select: text; }
|
|
52
|
+
.g9a-styled :global(.g9a-messages__newest) { position: absolute; bottom: 8px; inset-inline-start: 50%; transform: translateX(-50%); }
|
|
53
|
+
.g9a-styled :global(.g9a-list) { margin: 0 0 6px; padding-inline-start: 1.4em; }
|
|
54
|
+
.g9a-styled :global(.g9a-list li) { padding-inline-start: 0.2em; }
|
|
55
|
+
.g9a-styled :global(.g9a-composer__menu), .g9a-styled :global(.g9a-block__entities), .g9a-styled :global(.g9a-tour-nav) { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
56
|
+
.g9a-styled :global(.g9a-message) { max-inline-size: 88%; padding: 8px 12px; border-radius: var(--g9a-radius); background: var(--g9a-surface-2); }
|
|
57
|
+
.g9a-styled :global(.g9a-message__user) { align-self: flex-start; background: var(--g9a-user-bubble, color-mix(in srgb, var(--g9a-accent) 12%, var(--g9a-surface))); }
|
|
58
|
+
.g9a-styled :global(.g9a-message__assistant) { align-self: flex-end; }
|
|
59
|
+
.g9a-styled :global(.g9a-message[data-pending="true"]) { opacity: .7; }
|
|
60
|
+
.g9a-styled :global(.g9a-message__feedback) { display: flex; gap: 6px; align-items: center; margin-block-start: 4px; }
|
|
61
|
+
.g9a-styled :global(.g9a-message__feedback button) { min-block-size: 26px; font-size: 12px; padding: 0 8px; }
|
|
62
|
+
.g9a-styled :global(.g9a-message__provenance) { font-size: 11px; color: var(--g9a-muted); }
|
|
63
|
+
.g9a-styled :global(.g9a-p) { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
64
|
+
.g9a-styled :global(code) { font-family: ui-monospace, monospace; background: var(--g9a-surface); border-radius: 4px; padding: 0 4px; }
|
|
65
|
+
.g9a-styled :global(a) { color: var(--g9a-accent); }
|
|
66
|
+
.g9a-styled :global(.g9a-work) { display: flex; gap: var(--g9a-gap); align-items: flex-start; padding: var(--g9a-pad); border-top: 1px solid var(--g9a-line); }
|
|
67
|
+
.g9a-styled :global(.g9a-work-main) { flex: 1; min-inline-size: 0; }
|
|
68
|
+
.g9a-styled :global(.g9a-work-head) { display: flex; justify-content: space-between; gap: var(--g9a-gap); }
|
|
69
|
+
.g9a-styled :global(.g9a-work__elapsed), .g9a-styled :global(.g9a-work__tool), .g9a-styled :global(.g9a-note) { color: var(--g9a-muted); font-size: 12px; }
|
|
70
|
+
.g9a-styled :global(.g9a-stages), .g9a-styled :global(.g9a-stages-thinking) { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 4px; }
|
|
71
|
+
.g9a-styled :global(.g9a-work__stage), .g9a-styled :global(.g9a-stages-thinking > span) { padding: 1px 10px; border-radius: 999px; border: 1px solid var(--g9a-line); font-size: 12px; color: var(--g9a-muted); }
|
|
72
|
+
.g9a-styled :global([data-state="on"].g9a-work__stage), .g9a-styled :global(.g9a-stages-thinking > [data-state="on"]) { background: color-mix(in srgb, var(--g9a-accent) 20%, transparent); color: var(--g9a-ink); border-color: var(--g9a-accent); }
|
|
73
|
+
.g9a-styled :global(.g9a-thinking-orb) { inline-size: 18px; block-size: 18px; border-radius: 50%; background: var(--g9a-accent); animation: g9a-pulse 1.2s ease-in-out infinite; flex: none; margin-block-start: 4px; }
|
|
74
|
+
.g9a-styled :global(.g9a-thinking-orb[data-still="true"]) { animation: none; }
|
|
75
|
+
@keyframes -global-g9a-pulse { 0%, 100% { transform: scale(.8); opacity: .6; } 50% { transform: scale(1); opacity: 1; } }
|
|
76
|
+
@media (prefers-reduced-motion: reduce) { .g9a-styled :global(.g9a-thinking-orb) { animation: none; } }
|
|
77
|
+
.g9a-styled :global(.g9a-composer) { padding: var(--g9a-pad); border-top: 1px solid var(--g9a-line); }
|
|
78
|
+
.g9a-styled :global(.g9a-composer-row) { display: flex; gap: var(--g9a-gap); align-items: flex-end; }
|
|
79
|
+
.g9a-styled :global(.g9a-composer__input) { flex: 1; min-inline-size: 0; resize: none; max-block-size: 30vh; }
|
|
80
|
+
.g9a-styled :global(.g9a-composer__send) { background: var(--g9a-accent); color: var(--g9a-accent-ink); border-color: var(--g9a-accent); }
|
|
81
|
+
.g9a-styled :global(.g9a-file-chips) { display: flex; flex-wrap: wrap; gap: 4px; margin-block-end: 6px; }
|
|
82
|
+
.g9a-styled :global(.g9a-file-chip) { background: var(--g9a-surface-2); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; }
|
|
83
|
+
.g9a-styled :global(.g9a-file-chip button) { min-block-size: 20px; border: 0; background: none; padding: 0 6px; }
|
|
84
|
+
.g9a-styled :global(.g9a-card__approval) { border: 1px solid var(--g9a-approval-card-border); border-radius: var(--g9a-radius); padding: var(--g9a-pad); background: var(--g9a-surface); }
|
|
85
|
+
.g9a-styled :global(.g9a-card__approval h3) { margin: 0 0 6px; font-size: 15px; }
|
|
86
|
+
.g9a-styled :global(.g9a-card__approval__fact) { font-size: 12px; color: var(--g9a-muted); padding-inline-start: 24px; }
|
|
87
|
+
.g9a-styled :global(.g9a-card__approval__confirm) { background: var(--g9a-accent); color: var(--g9a-accent-ink); border-color: var(--g9a-accent); }
|
|
88
|
+
.g9a-styled :global(.g9a-warning) { color: var(--g9a-warn); font-size: 13px; }
|
|
89
|
+
.g9a-styled :global(.g9a-irreversible) { color: var(--g9a-danger); font-size: 12px; }
|
|
90
|
+
.g9a-styled :global(.g9a-row) { display: flex; gap: var(--g9a-gap); margin-block-start: 8px; }
|
|
91
|
+
.g9a-styled :global(.g9a-mode-banner) { background: var(--g9a-surface-2); border-bottom: 1px solid var(--g9a-line); color: var(--g9a-warn); padding: 6px var(--g9a-pad); font-size: 13px; }
|
|
92
|
+
.g9a-styled :global(.g9a-usage-chip) { display: inline-block; block-size: 22px; line-height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px;
|
|
93
|
+
background: linear-gradient(to left, var(--g9a-surface-2) calc(100% - var(--g9a-usage)), color-mix(in srgb, var(--g9a-accent) 25%, transparent) 0); }
|
|
94
|
+
.g9a-styled :global(.g9a-tabs) { display: flex; gap: 4px; border-bottom: 1px solid var(--g9a-line); margin-block-end: 8px; }
|
|
95
|
+
.g9a-styled :global(.g9a-tabs [aria-selected="true"]) { border-bottom: 2px solid var(--g9a-accent); }
|
|
96
|
+
/* A page placed in the host's own page carries the theme's surface, so a dark theme never writes light ink on a light page. */
|
|
97
|
+
.g9a-styled :global([data-page]) { background: var(--g9a-surface); color: var(--g9a-ink); border-radius: var(--g9a-radius-s); }
|
|
98
|
+
.g9a-styled :global(.g9a-admin-capability) { border: 1px solid var(--g9a-line); border-radius: 8px; padding: 8px; margin-block-end: 8px; display: grid; gap: 4px; }
|
|
99
|
+
.g9a-styled :global(.g9a-admin-capability label) { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
|
|
100
|
+
.g9a-styled :global([data-bad="true"]), .g9a-styled :global([data-ok="false"]) { color: var(--g9a-danger); }
|
|
101
|
+
.g9a-styled :global(.g9a-block-title) { font-weight: 600; margin-block: 4px; }
|
|
102
|
+
.g9a-styled :global(.g9a-block__table table) { border-collapse: collapse; inline-size: 100%; font-size: 13px; }
|
|
103
|
+
.g9a-styled :global(.g9a-block__table th), .g9a-styled :global(.g9a-block__table td) { border-bottom: 1px solid var(--g9a-line); padding: 4px 6px; text-align: start; }
|
|
104
|
+
.g9a-styled :global([data-kind="number"]), .g9a-styled :global([data-kind="money"]), .g9a-styled :global([data-kind="percent"]) { text-align: end; font-variant-numeric: tabular-nums; }
|
|
105
|
+
.g9a-styled :global(.g9a-block__table__card) { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 6px; padding: 6px 8px; background: var(--g9a-surface); border-radius: var(--g9a-radius-s); }
|
|
106
|
+
.g9a-styled :global(.g9a-block__table__card dt) { color: var(--g9a-muted); }
|
|
107
|
+
.g9a-styled :global(.g9a-block__table__card dd) { margin: 0; }
|
|
108
|
+
.g9a-styled :global(.g9a-block__chart__bar) { display: grid; grid-template-columns: 1fr; gap: 2px; margin-block-end: 6px; }
|
|
109
|
+
.g9a-styled :global(.g9a-bar-track) { display: block; block-size: 10px; background: var(--g9a-surface); border-radius: 5px; overflow: hidden; }
|
|
110
|
+
.g9a-styled :global(.g9a-bar-fill) { display: block; block-size: 100%; background: var(--g9a-chart-bar); border-radius: 5px; }
|
|
111
|
+
.g9a-styled :global(.g9a-bar-value) { font-size: 12px; color: var(--g9a-muted); }
|
|
112
|
+
.g9a-styled :global(.g9a-block__chart__line) { inline-size: 100%; block-size: 140px; }
|
|
113
|
+
.g9a-styled :global(.g9a-block__chart__line path) { stroke: var(--g9a-chart-bar); stroke-width: 2; }
|
|
114
|
+
.g9a-styled :global(.g9a-donut) { inline-size: 120px; }
|
|
115
|
+
.g9a-styled :global(.g9a-donut path) { fill: none; stroke: var(--g9a-chart-bar); stroke-width: 14; }
|
|
116
|
+
.g9a-styled :global(.g9a-block__kpi) { display: flex; flex-wrap: wrap; gap: var(--g9a-gap); }
|
|
117
|
+
.g9a-styled :global(.g9a-block__kpi > div) { display: flex; flex-direction: column; padding: 6px 10px; background: var(--g9a-surface); border-radius: var(--g9a-radius-s); }
|
|
118
|
+
.g9a-styled :global(.g9a-block__actions) { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 6px; }
|
|
119
|
+
.g9a-styled :global(.g9a-block__action) { background: color-mix(in srgb, var(--g9a-accent) 12%, var(--g9a-surface)); border-color: var(--g9a-accent); }
|
|
120
|
+
.g9a-styled :global(.g9a-block__action::after) { content: " ‹"; }
|
|
121
|
+
.g9a-styled :global([dir="ltr"] .g9a-block__action::after) { content: " ›"; }
|
|
122
|
+
.g9a-styled :global(.g9a-suggested) { font-size: 10px; color: var(--g9a-muted); margin-inline-start: 6px; }
|
|
123
|
+
.g9a-styled :global(.g9a-block__callout) { border-inline-start: 3px solid var(--g9a-accent); padding: 6px 10px; background: var(--g9a-surface); }
|
|
124
|
+
.g9a-styled :global(.g9a-block__callout[data-tone="danger"]) { border-color: var(--g9a-danger); }
|
|
125
|
+
.g9a-styled :global(.g9a-block__callout[data-tone="warn"]) { border-color: var(--g9a-warn); }
|
|
126
|
+
.g9a-styled :global(.g9a-block__image img) { max-inline-size: 100%; border-radius: var(--g9a-radius-s); }
|
|
127
|
+
.g9a-styled :global(.g9a-dialog) { position: fixed; inset: 10% 8%; background: var(--g9a-surface); border-radius: var(--g9a-radius); box-shadow: var(--g9a-shadow); padding: var(--g9a-pad); overflow: auto; }
|
|
128
|
+
.g9a-styled :global(.g9a-hero) { padding: var(--g9a-pad); border: 1px solid var(--g9a-line); border-radius: var(--g9a-radius); background: var(--g9a-surface); }
|
|
129
|
+
.g9a-styled :global(.g9a-badge) { margin-inline-start: 6px; background: var(--g9a-danger); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; }
|
|
130
|
+
.g9a-styled :global(.g9a-measure) { inline-size: 100%; block-size: 0; }
|
|
131
|
+
.g9a-styled :global(.g9a-count) { font-size: 11px; color: var(--g9a-muted); margin-inline-start: 4px; }
|
|
132
|
+
.g9a-styled :global(.g9a-history__list), .g9a-styled :global(.g9a-routines__list), .g9a-styled :global(.g9a-picker__list) { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
|
|
133
|
+
.g9a-styled :global(.g9a-history__row) { display: flex; gap: 4px; align-items: center; }
|
|
134
|
+
.g9a-styled :global(.g9a-history__open) { flex: 1; min-inline-size: 0; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
135
|
+
.g9a-styled :global(.g9a-history__row[data-waiting="true"] .g9a-history__open) { border-color: var(--g9a-warn); }
|
|
136
|
+
.g9a-styled :global(.g9a-history__delete), .g9a-styled :global(.g9a-history__delete-yes) { color: var(--g9a-danger); }
|
|
137
|
+
.g9a-styled :global(.g9a-routines__form) { display: grid; gap: var(--g9a-gap); }
|
|
138
|
+
.g9a-styled :global(.g9a-routines__slot) { display: grid; gap: 2px; }
|
|
139
|
+
.g9a-styled :global(.g9a-routines__slot[data-state="missing"] input), .g9a-styled :global(.g9a-routines__slot[data-state="invalid"] input) { border-color: var(--g9a-danger); }
|
|
140
|
+
.g9a-styled :global(.g9a-routines__choose) { inline-size: 100%; text-align: start; }
|
|
141
|
+
.g9a-styled :global(.g9a-picker__chosen) { font-weight: 600; margin-inline-end: 6px; }
|
|
142
|
+
.g9a-styled :global(.g9a-csv) { display: flex; gap: 6px; align-items: center; margin-block: 4px; }
|
|
143
|
+
</style>
|
|
@@ -1,84 +1,110 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
// Every block type from the core's view model; the host may replace any type (including its x:* blocks). A block no
|
|
3
|
-
// renderer knows shows its fallback text, never an error or a hole.
|
|
4
|
-
import { blockView, can, obj } from "@g9tm/aiassistant";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
{#if view.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
{:else if view.type === "
|
|
79
|
-
<
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
{
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Every block type from the core's view model; the host may replace any type (including its x:* blocks). A block no
|
|
3
|
+
// renderer knows shows its fallback text, never an error or a hole.
|
|
4
|
+
import { blockView, can, obj } from "@g9tm/aiassistant";
|
|
5
|
+
import { chatOf, guideBlock, openPage, pageTexts, tableText } from "@g9tm/aiassistant/pages";
|
|
6
|
+
import { blockOverride, cls, override, useUi } from "../context.js";
|
|
7
|
+
import Chart from "./Chart.svelte";
|
|
8
|
+
import CsvButton from "./CsvButton.svelte";
|
|
9
|
+
import TextView from "../parts/TextView.svelte";
|
|
10
|
+
import TourCard from "./TourCard.svelte";
|
|
11
|
+
|
|
12
|
+
let { block, compact = false, at = "tour" }: { block: unknown; compact?: boolean; at?: string } = $props();
|
|
13
|
+
let copied = $state(false);
|
|
14
|
+
async function copy(text: string): Promise<void> {
|
|
15
|
+
await ui.assistant.host.copy?.(text);
|
|
16
|
+
copied = true;
|
|
17
|
+
}
|
|
18
|
+
const ui = useUi();
|
|
19
|
+
const t = ui.texts.t;
|
|
20
|
+
const pt = pageTexts(ui.texts).t;
|
|
21
|
+
const guide = $derived(guideBlock(block));
|
|
22
|
+
const view = $derived(blockView(block, ui.texts.locale, ui.assistant.customBlocks));
|
|
23
|
+
const custom = $derived(blockOverride(ui, guide ? guide.type : view.type === "custom" ? view.name : view.type));
|
|
24
|
+
const Csv = $derived(override(ui, "CsvButton") ?? CsvButton);
|
|
25
|
+
// A table's file has the raw values (the export view of the same rows), not the text drawn for reading.
|
|
26
|
+
const raw = $derived(view.type === "table" ? blockView({ ...obj(block), type: "export" }, ui.texts.locale) : null);
|
|
27
|
+
let open = $state(false);
|
|
28
|
+
const fileUrl = (id: string): string => "/api/assistant/files/" + encodeURIComponent(id); // only the server's own files
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
{#if custom}
|
|
32
|
+
{@const Custom = custom}
|
|
33
|
+
<Custom view={guide ?? view} {block} {compact} />
|
|
34
|
+
{:else if guide?.type === "tour"}
|
|
35
|
+
<TourCard view={guide} {at} />
|
|
36
|
+
{:else if guide?.type === "draft"}
|
|
37
|
+
<div class={cls(ui, "block.draft")}>
|
|
38
|
+
{#if ui.assistant.host.openDraft}
|
|
39
|
+
<button type="button" class={cls(ui, "block.action")} data-role="draft" onclick={() => { if (guide?.type === "draft") ui.assistant.host.openDraft?.({ kind: guide.kind, values: guide.values, ...(guide.page ? { page: guide.page } : {}), ...(guide.subject ? { subject: guide.subject } : {}), ...(guide.label ? { label: guide.label } : {}) }); }}>{guide.label ?? pt("draft.open")}</button>
|
|
40
|
+
{:else}{guide.label ?? guide.fallbackText}{/if}
|
|
41
|
+
</div>
|
|
42
|
+
{:else if guide?.type === "entities"}
|
|
43
|
+
{#if ui.assistant.host.openEntity && guide.items.length > 0}
|
|
44
|
+
<div class={cls(ui, "block.entities")}>{#each guide.items as e (e.kind + ":" + e.id)}<button type="button" data-role="entity" onclick={() => ui.assistant.host.openEntity?.(e)}>{e.text}</button>{/each}</div>
|
|
45
|
+
{/if}
|
|
46
|
+
{:else if view.type === "text"}
|
|
47
|
+
<div class={cls(ui, "block.text")}><TextView text={view.text} /></div>
|
|
48
|
+
{:else if view.type === "callout"}
|
|
49
|
+
<div class={cls(ui, "block.callout")} data-tone={view.tone}><TextView text={view.text} /></div>
|
|
50
|
+
{:else if view.type === "table"}
|
|
51
|
+
<div class={cls(ui, "block.table")}>
|
|
52
|
+
{#if view.title}<div class="g9a-block-title">{view.title}</div>{/if}
|
|
53
|
+
{#if view.asCards || compact}
|
|
54
|
+
{#each view.rows.slice(0, open ? view.rows.length : view.shown) as row, r (r)}
|
|
55
|
+
<dl class={cls(ui, "block.table.card")}>
|
|
56
|
+
{#each view.columns as c, i (c.name)}<dt>{c.label}</dt><dd data-kind={c.kind}>{row[i]}</dd>{/each}
|
|
57
|
+
</dl>
|
|
58
|
+
{/each}
|
|
59
|
+
{:else}
|
|
60
|
+
<table>
|
|
61
|
+
<thead><tr>{#each view.columns as c (c.name)}<th data-kind={c.kind}>{c.label}</th>{/each}</tr></thead>
|
|
62
|
+
<tbody>
|
|
63
|
+
{#each view.rows.slice(0, open ? view.rows.length : view.shown) as row, r (r)}
|
|
64
|
+
<tr>{#each row as v, i (i)}<td data-kind={view.columns[i]?.kind}>{v}</td>{/each}</tr>
|
|
65
|
+
{/each}
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>
|
|
68
|
+
{/if}
|
|
69
|
+
{#if view.more > 0 && !open}<button type="button" class="g9a-more" onclick={() => (open = true)}>{t("block.more_rows", { count: view.more })}</button>{/if}
|
|
70
|
+
</div>
|
|
71
|
+
{#if raw?.type === "export"}<Csv title={view.title} labels={raw.columns.map((c) => c.label)} rows={raw.rows} />{/if}
|
|
72
|
+
{#if chatOf(ui.assistant).copyParts && ui.assistant.host.copy}<button type="button" class="g9a-copy" data-role="copy" onclick={() => copy(tableText(view.type === "table" ? view.columns.map((c) => c.label) : [], view.type === "table" ? view.rows : []))}>{copied ? pt("copy.done") : pt("copy.table")}</button>{/if}
|
|
73
|
+
{:else if view.type === "export"}
|
|
74
|
+
<div class={cls(ui, "block") + " g9a-block__export"}>
|
|
75
|
+
{#if view.title}<div class="g9a-block-title">{view.title}</div>{/if}
|
|
76
|
+
{#if can(ui.assistant.host, "save")}<Csv title={view.title} labels={view.columns.map((c) => c.label)} rows={view.rows} />{:else}<div>{view.fallbackText}</div>{/if}
|
|
77
|
+
</div>
|
|
78
|
+
{:else if view.type === "chart"}
|
|
79
|
+
<div class={cls(ui, "block.chart")}>
|
|
80
|
+
{#if view.title}<div class="g9a-block-title">{view.title}</div>{/if}
|
|
81
|
+
<Chart {view} />
|
|
82
|
+
{#if view.fewData}<div class="g9a-note">{t("block.few_data")}</div>{/if}
|
|
83
|
+
</div>
|
|
84
|
+
{:else if view.type === "kpi"}
|
|
85
|
+
<div class={cls(ui, "block.kpi")}>{#each view.items as k, i (i)}<div><span>{k.label}</span><strong>{k.value}</strong></div>{/each}</div>
|
|
86
|
+
{:else if view.type === "steps"}
|
|
87
|
+
<ol class={cls(ui, "block.steps")}>{#each view.items as s, i (i)}<li data-state={s.state}>{s.text}</li>{/each}</ol>
|
|
88
|
+
{:else if view.type === "actions"}
|
|
89
|
+
<div class={cls(ui, "block.actions")}>
|
|
90
|
+
{#each view.items as a, i (i)}
|
|
91
|
+
<button type="button" class={cls(ui, "block.action")} data-role="action" onclick={() => ui.assistant.send(a.send)}>
|
|
92
|
+
{a.label}{#if a.suggested}<span class="g9a-suggested">{t("block.suggested")}</span>{/if}
|
|
93
|
+
</button>
|
|
94
|
+
{/each}
|
|
95
|
+
</div>
|
|
96
|
+
{:else if view.type === "flow"}
|
|
97
|
+
<div class={cls(ui, "block.flow")}>{view.line}</div>
|
|
98
|
+
{:else if view.type === "image"}
|
|
99
|
+
<div class={cls(ui, "block.image")}>{#each view.fileIds as id (id)}<img src={fileUrl(id)} alt={view.fallbackText} loading="lazy" />{/each}</div>
|
|
100
|
+
{:else if view.type === "open" && ui.assistant.host.navigate}
|
|
101
|
+
{@const name = view.label ?? ui.assistant.host.pageName?.(view.pageId) ?? view.fallbackText}
|
|
102
|
+
<button type="button" class={cls(ui, "block.open")} data-role={view.target ? "show" : "open"} onclick={() => { if (view.type === "open") openPage(ui.assistant.host, view); }}>
|
|
103
|
+
{(view.target ? pt("guide.show") : pt("guide.open")) + ": " + name}
|
|
104
|
+
</button>
|
|
105
|
+
{:else if view.type === "open"}
|
|
106
|
+
<div class={cls(ui, "block.fallback")}>{view.label ?? ui.assistant.host.pageName?.(view.pageId) ?? view.fallbackText}</div>
|
|
107
|
+
|
|
108
|
+
{:else}
|
|
109
|
+
<div class={cls(ui, "block.fallback")}>{view.fallbackText}</div>
|
|
110
|
+
{/if}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// A tour: its steps as a numbered list with «show me step by step»; once started, one step at a time with back and
|
|
3
|
+
// next, each step opening its page and lighting its control through the host (navigate). Without navigate, the list.
|
|
4
|
+
import { item } from "@g9tm/aiassistant";
|
|
5
|
+
import { guideOf, pageTexts, type TourState, type TourView } from "@g9tm/aiassistant/pages";
|
|
6
|
+
import { cls, useUi } from "../context.js";
|
|
7
|
+
|
|
8
|
+
let { view, at }: { view: TourView; at: string } = $props();
|
|
9
|
+
const ui = useUi();
|
|
10
|
+
const t = pageTexts(ui.texts).t;
|
|
11
|
+
const guide = guideOf(ui.assistant);
|
|
12
|
+
let now = $state<TourState | null>(guide.tour);
|
|
13
|
+
$effect(() => guide.subscribe((x) => { now = x; }));
|
|
14
|
+
const tour = $derived(now && now.key === at ? now : null);
|
|
15
|
+
const step = $derived(tour ? item(tour.steps, tour.index) : undefined);
|
|
16
|
+
const can = typeof ui.assistant.host.navigate === "function";
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class={cls(ui, "block.tour")}>
|
|
20
|
+
{#if view.title}<div class="g9a-block-title">{view.title}</div>{/if}
|
|
21
|
+
{#if tour && step && !tour.done}
|
|
22
|
+
<div class={cls(ui, "block.tour.step")}>
|
|
23
|
+
<div class="g9a-note">{t("tour.step", { n: tour.index + 1, count: tour.steps.length })}</div>
|
|
24
|
+
<div>{step.text}</div>
|
|
25
|
+
<div class="g9a-tour-nav">
|
|
26
|
+
{#if tour.index > 0}<button type="button" data-role="tour" onclick={() => guide.back()}>{t("tour.back")}</button>{/if}
|
|
27
|
+
<button type="button" data-role="tour" class="g9a-primary" onclick={() => guide.next()}>{tour.index < tour.steps.length - 1 ? t("tour.next") : t("tour.done")}</button>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
{:else}
|
|
31
|
+
<ol class="g9a-list" data-done={tour?.done === true}>{#each view.steps as s, i (i)}<li>{s.text}</li>{/each}</ol>
|
|
32
|
+
{#if can && view.steps.some((s) => s.page)}<button type="button" data-role="tour" onclick={() => guide.start(at, view)}>{t("tour.start")}</button>{/if}
|
|
33
|
+
{/if}
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TourView } from "@g9tm/aiassistant/pages";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
view: TourView;
|
|
4
|
+
at: string;
|
|
5
|
+
};
|
|
6
|
+
declare const TourCard: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type TourCard = ReturnType<typeof TourCard>;
|
|
8
|
+
export default TourCard;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { default as ThinkingOrb } from "./parts/ThinkingOrb.svelte";
|
|
|
13
13
|
export { default as StagesThinking } from "./parts/StagesThinking.svelte";
|
|
14
14
|
export { default as Small } from "./parts/Small.svelte";
|
|
15
15
|
export { default as BlockView } from "./blocks/BlockView.svelte";
|
|
16
|
+
export { default as TourCard } from "./blocks/TourCard.svelte";
|
|
16
17
|
export { default as Chart } from "./blocks/Chart.svelte";
|
|
17
18
|
export { default as ApprovalCard } from "./cards/ApprovalCard.svelte";
|
|
18
19
|
export { default as Cards } from "./cards/Cards.svelte";
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { default as ThinkingOrb } from "./parts/ThinkingOrb.svelte";
|
|
|
13
13
|
export { default as StagesThinking } from "./parts/StagesThinking.svelte";
|
|
14
14
|
export { default as Small } from "./parts/Small.svelte";
|
|
15
15
|
export { default as BlockView } from "./blocks/BlockView.svelte";
|
|
16
|
+
export { default as TourCard } from "./blocks/TourCard.svelte";
|
|
16
17
|
export { default as Chart } from "./blocks/Chart.svelte";
|
|
17
18
|
export { default as ApprovalCard } from "./cards/ApprovalCard.svelte";
|
|
18
19
|
export { default as Cards } from "./cards/Cards.svelte";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
// The composer: input, attach (only when the host can pick a file), mic (only when the host can dictate), send or stop.
|
|
3
|
-
import { can } from "@g9tm/aiassistant";
|
|
3
|
+
import { can, type PickedRef, type QuickRequest } from "@g9tm/aiassistant";
|
|
4
|
+
import { atWord, chatOf, composerOf, matchQuick, pickRefs, putPick, refsIn, slashQuery } from "@g9tm/aiassistant/pages";
|
|
4
5
|
import { cls, sty, useUi } from "../context.js";
|
|
5
6
|
|
|
6
7
|
let { busy, attachments, placeholder = undefined }: { busy: boolean; attachments: { id: string; name: string; kind: string }[]; placeholder?: string | undefined } = $props();
|
|
@@ -9,11 +10,51 @@
|
|
|
9
10
|
const host = ui.assistant.host;
|
|
10
11
|
let text = $state("");
|
|
11
12
|
let input: HTMLTextAreaElement | undefined = $state();
|
|
13
|
+
let refs = $state<PickedRef[]>([]);
|
|
14
|
+
let quick = $state<QuickRequest[]>([]);
|
|
15
|
+
let found = $state<PickedRef[]>([]);
|
|
16
|
+
const chat = chatOf(ui.assistant);
|
|
17
|
+
// The question to edit (the answer's «edit») comes from the core.
|
|
18
|
+
$effect(() => composerOf(ui.assistant).subscribe((c) => { text = c.text; input?.focus(); }));
|
|
19
|
+
// The field grows with its text up to chat.maxLines (one line, as before, unless the host asks for more).
|
|
20
|
+
$effect(() => {
|
|
21
|
+
void text;
|
|
22
|
+
if (!input || chat.maxLines <= 1) return;
|
|
23
|
+
input.style.height = "auto";
|
|
24
|
+
const line = parseFloat(getComputedStyle(input).lineHeight) || 20;
|
|
25
|
+
input.style.height = Math.min(input.scrollHeight, line * chat.maxLines + 16) + "px";
|
|
26
|
+
});
|
|
27
|
+
$effect(() => {
|
|
28
|
+
const q = host.quickRequests ? slashQuery(text) : null;
|
|
29
|
+
if (q === null) { quick = []; return; }
|
|
30
|
+
void Promise.resolve(host.quickRequests?.() ?? []).then((all) => { quick = matchQuick(all, q); });
|
|
31
|
+
});
|
|
32
|
+
$effect(() => {
|
|
33
|
+
const w = host.pickKinds && host.pickKinds.length > 0 ? atWord(text) : null;
|
|
34
|
+
if (w === null) { found = []; return; }
|
|
35
|
+
let live = true;
|
|
36
|
+
void Promise.all((host.pickKinds ?? []).map((k) => pickRefs(ui.assistant.api, k, w))).then((xs) => { if (live) found = xs.flat().slice(0, 8); });
|
|
37
|
+
return () => { live = false; };
|
|
38
|
+
});
|
|
12
39
|
|
|
13
40
|
async function send(): Promise<void> {
|
|
14
41
|
if (busy) { await ui.assistant.stop(); return; }
|
|
15
42
|
const value = text;
|
|
16
|
-
if ((await ui.assistant.ask(value)) !== "refused") text = "";
|
|
43
|
+
if ((await ui.assistant.ask(value, undefined, refsIn(value, refs))) !== "refused") { text = ""; refs = []; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function pickOne(r: PickedRef): void {
|
|
47
|
+
refs = [...refs.filter((x) => x.kind !== r.kind || x.id !== r.id), r];
|
|
48
|
+
text = putPick(text, r);
|
|
49
|
+
input?.focus();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Enter: as the host says (chat.enterSends), else as before (send; Shift+Enter breaks the line).
|
|
53
|
+
function key(e: KeyboardEvent): void {
|
|
54
|
+
if (e.key !== "Enter" || e.shiftKey || e.isComposing) return;
|
|
55
|
+
if (chat.enterSends === false) return;
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
void send();
|
|
17
58
|
}
|
|
18
59
|
|
|
19
60
|
async function attach(): Promise<void> {
|
|
@@ -57,10 +98,16 @@
|
|
|
57
98
|
{/each}
|
|
58
99
|
</div>
|
|
59
100
|
{/if}
|
|
101
|
+
{#if quick.length > 0 || found.length > 0}
|
|
102
|
+
<div class={cls(ui, "composer.menu")} role="listbox">
|
|
103
|
+
{#each quick as q (q.label)}<button type="button" data-role="quick" onclick={() => { text = ""; void ui.assistant.ask(q.send); }}>{q.label}</button>{/each}
|
|
104
|
+
{#each found as r (r.kind + ":" + r.id)}<button type="button" data-role="pick" onclick={() => pickOne(r)}>{r.label}</button>{/each}
|
|
105
|
+
</div>
|
|
106
|
+
{/if}
|
|
60
107
|
<div class="g9a-composer-row">
|
|
61
108
|
{#if can(host, "attach")}<button type="button" class={cls(ui, "composer.attach")} aria-label={t("composer.attach")} onclick={attach}>📎</button>{/if}
|
|
62
109
|
<textarea bind:this={input} bind:value={text} class={cls(ui, "composer.input")} rows="1" placeholder={placeholder ?? t("composer.placeholder")} aria-label={placeholder ?? t("composer.placeholder")}
|
|
63
|
-
onkeydown={
|
|
110
|
+
onkeydown={key}></textarea>
|
|
64
111
|
{#if can(host, "mic")}<button type="button" class={cls(ui, "composer.mic")} aria-label={t("composer.mic")} onclick={dictate}>🎙</button>
|
|
65
112
|
{:else if voice && can(host, "record")}<button type="button" class={cls(ui, "composer.mic")} aria-label={t("composer.mic")} aria-pressed={stopRecording !== null} onclick={record}>{stopRecording ? "■" : "🎙"}</button>{/if}
|
|
66
113
|
<button type="submit" class={cls(ui, busy ? "composer.stop" : "composer.send")}>{busy ? t("composer.stop") : t("composer.send")}</button>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// One message: its text (revealed only when it arrived in front of the person), blocks, card, provenance and feedback.
|
|
3
3
|
import { untrack } from "svelte";
|
|
4
4
|
import type { MessageView } from "@g9tm/aiassistant";
|
|
5
|
+
import { askAgain, chatOf, editLast, pageTexts } from "@g9tm/aiassistant/pages";
|
|
5
6
|
import { cls, override, useUi } from "../context.js";
|
|
6
7
|
import BlockView from "../blocks/BlockView.svelte";
|
|
7
8
|
import ApprovalCard from "../cards/ApprovalCard.svelte";
|
|
@@ -9,9 +10,10 @@
|
|
|
9
10
|
import RevealText from "./RevealText.svelte";
|
|
10
11
|
import Small from "./Small.svelte";
|
|
11
12
|
|
|
12
|
-
let { message, plans, runId }: { message: MessageView; plans: ReadonlyMap<string, import("@g9tm/aiassistant").PlanView>; runId: string | null } = $props();
|
|
13
|
+
let { message, plans, runId, last = false }: { message: MessageView; plans: ReadonlyMap<string, import("@g9tm/aiassistant").PlanView>; runId: string | null; last?: boolean } = $props();
|
|
13
14
|
const ui = useUi();
|
|
14
15
|
const t = ui.texts.t;
|
|
16
|
+
const pt = pageTexts(ui.texts).t;
|
|
15
17
|
// Decided once, when the message first appears (the list is keyed by id): an answer seen once is never revealed again.
|
|
16
18
|
const reveal = untrack(() => ui.assistant.watched.reveal(message.id) && message.role === "assistant" && !message.pending);
|
|
17
19
|
const Approval = $derived(override(ui, "ApprovalCard") ?? ApprovalCard);
|
|
@@ -25,15 +27,16 @@
|
|
|
25
27
|
{#if plan}<Approval {plan} />{:else if message.card.kind !== "plan"}<Other card={message.card} {runId} />{/if}
|
|
26
28
|
{:else}
|
|
27
29
|
{#if message.text.length > 0}<div class={cls(ui, "message.text")}><RevealText text={message.text} {reveal} /></div>{/if}
|
|
28
|
-
{#each message.blocks as b, i (i)}<BlockView block={b} />{/each}
|
|
30
|
+
{#each message.blocks as b, i (i)}<BlockView block={b} at={message.id + ":" + i} />{/each}
|
|
29
31
|
{#if message.next.length > 0}
|
|
30
|
-
<div class={cls(ui, "block.actions")}>{#each message.next as n (n)}<button type="button" class={cls(ui, "block.action")} onclick={() => ui.assistant.send(n)}>{n}</button>{/each}</div>
|
|
32
|
+
<div class={cls(ui, "block.actions")}>{#each message.next as n (n)}<button type="button" class={cls(ui, "block.action")} data-role="next" onclick={() => ui.assistant.send(n)}>{n}</button>{/each}</div>
|
|
31
33
|
{/if}
|
|
32
34
|
{#if message.role === "assistant"}
|
|
33
35
|
<div class={cls(ui, "message.feedback")}>
|
|
34
36
|
<Small kind="provenance" provenance={message.provenance} />
|
|
35
|
-
{#if ui.assistant.host.copy}<button type="button" onclick={async () => { await ui.assistant.host.copy?.(message.text); copied = true; }}>{copied ? "✓" : t("feedback.copy")}</button>{/if}
|
|
36
|
-
{#if message.provenance === "learned"}<button type="button" onclick={() => ui.assistant.notRight(message.id)}>{t("feedback.not_right")}</button>{/if}
|
|
37
|
+
{#if ui.assistant.host.copy}<button type="button" data-role="copy" onclick={async () => { await ui.assistant.host.copy?.(message.text); copied = true; }}>{copied ? "✓" : t("feedback.copy")}</button>{/if}
|
|
38
|
+
{#if message.provenance === "learned"}<button type="button" data-role="feedback" onclick={() => ui.assistant.notRight(message.id)}>{t("feedback.not_right")}</button>{/if}
|
|
39
|
+
{#if last && chatOf(ui.assistant).again && !message.pending}<button type="button" data-role="again" onclick={() => askAgain(ui.assistant)}>{pt("message.again")}</button><button type="button" data-role="edit" onclick={() => editLast(ui.assistant)}>{pt("message.edit")}</button>{/if}
|
|
37
40
|
</div>
|
|
38
41
|
{/if}
|
|
39
42
|
{/if}
|
|
@@ -3,6 +3,7 @@ type $$ComponentProps = {
|
|
|
3
3
|
message: MessageView;
|
|
4
4
|
plans: ReadonlyMap<string, import("@g9tm/aiassistant").PlanView>;
|
|
5
5
|
runId: string | null;
|
|
6
|
+
last?: boolean;
|
|
6
7
|
};
|
|
7
8
|
declare const Message: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
9
|
type Message = ReturnType<typeof Message>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// The messages, opened at the end; a new question stays at the top of the view so its answer is read from the start.
|
|
3
3
|
// New messages are announced politely to screen readers.
|
|
4
4
|
import type { MessageView, PlanView } from "@g9tm/aiassistant";
|
|
5
|
+
import { chatOf, pageTexts } from "@g9tm/aiassistant/pages";
|
|
5
6
|
import { cls, override, useUi } from "../context.js";
|
|
6
7
|
import Message from "./Message.svelte";
|
|
7
8
|
|
|
@@ -10,19 +11,29 @@
|
|
|
10
11
|
const Item = $derived(override(ui, "Message") ?? Message);
|
|
11
12
|
let box: HTMLDivElement | undefined = $state();
|
|
12
13
|
let count = 0;
|
|
14
|
+
// New content below the view while the person reads above: the view stays, and «to the newest» appears.
|
|
15
|
+
let below = $state(false);
|
|
16
|
+
const measure = (): void => { if (box) below = box.scrollTop + box.clientHeight < box.scrollHeight - 40; };
|
|
13
17
|
$effect(() => {
|
|
14
18
|
const n = messages.length;
|
|
15
|
-
|
|
19
|
+
void messages[n - 1]?.text.length;
|
|
20
|
+
if (!box) return;
|
|
21
|
+
if (n === count) { measure(); return; }
|
|
16
22
|
const last = messages[n - 1];
|
|
17
23
|
const node = box.querySelector<HTMLElement>('[data-id="' + CSS.escape(last?.id ?? "") + '"]');
|
|
18
24
|
if (count === 0) box.scrollTop = box.scrollHeight; // history opens at its end
|
|
19
25
|
else if (last?.role === "user" && node) box.scrollTop = node.offsetTop - box.offsetTop; // the question at the top
|
|
20
26
|
count = n;
|
|
27
|
+
measure();
|
|
21
28
|
});
|
|
29
|
+
const lastAnswer = $derived(messages.length > 0 && messages[messages.length - 1]?.role === "assistant" ? messages[messages.length - 1]?.id : null);
|
|
22
30
|
</script>
|
|
23
31
|
|
|
24
|
-
<div class=
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
<div class="g9a-messages-frame">
|
|
33
|
+
<div class={cls(ui, "messages")} bind:this={box} aria-live="polite" onscroll={measure} data-selectable={chatOf(ui.assistant).selectable}>
|
|
34
|
+
{#each messages as m (m.id)}
|
|
35
|
+
<div data-id={m.id}><Item message={m} {plans} {runId} last={m.id === lastAnswer} /></div>
|
|
36
|
+
{/each}
|
|
37
|
+
</div>
|
|
38
|
+
{#if below}<button type="button" class={cls(ui, "messages.newest")} data-role="newest" onclick={() => { if (box) box.scrollTop = box.scrollHeight; below = false; }}>{pageTexts(ui.texts).t("messages.newest")}</button>{/if}
|
|
28
39
|
</div>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// "still working". The thinking orb is static with reduced motion.
|
|
4
4
|
import { onDestroy, untrack } from "svelte";
|
|
5
5
|
import { finished, LONG_RUNNING_MS, type RunView } from "@g9tm/aiassistant";
|
|
6
|
+
import { chatOf, pageTexts, statusOf } from "@g9tm/aiassistant/pages";
|
|
6
7
|
import { cls, useUi } from "../context.js";
|
|
7
8
|
import { Ticker } from "../store.svelte.js";
|
|
8
9
|
import ThinkingOrb from "./ThinkingOrb.svelte";
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
<ThinkingOrb />
|
|
30
31
|
<div class="g9a-work-main">
|
|
31
32
|
<div class="g9a-work-head"><strong>{long ? t("work.long") : t("work.title")}</strong><span class={cls(ui, "work.elapsed")}>{t("work.elapsed", { seconds })}</span></div>
|
|
33
|
+
{#if chatOf(ui.assistant).status && statusOf(run)}{@const st = statusOf(run)}<div class={cls(ui, "work.status")}>{pageTexts(ui.texts).t("work.status", { what: t(st?.key ?? "", st?.args) })}</div>{/if}
|
|
32
34
|
<div class="g9a-stages">
|
|
33
35
|
{#each run.stages.filter((s) => s.id !== "waiting") as s, i (i)}<span class={cls(ui, "work.stage")} data-state={s.state}>{label(s)}</span>{/each}
|
|
34
36
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/aiassistant-svelte",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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.9.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@sveltejs/package": "2.5.8",
|