@inkeep/agents-run-api 0.0.0-dev-20251009223620 → 0.0.0-dev-20251009233425
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/index.cjs +46 -7
- package/dist/index.js +46 -7
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4476,6 +4476,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
4476
4476
|
__publicField(this, "componentSnapshots", /* @__PURE__ */ new Map());
|
|
4477
4477
|
__publicField(this, "artifactMap");
|
|
4478
4478
|
__publicField(this, "subAgentId");
|
|
4479
|
+
__publicField(this, "allStreamedContent", []);
|
|
4479
4480
|
this.streamHelper = streamHelper;
|
|
4480
4481
|
this.contextId = contextId;
|
|
4481
4482
|
this.subAgentId = artifactParserOptions?.subAgentId;
|
|
@@ -4594,10 +4595,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
4594
4595
|
this.hasStartedRole = true;
|
|
4595
4596
|
}
|
|
4596
4597
|
await this.streamHelper.streamText(newText, 50);
|
|
4597
|
-
|
|
4598
|
+
const textPart = {
|
|
4598
4599
|
kind: "text",
|
|
4599
4600
|
text: newText
|
|
4600
|
-
}
|
|
4601
|
+
};
|
|
4602
|
+
this.collectedParts.push(textPart);
|
|
4603
|
+
this.allStreamedContent.push(textPart);
|
|
4601
4604
|
}
|
|
4602
4605
|
continue;
|
|
4603
4606
|
}
|
|
@@ -4723,10 +4726,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
4723
4726
|
if (this.pendingTextBuffer) {
|
|
4724
4727
|
const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/artifact:ref>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
|
|
4725
4728
|
if (cleanedText) {
|
|
4726
|
-
|
|
4729
|
+
const textPart = {
|
|
4727
4730
|
kind: "text",
|
|
4728
4731
|
text: cleanedText
|
|
4729
|
-
}
|
|
4732
|
+
};
|
|
4733
|
+
this.collectedParts.push(textPart);
|
|
4734
|
+
this.allStreamedContent.push(textPart);
|
|
4730
4735
|
await this.streamHelper.streamText(cleanedText, 50);
|
|
4731
4736
|
}
|
|
4732
4737
|
this.pendingTextBuffer = "";
|
|
@@ -4741,6 +4746,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
4741
4746
|
getCollectedParts() {
|
|
4742
4747
|
return [...this.collectedParts];
|
|
4743
4748
|
}
|
|
4749
|
+
/**
|
|
4750
|
+
* Get all streamed content that was actually sent to the user
|
|
4751
|
+
*/
|
|
4752
|
+
getAllStreamedContent() {
|
|
4753
|
+
return [...this.allStreamedContent];
|
|
4754
|
+
}
|
|
4744
4755
|
/**
|
|
4745
4756
|
* Parse buffer for complete artifacts and text parts (for text streaming)
|
|
4746
4757
|
*/
|
|
@@ -4800,10 +4811,15 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
4800
4811
|
*/
|
|
4801
4812
|
async streamPart(part) {
|
|
4802
4813
|
this.collectedParts.push({ ...part });
|
|
4814
|
+
this.allStreamedContent.push({ ...part });
|
|
4803
4815
|
if (this.collectedParts.length > _IncrementalStreamParser.MAX_COLLECTED_PARTS) {
|
|
4804
4816
|
const excess = this.collectedParts.length - _IncrementalStreamParser.MAX_COLLECTED_PARTS;
|
|
4805
4817
|
this.collectedParts.splice(0, excess);
|
|
4806
4818
|
}
|
|
4819
|
+
if (this.allStreamedContent.length > _IncrementalStreamParser.MAX_COLLECTED_PARTS) {
|
|
4820
|
+
const excess = this.allStreamedContent.length - _IncrementalStreamParser.MAX_COLLECTED_PARTS;
|
|
4821
|
+
this.allStreamedContent.splice(0, excess);
|
|
4822
|
+
}
|
|
4807
4823
|
if (!this.hasStartedRole) {
|
|
4808
4824
|
await this.streamHelper.writeRole("assistant");
|
|
4809
4825
|
this.hasStartedRole = true;
|
|
@@ -8712,6 +8728,16 @@ var Agent = class {
|
|
|
8712
8728
|
}))
|
|
8713
8729
|
};
|
|
8714
8730
|
}
|
|
8731
|
+
const streamedContent = parser.getAllStreamedContent();
|
|
8732
|
+
if (streamedContent.length > 0) {
|
|
8733
|
+
response.streamedContent = {
|
|
8734
|
+
parts: streamedContent.map((part) => ({
|
|
8735
|
+
kind: part.kind,
|
|
8736
|
+
...part.kind === "text" && { text: part.text },
|
|
8737
|
+
...part.kind === "data" && { data: part.data }
|
|
8738
|
+
}))
|
|
8739
|
+
};
|
|
8740
|
+
}
|
|
8715
8741
|
} else {
|
|
8716
8742
|
let genConfig;
|
|
8717
8743
|
if (hasStructuredOutput) {
|
|
@@ -10489,9 +10515,22 @@ var ExecutionHandler = class {
|
|
|
10489
10515
|
}
|
|
10490
10516
|
continue;
|
|
10491
10517
|
}
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10518
|
+
let responseParts = [];
|
|
10519
|
+
if (messageResponse.result.streamedContent?.parts) {
|
|
10520
|
+
responseParts = messageResponse.result.streamedContent.parts;
|
|
10521
|
+
logger22.info(
|
|
10522
|
+
{ partsCount: responseParts.length },
|
|
10523
|
+
"Using streamed content for conversation history"
|
|
10524
|
+
);
|
|
10525
|
+
} else {
|
|
10526
|
+
responseParts = messageResponse.result.artifacts?.flatMap(
|
|
10527
|
+
(artifact) => artifact.parts || []
|
|
10528
|
+
) || [];
|
|
10529
|
+
logger22.info(
|
|
10530
|
+
{ partsCount: responseParts.length },
|
|
10531
|
+
"Using artifacts for conversation history (fallback)"
|
|
10532
|
+
);
|
|
10533
|
+
}
|
|
10495
10534
|
if (responseParts && responseParts.length > 0) {
|
|
10496
10535
|
const graphSessionData = graphSessionManager.getSession(requestId2);
|
|
10497
10536
|
if (graphSessionData) {
|
package/dist/index.js
CHANGED
|
@@ -3668,6 +3668,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3668
3668
|
__publicField(this, "componentSnapshots", /* @__PURE__ */ new Map());
|
|
3669
3669
|
__publicField(this, "artifactMap");
|
|
3670
3670
|
__publicField(this, "subAgentId");
|
|
3671
|
+
__publicField(this, "allStreamedContent", []);
|
|
3671
3672
|
this.streamHelper = streamHelper;
|
|
3672
3673
|
this.contextId = contextId;
|
|
3673
3674
|
this.subAgentId = artifactParserOptions?.subAgentId;
|
|
@@ -3786,10 +3787,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3786
3787
|
this.hasStartedRole = true;
|
|
3787
3788
|
}
|
|
3788
3789
|
await this.streamHelper.streamText(newText, 50);
|
|
3789
|
-
|
|
3790
|
+
const textPart = {
|
|
3790
3791
|
kind: "text",
|
|
3791
3792
|
text: newText
|
|
3792
|
-
}
|
|
3793
|
+
};
|
|
3794
|
+
this.collectedParts.push(textPart);
|
|
3795
|
+
this.allStreamedContent.push(textPart);
|
|
3793
3796
|
}
|
|
3794
3797
|
continue;
|
|
3795
3798
|
}
|
|
@@ -3915,10 +3918,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3915
3918
|
if (this.pendingTextBuffer) {
|
|
3916
3919
|
const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/artifact:ref>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
|
|
3917
3920
|
if (cleanedText) {
|
|
3918
|
-
|
|
3921
|
+
const textPart = {
|
|
3919
3922
|
kind: "text",
|
|
3920
3923
|
text: cleanedText
|
|
3921
|
-
}
|
|
3924
|
+
};
|
|
3925
|
+
this.collectedParts.push(textPart);
|
|
3926
|
+
this.allStreamedContent.push(textPart);
|
|
3922
3927
|
await this.streamHelper.streamText(cleanedText, 50);
|
|
3923
3928
|
}
|
|
3924
3929
|
this.pendingTextBuffer = "";
|
|
@@ -3933,6 +3938,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3933
3938
|
getCollectedParts() {
|
|
3934
3939
|
return [...this.collectedParts];
|
|
3935
3940
|
}
|
|
3941
|
+
/**
|
|
3942
|
+
* Get all streamed content that was actually sent to the user
|
|
3943
|
+
*/
|
|
3944
|
+
getAllStreamedContent() {
|
|
3945
|
+
return [...this.allStreamedContent];
|
|
3946
|
+
}
|
|
3936
3947
|
/**
|
|
3937
3948
|
* Parse buffer for complete artifacts and text parts (for text streaming)
|
|
3938
3949
|
*/
|
|
@@ -3992,10 +4003,15 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3992
4003
|
*/
|
|
3993
4004
|
async streamPart(part) {
|
|
3994
4005
|
this.collectedParts.push({ ...part });
|
|
4006
|
+
this.allStreamedContent.push({ ...part });
|
|
3995
4007
|
if (this.collectedParts.length > _IncrementalStreamParser.MAX_COLLECTED_PARTS) {
|
|
3996
4008
|
const excess = this.collectedParts.length - _IncrementalStreamParser.MAX_COLLECTED_PARTS;
|
|
3997
4009
|
this.collectedParts.splice(0, excess);
|
|
3998
4010
|
}
|
|
4011
|
+
if (this.allStreamedContent.length > _IncrementalStreamParser.MAX_COLLECTED_PARTS) {
|
|
4012
|
+
const excess = this.allStreamedContent.length - _IncrementalStreamParser.MAX_COLLECTED_PARTS;
|
|
4013
|
+
this.allStreamedContent.splice(0, excess);
|
|
4014
|
+
}
|
|
3999
4015
|
if (!this.hasStartedRole) {
|
|
4000
4016
|
await this.streamHelper.writeRole("assistant");
|
|
4001
4017
|
this.hasStartedRole = true;
|
|
@@ -7888,6 +7904,16 @@ var Agent = class {
|
|
|
7888
7904
|
}))
|
|
7889
7905
|
};
|
|
7890
7906
|
}
|
|
7907
|
+
const streamedContent = parser.getAllStreamedContent();
|
|
7908
|
+
if (streamedContent.length > 0) {
|
|
7909
|
+
response.streamedContent = {
|
|
7910
|
+
parts: streamedContent.map((part) => ({
|
|
7911
|
+
kind: part.kind,
|
|
7912
|
+
...part.kind === "text" && { text: part.text },
|
|
7913
|
+
...part.kind === "data" && { data: part.data }
|
|
7914
|
+
}))
|
|
7915
|
+
};
|
|
7916
|
+
}
|
|
7891
7917
|
} else {
|
|
7892
7918
|
let genConfig;
|
|
7893
7919
|
if (hasStructuredOutput) {
|
|
@@ -9651,9 +9677,22 @@ var ExecutionHandler = class {
|
|
|
9651
9677
|
}
|
|
9652
9678
|
continue;
|
|
9653
9679
|
}
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9680
|
+
let responseParts = [];
|
|
9681
|
+
if (messageResponse.result.streamedContent?.parts) {
|
|
9682
|
+
responseParts = messageResponse.result.streamedContent.parts;
|
|
9683
|
+
logger20.info(
|
|
9684
|
+
{ partsCount: responseParts.length },
|
|
9685
|
+
"Using streamed content for conversation history"
|
|
9686
|
+
);
|
|
9687
|
+
} else {
|
|
9688
|
+
responseParts = messageResponse.result.artifacts?.flatMap(
|
|
9689
|
+
(artifact) => artifact.parts || []
|
|
9690
|
+
) || [];
|
|
9691
|
+
logger20.info(
|
|
9692
|
+
{ partsCount: responseParts.length },
|
|
9693
|
+
"Using artifacts for conversation history (fallback)"
|
|
9694
|
+
);
|
|
9695
|
+
}
|
|
9657
9696
|
if (responseParts && responseParts.length > 0) {
|
|
9658
9697
|
const graphSessionData = graphSessionManager.getSession(requestId2);
|
|
9659
9698
|
if (graphSessionData) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20251009233425",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"traverse": "^0.6.11",
|
|
52
52
|
"ts-pattern": "^5.7.1",
|
|
53
53
|
"zod": "^4.1.11",
|
|
54
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
54
|
+
"@inkeep/agents-core": "^0.0.0-dev-20251009233425"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
57
|
"keytar": "^7.9.0"
|