reasonix 0.4.12 → 0.4.13

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/cli/index.js CHANGED
@@ -1610,6 +1610,15 @@ var CacheFirstLoop = class {
1610
1610
  if (d.argumentsDelta)
1611
1611
  cur.function.arguments = (cur.function.arguments ?? "") + d.argumentsDelta;
1612
1612
  callBuf.set(d.index, cur);
1613
+ if (cur.function.name) {
1614
+ yield {
1615
+ turn: this._turn,
1616
+ role: "tool_call_delta",
1617
+ content: "",
1618
+ toolName: cur.function.name,
1619
+ toolCallArgsChars: (cur.function.arguments ?? "").length
1620
+ };
1621
+ }
1613
1622
  }
1614
1623
  if (chunk.usage) usage = chunk.usage;
1615
1624
  }
@@ -3910,8 +3919,10 @@ function StreamingAssistant({ event }) {
3910
3919
  }
3911
3920
  const tail = lastLine(event.text, 140);
3912
3921
  const reasoningTail = event.reasoning ? lastLine(event.reasoning, 120) : "";
3913
- const preFirstByte = !event.text && !event.reasoning;
3914
- const reasoningOnly = !event.text && !!event.reasoning;
3922
+ const toolCallBuild = event.toolCallBuild;
3923
+ const preFirstByte = !event.text && !event.reasoning && !toolCallBuild;
3924
+ const reasoningOnly = !event.text && !!event.reasoning && !toolCallBuild;
3925
+ const toolCallOnly = !event.text && !event.reasoning && !!toolCallBuild;
3915
3926
  let label;
3916
3927
  let labelColor;
3917
3928
  if (preFirstByte) {
@@ -3920,8 +3931,16 @@ function StreamingAssistant({ event }) {
3920
3931
  } else if (reasoningOnly) {
3921
3932
  label = `R1 reasoning \xB7 ${event.reasoning?.length ?? 0} chars of thought`;
3922
3933
  labelColor = "cyan";
3934
+ } else if (toolCallOnly) {
3935
+ label = `assembling tool call <${toolCallBuild.name}> \xB7 ${toolCallBuild.chars} chars of arguments`;
3936
+ labelColor = "magenta";
3923
3937
  } else {
3924
- label = event.reasoning ? `writing response \xB7 ${event.text.length} chars \xB7 after ${event.reasoning.length} chars of reasoning` : `writing response \xB7 ${event.text.length} chars`;
3938
+ const parts = [`writing response \xB7 ${event.text.length} chars`];
3939
+ if (event.reasoning) parts.push(`after ${event.reasoning.length} chars of reasoning`);
3940
+ if (toolCallBuild) {
3941
+ parts.push(`building tool call <${toolCallBuild.name}> \xB7 ${toolCallBuild.chars} chars`);
3942
+ }
3943
+ label = parts.join(" \xB7 ");
3925
3944
  labelColor = "green";
3926
3945
  }
3927
3946
  return /* @__PURE__ */ React3.createElement(Box3, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React3.createElement(Box3, null, /* @__PURE__ */ React3.createElement(Text3, { bold: true, color: "green" }, "assistant", " "), /* @__PURE__ */ React3.createElement(Pulse, null), /* @__PURE__ */ React3.createElement(Text3, { color: labelColor }, ` ${label} `), /* @__PURE__ */ React3.createElement(Elapsed, null)), reasoningTail ? /* @__PURE__ */ React3.createElement(Text3, { dimColor: true, italic: true }, "\u21B3 thinking: ", reasoningTail) : null, tail ? /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "\u25B8 ", tail) : reasoningOnly ? /* @__PURE__ */ React3.createElement(Text3, { color: "yellow", dimColor: true }, " R1 is thinking before it speaks \u2014 body text starts when reasoning completes (typically 20-90s).") : /* @__PURE__ */ React3.createElement(Text3, { dimColor: true, italic: true }, " connection open, first byte typically in 5-60s depending on model + load"));
