keyring-chatbot-agent-sdk 1.0.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/lib.d.ts ADDED
@@ -0,0 +1,164 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+
3
+ export declare interface Account {
4
+ address: string;
5
+ chainId: number | string;
6
+ }
7
+
8
+ /**
9
+ * `ChatWidget` is the main entry point for embedding the Keyring AI chat assistant
10
+ * into your dApp. It renders a floating chat button that opens a full-featured
11
+ * chat modal with AI-powered responses, token/NFT lookups, and on-chain transaction support.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * import { ChatWidget } from '@keyringpro/chatbot-agent-sdk';
16
+ *
17
+ * function App() {
18
+ * const { account, sendTransaction } = useWallet(); // your wallet hook
19
+ *
20
+ * return (
21
+ * <ChatWidget
22
+ * account={{ address: account.address, chainId: account.chainId }}
23
+ * onTransaction={sendTransaction}
24
+ * language="en"
25
+ * position="bottom-right"
26
+ * theme={{ primaryColor: '#6366f1', buttonSize: 56 }}
27
+ * rpcUrls={{ 1: 'https://mainnet.infura.io/v3/YOUR_KEY' }}
28
+ * />
29
+ * );
30
+ * }
31
+ * ```
32
+ *
33
+ * @param position - Corner to anchor the widget. `'bottom-right'` (default) or `'bottom-left'`.
34
+ * @param theme - Visual customisation: `primaryColor` (hex/CSS), `buttonSize` (px), `zIndex`.
35
+ * @param defaultOpen - If `true`, the chat modal is open on first render. Defaults to `false`.
36
+ * @param onOpen - Callback fired when the chat modal opens.
37
+ * @param onClose - Callback fired when the chat modal closes.
38
+ * @param account - Connected wallet info (`address` + `chainId`). Pass `undefined` when not connected.
39
+ * @param onTransaction - **Required for on-chain actions.** Receives an unsigned transaction object
40
+ * and must return a promise that resolves to `{ status, transactionHash?, error? }`.
41
+ * The widget uses this to sign & broadcast swap / send transactions.
42
+ * @param language - UI language: `'en'` (English, default), `'ja'` (Japanese), `'cn'` (Chinese).
43
+ * @param rpcUrls - Optional map of `chainId → RPC URL`. When provided, these URLs take priority
44
+ * over the built-in defaults for balance queries and fee estimation.
45
+ * e.g. `{ 1: 'https://...', 137: 'https://...' }`
46
+ */
47
+ export declare const ChatWidget: ({ position, theme, defaultOpen, onOpen, onClose, account, onTransaction, language, rpcUrls, }: ChatWidgetProps) => JSX.Element | null;
48
+
49
+ /** Alias kept for backwards-compatibility */
50
+ export declare type ChatWidgetLanguage = Language;
51
+
52
+ export declare interface ChatWidgetProps {
53
+ position?: 'bottom-right' | 'bottom-left';
54
+ theme?: ChatWidgetTheme;
55
+ defaultOpen?: boolean;
56
+ onOpen?: () => void;
57
+ onClose?: () => void;
58
+ account?: Account;
59
+ onTransaction?: (tx: Transaction) => Promise<TransactionResult>;
60
+ language?: ChatWidgetLanguage;
61
+ rpcUrls?: Record<number, string>;
62
+ }
63
+
64
+ export declare interface ChatWidgetTheme {
65
+ primaryColor?: string;
66
+ buttonSize?: number;
67
+ zIndex?: number;
68
+ modalChatStyle?: React.CSSProperties;
69
+ offset?: {
70
+ x: number;
71
+ y: number;
72
+ };
73
+ }
74
+
75
+ export declare interface Config {
76
+ position?: 'bottom-right' | 'bottom-left';
77
+ theme?: ChatWidgetTheme;
78
+ apiUrl?: string;
79
+ apiKey?: string;
80
+ /** Override RPC endpoint per chainId. Key = chainId, value = RPC URL. */
81
+ rpcUrls?: Record<number | string, string>;
82
+ [key: string]: unknown;
83
+ }
84
+
85
+ export declare type Language = 'en' | 'ja' | 'cn';
86
+
87
+ export declare interface Message {
88
+ id: string;
89
+ text: string;
90
+ sender: 'user' | 'bot';
91
+ timestamp: Date;
92
+ replyTo?: {
93
+ id: string;
94
+ text: string;
95
+ sender: 'user' | 'bot';
96
+ };
97
+ buttons?: MessageButton[];
98
+ actionData?: {
99
+ action: string;
100
+ parameters: Record<string, string>;
101
+ status?: 'pending' | 'submitted' | 'success' | 'fail' | 'idle';
102
+ tokenInfo?: MessageTokenInfo;
103
+ nftInfo?: MessageNftInfo;
104
+ };
105
+ typeChat?: TypeChat;
106
+ }
107
+
108
+ export declare interface MessageButton {
109
+ id: string;
110
+ text: string;
111
+ value: string;
112
+ action?: string;
113
+ extraData?: Record<string, unknown>;
114
+ fullWidth?: boolean;
115
+ }
116
+
117
+ declare interface MessageNftInfo {
118
+ name: string;
119
+ image?: string;
120
+ tokenId: string;
121
+ contractAddress: string;
122
+ tokenStandard?: string;
123
+ }
124
+
125
+ export declare interface MessageTokenInfo {
126
+ symbol: string;
127
+ name: string;
128
+ balance: string;
129
+ balanceFormatted: string;
130
+ usdValue?: number;
131
+ usdPrice?: number;
132
+ decimals: number;
133
+ logo?: string;
134
+ contractAddress: string;
135
+ }
136
+
137
+ export declare interface Transaction {
138
+ from: string;
139
+ to: string;
140
+ data: string;
141
+ value: string;
142
+ gasLimit?: string;
143
+ gasPrice?: string;
144
+ maxFeePerGas?: string;
145
+ maxPriorityFeePerGas?: string;
146
+ nonce?: number;
147
+ chainId?: number | string;
148
+ }
149
+
150
+ export declare interface TransactionResult {
151
+ status: 'success' | 'fail';
152
+ transactionHash?: string;
153
+ error?: string;
154
+ }
155
+
156
+ /**
157
+ * Shared public types for the Keyring Chatbot Agent SDK.
158
+ * Import from this file when consuming the SDK in a dApp.
159
+ */
160
+ export declare type TransactionStatus = 'pending' | 'process' | 'success' | 'fail';
161
+
162
+ declare type TypeChat = 'web3' | 'normal';
163
+
164
+ export { }
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "keyring-chatbot-agent-sdk",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "A React chat widget SDK with floating button and modal",
6
+ "keywords": [
7
+ "react",
8
+ "chat",
9
+ "widget",
10
+ "sdk",
11
+ "chat-widget"
12
+ ],
13
+ "homepage": "https://bitbucket.org/bacoorteam/keyring-chatbot-agent-sdk#readme",
14
+ "bugs": {
15
+ "url": "https://bitbucket.org/bacoorteam/keyring-chatbot-agent-sdk/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+ssh://git@bitbucket.org/bacoorteam/keyring-chatbot-agent-sdk.git"
20
+ },
21
+ "license": "ISC",
22
+ "author": "",
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/lib.d.ts",
27
+ "import": "./dist/chat-widget.es.js",
28
+ "require": "./dist/chat-widget.umd.js",
29
+ "default": "./dist/chat-widget.es.js"
30
+ },
31
+ "./web-component": {
32
+ "import": "./dist/chat-widget-wc.es.js",
33
+ "require": "./dist/chat-widget-wc.umd.js",
34
+ "default": "./dist/chat-widget-wc.es.js"
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
38
+ "main": "./dist/chat-widget.umd.js",
39
+ "types": "./dist/lib.d.ts",
40
+ "files": [
41
+ "dist"
42
+ ],
43
+ "scripts": {
44
+ "dev": "vite",
45
+ "build": "yarn build:react && yarn build:wc",
46
+ "build:react": "tsc -b && vite build --mode development",
47
+ "build:wc": "BUILD_TARGET=web-component vite build --mode development",
48
+ "build:production": "yarn build:react:production && yarn build:wc:production",
49
+ "build:react:production": "tsc -b && vite build",
50
+ "build:wc:production": "BUILD_TARGET=web-component vite build",
51
+ "watch": "chokidar 'src/**/*.{ts,tsx,css,json}' -c 'yarn build:react'",
52
+ "watch:production": "chokidar 'src/**/*.{ts,tsx,css,json}' -c 'yarn build:react:production'",
53
+ "lint": "eslint .",
54
+ "lint:fix": "eslint . --fix",
55
+ "format": "prettier --write \"src/**/*.{ts,tsx,css,json}\"",
56
+ "preview": "vite preview"
57
+ },
58
+ "dependencies": {
59
+ "@solana/web3.js": "^1.98.4",
60
+ "@types/react-syntax-highlighter": "^15.5.13",
61
+ "bignumber.js": "^9.3.1",
62
+ "lodash": "^4.17.23",
63
+ "react-device-detect": "^2.2.3",
64
+ "react-syntax-highlighter": "^16.1.0",
65
+ "remark-gfm": "^4.0.1",
66
+ "viem": "^2.45.1"
67
+ },
68
+ "devDependencies": {
69
+ "@eslint/js": "^9.39.1",
70
+ "@types/lodash": "^4.17.23",
71
+ "@types/node": "^24.10.1",
72
+ "@types/react": "^19.2.5",
73
+ "@types/react-dom": "^19.2.3",
74
+ "@types/uuid": "^10.0.0",
75
+ "@vitejs/plugin-react": "^5.1.1",
76
+ "chokidar-cli": "^3.0.0",
77
+ "eslint": "^9.39.1",
78
+ "eslint-config-prettier": "^10.1.8",
79
+ "eslint-plugin-prettier": "^5.5.5",
80
+ "eslint-plugin-react-hooks": "^7.0.1",
81
+ "eslint-plugin-react-refresh": "^0.4.24",
82
+ "globals": "^16.5.0",
83
+ "prettier": "^3.8.1",
84
+ "react": "^19.2.0",
85
+ "react-dom": "^19.2.0",
86
+ "terser": "^5.46.0",
87
+ "typescript": "~5.9.3",
88
+ "typescript-eslint": "^8.46.4",
89
+ "vite": "^7.2.4",
90
+ "vite-plugin-css-injected-by-js": "^3.5.2",
91
+ "vite-plugin-dts": "^4.5.4"
92
+ },
93
+ "peerDependencies": {
94
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
95
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
96
+ },
97
+ "module": "./dist/chat-widget.es.js",
98
+ "sideEffects": [
99
+ "**/*.css"
100
+ ]
101
+ }