@dabalabs/agent 0.0.1-beta → 0.0.2-beta

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 (47) hide show
  1. package/dist/chunk-7ENX2QZK.js +193 -0
  2. package/dist/chunk-7ENX2QZK.js.map +1 -0
  3. package/dist/chunk-CMHPVBEF.js +5195 -0
  4. package/dist/chunk-CMHPVBEF.js.map +1 -0
  5. package/dist/chunk-GCU5OBSZ.js +40 -0
  6. package/dist/chunk-GCU5OBSZ.js.map +1 -0
  7. package/dist/chunk-HJPH4GNS.cjs +196 -0
  8. package/dist/chunk-HJPH4GNS.cjs.map +1 -0
  9. package/dist/chunk-IMPMGYCG.cjs +5197 -0
  10. package/dist/chunk-IMPMGYCG.cjs.map +1 -0
  11. package/dist/chunk-JQMJMSFT.cjs +46 -0
  12. package/dist/chunk-JQMJMSFT.cjs.map +1 -0
  13. package/dist/custom-element-BZAUI4Dc.d.cts +121 -0
  14. package/dist/custom-element-PL2IXpG2.d.ts +121 -0
  15. package/dist/custom-element.cjs +4 -4
  16. package/dist/custom-element.d.cts +2 -2
  17. package/dist/custom-element.d.ts +2 -2
  18. package/dist/custom-element.js +2 -2
  19. package/dist/daba-agent.cjs +8 -8
  20. package/dist/daba-agent.d.cts +2 -2
  21. package/dist/daba-agent.d.ts +2 -2
  22. package/dist/daba-agent.js +3 -3
  23. package/dist/daba-agent.min.js +1728 -201
  24. package/dist/daba-agent.min.js.map +1 -1
  25. package/dist/react.cjs +5 -5
  26. package/dist/react.d.cts +1 -1
  27. package/dist/react.d.ts +1 -1
  28. package/dist/react.js +2 -2
  29. package/dist/types-hdR_wQ1B.d.cts +239 -0
  30. package/dist/types-hdR_wQ1B.d.ts +239 -0
  31. package/package.json +2 -2
  32. package/dist/chunk-EF6D33VT.cjs +0 -103
  33. package/dist/chunk-EF6D33VT.cjs.map +0 -1
  34. package/dist/chunk-G22V7GGM.js +0 -1667
  35. package/dist/chunk-G22V7GGM.js.map +0 -1
  36. package/dist/chunk-N4TBGDUO.cjs +0 -1669
  37. package/dist/chunk-N4TBGDUO.cjs.map +0 -1
  38. package/dist/chunk-QM6HDEVV.js +0 -39
  39. package/dist/chunk-QM6HDEVV.js.map +0 -1
  40. package/dist/chunk-WJQ444GI.js +0 -100
  41. package/dist/chunk-WJQ444GI.js.map +0 -1
  42. package/dist/chunk-ZXZX2D55.cjs +0 -45
  43. package/dist/chunk-ZXZX2D55.cjs.map +0 -1
  44. package/dist/custom-element-CpPr7b2Z.d.ts +0 -66
  45. package/dist/custom-element-XiZg8UN8.d.cts +0 -66
  46. package/dist/types-DYRGPzyp.d.cts +0 -76
  47. package/dist/types-DYRGPzyp.d.ts +0 -76
package/dist/react.cjs CHANGED
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunkZXZX2D55_cjs = require('./chunk-ZXZX2D55.cjs');
4
- require('./chunk-N4TBGDUO.cjs');
3
+ var chunkJQMJMSFT_cjs = require('./chunk-JQMJMSFT.cjs');
4
+ require('./chunk-IMPMGYCG.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "DabaAgent", {
9
9
  enumerable: true,
10
- get: function () { return chunkZXZX2D55_cjs.DabaAgentComponent; }
10
+ get: function () { return chunkJQMJMSFT_cjs.DabaAgentComponent; }
11
11
  });
12
12
  Object.defineProperty(exports, "DabaAgentComponent", {
13
13
  enumerable: true,
14
- get: function () { return chunkZXZX2D55_cjs.DabaAgentComponent; }
14
+ get: function () { return chunkJQMJMSFT_cjs.DabaAgentComponent; }
15
15
  });
16
16
  Object.defineProperty(exports, "DabaAgentReact", {
17
17
  enumerable: true,
18
- get: function () { return chunkZXZX2D55_cjs.DabaAgentComponent; }
18
+ get: function () { return chunkJQMJMSFT_cjs.DabaAgentComponent; }
19
19
  });
20
20
  //# sourceMappingURL=react.cjs.map
21
21
  //# sourceMappingURL=react.cjs.map
