@kubed.io/cdn 0.0.1 → 0.0.4

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.
Files changed (62) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +33 -5
  3. package/dist/chunks/define-XzEniRJH.js +10 -0
  4. package/dist/chunks/define-XzEniRJH.js.map +1 -0
  5. package/dist/chunks/element-ChNBLJ5X.js +632 -0
  6. package/dist/chunks/element-ChNBLJ5X.js.map +1 -0
  7. package/dist/chunks/kd-Bbw0GeQ5.js +1149 -0
  8. package/dist/chunks/kd-Bbw0GeQ5.js.map +1 -0
  9. package/dist/chunks/scene-CUr0fSXC.js +240 -0
  10. package/dist/chunks/scene-CUr0fSXC.js.map +1 -0
  11. package/dist/k8s/elements/events.d.ts +54 -0
  12. package/dist/k8s/elements/object.d.ts +47 -0
  13. package/dist/k8s/elements/ref.d.ts +45 -0
  14. package/dist/k8s/events.d.ts +63 -0
  15. package/dist/k8s/icons.d.ts +18 -0
  16. package/dist/k8s/index.d.ts +13 -0
  17. package/dist/k8s/links.d.ts +72 -0
  18. package/dist/k8s/map.d.ts +114 -0
  19. package/dist/k8s.js +909 -0
  20. package/dist/k8s.js.map +1 -0
  21. package/dist/kd/cell.d.ts +45 -0
  22. package/dist/kd/define.d.ts +0 -0
  23. package/dist/kd/element.d.ts +32 -0
  24. package/dist/kd/elements/bar.d.ts +33 -0
  25. package/dist/kd/elements/data.d.ts +27 -0
  26. package/dist/kd/elements/groups.d.ts +32 -0
  27. package/dist/kd/elements/link.d.ts +67 -0
  28. package/dist/kd/elements/mask.d.ts +22 -0
  29. package/dist/kd/elements/meter.d.ts +37 -0
  30. package/dist/kd/elements/pill.d.ts +15 -0
  31. package/dist/kd/elements/sheet.d.ts +28 -0
  32. package/dist/kd/elements/steps.d.ts +30 -0
  33. package/dist/kd/elements/table.d.ts +38 -0
  34. package/dist/kd/elements/tabs.d.ts +27 -0
  35. package/dist/kd/elements/tile.d.ts +19 -0
  36. package/dist/kd/helpers.d.ts +12 -0
  37. package/dist/kd/index.d.ts +30 -0
  38. package/dist/kd/parts.d.ts +15 -0
  39. package/dist/kd/scene.d.ts +178 -0
  40. package/dist/kd/theme.d.ts +2 -0
  41. package/dist/kd/yaml.d.ts +17 -0
  42. package/dist/kd.css +0 -0
  43. package/dist/kd.js +5 -64
  44. package/dist/n8n/config.d.ts +57 -0
  45. package/dist/n8n/fetch.d.ts +35 -0
  46. package/dist/n8n/history.d.ts +8 -0
  47. package/dist/n8n/index.d.ts +8 -0
  48. package/dist/n8n/metadata.d.ts +10 -0
  49. package/dist/n8n/mount.d.ts +29 -0
  50. package/dist/n8n/state.d.ts +44 -0
  51. package/dist/n8n/stream.d.ts +17 -0
  52. package/dist/n8n/styles.d.ts +1 -0
  53. package/dist/n8n.js +384 -0
  54. package/dist/n8n.js.map +1 -0
  55. package/dist/openapi/describe.d.ts +20 -0
  56. package/dist/openapi/index.d.ts +6 -0
  57. package/dist/openapi/model.d.ts +154 -0
  58. package/dist/openapi/schema.d.ts +52 -0
  59. package/dist/openapi.js +504 -0
  60. package/dist/openapi.js.map +1 -0
  61. package/package.json +18 -2
  62. package/dist/kd.js.map +0 -1
