@flutchai/flutch-sdk 0.1.15 → 0.1.17
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 +49 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +49 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1162,6 +1162,7 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1162
1162
|
constructor(eventProcessor: EventProcessor, configService?: ConfigService);
|
|
1163
1163
|
invokeGraph(graph: any, config: any, signal?: AbortSignal): Promise<any>;
|
|
1164
1164
|
streamGraph(graph: any, config: any, onPartial: (chunk: string) => void, signal?: AbortSignal): Promise<any>;
|
|
1165
|
+
private sendTraceFromAccumulator;
|
|
1165
1166
|
private sendMetricsWebhook;
|
|
1166
1167
|
private sendTraceEventsBatch;
|
|
1167
1168
|
private processGraphResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -1162,6 +1162,7 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1162
1162
|
constructor(eventProcessor: EventProcessor, configService?: ConfigService);
|
|
1163
1163
|
invokeGraph(graph: any, config: any, signal?: AbortSignal): Promise<any>;
|
|
1164
1164
|
streamGraph(graph: any, config: any, onPartial: (chunk: string) => void, signal?: AbortSignal): Promise<any>;
|
|
1165
|
+
private sendTraceFromAccumulator;
|
|
1165
1166
|
private sendMetricsWebhook;
|
|
1166
1167
|
private sendTraceEventsBatch;
|
|
1167
1168
|
private processGraphResult;
|
package/dist/index.js
CHANGED
|
@@ -4803,6 +4803,8 @@ var LangGraphEngine = class {
|
|
|
4803
4803
|
return this.processGraphResult(result);
|
|
4804
4804
|
}
|
|
4805
4805
|
async streamGraph(graph, config, onPartial, signal) {
|
|
4806
|
+
const acc = this.eventProcessor.createAccumulator();
|
|
4807
|
+
let streamError = null;
|
|
4806
4808
|
try {
|
|
4807
4809
|
if (signal) {
|
|
4808
4810
|
config.signal = signal;
|
|
@@ -4812,7 +4814,6 @@ var LangGraphEngine = class {
|
|
|
4812
4814
|
version: "v2"
|
|
4813
4815
|
// Important for correct operation
|
|
4814
4816
|
});
|
|
4815
|
-
const acc = this.eventProcessor.createAccumulator();
|
|
4816
4817
|
for await (const event of eventStream) {
|
|
4817
4818
|
try {
|
|
4818
4819
|
this.eventProcessor.processEvent(acc, event, onPartial);
|
|
@@ -4822,20 +4823,44 @@ var LangGraphEngine = class {
|
|
|
4822
4823
|
);
|
|
4823
4824
|
}
|
|
4824
4825
|
}
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4826
|
+
} catch (error) {
|
|
4827
|
+
streamError = error instanceof Error ? error : new Error(String(error));
|
|
4828
|
+
this.logger.error(
|
|
4829
|
+
`[STREAM-ERROR] Error in streamGraph: ${streamError.message}`
|
|
4830
|
+
);
|
|
4831
|
+
this.logger.error(`[STREAM-ERROR] Stack trace: ${streamError.stack}`);
|
|
4832
|
+
} finally {
|
|
4833
|
+
await this.sendTraceFromAccumulator(acc, config, streamError);
|
|
4834
|
+
}
|
|
4835
|
+
const { content, trace } = this.eventProcessor.getResult(acc);
|
|
4836
|
+
this.logger.debug("[STREAM-RESULT] Got result from EventProcessor", {
|
|
4837
|
+
hasContent: !!content,
|
|
4838
|
+
hasContext: !!config.configurable?.context,
|
|
4839
|
+
hasTrace: !!trace,
|
|
4840
|
+
traceEvents: trace?.events?.length || 0,
|
|
4841
|
+
hadError: !!streamError
|
|
4842
|
+
});
|
|
4843
|
+
if (streamError) {
|
|
4844
|
+
throw streamError;
|
|
4845
|
+
}
|
|
4846
|
+
return content;
|
|
4847
|
+
}
|
|
4848
|
+
/**
|
|
4849
|
+
* Extract trace from accumulator and send to backend webhook
|
|
4850
|
+
* Called in finally block to ensure trace is sent even on errors
|
|
4851
|
+
*/
|
|
4852
|
+
async sendTraceFromAccumulator(acc, config, error) {
|
|
4853
|
+
try {
|
|
4854
|
+
const { trace } = this.eventProcessor.getResult(acc);
|
|
4832
4855
|
if (trace && trace.events.length > 0 && config.configurable?.context) {
|
|
4833
4856
|
const context = config.configurable.context;
|
|
4834
4857
|
this.logger.debug("[TRACE-WEBHOOK] Sending trace events batch", {
|
|
4835
4858
|
messageId: context.messageId,
|
|
4836
4859
|
totalEvents: trace.totalEvents,
|
|
4837
4860
|
eventsArrayLength: trace.events.length,
|
|
4838
|
-
firstEventType: trace.events[0]?.type
|
|
4861
|
+
firstEventType: trace.events[0]?.type,
|
|
4862
|
+
hadError: !!error,
|
|
4863
|
+
errorMessage: error?.message
|
|
4839
4864
|
});
|
|
4840
4865
|
await this.sendTraceEventsBatch({
|
|
4841
4866
|
messageId: context.messageId || "unknown",
|
|
@@ -4846,24 +4871,28 @@ var LangGraphEngine = class {
|
|
|
4846
4871
|
events: trace.events,
|
|
4847
4872
|
totalEvents: trace.totalEvents,
|
|
4848
4873
|
startedAt: trace.startedAt,
|
|
4849
|
-
completedAt: trace.completedAt,
|
|
4850
|
-
durationMs: trace.durationMs
|
|
4874
|
+
completedAt: trace.completedAt || Date.now(),
|
|
4875
|
+
durationMs: trace.durationMs || Date.now() - trace.startedAt,
|
|
4876
|
+
status: error ? "error" : "success",
|
|
4877
|
+
error: error ? { message: error.message, name: error.name } : void 0
|
|
4851
4878
|
});
|
|
4852
4879
|
} else {
|
|
4853
4880
|
this.logger.debug("[TRACE-WEBHOOK] Skipping webhook", {
|
|
4854
4881
|
hasTrace: !!trace,
|
|
4855
4882
|
traceEvents: trace?.events?.length || 0,
|
|
4856
4883
|
hasContext: !!config.configurable?.context,
|
|
4857
|
-
contextKeys: config.configurable?.context ? Object.keys(config.configurable.context) : []
|
|
4884
|
+
contextKeys: config.configurable?.context ? Object.keys(config.configurable.context) : [],
|
|
4885
|
+
hadError: !!error
|
|
4858
4886
|
});
|
|
4859
4887
|
}
|
|
4860
|
-
|
|
4861
|
-
} catch (error) {
|
|
4888
|
+
} catch (webhookError) {
|
|
4862
4889
|
this.logger.error(
|
|
4863
|
-
|
|
4890
|
+
"[TRACE-WEBHOOK] Failed to send trace in finally block",
|
|
4891
|
+
{
|
|
4892
|
+
error: webhookError instanceof Error ? webhookError.message : String(webhookError),
|
|
4893
|
+
originalError: error?.message
|
|
4894
|
+
}
|
|
4864
4895
|
);
|
|
4865
|
-
this.logger.error(`[STREAM-ERROR] Stack trace: ${error.stack}`);
|
|
4866
|
-
throw error;
|
|
4867
4896
|
}
|
|
4868
4897
|
}
|
|
4869
4898
|
/**
|
|
@@ -4930,6 +4959,8 @@ var LangGraphEngine = class {
|
|
|
4930
4959
|
startedAt: payload.startedAt,
|
|
4931
4960
|
completedAt: payload.completedAt,
|
|
4932
4961
|
durationMs: payload.durationMs,
|
|
4962
|
+
status: payload.status || "success",
|
|
4963
|
+
error: payload.error,
|
|
4933
4964
|
events: payload.events.map((event) => ({
|
|
4934
4965
|
timestamp: event.timestamp ? new Date(event.timestamp).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
4935
4966
|
meta: {
|
|
@@ -5326,11 +5357,7 @@ var McpConverter = class _McpConverter {
|
|
|
5326
5357
|
let zodProp;
|
|
5327
5358
|
switch (prop.type) {
|
|
5328
5359
|
case "string":
|
|
5329
|
-
|
|
5330
|
-
zodProp = z.enum(prop.enum);
|
|
5331
|
-
} else {
|
|
5332
|
-
zodProp = z.string();
|
|
5333
|
-
}
|
|
5360
|
+
zodProp = z.string();
|
|
5334
5361
|
break;
|
|
5335
5362
|
case "number":
|
|
5336
5363
|
zodProp = z.number();
|