@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.
- package/dist/chunk-7ENX2QZK.js +193 -0
- package/dist/chunk-7ENX2QZK.js.map +1 -0
- package/dist/chunk-CMHPVBEF.js +5195 -0
- package/dist/chunk-CMHPVBEF.js.map +1 -0
- package/dist/chunk-GCU5OBSZ.js +40 -0
- package/dist/chunk-GCU5OBSZ.js.map +1 -0
- package/dist/chunk-HJPH4GNS.cjs +196 -0
- package/dist/chunk-HJPH4GNS.cjs.map +1 -0
- package/dist/chunk-IMPMGYCG.cjs +5197 -0
- package/dist/chunk-IMPMGYCG.cjs.map +1 -0
- package/dist/chunk-JQMJMSFT.cjs +46 -0
- package/dist/chunk-JQMJMSFT.cjs.map +1 -0
- package/dist/custom-element-BZAUI4Dc.d.cts +121 -0
- package/dist/custom-element-PL2IXpG2.d.ts +121 -0
- package/dist/custom-element.cjs +4 -4
- package/dist/custom-element.d.cts +2 -2
- package/dist/custom-element.d.ts +2 -2
- package/dist/custom-element.js +2 -2
- package/dist/daba-agent.cjs +8 -8
- package/dist/daba-agent.d.cts +2 -2
- package/dist/daba-agent.d.ts +2 -2
- package/dist/daba-agent.js +3 -3
- package/dist/daba-agent.min.js +1728 -201
- package/dist/daba-agent.min.js.map +1 -1
- package/dist/react.cjs +5 -5
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +2 -2
- package/dist/types-hdR_wQ1B.d.cts +239 -0
- package/dist/types-hdR_wQ1B.d.ts +239 -0
- package/package.json +2 -2
- package/dist/chunk-EF6D33VT.cjs +0 -103
- package/dist/chunk-EF6D33VT.cjs.map +0 -1
- package/dist/chunk-G22V7GGM.js +0 -1667
- package/dist/chunk-G22V7GGM.js.map +0 -1
- package/dist/chunk-N4TBGDUO.cjs +0 -1669
- package/dist/chunk-N4TBGDUO.cjs.map +0 -1
- package/dist/chunk-QM6HDEVV.js +0 -39
- package/dist/chunk-QM6HDEVV.js.map +0 -1
- package/dist/chunk-WJQ444GI.js +0 -100
- package/dist/chunk-WJQ444GI.js.map +0 -1
- package/dist/chunk-ZXZX2D55.cjs +0 -45
- package/dist/chunk-ZXZX2D55.cjs.map +0 -1
- package/dist/custom-element-CpPr7b2Z.d.ts +0 -66
- package/dist/custom-element-XiZg8UN8.d.cts +0 -66
- package/dist/types-DYRGPzyp.d.cts +0 -76
- package/dist/types-DYRGPzyp.d.ts +0 -76
package/dist/chunk-QM6HDEVV.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { DabaAgent } from './chunk-G22V7GGM.js';
|
|
2
|
-
import React, { useRef, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
function DabaAgentComponent(props) {
|
|
5
|
-
const containerRef = useRef(null);
|
|
6
|
-
const agentRef = useRef(null);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
if (!containerRef.current) return;
|
|
9
|
-
const agent = new DabaAgent({
|
|
10
|
-
container: containerRef.current,
|
|
11
|
-
...props
|
|
12
|
-
});
|
|
13
|
-
agentRef.current = agent;
|
|
14
|
-
return () => {
|
|
15
|
-
agent.destroy();
|
|
16
|
-
agentRef.current = null;
|
|
17
|
-
};
|
|
18
|
-
}, [
|
|
19
|
-
props.projectId,
|
|
20
|
-
props.apiKey,
|
|
21
|
-
props.gatewayUrl,
|
|
22
|
-
props.position,
|
|
23
|
-
props.accentColor,
|
|
24
|
-
props.mode,
|
|
25
|
-
props.title,
|
|
26
|
-
props.placeholder,
|
|
27
|
-
props.initialOpen,
|
|
28
|
-
props.hotkey
|
|
29
|
-
]);
|
|
30
|
-
return React.createElement("div", {
|
|
31
|
-
ref: containerRef,
|
|
32
|
-
style: { display: "contents" },
|
|
33
|
-
"data-daba-agent-react-container": "true"
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { DabaAgentComponent };
|
|
38
|
-
//# sourceMappingURL=chunk-QM6HDEVV.js.map
|
|
39
|
-
//# sourceMappingURL=chunk-QM6HDEVV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/react.ts"],"names":[],"mappings":";;;AAMO,SAAS,mBAAmB,KAAA,EAA2C;AAC5E,EAAA,MAAM,YAAA,GAAe,OAAuB,IAAI,CAAA;AAChD,EAAA,MAAM,QAAA,GAAW,OAAyB,IAAI,CAAA;AAE9C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,aAAa,OAAA,EAAS;AAE3B,IAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU;AAAA,MAC1B,WAAW,YAAA,CAAa,OAAA;AAAA,MACxB,GAAG;AAAA,KACJ,CAAA;AACD,IAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AAEnB,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,OAAA,EAAQ;AACd,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG;AAAA,IACD,KAAA,CAAM,SAAA;AAAA,IACN,KAAA,CAAM,MAAA;AAAA,IACN,KAAA,CAAM,UAAA;AAAA,IACN,KAAA,CAAM,QAAA;AAAA,IACN,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM,IAAA;AAAA,IACN,KAAA,CAAM,KAAA;AAAA,IACN,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM;AAAA,GACP,CAAA;AAED,EAAA,OAAO,KAAA,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-QM6HDEVV.js","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 useEffect(() => {\n if (!containerRef.current) return;\n\n const agent = new DabaAgent({\n container: containerRef.current,\n ...props,\n });\n agentRef.current = agent;\n\n return () => {\n agent.destroy();\n agentRef.current = null;\n };\n }, [\n props.projectId,\n props.apiKey,\n props.gatewayUrl,\n props.position,\n props.accentColor,\n props.mode,\n props.title,\n props.placeholder,\n props.initialOpen,\n props.hotkey,\n ]);\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"]}
|
package/dist/chunk-WJQ444GI.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { DabaAgent } from './chunk-G22V7GGM.js';
|
|
2
|
-
|
|
3
|
-
// src/components/custom-element.ts
|
|
4
|
-
var DabaAgentElement = class extends HTMLElement {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.agent = null;
|
|
8
|
-
}
|
|
9
|
-
connectedCallback() {
|
|
10
|
-
if (this.agent) return;
|
|
11
|
-
const getAttr = (name) => this.getAttribute(name) ?? this.getAttribute(`data-${name}`);
|
|
12
|
-
const projectId = getAttr("project-id");
|
|
13
|
-
const apiKey = getAttr("api-key");
|
|
14
|
-
if (!projectId || !apiKey) {
|
|
15
|
-
console.error(
|
|
16
|
-
"daba-agent: <daba-agent> custom element requires project-id and api-key attributes.",
|
|
17
|
-
this
|
|
18
|
-
);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const position = getAttr("position") ?? void 0;
|
|
22
|
-
const accentColor = getAttr("accent-color") ?? void 0;
|
|
23
|
-
const mode = getAttr("mode") ?? void 0;
|
|
24
|
-
const title = getAttr("title") ?? void 0;
|
|
25
|
-
const placeholder = getAttr("placeholder") ?? void 0;
|
|
26
|
-
const initialOpen = this.hasAttribute("initial-open") || this.hasAttribute("data-initial-open");
|
|
27
|
-
const hotkey = getAttr("hotkey") ?? void 0;
|
|
28
|
-
const gatewayUrl = getAttr("gateway-url") ?? void 0;
|
|
29
|
-
this.agent = new DabaAgent({
|
|
30
|
-
container: this,
|
|
31
|
-
projectId,
|
|
32
|
-
apiKey,
|
|
33
|
-
position,
|
|
34
|
-
accentColor,
|
|
35
|
-
mode,
|
|
36
|
-
title,
|
|
37
|
-
placeholder,
|
|
38
|
-
initialOpen,
|
|
39
|
-
hotkey,
|
|
40
|
-
gatewayUrl,
|
|
41
|
-
onStatusChange: (status) => {
|
|
42
|
-
this.dispatchEvent(
|
|
43
|
-
new CustomEvent("daba-status-change", { detail: { status }, bubbles: true, composed: true })
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
onTranscript: (role, text, isFinal) => {
|
|
47
|
-
this.dispatchEvent(
|
|
48
|
-
new CustomEvent("daba-transcript", {
|
|
49
|
-
detail: { role, text, isFinal },
|
|
50
|
-
bubbles: true,
|
|
51
|
-
composed: true
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
onError: (error) => {
|
|
56
|
-
this.dispatchEvent(
|
|
57
|
-
new CustomEvent("daba-error", { detail: { error }, bubbles: true, composed: true })
|
|
58
|
-
);
|
|
59
|
-
},
|
|
60
|
-
onChatToggle: (isOpen) => {
|
|
61
|
-
this.dispatchEvent(
|
|
62
|
-
new CustomEvent("daba-chat-toggle", { detail: { isOpen }, bubbles: true, composed: true })
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
disconnectedCallback() {
|
|
68
|
-
if (this.agent) {
|
|
69
|
-
this.agent.destroy();
|
|
70
|
-
this.agent = null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
get dabaAgent() {
|
|
74
|
-
return this.agent;
|
|
75
|
-
}
|
|
76
|
-
sendText(text) {
|
|
77
|
-
return this.agent?.sendText(text);
|
|
78
|
-
}
|
|
79
|
-
openChat() {
|
|
80
|
-
this.agent?.openChat();
|
|
81
|
-
}
|
|
82
|
-
closeChat() {
|
|
83
|
-
this.agent?.closeChat();
|
|
84
|
-
}
|
|
85
|
-
toggleChat() {
|
|
86
|
-
this.agent?.toggleChat();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
function defineDabaAgentElement(tagName = "daba-agent") {
|
|
90
|
-
if (typeof window !== "undefined" && typeof customElements !== "undefined") {
|
|
91
|
-
if (!customElements.get(tagName)) {
|
|
92
|
-
customElements.define(tagName, DabaAgentElement);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
defineDabaAgentElement();
|
|
97
|
-
|
|
98
|
-
export { DabaAgentElement, defineDabaAgentElement };
|
|
99
|
-
//# sourceMappingURL=chunk-WJQ444GI.js.map
|
|
100
|
-
//# sourceMappingURL=chunk-WJQ444GI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/custom-element.ts"],"names":[],"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,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AEO,SAAA,GAAkB;AACvB,IAAA,IAAA,CAAK,OAAO,SAAA,EAAU;AAAA,EACxB;AAAA,EAEO,UAAA,GAAmB;AACxB,IAAA,IAAA,CAAK,OAAO,UAAA,EAAW;AAAA,EACzB;AACF;AAEO,SAAS,sBAAA,CAAuB,UAAU,YAAA,EAAoB;AACnE,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,mBAAmB,WAAA,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-WJQ444GI.js","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"]}
|
package/dist/chunk-ZXZX2D55.cjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkN4TBGDUO_cjs = require('./chunk-N4TBGDUO.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
|
-
React.useEffect(() => {
|
|
14
|
-
if (!containerRef.current) return;
|
|
15
|
-
const agent = new chunkN4TBGDUO_cjs.DabaAgent({
|
|
16
|
-
container: containerRef.current,
|
|
17
|
-
...props
|
|
18
|
-
});
|
|
19
|
-
agentRef.current = agent;
|
|
20
|
-
return () => {
|
|
21
|
-
agent.destroy();
|
|
22
|
-
agentRef.current = null;
|
|
23
|
-
};
|
|
24
|
-
}, [
|
|
25
|
-
props.projectId,
|
|
26
|
-
props.apiKey,
|
|
27
|
-
props.gatewayUrl,
|
|
28
|
-
props.position,
|
|
29
|
-
props.accentColor,
|
|
30
|
-
props.mode,
|
|
31
|
-
props.title,
|
|
32
|
-
props.placeholder,
|
|
33
|
-
props.initialOpen,
|
|
34
|
-
props.hotkey
|
|
35
|
-
]);
|
|
36
|
-
return React__default.default.createElement("div", {
|
|
37
|
-
ref: containerRef,
|
|
38
|
-
style: { display: "contents" },
|
|
39
|
-
"data-daba-agent-react-container": "true"
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
exports.DabaAgentComponent = DabaAgentComponent;
|
|
44
|
-
//# sourceMappingURL=chunk-ZXZX2D55.cjs.map
|
|
45
|
-
//# sourceMappingURL=chunk-ZXZX2D55.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/react.ts"],"names":["useRef","useEffect","DabaAgent","React"],"mappings":";;;;;;;;;AAMO,SAAS,mBAAmB,KAAA,EAA2C;AAC5E,EAAA,MAAM,YAAA,GAAeA,aAAuB,IAAI,CAAA;AAChD,EAAA,MAAM,QAAA,GAAWA,aAAyB,IAAI,CAAA;AAE9C,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,aAAa,OAAA,EAAS;AAE3B,IAAA,MAAM,KAAA,GAAQ,IAAIC,2BAAA,CAAU;AAAA,MAC1B,WAAW,YAAA,CAAa,OAAA;AAAA,MACxB,GAAG;AAAA,KACJ,CAAA;AACD,IAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AAEnB,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,OAAA,EAAQ;AACd,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG;AAAA,IACD,KAAA,CAAM,SAAA;AAAA,IACN,KAAA,CAAM,MAAA;AAAA,IACN,KAAA,CAAM,UAAA;AAAA,IACN,KAAA,CAAM,QAAA;AAAA,IACN,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM,IAAA;AAAA,IACN,KAAA,CAAM,KAAA;AAAA,IACN,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM,WAAA;AAAA,IACN,KAAA,CAAM;AAAA,GACP,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-ZXZX2D55.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 useEffect(() => {\n if (!containerRef.current) return;\n\n const agent = new DabaAgent({\n container: containerRef.current,\n ...props,\n });\n agentRef.current = agent;\n\n return () => {\n agent.destroy();\n agentRef.current = null;\n };\n }, [\n props.projectId,\n props.apiKey,\n props.gatewayUrl,\n props.position,\n props.accentColor,\n props.mode,\n props.title,\n props.placeholder,\n props.initialOpen,\n props.hotkey,\n ]);\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,66 +0,0 @@
|
|
|
1
|
-
import { a as DabaAgentOptions, c as DabaAgentStatus } from './types-DYRGPzyp.js';
|
|
2
|
-
|
|
3
|
-
declare class DabaAgent {
|
|
4
|
-
private readonly options;
|
|
5
|
-
private readonly position;
|
|
6
|
-
private readonly 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
|
-
constructor(options: DabaAgentOptions);
|
|
28
|
-
private handleKeydown;
|
|
29
|
-
private setStatus;
|
|
30
|
-
private emitError;
|
|
31
|
-
get currentStatus(): DabaAgentStatus;
|
|
32
|
-
get isActive(): boolean;
|
|
33
|
-
get isChatOpen(): boolean;
|
|
34
|
-
openChat(): void;
|
|
35
|
-
closeChat(): void;
|
|
36
|
-
toggleChat(): void;
|
|
37
|
-
sendText(text: string): Promise<void>;
|
|
38
|
-
private handleTranscriptDelta;
|
|
39
|
-
toggle(): Promise<void>;
|
|
40
|
-
private startSession;
|
|
41
|
-
private tryReattach;
|
|
42
|
-
private attachWebSocket;
|
|
43
|
-
private onSocketOpen;
|
|
44
|
-
private onMicFrame;
|
|
45
|
-
private onSocketMessage;
|
|
46
|
-
private handleToolCall;
|
|
47
|
-
private stopSession;
|
|
48
|
-
private handleSocketClose;
|
|
49
|
-
private flashBadgeError;
|
|
50
|
-
private cleanupAfterClose;
|
|
51
|
-
destroy(): void;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare class DabaAgentElement extends HTMLElement {
|
|
55
|
-
private agent;
|
|
56
|
-
connectedCallback(): void;
|
|
57
|
-
disconnectedCallback(): void;
|
|
58
|
-
get dabaAgent(): DabaAgent | null;
|
|
59
|
-
sendText(text: string): Promise<void> | undefined;
|
|
60
|
-
openChat(): void;
|
|
61
|
-
closeChat(): void;
|
|
62
|
-
toggleChat(): void;
|
|
63
|
-
}
|
|
64
|
-
declare function defineDabaAgentElement(tagName?: string): void;
|
|
65
|
-
|
|
66
|
-
export { DabaAgent as D, DabaAgentElement as a, defineDabaAgentElement as d };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { a as DabaAgentOptions, c as DabaAgentStatus } from './types-DYRGPzyp.cjs';
|
|
2
|
-
|
|
3
|
-
declare class DabaAgent {
|
|
4
|
-
private readonly options;
|
|
5
|
-
private readonly position;
|
|
6
|
-
private readonly 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
|
-
constructor(options: DabaAgentOptions);
|
|
28
|
-
private handleKeydown;
|
|
29
|
-
private setStatus;
|
|
30
|
-
private emitError;
|
|
31
|
-
get currentStatus(): DabaAgentStatus;
|
|
32
|
-
get isActive(): boolean;
|
|
33
|
-
get isChatOpen(): boolean;
|
|
34
|
-
openChat(): void;
|
|
35
|
-
closeChat(): void;
|
|
36
|
-
toggleChat(): void;
|
|
37
|
-
sendText(text: string): Promise<void>;
|
|
38
|
-
private handleTranscriptDelta;
|
|
39
|
-
toggle(): Promise<void>;
|
|
40
|
-
private startSession;
|
|
41
|
-
private tryReattach;
|
|
42
|
-
private attachWebSocket;
|
|
43
|
-
private onSocketOpen;
|
|
44
|
-
private onMicFrame;
|
|
45
|
-
private onSocketMessage;
|
|
46
|
-
private handleToolCall;
|
|
47
|
-
private stopSession;
|
|
48
|
-
private handleSocketClose;
|
|
49
|
-
private flashBadgeError;
|
|
50
|
-
private cleanupAfterClose;
|
|
51
|
-
destroy(): void;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare class DabaAgentElement extends HTMLElement {
|
|
55
|
-
private agent;
|
|
56
|
-
connectedCallback(): void;
|
|
57
|
-
disconnectedCallback(): void;
|
|
58
|
-
get dabaAgent(): DabaAgent | null;
|
|
59
|
-
sendText(text: string): Promise<void> | undefined;
|
|
60
|
-
openChat(): void;
|
|
61
|
-
closeChat(): void;
|
|
62
|
-
toggleChat(): void;
|
|
63
|
-
}
|
|
64
|
-
declare function defineDabaAgentElement(tagName?: string): void;
|
|
65
|
-
|
|
66
|
-
export { DabaAgent as D, DabaAgentElement as a, defineDabaAgentElement as d };
|
|
@@ -1,76 +0,0 @@
|
|
|
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 DabaErrorKind = "invalid_key" | "origin_not_allowed" | "not_found" | "network" | "restricted";
|
|
14
|
-
interface DabaError {
|
|
15
|
-
kind: DabaErrorKind;
|
|
16
|
-
message: string;
|
|
17
|
-
}
|
|
18
|
-
/** "listening" = mic capturing, "thinking" = waiting on a model turn,
|
|
19
|
-
* "speaking" = agent audio playing back, "idle" = session not active. */
|
|
20
|
-
type DabaAgentStatus = "idle" | "connecting" | "listening" | "thinking" | "speaking";
|
|
21
|
-
/** Which viewport corner the default floating badge is pinned to. Only
|
|
22
|
-
* applies to the default badge (no custom `container`) — a host handing
|
|
23
|
-
* in its own `container` owns that element's placement entirely. */
|
|
24
|
-
type DabaAgentPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
25
|
-
/** UI display mode: "hybrid" (voice + chat window), "voice" (voice badge only), "chat" (chat popover only). */
|
|
26
|
-
type DabaAgentMode = "hybrid" | "voice" | "chat";
|
|
27
|
-
interface ChatMessage {
|
|
28
|
-
id: string;
|
|
29
|
-
role: "user" | "agent" | "system";
|
|
30
|
-
text: string;
|
|
31
|
-
timestamp: number;
|
|
32
|
-
isFinal?: boolean;
|
|
33
|
-
}
|
|
34
|
-
interface DabaAgentOptions {
|
|
35
|
-
projectId: string;
|
|
36
|
-
apiKey: string;
|
|
37
|
-
/** Overrides `env` when both are given — the only option that can name
|
|
38
|
-
* a host neither tier covers (self-hosted, a local gateway). */
|
|
39
|
-
gatewayUrl?: string;
|
|
40
|
-
/** Which Dabalabs tier to talk to. Omit for production; pass "staging"
|
|
41
|
-
* to point the agent at the staging gateway. */
|
|
42
|
-
env?: DabaEnvironment;
|
|
43
|
-
/** Where to mount the widget. Defaults to fixed-position element appended to <body> when omitted. */
|
|
44
|
-
container?: string | HTMLElement;
|
|
45
|
-
/** Corner of the viewport the default badge is fixed to. Defaults to "bottom-right". */
|
|
46
|
-
position?: DabaAgentPosition;
|
|
47
|
-
accentColor?: string;
|
|
48
|
-
/** Recolor the trigger icon's background substrate (the color under the
|
|
49
|
-
* grain/noise texture). Defaults to the icon's shipped green — the noise
|
|
50
|
-
* texture and decorative background art are unaffected by this, only the
|
|
51
|
-
* substrate color changes. */
|
|
52
|
-
iconBackgroundColor?: string;
|
|
53
|
-
/** Recolor the trigger icon's center mark (the face/mask shape).
|
|
54
|
-
* Defaults to the icon's shipped white. */
|
|
55
|
-
iconMarkColor?: string;
|
|
56
|
-
/** UI display mode. Defaults to "voice" — clicking the badge starts/stops
|
|
57
|
-
* a voice session, no chat window. Set to "hybrid" to also enable the
|
|
58
|
-
* chat popover (badge click opens chat instead of voice; voice still
|
|
59
|
-
* starts via the hotkey), or "chat" for chat-only. */
|
|
60
|
-
mode?: DabaAgentMode;
|
|
61
|
-
/** Header title displayed in the chat window. Defaults to "Voice & Text AI Assistant". */
|
|
62
|
-
title?: string;
|
|
63
|
-
/** Placeholder text for input box in chat window. */
|
|
64
|
-
placeholder?: string;
|
|
65
|
-
/** Whether the chat popover window starts open. Defaults to false. */
|
|
66
|
-
initialOpen?: boolean;
|
|
67
|
-
/** Defaults to "ctrl+space". Set to `null` to disable hotkey. */
|
|
68
|
-
hotkey?: string | null;
|
|
69
|
-
onError?: (error: DabaError) => void;
|
|
70
|
-
onStatusChange?: (status: DabaAgentStatus) => void;
|
|
71
|
-
/** Fired for both user speech/text and agent reply deltas. */
|
|
72
|
-
onTranscript?: (role: "user" | "agent", text: string, isFinal: boolean) => void;
|
|
73
|
-
onChatToggle?: (isOpen: boolean) => void;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export type { ChatMessage as C, DabaAgentMode as D, DabaAgentOptions as a, DabaAgentPosition as b, DabaAgentStatus as c, DabaError as d };
|
package/dist/types-DYRGPzyp.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
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 DabaErrorKind = "invalid_key" | "origin_not_allowed" | "not_found" | "network" | "restricted";
|
|
14
|
-
interface DabaError {
|
|
15
|
-
kind: DabaErrorKind;
|
|
16
|
-
message: string;
|
|
17
|
-
}
|
|
18
|
-
/** "listening" = mic capturing, "thinking" = waiting on a model turn,
|
|
19
|
-
* "speaking" = agent audio playing back, "idle" = session not active. */
|
|
20
|
-
type DabaAgentStatus = "idle" | "connecting" | "listening" | "thinking" | "speaking";
|
|
21
|
-
/** Which viewport corner the default floating badge is pinned to. Only
|
|
22
|
-
* applies to the default badge (no custom `container`) — a host handing
|
|
23
|
-
* in its own `container` owns that element's placement entirely. */
|
|
24
|
-
type DabaAgentPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
25
|
-
/** UI display mode: "hybrid" (voice + chat window), "voice" (voice badge only), "chat" (chat popover only). */
|
|
26
|
-
type DabaAgentMode = "hybrid" | "voice" | "chat";
|
|
27
|
-
interface ChatMessage {
|
|
28
|
-
id: string;
|
|
29
|
-
role: "user" | "agent" | "system";
|
|
30
|
-
text: string;
|
|
31
|
-
timestamp: number;
|
|
32
|
-
isFinal?: boolean;
|
|
33
|
-
}
|
|
34
|
-
interface DabaAgentOptions {
|
|
35
|
-
projectId: string;
|
|
36
|
-
apiKey: string;
|
|
37
|
-
/** Overrides `env` when both are given — the only option that can name
|
|
38
|
-
* a host neither tier covers (self-hosted, a local gateway). */
|
|
39
|
-
gatewayUrl?: string;
|
|
40
|
-
/** Which Dabalabs tier to talk to. Omit for production; pass "staging"
|
|
41
|
-
* to point the agent at the staging gateway. */
|
|
42
|
-
env?: DabaEnvironment;
|
|
43
|
-
/** Where to mount the widget. Defaults to fixed-position element appended to <body> when omitted. */
|
|
44
|
-
container?: string | HTMLElement;
|
|
45
|
-
/** Corner of the viewport the default badge is fixed to. Defaults to "bottom-right". */
|
|
46
|
-
position?: DabaAgentPosition;
|
|
47
|
-
accentColor?: string;
|
|
48
|
-
/** Recolor the trigger icon's background substrate (the color under the
|
|
49
|
-
* grain/noise texture). Defaults to the icon's shipped green — the noise
|
|
50
|
-
* texture and decorative background art are unaffected by this, only the
|
|
51
|
-
* substrate color changes. */
|
|
52
|
-
iconBackgroundColor?: string;
|
|
53
|
-
/** Recolor the trigger icon's center mark (the face/mask shape).
|
|
54
|
-
* Defaults to the icon's shipped white. */
|
|
55
|
-
iconMarkColor?: string;
|
|
56
|
-
/** UI display mode. Defaults to "voice" — clicking the badge starts/stops
|
|
57
|
-
* a voice session, no chat window. Set to "hybrid" to also enable the
|
|
58
|
-
* chat popover (badge click opens chat instead of voice; voice still
|
|
59
|
-
* starts via the hotkey), or "chat" for chat-only. */
|
|
60
|
-
mode?: DabaAgentMode;
|
|
61
|
-
/** Header title displayed in the chat window. Defaults to "Voice & Text AI Assistant". */
|
|
62
|
-
title?: string;
|
|
63
|
-
/** Placeholder text for input box in chat window. */
|
|
64
|
-
placeholder?: string;
|
|
65
|
-
/** Whether the chat popover window starts open. Defaults to false. */
|
|
66
|
-
initialOpen?: boolean;
|
|
67
|
-
/** Defaults to "ctrl+space". Set to `null` to disable hotkey. */
|
|
68
|
-
hotkey?: string | null;
|
|
69
|
-
onError?: (error: DabaError) => void;
|
|
70
|
-
onStatusChange?: (status: DabaAgentStatus) => void;
|
|
71
|
-
/** Fired for both user speech/text and agent reply deltas. */
|
|
72
|
-
onTranscript?: (role: "user" | "agent", text: string, isFinal: boolean) => void;
|
|
73
|
-
onChatToggle?: (isOpen: boolean) => void;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export type { ChatMessage as C, DabaAgentMode as D, DabaAgentOptions as a, DabaAgentPosition as b, DabaAgentStatus as c, DabaError as d };
|