@@ -0,0 +1,19 @@
1
+ import { KdElement } from '../element';
2
+ /**
3
+ * The chat tile's header link: a large icon (an image URL or an emoji) over a
4
+ * small label. An `http(s)` link opens in a new tab.
5
+ *
6
+ * `<kd-tile icon="🤖" label="Ask" href="https://…"></kd-tile>`
7
+ */
8
+ export declare class KdTile extends KdElement {
9
+ static properties: {
10
+ icon: {};
11
+ label: {};
12
+ href: {};
13
+ };
14
+ static styles: import("lit").CSSResult[];
15
+ icon: string | undefined;
16
+ label: string | undefined;
17
+ href: string | undefined;
18
+ render(): import("lit-html").TemplateResult<1>;
19
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Data for a JSON attribute. Double-stash it so Handlebars escapes the quotes:
3
+ * `<kd-table data="{{kdjson rows}}">`. Never triple-stash JSON into an
4
+ * attribute: one `'` in the data turns the whole tag into escaped text.
5
+ */
6
+ export declare function kdjson(value: unknown): string;
7
+ interface Handlebars {
8
+ registerHelper(name: string, helper: (...args: unknown[]) => unknown): void;
9
+ }
10
+ /** Registers `kdjson` on Business Text's `context.handlebars`. */
11
+ export declare function registerHelpers(handlebars: Handlebars): void;
12
+ export {};
@@ -1,2 +1,32 @@
1
1
  export { applyTheme, followTheme, type ThemeLike } from './theme';
2
2
  export { define, VERSION } from './define';
3
+ export { KdElement, base, json, themedAncestor } from './element';
4
+ export { kdjson, registerHelpers } from './helpers';
5
+ import './elements/bar';
6
+ import './elements/data';
7
+ import './elements/groups';
8
+ import './elements/link';
9
+ import './elements/mask';
10
+ import './elements/meter';
11
+ import './elements/pill';
12
+ import './elements/sheet';
13
+ import './elements/steps';
14
+ import './elements/table';
15
+ import './elements/tabs';
16
+ import './elements/tile';
17
+ export { renderCell, cellStyles, isEmpty, type Cell, type PillCell, type HrefCell, type DashboardCell, type DataCell, type CodeCell, } from './cell';
18
+ export { renderIcon, safeHref, tone, tones, type Tone } from './parts';
19
+ export { toYaml, yamlLines, quote, type YamlKind, type YamlLine, type YamlToken } from './yaml';
20
+ export { KdBar, type BarData } from './elements/bar';
21
+ export { KdData } from './elements/data';
22
+ export { KdGroups, jsonValue, type GroupsData } from './elements/groups';
23
+ export { KdLink, linkUrl, type LinkData, type Vars } from './elements/link';
24
+ export { KdMask } from './elements/mask';
25
+ export { KdMeter, type MeterData, type MeterMark } from './elements/meter';
26
+ export { KdPill } from './elements/pill';
27
+ export { KdSheet, type SheetData, type SheetRow } from './elements/sheet';
28
+ export { KdSteps, type Step, type StepStatus } from './elements/steps';
29
+ export { KdTable, type TableColumn, type TableData } from './elements/table';
30
+ export { KdTabs } from './elements/tabs';
31
+ export { KdTile } from './elements/tile';
32
+ export * from './scene';
@@ -0,0 +1,15 @@
1
+ import { nothing, type TemplateResult } from 'lit';
2
+ /** A semantic colour. Each maps to `--kd-<tone>`; neutral is the secondary text colour. */
3
+ export type Tone = 'primary' | 'success' | 'warning' | 'error' | 'info' | 'neutral';
4
+ /** `value` when it names a tone, else `fallback`. */
5
+ export declare function tone(value: unknown, fallback?: Tone): Tone;
6
+ /**
7
+ * Tone classes. Each sets `--tone` (the colour), `--tone-ink` (text in that
8
+ * colour, pulled towards the text colour so it reads on either theme) and
9
+ * `--tone-line` (a border in that colour).
10
+ */
11
+ export declare const tones: import("lit").CSSResult;
12
+ /** An icon that is either an image URL or a short text such as an emoji. */
13
+ export declare function renderIcon(value: string | null | undefined, cls?: string): TemplateResult | typeof nothing;
14
+ /** `href` unless it is a script or data URL, which data must never smuggle into a link. */
15
+ export declare function safeHref(href: string | null | undefined): string | undefined;
@@ -0,0 +1,178 @@
1
+ /** The page: its Window, or any node in it (a panel's `context.element`). */
2
+ export type Page = Window | Node;
3
+ export interface VariableOption {
4
+ value: unknown;
5
+ label?: string;
6
+ }
7
+ /** A dashboard variable: a dropdown has `changeValueTo` and options, a text box `setValue`. */
8
+ export interface SceneVariable {
9
+ state: {
10
+ name?: string;
11
+ options?: VariableOption[];
12
+ };
13
+ getValue(): unknown;
14
+ changeValueTo?(value: unknown, text?: unknown): void;
15
+ setValue?(value: string): void;
16
+ }
17
+ export interface VariableSet {
18
+ getByName(name: string): SceneVariable | undefined;
19
+ }
20
+ export interface RawRange {
21
+ from: string;
22
+ to: string;
23
+ }
24
+ /** SceneTimeRange: `from`/`to` are the raw picker strings, `value` the evaluated dates. */
25
+ export interface SceneTimeRange {
26
+ state: {
27
+ from?: unknown;
28
+ to?: unknown;
29
+ value?: {
30
+ from?: unknown;
31
+ to?: unknown;
32
+ };
33
+ };
34
+ onTimeRangeChange?(range: {
35
+ raw: RawRange;
36
+ from: string;
37
+ to: string;
38
+ }): void;
39
+ updateFromUrl?(raw: RawRange): void;
40
+ }
41
+ export interface RefreshPicker {
42
+ state: {
43
+ refresh?: string;
44
+ intervals?: string[];
45
+ };
46
+ setState(patch: {
47
+ refresh: string;
48
+ }): void;
49
+ }
50
+ /** Any scene object, for walking the graph. */
51
+ export interface SceneNode {
52
+ state: any;
53
+ parent?: SceneNode | null;
54
+ setState?(patch: Record<string, unknown>): void;
55
+ forEachChild?(fn: (child: SceneNode) => void): void;
56
+ }
57
+ export interface DashboardScene extends SceneNode {
58
+ state: {
59
+ $variables?: VariableSet;
60
+ $timeRange?: SceneTimeRange;
61
+ controls?: unknown;
62
+ refreshPicker?: unknown;
63
+ body?: SceneNode;
64
+ [key: string]: unknown;
65
+ };
66
+ }
67
+ /** A tab or a collapsible row, and the panels it holds (`panel-N` keys). */
68
+ export interface Group {
69
+ name: string;
70
+ kind: 'tab' | 'row';
71
+ open: boolean;
72
+ /** False for a row with a hidden header: always on screen, nothing to open. */
73
+ focusable: boolean;
74
+ panels: string[];
75
+ show(): void;
76
+ }
77
+ export interface Focused {
78
+ group: string;
79
+ kind: 'tab' | 'row';
80
+ panel: number | null;
81
+ }
82
+ export interface TimeWindow {
83
+ from: string;
84
+ to: string;
85
+ fromIso: string;
86
+ toIso: string;
87
+ }
88
+ /** The page's Window, from the Window itself or any node in it. */
89
+ export declare function pageWindow(page: Page | null | undefined): Window | null;
90
+ /** The dashboard scene, or null off a dashboard (or outside Grafana). */
91
+ export declare function scene(page: Page | null | undefined): DashboardScene | null;
92
+ export declare function variable(page: Page, name: string): SceneVariable | null;
93
+ /** A variable's value as text: a multi-value joins with commas; missing is ''. */
94
+ export declare function variableValue(page: Page, name: string): string;
95
+ /**
96
+ * Sets one variable. A dropdown takes one of its own options (or an `$__all`
97
+ * value); anything else is refused, because Grafana would store it and show a
98
+ * blank picker. A text box takes any value.
99
+ *
100
+ * @returns the value set, or null when nothing changed
101
+ */
102
+ export declare function setVariable(page: Page, name: string, value: unknown): string | null;
103
+ /**
104
+ * Sets the `allowed` names found in `values`, one at a time in `allowed`'s
105
+ * order (order can matter: a variable that starts a job goes last).
106
+ *
107
+ * @returns what really changed, which is not always what was asked for
108
+ */
109
+ export declare function setVariables(page: Page, values: Record<string, unknown>, allowed: string[]): Record<string, string>;
110
+ /** The window on screen: raw (`now-24h`, what a person reads) and ISO (what a query needs). */
111
+ export declare function timeRange(page: Page): TimeWindow | null;
112
+ /**
113
+ * Moves the time picker, both ends in one call: `onTimeRangeChange` reads only
114
+ * `raw`, evaluates it and pushes the URL, so a reload keeps the window. A
115
+ * missing end keeps the picker's current one.
116
+ *
117
+ * @returns the raw window set, or null
118
+ */
119
+ export declare function setTimeRange(page: Page, from?: string | null, to?: string | null): RawRange | null;
120
+ /** `5m` -> 300. Off, empty or unreadable is 0. */
121
+ export declare function intervalSeconds(interval: string | null | undefined): number;
122
+ /** The refresh interval: `''` when auto-refresh is off, null when there is no picker. */
123
+ export declare function refresh(page: Page): string | null;
124
+ /** The intervals this dashboard's picker offers. Anything else renders it blank. */
125
+ export declare function refreshIntervals(page: Page): string[];
126
+ /**
127
+ * The offered interval nearest `want`, on a log scale because the steps are
128
+ * multiplicative (10m is nearer 15m than 5m). A tie goes to the slower one:
129
+ * fewer queries is the cheaper mistake.
130
+ */
131
+ export declare function snapInterval(want: string, offered: string[]): string | null;
132
+ /**
133
+ * Sets auto-refresh. An interval the picker does not offer is not an error to
134
+ * Grafana - it is stored, the picker goes blank and refreshing stops - so it is
135
+ * snapped to the nearest offered one.
136
+ *
137
+ * @returns what was set (`off` or an interval), or null
138
+ */
139
+ export declare function setRefresh(page: Page, value: string): string | null;
140
+ /**
141
+ * The dashboard's tabs and collapsible rows, in order. A v2 dashboard is a list
142
+ * of rows; a row holds panels or a tabs manager, and both are groups here,
143
+ * because to the person looking at it either way some panels show and others
144
+ * do not.
145
+ */
146
+ export declare function groups(page: Page): Group[];
147
+ /**
148
+ * Brings a panel or a group on screen. `target` is a panel id (`5`, `panel-5`)
149
+ * or a group name; either way its group is opened, so the caller never needs
150
+ * to know whether that is a tab or a row. A panel is then scrolled to, retrying
151
+ * over animation frames because a tab that was closed mounts a beat later.
152
+ */
153
+ export declare function focusPanel(page: Page, target: string | number | null | undefined): Focused | null;
154
+ /** What `fitPanel` reads from Business Text's `context`. */
155
+ export interface FitContext {
156
+ grafana?: {
157
+ replaceVariables?(text: string): string;
158
+ };
159
+ /** The panel id or key, when `content` is not inside the panel's own DOM. */
160
+ panel?: string | number;
161
+ }
162
+ /**
163
+ * Grid rows needed for `px` of content. A grid item of height h spans 38h - 8
164
+ * px; `pad` covers the panel's own padding (12 with Business Text's `.dt-row`
165
+ * padding set to `4px 0 0`).
166
+ */
167
+ export declare function gridHeight(px: number, pad?: number): number;
168
+ /**
169
+ * Fits a panel's grid height to its content. Grafana has none of its own, but
170
+ * the grid item is reachable in the scene: setting its height changes state
171
+ * only, and the grid relays out once its parent gets a new children list. Live
172
+ * only, never saved; a no-op when the height is already right, so it is safe in
173
+ * an `afterRender` that runs twice per refresh.
174
+ *
175
+ * @param content the element to measure, inside the panel
176
+ * @returns the height set or kept, or null when the panel was not found
177
+ */
178
+ export declare function fitPanel(content: HTMLElement, context?: FitContext): number | null;
@@ -12,6 +12,8 @@ export interface ThemeLike {
12
12
  * @param theme a GrafanaTheme2, e.g. `context.grafana.theme`
13
13
  */
14
14
  export declare function applyTheme(element: HTMLElement | null | undefined, theme: ThemeLike | null | undefined): void;
15
+ /** Marks an element that is theming itself because nothing above it was. */
16
+ export declare const SELF_THEMED = "data-kd-self-themed";
15
17
  /**
16
18
  * Themes `element` from Grafana's live theme without being handed one, and
17
19
  * keeps it themed across a live theme switch. For code that has no
@@ -0,0 +1,17 @@
1
+ /** What a token is, for highlighting. Punctuation and indentation are `plain`. */
2
+ export type YamlKind = 'key' | 'str' | 'num' | 'bool' | 'null' | 'plain';
3
+ export interface YamlToken {
4
+ kind: YamlKind;
5
+ text: string;
6
+ }
7
+ /** One output line: its indentation (with any `- ` markers), then its tokens. */
8
+ export interface YamlLine {
9
+ prefix: string;
10
+ tokens: YamlToken[];
11
+ }
12
+ /** A string as a YAML scalar, double-quoted (JSON's escapes are YAML's) only when it must be. */
13
+ export declare function quote(s: string): string;
14
+ /** A JSON value as YAML lines of tokens, for rendering with highlighting. */
15
+ export declare function yamlLines(value: unknown): YamlLine[];
16
+ /** A JSON value as YAML text. */
17
+ export declare function toYaml(value: unknown): string;
package/dist/kd.css CHANGED
File without changes
package/dist/kd.js CHANGED
@@ -1,64 +1,5 @@
1
- //#region src/kd/theme.ts
2
- var e = [
3
- ["--kd-bg", (e) => e.colors.background.primary],
4
- ["--kd-bg-2", (e) => e.colors.background.secondary],
5
- ["--kd-canvas", (e) => e.colors.background.canvas],
6
- ["--kd-text", (e) => e.colors.text.primary],
7
- ["--kd-text-2", (e) => e.colors.text.secondary],
8
- ["--kd-text-dim", (e) => e.colors.text.disabled],
9
- ["--kd-link", (e) => e.colors.text.link],
10
- ["--kd-border", (e) => e.colors.border.weak],
11
- ["--kd-border-strong", (e) => e.colors.border.medium],
12
- ["--kd-primary", (e) => e.colors.primary.main],
13
- ["--kd-success", (e) => e.colors.success.main],
14
- ["--kd-warning", (e) => e.colors.warning.main],
15
- ["--kd-error", (e) => e.colors.error.main],
16
- ["--kd-info", (e) => e.colors.info.main],
17
- ["--kd-font", (e) => e.typography.fontFamily],
18
- ["--kd-font-mono", (e) => e.typography.fontFamilyMonospace],
19
- ["--kd-radius", (e) => e.shape.radius.default],
20
- ["--kd-space", (e) => e.spacing(1)]
21
- ];
22
- function t(e, t) {
23
- try {
24
- let n = t(e);
25
- return typeof n == "string" || typeof n == "number" ? String(n) : void 0;
26
- } catch {
27
- return;
28
- }
29
- }
30
- function n(n, r) {
31
- if (n && r) {
32
- for (let [i, a] of e) {
33
- let e = t(r, a);
34
- e !== void 0 && n.style.setProperty(i, e);
35
- }
36
- typeof r.isDark == "boolean" && n.setAttribute("data-theme", r.isDark ? "dark" : "light");
37
- }
38
- }
39
- var r = /* @__PURE__ */ new WeakMap();
40
- function i(e) {
41
- let t = r.get(e);
42
- return t || (t = Promise.resolve().then(() => e.System?.import?.("@grafana/runtime")).then((e) => {
43
- let t = e;
44
- return t?.config?.theme2 && t.getAppEvents && t.ThemeChangedEvent ? t : null;
45
- }).catch(() => null), r.set(e, t)), t;
46
- }
47
- async function a(e) {
48
- let t = e.ownerDocument?.defaultView, r = t ? await i(t) : null;
49
- if (!r) return () => {};
50
- n(e, r.config.theme2);
51
- let a = r.getAppEvents().subscribe(r.ThemeChangedEvent, (t) => n(e, t?.payload ?? r.config.theme2));
52
- return () => a.unsubscribe();
53
- }
54
- //#endregion
55
- //#region src/kd/define.ts
56
- var o = "0.0.1";
57
- function s(e, t, n = customElements) {
58
- let r = n.get(e);
59
- return r ? (r !== t && r.kdVersion !== "0.0.1" && console.warn(`@kubed.io/cdn ${o}: <${e}> is already defined by ${r.kdVersion ? `@kubed.io/cdn ${r.kdVersion}` : "another script"}; that definition stays until the page is reloaded.`), !1) : (Object.defineProperty(t, "kdVersion", { value: o }), n.define(e, t), !0);
60
- }
61
- //#endregion
62
- export { o as VERSION, n as applyTheme, s as define, a as followTheme };
63
-
64
- //# sourceMappingURL=kd.js.map
1
+ import { d as e, i as t, n, r, t as i, u as a } from "./chunks/element-ChNBLJ5X.js";
2
+ import { n as o, t as s } from "./chunks/define-XzEniRJH.js";
3
+ import { C as c, E as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, l as x, m as S, n as C, o as w, p as T, r as E, s as D, t as O, u as k, v as A, w as j, x as M, y as N } from "./chunks/kd-Bbw0GeQ5.js";
4
+ import { _ as P, a as F, c as I, d as L, f as R, g as z, h as B, i as V, l as H, m as U, n as W, o as G, p as K, r as q, s as J, t as Y, u as X } from "./chunks/scene-CUr0fSXC.js";
5
+ export { k as KdBar, M as KdData, i as KdElement, h as KdGroups, y as KdLink, D as KdMask, w as KdMeter, S as KdPill, p as KdSheet, b as KdSteps, E as KdTable, C as KdTabs, O as KdTile, s as VERSION, a as applyTheme, n as base, g as cellStyles, o as define, Y as fitPanel, W as focusPanel, e as followTheme, q as gridHeight, V as groups, F as intervalSeconds, _ as isEmpty, r as json, x as jsonValue, d as kdjson, v as linkUrl, G as pageWindow, u as quote, J as refresh, I as refreshIntervals, l as registerHelpers, T as renderCell, f as renderIcon, A as safeHref, H as scene, X as setRefresh, L as setTimeRange, R as setVariable, K as setVariables, U as snapInterval, t as themedAncestor, B as timeRange, c as toYaml, N as tone, m as tones, z as variable, P as variableValue, j as yamlLines };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * What the library panel passes to `mount`: its `chat_*` constants (decoded),
3
+ * the viewer, and the Authorization header. A field that arrives as a literal
4
+ * `${...}` (a dashboard without that variable) reads as empty.
5
+ */
6
+ export interface ChatConfig {
7
+ /** An emoji, or an image URL. */
8
+ icon?: string;
9
+ label?: string;
10
+ /** Where the tile goes; an http(s) link opens a new tab. */
11
+ link?: string;
12
+ /** The n8n Chat Trigger URL. Empty means tile only, and any leftover bubble is removed. */
13
+ webhook?: string;
14
+ title?: string;
15
+ subtitle?: string;
16
+ /** Greeting lines, split on `|`. */
17
+ greeting?: string;
18
+ /** Extra metadata as `key=variable` pairs, read live on every send: `pod=pod,database=datname`. */
19
+ context?: string;
20
+ /** The names the agent may set, in applied order. `time_from`, `time_to`, `refresh` and `focus` are reserved. */
21
+ settable?: string;
22
+ /** Each group's purpose, `Name=purpose` pairs joined by `|` (Grafana has no description on a tab or a row). */
23
+ groups?: string;
24
+ /** Stream the reply. Must match the Chat Trigger's responseMode, or nothing renders. */
25
+ stream?: boolean | string;
26
+ /** The viewer's login, sent as metadata. */
27
+ user?: string;
28
+ /** The Authorization header value. Kept in Grafana and passed in, never in this package. */
29
+ auth?: string;
30
+ /** The `@n8n/chat` version loaded from jsDelivr. */
31
+ chatVersion?: string;
32
+ /** The tile: an element, a selector, or by default `#n8n-chat-tile`. An `<a>` or a `<kd-tile>`. */
33
+ tile?: Element | string | null;
34
+ /** The page; by default the tile's, else the global window. */
35
+ window?: Window;
36
+ }
37
+ export declare const CHAT_VERSION = "1.39.2";
38
+ export interface Settings {
39
+ icon: string;
40
+ label: string;
41
+ link: string;
42
+ webhook: string;
43
+ title: string;
44
+ subtitle: string;
45
+ greeting: string[];
46
+ context: [key: string, variable: string][];
47
+ settable: string[];
48
+ groups: Record<string, string>;
49
+ stream: boolean;
50
+ user: string;
51
+ auth: string;
52
+ chatVersion: string;
53
+ }
54
+ export declare function list(value: string): string[];
55
+ /** `Name=purpose|Other=purpose` -> lower-cased name to purpose. */
56
+ export declare function groupNotes(value: string): Record<string, string>;
57
+ export declare function settings(config: ChatConfig): Settings;
@@ -0,0 +1,35 @@
1
+ import type { Focused } from '../kd/scene';
2
+ /**
3
+ * What the fetch wrapper acts for: the chat on screen. Kept on the page window
4
+ * as `n8nChat` in the shape the pre-package library panel used, so a wrapper
5
+ * installed by either one serves the other.
6
+ */
7
+ export interface ChatHandle {
8
+ webhook: string;
9
+ settable: string[];
10
+ stream: boolean;
11
+ setVariables(vars: Record<string, unknown> | null | undefined, names: string[]): Record<string, string>;
12
+ cleanHistory<T>(reply: T): T;
13
+ filterStream(body: ReadableStream<Uint8Array>): ReadableStream<Uint8Array>;
14
+ }
15
+ /** The page globals the chat keeps. They outlive this module across SPA navigation and package versions. */
16
+ export interface ChatWindow extends Window {
17
+ n8nChat?: ChatHandle | null;
18
+ n8nChatWatch?: number;
19
+ n8nChatFetchWrapped?: boolean;
20
+ n8nChatFit?: () => void;
21
+ n8nChatResize?: boolean;
22
+ n8nChatMount?: {
23
+ key: string;
24
+ done: boolean;
25
+ ready: Promise<void>;
26
+ };
27
+ /** The resolver the agent navigates with, for the dashboard's own buttons (Torrent's use it). */
28
+ dashboardFocus?: (target: string | number) => Focused | null;
29
+ }
30
+ /**
31
+ * Wraps the page's fetch, once per page. The wrapper reads `n8nChat` on every
32
+ * call, which each mount replaces, so it acts for the dashboard on screen and
33
+ * only for its webhook.
34
+ */
35
+ export declare function wrapFetch(win: ChatWindow): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Cleans a `loadPreviousSession` reply for the widget, whose markdown renderer
3
+ * throws on anything but a string. Tool, system and function messages are
4
+ * dropped (a tool message's content is the tool's raw JSON, a non-empty string
5
+ * that would otherwise fill the reloaded chat); array content is flattened to
6
+ * its text, and a message left with no text is dropped.
7
+ */
8
+ export declare function cleanHistory<T>(reply: T): T;
@@ -0,0 +1,8 @@
1
+ export { VERSION } from '../kd/define';
2
+ export { mount, fillTile, fitChat, injectStyles, chatBundle, chatStyle, type ChatLoader, type CreateChat } from './mount';
3
+ export { CHAT_VERSION, settings, type ChatConfig, type Settings } from './config';
4
+ export { CONTROL_NODE, controlFilter } from './stream';
5
+ export { cleanHistory } from './history';
6
+ export { applyState, applyToolCalls, readToolCalls, stateCard, placeCard, RESERVED, type DashboardState, type ToolCalls } from './state';
7
+ export { chatMetadata, describeGroups } from './metadata';
8
+ export type { ChatHandle, ChatWindow } from './fetch';
@@ -0,0 +1,10 @@
1
+ import { type Group } from '../kd/scene';
2
+ import type { Settings } from './config';
3
+ /** The navigation map for the agent: one line per group, with its purpose from `chat_groups`. */
4
+ export declare function describeGroups(list: Group[], notes: Record<string, string>): string;
5
+ /**
6
+ * The metadata sent with every message. @n8n/chat serialises this same object
7
+ * on each send, so every live field is a getter: the agent hears about the
8
+ * window, refresh and layout on screen at send time, not at page load.
9
+ */
10
+ export declare function chatMetadata(win: Window, s: Settings, home: string): Record<string, unknown>;
@@ -0,0 +1,29 @@
1
+ import { type ChatConfig, type Settings } from './config';
2
+ export type CreateChat = (options: Record<string, unknown>) => unknown;
3
+ export type ChatLoader = (url: string) => Promise<{
4
+ createChat: CreateChat;
5
+ }>;
6
+ export declare const chatBundle: (version: string) => string;
7
+ export declare const chatStyle: (version: string) => string;
8
+ /** Injects the tile's page-global stylesheet once; a newer build's replaces an older one's. */
9
+ export declare function injectStyles(doc: Document): void;
10
+ /** Fills the tile: an `<a>` with `.icon` and `.label` children, or a `<kd-tile>` by its attributes. */
11
+ export declare function fillTile(tile: Element, s: Pick<Settings, 'icon' | 'label' | 'link'>): void;
12
+ /**
13
+ * Pins the chat window's top under Grafana's controls row, which is measured
14
+ * because it grows when the variables wrap and is absent in a kiosk embed. With
15
+ * no row, or below 900px, the inline values go so the stylesheet's apply.
16
+ */
17
+ export declare function fitChat(win: Window): void;
18
+ /**
19
+ * Mounts the chat tile and its n8n chat on the page.
20
+ *
21
+ * Idempotent: the core text panel re-runs its script on every mount, so a
22
+ * repeat call for the same dashboard and settings keeps the chat that is there.
23
+ * Grafana is a single-page app, so the chat lives on `<body>` only while the URL
24
+ * stays on this dashboard. With no webhook it fills the tile and removes any
25
+ * leftover chat.
26
+ *
27
+ * @returns once the chat is created (or at once, tile only)
28
+ */
29
+ export declare function mount(config?: ChatConfig, loader?: ChatLoader): Promise<void>;
@@ -0,0 +1,44 @@
1
+ import { type Focused, type Page } from '../kd/scene';
2
+ /** Names in `chat_settable` that are not template variables. */
3
+ export declare const RESERVED: string[];
4
+ export interface ToolCalls {
5
+ tools?: {
6
+ args?: Record<string, unknown> | null;
7
+ }[];
8
+ }
9
+ export interface DashboardState {
10
+ /** Settable names to values; a later call in the turn wins. */
11
+ vars: Record<string, string>;
12
+ /** What to bring on screen: an explicit `focus`, else the last panel read. Null unless `focus` is settable. */
13
+ focus: string | null;
14
+ }
15
+ /**
16
+ * Maps a turn's tool calls onto the dashboard. An argument named like a
17
+ * settable name IS that name, so no dashboard-specific mapping lives in n8n.
18
+ * `panelId` is how the agent says which panel it read, so reading a panel is a
19
+ * focus; an explicit `focus` argument beats it.
20
+ */
21
+ export declare function readToolCalls(payload: ToolCalls | null | undefined, settable: string[]): DashboardState;
22
+ /**
23
+ * Applies `values` to the page: only the `settable` names, in that order.
24
+ * `refresh` snaps to an offered interval; `time_from`/`time_to` are applied
25
+ * together at the end in one call, both ends reported even when one was asked
26
+ * for. `focus` is not applied here.
27
+ *
28
+ * @returns what really changed, for the state card
29
+ */
30
+ export declare function applyState(page: Page, values: Record<string, unknown> | null | undefined, settable: string[]): Record<string, string>;
31
+ /**
32
+ * The card saying what the agent just did to the dashboard, or null when it
33
+ * did nothing. Every value came from the model, so all of it is text, never
34
+ * markup. The focused group is a button that goes back there.
35
+ */
36
+ export declare function stateCard(doc: Document, applied: Record<string, string>, focused: Focused | null, onGo: (target: string) => void): HTMLElement | null;
37
+ /**
38
+ * Puts the card inside the last bot message. The widget's Vue list reorders
39
+ * foreign children of the list itself to below every later message; inside a
40
+ * message they are that message's own subtree and scroll away with its turn.
41
+ */
42
+ export declare function placeCard(doc: Document, card: HTMLElement): boolean;
43
+ /** Applies one turn's control chunk: the settable values, then the focus, then the card. */
44
+ export declare function applyToolCalls(page: Page, payload: ToolCalls | null | undefined, settable: string[]): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The node whose chunks drive the dashboard. Each agent workflow ends with a
3
+ * `Dashboard State` node that writes one chunk carrying the turn's tool calls
4
+ * as JSON, and n8n stamps every chunk with the node that wrote it.
5
+ */
6
+ export declare const CONTROL_NODE = "Dashboard State";
7
+ /**
8
+ * Rewrites n8n's NDJSON stream on its way to the widget. The control node's
9
+ * chunks are recognised by their author and swallowed whole - begin, item and
10
+ * end alike, since a begin/end that got through would render an empty bubble -
11
+ * and each item's content is handed to `onControl`. Every other line passes
12
+ * untouched.
13
+ *
14
+ * Chunks split anywhere, so a partial line is held back until its newline
15
+ * arrives (or the stream ends): a half-received control chunk never leaks.
16
+ */
17
+ export declare function controlFilter(onControl: (payload: unknown) => void, node?: string): TransformStream<Uint8Array, Uint8Array>;
@@ -0,0 +1 @@
1
+ export declare const STYLES: string;