package/dist/react.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { a as DabaAgentOptions } from './types-DYRGPzyp.cjs';
2
+ import { a as DabaAgentOptions } from './types-hdR_wQ1B.cjs';
3
3
 
4
4
  type DabaAgentProps = Omit<DabaAgentOptions, "container">;
5
5
  declare function DabaAgentComponent(props: DabaAgentProps): React.ReactElement;
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { a as DabaAgentOptions } from './types-DYRGPzyp.js';
2
+ import { a as DabaAgentOptions } from './types-hdR_wQ1B.js';
3
3
 
4
4
  type DabaAgentProps = Omit<DabaAgentOptions, "container">;
5
5
  declare function DabaAgentComponent(props: DabaAgentProps): React.ReactElement;
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- export { DabaAgentComponent as DabaAgent, DabaAgentComponent, DabaAgentComponent as DabaAgentReact } from './chunk-QM6HDEVV.js';
2
- import './chunk-G22V7GGM.js';
1
+ export { DabaAgentComponent as DabaAgent, DabaAgentComponent, DabaAgentComponent as DabaAgentReact } from './chunk-GCU5OBSZ.js';
2
+ import './chunk-CMHPVBEF.js';
3
3
  //# sourceMappingURL=react.js.map
4
4
  //# sourceMappingURL=react.js.map
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Which deployment tier this widget talks to.
3
+ *
4
+ * Production is the default in every direction: an embed that says
5
+ * nothing about its environment is a customer's live site, and the one
6
+ * outcome worth engineering against is a production page silently
7
+ * pointing at staging. So the mapping is deliberately asymmetric —
8
+ * "staging" must be asked for by name, and anything else resolves to
9
+ * production.
10
+ */
11
+ type DabaEnvironment = "production" | "staging";
12
+
13
+ type DabaVoiceEngine = "realtime" | "live";
14
+ type DabaErrorKind = "invalid_key" | "origin_not_allowed" | "not_found" | "network" | "restricted";
15
+ interface DabaError {
16
+ kind: DabaErrorKind;
17
+ message: string;
18
+ }
19
+ /** "listening" = mic capturing, "thinking" = waiting on a model turn,
20
+ * "speaking" = agent audio playing back, "idle" = session not active.
21
+ * Text chat uses "thinking" and "idle" only — it never opens a mic. */
22
+ type DabaAgentStatus = "idle" | "connecting" | "listening" | "thinking" | "speaking";
23
+ /** Which viewport corner the default floating badge is pinned to. Only
24
+ * applies to the default badge (no custom `container`) — a host handing
25
+ * in its own `container` owns that element's placement entirely. */
26
+ type DabaAgentPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
27
+ /**
28
+ * Which media the assistant offers.
29
+ *
30
+ * - "voice" — talk only. Badge click starts/stops a Realtime session.
31
+ * - "chat" — type only. No microphone is ever requested.
32
+ * - "hybrid" — both, in one panel, sharing one transcript.
33
+ *
34
+ * These are genuinely independent transports, not one feature with a
35
+ * switch: chat is a plain HTTP turn against the gateway, voice is a
36
+ * Realtime WebSocket with a mic. A visitor in "chat" mode never grants
37
+ * microphone permission and never costs a voice minute.
38
+ */
39
+ type DabaAgentMode = "hybrid" | "voice" | "chat";
40
+ /** Text direction of the widget's own chrome. "auto" reads the host
41
+ * page's `dir`/`lang`, which is what makes the panel flip to RTL on an
42
+ * Arabic site without the integrator configuring anything. */
43
+ type DabaDirection = "auto" | "ltr" | "rtl";
44
+ type DabaThemePreference = "auto" | "light" | "dark";
45
+ type DabaLauncherShape = "rounded" | "circle" | "pill";
46
+ /** What a card is about. Drives the icon, the accent and which fields the
47
+ * card bothers to render — an event shows a date and a map link, an
48
+ * article shows a date and a read-more link. Unknown kinds render as
49
+ * "page", never as nothing. */
50
+ type DabaCardKind = "article" | "event" | "news" | "page" | "contact" | "action";
51
+ interface DabaCardMeta {
52
+ label: string;
53
+ value: string;
54
+ }
55
+ /**
56
+ * One structured item in a reply — an event, an article, a news item.
57
+ *
58
+ * The gateway builds and sanitises these (see routes/public_agents.rs::
59
+ * sanitize_cards): `mapUrl` is always constructed server-side from the
60
+ * address, and `url`/`imageUrl` are dropped unless they point at the
61
+ * site the widget is embedded in. So the widget can render every field
62
+ * here without re-validating it.
63
+ */
64
+ interface DabaCard {
65
+ kind: DabaCardKind;
66
+ title: string;
67
+ summary?: string | null;
68
+ /** ISO-8601 date or datetime. Formatted for display with `Intl` in the
69
+ * resolved UI locale, so an Arabic panel shows an Arabic date. */
70
+ date?: string | null;
71
+ endDate?: string | null;
72
+ locationName?: string | null;
73
+ address?: string | null;
74
+ /** Always gateway-built from the address — never whatever the model said. */
75
+ mapUrl?: string | null;
76
+ url?: string | null;
77
+ imageUrl?: string | null;
78
+ sourcePath?: string | null;
79
+ meta?: DabaCardMeta[];
80
+ }
81
+ interface ChatMessage {
82
+ id: string;
83
+ role: "user" | "agent" | "system";
84
+ text: string;
85
+ timestamp: number;
86
+ isFinal?: boolean;
87
+ cards?: DabaCard[];
88
+ suggestions?: string[];
89
+ }
90
+ /**
91
+ * Colour and shape overrides. Every field is optional and every absent
92
+ * field falls back to the Dabalabs brand kit, so `{}` is a complete,
93
+ * correct theme rather than an empty one.
94
+ */
95
+ interface DabaTheme {
96
+ accentColor?: string;
97
+ /** Text/icon colour drawn ON the accent. Defaults to white; a site with
98
+ * a pale accent needs to be able to say "ink", or its buttons are
99
+ * illegible. */
100
+ accentContrast?: string;
101
+ surfaceColor?: string;
102
+ textColor?: string;
103
+ mutedColor?: string;
104
+ borderColor?: string;
105
+ /** Any CSS length — "18px", "0", "1.5rem". */
106
+ radius?: string;
107
+ fontFamily?: string;
108
+ theme?: DabaThemePreference;
109
+ }
110
+ /** The panel shown on first open, before anybody has said anything. */
111
+ interface DabaIntro {
112
+ enabled?: boolean;
113
+ headline?: string | null;
114
+ subheadline?: string | null;
115
+ /** A short looping video or a still. Same-origin or https. */
116
+ mediaUrl?: string | null;
117
+ mediaType?: "video" | "image" | "none";
118
+ /** Tappable starter questions. These are what turn an empty box into an
119
+ * obvious next action, and they are the single biggest lever on whether
120
+ * a visitor ever sends a first message. */
121
+ suggestedPrompts?: string[];
122
+ }
123
+ interface DabaLauncher {
124
+ shape?: DabaLauncherShape;
125
+ /** Replaces the shipped mark entirely. Use for a customer's own logo. */
126
+ iconUrl?: string | null;
127
+ /** Text beside the icon, turning the badge into a labelled pill. */
128
+ label?: string | null;
129
+ }
130
+ interface DabaAgentOptions {
131
+ projectId: string;
132
+ apiKey: string;
133
+ /** Overrides `env` when both are given — the only option that can name
134
+ * a host neither tier covers (self-hosted, a local gateway). */
135
+ gatewayUrl?: string;
136
+ /** Which Dabalabs tier to talk to. Omit for production; pass "staging"
137
+ * to point the agent at the staging gateway. */
138
+ env?: DabaEnvironment;
139
+ /** Where to mount the widget. Defaults to a fixed-position element
140
+ * appended to <body> when omitted. */
141
+ container?: string | HTMLElement;
142
+ /** Corner of the viewport the default badge is fixed to. */
143
+ position?: DabaAgentPosition;
144
+ /**
145
+ * Everything below is an OVERRIDE of what the project already carries.
146
+ *
147
+ * The gateway serves a project's mode, theme, intro and locale from
148
+ * `GET /v1/public/agents/:id`, so an owner restyles their assistant
149
+ * from the dashboard and every embed picks it up on next load. An
150
+ * option passed here wins over the served value — an integrator who
151
+ * hard-codes a colour means it.
152
+ *
153
+ * Undefined is not "default", it is "defer to the server". That
154
+ * distinction is what makes remote configuration work at all.
155
+ */
156
+ mode?: DabaAgentMode;
157
+ voiceEngine?: DabaVoiceEngine;
158
+ theme?: DabaTheme;
159
+ intro?: DabaIntro;
160
+ launcher?: DabaLauncher;
161
+ /** Brand logo shown in the panel header. */
162
+ logoUrl?: string | null;
163
+ /** BCP-47 code for the widget's own chrome, or "auto" to follow the
164
+ * host page's `lang`. Independent of what the assistant replies in —
165
+ * it always answers in the visitor's language regardless. */
166
+ uiLanguage?: string;
167
+ direction?: DabaDirection;
168
+ accentColor?: string;
169
+ /** Recolour the trigger icon's background substrate (the colour under
170
+ * the grain/noise texture). Defaults to the icon's shipped green. */
171
+ iconBackgroundColor?: string;
172
+ /** Recolour the trigger icon's centre mark (the face/mask shape). */
173
+ iconMarkColor?: string;
174
+ /** Header title displayed in the chat window. Defaults to the project's
175
+ * title, then to a localised "AI Assistant". */
176
+ title?: string;
177
+ placeholder?: string;
178
+ /** Whether the chat popover starts open. */
179
+ initialOpen?: boolean;
180
+ /** Defaults to "ctrl+space". Set to `null` to disable the hotkey. */
181
+ hotkey?: string | null;
182
+ onError?: (error: DabaError) => void;
183
+ onStatusChange?: (status: DabaAgentStatus) => void;
184
+ /** Fired for both user speech/text and agent reply deltas. */
185
+ onTranscript?: (role: "user" | "agent", text: string, isFinal: boolean) => void;
186
+ onChatToggle?: (isOpen: boolean) => void;
187
+ /** Fired once per reply that carried structured items. */
188
+ onCards?: (cards: DabaCard[]) => void;
189
+ }
190
+ /**
191
+ * What the gateway serves for a project. Mirrors the JSON of
192
+ * `GET /v1/public/agents/:id` with keys camelised; every field is present
193
+ * because the gateway fills its own defaults before responding.
194
+ */
195
+ interface DabaRemoteConfig {
196
+ projectId: string;
197
+ title: string;
198
+ greetingMessage: string | null;
199
+ mode: DabaAgentMode;
200
+ voiceEngine?: DabaVoiceEngine;
201
+ appearance: {
202
+ accentColor: string | null;
203
+ accentContrast: string | null;
204
+ surfaceColor: string | null;
205
+ textColor: string | null;
206
+ radius: string | null;
207
+ fontFamily: string | null;
208
+ logoUrl: string | null;
209
+ launcherIconUrl: string | null;
210
+ launcherLabel: string | null;
211
+ launcherShape: DabaLauncherShape;
212
+ position: DabaAgentPosition | null;
213
+ theme: DabaThemePreference;
214
+ };
215
+ intro: {
216
+ enabled: boolean;
217
+ headline: string | null;
218
+ subheadline: string | null;
219
+ mediaUrl: string | null;
220
+ mediaType: "video" | "image" | "none";
221
+ suggestedPrompts: string[];
222
+ };
223
+ locale: {
224
+ uiLanguage: string;
225
+ direction: DabaDirection;
226
+ };
227
+ }
228
+ /** One text turn, as the chat endpoint returns it. */
229
+ interface DabaChatReply {
230
+ reply: string;
231
+ language: string;
232
+ cards: DabaCard[];
233
+ /** Follow-up questions the assistant thinks are likely next. Rendered as
234
+ * tappable chips under the reply; tapping one sends it. */
235
+ suggestions: string[];
236
+ conversationId: string;
237
+ }
238
+
239
+ export type { ChatMessage as C, DabaAgentMode as D, DabaAgentOptions as a, DabaAgentPosition as b, DabaAgentStatus as c, DabaCard as d, DabaCardKind as e, DabaCardMeta as f, DabaChatReply as g, DabaDirection as h, DabaError as i, DabaIntro as j, DabaLauncher as k, DabaLauncherShape as l, DabaRemoteConfig as m, DabaTheme as n, DabaThemePreference as o };
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Which deployment tier this widget talks to.
3
+ *
4
+ * Production is the default in every direction: an embed that says
5
+ * nothing about its environment is a customer's live site, and the one
6
+ * outcome worth engineering against is a production page silently
7
+ * pointing at staging. So the mapping is deliberately asymmetric —
8
+ * "staging" must be asked for by name, and anything else resolves to
9
+ * production.
10
+ */
11
+ type DabaEnvironment = "production" | "staging";
12
+
13
+ type DabaVoiceEngine = "realtime" | "live";
14
+ type DabaErrorKind = "invalid_key" | "origin_not_allowed" | "not_found" | "network" | "restricted";
15
+ interface DabaError {
16
+ kind: DabaErrorKind;
17
+ message: string;
18
+ }
19
+ /** "listening" = mic capturing, "thinking" = waiting on a model turn,
20
+ * "speaking" = agent audio playing back, "idle" = session not active.
21
+ * Text chat uses "thinking" and "idle" only — it never opens a mic. */
22
+ type DabaAgentStatus = "idle" | "connecting" | "listening" | "thinking" | "speaking";
23
+ /** Which viewport corner the default floating badge is pinned to. Only
24
+ * applies to the default badge (no custom `container`) — a host handing
25
+ * in its own `container` owns that element's placement entirely. */
26
+ type DabaAgentPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
27
+ /**
28
+ * Which media the assistant offers.
29
+ *
30
+ * - "voice" — talk only. Badge click starts/stops a Realtime session.
31
+ * - "chat" — type only. No microphone is ever requested.
32
+ * - "hybrid" — both, in one panel, sharing one transcript.
33
+ *
34
+ * These are genuinely independent transports, not one feature with a
35
+ * switch: chat is a plain HTTP turn against the gateway, voice is a
36
+ * Realtime WebSocket with a mic. A visitor in "chat" mode never grants
37
+ * microphone permission and never costs a voice minute.
38
+ */
39
+ type DabaAgentMode = "hybrid" | "voice" | "chat";
40
+ /** Text direction of the widget's own chrome. "auto" reads the host
41
+ * page's `dir`/`lang`, which is what makes the panel flip to RTL on an
42
+ * Arabic site without the integrator configuring anything. */
43
+ type DabaDirection = "auto" | "ltr" | "rtl";
44
+ type DabaThemePreference = "auto" | "light" | "dark";
45
+ type DabaLauncherShape = "rounded" | "circle" | "pill";
46
+ /** What a card is about. Drives the icon, the accent and which fields the
47
+ * card bothers to render — an event shows a date and a map link, an
48
+ * article shows a date and a read-more link. Unknown kinds render as
49
+ * "page", never as nothing. */
50
+ type DabaCardKind = "article" | "event" | "news" | "page" | "contact" | "action";
51
+ interface DabaCardMeta {
52
+ label: string;
53
+ value: string;
54
+ }
55
+ /**
56
+ * One structured item in a reply — an event, an article, a news item.
57
+ *
58
+ * The gateway builds and sanitises these (see routes/public_agents.rs::
59
+ * sanitize_cards): `mapUrl` is always constructed server-side from the
60
+ * address, and `url`/`imageUrl` are dropped unless they point at the
61
+ * site the widget is embedded in. So the widget can render every field
62
+ * here without re-validating it.
63
+ */
64
+ interface DabaCard {
65
+ kind: DabaCardKind;
66
+ title: string;
67
+ summary?: string | null;
68
+ /** ISO-8601 date or datetime. Formatted for display with `Intl` in the
69
+ * resolved UI locale, so an Arabic panel shows an Arabic date. */
70
+ date?: string | null;
71
+ endDate?: string | null;
72
+ locationName?: string | null;
73
+ address?: string | null;
74
+ /** Always gateway-built from the address — never whatever the model said. */
75
+ mapUrl?: string | null;
76
+ url?: string | null;
77
+ imageUrl?: string | null;
78
+ sourcePath?: string | null;
79
+ meta?: DabaCardMeta[];
80
+ }
81
+ interface ChatMessage {
82
+ id: string;
83
+ role: "user" | "agent" | "system";
84
+ text: string;
85
+ timestamp: number;
86
+ isFinal?: boolean;
87
+ cards?: DabaCard[];
88
+ suggestions?: string[];
89
+ }
90
+ /**
91
+ * Colour and shape overrides. Every field is optional and every absent
92
+ * field falls back to the Dabalabs brand kit, so `{}` is a complete,
93
+ * correct theme rather than an empty one.
94
+ */
95
+ interface DabaTheme {
96
+ accentColor?: string;
97
+ /** Text/icon colour drawn ON the accent. Defaults to white; a site with
98
+ * a pale accent needs to be able to say "ink", or its buttons are
99
+ * illegible. */
100
+ accentContrast?: string;
101
+ surfaceColor?: string;
102
+ textColor?: string;
103
+ mutedColor?: string;
104
+ borderColor?: string;
105
+ /** Any CSS length — "18px", "0", "1.5rem". */
106
+ radius?: string;
107
+ fontFamily?: string;
108
+ theme?: DabaThemePreference;
109
+ }
110
+ /** The panel shown on first open, before anybody has said anything. */
111
+ interface DabaIntro {
112
+ enabled?: boolean;
113
+ headline?: string | null;
114
+ subheadline?: string | null;
115
+ /** A short looping video or a still. Same-origin or https. */
116
+ mediaUrl?: string | null;
117
+ mediaType?: "video" | "image" | "none";
118
+ /** Tappable starter questions. These are what turn an empty box into an
119
+ * obvious next action, and they are the single biggest lever on whether
120
+ * a visitor ever sends a first message. */
121
+ suggestedPrompts?: string[];
122
+ }
123
+ interface DabaLauncher {
124
+ shape?: DabaLauncherShape;
125
+ /** Replaces the shipped mark entirely. Use for a customer's own logo. */
126
+ iconUrl?: string | null;
127
+ /** Text beside the icon, turning the badge into a labelled pill. */
128
+ label?: string | null;
129
+ }
130
+ interface DabaAgentOptions {
131
+ projectId: string;
132
+ apiKey: string;
133
+ /** Overrides `env` when both are given — the only option that can name
134
+ * a host neither tier covers (self-hosted, a local gateway). */
135
+ gatewayUrl?: string;
136
+ /** Which Dabalabs tier to talk to. Omit for production; pass "staging"
137
+ * to point the agent at the staging gateway. */
138
+ env?: DabaEnvironment;
139
+ /** Where to mount the widget. Defaults to a fixed-position element
140
+ * appended to <body> when omitted. */
141
+ container?: string | HTMLElement;
142
+ /** Corner of the viewport the default badge is fixed to. */
143
+ position?: DabaAgentPosition;
144
+ /**
145
+ * Everything below is an OVERRIDE of what the project already carries.
146
+ *
147
+ * The gateway serves a project's mode, theme, intro and locale from
148
+ * `GET /v1/public/agents/:id`, so an owner restyles their assistant
149
+ * from the dashboard and every embed picks it up on next load. An
150
+ * option passed here wins over the served value — an integrator who
151
+ * hard-codes a colour means it.
152
+ *
153
+ * Undefined is not "default", it is "defer to the server". That
154
+ * distinction is what makes remote configuration work at all.
155
+ */
156
+ mode?: DabaAgentMode;
157
+ voiceEngine?: DabaVoiceEngine;
158
+ theme?: DabaTheme;
159
+ intro?: DabaIntro;
160
+ launcher?: DabaLauncher;
161
+ /** Brand logo shown in the panel header. */
162
+ logoUrl?: string | null;
163
+ /** BCP-47 code for the widget's own chrome, or "auto" to follow the
164
+ * host page's `lang`. Independent of what the assistant replies in —
165
+ * it always answers in the visitor's language regardless. */
166
+ uiLanguage?: string;
167
+ direction?: DabaDirection;
168
+ accentColor?: string;
169
+ /** Recolour the trigger icon's background substrate (the colour under
170
+ * the grain/noise texture). Defaults to the icon's shipped green. */
171
+ iconBackgroundColor?: string;
172
+ /** Recolour the trigger icon's centre mark (the face/mask shape). */
173
+ iconMarkColor?: string;
174
+ /** Header title displayed in the chat window. Defaults to the project's
175
+ * title, then to a localised "AI Assistant". */
176
+ title?: string;
177
+ placeholder?: string;
178
+ /** Whether the chat popover starts open. */
179
+ initialOpen?: boolean;
180
+ /** Defaults to "ctrl+space". Set to `null` to disable the hotkey. */
181
+ hotkey?: string | null;
182
+ onError?: (error: DabaError) => void;
183
+ onStatusChange?: (status: DabaAgentStatus) => void;
184
+ /** Fired for both user speech/text and agent reply deltas. */
185
+ onTranscript?: (role: "user" | "agent", text: string, isFinal: boolean) => void;
186
+ onChatToggle?: (isOpen: boolean) => void;
187
+ /** Fired once per reply that carried structured items. */
188
+ onCards?: (cards: DabaCard[]) => void;
189
+ }
190
+ /**
191
+ * What the gateway serves for a project. Mirrors the JSON of
192
+ * `GET /v1/public/agents/:id` with keys camelised; every field is present
193
+ * because the gateway fills its own defaults before responding.
194
+ */
195
+ interface DabaRemoteConfig {
196
+ projectId: string;
197
+ title: string;
198
+ greetingMessage: string | null;
199
+ mode: DabaAgentMode;
200
+ voiceEngine?: DabaVoiceEngine;
201
+ appearance: {
202
+ accentColor: string | null;
203
+ accentContrast: string | null;
204
+ surfaceColor: string | null;
205
+ textColor: string | null;
206
+ radius: string | null;
207
+ fontFamily: string | null;
208
+ logoUrl: string | null;
209
+ launcherIconUrl: string | null;
210
+ launcherLabel: string | null;
211
+ launcherShape: DabaLauncherShape;
212
+ position: DabaAgentPosition | null;
213
+ theme: DabaThemePreference;
214
+ };
215
+ intro: {
216
+ enabled: boolean;
217
+ headline: string | null;
218
+ subheadline: string | null;
219
+ mediaUrl: string | null;
220
+ mediaType: "video" | "image" | "none";
221
+ suggestedPrompts: string[];
222
+ };
223
+ locale: {
224
+ uiLanguage: string;
225
+ direction: DabaDirection;
226
+ };
227
+ }
228
+ /** One text turn, as the chat endpoint returns it. */
229
+ interface DabaChatReply {
230
+ reply: string;
231
+ language: string;
232
+ cards: DabaCard[];
233
+ /** Follow-up questions the assistant thinks are likely next. Rendered as
234
+ * tappable chips under the reply; tapping one sends it. */
235
+ suggestions: string[];
236
+ conversationId: string;
237
+ }
238
+
239
+ export type { ChatMessage as C, DabaAgentMode as D, DabaAgentOptions as a, DabaAgentPosition as b, DabaAgentStatus as c, DabaCard as d, DabaCardKind as e, DabaCardMeta as f, DabaChatReply as g, DabaDirection as h, DabaError as i, DabaIntro as j, DabaLauncher as k, DabaLauncherShape as l, DabaRemoteConfig as m, DabaTheme as n, DabaThemePreference as o };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dabalabs/agent",
3
- "version": "0.0.1-beta",
4
- "description": "Embeddable voice AI website assistant widget for dabalabs projects \u2014 press Ctrl+Space, talk to your site.",
3
+ "version": "0.0.2-beta",
4
+ "description": "Embeddable voice AI website assistant widget for dabalabs projects press Ctrl+Space, talk to your site.",
5
5
  "author": "dabalabs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://dabalabs.com",
