@pinecall/chat-core 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/README.md +240 -0
- package/dist/chunk-ST5DVE5W.js +237 -0
- package/dist/chunk-ST5DVE5W.js.map +1 -0
- package/dist/index.cjs +239 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +279 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +35 -0
- package/dist/react.d.ts +35 -0
- package/dist/react.js +41 -0
- package/dist/react.js.map +1 -0
- package/dist/types-CGPqse91.d.cts +45 -0
- package/dist/types-CGPqse91.d.ts +45 -0
- package/package.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ChatSession.ts","../src/react.tsx"],"names":["useRef","useSyncExternalStore","useCallback","useEffect"],"mappings":";;;;;;;AAeA,IAAM,aAAA,GAAkC;AAAA,EACtC,MAAA,EAAQ,MAAA;AAAA,EACR,KAAA,EAAO,IAAA;AAAA,EACP,UAAU,EAAC;AAAA,EACX,MAAA,EAAQ,KAAA;AAAA,EACR,aAAA,EAAe,EAAA;AAAA,EACf,SAAA,EAAW;AACb,CAAA;AAEO,IAAM,WAAA,GAAN,cAA0B,WAAA,CAAY;AAAA,EAQ3C,YAAoB,IAAA,EAA0B;AAC5C,IAAA,KAAA,EAAM;AADY,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAEpB;AAAA,EAFoB,IAAA;AAAA,EAPZ,KAAA,GAA0B,EAAE,GAAG,aAAA,EAAc;AAAA,EAC7C,SAAA,uBAAgB,GAAA,EAAgB;AAAA,EAEhC,EAAA,GAAuB,IAAA;AAAA,EACvB,cAAA,GAAuD,IAAA;AAAA,EACvD,UAAA,GAAa,CAAA;AAAA;AAAA,EAOrB,QAAA,GAAuC;AACrC,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AAAA,IACd,eAAe,KAAA,CAAM,aAAA;AAAA,IACrB,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,UAAA,EAAYA,iBAAA;AAAA,MACV,CAAC,GAAA,EAAa,KAAA,KAAyB,OAAA,CAAQ,UAAA,CAAW,KAAK,KAAK,CAAA;AAAA,MACpE,CAAC,OAAO;AAAA,KACV;AAAA,IACA,OAAA,EAASA,kBAAY,MAAM,OAAA,CAAQ,SAAQ,EAAG,CAAC,OAAO,CAAC,CAAA;AAAA,IACvD,UAAA,EAAYA,kBAAY,MAAM,OAAA,CAAQ,YAAW,EAAG,CAAC,OAAO,CAAC;AAAA,GAC/D;AACF","file":"react.cjs","sourcesContent":["/**\n * ChatSession — Framework-agnostic text chat client for Pinecall agents.\n *\n * Mirrors VoiceSession's API patterns:\n * - session.subscribe(cb) + session.getState() — for React useSyncExternalStore\n * - session.addEventListener('status' | 'message' | 'error' | 'change', cb)\n *\n * Flow: GET /chat/token → WS /chat/ws?token=cht_xxx → bidirectional text chat\n */\nimport type {\n ChatSessionState,\n ChatSessionOptions,\n ChatMessage,\n} from \"./types\";\n\nconst INITIAL_STATE: ChatSessionState = {\n status: \"idle\",\n error: null,\n messages: [],\n typing: false,\n streamingText: \"\",\n sessionId: null,\n};\n\nexport class ChatSession extends EventTarget {\n private state: ChatSessionState = { ...INITIAL_STATE };\n private listeners = new Set<() => void>();\n\n private ws: WebSocket | null = null;\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n private msgCounter = 0;\n\n constructor(private opts: ChatSessionOptions) {\n super();\n }\n\n /** Read-only snapshot of current state (stable ref until next mutation). */\n getState(): Readonly<ChatSessionState> {\n return this.state;\n }\n\n /** Subscribe to ANY state change (for React useSyncExternalStore). */\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n private setState(patch: Partial<ChatSessionState>): void {\n const prev = this.state;\n this.state = { ...prev, ...patch };\n for (const l of this.listeners) l();\n\n if (patch.status !== undefined && patch.status !== prev.status) {\n this.dispatchEvent(\n new CustomEvent(\"status\", { detail: { status: this.state.status } }),\n );\n }\n if (\n patch.error !== undefined &&\n patch.error !== null &&\n patch.error !== prev.error\n ) {\n this.dispatchEvent(\n new CustomEvent(\"error\", { detail: { error: this.state.error } }),\n );\n }\n this.dispatchEvent(\n new CustomEvent(\"change\", { detail: { state: this.state } }),\n );\n }\n\n private setMessages(\n updater: (prev: ChatMessage[]) => ChatMessage[],\n ): void {\n const next = updater(this.state.messages);\n this.setState({ messages: next });\n const last = next[next.length - 1];\n if (last) {\n this.dispatchEvent(\n new CustomEvent(\"message\", { detail: { message: last } }),\n );\n }\n }\n\n // ── Connection ──────────────────────────────────────────────────────\n\n async connect(): Promise<void> {\n if (this.ws) return;\n\n try {\n this.setState({\n status: \"connecting\",\n error: null,\n });\n\n const base = (this.opts.server ?? \"https://voice.pinecall.io\").replace(\n /\\/$/,\n \"\",\n );\n\n // 1. Fetch chat token (public, no API key)\n const tRes = await fetch(\n `${base}/chat/token?agent_id=${encodeURIComponent(this.opts.agent)}`,\n );\n if (!tRes.ok) {\n const body = await tRes.text();\n throw new Error(`Token: ${tRes.status} ${body}`);\n }\n const { token, server: chatServer } = await tRes.json();\n const wsBase = (chatServer || base)\n .replace(/^http:/, \"ws:\")\n .replace(/^https:/, \"wss:\");\n\n // 2. Open WebSocket\n const ws = new WebSocket(`${wsBase}/chat/ws?token=${token}`);\n this.ws = ws;\n\n ws.onopen = () => {\n // Wait for chat.connected event before setting status\n };\n\n ws.onmessage = (evt) => this.handleMessage(evt);\n\n ws.onerror = () => {\n this.setState({ error: \"WebSocket error\", status: \"error\" });\n };\n\n ws.onclose = (evt) => {\n this.ws = null;\n if (this.state.status === \"connected\") {\n // Unexpected disconnect\n this.setState({ status: \"idle\" });\n }\n };\n } catch (err) {\n this.setState({\n error: err instanceof Error ? err.message : String(err),\n status: \"error\",\n });\n this.ws = null;\n }\n }\n\n private handleMessage(evt: MessageEvent): void {\n let d: any;\n try {\n d = JSON.parse(evt.data);\n } catch {\n return;\n }\n\n switch (d.event) {\n case \"chat.connected\":\n this.setState({\n status: \"connected\",\n sessionId: d.session_id ?? null,\n });\n break;\n\n case \"chat.token\":\n case \"llm.chat.token\":\n // Streaming token from LLM\n this.setState({\n typing: true,\n streamingText: d.text ?? \"\",\n });\n\n // Update or create bot message\n this.setMessages((prev) => {\n const idx = prev.findIndex(\n (m) => m.messageId === d.message_id && m.isStreaming,\n );\n if (idx >= 0) {\n return prev.map((m, i) =>\n i === idx ? { ...m, text: d.text ?? \"\" } : m,\n );\n }\n return [\n ...prev,\n {\n id: ++this.msgCounter,\n role: \"bot\",\n text: d.text ?? \"\",\n messageId: d.message_id,\n isStreaming: true,\n },\n ];\n });\n break;\n\n case \"chat.done\":\n case \"llm.chat.done\":\n // LLM finished streaming\n this.setState({\n typing: false,\n streamingText: \"\",\n });\n\n this.setMessages((prev) => {\n const idx = prev.findIndex(\n (m) => m.messageId === d.message_id && m.isStreaming,\n );\n if (idx >= 0) {\n return prev.map((m, i) =>\n i === idx\n ? { ...m, text: d.text ?? m.text, isStreaming: false }\n : m,\n );\n }\n // If we missed the streaming, add the final message\n return [\n ...prev,\n {\n id: ++this.msgCounter,\n role: \"bot\",\n text: d.text ?? \"\",\n messageId: d.message_id,\n isStreaming: false,\n },\n ];\n });\n break;\n\n case \"chat.error\":\n case \"llm.chat.error\":\n this.setState({\n typing: false,\n error: d.error ?? \"Unknown error\",\n });\n break;\n\n case \"error\":\n this.setState({\n error: d.error ?? \"Unknown error\",\n status: \"error\",\n });\n break;\n }\n\n // Emit raw event for power users\n this.dispatchEvent(new CustomEvent(\"event\", { detail: d }));\n }\n\n // ── Actions ─────────────────────────────────────────────────────────\n\n /** Send a text message to the agent. */\n send(text: string): void {\n if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;\n\n const trimmed = text.trim();\n if (!trimmed) return;\n\n // Add user message to local state immediately\n this.setMessages((prev) => [\n ...prev,\n {\n id: ++this.msgCounter,\n role: \"user\",\n text: trimmed,\n },\n ]);\n\n // Send to server\n this.ws.send(JSON.stringify({ event: \"message\", text: trimmed }));\n }\n\n /**\n * Set or clear a keyed context block in the LLM system prompt.\n *\n * @example\n * ```ts\n * session.setContext(\"form\", JSON.stringify({ name: \"Juan\" }));\n * session.setContext(\"form\", null); // clear\n * ```\n */\n setContext(key: string, value: string | null): void {\n if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;\n this.ws.send(JSON.stringify({ event: \"set_context\", key, value }));\n }\n\n /** Disconnect the chat session. */\n disconnect(): void {\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n if (this.ws) {\n this.ws.close();\n this.ws = null;\n }\n this.setState({ status: \"idle\", typing: false, streamingText: \"\" });\n }\n\n /** Tear down the session and clear subscribers. Do not reuse after this. */\n destroy(): void {\n this.disconnect();\n this.listeners.clear();\n }\n}\n","/**\n * @pinecall/chat-core/react\n *\n * React hook for Pinecall text chat.\n *\n * @example\n * ```tsx\n * import { usePinecallChat } from \"@pinecall/chat-core/react\";\n *\n * function Chat() {\n * const { messages, send, connected, typing } = usePinecallChat({\n * agent: \"florencia\",\n * });\n *\n * return (\n * <div>\n * {messages.map((m) => (\n * <p key={m.id}>{m.role}: {m.text}</p>\n * ))}\n * <input onKeyDown={(e) => {\n * if (e.key === \"Enter\") {\n * send(e.currentTarget.value);\n * e.currentTarget.value = \"\";\n * }\n * }} />\n * </div>\n * );\n * }\n * ```\n */\nimport { useSyncExternalStore, useRef, useCallback, useEffect } from \"react\";\nimport { ChatSession } from \"./ChatSession\";\nimport type { ChatSessionOptions, ChatMessage } from \"./types\";\n\nexport interface UsePinecallChatReturn {\n /** All messages in the conversation. */\n messages: ChatMessage[];\n /** Send a text message. */\n send: (text: string) => void;\n /** True when connected to the server. */\n connected: boolean;\n /** True while the bot is streaming a response. */\n typing: boolean;\n /** Partial text of the current response being streamed. */\n streamingText: string;\n /** Current error, if any. */\n error: string | null;\n /** Inject dynamic context into the LLM prompt. */\n setContext: (key: string, value: string | null) => void;\n /** Connect to the chat server. */\n connect: () => void;\n /** Disconnect from the chat server. */\n disconnect: () => void;\n}\n\n/**\n * React hook for Pinecall text chat.\n *\n * Creates a ChatSession and exposes reactive state via useSyncExternalStore.\n * The session auto-connects on mount and disconnects on unmount.\n */\nexport function usePinecallChat(\n opts: ChatSessionOptions & {\n /** Set to false to disable auto-connect on mount. @default true */\n autoConnect?: boolean;\n },\n): UsePinecallChatReturn {\n const sessionRef = useRef<ChatSession | null>(null);\n\n // Stable session instance\n if (!sessionRef.current) {\n sessionRef.current = new ChatSession(opts);\n }\n const session = sessionRef.current;\n\n // useSyncExternalStore for reactive state\n const state = useSyncExternalStore(\n useCallback((cb: () => void) => session.subscribe(cb), [session]),\n useCallback(() => session.getState(), [session]),\n );\n\n // Auto-connect on mount\n useEffect(() => {\n if (opts.autoConnect !== false) {\n session.connect();\n }\n return () => {\n session.destroy();\n sessionRef.current = null;\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n messages: state.messages,\n send: useCallback((text: string) => session.send(text), [session]),\n connected: state.status === \"connected\",\n typing: state.typing,\n streamingText: state.streamingText,\n error: state.error,\n setContext: useCallback(\n (key: string, value: string | null) => session.setContext(key, value),\n [session],\n ),\n connect: useCallback(() => session.connect(), [session]),\n disconnect: useCallback(() => session.disconnect(), [session]),\n };\n}\n\n// Re-export core types for convenience\nexport type { ChatSessionOptions, ChatMessage, ChatSessionState } from \"./types\";\n"]}
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { a as ChatMessage, b as ChatSessionOptions } from './types-CGPqse91.cjs';
|
|
2
|
+
export { c as ChatSessionState } from './types-CGPqse91.cjs';
|
|
3
|
+
|
|
4
|
+
interface UsePinecallChatReturn {
|
|
5
|
+
/** All messages in the conversation. */
|
|
6
|
+
messages: ChatMessage[];
|
|
7
|
+
/** Send a text message. */
|
|
8
|
+
send: (text: string) => void;
|
|
9
|
+
/** True when connected to the server. */
|
|
10
|
+
connected: boolean;
|
|
11
|
+
/** True while the bot is streaming a response. */
|
|
12
|
+
typing: boolean;
|
|
13
|
+
/** Partial text of the current response being streamed. */
|
|
14
|
+
streamingText: string;
|
|
15
|
+
/** Current error, if any. */
|
|
16
|
+
error: string | null;
|
|
17
|
+
/** Inject dynamic context into the LLM prompt. */
|
|
18
|
+
setContext: (key: string, value: string | null) => void;
|
|
19
|
+
/** Connect to the chat server. */
|
|
20
|
+
connect: () => void;
|
|
21
|
+
/** Disconnect from the chat server. */
|
|
22
|
+
disconnect: () => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* React hook for Pinecall text chat.
|
|
26
|
+
*
|
|
27
|
+
* Creates a ChatSession and exposes reactive state via useSyncExternalStore.
|
|
28
|
+
* The session auto-connects on mount and disconnects on unmount.
|
|
29
|
+
*/
|
|
30
|
+
declare function usePinecallChat(opts: ChatSessionOptions & {
|
|
31
|
+
/** Set to false to disable auto-connect on mount. @default true */
|
|
32
|
+
autoConnect?: boolean;
|
|
33
|
+
}): UsePinecallChatReturn;
|
|
34
|
+
|
|
35
|
+
export { ChatMessage, ChatSessionOptions, type UsePinecallChatReturn, usePinecallChat };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { a as ChatMessage, b as ChatSessionOptions } from './types-CGPqse91.js';
|
|
2
|
+
export { c as ChatSessionState } from './types-CGPqse91.js';
|
|
3
|
+
|
|
4
|
+
interface UsePinecallChatReturn {
|
|
5
|
+
/** All messages in the conversation. */
|
|
6
|
+
messages: ChatMessage[];
|
|
7
|
+
/** Send a text message. */
|
|
8
|
+
send: (text: string) => void;
|
|
9
|
+
/** True when connected to the server. */
|
|
10
|
+
connected: boolean;
|
|
11
|
+
/** True while the bot is streaming a response. */
|
|
12
|
+
typing: boolean;
|
|
13
|
+
/** Partial text of the current response being streamed. */
|
|
14
|
+
streamingText: string;
|
|
15
|
+
/** Current error, if any. */
|
|
16
|
+
error: string | null;
|
|
17
|
+
/** Inject dynamic context into the LLM prompt. */
|
|
18
|
+
setContext: (key: string, value: string | null) => void;
|
|
19
|
+
/** Connect to the chat server. */
|
|
20
|
+
connect: () => void;
|
|
21
|
+
/** Disconnect from the chat server. */
|
|
22
|
+
disconnect: () => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* React hook for Pinecall text chat.
|
|
26
|
+
*
|
|
27
|
+
* Creates a ChatSession and exposes reactive state via useSyncExternalStore.
|
|
28
|
+
* The session auto-connects on mount and disconnects on unmount.
|
|
29
|
+
*/
|
|
30
|
+
declare function usePinecallChat(opts: ChatSessionOptions & {
|
|
31
|
+
/** Set to false to disable auto-connect on mount. @default true */
|
|
32
|
+
autoConnect?: boolean;
|
|
33
|
+
}): UsePinecallChatReturn;
|
|
34
|
+
|
|
35
|
+
export { ChatMessage, ChatSessionOptions, type UsePinecallChatReturn, usePinecallChat };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ChatSession } from './chunk-ST5DVE5W.js';
|
|
2
|
+
import { useRef, useSyncExternalStore, useCallback, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
function usePinecallChat(opts) {
|
|
5
|
+
const sessionRef = useRef(null);
|
|
6
|
+
if (!sessionRef.current) {
|
|
7
|
+
sessionRef.current = new ChatSession(opts);
|
|
8
|
+
}
|
|
9
|
+
const session = sessionRef.current;
|
|
10
|
+
const state = useSyncExternalStore(
|
|
11
|
+
useCallback((cb) => session.subscribe(cb), [session]),
|
|
12
|
+
useCallback(() => session.getState(), [session])
|
|
13
|
+
);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (opts.autoConnect !== false) {
|
|
16
|
+
session.connect();
|
|
17
|
+
}
|
|
18
|
+
return () => {
|
|
19
|
+
session.destroy();
|
|
20
|
+
sessionRef.current = null;
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
return {
|
|
24
|
+
messages: state.messages,
|
|
25
|
+
send: useCallback((text) => session.send(text), [session]),
|
|
26
|
+
connected: state.status === "connected",
|
|
27
|
+
typing: state.typing,
|
|
28
|
+
streamingText: state.streamingText,
|
|
29
|
+
error: state.error,
|
|
30
|
+
setContext: useCallback(
|
|
31
|
+
(key, value) => session.setContext(key, value),
|
|
32
|
+
[session]
|
|
33
|
+
),
|
|
34
|
+
connect: useCallback(() => session.connect(), [session]),
|
|
35
|
+
disconnect: useCallback(() => session.disconnect(), [session])
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { usePinecallChat };
|
|
40
|
+
//# sourceMappingURL=react.js.map
|
|
41
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx"],"names":[],"mappings":";;;AA6DO,SAAS,gBACd,IAAA,EAIuB;AACvB,EAAA,MAAM,UAAA,GAAa,OAA2B,IAAI,CAAA;AAGlD,EAAA,IAAI,CAAC,WAAW,OAAA,EAAS;AACvB,IAAA,UAAA,CAAW,OAAA,GAAU,IAAI,WAAA,CAAY,IAAI,CAAA;AAAA,EAC3C;AACA,EAAA,MAAM,UAAU,UAAA,CAAW,OAAA;AAG3B,EAAA,MAAM,KAAA,GAAQ,oBAAA;AAAA,IACZ,WAAA,CAAY,CAAC,EAAA,KAAmB,OAAA,CAAQ,UAAU,EAAE,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAAA,IAChE,YAAY,MAAM,OAAA,CAAQ,UAAS,EAAG,CAAC,OAAO,CAAC;AAAA,GACjD;AAGA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,IAAA,CAAK,gBAAgB,KAAA,EAAO;AAC9B,MAAA,OAAA,CAAQ,OAAA,EAAQ;AAAA,IAClB;AACA,IAAA,OAAO,MAAM;AACX,MAAA,OAAA,CAAQ,OAAA,EAAQ;AAChB,MAAA,UAAA,CAAW,OAAA,GAAU,IAAA;AAAA,IACvB,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO;AAAA,IACL,UAAU,KAAA,CAAM,QAAA;AAAA,IAChB,IAAA,EAAM,WAAA,CAAY,CAAC,IAAA,KAAiB,OAAA,CAAQ,KAAK,IAAI,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAAA,IACjE,SAAA,EAAW,MAAM,MAAA,KAAW,WAAA;AAAA,IAC5B,QAAQ,KAAA,CAAM,MAAA;AAAA,IACd,eAAe,KAAA,CAAM,aAAA;AAAA,IACrB,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,UAAA,EAAY,WAAA;AAAA,MACV,CAAC,GAAA,EAAa,KAAA,KAAyB,OAAA,CAAQ,UAAA,CAAW,KAAK,KAAK,CAAA;AAAA,MACpE,CAAC,OAAO;AAAA,KACV;AAAA,IACA,OAAA,EAAS,YAAY,MAAM,OAAA,CAAQ,SAAQ,EAAG,CAAC,OAAO,CAAC,CAAA;AAAA,IACvD,UAAA,EAAY,YAAY,MAAM,OAAA,CAAQ,YAAW,EAAG,CAAC,OAAO,CAAC;AAAA,GAC/D;AACF","file":"react.js","sourcesContent":["/**\n * @pinecall/chat-core/react\n *\n * React hook for Pinecall text chat.\n *\n * @example\n * ```tsx\n * import { usePinecallChat } from \"@pinecall/chat-core/react\";\n *\n * function Chat() {\n * const { messages, send, connected, typing } = usePinecallChat({\n * agent: \"florencia\",\n * });\n *\n * return (\n * <div>\n * {messages.map((m) => (\n * <p key={m.id}>{m.role}: {m.text}</p>\n * ))}\n * <input onKeyDown={(e) => {\n * if (e.key === \"Enter\") {\n * send(e.currentTarget.value);\n * e.currentTarget.value = \"\";\n * }\n * }} />\n * </div>\n * );\n * }\n * ```\n */\nimport { useSyncExternalStore, useRef, useCallback, useEffect } from \"react\";\nimport { ChatSession } from \"./ChatSession\";\nimport type { ChatSessionOptions, ChatMessage } from \"./types\";\n\nexport interface UsePinecallChatReturn {\n /** All messages in the conversation. */\n messages: ChatMessage[];\n /** Send a text message. */\n send: (text: string) => void;\n /** True when connected to the server. */\n connected: boolean;\n /** True while the bot is streaming a response. */\n typing: boolean;\n /** Partial text of the current response being streamed. */\n streamingText: string;\n /** Current error, if any. */\n error: string | null;\n /** Inject dynamic context into the LLM prompt. */\n setContext: (key: string, value: string | null) => void;\n /** Connect to the chat server. */\n connect: () => void;\n /** Disconnect from the chat server. */\n disconnect: () => void;\n}\n\n/**\n * React hook for Pinecall text chat.\n *\n * Creates a ChatSession and exposes reactive state via useSyncExternalStore.\n * The session auto-connects on mount and disconnects on unmount.\n */\nexport function usePinecallChat(\n opts: ChatSessionOptions & {\n /** Set to false to disable auto-connect on mount. @default true */\n autoConnect?: boolean;\n },\n): UsePinecallChatReturn {\n const sessionRef = useRef<ChatSession | null>(null);\n\n // Stable session instance\n if (!sessionRef.current) {\n sessionRef.current = new ChatSession(opts);\n }\n const session = sessionRef.current;\n\n // useSyncExternalStore for reactive state\n const state = useSyncExternalStore(\n useCallback((cb: () => void) => session.subscribe(cb), [session]),\n useCallback(() => session.getState(), [session]),\n );\n\n // Auto-connect on mount\n useEffect(() => {\n if (opts.autoConnect !== false) {\n session.connect();\n }\n return () => {\n session.destroy();\n sessionRef.current = null;\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n messages: state.messages,\n send: useCallback((text: string) => session.send(text), [session]),\n connected: state.status === \"connected\",\n typing: state.typing,\n streamingText: state.streamingText,\n error: state.error,\n setContext: useCallback(\n (key: string, value: string | null) => session.setContext(key, value),\n [session],\n ),\n connect: useCallback(() => session.connect(), [session]),\n disconnect: useCallback(() => session.disconnect(), [session]),\n };\n}\n\n// Re-export core types for convenience\nexport type { ChatSessionOptions, ChatMessage, ChatSessionState } from \"./types\";\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pinecall/chat-core — Type definitions.
|
|
3
|
+
*/
|
|
4
|
+
/** Chat session connection status. */
|
|
5
|
+
type ChatStatus = "idle" | "connecting" | "connected" | "error";
|
|
6
|
+
/** A single message in the conversation. */
|
|
7
|
+
interface ChatMessage {
|
|
8
|
+
id: number;
|
|
9
|
+
role: "user" | "bot";
|
|
10
|
+
text: string;
|
|
11
|
+
/** Server-assigned message ID (for bot messages). */
|
|
12
|
+
messageId?: string;
|
|
13
|
+
/** True while the bot is still streaming this message. */
|
|
14
|
+
isStreaming?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Full state of a ChatSession (immutable snapshots). */
|
|
17
|
+
interface ChatSessionState {
|
|
18
|
+
status: ChatStatus;
|
|
19
|
+
error: string | null;
|
|
20
|
+
/** All messages in the conversation. */
|
|
21
|
+
messages: ChatMessage[];
|
|
22
|
+
/** True while the bot is streaming a response. */
|
|
23
|
+
typing: boolean;
|
|
24
|
+
/** Partial text of the current bot response being streamed. */
|
|
25
|
+
streamingText: string;
|
|
26
|
+
/** Session ID assigned by the server. */
|
|
27
|
+
sessionId: string | null;
|
|
28
|
+
}
|
|
29
|
+
/** Options for creating a ChatSession. */
|
|
30
|
+
interface ChatSessionOptions {
|
|
31
|
+
/** Agent ID to connect to (e.g. "florencia", "dev-berna-florencia"). */
|
|
32
|
+
agent: string;
|
|
33
|
+
/**
|
|
34
|
+
* Voice server URL.
|
|
35
|
+
* The SDK fetches a chat token from `GET {server}/chat/token?agent_id=X`.
|
|
36
|
+
* Then opens a WebSocket to `{server}/chat/ws?token=cht_xxx`.
|
|
37
|
+
*
|
|
38
|
+
* @default "https://voice.pinecall.io"
|
|
39
|
+
*/
|
|
40
|
+
server?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Events emitted by ChatSession via EventTarget. */
|
|
43
|
+
type ChatEventType = "status" | "message" | "error" | "change";
|
|
44
|
+
|
|
45
|
+
export type { ChatEventType as C, ChatMessage as a, ChatSessionOptions as b, ChatSessionState as c, ChatStatus as d };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pinecall/chat-core — Type definitions.
|
|
3
|
+
*/
|
|
4
|
+
/** Chat session connection status. */
|
|
5
|
+
type ChatStatus = "idle" | "connecting" | "connected" | "error";
|
|
6
|
+
/** A single message in the conversation. */
|
|
7
|
+
interface ChatMessage {
|
|
8
|
+
id: number;
|
|
9
|
+
role: "user" | "bot";
|
|
10
|
+
text: string;
|
|
11
|
+
/** Server-assigned message ID (for bot messages). */
|
|
12
|
+
messageId?: string;
|
|
13
|
+
/** True while the bot is still streaming this message. */
|
|
14
|
+
isStreaming?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Full state of a ChatSession (immutable snapshots). */
|
|
17
|
+
interface ChatSessionState {
|
|
18
|
+
status: ChatStatus;
|
|
19
|
+
error: string | null;
|
|
20
|
+
/** All messages in the conversation. */
|
|
21
|
+
messages: ChatMessage[];
|
|
22
|
+
/** True while the bot is streaming a response. */
|
|
23
|
+
typing: boolean;
|
|
24
|
+
/** Partial text of the current bot response being streamed. */
|
|
25
|
+
streamingText: string;
|
|
26
|
+
/** Session ID assigned by the server. */
|
|
27
|
+
sessionId: string | null;
|
|
28
|
+
}
|
|
29
|
+
/** Options for creating a ChatSession. */
|
|
30
|
+
interface ChatSessionOptions {
|
|
31
|
+
/** Agent ID to connect to (e.g. "florencia", "dev-berna-florencia"). */
|
|
32
|
+
agent: string;
|
|
33
|
+
/**
|
|
34
|
+
* Voice server URL.
|
|
35
|
+
* The SDK fetches a chat token from `GET {server}/chat/token?agent_id=X`.
|
|
36
|
+
* Then opens a WebSocket to `{server}/chat/ws?token=cht_xxx`.
|
|
37
|
+
*
|
|
38
|
+
* @default "https://voice.pinecall.io"
|
|
39
|
+
*/
|
|
40
|
+
server?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Events emitted by ChatSession via EventTarget. */
|
|
43
|
+
type ChatEventType = "status" | "message" | "error" | "change";
|
|
44
|
+
|
|
45
|
+
export type { ChatEventType as C, ChatMessage as a, ChatSessionOptions as b, ChatSessionState as c, ChatStatus as d };
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pinecall/chat-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-agnostic text chat client for Pinecall agents",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./react": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/react.d.ts",
|
|
24
|
+
"default": "./dist/react.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/react.d.cts",
|
|
28
|
+
"default": "./dist/react.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"dev": "tsup --watch",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": ">=18"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"react": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"react": "^18.3.1",
|
|
53
|
+
"@types/react": "^18.3.12",
|
|
54
|
+
"tsup": "^8.3.5",
|
|
55
|
+
"typescript": "^5.6.3"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"chat",
|
|
62
|
+
"ai",
|
|
63
|
+
"agent",
|
|
64
|
+
"pinecall",
|
|
65
|
+
"llm"
|
|
66
|
+
],
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "https://github.com/pinecall/webrtc"
|
|
70
|
+
}
|
|
71
|
+
}
|