@inkeep/agents-run-api 0.30.0 → 0.30.2
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 +48 -6
- package/dist/index.js +48 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -11431,7 +11431,7 @@ var VercelDataStreamHelper = _VercelDataStreamHelper;
|
|
|
11431
11431
|
function createVercelStreamHelper(writer) {
|
|
11432
11432
|
return new VercelDataStreamHelper(writer);
|
|
11433
11433
|
}
|
|
11434
|
-
var
|
|
11434
|
+
var BufferingStreamHelper = class {
|
|
11435
11435
|
constructor() {
|
|
11436
11436
|
__publicField(this, "capturedText", "");
|
|
11437
11437
|
__publicField(this, "capturedData", []);
|
|
@@ -11477,7 +11477,7 @@ var MCPStreamHelper = class {
|
|
|
11477
11477
|
async complete() {
|
|
11478
11478
|
}
|
|
11479
11479
|
/**
|
|
11480
|
-
* Get the captured response for
|
|
11480
|
+
* Get the captured response for non-streaming output
|
|
11481
11481
|
*/
|
|
11482
11482
|
getCapturedResponse() {
|
|
11483
11483
|
return {
|
|
@@ -11489,9 +11489,10 @@ var MCPStreamHelper = class {
|
|
|
11489
11489
|
};
|
|
11490
11490
|
}
|
|
11491
11491
|
};
|
|
11492
|
-
function
|
|
11493
|
-
return new
|
|
11492
|
+
function createBufferingStreamHelper() {
|
|
11493
|
+
return new BufferingStreamHelper();
|
|
11494
11494
|
}
|
|
11495
|
+
var createMCPStreamHelper = createBufferingStreamHelper;
|
|
11495
11496
|
|
|
11496
11497
|
// src/handlers/executionHandler.ts
|
|
11497
11498
|
var logger24 = agentsCore.getLogger("ExecutionHandler");
|
|
@@ -11831,7 +11832,7 @@ var ExecutionHandler = class {
|
|
|
11831
11832
|
logger24.info({}, "Cleaning up streamHelper");
|
|
11832
11833
|
unregisterStreamHelper(requestId2);
|
|
11833
11834
|
let response;
|
|
11834
|
-
if (sseHelper instanceof
|
|
11835
|
+
if (sseHelper instanceof BufferingStreamHelper) {
|
|
11835
11836
|
const captured = sseHelper.getCapturedResponse();
|
|
11836
11837
|
response = captured.text || "No response content";
|
|
11837
11838
|
}
|
|
@@ -12304,7 +12305,10 @@ var chatDataStreamRoute = zodOpenapi.createRoute({
|
|
|
12304
12305
|
),
|
|
12305
12306
|
id: zodOpenapi.z.string().optional(),
|
|
12306
12307
|
conversationId: zodOpenapi.z.string().optional(),
|
|
12307
|
-
|
|
12308
|
+
stream: zodOpenapi.z.boolean().optional().describe("Whether to stream the response").default(true),
|
|
12309
|
+
max_tokens: zodOpenapi.z.number().optional().describe("Maximum tokens to generate"),
|
|
12310
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional().describe("Headers data for template processing"),
|
|
12311
|
+
runConfig: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional().describe("Run configuration")
|
|
12308
12312
|
})
|
|
12309
12313
|
}
|
|
12310
12314
|
}
|
|
@@ -12422,6 +12426,44 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
12422
12426
|
"database.operation": "insert"
|
|
12423
12427
|
});
|
|
12424
12428
|
}
|
|
12429
|
+
const shouldStream = body.stream !== false;
|
|
12430
|
+
if (!shouldStream) {
|
|
12431
|
+
const emitOperationsHeader = c.req.header("x-emit-operations");
|
|
12432
|
+
const emitOperations = emitOperationsHeader === "true";
|
|
12433
|
+
const bufferingHelper = createBufferingStreamHelper();
|
|
12434
|
+
const executionHandler = new ExecutionHandler();
|
|
12435
|
+
const result = await executionHandler.execute({
|
|
12436
|
+
executionContext,
|
|
12437
|
+
conversationId,
|
|
12438
|
+
userMessage: userText,
|
|
12439
|
+
initialAgentId: subAgentId,
|
|
12440
|
+
requestId: `chat-${Date.now()}`,
|
|
12441
|
+
sseHelper: bufferingHelper,
|
|
12442
|
+
emitOperations
|
|
12443
|
+
});
|
|
12444
|
+
const captured = bufferingHelper.getCapturedResponse();
|
|
12445
|
+
return c.json({
|
|
12446
|
+
id: `chat-${Date.now()}`,
|
|
12447
|
+
object: "chat.completion",
|
|
12448
|
+
created: Math.floor(Date.now() / 1e3),
|
|
12449
|
+
model: agentName,
|
|
12450
|
+
choices: [
|
|
12451
|
+
{
|
|
12452
|
+
index: 0,
|
|
12453
|
+
message: {
|
|
12454
|
+
role: "assistant",
|
|
12455
|
+
content: captured.hasError ? captured.errorMessage : captured.text
|
|
12456
|
+
},
|
|
12457
|
+
finish_reason: result.success && !captured.hasError ? "stop" : "error"
|
|
12458
|
+
}
|
|
12459
|
+
],
|
|
12460
|
+
usage: {
|
|
12461
|
+
prompt_tokens: 0,
|
|
12462
|
+
completion_tokens: 0,
|
|
12463
|
+
total_tokens: 0
|
|
12464
|
+
}
|
|
12465
|
+
});
|
|
12466
|
+
}
|
|
12425
12467
|
const dataStream = ai.createUIMessageStream({
|
|
12426
12468
|
execute: async ({ writer }) => {
|
|
12427
12469
|
const streamHelper = createVercelStreamHelper(writer);
|
package/dist/index.js
CHANGED
|
@@ -9943,7 +9943,7 @@ var VercelDataStreamHelper = _VercelDataStreamHelper;
|
|
|
9943
9943
|
function createVercelStreamHelper(writer) {
|
|
9944
9944
|
return new VercelDataStreamHelper(writer);
|
|
9945
9945
|
}
|
|
9946
|
-
var
|
|
9946
|
+
var BufferingStreamHelper = class {
|
|
9947
9947
|
constructor() {
|
|
9948
9948
|
__publicField(this, "capturedText", "");
|
|
9949
9949
|
__publicField(this, "capturedData", []);
|
|
@@ -9989,7 +9989,7 @@ var MCPStreamHelper = class {
|
|
|
9989
9989
|
async complete() {
|
|
9990
9990
|
}
|
|
9991
9991
|
/**
|
|
9992
|
-
* Get the captured response for
|
|
9992
|
+
* Get the captured response for non-streaming output
|
|
9993
9993
|
*/
|
|
9994
9994
|
getCapturedResponse() {
|
|
9995
9995
|
return {
|
|
@@ -10001,9 +10001,10 @@ var MCPStreamHelper = class {
|
|
|
10001
10001
|
};
|
|
10002
10002
|
}
|
|
10003
10003
|
};
|
|
10004
|
-
function
|
|
10005
|
-
return new
|
|
10004
|
+
function createBufferingStreamHelper() {
|
|
10005
|
+
return new BufferingStreamHelper();
|
|
10006
10006
|
}
|
|
10007
|
+
var createMCPStreamHelper = createBufferingStreamHelper;
|
|
10007
10008
|
|
|
10008
10009
|
// src/handlers/executionHandler.ts
|
|
10009
10010
|
var logger20 = getLogger("ExecutionHandler");
|
|
@@ -10343,7 +10344,7 @@ var ExecutionHandler = class {
|
|
|
10343
10344
|
logger20.info({}, "Cleaning up streamHelper");
|
|
10344
10345
|
unregisterStreamHelper(requestId2);
|
|
10345
10346
|
let response;
|
|
10346
|
-
if (sseHelper instanceof
|
|
10347
|
+
if (sseHelper instanceof BufferingStreamHelper) {
|
|
10347
10348
|
const captured = sseHelper.getCapturedResponse();
|
|
10348
10349
|
response = captured.text || "No response content";
|
|
10349
10350
|
}
|
|
@@ -10811,7 +10812,10 @@ var chatDataStreamRoute = createRoute({
|
|
|
10811
10812
|
),
|
|
10812
10813
|
id: z$1.string().optional(),
|
|
10813
10814
|
conversationId: z$1.string().optional(),
|
|
10814
|
-
|
|
10815
|
+
stream: z$1.boolean().optional().describe("Whether to stream the response").default(true),
|
|
10816
|
+
max_tokens: z$1.number().optional().describe("Maximum tokens to generate"),
|
|
10817
|
+
headers: z$1.record(z$1.string(), z$1.unknown()).optional().describe("Headers data for template processing"),
|
|
10818
|
+
runConfig: z$1.record(z$1.string(), z$1.unknown()).optional().describe("Run configuration")
|
|
10815
10819
|
})
|
|
10816
10820
|
}
|
|
10817
10821
|
}
|
|
@@ -10929,6 +10933,44 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
10929
10933
|
"database.operation": "insert"
|
|
10930
10934
|
});
|
|
10931
10935
|
}
|
|
10936
|
+
const shouldStream = body.stream !== false;
|
|
10937
|
+
if (!shouldStream) {
|
|
10938
|
+
const emitOperationsHeader = c.req.header("x-emit-operations");
|
|
10939
|
+
const emitOperations = emitOperationsHeader === "true";
|
|
10940
|
+
const bufferingHelper = createBufferingStreamHelper();
|
|
10941
|
+
const executionHandler = new ExecutionHandler();
|
|
10942
|
+
const result = await executionHandler.execute({
|
|
10943
|
+
executionContext,
|
|
10944
|
+
conversationId,
|
|
10945
|
+
userMessage: userText,
|
|
10946
|
+
initialAgentId: subAgentId,
|
|
10947
|
+
requestId: `chat-${Date.now()}`,
|
|
10948
|
+
sseHelper: bufferingHelper,
|
|
10949
|
+
emitOperations
|
|
10950
|
+
});
|
|
10951
|
+
const captured = bufferingHelper.getCapturedResponse();
|
|
10952
|
+
return c.json({
|
|
10953
|
+
id: `chat-${Date.now()}`,
|
|
10954
|
+
object: "chat.completion",
|
|
10955
|
+
created: Math.floor(Date.now() / 1e3),
|
|
10956
|
+
model: agentName,
|
|
10957
|
+
choices: [
|
|
10958
|
+
{
|
|
10959
|
+
index: 0,
|
|
10960
|
+
message: {
|
|
10961
|
+
role: "assistant",
|
|
10962
|
+
content: captured.hasError ? captured.errorMessage : captured.text
|
|
10963
|
+
},
|
|
10964
|
+
finish_reason: result.success && !captured.hasError ? "stop" : "error"
|
|
10965
|
+
}
|
|
10966
|
+
],
|
|
10967
|
+
usage: {
|
|
10968
|
+
prompt_tokens: 0,
|
|
10969
|
+
completion_tokens: 0,
|
|
10970
|
+
total_tokens: 0
|
|
10971
|
+
}
|
|
10972
|
+
});
|
|
10973
|
+
}
|
|
10932
10974
|
const dataStream = createUIMessageStream({
|
|
10933
10975
|
execute: async ({ writer }) => {
|
|
10934
10976
|
const streamHelper = createVercelStreamHelper(writer);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.2",
|
|
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",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"traverse": "^0.6.11",
|
|
53
53
|
"ts-pattern": "^5.7.1",
|
|
54
54
|
"zod": "^4.1.11",
|
|
55
|
-
"@inkeep/agents-core": "^0.30.
|
|
55
|
+
"@inkeep/agents-core": "^0.30.2"
|
|
56
56
|
},
|
|
57
57
|
"optionalDependencies": {
|
|
58
58
|
"keytar": "^7.9.0"
|