@flutchai/flutch-sdk 0.7.7 → 0.7.8
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 +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -366,8 +366,9 @@ declare class GraphController {
|
|
|
366
366
|
timestamp: string;
|
|
367
367
|
}>;
|
|
368
368
|
getSupportedGraphTypes(): Promise<string[]>;
|
|
369
|
-
generateAnswer(payload: IGraphRequestPayload): Promise<IGraphResponsePayload>;
|
|
369
|
+
generateAnswer(payload: IGraphRequestPayload, res: Response): Promise<IGraphResponsePayload>;
|
|
370
370
|
streamAnswer(payload: IGraphRequestPayload, res: Response): Promise<void>;
|
|
371
|
+
private cancelOnDisconnect;
|
|
371
372
|
cancelGeneration(requestId: string): Promise<{
|
|
372
373
|
message: string;
|
|
373
374
|
}>;
|
|
@@ -1428,7 +1429,7 @@ declare class McpRuntimeHttpClient implements McpRuntimeClient {
|
|
|
1428
1429
|
private readonly baseUrl;
|
|
1429
1430
|
constructor(mcpRuntimeUrl?: string);
|
|
1430
1431
|
getTools(): Promise<McpTool[]>;
|
|
1431
|
-
executeTool(name: string, args: any, context?: any, mcpServers?: Record<string, any>[]): Promise<ToolExecutionResult>;
|
|
1432
|
+
executeTool(name: string, args: any, context?: any, mcpServers?: Record<string, any>[], signal?: AbortSignal): Promise<ToolExecutionResult>;
|
|
1432
1433
|
getToolStats(): Promise<any>;
|
|
1433
1434
|
isHealthy(): Promise<boolean>;
|
|
1434
1435
|
executeToolWithEvents(toolCallId: string, toolName: string, enrichedArgs: Record<string, any>, executionContext: Record<string, any>, config?: RunnableConfig, mcpServers?: Record<string, any>[]): Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -366,8 +366,9 @@ declare class GraphController {
|
|
|
366
366
|
timestamp: string;
|
|
367
367
|
}>;
|
|
368
368
|
getSupportedGraphTypes(): Promise<string[]>;
|
|
369
|
-
generateAnswer(payload: IGraphRequestPayload): Promise<IGraphResponsePayload>;
|
|
369
|
+
generateAnswer(payload: IGraphRequestPayload, res: Response): Promise<IGraphResponsePayload>;
|
|
370
370
|
streamAnswer(payload: IGraphRequestPayload, res: Response): Promise<void>;
|
|
371
|
+
private cancelOnDisconnect;
|
|
371
372
|
cancelGeneration(requestId: string): Promise<{
|
|
372
373
|
message: string;
|
|
373
374
|
}>;
|
|
@@ -1428,7 +1429,7 @@ declare class McpRuntimeHttpClient implements McpRuntimeClient {
|
|
|
1428
1429
|
private readonly baseUrl;
|
|
1429
1430
|
constructor(mcpRuntimeUrl?: string);
|
|
1430
1431
|
getTools(): Promise<McpTool[]>;
|
|
1431
|
-
executeTool(name: string, args: any, context?: any, mcpServers?: Record<string, any>[]): Promise<ToolExecutionResult>;
|
|
1432
|
+
executeTool(name: string, args: any, context?: any, mcpServers?: Record<string, any>[], signal?: AbortSignal): Promise<ToolExecutionResult>;
|
|
1432
1433
|
getToolStats(): Promise<any>;
|
|
1433
1434
|
isHealthy(): Promise<boolean>;
|
|
1434
1435
|
executeToolWithEvents(toolCallId: string, toolName: string, enrichedArgs: Record<string, any>, executionContext: Record<string, any>, config?: RunnableConfig, mcpServers?: Record<string, any>[]): Promise<{
|
package/dist/index.js
CHANGED
|
@@ -2101,7 +2101,8 @@ var GraphController = class _GraphController {
|
|
|
2101
2101
|
async getSupportedGraphTypes() {
|
|
2102
2102
|
return this.graphService.getSupportedGraphTypes();
|
|
2103
2103
|
}
|
|
2104
|
-
async generateAnswer(payload) {
|
|
2104
|
+
async generateAnswer(payload, res) {
|
|
2105
|
+
this.cancelOnDisconnect(res, payload.requestId);
|
|
2105
2106
|
try {
|
|
2106
2107
|
return await this.graphService.generateAnswer(payload);
|
|
2107
2108
|
} catch (error) {
|
|
@@ -2114,6 +2115,7 @@ var GraphController = class _GraphController {
|
|
|
2114
2115
|
res.setHeader("Transfer-Encoding", "chunked");
|
|
2115
2116
|
res.setHeader("Cache-Control", "no-cache");
|
|
2116
2117
|
res.setHeader("Connection", "keep-alive");
|
|
2118
|
+
this.cancelOnDisconnect(res, payload.requestId);
|
|
2117
2119
|
try {
|
|
2118
2120
|
this.logger.debug(`[CONTROLLER] Starting streamAnswer for requestId: ${payload.requestId}`);
|
|
2119
2121
|
const result = await this.graphService.streamAnswer(payload, (chunk) => {
|
|
@@ -2151,6 +2153,19 @@ var GraphController = class _GraphController {
|
|
|
2151
2153
|
res.end();
|
|
2152
2154
|
}
|
|
2153
2155
|
}
|
|
2156
|
+
/**
|
|
2157
|
+
* A caller that hangs up before the answer is done — its own timeout, a
|
|
2158
|
+
* restart, a cancelled parent run — no longer waits for it, so the run is
|
|
2159
|
+
* cancelled: left going, it keeps calling models and tools nobody reads.
|
|
2160
|
+
*/
|
|
2161
|
+
cancelOnDisconnect(res, requestId) {
|
|
2162
|
+
if (!requestId) return;
|
|
2163
|
+
res.on("close", () => {
|
|
2164
|
+
if (res.writableFinished) return;
|
|
2165
|
+
this.logger.warn(`[CONTROLLER] Caller disconnected before the answer: cancelling ${requestId}`);
|
|
2166
|
+
this.graphService.cancelGeneration(requestId).catch((error) => this.logger.warn(`[CONTROLLER] Cancel after disconnect failed for ${requestId}: ${error.message}`));
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2154
2169
|
async cancelGeneration(requestId) {
|
|
2155
2170
|
try {
|
|
2156
2171
|
await this.graphService.cancelGeneration(requestId);
|
|
@@ -2224,9 +2239,13 @@ _ts_decorate8([
|
|
|
2224
2239
|
description: "Answer generated"
|
|
2225
2240
|
}),
|
|
2226
2241
|
_ts_param4(0, Body()),
|
|
2242
|
+
_ts_param4(1, Res({
|
|
2243
|
+
passthrough: true
|
|
2244
|
+
})),
|
|
2227
2245
|
_ts_metadata6("design:type", Function),
|
|
2228
2246
|
_ts_metadata6("design:paramtypes", [
|
|
2229
|
-
typeof IGraphRequestPayload === "undefined" ? Object : IGraphRequestPayload
|
|
2247
|
+
typeof IGraphRequestPayload === "undefined" ? Object : IGraphRequestPayload,
|
|
2248
|
+
typeof Response === "undefined" ? Object : Response
|
|
2230
2249
|
]),
|
|
2231
2250
|
_ts_metadata6("design:returntype", Promise)
|
|
2232
2251
|
], GraphController.prototype, "generateAnswer", null);
|
|
@@ -7007,7 +7026,7 @@ var McpRuntimeHttpClient = class _McpRuntimeHttpClient {
|
|
|
7007
7026
|
/**
|
|
7008
7027
|
* Execute a tool by name with given arguments
|
|
7009
7028
|
*/
|
|
7010
|
-
async executeTool(name, args, context, mcpServers) {
|
|
7029
|
+
async executeTool(name, args, context, mcpServers, signal) {
|
|
7011
7030
|
try {
|
|
7012
7031
|
this.logger.debug(`Executing tool: ${name} with args:`, args);
|
|
7013
7032
|
const payload = {
|
|
@@ -7020,7 +7039,9 @@ var McpRuntimeHttpClient = class _McpRuntimeHttpClient {
|
|
|
7020
7039
|
if (mcpServers && mcpServers.length > 0) {
|
|
7021
7040
|
payload.mcpServers = mcpServers;
|
|
7022
7041
|
}
|
|
7023
|
-
const response = await this.httpClient.post("/tools/execute", payload
|
|
7042
|
+
const response = signal ? await this.httpClient.post("/tools/execute", payload, {
|
|
7043
|
+
signal
|
|
7044
|
+
}) : await this.httpClient.post("/tools/execute", payload);
|
|
7024
7045
|
this.logger.log(`Tool ${name} executed successfully`);
|
|
7025
7046
|
return response.data;
|
|
7026
7047
|
} catch (error) {
|
|
@@ -7088,7 +7109,7 @@ var McpRuntimeHttpClient = class _McpRuntimeHttpClient {
|
|
|
7088
7109
|
toolName
|
|
7089
7110
|
]
|
|
7090
7111
|
}, JSON.stringify(enrichedArgs), parsedConfig.runId, void 0, parsedConfig.tags, parsedConfig.metadata, toolName);
|
|
7091
|
-
const result = await this.executeTool(toolName, enrichedArgs, executionContext, mcpServers);
|
|
7112
|
+
const result = await this.executeTool(toolName, enrichedArgs, executionContext, mcpServers, config?.signal);
|
|
7092
7113
|
const content = result.success ? JSON.stringify(result) : result.error || JSON.stringify(result);
|
|
7093
7114
|
await runManager?.handleToolEnd(content);
|
|
7094
7115
|
return {
|