@ai-matrx/agents 0.10.3 → 0.10.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.4
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/matrx-agents/v0.10.3..npm/matrx-agents/v0.10.4 -- apps/shared/matrx-agents`).
7
+ No source changes intended and no consumer action required.
8
+
3
9
  ## 0.10.3
4
10
 
5
11
  Automatic changed-only republish (docs/metadata drift since the last tag — see
package/dist/index.cjs CHANGED
@@ -84,17 +84,33 @@ function normalizeMatrxStreamEnvelope(value) {
84
84
  if (!isRecord(value)) return null;
85
85
  if (typeof value.event === "string") {
86
86
  const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
87
+ const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
87
88
  return {
88
89
  event: value.event,
89
90
  data: value.data,
91
+ ...streamId === void 0 ? {} : { stream_id: streamId },
90
92
  ...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
91
93
  };
92
94
  }
93
95
  if (value.e === "c" && typeof value.t === "string") {
94
- return { event: "chunk", data: { text: value.t } };
96
+ const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
97
+ const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
98
+ return {
99
+ event: "chunk",
100
+ data: { text: value.t },
101
+ ...streamId === void 0 ? {} : { stream_id: streamId },
102
+ ...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
103
+ };
95
104
  }
96
105
  if (value.e === "r" && typeof value.t === "string") {
97
- return { event: "reasoning_chunk", data: { text: value.t } };
106
+ const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
107
+ const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
108
+ return {
109
+ event: "reasoning_chunk",
110
+ data: { text: value.t },
111
+ ...streamId === void 0 ? {} : { stream_id: streamId },
112
+ ...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
113
+ };
98
114
  }
99
115
  return null;
100
116
  }
@@ -434,6 +450,7 @@ function createAgentRequestProjection(input) {
434
450
  completion: null,
435
451
  error: null,
436
452
  lastTransportSeq: 0,
453
+ transportStreamId: null,
437
454
  eventCount: 0
438
455
  };
439
456
  }
@@ -457,12 +474,17 @@ function toolStatus(event) {
457
474
  }
458
475
  function projectAgentEvent(current, event) {
459
476
  const streamSeq = asNumber(event.stream_seq);
460
- if (streamSeq !== null && streamSeq <= current.lastTransportSeq) return current;
477
+ const streamId = asString(event.stream_id);
478
+ const sameSegment = streamId === null || streamId === current.transportStreamId;
479
+ if (sameSegment && streamSeq !== null && streamSeq <= current.lastTransportSeq) {
480
+ return current;
481
+ }
461
482
  const data = asRecord(event.data);
462
483
  const next = {
463
484
  ...current,
464
485
  status: current.status === "pending" ? "streaming" : current.status,
465
- lastTransportSeq: streamSeq ?? current.lastTransportSeq,
486
+ lastTransportSeq: streamSeq === null ? current.lastTransportSeq : sameSegment ? Math.max(current.lastTransportSeq, streamSeq) : streamSeq,
487
+ transportStreamId: streamId ?? current.transportStreamId,
466
488
  eventCount: current.eventCount + 1
467
489
  };
468
490
  switch (event.event) {