@kuntur/a2a-carbon-chat-adapter 0.1.2 → 0.1.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.
- package/README.md +7 -3
- package/dist/index.cjs +64 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +64 -35
- package/dist/index.js.map +1 -1
- package/dist/styles/index.css +284 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,14 +12,15 @@ npm install @kuntur/a2a-carbon-chat-adapter @carbon/ai-chat react react-dom
|
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
14
|
import { A2AChat } from '@kuntur/a2a-carbon-chat-adapter';
|
|
15
|
-
import '@
|
|
15
|
+
import '@kuntur/a2a-carbon-chat-adapter/styles'; // Adapter layout styles
|
|
16
|
+
import '@carbon/ai-chat/dist/styles.css'; // Carbon AI Chat styles (if not already imported)
|
|
16
17
|
|
|
17
18
|
function App() {
|
|
18
19
|
return (
|
|
19
20
|
<A2AChat
|
|
20
21
|
agentUrl="https://your-agent.example.com"
|
|
21
22
|
agentName="My Agent"
|
|
22
|
-
layout="
|
|
23
|
+
layout="sidebar"
|
|
23
24
|
/>
|
|
24
25
|
);
|
|
25
26
|
}
|
|
@@ -67,9 +68,12 @@ function ChatWithSwitcher() {
|
|
|
67
68
|
import { createA2AHandler } from '@kuntur/a2a-carbon-chat-adapter/server';
|
|
68
69
|
|
|
69
70
|
export const POST = createA2AHandler({
|
|
70
|
-
allowedAgentUrls: ['https://trusted-
|
|
71
|
+
allowedAgentUrls: ['https://trusted-agent.example.com'],
|
|
71
72
|
timeout: 120000,
|
|
72
73
|
});
|
|
74
|
+
|
|
75
|
+
export const runtime = 'nodejs';
|
|
76
|
+
export const dynamic = 'force-dynamic';
|
|
73
77
|
```
|
|
74
78
|
|
|
75
79
|
## Programmatic Usage with Hooks
|
package/dist/index.cjs
CHANGED
|
@@ -1890,39 +1890,10 @@ function A2AChat({
|
|
|
1890
1890
|
setCurrentFormRequest(null);
|
|
1891
1891
|
setPendingTaskId(null);
|
|
1892
1892
|
}, []);
|
|
1893
|
-
const
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
hasContentMaxWidth: true
|
|
1898
|
-
},
|
|
1899
|
-
header: {
|
|
1900
|
-
title: agent?.name ?? "AI Assistant",
|
|
1901
|
-
icons: {
|
|
1902
|
-
agent: agent?.iconUrl ?? "/bot.svg"
|
|
1903
|
-
}
|
|
1904
|
-
},
|
|
1905
|
-
input: {
|
|
1906
|
-
placeholder: "Type a message..."
|
|
1907
|
-
},
|
|
1908
|
-
messaging: {
|
|
1909
|
-
customSendMessage: async (request, options, instance) => {
|
|
1910
|
-
instanceRef.current = instance;
|
|
1911
|
-
const text = request?.input?.text;
|
|
1912
|
-
if (text) {
|
|
1913
|
-
await handleSendMessage(text);
|
|
1914
|
-
}
|
|
1915
|
-
},
|
|
1916
|
-
skipWelcome: true
|
|
1917
|
-
},
|
|
1918
|
-
userDefinedResponses: {
|
|
1919
|
-
text_with_citations: renderCustomResponse,
|
|
1920
|
-
sources_list: renderCustomResponse,
|
|
1921
|
-
error: renderCustomResponse
|
|
1922
|
-
}
|
|
1923
|
-
}),
|
|
1924
|
-
[agent, layout, handleSendMessage, renderCustomResponse]
|
|
1925
|
-
);
|
|
1893
|
+
const handleAfterRender = react.useCallback((instance) => {
|
|
1894
|
+
instanceRef.current = instance;
|
|
1895
|
+
console.log("[A2AChat] Chat instance ready");
|
|
1896
|
+
}, []);
|
|
1926
1897
|
if (!agent) {
|
|
1927
1898
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `a2a-chat a2a-chat--error ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "No agent configured. Provide `agent`, `agentId`, or `agentUrl` prop." }) });
|
|
1928
1899
|
}
|
|
@@ -1940,7 +1911,32 @@ function A2AChat({
|
|
|
1940
1911
|
) });
|
|
1941
1912
|
if (layout === "float" && ChatContainer) {
|
|
1942
1913
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `a2a-chat a2a-chat--float ${className}`, children: [
|
|
1943
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1914
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1915
|
+
ChatContainer,
|
|
1916
|
+
{
|
|
1917
|
+
...{
|
|
1918
|
+
debug: false,
|
|
1919
|
+
aiEnabled: true
|
|
1920
|
+
},
|
|
1921
|
+
header: {
|
|
1922
|
+
title: agent?.name ?? "AI Assistant"
|
|
1923
|
+
},
|
|
1924
|
+
launcher: {
|
|
1925
|
+
isOn: true
|
|
1926
|
+
},
|
|
1927
|
+
onAfterRender: handleAfterRender,
|
|
1928
|
+
renderUserDefinedResponse: renderCustomResponse,
|
|
1929
|
+
messaging: {
|
|
1930
|
+
skipWelcome: true,
|
|
1931
|
+
customSendMessage: async (request, _options, _instance) => {
|
|
1932
|
+
const text = request?.input?.text;
|
|
1933
|
+
if (text) {
|
|
1934
|
+
await handleSendMessage(text);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
),
|
|
1944
1940
|
formOverlay
|
|
1945
1941
|
] });
|
|
1946
1942
|
}
|
|
@@ -1954,7 +1950,40 @@ function A2AChat({
|
|
|
1954
1950
|
width: layout === "sidebar" ? "400px" : void 0
|
|
1955
1951
|
},
|
|
1956
1952
|
children: [
|
|
1957
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1953
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1954
|
+
ChatCustomElement,
|
|
1955
|
+
{
|
|
1956
|
+
...{
|
|
1957
|
+
className: "a2a-chat__element",
|
|
1958
|
+
debug: false,
|
|
1959
|
+
aiEnabled: true,
|
|
1960
|
+
openChatByDefault: true
|
|
1961
|
+
},
|
|
1962
|
+
header: {
|
|
1963
|
+
title: agent?.name ?? "AI Assistant",
|
|
1964
|
+
showMinimize: layout !== "fullscreen"
|
|
1965
|
+
},
|
|
1966
|
+
launcher: {
|
|
1967
|
+
isOn: layout === "float"
|
|
1968
|
+
},
|
|
1969
|
+
layout: {
|
|
1970
|
+
showFrame: layout === "float",
|
|
1971
|
+
showCloseAndRestartButton: layout !== "fullscreen"
|
|
1972
|
+
},
|
|
1973
|
+
onAfterRender: handleAfterRender,
|
|
1974
|
+
renderUserDefinedResponse: renderCustomResponse,
|
|
1975
|
+
messaging: {
|
|
1976
|
+
skipWelcome: true,
|
|
1977
|
+
messageLoadingIndicatorTimeoutSecs: 0,
|
|
1978
|
+
customSendMessage: async (request, _options, _instance) => {
|
|
1979
|
+
const text = request?.input?.text;
|
|
1980
|
+
if (text) {
|
|
1981
|
+
await handleSendMessage(text);
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
),
|
|
1958
1987
|
formOverlay
|
|
1959
1988
|
]
|
|
1960
1989
|
}
|