wecool-chat 0.1.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/client.d.ts +42 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/components/ChatFooter.d.ts +9 -0
- package/dist/components/ChatFooter.d.ts.map +1 -0
- package/dist/components/ChatHeader.d.ts +7 -0
- package/dist/components/ChatHeader.d.ts.map +1 -0
- package/dist/components/ChatPanel.d.ts +14 -0
- package/dist/components/ChatPanel.d.ts.map +1 -0
- package/dist/components/ChatWidget.d.ts +3 -0
- package/dist/components/ChatWidget.d.ts.map +1 -0
- package/dist/components/FloatButton.d.ts +7 -0
- package/dist/components/FloatButton.d.ts.map +1 -0
- package/dist/components/MessageList.d.ts +8 -0
- package/dist/components/MessageList.d.ts.map +1 -0
- package/dist/hooks/tool-runner.d.ts +20 -0
- package/dist/hooks/tool-runner.d.ts.map +1 -0
- package/dist/hooks/useChatStream.d.ts +26 -0
- package/dist/hooks/useChatStream.d.ts.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +728 -0
- package/dist/sse-parser.d.ts +7 -0
- package/dist/sse-parser.d.ts.map +1 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +73 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-02-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release
|
|
13
|
+
- React-based chat widget component
|
|
14
|
+
- Tool calling support (LLM executes JavaScript functions)
|
|
15
|
+
- Floating and inline display modes
|
|
16
|
+
- Light/Dark theme support
|
|
17
|
+
- Customizable positioning (bottom-right, bottom-left)
|
|
18
|
+
- Japanese and English locale support
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wecool-dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# wecool
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/wecool-chat)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
wecool は、Webアプリケーションに自然言語チャットインターフェースを組み込むためのReactウィジェットです。
|
|
7
|
+
|
|
8
|
+
ユーザーが「ダークモードにして」「一覧を名前順にソートして」のように話しかけると、LLM(大規模言語モデル)が意図を解釈し、あらかじめ定義したJavaScript関数(ツール)を自動で選択・実行します。テーマ切替、ページ遷移、テーブル操作、フォーム入力など、UIの操作を自然言語で行えるようになります。
|
|
9
|
+
|
|
10
|
+
## 特徴
|
|
11
|
+
|
|
12
|
+
- **自然言語でUI操作** - ユーザーは普通の言葉でアプリを操作できる
|
|
13
|
+
- **Tool Calling** - LLMが意図を解釈し、定義済みのJavaScript関数を自動実行
|
|
14
|
+
- **Reactコンポーネント** - Reactアプリに簡単に組み込み可能
|
|
15
|
+
- **カスタマイズ可能** - フローティングモード・インラインモード対応
|
|
16
|
+
- **ヘッドレス対応** - ChatEngineを使ってUIを自作することも可能
|
|
17
|
+
|
|
18
|
+
## 利用開始手順
|
|
19
|
+
|
|
20
|
+
### 1. アカウント登録
|
|
21
|
+
|
|
22
|
+
[ダッシュボード(app.wecool.dev)](https://app.wecool.dev)にアクセスし、アカウントを作成します。登録後、確認メールが届くのでメール内のリンクをクリックして認証を完了してください。
|
|
23
|
+
|
|
24
|
+
### 2. APIキーの発行
|
|
25
|
+
|
|
26
|
+
ダッシュボードにログインし、「API Keys」ページから新しいAPIキーを作成します。表示されたキーを控えておいてください(再表示はできません)。
|
|
27
|
+
|
|
28
|
+
### 3. パッケージのインストール
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install wecool-chat
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 4. コンポーネントの配置
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { ChatWidget } from "wecool-chat";
|
|
38
|
+
import "wecool-chat/styles.css";
|
|
39
|
+
|
|
40
|
+
const tools = [
|
|
41
|
+
{
|
|
42
|
+
name: "toggleDarkMode",
|
|
43
|
+
description: "ダークモードの切り替え",
|
|
44
|
+
parameters: {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
enabled: { type: "boolean" },
|
|
48
|
+
},
|
|
49
|
+
required: ["enabled"],
|
|
50
|
+
},
|
|
51
|
+
handler: (args) => {
|
|
52
|
+
document.body.classList.toggle("dark", args.enabled);
|
|
53
|
+
return { success: true };
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
function App() {
|
|
59
|
+
return (
|
|
60
|
+
<ChatWidget
|
|
61
|
+
config={{
|
|
62
|
+
endpoint: "https://api.wecool.dev",
|
|
63
|
+
apiKey: "your-api-key", // 手順2で発行したAPIキー
|
|
64
|
+
tools,
|
|
65
|
+
}}
|
|
66
|
+
floating={true}
|
|
67
|
+
position="bottom-right"
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API リファレンス
|
|
74
|
+
|
|
75
|
+
### ChatWidget Props
|
|
76
|
+
|
|
77
|
+
| Prop | 型 | 必須 | 説明 |
|
|
78
|
+
| ----------- | ------------------------------- | ------ | ----------------------------------------- |
|
|
79
|
+
| config | ChatConfig | はい | 設定オブジェクト |
|
|
80
|
+
| floating | boolean | いいえ | フローティングモード(デフォルト: false) |
|
|
81
|
+
| position | 'bottom-right' \| 'bottom-left' | いいえ | フローティング時の表示位置 |
|
|
82
|
+
| defaultOpen | boolean | いいえ | 初期表示状態(デフォルト: false) |
|
|
83
|
+
|
|
84
|
+
### ChatConfig
|
|
85
|
+
|
|
86
|
+
| プロパティ | 型 | 必須 | 説明 |
|
|
87
|
+
| ------------- | -------- | ------ | ------------------------------ |
|
|
88
|
+
| endpoint | string | はい | APIエンドポイントURL |
|
|
89
|
+
| apiKey | string | いいえ | APIキー |
|
|
90
|
+
| tools | Tool[] | はい | ツール定義の配列 |
|
|
91
|
+
| locale | string | いいえ | UIテキストのロケール |
|
|
92
|
+
| placeholder | string | いいえ | 入力欄のプレースホルダー |
|
|
93
|
+
| onToolExecute | function | いいえ | ツール実行時のコールバック |
|
|
94
|
+
| onToolResult | function | いいえ | ツール結果返却時のコールバック |
|
|
95
|
+
| onError | function | いいえ | エラー時のコールバック |
|
|
96
|
+
|
|
97
|
+
### Tool 定義
|
|
98
|
+
|
|
99
|
+
| プロパティ | 型 | 必須 | 説明 |
|
|
100
|
+
| ----------- | -------- | ---- | ------------------------- |
|
|
101
|
+
| name | string | はい | ツールの一意な識別子 |
|
|
102
|
+
| description | string | はい | ツールの説明(LLMが参照) |
|
|
103
|
+
| parameters | object | はい | パラメータのJSON Schema |
|
|
104
|
+
| handler | function | はい | 実行する関数 |
|
|
105
|
+
|
|
106
|
+
## デモ
|
|
107
|
+
|
|
108
|
+
ライブデモ: [demo.wecool.dev](https://demo.wecool.dev)
|
|
109
|
+
|
|
110
|
+
## ライセンス
|
|
111
|
+
|
|
112
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ToolDefinition, Message, ChatEvent, ToolResult } from './types';
|
|
2
|
+
interface ChatParams {
|
|
3
|
+
message?: string;
|
|
4
|
+
tools: ToolDefinition[];
|
|
5
|
+
history?: Message[];
|
|
6
|
+
toolResults?: ToolResult[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* API client for communicating with the chat backend via SSE
|
|
10
|
+
*/
|
|
11
|
+
export declare class ChatClient {
|
|
12
|
+
private endpoint;
|
|
13
|
+
private apiKey?;
|
|
14
|
+
private conversationId;
|
|
15
|
+
constructor(endpoint: string, apiKey?: string);
|
|
16
|
+
getConversationId(): string;
|
|
17
|
+
resetConversation(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Send a chat message or tool results and receive SSE events.
|
|
20
|
+
*/
|
|
21
|
+
chat(params: ChatParams): AsyncGenerator<ChatEvent>;
|
|
22
|
+
private buildHeaders;
|
|
23
|
+
private buildBody;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a unique message ID
|
|
27
|
+
*/
|
|
28
|
+
export declare function createMessageId(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Create a user message
|
|
31
|
+
*/
|
|
32
|
+
export declare function createUserMessage(content: string): Message;
|
|
33
|
+
/**
|
|
34
|
+
* Create an assistant message
|
|
35
|
+
*/
|
|
36
|
+
export declare function createAssistantMessage(content: string): Message;
|
|
37
|
+
/**
|
|
38
|
+
* Create a tool result message
|
|
39
|
+
*/
|
|
40
|
+
export declare function createToolMessage(toolName: string, args: Record<string, unknown>, result: unknown): Message;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG9E,UAAU,UAAU;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,cAAc,CAAuB;gBAEjC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAK7C,iBAAiB,IAAI,MAAM;IAO3B,iBAAiB,IAAI,IAAI;IAIzB;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,SAAS,CAAC;IAoB1D,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,SAAS;CAclB;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAO1D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAO/D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,OAAO,GACd,OAAO,CAYT"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type ChatFooterProps = {
|
|
2
|
+
onSubmit: (message: string) => void;
|
|
3
|
+
onClear: () => void;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function ChatFooter({ onSubmit, onClear, disabled, placeholder }: ChatFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ChatFooter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatFooter.d.ts","sourceRoot":"","sources":["../../src/components/ChatFooter.tsx"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAgDF,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,eAAe,2CAgFvF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatHeader.d.ts","sourceRoot":"","sources":["../../src/components/ChatHeader.tsx"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AA0BF,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,SAAiB,EAAE,EAAE,eAAe,2CAwBzE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Message } from '../types';
|
|
2
|
+
type ChatPanelProps = {
|
|
3
|
+
messages: Message[];
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: string | null;
|
|
6
|
+
onSendMessage: (message: string) => void;
|
|
7
|
+
onClear: () => void;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
showClose?: boolean;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function ChatPanel({ messages, isLoading, error, onSendMessage, onClear, onClose, showClose, placeholder, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=ChatPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatPanel.d.ts","sourceRoot":"","sources":["../../src/components/ChatPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxC,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAqBF,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,aAAa,EACb,OAAO,EACP,OAAO,EACP,SAAiB,EACjB,WAAW,GACZ,EAAE,cAAc,2CAchB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../src/components/ChatWidget.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,UAAU,CAAC;AAkCtE,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EAAE,SAAS,EAChB,QAAgB,EAChB,WAAmB,EACnB,QAAyB,GAC1B,EAAE,eAAe,2CAsDjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloatButton.d.ts","sourceRoot":"","sources":["../../src/components/FloatButton.tsx"],"names":[],"mappings":"AAEA,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAiBF,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,gBAAgB,2CAkBhE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Message } from '../types';
|
|
2
|
+
type MessageListProps = {
|
|
3
|
+
messages: Message[];
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function MessageList({ messages, isLoading }: MessageListProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=MessageList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../src/components/MessageList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAgEF,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,gBAAgB,2CAiDpE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChatEvent, Tool } from '../types';
|
|
2
|
+
type ToolUseEvent = Extract<ChatEvent, {
|
|
3
|
+
type: "tool_use";
|
|
4
|
+
}>;
|
|
5
|
+
export interface ToolExecution {
|
|
6
|
+
event: ToolUseEvent;
|
|
7
|
+
result: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface ToolRunnerCallbacks {
|
|
10
|
+
onToolExecute?: (toolName: string, args: unknown) => void;
|
|
11
|
+
onToolResult?: (toolName: string, result: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 1件の tool_use イベントを実行し、結果 / エラーをどちらも ToolExecution に正規化して返す。
|
|
15
|
+
*/
|
|
16
|
+
export declare const executeToolCall: (event: ToolUseEvent, findTool: (name: string) => Tool | undefined, options: ToolRunnerCallbacks & {
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
}) => Promise<ToolExecution>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=tool-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-runner.d.ts","sourceRoot":"","sources":["../../src/hooks/tool-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,KAAK,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5D;AAaD;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,YAAY,EACnB,UAAU,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,EAC5C,SAAS,mBAAmB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,KACpD,OAAO,CAAC,aAAa,CAuBvB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChatClient } from '../client';
|
|
2
|
+
import { Message, Tool, ToolDefinition } from '../types';
|
|
3
|
+
import { ToolRunnerCallbacks } from './tool-runner';
|
|
4
|
+
export interface UseChatStreamOptions extends ToolRunnerCallbacks {
|
|
5
|
+
client: ChatClient;
|
|
6
|
+
tools: Tool[];
|
|
7
|
+
toolDefinitions: ToolDefinition[];
|
|
8
|
+
toolTimeout?: number;
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface UseChatStreamResult {
|
|
12
|
+
messages: Message[];
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
error: string | null;
|
|
15
|
+
sendMessage: (content: string) => Promise<void>;
|
|
16
|
+
clear: () => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ChatWidget の状態機械を外出ししたフック。
|
|
20
|
+
*
|
|
21
|
+
* - ストリーミング text_delta を 1件の assistant メッセージに貼り合わせる
|
|
22
|
+
* - tool_use が返ったら並列実行して次ラウンドへ投げ直す
|
|
23
|
+
* - tool 呼び出しの無限ループは MAX_TOOL_ITERATIONS で明示的に打ち切る
|
|
24
|
+
*/
|
|
25
|
+
export declare function useChatStream(options: UseChatStreamOptions): UseChatStreamResult;
|
|
26
|
+
//# sourceMappingURL=useChatStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatStream.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatStream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAa,OAAO,EAAE,IAAI,EAAE,cAAc,EAAc,MAAM,UAAU,CAAC;AACrF,OAAO,EAAuC,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAM9F,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AASD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,mBAAmB,CA0DhF"}
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-outline-style:solid;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.absolute{position:absolute}.fixed{position:fixed}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.flex{display:flex}.hidden{display:none}.inline{display:inline}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.border{border-style:var(--tw-border-style);border-width:1px}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}}@keyframes wecool-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.wecool-loading-dot{animation:1.4s ease-in-out infinite both wecool-bounce}.wecool-loading-dot:first-child{animation-delay:-.32s}.wecool-loading-dot:nth-child(2){animation-delay:-.16s}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-ease{syntax:"*";inherits:false}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChatWidget } from './components/ChatWidget';
|
|
2
|
+
import { ChatConfig } from './types';
|
|
3
|
+
export type { Tool, ToolDefinition, ToolParameters, ChatConfig, ChatWidgetProps, Message, ToolCall, ChatEvent, ToolResult, } from './types';
|
|
4
|
+
export { ChatWidget } from './components/ChatWidget';
|
|
5
|
+
export { ChatPanel } from './components/ChatPanel';
|
|
6
|
+
export { ChatHeader } from './components/ChatHeader';
|
|
7
|
+
export { ChatFooter } from './components/ChatFooter';
|
|
8
|
+
export { MessageList } from './components/MessageList';
|
|
9
|
+
export { FloatButton } from './components/FloatButton';
|
|
10
|
+
export { ChatClient, createMessageId, createUserMessage, createAssistantMessage, createToolMessage, } from './client';
|
|
11
|
+
/**
|
|
12
|
+
* Initialize the chat widget and mount it to the DOM
|
|
13
|
+
*
|
|
14
|
+
* @param config - Chat configuration
|
|
15
|
+
* @param container - Container element or selector (default: creates a new div)
|
|
16
|
+
* @returns Cleanup function to unmount the widget
|
|
17
|
+
*/
|
|
18
|
+
export declare function initWecoolChat(config: ChatConfig, container?: HTMLElement | string): () => void;
|
|
19
|
+
declare const _default: {
|
|
20
|
+
initWecoolChat: typeof initWecoolChat;
|
|
21
|
+
ChatWidget: typeof ChatWidget;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,SAAS,CAAC;AAG3D,YAAY,EACV,IAAI,EACJ,cAAc,EACd,cAAc,EACd,UAAU,EACV,eAAe,EACf,OAAO,EACP,QAAQ,EACR,SAAS,EACT,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EACL,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,IAAI,CAyC/F;;;;;AAGD,wBAA8C"}
|