@melaya/runner 1.0.14 → 1.0.15

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.
Files changed (2) hide show
  1. package/dist/localRelay.js +25 -7
  2. package/package.json +1 -1
@@ -20,20 +20,38 @@ let _throttleQueue = [];
20
20
  function _flushThrottle(socket, verbose) {
21
21
  if (_throttleQueue.length === 0)
22
22
  return;
23
- // Send the LAST event per replyId (most recent content wins)
24
- const byReply = new Map();
23
+ // Coalescing rule:
24
+ // - `agent_message` is a streaming event type whose payload GROWS
25
+ // over time (each update replaces the previous with more text).
26
+ // Only the LAST per replyId matters — keep the last-write-wins
27
+ // dedup for these.
28
+ // - Everything else (reasoning / tool_call / tool_result /
29
+ // agent_reply / cost / session_status / compact / hook) is a
30
+ // discrete event — coalescing drops real information. Emit every
31
+ // one exactly once, preserving order.
32
+ const streamingByReply = new Map();
33
+ const discrete = [];
25
34
  for (const p of _throttleQueue) {
26
- const key = p.replyId || p.run_id || "default";
27
- byReply.set(key, p);
35
+ if (p.event_type === "agent_message") {
36
+ const key = p.replyId || p.run_id || "default";
37
+ streamingByReply.set(key, p);
38
+ }
39
+ else {
40
+ discrete.push(p);
41
+ }
28
42
  }
29
- for (const payload of byReply.values()) {
43
+ const emit = (payload) => {
30
44
  socket.emit("runner:event", payload);
31
45
  if (verbose) {
32
46
  const type = payload.event_type || "unknown";
33
- const agent = payload.replyName || "";
47
+ const agent = payload.replyName || payload.agent_name || "";
34
48
  process.stdout.write(` [relay] ${type}${agent ? ` (${agent})` : ""}\n`);
35
49
  }
36
- }
50
+ };
51
+ for (const payload of discrete)
52
+ emit(payload);
53
+ for (const payload of streamingByReply.values())
54
+ emit(payload);
37
55
  _throttleQueue = [];
38
56
  _throttleTimer = null;
39
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melaya/runner",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,