@versot/vaguspi 0.1.5 → 0.1.7

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/bin.js CHANGED
@@ -1064,8 +1064,29 @@ var VagusEngine = class _VagusEngine {
1064
1064
  if (entry.type !== "message" || !entry.message)
1065
1065
  continue;
1066
1066
  const role = String(entry.message.role);
1067
- if (role === "toolResult")
1067
+ if (role === "toolResult") {
1068
+ const m = entry.message;
1069
+ if (typeof m.toolCallId === "string") {
1070
+ const tid = m.toolCallId;
1071
+ const res = resultsById.get(tid);
1072
+ views.push({
1073
+ role: "tool",
1074
+ text: "",
1075
+ toolCalls: [{
1076
+ id: tid,
1077
+ name: typeof m.toolName === "string" ? m.toolName : "tool",
1078
+ args: "",
1079
+ ...res ? {
1080
+ result: truncateDisplay(res.result, 2e4),
1081
+ isError: res.isError,
1082
+ ...res.diff !== void 0 ? { diff: res.diff } : {},
1083
+ ...res.patch !== void 0 ? { patch: res.patch } : {}
1084
+ } : {}
1085
+ }]
1086
+ });
1087
+ }
1068
1088
  continue;
1089
+ }
1069
1090
  const entryTs = new Date(entry.timestamp).getTime();
1070
1091
  if (role === "user")
1071
1092
  closeTurn();
@@ -1950,18 +1971,35 @@ var VagusEngine = class _VagusEngine {
1950
1971
  const session = this.requireSession(sessionId);
1951
1972
  await session.steer(text);
1952
1973
  }
1953
- /** Cancels a queued message by removing it from pi's steering queue. */
1974
+ /** Cancels a queued message by removing it from pi's steering queue.
1975
+ * pi keeps TWO queues in sync: AgentSession._steeringMessages (display
1976
+ * tracking) and Agent.steeringQueue.messages (the real send queue —
1977
+ * clearing only the former still delivers the message). Remove from both;
1978
+ * match by message text on the agent queue (AgentMessage.content text). */
1954
1979
  async cancelQueuedMessage(sessionId, text) {
1955
1980
  const session = this.requireSession(sessionId);
1981
+ let cancelled = false;
1956
1982
  const msgs = session["_steeringMessages"];
1957
1983
  if (msgs) {
1958
1984
  const idx = msgs.indexOf(text);
1959
1985
  if (idx !== -1) {
1960
1986
  msgs.splice(idx, 1);
1961
- return { cancelled: true };
1987
+ cancelled = true;
1962
1988
  }
1963
1989
  }
1964
- return { cancelled: false };
1990
+ const agent = session["agent"];
1991
+ const q = agent?.steeringQueue;
1992
+ if (q?.messages) {
1993
+ const idx = q.messages.findIndex((m) => m.content.some((c) => c.type === "text" && c.text === text));
1994
+ if (idx !== -1) {
1995
+ q.messages.splice(idx, 1);
1996
+ cancelled = true;
1997
+ }
1998
+ }
1999
+ if (cancelled) {
2000
+ session._emitQueueUpdate?.();
2001
+ }
2002
+ return { cancelled };
1965
2003
  }
1966
2004
  /**
1967
2005
  * Queues a follow-up message.