@arbidocs/tui 0.3.131 → 0.3.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1953,16 +1953,6 @@ function registerAllCommands() {
1953
1953
  registerCommands(historyCommands);
1954
1954
  registerCommands(skillCommands);
1955
1955
  }
1956
- function extractStepDetails(data) {
1957
- const detail = data.detail;
1958
- if (!detail || detail.length === 0) return void 0;
1959
- const d = detail[0];
1960
- if (!d) return void 0;
1961
- const result = {};
1962
- if (d.tool) result.tool = d.tool;
1963
- if (d.message) result.args = d.message;
1964
- return result.tool || result.args || result.result ? result : void 0;
1965
- }
1966
1956
  async function streamResponse(tui, response, docNames) {
1967
1957
  tui.chatLog.startAssistant();
1968
1958
  tui.state.activityStatus = "streaming";
@@ -1970,6 +1960,16 @@ async function streamResponse(tui, response, docNames) {
1970
1960
  let accumulated = "";
1971
1961
  let elapsedTime = null;
1972
1962
  let firstToken = true;
1963
+ const updateAnswer = (content) => {
1964
+ if (!content) return;
1965
+ if (firstToken) {
1966
+ firstToken = false;
1967
+ tui.chatLog.clearActiveSteps();
1968
+ }
1969
+ accumulated = content;
1970
+ tui.chatLog.updateAssistant(accumulated);
1971
+ tui.requestRender();
1972
+ };
1973
1973
  let lastStepIndex = null;
1974
1974
  let lastStepLabel = "";
1975
1975
  const callbacks = {
@@ -1979,21 +1979,16 @@ async function streamResponse(tui, response, docNames) {
1979
1979
  }
1980
1980
  },
1981
1981
  onToken: (content) => {
1982
- if (firstToken) {
1983
- firstToken = false;
1984
- tui.chatLog.clearActiveSteps();
1985
- }
1986
- accumulated += content;
1987
- tui.chatLog.updateAssistant(accumulated);
1988
- tui.requestRender();
1982
+ updateAnswer(accumulated + content);
1989
1983
  },
1984
+ onTextDone: updateAnswer,
1990
1985
  onAgentStep: (data) => {
1991
1986
  const label = sdk.formatAgentStepLabel(data, docNames);
1992
1987
  if (label) {
1993
1988
  if (data.index === lastStepIndex && label === lastStepLabel) return;
1994
1989
  lastStepIndex = data.index;
1995
1990
  lastStepLabel = label;
1996
- tui.chatLog.addAgentStep(label, extractStepDetails(data));
1991
+ tui.chatLog.addAgentStep(label);
1997
1992
  tui.requestRender();
1998
1993
  }
1999
1994
  },
@@ -2007,6 +2002,7 @@ async function streamResponse(tui, response, docNames) {
2007
2002
  };
2008
2003
  try {
2009
2004
  const result = await sdk.streamSSE(response, callbacks);
2005
+ if (result.text && result.text !== accumulated) updateAnswer(result.text);
2010
2006
  tui.chatLog.finalizeAssistant();
2011
2007
  tui.lastMetadata = result.metadata ?? null;
2012
2008
  tui.sourcesIndex.recordCitations(result.metadata);