@paimon-labs/ara-embed-first
v0.1.9
Published
Lightweight JS SDK to embed ARA AI Agent chat via streaming API.
Readme
ara-embed-test-001
ARA AI Agent를 웹/앱에 손쉽게 임베드하기 위한 경량 JS SDK입니다. ARA API의 스트리밍 출력(begin/item/end)을 그대로 지원합니다.
설치
npm
npm install ara-embed-test-001pnpm
pnpm add ara-embed-test-001빠른 시작 (모듈)
import { AraClient } from 'ara-embed-test-001';
const client = new AraClient({
baseUrl: 'https://<YOUR_ARA_API_ENDPOINT>',
bearerToken: '<OPTIONAL_BEARER_TOKEN>'
});
await client.start(
{
body: {
chatId: 'your-chat-id',
question: 'Hello ARA!',
locale: navigator.language || 'en-US',
requestType: 'com.nexus.crosswallet.desktop',
walletAddress: '0x...',
},
},
{
onBegin: (meta) => console.log('begin', meta),
onItem: (t) => console.log('token', t),
onEnd: (meta) => console.log('end', meta),
onError: (e) => console.error(e),
}
);스크립트 태그 사용(IIFE)
빌드 산출물에는 전역 window.AraEmbed가 노출됩니다.
<script src="https://unpkg.com/ara-embed-test-001/dist/index.global.js"></script>
<script>
const { AraClient, createAraWidget } = window.AraEmbed;
const client = new AraClient({ baseUrl: 'https://<YOUR_ARA_API_ENDPOINT>', bearerToken: '<TOKEN>' });
createAraWidget({ client, chatId: 'your-chat-id', locale: 'ko-KR' });
// 옵션: container 선택자, requestType, walletAddress 등 전달 가능
// createAraWidget({ container: '#chat', client, chatId, requestType: 'com.nexus...', walletAddress: '0x...' })
</script>Flowise 스타일(ESM) 임베드
<script type="module">
import Chatbot from 'https://cdn.jsdelivr.net/npm/ara-embed-test-001/dist/web.js';
Chatbot.init({
baseUrl: 'https://<YOUR_ARA_API_ENDPOINT>',
// bearerToken: '<TOKEN>',
});
// Chatbot.initFull({ baseUrl: 'https://<YOUR_ARA_API_ENDPOINT>' });
// 또는 로컬: import Chatbot from '../dist/web.js'
</script>웹 컴포넌트 <ara-fullchat>
<script src="https://unpkg.com/ara-embed-test-001/dist/index.global.js"></script>
<ara-fullchat base-url="https://<YOUR_ARA_API_ENDPOINT>" bearer-token="<TOKEN>"></ara-fullchat>API
AraClientconstructor({ baseUrl, bearerToken, defaultHeaders })start(params, handlers)params.body는 ARA 사양(chatId,question,locale,requestType,walletAddress, 등)을 따릅니다.
cancel()스트림 중단
createAraWidget({ container?, client, chatId, locale?, placeholder?, requestType?, walletAddress? })- 최소한의 기본 채팅 위젯을 DOM에 생성합니다.
빌드
pnpm build- ESM, CJS, IIFE 번들이 생성됩니다.
- 타입 선언(
.d.ts)이 포함됩니다.
라이선스
MIT
