bs-agent 0.0.24 → 0.0.25

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.
@@ -372,23 +372,17 @@ function buildStreamCallbacks(deps, debugKey) {
372
372
  return {
373
373
  onComplete: () => {
374
374
  console.log("Agent closed");
375
- setMessages((current) => {
376
- if (syncSessionRef.current) {
377
- syncSessionRef.current(current);
378
- }
379
- return current;
380
- });
381
375
  setInProgress(false);
376
+ if (syncSessionRef.current) {
377
+ syncSessionRef.current(messagesRef.current);
378
+ }
382
379
  },
383
380
  onError: (error) => {
384
381
  console.log("Agent error", error);
385
- setMessages((current) => {
386
- if (syncSessionRef.current) {
387
- syncSessionRef.current(current);
388
- }
389
- return current;
390
- });
391
382
  setInProgress(false);
383
+ if (syncSessionRef.current) {
384
+ syncSessionRef.current(messagesRef.current);
385
+ }
392
386
  },
393
387
  onEvent: (event) => {
394
388
  if (event.type === "text_delta") {
@@ -515,25 +509,7 @@ function handleTextDelta(event, setMessages, syncSessionRef, modifier, fullTextM
515
509
  }
516
510
  function handleClientToolCall(event, setMessages, syncSessionRef, toolContext, agentId) {
517
511
  const tool = toolContext?.getTool(agentId, event.data.toolName);
518
- console.log(
519
- "[DEBUG] handleClientToolCall:",
520
- event.data.toolName,
521
- "paused:",
522
- event.data.paused,
523
- "toolFound:",
524
- !!tool,
525
- "hasRender:",
526
- !!tool?.render
527
- );
528
- if (!tool?.render && !event.data.paused) {
529
- console.log("[DEBUG] handleClientToolCall: SKIPPING part creation \u2014 not paused and no render");
530
- return;
531
- }
532
- console.log(
533
- "[DEBUG] handleClientToolCall: CREATING widget part for",
534
- event.data.toolName,
535
- event.data.callId
536
- );
512
+ if (!tool?.render && !event.data.paused) return;
537
513
  setMessages((prev) => {
538
514
  const lastMessage = prev[prev.length - 1];
539
515
  const newPart = {
@@ -821,34 +797,19 @@ function useAgent(agent, options) {
821
797
  sessionUtils.syncSessionRef.current(messagesRef.current);
822
798
  }
823
799
  }, [sessionUtils.syncSessionRef]);
824
- return (0, import_react3.useMemo)(
825
- () => ({
826
- inProgress,
827
- messages,
828
- handleSend,
829
- resumeTool,
830
- addOptimisticMessage,
831
- abort,
832
- sessionId: currentSessionId,
833
- switchSession: sessionUtils.switchSession,
834
- deleteSession: sessionUtils.deleteSession,
835
- sessions: sessionUtils.sessionsList,
836
- debugData
837
- }),
838
- [
839
- inProgress,
840
- messages,
841
- handleSend,
842
- resumeTool,
843
- addOptimisticMessage,
844
- abort,
845
- currentSessionId,
846
- sessionUtils.switchSession,
847
- sessionUtils.deleteSession,
848
- sessionUtils.sessionsList,
849
- debugData
850
- ]
851
- );
800
+ return {
801
+ inProgress,
802
+ messages,
803
+ handleSend,
804
+ resumeTool,
805
+ addOptimisticMessage,
806
+ abort,
807
+ sessionId: currentSessionId,
808
+ switchSession: sessionUtils.switchSession,
809
+ deleteSession: sessionUtils.deleteSession,
810
+ sessions: sessionUtils.sessionsList,
811
+ debugData
812
+ };
852
813
  }
853
814
 
854
815
  // src/core/stream.ts
@@ -1667,19 +1628,6 @@ function ToolRenderer({ agentId, part }) {
1667
1628
  throw new Error("ToolRenderer must be used within <AgentContextProvider>");
1668
1629
  }
1669
1630
  const tool = context.getTool(agentId, part.toolName);
1670
- console.log(
1671
- "[DEBUG] ToolRenderer:",
1672
- part.toolName,
1673
- part.callId,
1674
- "toolFound:",
1675
- !!tool,
1676
- "hasRender:",
1677
- !!tool?.render,
1678
- "paused:",
1679
- part.paused,
1680
- "status:",
1681
- localStatus
1682
- );
1683
1631
  const handleSubmit = (0, import_react6.useCallback)(
1684
1632
  (result) => {
1685
1633
  if (localStatus === "submitted") return;