@ai-matrx/agents 0.10.3 → 0.10.5
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.3.json +469 -0
- package/mandates/snapshots/keys.0.10.4.json +469 -0
- package/package.json +3 -3
package/dist/react/index.d.cts
CHANGED
|
@@ -39,6 +39,7 @@ interface AgentRequestProjection {
|
|
|
39
39
|
completion: Record<string, unknown> | null;
|
|
40
40
|
error: Record<string, unknown> | null;
|
|
41
41
|
lastTransportSeq: number;
|
|
42
|
+
transportStreamId: string | null;
|
|
42
43
|
eventCount: number;
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -244,6 +245,8 @@ type MatrxConversationStart = MatrxStoredConversationCreate | MatrxStoredConvers
|
|
|
244
245
|
*/
|
|
245
246
|
interface MatrxStreamEnvelope<TData = unknown> {
|
|
246
247
|
event: string;
|
|
248
|
+
/** Immutable emitter segment; transport sequence is scoped to this id. */
|
|
249
|
+
stream_id?: string;
|
|
247
250
|
data: TData;
|
|
248
251
|
/** Monotonic transport sequence from full envelopes, when supplied. */
|
|
249
252
|
stream_seq?: number;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ interface AgentRequestProjection {
|
|
|
39
39
|
completion: Record<string, unknown> | null;
|
|
40
40
|
error: Record<string, unknown> | null;
|
|
41
41
|
lastTransportSeq: number;
|
|
42
|
+
transportStreamId: string | null;
|
|
42
43
|
eventCount: number;
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -244,6 +245,8 @@ type MatrxConversationStart = MatrxStoredConversationCreate | MatrxStoredConvers
|
|
|
244
245
|
*/
|
|
245
246
|
interface MatrxStreamEnvelope<TData = unknown> {
|
|
246
247
|
event: string;
|
|
248
|
+
/** Immutable emitter segment; transport sequence is scoped to this id. */
|
|
249
|
+
stream_id?: string;
|
|
247
250
|
data: TData;
|
|
248
251
|
/** Monotonic transport sequence from full envelopes, when supplied. */
|
|
249
252
|
stream_seq?: number;
|
package/dist/react/index.js
CHANGED
|
@@ -24,6 +24,7 @@ function createAgentRequestProjection(input) {
|
|
|
24
24
|
completion: null,
|
|
25
25
|
error: null,
|
|
26
26
|
lastTransportSeq: 0,
|
|
27
|
+
transportStreamId: null,
|
|
27
28
|
eventCount: 0
|
|
28
29
|
};
|
|
29
30
|
}
|
|
@@ -47,12 +48,17 @@ function toolStatus(event) {
|
|
|
47
48
|
}
|
|
48
49
|
function projectAgentEvent(current, event) {
|
|
49
50
|
const streamSeq = asNumber(event.stream_seq);
|
|
50
|
-
|
|
51
|
+
const streamId = asString(event.stream_id);
|
|
52
|
+
const sameSegment = streamId === null || streamId === current.transportStreamId;
|
|
53
|
+
if (sameSegment && streamSeq !== null && streamSeq <= current.lastTransportSeq) {
|
|
54
|
+
return current;
|
|
55
|
+
}
|
|
51
56
|
const data = asRecord(event.data);
|
|
52
57
|
const next = {
|
|
53
58
|
...current,
|
|
54
59
|
status: current.status === "pending" ? "streaming" : current.status,
|
|
55
|
-
lastTransportSeq: streamSeq
|
|
60
|
+
lastTransportSeq: streamSeq === null ? current.lastTransportSeq : sameSegment ? Math.max(current.lastTransportSeq, streamSeq) : streamSeq,
|
|
61
|
+
transportStreamId: streamId ?? current.transportStreamId,
|
|
56
62
|
eventCount: current.eventCount + 1
|
|
57
63
|
};
|
|
58
64
|
switch (event.event) {
|
|
@@ -335,17 +341,33 @@ function normalizeMatrxStreamEnvelope(value) {
|
|
|
335
341
|
if (!isRecord2(value)) return null;
|
|
336
342
|
if (typeof value.event === "string") {
|
|
337
343
|
const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
|
|
344
|
+
const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
|
|
338
345
|
return {
|
|
339
346
|
event: value.event,
|
|
340
347
|
data: value.data,
|
|
348
|
+
...streamId === void 0 ? {} : { stream_id: streamId },
|
|
341
349
|
...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
|
|
342
350
|
};
|
|
343
351
|
}
|
|
344
352
|
if (value.e === "c" && typeof value.t === "string") {
|
|
345
|
-
|
|
353
|
+
const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
|
|
354
|
+
const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
|
|
355
|
+
return {
|
|
356
|
+
event: "chunk",
|
|
357
|
+
data: { text: value.t },
|
|
358
|
+
...streamId === void 0 ? {} : { stream_id: streamId },
|
|
359
|
+
...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
|
|
360
|
+
};
|
|
346
361
|
}
|
|
347
362
|
if (value.e === "r" && typeof value.t === "string") {
|
|
348
|
-
|
|
363
|
+
const streamId = typeof value.stream_id === "string" ? value.stream_id : void 0;
|
|
364
|
+
const streamSeq = typeof value.stream_seq === "number" && Number.isFinite(value.stream_seq) ? value.stream_seq : void 0;
|
|
365
|
+
return {
|
|
366
|
+
event: "reasoning_chunk",
|
|
367
|
+
data: { text: value.t },
|
|
368
|
+
...streamId === void 0 ? {} : { stream_id: streamId },
|
|
369
|
+
...streamSeq === void 0 ? {} : { stream_seq: streamSeq }
|
|
370
|
+
};
|
|
349
371
|
}
|
|
350
372
|
return null;
|
|
351
373
|
}
|