@sinas/sdk 0.7.0 → 0.8.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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useQuery.ts","../src/hooks/context.ts","../src/hooks/useExecute.ts","../src/hooks/useStateStore.ts","../src/hooks/useChat.ts","../src/hooks/useSinas.ts","../src/hooks/useAuth.ts"],"sourcesContent":["import React from 'react';\nimport { executeQuery } from '../client/queries';\nimport { useClient } from './context';\nimport type { QueryResult } from '../client/types';\n\nexport interface UseQueryOptions {\n enabled?: boolean;\n refetchInterval?: number | null;\n}\n\nexport interface UseQueryResult {\n data: Record<string, unknown>[] | null;\n loading: boolean;\n error: string | null;\n rowCount: number | null;\n refetch: (overrideInput?: Record<string, unknown>) => Promise<QueryResult | undefined>;\n}\n\nexport function useQuery(\n ref: string,\n input: Record<string, unknown> = {},\n options: UseQueryOptions = {}\n): UseQueryResult {\n const client = useClient();\n const { enabled = true, refetchInterval = null } = options;\n\n const [data, setData] = React.useState<Record<string, unknown>[] | null>(null);\n const [loading, setLoading] = React.useState(false);\n const [error, setError] = React.useState<string | null>(null);\n const [rowCount, setRowCount] = React.useState<number | null>(null);\n\n const abortRef = React.useRef<AbortController | null>(null);\n const inputJson = JSON.stringify(input);\n\n const execute = React.useCallback(\n async (overrideInput?: Record<string, unknown>) => {\n abortRef.current?.abort();\n const controller = new AbortController();\n abortRef.current = controller;\n\n setLoading(true);\n setError(null);\n try {\n const result = await executeQuery(\n client,\n ref,\n overrideInput || JSON.parse(inputJson)\n );\n if (!controller.signal.aborted) {\n setData(result.data || null);\n setRowCount(result.rowCount ?? result.affectedRows ?? null);\n }\n return result;\n } catch (e) {\n if (!controller.signal.aborted) {\n setError((e as Error).message);\n }\n } finally {\n if (!controller.signal.aborted) {\n setLoading(false);\n }\n }\n },\n [client, ref, inputJson]\n );\n\n React.useEffect(() => {\n if (enabled) {\n execute();\n }\n return () => {\n abortRef.current?.abort();\n };\n }, [enabled, execute]);\n\n React.useEffect(() => {\n if (refetchInterval && enabled) {\n const id = setInterval(execute, refetchInterval);\n return () => clearInterval(id);\n }\n }, [refetchInterval, enabled, execute]);\n\n return { data, loading, error, rowCount, refetch: execute };\n}\n","import React from 'react';\nimport { SinasClient, type SinasClientOptions } from '../client/SinasClient';\n\nconst SinasContext = React.createContext<SinasClient | null>(null);\n\nexport interface SinasProviderProps {\n /** Pre-built client. If provided, options below are ignored. */\n client?: SinasClient;\n /** Standalone-mode options (baseUrl, token callbacks, etc.). */\n options?: SinasClientOptions;\n children: React.ReactNode;\n}\n\nexport function SinasProvider({ client, options, children }: SinasProviderProps) {\n const value = React.useMemo(\n () => client || new SinasClient(options),\n // We intentionally only re-create when `client` reference changes; `options`\n // is expected to be a stable object (callbacks reading from localStorage).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [client],\n );\n return React.createElement(SinasContext.Provider, { value }, children);\n}\n\nexport function useClient(): SinasClient {\n const client = React.useContext(SinasContext);\n if (client) return client;\n return defaultClient;\n}\n\nconst defaultClient = new SinasClient();\n","import React from 'react';\nimport { executeFunction } from '../client/functions';\nimport { useClient } from './context';\nimport type { FunctionResult } from '../client/types';\n\nexport interface UseExecuteResult {\n execute: (input?: Record<string, unknown>, timeout?: number) => Promise<FunctionResult | undefined>;\n result: unknown;\n loading: boolean;\n error: string | null;\n executionId: string | null;\n}\n\nexport function useExecute(ref: string): UseExecuteResult {\n const client = useClient();\n\n const [result, setResult] = React.useState<unknown>(null);\n const [loading, setLoading] = React.useState(false);\n const [error, setError] = React.useState<string | null>(null);\n const [executionId, setExecutionId] = React.useState<string | null>(null);\n\n const execute = React.useCallback(\n async (input: Record<string, unknown> = {}, timeout?: number) => {\n setLoading(true);\n setError(null);\n try {\n const data = await executeFunction(client, ref, input, timeout);\n setResult(data.result);\n setExecutionId(data.executionId);\n if (data.status === 'error') {\n setError(data.error || 'Function execution failed');\n } else if (data.status === 'timeout') {\n setError('Function execution timed out');\n }\n return data;\n } catch (e) {\n setError((e as Error).message);\n } finally {\n setLoading(false);\n }\n },\n [client, ref]\n );\n\n return { execute, result, loading, error, executionId };\n}\n","import React from 'react';\nimport { stateGet, stateSet, stateDelete, stateList } from '../client/states';\nimport { useClient } from './context';\nimport type { StateListResult } from '../client/types';\n\nexport interface UseStateStoreOptions {\n visibility?: 'private' | 'shared';\n}\n\nexport interface UseStateStoreResult {\n value: unknown;\n loading: boolean;\n error: string | null;\n save: (value: unknown, opts?: UseStateStoreOptions) => Promise<void>;\n remove: () => Promise<void>;\n refetch: () => Promise<void>;\n list: () => Promise<StateListResult | undefined>;\n}\n\nexport function useStateStore(ns: string, key?: string): UseStateStoreResult {\n const client = useClient();\n\n const [value, setValue] = React.useState<unknown>(null);\n const [loading, setLoading] = React.useState(true);\n const [error, setError] = React.useState<string | null>(null);\n\n const load = React.useCallback(async () => {\n if (!key) {\n setLoading(false);\n return;\n }\n setLoading(true);\n setError(null);\n try {\n const result = await stateGet(client, ns, key);\n if (result.found) {\n setValue(result.value);\n } else {\n setValue(null);\n }\n } catch (e) {\n setError((e as Error).message);\n } finally {\n setLoading(false);\n }\n }, [client, ns, key]);\n\n const save = React.useCallback(\n async (newValue: unknown, opts?: UseStateStoreOptions) => {\n if (!key) throw new Error('Cannot save without a key');\n setValue(newValue);\n setError(null);\n try {\n await stateSet(client, ns, key, newValue, opts?.visibility);\n } catch (e) {\n setError((e as Error).message);\n throw e;\n }\n },\n [client, ns, key]\n );\n\n const remove = React.useCallback(async () => {\n if (!key) throw new Error('Cannot delete without a key');\n setValue(null);\n setError(null);\n try {\n await stateDelete(client, ns, key);\n } catch (e) {\n setError((e as Error).message);\n throw e;\n }\n }, [client, ns, key]);\n\n const list = React.useCallback(async () => {\n setError(null);\n try {\n return await stateList(client, ns);\n } catch (e) {\n setError((e as Error).message);\n }\n }, [client, ns]);\n\n React.useEffect(() => {\n load();\n }, [load]);\n\n return { value, loading, error, save, remove, refetch: load, list };\n}\n","import React from 'react';\nimport { createChat, getChat, streamMessage, approveToolCall, streamFromChannel } from '../client/chat';\nimport { useClient } from './context';\nimport type { ChatMessageFull, ApprovalRequest, SSEChunk, MessageContent } from '../client/types';\n\nexport interface ToolResult {\n content: string;\n name: string;\n}\n\nexport interface ChatSessionMessage extends ChatMessageFull {\n /** True while streaming content is being appended */\n streaming?: boolean;\n /** Inline tool results keyed by tool_call_id (merged from tool_end events) */\n toolResults?: Record<string, ToolResult>;\n}\n\nexport interface ToolStatus {\n toolCallId: string;\n name: string;\n description: string;\n status: 'running' | 'complete';\n}\n\nexport interface UseChatResult {\n chatId: string | null;\n messages: ChatSessionMessage[];\n loading: boolean;\n streaming: boolean;\n error: string | null;\n pendingApprovals: ApprovalRequest[];\n toolStatus: ToolStatus[];\n send: (content: MessageContent) => void;\n approve: (toolCallId: string) => void;\n reject: (toolCallId: string) => void;\n stop: () => void;\n clearError: () => void;\n}\n\nexport interface UseChatOptions {\n chatId?: string;\n input?: Record<string, unknown>;\n}\n\nexport function useChat(\n agentRef: string,\n options?: UseChatOptions,\n): UseChatResult {\n const client = useClient();\n\n const [chatId, setChatId] = React.useState<string | null>(options?.chatId ?? null);\n const [messages, setMessages] = React.useState<ChatSessionMessage[]>([]);\n const [loading, setLoading] = React.useState(false);\n const [streaming, setStreaming] = React.useState(false);\n const [error, setError] = React.useState<string | null>(null);\n const [pendingApprovals, setPendingApprovals] = React.useState<ApprovalRequest[]>([]);\n const [toolStatus, setToolStatus] = React.useState<ToolStatus[]>([]);\n\n const abortRef = React.useRef<AbortController | null>(null);\n const chatIdRef = React.useRef<string | null>(chatId);\n chatIdRef.current = chatId;\n\n // Load existing chat on mount if chatId provided\n React.useEffect(() => {\n if (!options?.chatId) return;\n let cancelled = false;\n\n setLoading(true);\n getChat(client, options.chatId)\n .then((detail) => {\n if (cancelled) return;\n setChatId(detail.id);\n setMessages(detail.messages);\n if (detail.pendingApprovals?.length) {\n setPendingApprovals(detail.pendingApprovals);\n }\n })\n .catch((e) => {\n if (cancelled) return;\n setError((e as Error).message);\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n\n return () => { cancelled = true; };\n }, [client, options?.chatId]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n abortRef.current?.abort();\n };\n }, []);\n\n const handleStreamChunks = React.useCallback(\n (chunk: SSEChunk) => {\n if (chunk.event === 'message') {\n // Append text to the last assistant text message, or create a new one.\n const newContent = (() => {\n try {\n const parsed = JSON.parse(chunk.data);\n return parsed.content || '';\n } catch {\n return chunk.data;\n }\n })();\n if (!newContent) return;\n setMessages((prev) => {\n const last = prev[prev.length - 1];\n if (last && last.role === 'assistant' && !last.toolCalls && last.streaming) {\n // Append to existing text message\n const next = [...prev];\n next[next.length - 1] = { ...last, content: (last.content || '') + newContent };\n return next;\n }\n // Create a new text message\n return [...prev, {\n id: `tmp-text-${Date.now()}`,\n chatId: chatIdRef.current || '',\n role: 'assistant' as const,\n content: newContent,\n toolCalls: null,\n toolCallId: null,\n name: null,\n createdAt: new Date().toISOString(),\n streaming: true,\n }];\n });\n } else if (chunk.event === 'tool_start') {\n try {\n const parsed = JSON.parse(chunk.data);\n setToolStatus((prev) => [\n ...prev,\n { toolCallId: parsed.tool_call_id, name: parsed.name, description: parsed.description, status: 'running' },\n ]);\n setMessages((prev) => {\n if (prev.some((m) => m.toolCalls?.some((tc) => tc.id === parsed.tool_call_id))) {\n return prev;\n }\n // Stop streaming on previous text message (freeze it in place)\n const next = prev.map((m, i) =>\n i === prev.length - 1 && m.streaming && m.role === 'assistant' && !m.toolCalls\n ? { ...m, streaming: false }\n : m,\n );\n return [...next, {\n id: `tmp-tc-${parsed.tool_call_id}`,\n chatId: chatIdRef.current || '',\n role: 'assistant' as const,\n content: null,\n toolCalls: [{\n id: parsed.tool_call_id,\n type: 'function' as const,\n function: { name: parsed.name, arguments: parsed.arguments || '{}' },\n description: parsed.description,\n }],\n toolCallId: null,\n name: null,\n createdAt: new Date().toISOString(),\n streaming: true,\n }];\n });\n } catch {\n // ignore malformed tool_start events\n }\n } else if (chunk.event === 'tool_end') {\n try {\n const parsed = JSON.parse(chunk.data);\n setToolStatus((prev) =>\n prev.map((t) => t.toolCallId === parsed.tool_call_id ? { ...t, status: 'complete' } : t),\n );\n // Merge result into the existing tool call message (same bubble)\n if (parsed.result !== undefined) {\n const resultContent = typeof parsed.result === 'string' ? parsed.result : JSON.stringify(parsed.result);\n setMessages((prev) =>\n prev.map((m) => {\n if (m.toolCalls?.some((tc) => tc.id === parsed.tool_call_id)) {\n return {\n ...m,\n toolResults: {\n ...m.toolResults,\n [parsed.tool_call_id]: { content: resultContent, name: parsed.name },\n },\n };\n }\n return m;\n }),\n );\n }\n } catch {\n // ignore malformed tool_end events\n }\n } else if (chunk.event === 'approval_required') {\n try {\n const raw = JSON.parse(chunk.data);\n const parsed: ApprovalRequest = {\n type: raw.type,\n toolCallId: raw.tool_call_id,\n functionNamespace: raw.function_namespace,\n functionName: raw.function_name,\n arguments: raw.arguments,\n };\n setPendingApprovals((prev) => [...prev, parsed]);\n } catch {\n // ignore malformed approval events\n }\n } else if (chunk.event === 'error') {\n try {\n const parsed = JSON.parse(chunk.data);\n setError(parsed.error || 'Stream error');\n } catch {\n setError(chunk.data || 'Stream error');\n }\n }\n },\n [],\n );\n\n const refreshMessages = React.useCallback(\n async (id: string) => {\n try {\n const detail = await getChat(client, id);\n setMessages(detail.messages);\n if (detail.pendingApprovals?.length) {\n setPendingApprovals(detail.pendingApprovals);\n }\n } catch {\n // Refresh is best-effort — streaming content already visible\n }\n },\n [client],\n );\n\n const send = React.useCallback(\n (content: MessageContent) => {\n const doSend = async () => {\n let activeChatId = chatIdRef.current;\n\n // Auto-create chat on first send\n if (!activeChatId) {\n setLoading(true);\n setError(null);\n try {\n const result = await createChat(client, agentRef, options?.input);\n activeChatId = result.id;\n setChatId(result.id);\n chatIdRef.current = result.id;\n } catch (e) {\n setError((e as Error).message);\n setLoading(false);\n return;\n }\n setLoading(false);\n }\n\n abortRef.current?.abort();\n setStreaming(true);\n setError(null);\n setPendingApprovals([]);\n setToolStatus([]);\n\n // Add user message optimistically\n const displayContent = typeof content === 'string' ? content : JSON.stringify(content);\n const userMsg: ChatSessionMessage = {\n id: `tmp-user-${Date.now()}`,\n chatId: activeChatId,\n role: 'user',\n content: displayContent,\n toolCalls: null,\n toolCallId: null,\n name: null,\n createdAt: new Date().toISOString(),\n };\n setMessages((prev) => [...prev, userMsg]);\n\n const controller = streamMessage(\n client,\n activeChatId,\n content,\n handleStreamChunks,\n () => {\n setStreaming(false);\n setToolStatus([]);\n // Refresh to get authoritative server state\n refreshMessages(activeChatId!);\n },\n (err: Error) => {\n setError(err.message);\n setStreaming(false);\n setToolStatus([]);\n },\n );\n\n abortRef.current = controller;\n };\n\n doSend();\n },\n [client, agentRef, options?.input, handleStreamChunks, refreshMessages],\n );\n\n const handleApproval = React.useCallback(\n (toolCallId: string, approved: boolean) => {\n const currentChatId = chatIdRef.current;\n if (!currentChatId) return;\n\n setPendingApprovals((prev) => prev.filter((a) => a.toolCallId !== toolCallId));\n setStreaming(true);\n setError(null);\n\n // No placeholder needed — handleStreamChunks creates messages on demand\n\n (async () => {\n try {\n const result = await approveToolCall(client, currentChatId, toolCallId, approved);\n\n if (!approved) {\n setStreaming(false);\n refreshMessages(currentChatId);\n return;\n }\n\n // Connect to resume stream\n const controller = streamFromChannel(\n client,\n currentChatId,\n result.channelId,\n handleStreamChunks,\n () => {\n setStreaming(false);\n setToolStatus([]);\n refreshMessages(currentChatId);\n },\n (err: Error) => {\n setError(err.message);\n setStreaming(false);\n setToolStatus([]);\n },\n );\n\n abortRef.current = controller;\n } catch (e) {\n setError((e as Error).message);\n setStreaming(false);\n }\n })();\n },\n [client, handleStreamChunks, refreshMessages],\n );\n\n const approve = React.useCallback(\n (toolCallId: string) => handleApproval(toolCallId, true),\n [handleApproval],\n );\n\n const reject = React.useCallback(\n (toolCallId: string) => handleApproval(toolCallId, false),\n [handleApproval],\n );\n\n const stop = React.useCallback(() => {\n abortRef.current?.abort();\n abortRef.current = null;\n setStreaming(false);\n }, []);\n\n const clearError = React.useCallback(() => {\n setError(null);\n }, []);\n\n return {\n chatId,\n messages,\n loading,\n streaming,\n error,\n pendingApprovals,\n toolStatus,\n send,\n approve,\n reject,\n stop,\n clearError,\n };\n}\n","import { useClient } from './context';\nimport { useQuery } from './useQuery';\nimport { useExecute } from './useExecute';\nimport { useStateStore } from './useStateStore';\nimport { useChat } from './useChat';\nimport type { SinasConfig } from '../client/types';\nimport type { SinasClient } from '../client/SinasClient';\n\nexport interface UseSinasResult {\n config: SinasConfig;\n input: Record<string, unknown>;\n client: SinasClient;\n useQuery: typeof useQuery;\n useExecute: typeof useExecute;\n useStateStore: typeof useStateStore;\n useChat: typeof useChat;\n}\n\nexport function useSinas(): UseSinasResult {\n const client = useClient();\n\n return {\n config: client.getConfig(),\n input: client.getInput(),\n client,\n useQuery,\n useExecute,\n useStateStore,\n useChat,\n };\n}\n","import React from 'react';\nimport { useClient } from './context';\nimport { SinasAuthError } from '../client/errors';\nimport type {\n AuthUser,\n InfoResponse,\n LoginResponse,\n OTPVerifyResponse,\n} from '../client/types';\n\nexport type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';\n\nexport interface UseAuthResult {\n status: AuthStatus;\n user: AuthUser | null;\n info: InfoResponse | null;\n error: string | null;\n\n /**\n * Refresh the session by calling /auth/me with the current access token.\n * Call this on app boot and after token changes.\n */\n refresh: () => Promise<void>;\n\n /**\n * Start a login. In password-only mode this completes the login and\n * returns access/refresh tokens. In OTP / password+OTP mode the response\n * carries a `session_id` to feed into `verifyOTP`.\n */\n login: (email: string, password?: string) => Promise<LoginResponse>;\n\n /** Second step for OTP / password+OTP. Returns the final tokens. */\n verifyOTP: (sessionId: string, otpCode: string) => Promise<OTPVerifyResponse>;\n\n /** Revoke the refresh token and clear local auth state. */\n logout: (refreshToken?: string) => Promise<void>;\n}\n\nexport interface UseAuthOptions {\n /** Refresh on mount. Default true. */\n autoRefresh?: boolean;\n}\n\n/**\n * React hook for the standalone Sinas login flow. The hosting app is\n * responsible for storing the tokens it receives (typically in localStorage)\n * and wiring `getAccessToken` / `getRefreshToken` / `onTokenRefresh` on the\n * SinasProvider so this hook can read the current session.\n */\nexport function useAuth(options: UseAuthOptions = {}): UseAuthResult {\n const { autoRefresh = true } = options;\n const client = useClient();\n\n const [status, setStatus] = React.useState<AuthStatus>('loading');\n const [user, setUser] = React.useState<AuthUser | null>(null);\n const [info, setInfo] = React.useState<InfoResponse | null>(null);\n const [error, setError] = React.useState<string | null>(null);\n\n const refresh = React.useCallback(async () => {\n setError(null);\n try {\n // Fetch /info in parallel with /me (info is unauthenticated and cheap).\n const [infoResp, meResp] = await Promise.all([\n client.auth.getInfo().catch(() => null),\n client.getAccessToken() ? client.auth.getMe().catch(() => null) : Promise.resolve(null),\n ]);\n if (infoResp) setInfo(infoResp);\n if (meResp) {\n setUser(meResp);\n setStatus('authenticated');\n } else {\n setUser(null);\n setStatus('unauthenticated');\n }\n } catch (e) {\n setError(e instanceof Error ? e.message : String(e));\n setStatus('unauthenticated');\n }\n }, [client]);\n\n React.useEffect(() => {\n if (autoRefresh) void refresh();\n }, [autoRefresh, refresh]);\n\n const login = React.useCallback(\n async (email: string, password?: string) => {\n setError(null);\n try {\n return await client.auth.login({ email, password });\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n setError(msg);\n throw e;\n }\n },\n [client],\n );\n\n const verifyOTP = React.useCallback(\n async (sessionId: string, otpCode: string) => {\n setError(null);\n try {\n return await client.auth.verifyOTP({ session_id: sessionId, otp_code: otpCode });\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n setError(msg);\n throw e;\n }\n },\n [client],\n );\n\n const logout = React.useCallback(\n async (refreshToken?: string) => {\n if (refreshToken) {\n try {\n await client.auth.logout(refreshToken);\n } catch (e) {\n if (!(e instanceof SinasAuthError)) throw e;\n }\n }\n setUser(null);\n setStatus('unauthenticated');\n },\n [client],\n );\n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D,iBAAS,GAAG;AACZ,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,QAAMG,aAAYH,OAAM;AAAA,IACtB,OAAO,WAAmB,YAAoB;AAC5C,eAAS,IAAI;AACb,UAAI;AACF,eAAO,MAAM,OAAO,KAAK,UAAU,EAAE,YAAY,WAAW,UAAU,QAAQ,CAAC;AAAA,MACjF,SAAS,GAAG;AACV,cAAM,MAAM,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AACrD,iBAAS,GAAG;AACZ,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,QAAMI,UAASJ,OAAM;AAAA,IACnB,OAAO,iBAA0B;AAC/B,UAAI,cAAc;AAChB,YAAI;AACF,gBAAM,OAAO,KAAK,OAAO,YAAY;AAAA,QACvC,SAAS,GAAG;AACV,cAAI,EAAE,aAAa,gBAAiB,OAAM;AAAA,QAC5C;AAAA,MACF;AACA,cAAQ,IAAI;AACZ,gBAAU,iBAAiB;AAAA,IAC7B;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,SAAO,EAAE,QAAQ,MAAM,MAAM,OAAO,SAAAC,UAAS,OAAAC,QAAO,WAAAC,YAAW,QAAAC,QAAO;AACxE;","names":["React","React","React","React","React","React","React","React","React","React","refresh","login","verifyOTP","logout"]}
1
+ {"version":3,"sources":["../src/hooks/useQuery.ts","../src/hooks/context.ts","../src/hooks/useExecute.ts","../src/hooks/useStateStore.ts","../src/hooks/useChat.ts","../src/hooks/chatState.ts","../src/hooks/useSinas.ts","../src/hooks/useAuth.ts"],"sourcesContent":["import React from 'react';\nimport { executeQuery } from '../client/queries';\nimport { useClient } from './context';\nimport type { QueryResult } from '../client/types';\n\nexport interface UseQueryOptions {\n enabled?: boolean;\n refetchInterval?: number | null;\n}\n\nexport interface UseQueryResult {\n data: Record<string, unknown>[] | null;\n loading: boolean;\n error: string | null;\n rowCount: number | null;\n refetch: (overrideInput?: Record<string, unknown>) => Promise<QueryResult | undefined>;\n}\n\nexport function useQuery(\n ref: string,\n input: Record<string, unknown> = {},\n options: UseQueryOptions = {}\n): UseQueryResult {\n const client = useClient();\n const { enabled = true, refetchInterval = null } = options;\n\n const [data, setData] = React.useState<Record<string, unknown>[] | null>(null);\n const [loading, setLoading] = React.useState(false);\n const [error, setError] = React.useState<string | null>(null);\n const [rowCount, setRowCount] = React.useState<number | null>(null);\n\n const abortRef = React.useRef<AbortController | null>(null);\n const inputJson = JSON.stringify(input);\n\n const execute = React.useCallback(\n async (overrideInput?: Record<string, unknown>) => {\n abortRef.current?.abort();\n const controller = new AbortController();\n abortRef.current = controller;\n\n setLoading(true);\n setError(null);\n try {\n const result = await executeQuery(\n client,\n ref,\n overrideInput || JSON.parse(inputJson)\n );\n if (!controller.signal.aborted) {\n setData(result.data || null);\n setRowCount(result.rowCount ?? result.affectedRows ?? null);\n }\n return result;\n } catch (e) {\n if (!controller.signal.aborted) {\n setError((e as Error).message);\n }\n } finally {\n if (!controller.signal.aborted) {\n setLoading(false);\n }\n }\n },\n [client, ref, inputJson]\n );\n\n React.useEffect(() => {\n if (enabled) {\n execute();\n }\n return () => {\n abortRef.current?.abort();\n };\n }, [enabled, execute]);\n\n React.useEffect(() => {\n if (refetchInterval && enabled) {\n const id = setInterval(execute, refetchInterval);\n return () => clearInterval(id);\n }\n }, [refetchInterval, enabled, execute]);\n\n return { data, loading, error, rowCount, refetch: execute };\n}\n","import React from 'react';\nimport { SinasClient, type SinasClientOptions } from '../client/SinasClient';\n\nconst SinasContext = React.createContext<SinasClient | null>(null);\n\nexport interface SinasProviderProps {\n /** Pre-built client. If provided, options below are ignored. */\n client?: SinasClient;\n /** Standalone-mode options (baseUrl, token callbacks, etc.). */\n options?: SinasClientOptions;\n children: React.ReactNode;\n}\n\nexport function SinasProvider({ client, options, children }: SinasProviderProps) {\n const value = React.useMemo(\n () => client || new SinasClient(options),\n // We intentionally only re-create when `client` reference changes; `options`\n // is expected to be a stable object (callbacks reading from localStorage).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [client],\n );\n return React.createElement(SinasContext.Provider, { value }, children);\n}\n\nexport function useClient(): SinasClient {\n const client = React.useContext(SinasContext);\n if (client) return client;\n return defaultClient;\n}\n\nconst defaultClient = new SinasClient();\n","import React from 'react';\nimport { executeFunction } from '../client/functions';\nimport { useClient } from './context';\nimport type { FunctionResult } from '../client/types';\n\nexport interface UseExecuteResult {\n execute: (input?: Record<string, unknown>, timeout?: number) => Promise<FunctionResult | undefined>;\n result: unknown;\n loading: boolean;\n error: string | null;\n executionId: string | null;\n}\n\nexport function useExecute(ref: string): UseExecuteResult {\n const client = useClient();\n\n const [result, setResult] = React.useState<unknown>(null);\n const [loading, setLoading] = React.useState(false);\n const [error, setError] = React.useState<string | null>(null);\n const [executionId, setExecutionId] = React.useState<string | null>(null);\n\n const execute = React.useCallback(\n async (input: Record<string, unknown> = {}, timeout?: number) => {\n setLoading(true);\n setError(null);\n try {\n const data = await executeFunction(client, ref, input, timeout);\n setResult(data.result);\n setExecutionId(data.executionId);\n if (data.status === 'error') {\n setError(data.error || 'Function execution failed');\n } else if (data.status === 'timeout') {\n setError('Function execution timed out');\n }\n return data;\n } catch (e) {\n setError((e as Error).message);\n } finally {\n setLoading(false);\n }\n },\n [client, ref]\n );\n\n return { execute, result, loading, error, executionId };\n}\n","import React from 'react';\nimport { stateGet, stateSet, stateDelete, stateList } from '../client/states';\nimport { useClient } from './context';\nimport type { StateListResult } from '../client/types';\n\nexport interface UseStateStoreOptions {\n visibility?: 'private' | 'shared';\n}\n\nexport interface UseStateStoreResult {\n value: unknown;\n loading: boolean;\n error: string | null;\n save: (value: unknown, opts?: UseStateStoreOptions) => Promise<void>;\n remove: () => Promise<void>;\n refetch: () => Promise<void>;\n list: () => Promise<StateListResult | undefined>;\n}\n\nexport function useStateStore(ns: string, key?: string): UseStateStoreResult {\n const client = useClient();\n\n const [value, setValue] = React.useState<unknown>(null);\n const [loading, setLoading] = React.useState(true);\n const [error, setError] = React.useState<string | null>(null);\n\n const load = React.useCallback(async () => {\n if (!key) {\n setLoading(false);\n return;\n }\n setLoading(true);\n setError(null);\n try {\n const result = await stateGet(client, ns, key);\n if (result.found) {\n setValue(result.value);\n } else {\n setValue(null);\n }\n } catch (e) {\n setError((e as Error).message);\n } finally {\n setLoading(false);\n }\n }, [client, ns, key]);\n\n const save = React.useCallback(\n async (newValue: unknown, opts?: UseStateStoreOptions) => {\n if (!key) throw new Error('Cannot save without a key');\n setValue(newValue);\n setError(null);\n try {\n await stateSet(client, ns, key, newValue, opts?.visibility);\n } catch (e) {\n setError((e as Error).message);\n throw e;\n }\n },\n [client, ns, key]\n );\n\n const remove = React.useCallback(async () => {\n if (!key) throw new Error('Cannot delete without a key');\n setValue(null);\n setError(null);\n try {\n await stateDelete(client, ns, key);\n } catch (e) {\n setError((e as Error).message);\n throw e;\n }\n }, [client, ns, key]);\n\n const list = React.useCallback(async () => {\n setError(null);\n try {\n return await stateList(client, ns);\n } catch (e) {\n setError((e as Error).message);\n }\n }, [client, ns]);\n\n React.useEffect(() => {\n load();\n }, [load]);\n\n return { value, loading, error, save, remove, refetch: load, list };\n}\n","import React from 'react';\nimport {\n answerPendingInput,\n approveToolCall,\n createChat,\n getChat,\n streamFromChannel,\n streamMessage,\n} from '../client/chat';\nimport {\n answerResumeChannel,\n approvalResumeChannel,\n parseApproval,\n pendingInputFromChunk,\n} from '../client/chatEvents';\nimport { useClient } from './context';\nimport {\n NOT_THINKING,\n TRAILING_POLLS_MS,\n addApproval,\n applyTextDelta,\n applyThinking,\n applyToolEnd,\n applyToolStart,\n createLatestGate,\n mergePendingInputs,\n nextPendingPollMs,\n parseMessageChunk,\n stopThinking,\n thinkingView,\n type ThinkingRounds,\n} from './chatState';\nimport type {\n ChatMessageFull,\n ApprovalRequest,\n SSEChunk,\n MessageContent,\n PendingInput,\n StreamDone,\n} from '../client/types';\n\nexport interface ToolResult {\n content: string;\n name: string;\n}\n\nexport interface ChatSessionMessage extends ChatMessageFull {\n /** True while streaming content is being appended */\n streaming?: boolean;\n /** Inline tool results keyed by tool_call_id (merged from tool_end events) */\n toolResults?: Record<string, ToolResult>;\n}\n\nexport interface ToolStatus {\n toolCallId: string;\n name: string;\n description: string;\n status: 'running' | 'complete';\n}\n\n/**\n * The model's thinking during the current turn. Thinking isn't stored with\n * the messages, so it is only known while (and after) streaming the turn;\n * it resets when the next turn starts.\n */\nexport interface ChatThinking {\n /** The model is thinking right now (before its answer or next tool call). */\n active: boolean;\n /**\n * The thinking text so far this turn; only sent with `includeThinking`\n * (otherwise always ''). Thinking rounds are separated by a blank line.\n */\n text: string;\n}\n\nexport interface ApproveOptions {\n /** Approve this tool for the rest of the chat: it won't ask again (Sinas 0.5+). */\n alwaysAllow?: boolean;\n}\n\nexport interface FollowOptions {\n /** Last received stream entry id to resume after (default: from the start). */\n lastId?: string;\n}\n\nexport interface UseChatResult {\n chatId: string | null;\n messages: ChatSessionMessage[];\n loading: boolean;\n streaming: boolean;\n error: string | null;\n pendingApprovals: ApprovalRequest[];\n /**\n * The ask_user questions the conversation waits on (Sinas 0.5+): from\n * `input_required` stream events and from the chat as loaded. Answer with\n * `answer`.\n */\n pendingInputs: PendingInput[];\n /** The model's thinking in the current turn (see `includeThinking`). */\n thinking: ChatThinking;\n toolStatus: ToolStatus[];\n send: (content: MessageContent) => void;\n /**\n * Approve a tool call. When other calls of the same round still wait for a\n * decision, nothing streams until the last one is decided.\n */\n approve: (toolCallId: string, options?: ApproveOptions) => void;\n reject: (toolCallId: string) => void;\n /**\n * Answer an ask_user question. Resolves true once the answer is recorded\n * (the question is then removed from `pendingInputs`), false when it\n * failed (see `error`). When it was the round's last open question, the\n * resumed turn streams into `messages`.\n */\n answer: (toolCallId: string, answer: string) => Promise<boolean>;\n /**\n * Stream a channel into this session: a turn that goes on elsewhere (an\n * `in_progress` result, a reconnect to a running turn).\n */\n follow: (channelId: string, options?: FollowOptions) => void;\n stop: () => void;\n clearError: () => void;\n}\n\nexport interface UseChatOptions {\n chatId?: string;\n input?: Record<string, unknown>;\n /**\n * Stream the model's thinking text into `thinking.text` (Sinas 0.5+).\n * Without it, `thinking.active` still says when the model is thinking.\n */\n includeThinking?: boolean;\n /**\n * While questions wait with no stream open, re-read the chat periodically\n * and just after the earliest deadline, so an expired question (the round\n * then resumes server-side) or one answered elsewhere shows up without a\n * reload. Default true.\n */\n pollPendingInputs?: boolean;\n}\n\nexport function useChat(\n agentRef: string,\n options?: UseChatOptions,\n): UseChatResult {\n const client = useClient();\n const includeThinking = !!options?.includeThinking;\n const pollPendingInputs = options?.pollPendingInputs !== false;\n\n const [chatId, setChatId] = React.useState<string | null>(options?.chatId ?? null);\n const [messages, setMessages] = React.useState<ChatSessionMessage[]>([]);\n const [loading, setLoading] = React.useState(false);\n const [streaming, setStreaming] = React.useState(false);\n const [error, setError] = React.useState<string | null>(null);\n const [pendingApprovals, setPendingApprovals] = React.useState<ApprovalRequest[]>([]);\n const [pendingInputs, setPendingInputs] = React.useState<PendingInput[]>([]);\n const [thinking, setThinking] = React.useState<ThinkingRounds>(NOT_THINKING);\n const thinkingShown = React.useMemo(() => thinkingView(thinking), [thinking]);\n const [toolStatus, setToolStatus] = React.useState<ToolStatus[]>([]);\n // Index into TRAILING_POLLS_MS while re-reading a chat whose question went\n // away server-side; its length means \"not trailing\".\n const [trailingPoll, setTrailingPoll] = React.useState(TRAILING_POLLS_MS.length);\n // Bumped after each poll so the next one is scheduled even when the poll's\n // refresh was superseded (and so changed nothing).\n const [pollTick, setPollTick] = React.useState(0);\n\n const abortRef = React.useRef<AbortController | null>(null);\n const chatIdRef = React.useRef<string | null>(chatId);\n chatIdRef.current = chatId;\n // Only the newest refresh (or turn) may write the server's state.\n const [gate] = React.useState(createLatestGate);\n\n /**\n * Re-read the server's state: messages, approvals, questions. Resolves to\n * the questions shown, or null when the read failed or a newer refresh or\n * turn superseded it (its result is then dropped).\n */\n const refresh = React.useCallback(\n async (id: string): Promise<PendingInput[] | null> => {\n const ticket = gate.next();\n try {\n const detail = await getChat(client, id);\n if (!gate.isCurrent(ticket)) return null;\n setMessages(detail.messages);\n setPendingApprovals(detail.pendingApprovals ?? []);\n const inputs = detail.pendingInputs ?? [];\n setPendingInputs(inputs);\n return inputs;\n } catch {\n // Best-effort: what is already shown stays when the read fails.\n return null;\n }\n },\n [client, gate],\n );\n\n // Load existing chat on mount if chatId provided\n React.useEffect(() => {\n if (!options?.chatId) return;\n let cancelled = false;\n const ticket = gate.next();\n\n setLoading(true);\n getChat(client, options.chatId)\n .then((detail) => {\n if (cancelled || !gate.isCurrent(ticket)) return;\n setChatId(detail.id);\n setMessages(detail.messages);\n setPendingApprovals(detail.pendingApprovals ?? []);\n setPendingInputs(detail.pendingInputs ?? []);\n })\n .catch((e) => {\n if (cancelled) return;\n setError((e as Error).message);\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n\n return () => { cancelled = true; };\n }, [client, gate, options?.chatId]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n abortRef.current?.abort();\n };\n }, []);\n\n // While questions wait with no stream open, nothing announces that one\n // expired (the round then resumes server-side) or was answered elsewhere:\n // re-read the chat periodically and just after the earliest deadline,\n // then a few more times once a question went away, to show the reply.\n React.useEffect(() => {\n if (!pollPendingInputs || streaming || !chatId) return;\n let delay: number | null = null;\n if (pendingInputs.length > 0) delay = nextPendingPollMs(pendingInputs, Date.now());\n else if (trailingPoll < TRAILING_POLLS_MS.length) delay = TRAILING_POLLS_MS[trailingPoll];\n if (delay === null) return;\n const waiting = pendingInputs.map((p) => p.toolCallId);\n const timer = setTimeout(async () => {\n const now = await refresh(chatId);\n if (waiting.length === 0) setTrailingPoll((i) => i + 1);\n else if (now && waiting.some((id) => !now.some((p) => p.toolCallId === id))) setTrailingPoll(0);\n setPollTick((t) => t + 1);\n }, delay);\n return () => clearTimeout(timer);\n }, [pollPendingInputs, chatId, streaming, pendingInputs, trailingPoll, pollTick, refresh]);\n\n const handleStreamChunk = React.useCallback(\n (chunk: SSEChunk) => {\n // A question: its own event, or (some earlier backends, inline turn)\n // a typed message event.\n const asked = pendingInputFromChunk(chunk);\n if (asked) {\n setThinking(stopThinking);\n setPendingInputs((prev) => mergePendingInputs(prev, [asked]));\n return;\n }\n const chatIdNow = chatIdRef.current || '';\n if (chunk.event === 'message') {\n const { text, thinking: thought } = parseMessageChunk(chunk.data);\n if (thought !== undefined) setThinking((prev) => applyThinking(prev, thought));\n if (text) {\n setThinking(stopThinking);\n setMessages((prev) => applyTextDelta(prev, text, chatIdNow));\n }\n } else if (chunk.event === 'tool_start') {\n setThinking(stopThinking);\n try {\n const parsed = JSON.parse(chunk.data);\n setToolStatus((prev) => [\n ...prev,\n { toolCallId: parsed.tool_call_id, name: parsed.name, description: parsed.description, status: 'running' },\n ]);\n setMessages((prev) => applyToolStart(prev, parsed, chatIdNow));\n } catch {\n // ignore malformed tool_start events\n }\n } else if (chunk.event === 'tool_end') {\n try {\n const parsed = JSON.parse(chunk.data);\n setToolStatus((prev) =>\n prev.map((t) => (t.toolCallId === parsed.tool_call_id ? { ...t, status: 'complete' } : t)),\n );\n setMessages((prev) => applyToolEnd(prev, parsed));\n } catch {\n // ignore malformed tool_end events\n }\n } else if (chunk.event === 'approval_required') {\n setThinking(stopThinking);\n try {\n const approval = parseApproval(JSON.parse(chunk.data));\n if (approval) setPendingApprovals((prev) => addApproval(prev, approval));\n } catch {\n // ignore malformed approval events\n }\n } else if (chunk.event === 'error') {\n setThinking(stopThinking);\n try {\n const parsed = JSON.parse(chunk.data);\n setError(parsed.error || 'Stream error');\n } catch {\n setError(chunk.data || 'Stream error');\n }\n }\n },\n [],\n );\n\n const streamCallbacks = React.useCallback(\n (id: string) =>\n [\n (_done: StreamDone) => {\n setStreaming(false);\n setToolStatus([]);\n setThinking(stopThinking);\n // Re-read the authoritative server state (and, after a suspended\n // turn, the questions it waits on).\n refresh(id);\n },\n (err: Error) => {\n setError(err.message);\n setStreaming(false);\n setToolStatus([]);\n setThinking(stopThinking);\n },\n ] as const,\n [refresh],\n );\n\n // Stream a channel (a resumed round after an approval or an answer).\n const followChannel = React.useCallback(\n (id: string, channelId: string, lastId?: string) => {\n abortRef.current?.abort();\n gate.next(); // a refresh still in flight is older than this stream\n setStreaming(true);\n setError(null);\n setThinking(NOT_THINKING);\n const [onDone, onError] = streamCallbacks(id);\n abortRef.current = streamFromChannel(client, id, channelId, handleStreamChunk, onDone, onError, {\n includeThinking,\n lastId,\n });\n },\n [client, gate, includeThinking, handleStreamChunk, streamCallbacks],\n );\n\n const send = React.useCallback(\n (content: MessageContent) => {\n const doSend = async () => {\n let activeChatId = chatIdRef.current;\n\n // Auto-create chat on first send\n if (!activeChatId) {\n setLoading(true);\n setError(null);\n try {\n const result = await createChat(client, agentRef, options?.input);\n activeChatId = result.id;\n setChatId(result.id);\n chatIdRef.current = result.id;\n } catch (e) {\n setError((e as Error).message);\n setLoading(false);\n return;\n }\n setLoading(false);\n }\n\n abortRef.current?.abort();\n gate.next(); // a refresh still in flight is older than this turn\n setStreaming(true);\n setError(null);\n setPendingApprovals([]);\n setToolStatus([]);\n setThinking(NOT_THINKING);\n\n // Add user message optimistically\n const displayContent = typeof content === 'string' ? content : JSON.stringify(content);\n const userMsg: ChatSessionMessage = {\n id: `tmp-user-${Date.now()}`,\n chatId: activeChatId,\n role: 'user',\n content: displayContent,\n toolCalls: null,\n toolCallId: null,\n name: null,\n createdAt: new Date().toISOString(),\n };\n setMessages((prev) => [...prev, userMsg]);\n\n const [onDone, onError] = streamCallbacks(activeChatId);\n abortRef.current = streamMessage(client, activeChatId, content, handleStreamChunk, onDone, onError, {\n includeThinking,\n });\n };\n\n doSend();\n },\n [client, agentRef, options?.input, gate, includeThinking, handleStreamChunk, streamCallbacks],\n );\n\n const decide = React.useCallback(\n (toolCallId: string, approved: boolean, alwaysAllow: boolean) => {\n const id = chatIdRef.current;\n if (!id) return;\n gate.next(); // a refresh in flight must not bring the card back\n setPendingApprovals((prev) => prev.filter((a) => a.toolCallId !== toolCallId));\n setError(null);\n\n (async () => {\n try {\n const result = await approveToolCall(client, id, toolCallId, approved, { alwaysAllow });\n // Until the round's last decision there is nothing to stream: the\n // remaining approvals stay pending.\n const channelId = approvalResumeChannel(result, approved);\n if (channelId) followChannel(id, channelId);\n else if (result.resume === undefined) refresh(id); // pre-0.5 rejection\n } catch (e) {\n setError((e as Error).message);\n // Show what is actually still pending (expired, already decided…)\n refresh(id);\n }\n })();\n },\n [client, gate, followChannel, refresh],\n );\n\n const approve = React.useCallback(\n (toolCallId: string, opts?: ApproveOptions) => decide(toolCallId, true, !!opts?.alwaysAllow),\n [decide],\n );\n\n const reject = React.useCallback(\n (toolCallId: string) => decide(toolCallId, false, false),\n [decide],\n );\n\n const answer = React.useCallback(\n async (toolCallId: string, text: string): Promise<boolean> => {\n const id = chatIdRef.current;\n if (!id) return false;\n setError(null);\n try {\n const result = await answerPendingInput(client, id, toolCallId, text);\n gate.next(); // a refresh in flight must not bring the question back\n setPendingInputs((prev) => prev.filter((p) => p.toolCallId !== toolCallId));\n // The last outstanding completion resumes the round on a fresh\n // channel; otherwise the round keeps waiting on the others.\n const channelId = answerResumeChannel(result);\n if (channelId) followChannel(id, channelId);\n return true;\n } catch (e) {\n setError((e as Error).message);\n refresh(id);\n return false;\n }\n },\n [client, gate, followChannel, refresh],\n );\n\n const follow = React.useCallback(\n (channelId: string, opts?: FollowOptions) => {\n const id = chatIdRef.current;\n if (!id) return;\n followChannel(id, channelId, opts?.lastId);\n },\n [followChannel],\n );\n\n const stop = React.useCallback(() => {\n abortRef.current?.abort();\n abortRef.current = null;\n setStreaming(false);\n setThinking(stopThinking);\n }, []);\n\n const clearError = React.useCallback(() => {\n setError(null);\n }, []);\n\n return {\n chatId,\n messages,\n loading,\n streaming,\n error,\n pendingApprovals,\n pendingInputs,\n thinking: thinkingShown,\n toolStatus,\n send,\n approve,\n reject,\n answer,\n follow,\n stop,\n clearError,\n };\n}\n","// useChat's state transitions as pure functions, so they can be tested\n// without React (tests/chat-state.test.mjs). The hook only wires them to\n// state.\nimport type { ApprovalRequest, PendingInput } from '../client/types';\nimport type { ChatSessionMessage, ChatThinking } from './useChat';\n\n/** What a `message` stream event carries: answer text and/or thinking. */\nexport interface MessageChunk {\n /** Answer text ('' when the event carries none, e.g. a typed event such as tool_rejected). */\n text: string;\n /** Thinking text: '' for \"the model started thinking\", undefined when not a thinking event. */\n thinking?: string;\n}\n\nexport function parseMessageChunk(data: string): MessageChunk {\n let parsed: unknown;\n try {\n parsed = JSON.parse(data);\n } catch {\n return { text: data };\n }\n if (!parsed || typeof parsed !== 'object') return { text: '' };\n const p = parsed as Record<string, unknown>;\n const out: MessageChunk = { text: typeof p.content === 'string' ? p.content : '' };\n if (typeof p.thinking === 'string') out.thinking = p.thinking;\n return out;\n}\n\n/** Appends streamed text to the assistant message being streamed, or starts one. */\nexport function applyTextDelta(\n messages: ChatSessionMessage[],\n text: string,\n chatId: string,\n now: Date = new Date(),\n): ChatSessionMessage[] {\n if (!text) return messages;\n const last = messages[messages.length - 1];\n if (last && last.role === 'assistant' && !last.toolCalls && last.streaming) {\n const next = [...messages];\n next[next.length - 1] = { ...last, content: (last.content || '') + text };\n return next;\n }\n return [\n ...messages,\n {\n id: `tmp-text-${now.getTime()}`,\n chatId,\n role: 'assistant',\n content: text,\n toolCalls: null,\n toolCallId: null,\n name: null,\n createdAt: now.toISOString(),\n streaming: true,\n },\n ];\n}\n\nexport interface ToolStartEvent {\n tool_call_id: string;\n name: string;\n arguments?: string;\n description?: string;\n}\n\n/** Shows a started tool call as its own bubble (once), freezing the text before it. */\nexport function applyToolStart(\n messages: ChatSessionMessage[],\n event: ToolStartEvent,\n chatId: string,\n now: Date = new Date(),\n): ChatSessionMessage[] {\n if (messages.some((m) => m.toolCalls?.some((tc) => tc.id === event.tool_call_id))) return messages;\n const frozen = messages.map((m, i) =>\n i === messages.length - 1 && m.streaming && m.role === 'assistant' && !m.toolCalls ? { ...m, streaming: false } : m,\n );\n return [\n ...frozen,\n {\n id: `tmp-tc-${event.tool_call_id}`,\n chatId,\n role: 'assistant',\n content: null,\n toolCalls: [\n {\n id: event.tool_call_id,\n type: 'function',\n function: { name: event.name, arguments: event.arguments || '{}' },\n description: event.description,\n },\n ],\n toolCallId: null,\n name: null,\n createdAt: now.toISOString(),\n streaming: true,\n },\n ];\n}\n\n/** Merges a finished tool call's result into its bubble. */\nexport function applyToolEnd(\n messages: ChatSessionMessage[],\n event: { tool_call_id: string; name: string; result?: unknown },\n): ChatSessionMessage[] {\n if (event.result === undefined) return messages;\n const content = typeof event.result === 'string' ? event.result : JSON.stringify(event.result);\n return messages.map((m) =>\n m.toolCalls?.some((tc) => tc.id === event.tool_call_id)\n ? { ...m, toolResults: { ...m.toolResults, [event.tool_call_id]: { content, name: event.name } } }\n : m,\n );\n}\n\n/** Adds an approval card unless that call already has one. */\nexport function addApproval(current: ApprovalRequest[], approval: ApprovalRequest): ApprovalRequest[] {\n return current.some((a) => a.toolCallId === approval.toolCallId) ? current : [...current, approval];\n}\n\n/** Adds questions not already listed (by tool call id), keeping order. */\nexport function mergePendingInputs(current: PendingInput[], incoming: PendingInput[]): PendingInput[] {\n const seen = new Set(current.map((p) => p.toolCallId));\n const added = incoming.filter((p) => !seen.has(p.toolCallId) && seen.add(p.toolCallId));\n return added.length ? [...current, ...added] : current;\n}\n\n/** The hook's thinking state: one entry per thinking round of the turn. */\nexport interface ThinkingRounds {\n active: boolean;\n rounds: string[];\n}\n\nexport const NOT_THINKING: ThinkingRounds = { active: false, rounds: [] };\n\n/**\n * A thinking chunk: the model is thinking. The first chunk after the answer\n * or a tool call started (often an empty \"started thinking\") opens a new\n * round.\n */\nexport function applyThinking(state: ThinkingRounds, thinking: string): ThinkingRounds {\n if (!state.active) return { active: true, rounds: [...state.rounds, thinking] };\n if (!thinking) return state;\n const rounds = [...state.rounds];\n rounds[rounds.length - 1] += thinking;\n return { active: true, rounds };\n}\n\n/** The answer, a tool call or the end of the stream: thinking has stopped. */\nexport function stopThinking(state: ThinkingRounds): ThinkingRounds {\n return state.active ? { ...state, active: false } : state;\n}\n\n/** What the hook returns: the rounds' text, separated by a blank line. */\nexport function thinkingView(state: ThinkingRounds): ChatThinking {\n return { active: state.active, text: state.rounds.filter((r) => r).join('\\n\\n') };\n}\n\n/**\n * Orders asynchronous refreshes: each one takes a ticket, and only the\n * newest ticket may write its result. A slow refresh from an earlier turn\n * then can't overwrite what a later turn (or a later refresh) showed.\n * Starting a turn also takes a ticket, voiding refreshes still in flight.\n */\nexport function createLatestGate() {\n let latest = 0;\n return {\n next: (): number => ++latest,\n isCurrent: (ticket: number): boolean => ticket === latest,\n };\n}\n\n/** Never wait longer than this between checks while a question is open. */\nexport const PENDING_POLL_MAX_MS = 30_000;\nconst PENDING_POLL_MIN_MS = 1_000;\n/** Checked this long after a deadline (the server's expiry sweep runs about once a minute). */\nconst EXPIRY_GRACE_MS = 5_000;\n/** Once a deadline has passed, how often to check until the sweep has run. */\nconst OVERDUE_POLL_MS = 10_000;\n\n/**\n * How long to wait before re-reading a chat that waits on ask_user\n * questions with no stream open. An unanswered question expires and the\n * round resumes server-side without the client being told; re-reading\n * every PENDING_POLL_MAX_MS, and just after the earliest deadline, shows\n * that (and an answer given elsewhere) without a reload.\n */\nexport function nextPendingPollMs(inputs: PendingInput[], nowMs: number): number {\n let wait = PENDING_POLL_MAX_MS;\n for (const input of inputs) {\n const deadline = input.expiresAt ? Date.parse(input.expiresAt) : NaN;\n if (Number.isNaN(deadline)) continue;\n const untilDue = deadline + EXPIRY_GRACE_MS - nowMs;\n wait = Math.min(wait, untilDue > 0 ? untilDue : OVERDUE_POLL_MS);\n }\n return Math.max(PENDING_POLL_MIN_MS, wait);\n}\n\n/**\n * After a question disappears without an answer from this hook (it expired,\n * or was answered elsewhere), the round resumes server-side: re-read the\n * chat at these delays to show the reply.\n */\nexport const TRAILING_POLLS_MS = [5_000, 15_000, 30_000];\n","import { useClient } from './context';\nimport { useQuery } from './useQuery';\nimport { useExecute } from './useExecute';\nimport { useStateStore } from './useStateStore';\nimport { useChat } from './useChat';\nimport type { SinasConfig } from '../client/types';\nimport type { SinasClient } from '../client/SinasClient';\n\nexport interface UseSinasResult {\n config: SinasConfig;\n input: Record<string, unknown>;\n client: SinasClient;\n useQuery: typeof useQuery;\n useExecute: typeof useExecute;\n useStateStore: typeof useStateStore;\n useChat: typeof useChat;\n}\n\nexport function useSinas(): UseSinasResult {\n const client = useClient();\n\n return {\n config: client.getConfig(),\n input: client.getInput(),\n client,\n useQuery,\n useExecute,\n useStateStore,\n useChat,\n };\n}\n","import React from 'react';\nimport { useClient } from './context';\nimport { SinasAuthError } from '../client/errors';\nimport type {\n AuthUser,\n InfoResponse,\n LoginResponse,\n OTPVerifyResponse,\n} from '../client/types';\n\nexport type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';\n\nexport interface UseAuthResult {\n status: AuthStatus;\n user: AuthUser | null;\n info: InfoResponse | null;\n error: string | null;\n\n /**\n * Refresh the session by calling /auth/me with the current access token.\n * Call this on app boot and after token changes.\n */\n refresh: () => Promise<void>;\n\n /**\n * Start a login. In password-only mode this completes the login and\n * returns access/refresh tokens. In OTP / password+OTP mode the response\n * carries a `session_id` to feed into `verifyOTP`.\n */\n login: (email: string, password?: string) => Promise<LoginResponse>;\n\n /** Second step for OTP / password+OTP. Returns the final tokens. */\n verifyOTP: (sessionId: string, otpCode: string) => Promise<OTPVerifyResponse>;\n\n /** Revoke the refresh token and clear local auth state. */\n logout: (refreshToken?: string) => Promise<void>;\n}\n\nexport interface UseAuthOptions {\n /** Refresh on mount. Default true. */\n autoRefresh?: boolean;\n}\n\n/**\n * React hook for the standalone Sinas login flow. The hosting app is\n * responsible for storing the tokens it receives (typically in localStorage)\n * and wiring `getAccessToken` / `getRefreshToken` / `onTokenRefresh` on the\n * SinasProvider so this hook can read the current session.\n */\nexport function useAuth(options: UseAuthOptions = {}): UseAuthResult {\n const { autoRefresh = true } = options;\n const client = useClient();\n\n const [status, setStatus] = React.useState<AuthStatus>('loading');\n const [user, setUser] = React.useState<AuthUser | null>(null);\n const [info, setInfo] = React.useState<InfoResponse | null>(null);\n const [error, setError] = React.useState<string | null>(null);\n\n const refresh = React.useCallback(async () => {\n setError(null);\n try {\n // Fetch /info in parallel with /me (info is unauthenticated and cheap).\n const [infoResp, meResp] = await Promise.all([\n client.auth.getInfo().catch(() => null),\n client.getAccessToken() ? client.auth.getMe().catch(() => null) : Promise.resolve(null),\n ]);\n if (infoResp) setInfo(infoResp);\n if (meResp) {\n setUser(meResp);\n setStatus('authenticated');\n } else {\n setUser(null);\n setStatus('unauthenticated');\n }\n } catch (e) {\n setError(e instanceof Error ? e.message : String(e));\n setStatus('unauthenticated');\n }\n }, [client]);\n\n React.useEffect(() => {\n if (autoRefresh) void refresh();\n }, [autoRefresh, refresh]);\n\n const login = React.useCallback(\n async (email: string, password?: string) => {\n setError(null);\n try {\n return await client.auth.login({ email, password });\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n setError(msg);\n throw e;\n }\n },\n [client],\n );\n\n const verifyOTP = React.useCallback(\n async (sessionId: string, otpCode: string) => {\n setError(null);\n try {\n return await client.auth.verifyOTP({ session_id: sessionId, otp_code: otpCode });\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n setError(msg);\n throw e;\n }\n },\n [client],\n );\n\n const logout = React.useCallback(\n async (refreshToken?: string) => {\n if (refreshToken) {\n try {\n await client.auth.logout(refreshToken);\n } catch (e) {\n if (!(e instanceof SinasAuthError)) throw e;\n }\n }\n setUser(null);\n setStatus('unauthenticated');\n },\n [client],\n );\n\n return { status, user, info, error, refresh, login, verifyOTP, logout };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAO,WAAW;AAGlB,IAAM,eAAe,MAAM,cAAkC,IAAI;AAU1D,SAAS,cAAc,EAAE,QAAQ,SAAS,SAAS,GAAuB;AAC/E,QAAM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AC,MAAM;AAAA,EACT;AAEA,QAAMI,UAASJ,OAAM;AAAA,IACnB,OAAO,iBAA0B;AAC/B,UAAI,cAAc;AAChB,YAAI;AACF,gBAAM,OAAO,KAAK,OAAO,YAAY;AAAA,QACvC,SAAS,GAAG;AACV,cAAI,EAAE,aAAa,gBAAiB,OAAM;AAAA,QAC5C;AAAA,MACF;AACA,cAAQ,IAAI;AACZ,gBAAU,iBAAiB;AAAA,IAC7B;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,SAAO,EAAE,QAAQ,MAAM,MAAM,OAAO,SAAAC,UAAS,OAAAC,QAAO,WAAAC,YAAW,QAAAC,QAAO;AACxE;","names":["React","React","React","React","React","React","React","React","refresh","React","React","refresh","login","verifyOTP","logout"]}