@@ -1,103 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkN4TBGDUO_cjs = require('./chunk-N4TBGDUO.cjs');
4
-
5
- // src/components/custom-element.ts
6
- var DabaAgentElement = class extends HTMLElement {
7
- constructor() {
8
- super(...arguments);
9
- this.agent = null;
10
- }
11
- connectedCallback() {
12
- if (this.agent) return;
13
- const getAttr = (name) => this.getAttribute(name) ?? this.getAttribute(`data-${name}`);
14
- const projectId = getAttr("project-id");
15
- const apiKey = getAttr("api-key");
16
- if (!projectId || !apiKey) {
17
- console.error(
18
- "daba-agent: <daba-agent> custom element requires project-id and api-key attributes.",
19
- this
20
- );
21
- return;
22
- }
23
- const position = getAttr("position") ?? void 0;
24
- const accentColor = getAttr("accent-color") ?? void 0;
25
- const mode = getAttr("mode") ?? void 0;
26
- const title = getAttr("title") ?? void 0;
27
- const placeholder = getAttr("placeholder") ?? void 0;
28
- const initialOpen = this.hasAttribute("initial-open") || this.hasAttribute("data-initial-open");
29
- const hotkey = getAttr("hotkey") ?? void 0;
30
- const gatewayUrl = getAttr("gateway-url") ?? void 0;
31
- this.agent = new chunkN4TBGDUO_cjs.DabaAgent({
32
- container: this,
33
- projectId,
34
- apiKey,
35
- position,
36
- accentColor,
37
- mode,
38
- title,
39
- placeholder,
40
- initialOpen,
41
- hotkey,
42
- gatewayUrl,
43
- onStatusChange: (status) => {
44
- this.dispatchEvent(
45
- new CustomEvent("daba-status-change", { detail: { status }, bubbles: true, composed: true })
46
- );
47
- },
48
- onTranscript: (role, text, isFinal) => {
49
- this.dispatchEvent(
50
- new CustomEvent("daba-transcript", {
51
- detail: { role, text, isFinal },
52
- bubbles: true,
53
- composed: true
54
- })
55
- );
56
- },
57
- onError: (error) => {
58
- this.dispatchEvent(
59
- new CustomEvent("daba-error", { detail: { error }, bubbles: true, composed: true })
60
- );
61
- },
62
- onChatToggle: (isOpen) => {
63
- this.dispatchEvent(
64
- new CustomEvent("daba-chat-toggle", { detail: { isOpen }, bubbles: true, composed: true })
65
- );
66
- }
67
- });
68
- }
69
- disconnectedCallback() {
70
- if (this.agent) {
71
- this.agent.destroy();
72
- this.agent = null;
73
- }
74
- }
75
- get dabaAgent() {
76
- return this.agent;
77
- }
78
- sendText(text) {
79
- return this.agent?.sendText(text);
80
- }
81
- openChat() {
82
- this.agent?.openChat();
83
- }
84
- closeChat() {
85
- this.agent?.closeChat();
86
- }
87
- toggleChat() {
88
- this.agent?.toggleChat();
89
- }
90
- };
91
- function defineDabaAgentElement(tagName = "daba-agent") {
92
- if (typeof window !== "undefined" && typeof customElements !== "undefined") {
93
- if (!customElements.get(tagName)) {
94
- customElements.define(tagName, DabaAgentElement);
95
- }
96
- }
97
- }
98
- defineDabaAgentElement();
99
-
100
- exports.DabaAgentElement = DabaAgentElement;
101
- exports.defineDabaAgentElement = defineDabaAgentElement;
102
- //# sourceMappingURL=chunk-EF6D33VT.cjs.map
103
- //# sourceMappingURL=chunk-EF6D33VT.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/custom-element.ts"],"names":["DabaAgent"],"mappings":";;;;;AAGO,IAAM,gBAAA,GAAN,cAA+B,WAAA,CAAY;AAAA,EAA3C,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACL,IAAA,IAAA,CAAQ,KAAA,GAA0B,IAAA;AAAA,EAAA;AAAA,EAElC,iBAAA,GAA0B;AACxB,IAAA,IAAI,KAAK,KAAA,EAAO;AAEhB,IAAA,MAAM,OAAA,GAAU,CAAC,IAAA,KACf,IAAA,CAAK,YAAA,CAAa,IAAI,CAAA,IAAK,IAAA,CAAK,YAAA,CAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,CAAE,CAAA;AAE7D,IAAA,MAAM,SAAA,GAAY,QAAQ,YAAY,CAAA;AACtC,IAAA,MAAM,MAAA,GAAS,QAAQ,SAAS,CAAA;AAEhC,IAAA,IAAI,CAAC,SAAA,IAAa,CAAC,MAAA,EAAQ;AACzB,MAAA,OAAA,CAAQ,KAAA;AAAA,QACN,qFAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,QAAA,GAAY,OAAA,CAAQ,UAAU,CAAA,IAA2B,MAAA;AAC/D,IAAA,MAAM,WAAA,GAAc,OAAA,CAAQ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,EAAa;AAC1E,IAAA,IAAI,CAAC,cAAA,CAAe,GAAA,CAAI,OAAO,CAAA,EAAG;AAChC,MAAA,cAAA,CAAe,MAAA,CAAO,SAAS,gBAAgB,CAAA;AAAA,IACjD;AAAA,EACF;AACF;AAEA,sBAAA,EAAuB","file":"chunk-EF6D33VT.cjs","sourcesContent":["import { DabaAgent } from \"../agent\";\nimport type { DabaAgentPosition, DabaAgentMode } from \"../types\";\n\nexport class DabaAgentElement extends HTMLElement {\n private agent: DabaAgent | null = null;\n\n connectedCallback(): void {\n if (this.agent) return;\n\n const getAttr = (name: string): string | null =>\n this.getAttribute(name) ?? this.getAttribute(`data-${name}`);\n\n const projectId = getAttr(\"project-id\");\n const apiKey = getAttr(\"api-key\");\n\n if (!projectId || !apiKey) {\n console.error(\n \"daba-agent: <daba-agent> custom element requires project-id and api-key attributes.\",\n this,\n );\n return;\n }\n\n const position = (getAttr(\"position\") as DabaAgentPosition) ?? undefined;\n const accentColor = getAttr(\"accent-color\") ?? undefined;\n const mode = (getAttr(\"mode\") as DabaAgentMode) ?? undefined;\n const title = getAttr(\"title\") ?? undefined;\n const placeholder = getAttr(\"placeholder\") ?? undefined;\n const initialOpen = this.hasAttribute(\"initial-open\") || this.hasAttribute(\"data-initial-open\");\n const hotkey = getAttr(\"hotkey\") ?? undefined;\n const gatewayUrl = getAttr(\"gateway-url\") ?? undefined;\n\n this.agent = new DabaAgent({\n container: this,\n projectId,\n apiKey,\n position,\n accentColor,\n mode,\n title,\n placeholder,\n initialOpen,\n hotkey,\n gatewayUrl,\n onStatusChange: (status) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-status-change\", { detail: { status }, bubbles: true, composed: true }),\n );\n },\n onTranscript: (role, text, isFinal) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-transcript\", {\n detail: { role, text, isFinal },\n bubbles: true,\n composed: true,\n }),\n );\n },\n onError: (error) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-error\", { detail: { error }, bubbles: true, composed: true }),\n );\n },\n onChatToggle: (isOpen) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-chat-toggle\", { detail: { isOpen }, bubbles: true, composed: true }),\n );\n },\n });\n }\n\n disconnectedCallback(): void {\n if (this.agent) {\n this.agent.destroy();\n this.agent = null;\n }\n }\n\n public get dabaAgent(): DabaAgent | null {\n return this.agent;\n }\n\n public sendText(text: string): Promise<void> | undefined {\n return this.agent?.sendText(text);\n }\n\n public openChat(): void {\n this.agent?.openChat();\n }\n\n public closeChat(): void {\n this.agent?.closeChat();\n }\n\n public toggleChat(): void {\n this.agent?.toggleChat();\n }\n}\n\nexport function defineDabaAgentElement(tagName = \"daba-agent\"): void {\n if (typeof window !== \"undefined\" && typeof customElements !== \"undefined\") {\n if (!customElements.get(tagName)) {\n customElements.define(tagName, DabaAgentElement);\n }\n }\n}\n\ndefineDabaAgentElement();\n"]}