@@ -4565,6 +4584,7 @@ function App({
4565
4584
  const pendingEdits = useRef([]);
4566
4585
  const promptHistory = useRef([]);
4567
4586
  const historyCursor = useRef(-1);
4587
+ const assistantIterCounter = useRef(0);
4568
4588
  const toolHistoryRef = useRef([]);
4569
4589
  const [slashSelected, setSlashSelected] = useState3(0);
4570
4590
  const [summary, setSummary] = useState3({
@@ -4824,20 +4844,28 @@ function App({
4824
4844
  const streamRef = { id: assistantId, text: "", reasoning: "" };
4825
4845
  const contentBuf = { current: "" };
4826
4846
  const reasoningBuf = { current: "" };
4847
+ const toolCallBuildBuf = {
4848
+ current: null
4849
+ };
4827
4850
  setStreaming({ id: assistantId, role: "assistant", text: "", streaming: true });
4828
4851
  setBusy(true);
4829
4852
  abortedThisTurn.current = false;
4830
4853
  const flush = () => {
4831
- if (!contentBuf.current && !reasoningBuf.current) return;
4854
+ if (!contentBuf.current && !reasoningBuf.current && !toolCallBuildBuf.current) return;
4832
4855
  streamRef.text += contentBuf.current;
4833
4856
  streamRef.reasoning += reasoningBuf.current;
4857
+ if (toolCallBuildBuf.current) {
4858
+ streamRef.toolCallBuild = toolCallBuildBuf.current;
4859
+ }
4834
4860
  contentBuf.current = "";
4835
4861
  reasoningBuf.current = "";
4862
+ toolCallBuildBuf.current = null;
4836
4863
  setStreaming({
4837
4864
  id: assistantId,
4838
4865
  role: "assistant",
4839
4866
  text: streamRef.text,
4840
4867
  reasoning: streamRef.reasoning || void 0,
4868
+ toolCallBuild: streamRef.toolCallBuild,
4841
4869
  streaming: true
4842
4870
  });
4843
4871
  };
@@ -4853,6 +4881,13 @@ function App({
4853
4881
  } else if (ev.role === "assistant_delta") {
4854
4882
  if (ev.content) contentBuf.current += ev.content;
4855
4883
  if (ev.reasoningDelta) reasoningBuf.current += ev.reasoningDelta;
4884
+ } else if (ev.role === "tool_call_delta") {
4885
+ if (ev.toolName) {
4886
+ toolCallBuildBuf.current = {
4887
+ name: ev.toolName,
4888
+ chars: ev.toolCallArgsChars ?? 0
4889
+ };
4890
+ }
4856
4891
  } else if (ev.role === "branch_start") {
4857
4892
  setStreaming({
4858
4893
  id: assistantId,
@@ -4876,13 +4911,15 @@ function App({
4876
4911
  setStreaming(null);
4877
4912
  setSummary(loop.stats.summary());
4878
4913
  const finalText = ev.content || streamRef.text;
4914
+ const iterReasoning = streamRef.reasoning || void 0;
4915
+ const iterId = `${assistantId}-i${assistantIterCounter.current++}`;
4879
4916
  setHistorical((prev) => [
4880
4917
  ...prev,
4881
4918
  {
4882
- id: assistantId,
4919
+ id: iterId,
4883
4920
  role: "assistant",
4884
4921
  text: finalText,
4885
- reasoning: streamRef.reasoning || void 0,
4922
+ reasoning: iterReasoning,
4886
4923
  planState: ev.planState,
4887
4924
  branch: ev.branch,
4888
4925
  stats: ev.stats,
@@ -4890,6 +4927,12 @@ function App({
4890
4927
  streaming: false
4891
4928
  }
4892
4929
  ]);
4930
+ streamRef.text = "";
4931
+ streamRef.reasoning = "";
4932
+ streamRef.toolCallBuild = void 0;
4933
+ contentBuf.current = "";
4934
+ reasoningBuf.current = "";
4935
+ toolCallBuildBuf.current = null;
4893
4936
  if (codeMode && finalText && !ev.forcedSummary) {
4894
4937
  const blocks = parseEditBlocks(finalText);
4895
4938
  if (blocks.length > 0) {