@super_studio/ecforce-ai-agent-react 0.4.0 → 0.5.0
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/components/chatbot-frame.d.ts +19 -1
- package/dist/components/chatbot-frame.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -17
- package/dist/index.mjs +17 -17
- package/package.json +1 -1
- package/src/components/chatbot-frame.tsx +61 -1
- package/src/index.ts +0 -1
- package/dist/hooks/use-chatbot-config.d.ts +0 -19
- package/dist/hooks/use-chatbot-config.d.ts.map +0 -1
- package/src/hooks/use-chatbot-config.tsx +0 -60
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
import type { MCP } from "./provider/use-chatbot-frame-handler";
|
|
1
2
|
export type ChatbotFrameProps = {
|
|
3
|
+
/** 管理画面上のエージェントID */
|
|
2
4
|
agentId: string;
|
|
5
|
+
/** エージェントにつなげるMCPの情報 */
|
|
6
|
+
mcps?: MCP[];
|
|
7
|
+
/** アプリ名のメタデータ */
|
|
8
|
+
appName?: string;
|
|
9
|
+
/**
|
|
10
|
+
* trueになるまで、初期化されません。
|
|
11
|
+
* 初期化せれたあとはもう使われません。
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* エージェントのURLを上書きしたい場合にこちらを使います。
|
|
17
|
+
* 基本的には使われません。
|
|
18
|
+
* [CHATBOT_URL]の環境変数でも設定可能。
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
3
21
|
url?: string;
|
|
4
22
|
className?: string;
|
|
5
23
|
};
|
|
6
|
-
export declare function ChatbotFrame({ agentId,
|
|
24
|
+
export declare function ChatbotFrame({ agentId, appName, mcps, enabled, url, className, }: ChatbotFrameProps): import("react/jsx-runtime").JSX.Element;
|
|
7
25
|
//# sourceMappingURL=chatbot-frame.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot-frame.d.ts","sourceRoot":"","sources":["../../src/components/chatbot-frame.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"chatbot-frame.d.ts","sourceRoot":"","sources":["../../src/components/chatbot-frame.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,iBAAiB;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAc,EACd,GAAG,EACH,SAAS,GACV,EAAE,iBAAiB,2CAkDnB"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -164,13 +164,25 @@ function ChatbotProvider({ children }) {
|
|
|
164
164
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatbotContext.Provider, { value, children });
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
// src/
|
|
167
|
+
// src/components/chatbot-frame.tsx
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
|
|
170
|
+
// src/lib/constants.ts
|
|
171
|
+
var PROD_CHATBOT_URL = "https://ecforce-ai-agent.vercel.app";
|
|
172
|
+
|
|
173
|
+
// src/components/chatbot-frame.tsx
|
|
174
|
+
|
|
175
|
+
function ChatbotFrame({
|
|
176
|
+
agentId,
|
|
171
177
|
appName,
|
|
172
|
-
|
|
178
|
+
mcps,
|
|
179
|
+
enabled = true,
|
|
180
|
+
url,
|
|
181
|
+
className
|
|
173
182
|
}) {
|
|
183
|
+
var _a;
|
|
184
|
+
const chatbotUrl = (_a = url != null ? url : process.env.CHATBOT_URL) != null ? _a : PROD_CHATBOT_URL;
|
|
185
|
+
const { setIframeEl } = useChatbot();
|
|
174
186
|
const { init, setMcps, setAppName, isReady } = useChatbot();
|
|
175
187
|
const sentInitRef = React5.default.useRef(false);
|
|
176
188
|
const [currentMcps, setCurrentMcps] = React5.default.useState();
|
|
@@ -195,17 +207,6 @@ function useChatbotConfig({
|
|
|
195
207
|
setAppName(appName);
|
|
196
208
|
}
|
|
197
209
|
}, [appName]);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// src/lib/constants.ts
|
|
201
|
-
var PROD_CHATBOT_URL = "https://ecforce-ai-agent.vercel.app";
|
|
202
|
-
|
|
203
|
-
// src/components/chatbot-frame.tsx
|
|
204
|
-
|
|
205
|
-
function ChatbotFrame({ agentId, className, url }) {
|
|
206
|
-
var _a;
|
|
207
|
-
const chatbotUrl = (_a = url != null ? url : process.env.CHATBOT_URL) != null ? _a : PROD_CHATBOT_URL;
|
|
208
|
-
const { setIframeEl } = useChatbot();
|
|
209
210
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
210
211
|
"iframe",
|
|
211
212
|
{
|
|
@@ -460,5 +461,4 @@ function EcforceAiIcon() {
|
|
|
460
461
|
|
|
461
462
|
|
|
462
463
|
|
|
463
|
-
|
|
464
|
-
exports.ChatbotFrame = ChatbotFrame; exports.ChatbotProvider = ChatbotProvider; exports.ChatbotSheet = ChatbotSheet; exports.Sheet = Sheet; exports.SheetClose = SheetClose; exports.SheetContent = SheetContent; exports.SheetDescription = SheetDescription; exports.SheetFooter = SheetFooter; exports.SheetHeader = SheetHeader; exports.SheetTitle = SheetTitle; exports.SheetTrigger = SheetTrigger; exports.Tooltip = Tooltip; exports.useChatbot = useChatbot; exports.useChatbotConfig = useChatbotConfig;
|
|
464
|
+
exports.ChatbotFrame = ChatbotFrame; exports.ChatbotProvider = ChatbotProvider; exports.ChatbotSheet = ChatbotSheet; exports.Sheet = Sheet; exports.SheetClose = SheetClose; exports.SheetContent = SheetContent; exports.SheetDescription = SheetDescription; exports.SheetFooter = SheetFooter; exports.SheetHeader = SheetHeader; exports.SheetTitle = SheetTitle; exports.SheetTrigger = SheetTrigger; exports.Tooltip = Tooltip; exports.useChatbot = useChatbot;
|
package/dist/index.mjs
CHANGED
|
@@ -164,13 +164,25 @@ function ChatbotProvider({ children }) {
|
|
|
164
164
|
return /* @__PURE__ */ jsx(ChatbotContext.Provider, { value, children });
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
// src/
|
|
167
|
+
// src/components/chatbot-frame.tsx
|
|
168
168
|
import React4 from "react";
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
|
|
170
|
+
// src/lib/constants.ts
|
|
171
|
+
var PROD_CHATBOT_URL = "https://ecforce-ai-agent.vercel.app";
|
|
172
|
+
|
|
173
|
+
// src/components/chatbot-frame.tsx
|
|
174
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
175
|
+
function ChatbotFrame({
|
|
176
|
+
agentId,
|
|
171
177
|
appName,
|
|
172
|
-
|
|
178
|
+
mcps,
|
|
179
|
+
enabled = true,
|
|
180
|
+
url,
|
|
181
|
+
className
|
|
173
182
|
}) {
|
|
183
|
+
var _a;
|
|
184
|
+
const chatbotUrl = (_a = url != null ? url : process.env.CHATBOT_URL) != null ? _a : PROD_CHATBOT_URL;
|
|
185
|
+
const { setIframeEl } = useChatbot();
|
|
174
186
|
const { init, setMcps, setAppName, isReady } = useChatbot();
|
|
175
187
|
const sentInitRef = React4.useRef(false);
|
|
176
188
|
const [currentMcps, setCurrentMcps] = React4.useState();
|
|
@@ -195,17 +207,6 @@ function useChatbotConfig({
|
|
|
195
207
|
setAppName(appName);
|
|
196
208
|
}
|
|
197
209
|
}, [appName]);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// src/lib/constants.ts
|
|
201
|
-
var PROD_CHATBOT_URL = "https://ecforce-ai-agent.vercel.app";
|
|
202
|
-
|
|
203
|
-
// src/components/chatbot-frame.tsx
|
|
204
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
205
|
-
function ChatbotFrame({ agentId, className, url }) {
|
|
206
|
-
var _a;
|
|
207
|
-
const chatbotUrl = (_a = url != null ? url : process.env.CHATBOT_URL) != null ? _a : PROD_CHATBOT_URL;
|
|
208
|
-
const { setIframeEl } = useChatbot();
|
|
209
210
|
return /* @__PURE__ */ jsx2(
|
|
210
211
|
"iframe",
|
|
211
212
|
{
|
|
@@ -459,6 +460,5 @@ export {
|
|
|
459
460
|
SheetTitle,
|
|
460
461
|
SheetTrigger,
|
|
461
462
|
Tooltip,
|
|
462
|
-
useChatbot
|
|
463
|
-
useChatbotConfig
|
|
463
|
+
useChatbot
|
|
464
464
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,75 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { PROD_CHATBOT_URL } from "../lib/constants";
|
|
2
3
|
import { useChatbot } from "./provider/chatbot-proivder";
|
|
4
|
+
import type { MCP } from "./provider/use-chatbot-frame-handler";
|
|
3
5
|
|
|
4
6
|
export type ChatbotFrameProps = {
|
|
7
|
+
/** 管理画面上のエージェントID */
|
|
5
8
|
agentId: string;
|
|
9
|
+
/** エージェントにつなげるMCPの情報 */
|
|
10
|
+
mcps?: MCP[];
|
|
11
|
+
/** アプリ名のメタデータ */
|
|
12
|
+
appName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* trueになるまで、初期化されません。
|
|
15
|
+
* 初期化せれたあとはもう使われません。
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* エージェントのURLを上書きしたい場合にこちらを使います。
|
|
21
|
+
* 基本的には使われません。
|
|
22
|
+
* [CHATBOT_URL]の環境変数でも設定可能。
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
6
25
|
url?: string;
|
|
7
26
|
className?: string;
|
|
8
27
|
};
|
|
9
28
|
|
|
10
|
-
export function ChatbotFrame({
|
|
29
|
+
export function ChatbotFrame({
|
|
30
|
+
agentId,
|
|
31
|
+
appName,
|
|
32
|
+
mcps,
|
|
33
|
+
enabled = true,
|
|
34
|
+
url,
|
|
35
|
+
className,
|
|
36
|
+
}: ChatbotFrameProps) {
|
|
11
37
|
const chatbotUrl = url ?? process.env.CHATBOT_URL ?? PROD_CHATBOT_URL;
|
|
12
38
|
const { setIframeEl } = useChatbot();
|
|
39
|
+
const { init, setMcps, setAppName, isReady } = useChatbot();
|
|
40
|
+
const sentInitRef = React.useRef(false);
|
|
41
|
+
const [currentMcps, setCurrentMcps] = React.useState<MCP[]>();
|
|
42
|
+
const [currentAppName, setCurrentAppName] = React.useState<string>();
|
|
43
|
+
|
|
44
|
+
// 初期化の仕組み
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
if (enabled && isReady && !sentInitRef.current) {
|
|
47
|
+
init({ mcps, appName });
|
|
48
|
+
sentInitRef.current = true;
|
|
49
|
+
setCurrentMcps(mcps);
|
|
50
|
+
setCurrentAppName(appName);
|
|
51
|
+
}
|
|
52
|
+
}, [enabled, init, mcps, appName, isReady]);
|
|
53
|
+
|
|
54
|
+
// mcpsの更新の仕組み
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (
|
|
57
|
+
sentInitRef.current &&
|
|
58
|
+
mcps &&
|
|
59
|
+
JSON.stringify(currentMcps) !== JSON.stringify(mcps)
|
|
60
|
+
) {
|
|
61
|
+
setMcps(mcps);
|
|
62
|
+
setCurrentMcps(mcps);
|
|
63
|
+
}
|
|
64
|
+
}, [mcps]);
|
|
65
|
+
|
|
66
|
+
// appNameの更新の仕組み
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (sentInitRef.current && appName && currentAppName !== appName) {
|
|
69
|
+
setCurrentAppName(appName);
|
|
70
|
+
setAppName(appName);
|
|
71
|
+
}
|
|
72
|
+
}, [appName]);
|
|
13
73
|
|
|
14
74
|
return (
|
|
15
75
|
<iframe
|
package/src/index.ts
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type MCP } from "../components/provider/use-chatbot-frame-handler";
|
|
2
|
-
type ChatbotConfig = {
|
|
3
|
-
/** エージェントにつなげるMCPの情報 */
|
|
4
|
-
mcps?: MCP[];
|
|
5
|
-
/** アプリ名のメタデータ */
|
|
6
|
-
appName?: string;
|
|
7
|
-
/**
|
|
8
|
-
* trueになるまで、初期化されません。
|
|
9
|
-
* 初期化せれたあとはもう使われません。
|
|
10
|
-
* @default true
|
|
11
|
-
*/
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* このフックに渡される情報で受動的にinitを呼び出し、mcpsとappNameを更新する
|
|
16
|
-
*/
|
|
17
|
-
export declare function useChatbotConfig({ mcps, appName, enabled, }: ChatbotConfig): void;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=use-chatbot-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-chatbot-config.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chatbot-config.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,kDAAkD,CAAC;AAE5E,KAAK,aAAa,GAAG;IACnB,wBAAwB;IACxB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,iBAAiB;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,OAAO,EACP,OAAc,GACf,EAAE,aAAa,QAmCf"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useChatbot } from "../components/provider/chatbot-proivder";
|
|
3
|
-
import { type MCP } from "../components/provider/use-chatbot-frame-handler";
|
|
4
|
-
|
|
5
|
-
type ChatbotConfig = {
|
|
6
|
-
/** エージェントにつなげるMCPの情報 */
|
|
7
|
-
mcps?: MCP[];
|
|
8
|
-
/** アプリ名のメタデータ */
|
|
9
|
-
appName?: string;
|
|
10
|
-
/**
|
|
11
|
-
* trueになるまで、初期化されません。
|
|
12
|
-
* 初期化せれたあとはもう使われません。
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* このフックに渡される情報で受動的にinitを呼び出し、mcpsとappNameを更新する
|
|
20
|
-
*/
|
|
21
|
-
export function useChatbotConfig({
|
|
22
|
-
mcps,
|
|
23
|
-
appName,
|
|
24
|
-
enabled = true,
|
|
25
|
-
}: ChatbotConfig) {
|
|
26
|
-
const { init, setMcps, setAppName, isReady } = useChatbot();
|
|
27
|
-
const sentInitRef = React.useRef(false);
|
|
28
|
-
const [currentMcps, setCurrentMcps] = React.useState<MCP[]>();
|
|
29
|
-
const [currentAppName, setCurrentAppName] = React.useState<string>();
|
|
30
|
-
|
|
31
|
-
// 初期化の仕組み
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
if (enabled && isReady && !sentInitRef.current) {
|
|
34
|
-
init({ mcps, appName });
|
|
35
|
-
sentInitRef.current = true;
|
|
36
|
-
setCurrentMcps(mcps);
|
|
37
|
-
setCurrentAppName(appName);
|
|
38
|
-
}
|
|
39
|
-
}, [enabled, init, mcps, appName, isReady]);
|
|
40
|
-
|
|
41
|
-
// mcpsの更新の仕組み
|
|
42
|
-
React.useEffect(() => {
|
|
43
|
-
if (
|
|
44
|
-
sentInitRef.current &&
|
|
45
|
-
mcps &&
|
|
46
|
-
JSON.stringify(currentMcps) !== JSON.stringify(mcps)
|
|
47
|
-
) {
|
|
48
|
-
setMcps(mcps);
|
|
49
|
-
setCurrentMcps(mcps);
|
|
50
|
-
}
|
|
51
|
-
}, [mcps]);
|
|
52
|
-
|
|
53
|
-
// appNameの更新の仕組み
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
if (sentInitRef.current && appName && currentAppName !== appName) {
|
|
56
|
-
setCurrentAppName(appName);
|
|
57
|
-
setAppName(appName);
|
|
58
|
-
}
|
|
59
|
-
}, [appName]);
|
|
60
|
-
}
|