@agentconnect.md/daemon 1.0.0-rc.104 → 1.0.0-rc.105

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
@@ -81555,6 +81555,7 @@ const THINKING = "is thinking…";
81555
81555
  const MAX_ACTIVITY = 10;
81556
81556
  const MAX_LABEL = 100;
81557
81557
  const MAX_STATUS = 50;
81558
+ const MAX_REASONING = 2800;
81558
81559
  function clampTo(s, max) {
81559
81560
  const t = s.trim();
81560
81561
  return t.length > max ? `${t.slice(0, max - 1)}…` : t;
@@ -81572,24 +81573,44 @@ function planIcon(status) {
81572
81573
  function renderPlan(entries) {
81573
81574
  return [":clipboard: **Plan**", ...entries.map((e) => `${planIcon(e.status)} ${clampLabel(e.content ?? "")}`)].join("\n");
81574
81575
  }
81576
+ /** Render the accumulated reasoning trace (high mode) as one in-place message. Posted as
81577
+ * a `markdown` block (verbatim CommonMark, so `**bold**`), tail-clamped to a compact cap
81578
+ * — the newest thinking is the most relevant, so keep the end and mark truncation with a
81579
+ * leading ellipsis. */
81580
+ function renderReasoning(buf) {
81581
+ const trimmed = buf.trim();
81582
+ return `:thought_balloon: **Thinking**\n${trimmed.length > MAX_REASONING ? `…${trimmed.slice(-2800)}` : trimmed}`;
81583
+ }
81575
81584
  var OutputConverger = class {
81576
81585
  mode;
81577
81586
  buf = "";
81587
+ reasoningBuf = "";
81588
+ reasoningDirty = false;
81578
81589
  activity = [];
81579
81590
  toolTitles = /* @__PURE__ */ new Map();
81580
81591
  constructor(mode) {
81581
81592
  this.mode = mode;
81582
81593
  }
81583
- /** True while body text is buffered — the daemon uses this to (re)arm the ~2s
81584
- * idle-flush timer (§9.1 text-buffer) so a long pure-text stream posts in steps. */
81594
+ /** True while body text OR reasoning is pending — the daemon uses this to (re)arm
81595
+ * the ~2s idle-flush timer (§9.1 text-buffer) so a long pure-text stream posts in
81596
+ * steps and streamed thinking updates its in-place block at most once per window. */
81585
81597
  hasBuffered() {
81586
- return this.buf.trim().length > 0;
81598
+ return this.buf.trim().length > 0 || this.reasoningDirty;
81587
81599
  }
81588
- /** Flush the buffered body: split the agent's verbatim markdown into ≤block-limit
81589
- * sections, one `post` per section (each posted as a Block Kit `markdown` block, so
81590
- * no mrkdwn conversion). Public so the daemon's idle timer can call it. */
81600
+ /** Flush pending output for the idle timer: the buffered body (verbatim markdown split
81601
+ * into ≤block-limit `post` sections — each posted as a Block Kit `markdown` block, no
81602
+ * mrkdwn conversion) plus, in high mode, one in-place `reasoning` update carrying the
81603
+ * reasoning accumulated since the last flush. */
81591
81604
  flushBuffered() {
81592
- return this.flush();
81605
+ const out = this.flush();
81606
+ if (this.reasoningDirty) {
81607
+ this.reasoningDirty = false;
81608
+ out.push({
81609
+ kind: "reasoning",
81610
+ text: renderReasoning(this.reasoningBuf)
81611
+ });
81612
+ }
81613
+ return out;
81593
81614
  }
81594
81615
  flush() {
81595
81616
  const text = this.buf;
@@ -81632,21 +81653,16 @@ var OutputConverger = class {
81632
81653
  if (content?.type === "text") this.buf += content.text ?? "";
81633
81654
  return [];
81634
81655
  }
81635
- case "agent_thought_chunk": {
81636
- const status = this.pushActivity(THINKING);
81656
+ case "agent_thought_chunk":
81637
81657
  if (this.mode === "high") {
81638
- const content = update.content;
81639
- return [
81640
- ...this.flush(),
81641
- ...status,
81642
- {
81643
- kind: "progress",
81644
- text: `:thought_balloon: ${clampLabel(content?.text ?? "thinking…")}`
81645
- }
81646
- ];
81658
+ const text = update.content?.text ?? "";
81659
+ if (text) {
81660
+ this.reasoningBuf += text;
81661
+ if (this.reasoningBuf.length > MAX_REASONING * 2) this.reasoningBuf = this.reasoningBuf.slice(-2800 * 2);
81662
+ this.reasoningDirty = true;
81663
+ }
81647
81664
  }
81648
- return [...this.flush(), ...status];
81649
- }
81665
+ return [...this.flush(), ...this.pushActivity(THINKING)];
81650
81666
  case "tool_call":
81651
81667
  case "tool_call_update": {
81652
81668
  const label = this.toolLabel(update);
@@ -81684,12 +81700,21 @@ var OutputConverger = class {
81684
81700
  text: ""
81685
81701
  };
81686
81702
  if (this.mode === "low") return [...this.flush(), clear];
81703
+ const reasoning = [];
81704
+ if (this.reasoningDirty) {
81705
+ this.reasoningDirty = false;
81706
+ reasoning.push({
81707
+ kind: "reasoning",
81708
+ text: renderReasoning(this.reasoningBuf)
81709
+ });
81710
+ }
81687
81711
  const footer = link ? [{
81688
81712
  kind: "notice",
81689
81713
  text: `:white_check_mark: done — [details](${link})`
81690
81714
  }] : [];
81691
81715
  return [
81692
81716
  ...this.flush(),
81717
+ ...reasoning,
81693
81718
  clear,
81694
81719
  ...footer
81695
81720
  ];
@@ -84863,6 +84888,13 @@ var Daemon = class Daemon {
84863
84888
  p.planTs = await conn.postMessage(p.channel, action.text, p.thread);
84864
84889
  }
84865
84890
  return;
84891
+ case "reasoning":
84892
+ if (p.reasoningTs) await conn.updateMessage(p.channel, p.reasoningTs, action.text);
84893
+ else if (!p.reasoningAttempted) {
84894
+ p.reasoningAttempted = true;
84895
+ p.reasoningTs = await conn.postMessage(p.channel, action.text, p.thread);
84896
+ }
84897
+ return;
84866
84898
  }
84867
84899
  }
84868
84900
  /** Serialize action application per session so in-place edits never race on the