@arbidocs/sdk 0.3.132 → 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.
@@ -309,6 +309,7 @@ type ResponseOutputItemDoneEvent = components['schemas']['ResponseOutputItemDone
309
309
  type ResponseContentPartAddedEvent = components['schemas']['ResponseContentPartAddedEvent'];
310
310
  type AgentStepEvent = components['schemas']['AgentStepEvent'];
311
311
  type AgentStepDeltaEvent = components['schemas']['AgentStepDeltaEvent'];
312
+ type GeneratingEvent = components['schemas']['GeneratingEvent'];
312
313
  type UserInputRequestEvent = components['schemas']['UserInputRequestEvent'];
313
314
  type ProbeAnswerEvent = components['schemas']['ProbeAnswerEvent'];
314
315
  type DeferredInterjectionEvent = components['schemas']['DeferredInterjectionEvent'];
@@ -404,6 +405,13 @@ interface SSEStreamCallbacks {
404
405
  onAgentStep?: (data: AgentStepEvent) => void;
405
406
  /** Live narration delta — append `delta` to the focus of the step with the matching `index`. */
406
407
  onAgentStepDelta?: (data: AgentStepDeltaEvent) => void;
408
+ /**
409
+ * The model has started generating free text. Open the token channel here.
410
+ * It does NOT mean the text is the answer — a preamble before a tool call
411
+ * looks identical at this point. Only the absence of a tool call proves it
412
+ * was the answer, which is not known until the turn resolves.
413
+ */
414
+ onGenerating?: (data: GeneratingEvent) => void;
407
415
  onError?: (message: string) => void;
408
416
  /**
409
417
  * Fired when the server emits a structured `arbi.error` event mid-stream.
@@ -309,6 +309,7 @@ type ResponseOutputItemDoneEvent = components['schemas']['ResponseOutputItemDone
309
309
  type ResponseContentPartAddedEvent = components['schemas']['ResponseContentPartAddedEvent'];
310
310
  type AgentStepEvent = components['schemas']['AgentStepEvent'];
311
311
  type AgentStepDeltaEvent = components['schemas']['AgentStepDeltaEvent'];
312
+ type GeneratingEvent = components['schemas']['GeneratingEvent'];
312
313
  type UserInputRequestEvent = components['schemas']['UserInputRequestEvent'];
313
314
  type ProbeAnswerEvent = components['schemas']['ProbeAnswerEvent'];
314
315
  type DeferredInterjectionEvent = components['schemas']['DeferredInterjectionEvent'];
@@ -404,6 +405,13 @@ interface SSEStreamCallbacks {
404
405
  onAgentStep?: (data: AgentStepEvent) => void;
405
406
  /** Live narration delta — append `delta` to the focus of the step with the matching `index`. */
406
407
  onAgentStepDelta?: (data: AgentStepDeltaEvent) => void;
408
+ /**
409
+ * The model has started generating free text. Open the token channel here.
410
+ * It does NOT mean the text is the answer — a preamble before a tool call
411
+ * looks identical at this point. Only the absence of a tool call proves it
412
+ * was the answer, which is not known until the turn resolves.
413
+ */
414
+ onGenerating?: (data: GeneratingEvent) => void;
407
415
  onError?: (message: string) => void;
408
416
  /**
409
417
  * Fired when the server emits a structured `arbi.error` event mid-stream.
package/dist/browser.cjs CHANGED
@@ -3786,14 +3786,10 @@ async function resolveWorkspace(store, workspaceOpt) {
3786
3786
  }
3787
3787
 
3788
3788
  // src/sse.ts
3789
- var LIFECYCLE_LABELS_FALLBACK = {
3790
- goal: "Thinking\u2026",
3791
- evaluation: "Evaluating results",
3792
- answering: "Answered",
3793
- interjection: "Your message",
3794
- planning: "Planning",
3795
- tool_progress: "Working"
3796
- };
3789
+ function humanizeStep(identifier) {
3790
+ const spaced = identifier.replace(/[_-]+/g, " ").trim();
3791
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1);
3792
+ }
3797
3793
  function resolveDocRefs(text, docNames) {
3798
3794
  if (!docNames) return text;
3799
3795
  return text.replace(/\{(doc-[^}]+)\}/g, (_match, id) => docNames[id] ?? id);
@@ -3837,13 +3833,13 @@ function formatAgentStepLabel(step, docNames) {
3837
3833
  if (step.label) return `${step.label}${suffix}`;
3838
3834
  const detail = step.detail;
3839
3835
  if (step.step === "tool_progress" && detail && detail.length > 0) {
3840
- const label = detail[0].label || LIFECYCLE_LABELS_FALLBACK.tool_progress;
3836
+ const label = detail[0].label || humanizeStep(step.step);
3841
3837
  if (suffix) return `${label}${suffix}`;
3842
3838
  const message = detail[0].message;
3843
3839
  return message ? `${label}: ${resolveDocRefs(message, docNames)}` : label;
3844
3840
  }
3845
3841
  if (step.step) {
3846
- return LIFECYCLE_LABELS_FALLBACK[step.step] || step.step;
3842
+ return humanizeStep(step.step);
3847
3843
  }
3848
3844
  if (detail && detail.length > 0) {
3849
3845
  if (detail[0].label) return `${detail[0].label}${suffix}`;
@@ -3966,6 +3962,11 @@ async function streamSSE(response, callbacks = {}) {
3966
3962
  callbacks.onAgentStep?.(data);
3967
3963
  if (data.t != null) callbacks.onElapsedTime?.(data.t);
3968
3964
  },
3965
+ "arbi.generating": (raw) => {
3966
+ const data = JSON.parse(raw);
3967
+ callbacks.onGenerating?.(data);
3968
+ if (data.t != null) callbacks.onElapsedTime?.(data.t);
3969
+ },
3969
3970
  "arbi.agent_step_delta": (raw) => {
3970
3971
  const data = JSON.parse(raw);
3971
3972
  callbacks.onAgentStepDelta?.(data);