@dabalabs/agent 0.0.2-beta → 0.0.4-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 (40) hide show
  1. package/README.md +56 -3
  2. package/dist/chunk-3BQ6LE6X.cjs +222 -0
  3. package/dist/chunk-3BQ6LE6X.cjs.map +1 -0
  4. package/dist/{chunk-CMHPVBEF.js → chunk-ETI4LRM7.js} +841 -100
  5. package/dist/chunk-ETI4LRM7.js.map +1 -0
  6. package/dist/chunk-TYOHYQDK.js +220 -0
  7. package/dist/chunk-TYOHYQDK.js.map +1 -0
  8. package/dist/{chunk-IMPMGYCG.cjs → chunk-VAIC5ACS.cjs} +841 -99
  9. package/dist/chunk-VAIC5ACS.cjs.map +1 -0
  10. package/dist/custom-element.cjs +4 -4
  11. package/dist/custom-element.d.cts +191 -2
  12. package/dist/custom-element.d.ts +191 -2
  13. package/dist/custom-element.js +2 -2
  14. package/dist/daba-agent.cjs +5 -14
  15. package/dist/daba-agent.d.cts +2 -4
  16. package/dist/daba-agent.d.ts +2 -4
  17. package/dist/daba-agent.js +2 -3
  18. package/dist/daba-agent.min.js +141 -36
  19. package/dist/daba-agent.min.js.map +1 -1
  20. package/dist/react.cjs +41 -14
  21. package/dist/react.cjs.map +1 -1
  22. package/dist/react.d.cts +1 -1
  23. package/dist/react.d.ts +1 -1
  24. package/dist/react.js +38 -2
  25. package/dist/react.js.map +1 -1
  26. package/dist/{types-hdR_wQ1B.d.cts → types-BQRgqD4n.d.cts} +70 -4
  27. package/dist/{types-hdR_wQ1B.d.ts → types-BQRgqD4n.d.ts} +70 -4
  28. package/package.json +1 -1
  29. package/dist/chunk-7ENX2QZK.js +0 -193
  30. package/dist/chunk-7ENX2QZK.js.map +0 -1
  31. package/dist/chunk-CMHPVBEF.js.map +0 -1
  32. package/dist/chunk-GCU5OBSZ.js +0 -40
  33. package/dist/chunk-GCU5OBSZ.js.map +0 -1
  34. package/dist/chunk-HJPH4GNS.cjs +0 -196
  35. package/dist/chunk-HJPH4GNS.cjs.map +0 -1
  36. package/dist/chunk-IMPMGYCG.cjs.map +0 -1
  37. package/dist/chunk-JQMJMSFT.cjs +0 -46
  38. package/dist/chunk-JQMJMSFT.cjs.map +0 -1
  39. package/dist/custom-element-BZAUI4Dc.d.cts +0 -121
  40. package/dist/custom-element-PL2IXpG2.d.ts +0 -121
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkIMPMGYCG_cjs = require('./chunk-IMPMGYCG.cjs');
4
- var React = require('react');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var React__default = /*#__PURE__*/_interopDefault(React);
9
-
10
- function DabaAgentComponent(props) {
11
- const containerRef = React.useRef(null);
12
- const agentRef = React.useRef(null);
13
- const propsRef = React.useRef(props);
14
- propsRef.current = props;
15
- const configKey = JSON.stringify(
16
- props,
17
- (_key, value) => typeof value === "function" ? void 0 : value
18
- );
19
- React.useEffect(() => {
20
- if (!containerRef.current) return;
21
- const agent = new chunkIMPMGYCG_cjs.DabaAgent({
22
- ...propsRef.current,
23
- // After the spread: this component owns where the widget mounts.
24
- container: containerRef.current,
25
- onStatusChange: (status) => propsRef.current.onStatusChange?.(status),
26
- onTranscript: (role, text, isFinal) => propsRef.current.onTranscript?.(role, text, isFinal),
27
- onChatToggle: (isOpen) => propsRef.current.onChatToggle?.(isOpen),
28
- onCards: (cards) => propsRef.current.onCards?.(cards),
29
- onError: (error) => propsRef.current.onError?.(error)
30
- });
31
- agentRef.current = agent;
32
- return () => {
33
- agent.destroy();
34
- agentRef.current = null;
35
- };
36
- }, [configKey]);
37
- return React__default.default.createElement("div", {
38
- ref: containerRef,
39
- style: { display: "contents" },
40
- "data-daba-agent-react-container": "true"
41
- });
42
- }
43
-
44
- exports.DabaAgentComponent = DabaAgentComponent;
45
- //# sourceMappingURL=chunk-JQMJMSFT.cjs.map
46
- //# sourceMappingURL=chunk-JQMJMSFT.cjs.map
@@ -1 +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AAA,EAAQ;AACd,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAA,OAAOC,sBAAA,CAAM,cAAc,KAAA,EAAO;AAAA,IAChC,GAAA,EAAK,YAAA;AAAA,IACL,KAAA,EAAO,EAAE,OAAA,EAAS,UAAA,EAAW;AAAA,IAC7B,iCAAA,EAAmC;AAAA,GACpC,CAAA;AACH","file":"chunk-JQMJMSFT.cjs","sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { DabaAgent } from \"../agent\";\nimport type { DabaAgentOptions } from \"../types\";\n\nexport type DabaAgentProps = Omit<DabaAgentOptions, \"container\">;\n\nexport function DabaAgentComponent(props: DabaAgentProps): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null);\n const agentRef = useRef<DabaAgent | null>(null);\n\n // The agent reads its handlers back out of this ref at call time, which\n // is what keeps an inline `onCards={(c) => setCards(c)}` current without\n // its per-render identity forcing a rebuild below.\n const propsRef = useRef(props);\n propsRef.current = props;\n\n /**\n * The effect keys on the configuration's VALUE, not on the prop objects.\n *\n * `theme={{ accentColor: \"#0c8c5e\" }}` is a fresh object on every render\n * of the parent, so listing it as a dependency would destroy and rebuild\n * the widget — closing the panel, dropping the conversation, restarting\n * a voice session — every time an unrelated piece of the host page's\n * state changed. Serialising compares the way the integrator meant it.\n *\n * Functions are stripped rather than compared: callbacks are re-created\n * on every render too, and they reach the live agent through `propsRef`\n * instead. Serialising also means a newly added option is covered here\n * the moment it exists, which the hand-listed dependency array this\n * replaces was already out of step with (`env` never made it in).\n */\n const configKey = JSON.stringify(props, (_key, value) =>\n typeof value === \"function\" ? undefined : value,\n );\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const agent = new DabaAgent({\n ...propsRef.current,\n // After the spread: this component owns where the widget mounts.\n container: containerRef.current,\n onStatusChange: (status) => propsRef.current.onStatusChange?.(status),\n onTranscript: (role, text, isFinal) =>\n propsRef.current.onTranscript?.(role, text, isFinal),\n onChatToggle: (isOpen) => propsRef.current.onChatToggle?.(isOpen),\n onCards: (cards) => propsRef.current.onCards?.(cards),\n onError: (error) => propsRef.current.onError?.(error),\n });\n agentRef.current = agent;\n\n return () => {\n agent.destroy();\n agentRef.current = null;\n };\n }, [configKey]);\n\n return React.createElement(\"div\", {\n ref: containerRef,\n style: { display: \"contents\" },\n \"data-daba-agent-react-container\": \"true\",\n });\n}\n\nexport { DabaAgentComponent as DabaAgentReact, DabaAgentComponent as DabaAgent };\n"]}
@@ -1,121 +0,0 @@
1
- import { a as DabaAgentOptions, c as DabaAgentStatus } from './types-hdR_wQ1B.cjs';
2
-
3
- declare class DabaAgent {
4
- private readonly options;
5
- private readonly position;
6
- private mode;
7
- private readonly badge;
8
- private readonly badgeLabel;
9
- private readonly chatWindow;
10
- private readonly messagesContainer;
11
- private readonly inputElement;
12
- private readonly micBtn;
13
- private readonly keydownHandler;
14
- private readonly restricted;
15
- private status;
16
- private isOpen;
17
- private destroyed;
18
- private ws;
19
- private audioContext;
20
- private mic;
21
- private player;
22
- private bargeInStreak;
23
- private isReattaching;
24
- private messages;
25
- private currentStreamBubble;
26
- private currentStreamRole;
27
- private readonly ui;
28
- private readonly strings;
29
- private readonly uiLang;
30
- private conversationId;
31
- private chatInFlight;
32
- private remoteConfig;
33
- private live;
34
- constructor(options: DabaAgentOptions);
35
- /** Put back what this thread already showed, so a reload or a
36
- * navigate() lands the visitor mid-conversation, not on a blank intro
37
- * while the model silently remembers the last four turns. */
38
- private restoreTranscript;
39
- private saveTranscript;
40
- /**
41
- * Pull the project's own mode, theme, intro and locale from the gateway.
42
- *
43
- * Fire-and-forget on purpose: the widget is fully usable before this
44
- * resolves and stays usable if it never does. A visitor must never be
45
- * left unable to type because a styling fetch was slow, so every failure
46
- * path here is a silent fall back to the built-in brand kit rather than
47
- * an error the visitor has to read.
48
- */
49
- private loadRemoteConfig;
50
- /** Show or hide the voice controls to match the resolved mode. Removing
51
- * them rather than disabling them: a greyed-out microphone still
52
- * promises voice the project has switched off. */
53
- private applyMode;
54
- private handleKeydown;
55
- private setStatus;
56
- private emitError;
57
- get currentStatus(): DabaAgentStatus;
58
- get isActive(): boolean;
59
- get isChatOpen(): boolean;
60
- openChat(): void;
61
- closeChat(): void;
62
- toggleChat(): void;
63
- /**
64
- * Send one typed message.
65
- *
66
- * This used to call `startSession()`, which opens the Realtime
67
- * WebSocket, and `onSocketOpen` then unconditionally grabbed the
68
- * microphone — so typing a sentence demanded microphone permission and
69
- * was billed as voice minutes. Typing now goes over plain HTTP and
70
- * touches neither the mic, the AudioContext nor the socket.
71
- *
72
- * The one exception is a voice session that is ALREADY live: injecting
73
- * the text there keeps a single continuous conversation, which is what a
74
- * visitor switching medium mid-sentence expects. It is not a reason to
75
- * start a session that does not exist.
76
- */
77
- sendText(text: string): Promise<void>;
78
- private sendChatMessage;
79
- /**
80
- * Start a new conversation: clear the transcript, forget the history the
81
- * gateway is keyed on, and put the intro back. A fresh id rather than a
82
- * reset flag, so the old thread simply expires on its own TTL instead of
83
- * needing a round trip to delete.
84
- */
85
- resetConversation(): void;
86
- /** Voice, explicitly. Never reached in chat mode — the controls that
87
- * would call it are not rendered there. */
88
- private toggleVoice;
89
- private handleTranscriptDelta;
90
- toggle(): Promise<void>;
91
- private get usesLiveEngine();
92
- private startLiveSession;
93
- private runVoiceTool;
94
- private startSession;
95
- private tryReattach;
96
- private attachWebSocket;
97
- private onSocketOpen;
98
- private onMicFrame;
99
- private onSocketMessage;
100
- private executeTool;
101
- private handleToolCall;
102
- private stopSession;
103
- private handleSocketClose;
104
- private flashBadgeError;
105
- private cleanupAfterClose;
106
- destroy(): void;
107
- }
108
-
109
- declare class DabaAgentElement extends HTMLElement {
110
- private agent;
111
- connectedCallback(): void;
112
- disconnectedCallback(): void;
113
- get dabaAgent(): DabaAgent | null;
114
- sendText(text: string): Promise<void> | undefined;
115
- openChat(): void;
116
- closeChat(): void;
117
- toggleChat(): void;
118
- }
119
- declare function defineDabaAgentElement(tagName?: string): void;
120
-
121
- export { DabaAgent as D, DabaAgentElement as a, defineDabaAgentElement as d };
@@ -1,121 +0,0 @@
1
- import { a as DabaAgentOptions, c as DabaAgentStatus } from './types-hdR_wQ1B.js';
2
-
3
- declare class DabaAgent {
4
- private readonly options;
5
- private readonly position;
6
- private mode;
7
- private readonly badge;
8
- private readonly badgeLabel;
9
- private readonly chatWindow;
10
- private readonly messagesContainer;
11
- private readonly inputElement;
12
- private readonly micBtn;
13
- private readonly keydownHandler;
14
- private readonly restricted;
15
- private status;
16
- private isOpen;
17
- private destroyed;
18
- private ws;
19
- private audioContext;
20
- private mic;
21
- private player;
22
- private bargeInStreak;
23
- private isReattaching;
24
- private messages;
25
- private currentStreamBubble;
26
- private currentStreamRole;
27
- private readonly ui;
28
- private readonly strings;
29
- private readonly uiLang;
30
- private conversationId;
31
- private chatInFlight;
32
- private remoteConfig;
33
- private live;
34
- constructor(options: DabaAgentOptions);
35
- /** Put back what this thread already showed, so a reload or a
36
- * navigate() lands the visitor mid-conversation, not on a blank intro
37
- * while the model silently remembers the last four turns. */
38
- private restoreTranscript;
39
- private saveTranscript;
40
- /**
41
- * Pull the project's own mode, theme, intro and locale from the gateway.
42
- *
43
- * Fire-and-forget on purpose: the widget is fully usable before this
44
- * resolves and stays usable if it never does. A visitor must never be
45
- * left unable to type because a styling fetch was slow, so every failure
46
- * path here is a silent fall back to the built-in brand kit rather than
47
- * an error the visitor has to read.
48
- */
49
- private loadRemoteConfig;
50
- /** Show or hide the voice controls to match the resolved mode. Removing
51
- * them rather than disabling them: a greyed-out microphone still
52
- * promises voice the project has switched off. */
53
- private applyMode;
54
- private handleKeydown;
55
- private setStatus;
56
- private emitError;
57
- get currentStatus(): DabaAgentStatus;
58
- get isActive(): boolean;
59
- get isChatOpen(): boolean;
60
- openChat(): void;
61
- closeChat(): void;
62
- toggleChat(): void;
63
- /**
64
- * Send one typed message.
65
- *
66
- * This used to call `startSession()`, which opens the Realtime
67
- * WebSocket, and `onSocketOpen` then unconditionally grabbed the
68
- * microphone — so typing a sentence demanded microphone permission and
69
- * was billed as voice minutes. Typing now goes over plain HTTP and
70
- * touches neither the mic, the AudioContext nor the socket.
71
- *
72
- * The one exception is a voice session that is ALREADY live: injecting
73
- * the text there keeps a single continuous conversation, which is what a
74
- * visitor switching medium mid-sentence expects. It is not a reason to
75
- * start a session that does not exist.
76
- */
77
- sendText(text: string): Promise<void>;
78
- private sendChatMessage;
79
- /**
80
- * Start a new conversation: clear the transcript, forget the history the
81
- * gateway is keyed on, and put the intro back. A fresh id rather than a
82
- * reset flag, so the old thread simply expires on its own TTL instead of
83
- * needing a round trip to delete.
84
- */
85
- resetConversation(): void;
86
- /** Voice, explicitly. Never reached in chat mode — the controls that
87
- * would call it are not rendered there. */
88
- private toggleVoice;
89
- private handleTranscriptDelta;
90
- toggle(): Promise<void>;
91
- private get usesLiveEngine();
92
- private startLiveSession;
93
- private runVoiceTool;
94
- private startSession;
95
- private tryReattach;
96
- private attachWebSocket;
97
- private onSocketOpen;
98
- private onMicFrame;
99
- private onSocketMessage;
100
- private executeTool;
101
- private handleToolCall;
102
- private stopSession;
103
- private handleSocketClose;
104
- private flashBadgeError;
105
- private cleanupAfterClose;
106
- destroy(): void;
107
- }
108
-
109
- declare class DabaAgentElement extends HTMLElement {
110
- private agent;
111
- connectedCallback(): void;
112
- disconnectedCallback(): void;
113
- get dabaAgent(): DabaAgent | null;
114
- sendText(text: string): Promise<void> | undefined;
115
- openChat(): void;
116
- closeChat(): void;
117
- toggleChat(): void;
118
- }
119
- declare function defineDabaAgentElement(tagName?: string): void;
120
-
121
- export { DabaAgent as D, DabaAgentElement as a, defineDabaAgentElement as d };