@ai-matrx/agents 0.10.2 → 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 +12 -0
- package/dist/index.cjs +26 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/dist/mandates/index.cjs +2 -2
- package/dist/mandates/index.cjs.map +1 -1
- package/dist/mandates/index.d.cts +4 -4
- package/dist/mandates/index.d.ts +4 -4
- package/dist/mandates/index.js +2 -2
- package/dist/mandates/index.js.map +1 -1
- package/dist/matrx/index.cjs +18 -2
- package/dist/matrx/index.cjs.map +1 -1
- package/dist/matrx/index.js +18 -2
- package/dist/matrx/index.js.map +1 -1
- package/dist/projection/request.cjs +8 -2
- package/dist/projection/request.cjs.map +1 -1
- package/dist/projection/request.d.cts +2 -0
- package/dist/projection/request.d.ts +2 -0
- package/dist/projection/request.js +8 -2
- package/dist/projection/request.js.map +1 -1
- package/dist/react/index.cjs +26 -4
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +3 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +26 -4
- package/dist/react/index.js.map +1 -1
- package/dist/stream/ndjson.cjs +18 -2
- package/dist/stream/ndjson.cjs.map +1 -1
- package/dist/stream/ndjson.d.cts +2 -0
- package/dist/stream/ndjson.d.ts +2 -0
- package/dist/stream/ndjson.js +18 -2
- package/dist/stream/ndjson.js.map +1 -1
- package/mandates/snapshots/keys.0.10.2.json +469 -0
- package/mandates/snapshots/keys.0.10.3.json +469 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,17 +7,33 @@ function normalizeMatrxStreamEnvelope(value) {
|
|
|
7
7
|
if (!isRecord(value)) return null;
|
|
8
8
|
if (typeof value.event === "string") {
|
|
9
9
|
const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
|
|
10
|
+
const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
|
|
10
11
|
return {
|
|
11
12
|
event: value.event,
|
|
12
13
|
data: value.data,
|
|
14
|
+
...streamId === void 0 ? {} : { stream_id: streamId },
|
|
13
15
|
...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
if (value.e === "c" && typeof value.t === "string") {
|
|
17
|
-
|
|
19
|
+
const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
|
|
20
|
+
const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
|
|
21
|
+
return {
|
|
22
|
+
event: "chunk",
|
|
23
|
+
data: { text: value.t },
|
|
24
|
+
...streamId === void 0 ? {} : { stream_id: streamId },
|
|
25
|
+
...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
|
|
26
|
+
};
|
|
18
27
|
}
|
|
19
28
|
if (value.e === "r" && typeof value.t === "string") {
|
|
20
|
-
|
|
29
|
+
const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
|
|
30
|
+
const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
|
|
31
|
+
return {
|
|
32
|
+
event: "reasoning_chunk",
|
|
33
|
+
data: { text: value.t },
|
|
34
|
+
...streamId === void 0 ? {} : { stream_id: streamId },
|
|
35
|
+
...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
|
|
36
|
+
};
|
|
21
37
|
}
|
|
22
38
|
return null;
|
|
23
39
|
}
|
|
@@ -357,6 +373,7 @@ function createAgentRequestProjection(input) {
|
|
|
357
373
|
completion: null,
|
|
358
374
|
error: null,
|
|
359
375
|
lastTransportSeq: 0,
|
|
376
|
+
transportStreamId: null,
|
|
360
377
|
eventCount: 0
|
|
361
378
|
};
|
|
362
379
|
}
|
|
@@ -380,12 +397,17 @@ function toolStatus(event) {
|
|
|
380
397
|
}
|
|
381
398
|
function projectAgentEvent(current, event) {
|
|
382
399
|
const streamSeq = asNumber(event.stream_seq);
|
|
383
|
-
|
|
400
|
+
const streamId = asString(event.stream_id);
|
|
401
|
+
const sameSegment = streamId === null || streamId === current.transportStreamId;
|
|
402
|
+
if (sameSegment && streamSeq !== null && streamSeq <= current.lastTransportSeq) {
|
|
403
|
+
return current;
|
|
404
|
+
}
|
|
384
405
|
const data = asRecord(event.data);
|
|
385
406
|
const next = {
|
|
386
407
|
...current,
|
|
387
408
|
status: current.status === "pending" ? "streaming" : current.status,
|
|
388
|
-
lastTransportSeq: streamSeq
|
|
409
|
+
lastTransportSeq: streamSeq === null ? current.lastTransportSeq : sameSegment ? Math.max(current.lastTransportSeq, streamSeq) : streamSeq,
|
|
410
|
+
transportStreamId: streamId ?? current.transportStreamId,
|
|
389
411
|
eventCount: current.eventCount + 1
|
|
390
412
|
};
|
|
391
413
|
switch (event.event) {
|