@sinas/sdk 0.1.0 → 0.2.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/{chunk-M7YHE5Y6.js → chunk-EV5ARSUJ.js} +101 -2
- package/dist/chunk-EV5ARSUJ.js.map +1 -0
- package/dist/client.cjs +104 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +89 -3
- package/dist/client.d.ts +89 -3
- package/dist/client.js +11 -1
- package/dist/index.cjs +301 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.js +208 -88
- package/dist/index.js.map +1 -1
- package/dist/sinas-sdk.umd.js +299 -2265
- package/dist/sinas-sdk.umd.js.map +1 -1
- package/package.json +7 -3
- package/dist/chunk-M7YHE5Y6.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -5,16 +5,21 @@ import {
|
|
|
5
5
|
SinasNotFoundError,
|
|
6
6
|
SinasPermissionError,
|
|
7
7
|
SinasTimeoutError,
|
|
8
|
+
approveToolCall,
|
|
8
9
|
createChat,
|
|
9
10
|
executeFunction,
|
|
10
11
|
executeQuery,
|
|
12
|
+
getChat,
|
|
13
|
+
listCollections,
|
|
14
|
+
listFiles,
|
|
11
15
|
sendMessage,
|
|
12
16
|
stateDelete,
|
|
13
17
|
stateGet,
|
|
14
18
|
stateList,
|
|
15
19
|
stateSet,
|
|
20
|
+
streamFromChannel,
|
|
16
21
|
streamMessage
|
|
17
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-EV5ARSUJ.js";
|
|
18
23
|
|
|
19
24
|
// src/hooks/useQuery.ts
|
|
20
25
|
import React2 from "react";
|
|
@@ -191,125 +196,235 @@ function useStateStore(ns, key) {
|
|
|
191
196
|
|
|
192
197
|
// src/hooks/useChat.ts
|
|
193
198
|
import React5 from "react";
|
|
194
|
-
function useChat(agentRef) {
|
|
199
|
+
function useChat(agentRef, options) {
|
|
195
200
|
const client = useClient();
|
|
196
|
-
const [chatId, setChatId] = React5.useState(null);
|
|
201
|
+
const [chatId, setChatId] = React5.useState(options?.chatId ?? null);
|
|
197
202
|
const [messages, setMessages] = React5.useState([]);
|
|
198
203
|
const [loading, setLoading] = React5.useState(false);
|
|
199
204
|
const [streaming, setStreaming] = React5.useState(false);
|
|
200
205
|
const [error, setError] = React5.useState(null);
|
|
206
|
+
const [pendingApprovals, setPendingApprovals] = React5.useState([]);
|
|
201
207
|
const abortRef = React5.useRef(null);
|
|
208
|
+
const chatIdRef = React5.useRef(chatId);
|
|
209
|
+
chatIdRef.current = chatId;
|
|
210
|
+
React5.useEffect(() => {
|
|
211
|
+
if (!options?.chatId) return;
|
|
212
|
+
let cancelled = false;
|
|
213
|
+
setLoading(true);
|
|
214
|
+
getChat(client, options.chatId).then((detail) => {
|
|
215
|
+
if (cancelled) return;
|
|
216
|
+
setChatId(detail.id);
|
|
217
|
+
setMessages(detail.messages);
|
|
218
|
+
}).catch((e) => {
|
|
219
|
+
if (cancelled) return;
|
|
220
|
+
setError(e.message);
|
|
221
|
+
}).finally(() => {
|
|
222
|
+
if (!cancelled) setLoading(false);
|
|
223
|
+
});
|
|
224
|
+
return () => {
|
|
225
|
+
cancelled = true;
|
|
226
|
+
};
|
|
227
|
+
}, [client, options?.chatId]);
|
|
202
228
|
React5.useEffect(() => {
|
|
203
229
|
return () => {
|
|
204
230
|
abortRef.current?.abort();
|
|
205
231
|
};
|
|
206
232
|
}, []);
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
233
|
+
const handleStreamChunks = React5.useCallback(
|
|
234
|
+
(assistantId) => (chunk) => {
|
|
235
|
+
if (chunk.event === "message") {
|
|
236
|
+
try {
|
|
237
|
+
const parsed = JSON.parse(chunk.data);
|
|
238
|
+
if (parsed.content) {
|
|
239
|
+
setMessages(
|
|
240
|
+
(prev) => prev.map(
|
|
241
|
+
(m) => m.id === assistantId ? { ...m, content: (m.content || "") + parsed.content } : m
|
|
242
|
+
)
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
} catch {
|
|
246
|
+
setMessages(
|
|
247
|
+
(prev) => prev.map(
|
|
248
|
+
(m) => m.id === assistantId ? { ...m, content: (m.content || "") + chunk.data } : m
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
} else if (chunk.event === "approval_required") {
|
|
253
|
+
try {
|
|
254
|
+
const parsed = JSON.parse(chunk.data);
|
|
255
|
+
setPendingApprovals((prev) => [...prev, parsed]);
|
|
256
|
+
} catch {
|
|
257
|
+
}
|
|
258
|
+
} else if (chunk.event === "error") {
|
|
259
|
+
try {
|
|
260
|
+
const parsed = JSON.parse(chunk.data);
|
|
261
|
+
setError(parsed.error || "Stream error");
|
|
262
|
+
} catch {
|
|
263
|
+
setError(chunk.data || "Stream error");
|
|
264
|
+
}
|
|
220
265
|
}
|
|
221
266
|
},
|
|
222
|
-
[
|
|
267
|
+
[]
|
|
223
268
|
);
|
|
224
|
-
const
|
|
225
|
-
async (
|
|
226
|
-
if (!chatId) {
|
|
227
|
-
setError("No active chat. Call createChat first.");
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
setLoading(true);
|
|
231
|
-
setError(null);
|
|
232
|
-
const userMsg = {
|
|
233
|
-
id: `tmp-${Date.now()}`,
|
|
234
|
-
chatId,
|
|
235
|
-
role: "user",
|
|
236
|
-
content,
|
|
237
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
238
|
-
};
|
|
239
|
-
setMessages((prev) => [...prev, userMsg]);
|
|
269
|
+
const refreshMessages = React5.useCallback(
|
|
270
|
+
async (id) => {
|
|
240
271
|
try {
|
|
241
|
-
const
|
|
242
|
-
setMessages(
|
|
243
|
-
|
|
244
|
-
} catch (e) {
|
|
245
|
-
setError(e.message);
|
|
246
|
-
} finally {
|
|
247
|
-
setLoading(false);
|
|
272
|
+
const detail = await getChat(client, id);
|
|
273
|
+
setMessages(detail.messages);
|
|
274
|
+
} catch {
|
|
248
275
|
}
|
|
249
276
|
},
|
|
250
|
-
[client
|
|
277
|
+
[client]
|
|
251
278
|
);
|
|
252
|
-
const
|
|
279
|
+
const send = React5.useCallback(
|
|
253
280
|
(content) => {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
281
|
+
const doSend = async () => {
|
|
282
|
+
let activeChatId = chatIdRef.current;
|
|
283
|
+
if (!activeChatId) {
|
|
284
|
+
setLoading(true);
|
|
285
|
+
setError(null);
|
|
286
|
+
try {
|
|
287
|
+
const result = await createChat(client, agentRef, options?.input);
|
|
288
|
+
activeChatId = result.id;
|
|
289
|
+
setChatId(result.id);
|
|
290
|
+
chatIdRef.current = result.id;
|
|
291
|
+
} catch (e) {
|
|
292
|
+
setError(e.message);
|
|
293
|
+
setLoading(false);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
setLoading(false);
|
|
297
|
+
}
|
|
298
|
+
abortRef.current?.abort();
|
|
299
|
+
setStreaming(true);
|
|
300
|
+
setError(null);
|
|
301
|
+
setPendingApprovals([]);
|
|
302
|
+
const displayContent = typeof content === "string" ? content : JSON.stringify(content);
|
|
303
|
+
const userMsg = {
|
|
304
|
+
id: `tmp-user-${Date.now()}`,
|
|
305
|
+
chatId: activeChatId,
|
|
306
|
+
role: "user",
|
|
307
|
+
content: displayContent,
|
|
308
|
+
toolCalls: null,
|
|
309
|
+
toolCallId: null,
|
|
310
|
+
name: null,
|
|
311
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
312
|
+
};
|
|
313
|
+
setMessages((prev) => [...prev, userMsg]);
|
|
314
|
+
const assistantId = `tmp-assistant-${Date.now()}`;
|
|
315
|
+
const assistantMsg = {
|
|
316
|
+
id: assistantId,
|
|
317
|
+
chatId: activeChatId,
|
|
318
|
+
role: "assistant",
|
|
319
|
+
content: "",
|
|
320
|
+
toolCalls: null,
|
|
321
|
+
toolCallId: null,
|
|
322
|
+
name: null,
|
|
323
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
324
|
+
streaming: true
|
|
325
|
+
};
|
|
326
|
+
setMessages((prev) => [...prev, assistantMsg]);
|
|
327
|
+
const controller = streamMessage(
|
|
328
|
+
client,
|
|
329
|
+
activeChatId,
|
|
330
|
+
content,
|
|
331
|
+
handleStreamChunks(assistantId),
|
|
332
|
+
() => {
|
|
333
|
+
setStreaming(false);
|
|
334
|
+
refreshMessages(activeChatId);
|
|
335
|
+
},
|
|
336
|
+
(err) => {
|
|
337
|
+
setError(err.message);
|
|
338
|
+
setStreaming(false);
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
abortRef.current = controller;
|
|
342
|
+
};
|
|
343
|
+
doSend();
|
|
344
|
+
},
|
|
345
|
+
[client, agentRef, options?.input, handleStreamChunks, refreshMessages]
|
|
346
|
+
);
|
|
347
|
+
const handleApproval = React5.useCallback(
|
|
348
|
+
(toolCallId, approved) => {
|
|
349
|
+
const currentChatId = chatIdRef.current;
|
|
350
|
+
if (!currentChatId) return;
|
|
351
|
+
setPendingApprovals((prev) => prev.filter((a) => a.toolCallId !== toolCallId));
|
|
259
352
|
setStreaming(true);
|
|
260
353
|
setError(null);
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (chunk.event === "content" || chunk.event === "message") {
|
|
284
|
-
setMessages(
|
|
285
|
-
(prev) => prev.map(
|
|
286
|
-
(m) => m.id === assistantId ? { ...m, content: m.content + chunk.data } : m
|
|
287
|
-
)
|
|
288
|
-
);
|
|
354
|
+
const assistantId = `tmp-resume-${Date.now()}`;
|
|
355
|
+
if (approved) {
|
|
356
|
+
const assistantMsg = {
|
|
357
|
+
id: assistantId,
|
|
358
|
+
chatId: currentChatId,
|
|
359
|
+
role: "assistant",
|
|
360
|
+
content: "",
|
|
361
|
+
toolCalls: null,
|
|
362
|
+
toolCallId: null,
|
|
363
|
+
name: null,
|
|
364
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
365
|
+
streaming: true
|
|
366
|
+
};
|
|
367
|
+
setMessages((prev) => [...prev, assistantMsg]);
|
|
368
|
+
}
|
|
369
|
+
(async () => {
|
|
370
|
+
try {
|
|
371
|
+
const result = await approveToolCall(client, currentChatId, toolCallId, approved);
|
|
372
|
+
if (!approved) {
|
|
373
|
+
setStreaming(false);
|
|
374
|
+
refreshMessages(currentChatId);
|
|
375
|
+
return;
|
|
289
376
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
377
|
+
const controller = streamFromChannel(
|
|
378
|
+
client,
|
|
379
|
+
currentChatId,
|
|
380
|
+
result.channelId,
|
|
381
|
+
handleStreamChunks(assistantId),
|
|
382
|
+
() => {
|
|
383
|
+
setStreaming(false);
|
|
384
|
+
refreshMessages(currentChatId);
|
|
385
|
+
},
|
|
386
|
+
(err) => {
|
|
387
|
+
setError(err.message);
|
|
388
|
+
setStreaming(false);
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
abortRef.current = controller;
|
|
392
|
+
} catch (e) {
|
|
393
|
+
setError(e.message);
|
|
296
394
|
setStreaming(false);
|
|
297
395
|
}
|
|
298
|
-
);
|
|
299
|
-
abortRef.current = controller;
|
|
300
|
-
return controller;
|
|
396
|
+
})();
|
|
301
397
|
},
|
|
302
|
-
[client,
|
|
398
|
+
[client, handleStreamChunks, refreshMessages]
|
|
399
|
+
);
|
|
400
|
+
const approve = React5.useCallback(
|
|
401
|
+
(toolCallId) => handleApproval(toolCallId, true),
|
|
402
|
+
[handleApproval]
|
|
403
|
+
);
|
|
404
|
+
const reject = React5.useCallback(
|
|
405
|
+
(toolCallId) => handleApproval(toolCallId, false),
|
|
406
|
+
[handleApproval]
|
|
303
407
|
);
|
|
408
|
+
const stop = React5.useCallback(() => {
|
|
409
|
+
abortRef.current?.abort();
|
|
410
|
+
abortRef.current = null;
|
|
411
|
+
setStreaming(false);
|
|
412
|
+
}, []);
|
|
413
|
+
const clearError = React5.useCallback(() => {
|
|
414
|
+
setError(null);
|
|
415
|
+
}, []);
|
|
304
416
|
return {
|
|
305
417
|
chatId,
|
|
306
418
|
messages,
|
|
307
419
|
loading,
|
|
308
420
|
streaming,
|
|
309
421
|
error,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
422
|
+
pendingApprovals,
|
|
423
|
+
send,
|
|
424
|
+
approve,
|
|
425
|
+
reject,
|
|
426
|
+
stop,
|
|
427
|
+
clearError
|
|
313
428
|
};
|
|
314
429
|
}
|
|
315
430
|
|
|
@@ -334,14 +449,19 @@ export {
|
|
|
334
449
|
SinasPermissionError,
|
|
335
450
|
SinasProvider,
|
|
336
451
|
SinasTimeoutError,
|
|
452
|
+
approveToolCall,
|
|
337
453
|
createChat,
|
|
338
454
|
executeFunction,
|
|
339
455
|
executeQuery,
|
|
456
|
+
getChat,
|
|
457
|
+
listCollections,
|
|
458
|
+
listFiles,
|
|
340
459
|
sendMessage,
|
|
341
460
|
stateDelete,
|
|
342
461
|
stateGet,
|
|
343
462
|
stateList,
|
|
344
463
|
stateSet,
|
|
464
|
+
streamFromChannel,
|
|
345
465
|
streamMessage,
|
|
346
466
|
useChat,
|
|
347
467
|
useExecute,
|
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"],"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 } from '../client/SinasClient';\n\nconst SinasContext = React.createContext<SinasClient | null>(null);\n\nexport interface SinasProviderProps {\n client?: SinasClient;\n children: React.ReactNode;\n}\n\nexport function SinasProvider({ client, children }: SinasProviderProps) {\n const value = React.useMemo(() => client || new SinasClient(), [client]);\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 // Fallback: create a default client using window globals\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, sendMessage, streamMessage } from '../client/chat';\nimport { useClient } from './context';\nimport type { ChatMessage, SSEChunk } from '../client/types';\n\nexport interface UseChatResult {\n chatId: string | null;\n messages: ChatMessage[];\n loading: boolean;\n streaming: boolean;\n error: string | null;\n createChat: (input?: Record<string, unknown>) => Promise<string | undefined>;\n sendMessage: (content: string) => Promise<ChatMessage | undefined>;\n streamMessage: (content: string) => AbortController | undefined;\n}\n\nexport function useChat(agentRef: string): UseChatResult {\n const client = useClient();\n\n const [chatId, setChatId] = React.useState<string | null>(null);\n const [messages, setMessages] = React.useState<ChatMessage[]>([]);\n const [loading, setLoading] = React.useState(false);\n const [streaming, setStreaming] = React.useState(false);\n const [error, setError] = React.useState<string | null>(null);\n\n const abortRef = React.useRef<AbortController | null>(null);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n abortRef.current?.abort();\n };\n }, []);\n\n const doCreateChat = React.useCallback(\n async (input?: Record<string, unknown>) => {\n setLoading(true);\n setError(null);\n try {\n const result = await createChat(client, agentRef, input);\n setChatId(result.id);\n setMessages([]);\n return result.id;\n } catch (e) {\n setError((e as Error).message);\n } finally {\n setLoading(false);\n }\n },\n [client, agentRef]\n );\n\n const doSendMessage = React.useCallback(\n async (content: string) => {\n if (!chatId) {\n setError('No active chat. Call createChat first.');\n return;\n }\n setLoading(true);\n setError(null);\n\n // Add user message optimistically\n const userMsg: ChatMessage = {\n id: `tmp-${Date.now()}`,\n chatId,\n role: 'user',\n content,\n createdAt: new Date().toISOString(),\n };\n setMessages(prev => [...prev, userMsg]);\n\n try {\n const msg = await sendMessage(client, chatId, content);\n setMessages(prev => [...prev, msg]);\n return msg;\n } catch (e) {\n setError((e as Error).message);\n } finally {\n setLoading(false);\n }\n },\n [client, chatId]\n );\n\n const doStreamMessage = React.useCallback(\n (content: string) => {\n if (!chatId) {\n setError('No active chat. Call createChat first.');\n return;\n }\n\n abortRef.current?.abort();\n setStreaming(true);\n setError(null);\n\n // Add user message optimistically\n const userMsg: ChatMessage = {\n id: `tmp-${Date.now()}`,\n chatId,\n role: 'user',\n content,\n createdAt: new Date().toISOString(),\n };\n setMessages(prev => [...prev, userMsg]);\n\n // Add empty assistant message to accumulate chunks\n const assistantId = `stream-${Date.now()}`;\n const assistantMsg: ChatMessage = {\n id: assistantId,\n chatId,\n role: 'assistant',\n content: '',\n createdAt: new Date().toISOString(),\n };\n setMessages(prev => [...prev, assistantMsg]);\n\n const controller = streamMessage(\n client,\n chatId,\n content,\n (chunk: SSEChunk) => {\n if (chunk.event === 'content' || chunk.event === 'message') {\n setMessages(prev =>\n prev.map(m =>\n m.id === assistantId ? { ...m, content: m.content + chunk.data } : m\n )\n );\n }\n },\n () => {\n setStreaming(false);\n },\n (err: Error) => {\n setError(err.message);\n setStreaming(false);\n }\n );\n\n abortRef.current = controller;\n return controller;\n },\n [client, chatId]\n );\n\n return {\n chatId,\n messages,\n loading,\n streaming,\n error,\n createChat: doCreateChat,\n sendMessage: doSendMessage,\n streamMessage: doStreamMessage,\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"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAO,WAAW;AAGlB,IAAM,eAAe,MAAM,cAAkC,IAAI;AAO1D,SAAS,cAAc,EAAE,QAAQ,SAAS,GAAuB;AACtE,QAAM,QAAQ,MAAM,QAAQ,MAAM,UAAU,IAAI,YAAY,GAAG,CAAC,MAAM,CAAC;AACvE,SAAO,MAAM,cAAc,aAAa,UAAU,EAAE,MAAM,GAAG,QAAQ;AACvE;AAEO,SAAS,YAAyB;AACvC,QAAM,SAAS,MAAM,WAAW,YAAY;AAC5C,MAAI,OAAQ,QAAO;AAEnB,SAAO;AACT;AAEA,IAAM,gBAAgB,IAAI,YAAY;;;ADJ/B,SAAS,SACd,KACA,QAAiC,CAAC,GAClC,UAA2B,CAAC,GACZ;AAChB,QAAM,SAAS,UAAU;AACzB,QAAM,EAAE,UAAU,MAAM,kBAAkB,KAAK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AAI,MAAM,UAAU,aAAa,MAAM,UAAU,WAAW;AAC1D;AAAA,cAAY,UACV,KAAK;AAAA,gBAAI,OACP,EAAE,OAAO,cAAc,EAAE,GAAG,GAAG,SAAS,EAAE,UAAU,MAAM,KAAK,IAAI;AAAA,cACrE;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,QACA,MAAM;AACJ,uBAAa,KAAK;AAAA,QACpB;AAAA,QACA,CAAC,QAAe;AACd,mBAAS,IAAI,OAAO;AACpB,uBAAa,KAAK;AAAA,QACpB;AAAA,MACF;AAEA,eAAS,UAAU;AACnB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,QAAQ,MAAM;AAAA,EACjB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,eAAe;AAAA,EACjB;AACF;;;ACxIO,SAAS,WAA2B;AACzC,QAAM,SAAS,UAAU;AAEzB,SAAO;AAAA,IACL,QAAQ,OAAO,UAAU;AAAA,IACzB,OAAO,OAAO,SAAS;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["React","React","React","React","React","React","React","React"]}
|
|
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"],"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 } from '../client/SinasClient';\n\nconst SinasContext = React.createContext<SinasClient | null>(null);\n\nexport interface SinasProviderProps {\n client?: SinasClient;\n children: React.ReactNode;\n}\n\nexport function SinasProvider({ client, children }: SinasProviderProps) {\n const value = React.useMemo(() => client || new SinasClient(), [client]);\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 // Fallback: create a default client using window globals\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 ChatSessionMessage extends ChatMessageFull {\n /** True while streaming content is being appended */\n streaming?: boolean;\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 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\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 })\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 (assistantId: string) => (chunk: SSEChunk) => {\n if (chunk.event === 'message') {\n try {\n const parsed = JSON.parse(chunk.data);\n if (parsed.content) {\n setMessages((prev) =>\n prev.map((m) =>\n m.id === assistantId\n ? { ...m, content: (m.content || '') + parsed.content }\n : m,\n ),\n );\n }\n } catch {\n // Non-JSON content chunk — append raw data\n setMessages((prev) =>\n prev.map((m) =>\n m.id === assistantId\n ? { ...m, content: (m.content || '') + chunk.data }\n : m,\n ),\n );\n }\n } else if (chunk.event === 'approval_required') {\n try {\n const parsed = JSON.parse(chunk.data) as ApprovalRequest;\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 } 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\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 // Add empty assistant message to accumulate streaming content\n const assistantId = `tmp-assistant-${Date.now()}`;\n const assistantMsg: ChatSessionMessage = {\n id: assistantId,\n chatId: activeChatId,\n role: 'assistant',\n content: '',\n toolCalls: null,\n toolCallId: null,\n name: null,\n createdAt: new Date().toISOString(),\n streaming: true,\n };\n setMessages((prev) => [...prev, assistantMsg]);\n\n const controller = streamMessage(\n client,\n activeChatId,\n content,\n handleStreamChunks(assistantId),\n () => {\n setStreaming(false);\n // Refresh to get authoritative server state (tool calls, tool responses)\n refreshMessages(activeChatId!);\n },\n (err: Error) => {\n setError(err.message);\n setStreaming(false);\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 // Add placeholder assistant message for the resumed stream\n const assistantId = `tmp-resume-${Date.now()}`;\n if (approved) {\n const assistantMsg: ChatSessionMessage = {\n id: assistantId,\n chatId: currentChatId,\n role: 'assistant',\n content: '',\n toolCalls: null,\n toolCallId: null,\n name: null,\n createdAt: new Date().toISOString(),\n streaming: true,\n };\n setMessages((prev) => [...prev, assistantMsg]);\n }\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(assistantId),\n () => {\n setStreaming(false);\n refreshMessages(currentChatId);\n },\n (err: Error) => {\n setError(err.message);\n setStreaming(false);\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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAO,WAAW;AAGlB,IAAM,eAAe,MAAM,cAAkC,IAAI;AAO1D,SAAS,cAAc,EAAE,QAAQ,SAAS,GAAuB;AACtE,QAAM,QAAQ,MAAM,QAAQ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AAAA,IACA;AAAA,EACF;AACF;;;AChSO,SAAS,WAA2B;AACzC,QAAM,SAAS,UAAU;AAEzB,SAAO;AAAA,IACL,QAAQ,OAAO,UAAU;AAAA,IACzB,OAAO,OAAO,SAAS;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["React","React","React","React","React","React","React","React"]}
|