n8n-nodes-mindrouter 0.2.2 → 0.3.0

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.
@@ -4,6 +4,7 @@ exports.MindRouterChatModel = void 0;
4
4
  const openai_1 = require("@langchain/openai");
5
5
  const n8n_workflow_1 = require("n8n-workflow");
6
6
  const api_1 = require("../shared/api");
7
+ const statusCallback_1 = require("../shared/statusCallback");
7
8
  class MindRouterChatModel {
8
9
  constructor() {
9
10
  this.description = {
@@ -128,6 +129,7 @@ class MindRouterChatModel {
128
129
  configuration: {
129
130
  baseURL: (0, api_1.normalizeBaseUrl)(credentials.baseUrl),
130
131
  },
132
+ callbacks: [new statusCallback_1.N8nExecutionStatusHandler(this)],
131
133
  });
132
134
  return {
133
135
  response: model,
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.N8nExecutionStatusHandler = void 0;
4
+ const base_1 = require("@langchain/core/callbacks/base");
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ class N8nExecutionStatusHandler extends base_1.BaseCallbackHandler {
7
+ constructor(context) {
8
+ super();
9
+ this.context = context;
10
+ this.name = 'mindRouterExecutionStatus';
11
+ this.runIndexes = new Map();
12
+ }
13
+ start(runId, payload) {
14
+ const { index } = this.context.addInputData(n8n_workflow_1.NodeConnectionTypes.AiLanguageModel, [
15
+ [{ json: { input: payload } }],
16
+ ]);
17
+ this.runIndexes.set(runId, index);
18
+ }
19
+ end(runId, payload) {
20
+ const index = this.runIndexes.get(runId);
21
+ if (index === undefined)
22
+ return;
23
+ this.runIndexes.delete(runId);
24
+ this.context.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiLanguageModel, index, [
25
+ [{ json: { output: payload } }],
26
+ ]);
27
+ }
28
+ handleChatModelStart(_llm, messages, runId) {
29
+ this.start(runId, messages);
30
+ }
31
+ handleLLMStart(_llm, prompts, runId) {
32
+ this.start(runId, prompts);
33
+ }
34
+ handleLLMEnd(output, runId) {
35
+ this.end(runId, output);
36
+ }
37
+ handleLLMError(error, runId) {
38
+ const index = this.runIndexes.get(runId);
39
+ if (index === undefined)
40
+ return;
41
+ this.runIndexes.delete(runId);
42
+ this.context.addOutputData(n8n_workflow_1.NodeConnectionTypes.AiLanguageModel, index, new n8n_workflow_1.NodeOperationError(this.context.getNode(), error.message));
43
+ }
44
+ }
45
+ exports.N8nExecutionStatusHandler = N8nExecutionStatusHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-mindrouter",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "n8n community node for MindRouter — unified gateway to AI models with Indonesian PII guardrails",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -53,6 +53,7 @@
53
53
  "n8n-workflow": "*"
54
54
  },
55
55
  "dependencies": {
56
+ "@langchain/core": "^1.2.9",
56
57
  "@langchain/openai": "^1.5.11"
57
58
  }
58
59
  }