@sinas/sdk 0.1.1 → 0.2.1
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 +384 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +291 -88
- package/dist/index.js.map +1 -1
- package/dist/sinas-sdk.umd.js +379 -87
- package/dist/sinas-sdk.umd.js.map +1 -1
- package/package.json +7 -2
- 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,318 @@ 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([]);
|
|
207
|
+
const [toolStatus, setToolStatus] = React5.useState([]);
|
|
201
208
|
const abortRef = React5.useRef(null);
|
|
209
|
+
const chatIdRef = React5.useRef(chatId);
|
|
210
|
+
chatIdRef.current = chatId;
|
|
211
|
+
const activeAssistantIdRef = React5.useRef("");
|
|
212
|
+
React5.useEffect(() => {
|
|
213
|
+
if (!options?.chatId) return;
|
|
214
|
+
let cancelled = false;
|
|
215
|
+
setLoading(true);
|
|
216
|
+
getChat(client, options.chatId).then((detail) => {
|
|
217
|
+
if (cancelled) return;
|
|
218
|
+
setChatId(detail.id);
|
|
219
|
+
setMessages(detail.messages);
|
|
220
|
+
}).catch((e) => {
|
|
221
|
+
if (cancelled) return;
|
|
222
|
+
setError(e.message);
|
|
223
|
+
}).finally(() => {
|
|
224
|
+
if (!cancelled) setLoading(false);
|
|
225
|
+
});
|
|
226
|
+
return () => {
|
|
227
|
+
cancelled = true;
|
|
228
|
+
};
|
|
229
|
+
}, [client, options?.chatId]);
|
|
202
230
|
React5.useEffect(() => {
|
|
203
231
|
return () => {
|
|
204
232
|
abortRef.current?.abort();
|
|
205
233
|
};
|
|
206
234
|
}, []);
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
235
|
+
const handleStreamChunks = React5.useCallback(
|
|
236
|
+
(chunk) => {
|
|
237
|
+
if (chunk.event === "message") {
|
|
238
|
+
try {
|
|
239
|
+
const parsed = JSON.parse(chunk.data);
|
|
240
|
+
if (parsed.content) {
|
|
241
|
+
const targetId = activeAssistantIdRef.current;
|
|
242
|
+
setMessages(
|
|
243
|
+
(prev) => prev.map(
|
|
244
|
+
(m) => m.id === targetId ? { ...m, content: (m.content || "") + parsed.content } : m
|
|
245
|
+
)
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
} catch {
|
|
249
|
+
const targetId = activeAssistantIdRef.current;
|
|
250
|
+
setMessages(
|
|
251
|
+
(prev) => prev.map(
|
|
252
|
+
(m) => m.id === targetId ? { ...m, content: (m.content || "") + chunk.data } : m
|
|
253
|
+
)
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
} else if (chunk.event === "tool_start") {
|
|
257
|
+
try {
|
|
258
|
+
const parsed = JSON.parse(chunk.data);
|
|
259
|
+
setToolStatus((prev) => [
|
|
260
|
+
...prev,
|
|
261
|
+
{ toolCallId: parsed.tool_call_id, name: parsed.name, description: parsed.description, status: "running" }
|
|
262
|
+
]);
|
|
263
|
+
const placeholderId = activeAssistantIdRef.current;
|
|
264
|
+
const toolCallMsg = {
|
|
265
|
+
id: `tmp-tc-${parsed.tool_call_id}`,
|
|
266
|
+
chatId: chatIdRef.current || "",
|
|
267
|
+
role: "assistant",
|
|
268
|
+
content: null,
|
|
269
|
+
toolCalls: [{
|
|
270
|
+
id: parsed.tool_call_id,
|
|
271
|
+
type: "function",
|
|
272
|
+
function: { name: parsed.name, arguments: parsed.arguments || "{}" }
|
|
273
|
+
}],
|
|
274
|
+
toolCallId: null,
|
|
275
|
+
name: null,
|
|
276
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
277
|
+
};
|
|
278
|
+
setMessages((prev) => {
|
|
279
|
+
const filtered = prev.filter(
|
|
280
|
+
(m) => !(m.id === placeholderId && m.streaming && !m.content)
|
|
281
|
+
);
|
|
282
|
+
return [...filtered, toolCallMsg];
|
|
283
|
+
});
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
} else if (chunk.event === "tool_end") {
|
|
287
|
+
try {
|
|
288
|
+
const parsed = JSON.parse(chunk.data);
|
|
289
|
+
setToolStatus(
|
|
290
|
+
(prev) => prev.map((t) => t.toolCallId === parsed.tool_call_id ? { ...t, status: "complete" } : t)
|
|
291
|
+
);
|
|
292
|
+
if (parsed.result !== void 0) {
|
|
293
|
+
const toolResultMsg = {
|
|
294
|
+
id: `tmp-tr-${parsed.tool_call_id}`,
|
|
295
|
+
chatId: chatIdRef.current || "",
|
|
296
|
+
role: "tool",
|
|
297
|
+
content: typeof parsed.result === "string" ? parsed.result : JSON.stringify(parsed.result),
|
|
298
|
+
toolCalls: null,
|
|
299
|
+
toolCallId: parsed.tool_call_id,
|
|
300
|
+
name: parsed.name,
|
|
301
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
302
|
+
};
|
|
303
|
+
setMessages((prev) => [...prev, toolResultMsg]);
|
|
304
|
+
}
|
|
305
|
+
setToolStatus((currentStatus) => {
|
|
306
|
+
const stillRunning = currentStatus.filter((t) => t.status === "running");
|
|
307
|
+
if (stillRunning.length === 0) {
|
|
308
|
+
const newAssistantId = `tmp-assistant-${Date.now()}`;
|
|
309
|
+
activeAssistantIdRef.current = newAssistantId;
|
|
310
|
+
const newMsg = {
|
|
311
|
+
id: newAssistantId,
|
|
312
|
+
chatId: chatIdRef.current || "",
|
|
313
|
+
role: "assistant",
|
|
314
|
+
content: "",
|
|
315
|
+
toolCalls: null,
|
|
316
|
+
toolCallId: null,
|
|
317
|
+
name: null,
|
|
318
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
319
|
+
streaming: true
|
|
320
|
+
};
|
|
321
|
+
setMessages((prev) => [...prev, newMsg]);
|
|
322
|
+
}
|
|
323
|
+
return currentStatus;
|
|
324
|
+
});
|
|
325
|
+
} catch {
|
|
326
|
+
}
|
|
327
|
+
} else if (chunk.event === "approval_required") {
|
|
328
|
+
try {
|
|
329
|
+
const parsed = JSON.parse(chunk.data);
|
|
330
|
+
setPendingApprovals((prev) => [...prev, parsed]);
|
|
331
|
+
} catch {
|
|
332
|
+
}
|
|
333
|
+
} else if (chunk.event === "error") {
|
|
334
|
+
try {
|
|
335
|
+
const parsed = JSON.parse(chunk.data);
|
|
336
|
+
setError(parsed.error || "Stream error");
|
|
337
|
+
} catch {
|
|
338
|
+
setError(chunk.data || "Stream error");
|
|
339
|
+
}
|
|
220
340
|
}
|
|
221
341
|
},
|
|
222
|
-
[
|
|
342
|
+
[]
|
|
223
343
|
);
|
|
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]);
|
|
344
|
+
const refreshMessages = React5.useCallback(
|
|
345
|
+
async (id) => {
|
|
240
346
|
try {
|
|
241
|
-
const
|
|
242
|
-
setMessages(
|
|
243
|
-
|
|
244
|
-
} catch (e) {
|
|
245
|
-
setError(e.message);
|
|
246
|
-
} finally {
|
|
247
|
-
setLoading(false);
|
|
347
|
+
const detail = await getChat(client, id);
|
|
348
|
+
setMessages(detail.messages);
|
|
349
|
+
} catch {
|
|
248
350
|
}
|
|
249
351
|
},
|
|
250
|
-
[client
|
|
352
|
+
[client]
|
|
251
353
|
);
|
|
252
|
-
const
|
|
354
|
+
const send = React5.useCallback(
|
|
253
355
|
(content) => {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
356
|
+
const doSend = async () => {
|
|
357
|
+
let activeChatId = chatIdRef.current;
|
|
358
|
+
if (!activeChatId) {
|
|
359
|
+
setLoading(true);
|
|
360
|
+
setError(null);
|
|
361
|
+
try {
|
|
362
|
+
const result = await createChat(client, agentRef, options?.input);
|
|
363
|
+
activeChatId = result.id;
|
|
364
|
+
setChatId(result.id);
|
|
365
|
+
chatIdRef.current = result.id;
|
|
366
|
+
} catch (e) {
|
|
367
|
+
setError(e.message);
|
|
368
|
+
setLoading(false);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
setLoading(false);
|
|
372
|
+
}
|
|
373
|
+
abortRef.current?.abort();
|
|
374
|
+
setStreaming(true);
|
|
375
|
+
setError(null);
|
|
376
|
+
setPendingApprovals([]);
|
|
377
|
+
setToolStatus([]);
|
|
378
|
+
const displayContent = typeof content === "string" ? content : JSON.stringify(content);
|
|
379
|
+
const userMsg = {
|
|
380
|
+
id: `tmp-user-${Date.now()}`,
|
|
381
|
+
chatId: activeChatId,
|
|
382
|
+
role: "user",
|
|
383
|
+
content: displayContent,
|
|
384
|
+
toolCalls: null,
|
|
385
|
+
toolCallId: null,
|
|
386
|
+
name: null,
|
|
387
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
388
|
+
};
|
|
389
|
+
setMessages((prev) => [...prev, userMsg]);
|
|
390
|
+
const assistantId = `tmp-assistant-${Date.now()}`;
|
|
391
|
+
activeAssistantIdRef.current = assistantId;
|
|
392
|
+
const assistantMsg = {
|
|
393
|
+
id: assistantId,
|
|
394
|
+
chatId: activeChatId,
|
|
395
|
+
role: "assistant",
|
|
396
|
+
content: "",
|
|
397
|
+
toolCalls: null,
|
|
398
|
+
toolCallId: null,
|
|
399
|
+
name: null,
|
|
400
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
401
|
+
streaming: true
|
|
402
|
+
};
|
|
403
|
+
setMessages((prev) => [...prev, assistantMsg]);
|
|
404
|
+
const controller = streamMessage(
|
|
405
|
+
client,
|
|
406
|
+
activeChatId,
|
|
407
|
+
content,
|
|
408
|
+
handleStreamChunks,
|
|
409
|
+
() => {
|
|
410
|
+
setStreaming(false);
|
|
411
|
+
setToolStatus([]);
|
|
412
|
+
refreshMessages(activeChatId);
|
|
413
|
+
},
|
|
414
|
+
(err) => {
|
|
415
|
+
setError(err.message);
|
|
416
|
+
setStreaming(false);
|
|
417
|
+
setToolStatus([]);
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
abortRef.current = controller;
|
|
421
|
+
};
|
|
422
|
+
doSend();
|
|
423
|
+
},
|
|
424
|
+
[client, agentRef, options?.input, handleStreamChunks, refreshMessages]
|
|
425
|
+
);
|
|
426
|
+
const handleApproval = React5.useCallback(
|
|
427
|
+
(toolCallId, approved) => {
|
|
428
|
+
const currentChatId = chatIdRef.current;
|
|
429
|
+
if (!currentChatId) return;
|
|
430
|
+
setPendingApprovals((prev) => prev.filter((a) => a.toolCallId !== toolCallId));
|
|
259
431
|
setStreaming(true);
|
|
260
432
|
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
|
-
|
|
284
|
-
setMessages(
|
|
285
|
-
(prev) => prev.map(
|
|
286
|
-
(m) => m.id === assistantId ? { ...m, content: m.content + chunk.data } : m
|
|
287
|
-
)
|
|
288
|
-
);
|
|
433
|
+
const assistantId = `tmp-resume-${Date.now()}`;
|
|
434
|
+
activeAssistantIdRef.current = assistantId;
|
|
435
|
+
if (approved) {
|
|
436
|
+
const assistantMsg = {
|
|
437
|
+
id: assistantId,
|
|
438
|
+
chatId: currentChatId,
|
|
439
|
+
role: "assistant",
|
|
440
|
+
content: "",
|
|
441
|
+
toolCalls: null,
|
|
442
|
+
toolCallId: null,
|
|
443
|
+
name: null,
|
|
444
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
445
|
+
streaming: true
|
|
446
|
+
};
|
|
447
|
+
setMessages((prev) => [...prev, assistantMsg]);
|
|
448
|
+
}
|
|
449
|
+
(async () => {
|
|
450
|
+
try {
|
|
451
|
+
const result = await approveToolCall(client, currentChatId, toolCallId, approved);
|
|
452
|
+
if (!approved) {
|
|
453
|
+
setStreaming(false);
|
|
454
|
+
refreshMessages(currentChatId);
|
|
455
|
+
return;
|
|
289
456
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
457
|
+
const controller = streamFromChannel(
|
|
458
|
+
client,
|
|
459
|
+
currentChatId,
|
|
460
|
+
result.channelId,
|
|
461
|
+
handleStreamChunks,
|
|
462
|
+
() => {
|
|
463
|
+
setStreaming(false);
|
|
464
|
+
setToolStatus([]);
|
|
465
|
+
refreshMessages(currentChatId);
|
|
466
|
+
},
|
|
467
|
+
(err) => {
|
|
468
|
+
setError(err.message);
|
|
469
|
+
setStreaming(false);
|
|
470
|
+
setToolStatus([]);
|
|
471
|
+
}
|
|
472
|
+
);
|
|
473
|
+
abortRef.current = controller;
|
|
474
|
+
} catch (e) {
|
|
475
|
+
setError(e.message);
|
|
296
476
|
setStreaming(false);
|
|
297
477
|
}
|
|
298
|
-
);
|
|
299
|
-
abortRef.current = controller;
|
|
300
|
-
return controller;
|
|
478
|
+
})();
|
|
301
479
|
},
|
|
302
|
-
[client,
|
|
480
|
+
[client, handleStreamChunks, refreshMessages]
|
|
481
|
+
);
|
|
482
|
+
const approve = React5.useCallback(
|
|
483
|
+
(toolCallId) => handleApproval(toolCallId, true),
|
|
484
|
+
[handleApproval]
|
|
485
|
+
);
|
|
486
|
+
const reject = React5.useCallback(
|
|
487
|
+
(toolCallId) => handleApproval(toolCallId, false),
|
|
488
|
+
[handleApproval]
|
|
303
489
|
);
|
|
490
|
+
const stop = React5.useCallback(() => {
|
|
491
|
+
abortRef.current?.abort();
|
|
492
|
+
abortRef.current = null;
|
|
493
|
+
setStreaming(false);
|
|
494
|
+
}, []);
|
|
495
|
+
const clearError = React5.useCallback(() => {
|
|
496
|
+
setError(null);
|
|
497
|
+
}, []);
|
|
304
498
|
return {
|
|
305
499
|
chatId,
|
|
306
500
|
messages,
|
|
307
501
|
loading,
|
|
308
502
|
streaming,
|
|
309
503
|
error,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
504
|
+
pendingApprovals,
|
|
505
|
+
toolStatus,
|
|
506
|
+
send,
|
|
507
|
+
approve,
|
|
508
|
+
reject,
|
|
509
|
+
stop,
|
|
510
|
+
clearError
|
|
313
511
|
};
|
|
314
512
|
}
|
|
315
513
|
|
|
@@ -334,14 +532,19 @@ export {
|
|
|
334
532
|
SinasPermissionError,
|
|
335
533
|
SinasProvider,
|
|
336
534
|
SinasTimeoutError,
|
|
535
|
+
approveToolCall,
|
|
337
536
|
createChat,
|
|
338
537
|
executeFunction,
|
|
339
538
|
executeQuery,
|
|
539
|
+
getChat,
|
|
540
|
+
listCollections,
|
|
541
|
+
listFiles,
|
|
340
542
|
sendMessage,
|
|
341
543
|
stateDelete,
|
|
342
544
|
stateGet,
|
|
343
545
|
stateList,
|
|
344
546
|
stateSet,
|
|
547
|
+
streamFromChannel,
|
|
345
548
|
streamMessage,
|
|
346
549
|
useChat,
|
|
347
550
|
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,IAAI;AAEnD,QAAM,CAAC,MAAM,OAAO,IAAIC,OAAM,SAA2C,IAAI;AAC7E,QAAM,CAAC,SAAS,UAAU,IAAIA,OAAM,SAAS,KAAK;AAClD,QAAM,CAAC,OAAO,QAAQ,IAAIA,OAAM,SAAwB,IAAI;AAC5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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 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 const activeAssistantIdRef = React.useRef<string>('');\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 (chunk: SSEChunk) => {\n if (chunk.event === 'message') {\n try {\n const parsed = JSON.parse(chunk.data);\n if (parsed.content) {\n const targetId = activeAssistantIdRef.current;\n setMessages((prev) =>\n prev.map((m) =>\n m.id === targetId\n ? { ...m, content: (m.content || '') + parsed.content }\n : m,\n ),\n );\n }\n } catch {\n // Non-JSON content chunk — append raw data\n const targetId = activeAssistantIdRef.current;\n setMessages((prev) =>\n prev.map((m) =>\n m.id === targetId\n ? { ...m, content: (m.content || '') + chunk.data }\n : m,\n ),\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 // Remove the empty streaming placeholder and inject tool call message\n const placeholderId = activeAssistantIdRef.current;\n const toolCallMsg: ChatSessionMessage = {\n id: `tmp-tc-${parsed.tool_call_id}`,\n chatId: chatIdRef.current || '',\n role: 'assistant',\n content: null,\n toolCalls: [{\n id: parsed.tool_call_id,\n type: 'function',\n function: { name: parsed.name, arguments: parsed.arguments || '{}' },\n }],\n toolCallId: null,\n name: null,\n createdAt: new Date().toISOString(),\n };\n setMessages((prev) => {\n // Remove empty placeholder (no content accumulated yet)\n const filtered = prev.filter((m) =>\n !(m.id === placeholderId && m.streaming && !m.content),\n );\n return [...filtered, toolCallMsg];\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 // Inject tool result message into messages\n if (parsed.result !== undefined) {\n const toolResultMsg: ChatSessionMessage = {\n id: `tmp-tr-${parsed.tool_call_id}`,\n chatId: chatIdRef.current || '',\n role: 'tool',\n content: typeof parsed.result === 'string' ? parsed.result : JSON.stringify(parsed.result),\n toolCalls: null,\n toolCallId: parsed.tool_call_id,\n name: parsed.name,\n createdAt: new Date().toISOString(),\n };\n setMessages((prev) => [...prev, toolResultMsg]);\n }\n // Create new assistant message for follow-up LLM content after tool execution\n setToolStatus((currentStatus) => {\n const stillRunning = currentStatus.filter((t) => t.status === 'running');\n if (stillRunning.length === 0) {\n const newAssistantId = `tmp-assistant-${Date.now()}`;\n activeAssistantIdRef.current = newAssistantId;\n const newMsg: ChatSessionMessage = {\n id: newAssistantId,\n chatId: chatIdRef.current || '',\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, newMsg]);\n }\n return currentStatus;\n });\n } catch {\n // ignore malformed tool_end events\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 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 // Add empty assistant message to accumulate streaming content\n const assistantId = `tmp-assistant-${Date.now()}`;\n activeAssistantIdRef.current = assistantId;\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,\n () => {\n setStreaming(false);\n setToolStatus([]);\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 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 // Add placeholder assistant message for the resumed stream\n const assistantId = `tmp-resume-${Date.now()}`;\n activeAssistantIdRef.current = assistantId;\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,\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 use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AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACjYO,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"]}
|