n8n-nodes-agnicwallet 1.0.5 → 1.0.7

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.
@@ -1,4 +1,4 @@
1
- import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
1
+ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from "n8n-workflow";
2
2
  export declare class AgnicWalletApi implements ICredentialType {
3
3
  name: string;
4
4
  displayName: string;
@@ -3,37 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgnicWalletApi = void 0;
4
4
  class AgnicWalletApi {
5
5
  constructor() {
6
- this.name = 'agnicWalletApi';
7
- this.displayName = 'AgnicWallet API';
8
- this.documentationUrl = 'https://github.com/agnicpay/agnicwallet-project#setup';
6
+ this.name = "agnicWalletApi";
7
+ this.displayName = "AgnicWallet API";
8
+ this.documentationUrl = "https://github.com/agnicpay/n8n-X402-AgnicWallet#setup";
9
9
  this.properties = [
10
10
  {
11
- displayName: 'User ID',
12
- name: 'userId',
13
- type: 'string',
14
- default: '',
11
+ displayName: "User ID",
12
+ name: "userId",
13
+ type: "string",
14
+ default: "",
15
15
  required: true,
16
- description: 'Your AgnicWallet user ID (from dashboard)',
17
- placeholder: 'user_2kX9mNz8pQw7VbC',
16
+ description: "Your AgnicWallet user ID (from dashboard)",
17
+ placeholder: "user_2kX9mNz8pQw7VbC",
18
18
  },
19
19
  {
20
- displayName: 'API Token',
21
- name: 'apiToken',
22
- type: 'string',
20
+ displayName: "API Token",
21
+ name: "apiToken",
22
+ type: "string",
23
23
  typeOptions: {
24
24
  password: true,
25
25
  },
26
- default: '',
26
+ default: "",
27
27
  required: true,
28
- description: 'Your AgnicWallet API token (starts with agnic_tok_)',
29
- placeholder: 'agnic_tok_sk_live_...',
28
+ description: "Your AgnicWallet API token (starts with agnic_tok_)",
29
+ placeholder: "agnic_tok_sk_live_...",
30
30
  },
31
31
  ];
32
32
  this.authenticate = {
33
- type: 'generic',
33
+ type: "generic",
34
34
  properties: {
35
35
  headers: {
36
- 'X-Agnic-Token': '={{$credentials.apiToken}}',
36
+ "X-Agnic-Token": "={{$credentials.apiToken}}",
37
37
  },
38
38
  },
39
39
  };
@@ -1,4 +1,4 @@
1
- import { ICredentialType, INodeProperties } from 'n8n-workflow';
1
+ import { ICredentialType, INodeProperties } from "n8n-workflow";
2
2
  export declare class AgnicWalletOAuth2Api implements ICredentialType {
3
3
  name: string;
4
4
  extends: string[];
@@ -3,88 +3,88 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgnicWalletOAuth2Api = void 0;
4
4
  class AgnicWalletOAuth2Api {
5
5
  constructor() {
6
- this.name = 'agnicWalletOAuth2Api';
7
- this.extends = ['oAuth2Api'];
8
- this.displayName = 'AgnicWallet OAuth2 API';
9
- this.documentationUrl = 'https://github.com/agnicpay/agnicwallet-project/blob/main/OAUTH_COMPLETE_GUIDE.md';
6
+ this.name = "agnicWalletOAuth2Api";
7
+ this.extends = ["oAuth2Api"];
8
+ this.displayName = "AgnicWallet OAuth2 API";
9
+ this.documentationUrl = "https://github.com/agnicpay/n8n-X402-AgnicWallet#readme";
10
10
  this.properties = [
11
11
  {
12
- displayName: 'Grant Type',
13
- name: 'grantType',
14
- type: 'hidden',
15
- default: 'authorizationCode',
12
+ displayName: "Grant Type",
13
+ name: "grantType",
14
+ type: "hidden",
15
+ default: "authorizationCode",
16
16
  },
17
17
  {
18
- displayName: 'Authorization URL',
19
- name: 'authUrl',
20
- type: 'string',
21
- default: 'https://api.agnicpay.xyz/oauth/authorize',
18
+ displayName: "Authorization URL",
19
+ name: "authUrl",
20
+ type: "string",
21
+ default: "https://api.agnicpay.xyz/oauth/authorize",
22
22
  required: true,
23
- description: 'The OAuth2 authorization endpoint',
23
+ description: "The OAuth2 authorization endpoint",
24
24
  },
25
25
  {
26
- displayName: 'Access Token URL',
27
- name: 'accessTokenUrl',
28
- type: 'string',
29
- default: 'https://api.agnicpay.xyz/oauth/token',
26
+ displayName: "Access Token URL",
27
+ name: "accessTokenUrl",
28
+ type: "string",
29
+ default: "https://api.agnicpay.xyz/oauth/token",
30
30
  required: true,
31
- description: 'The OAuth2 token endpoint',
31
+ description: "The OAuth2 token endpoint",
32
32
  },
33
33
  {
34
- displayName: 'Client ID',
35
- name: 'clientId',
36
- type: 'string',
37
- default: 'n8n_default',
34
+ displayName: "Client ID",
35
+ name: "clientId",
36
+ type: "string",
37
+ default: "n8n_default",
38
38
  required: true,
39
- description: 'OAuth2 Client ID (default: n8n_default)',
39
+ description: "OAuth2 Client ID (default: n8n_default)",
40
40
  },
41
41
  {
42
- displayName: 'Client Secret',
43
- name: 'clientSecret',
44
- type: 'string',
42
+ displayName: "Client Secret",
43
+ name: "clientSecret",
44
+ type: "string",
45
45
  typeOptions: {
46
46
  password: true,
47
47
  },
48
- default: '',
49
- description: 'OAuth2 Client Secret (optional for PKCE)',
48
+ default: "",
49
+ description: "OAuth2 Client Secret (optional for PKCE)",
50
50
  },
51
51
  {
52
- displayName: 'Scope',
53
- name: 'scope',
54
- type: 'string',
55
- default: 'payments:sign balance:read',
56
- description: 'OAuth2 scopes',
52
+ displayName: "Scope",
53
+ name: "scope",
54
+ type: "string",
55
+ default: "payments:sign balance:read",
56
+ description: "OAuth2 scopes",
57
57
  },
58
58
  {
59
- displayName: 'Auth URI Query Parameters',
60
- name: 'authQueryParameters',
61
- type: 'string',
62
- default: '',
63
- description: 'Additional query parameters for authorization URL',
59
+ displayName: "Auth URI Query Parameters",
60
+ name: "authQueryParameters",
61
+ type: "string",
62
+ default: "",
63
+ description: "Additional query parameters for authorization URL",
64
64
  },
65
65
  {
66
- displayName: 'Authentication',
67
- name: 'authentication',
68
- type: 'options',
66
+ displayName: "Authentication",
67
+ name: "authentication",
68
+ type: "options",
69
69
  options: [
70
70
  {
71
- name: 'Body',
72
- value: 'body',
71
+ name: "Body",
72
+ value: "body",
73
73
  },
74
74
  {
75
- name: 'Header',
76
- value: 'header',
75
+ name: "Header",
76
+ value: "header",
77
77
  },
78
78
  ],
79
- default: 'body',
80
- description: 'How to send credentials',
79
+ default: "body",
80
+ description: "How to send credentials",
81
81
  },
82
82
  {
83
- displayName: 'Use PKCE',
84
- name: 'usePKCE',
85
- type: 'boolean',
83
+ displayName: "Use PKCE",
84
+ name: "usePKCE",
85
+ type: "boolean",
86
86
  default: true,
87
- description: 'Whether to use PKCE (Proof Key for Code Exchange)',
87
+ description: "Whether to use PKCE (Proof Key for Code Exchange)",
88
88
  },
89
89
  ];
90
90
  }
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from "n8n-workflow";
2
+ export declare class AgnicAI implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,422 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgnicAI = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class AgnicAI {
6
+ constructor() {
7
+ this.description = {
8
+ displayName: "AgnicAI",
9
+ name: "agnicAI",
10
+ group: ["transform"],
11
+ version: 1.0,
12
+ description: "Access various language models through AgnicPay AI Gateway with X402 payment support. Use this node in regular workflows to call AI models.",
13
+ defaults: {
14
+ name: "AgnicAI",
15
+ },
16
+ icon: "file:AgnicAI.png",
17
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
18
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
19
+ credentials: [
20
+ {
21
+ name: "agnicWalletOAuth2Api",
22
+ required: false,
23
+ displayOptions: {
24
+ show: {
25
+ authentication: ["oAuth2"],
26
+ },
27
+ },
28
+ },
29
+ {
30
+ name: "agnicWalletApi",
31
+ required: false,
32
+ displayOptions: {
33
+ show: {
34
+ authentication: ["apiKey"],
35
+ },
36
+ },
37
+ },
38
+ ],
39
+ properties: [
40
+ {
41
+ displayName: "Authentication",
42
+ name: "authentication",
43
+ type: "options",
44
+ options: [
45
+ {
46
+ name: "OAuth2",
47
+ value: "oAuth2",
48
+ description: "Recommended: Connect your account",
49
+ },
50
+ {
51
+ name: "API Key",
52
+ value: "apiKey",
53
+ description: "For CI/CD or programmatic access",
54
+ },
55
+ ],
56
+ default: "oAuth2",
57
+ description: "How to authenticate with AgnicWallet",
58
+ },
59
+ {
60
+ displayName: "Model",
61
+ name: "model",
62
+ type: "options",
63
+ typeOptions: {
64
+ allowCustomValues: true,
65
+ },
66
+ options: [
67
+ {
68
+ name: "Simple (GPT-4o Mini)",
69
+ value: "openai/gpt-4o-mini",
70
+ description: "Simple and fast default option - GPT-4o Mini",
71
+ },
72
+ {
73
+ name: "OpenAI - GPT-4o",
74
+ value: "openai/gpt-4o",
75
+ description: "OpenAI's latest GPT-4o model",
76
+ },
77
+ {
78
+ name: "OpenAI - GPT-4o Mini",
79
+ value: "openai/gpt-4o-mini",
80
+ description: "Fast and efficient GPT-4o Mini",
81
+ },
82
+ {
83
+ name: "OpenAI - GPT-4 Turbo",
84
+ value: "openai/gpt-4-turbo",
85
+ description: "GPT-4 Turbo with extended context",
86
+ },
87
+ {
88
+ name: "OpenAI - GPT-4",
89
+ value: "openai/gpt-4",
90
+ description: "OpenAI GPT-4",
91
+ },
92
+ {
93
+ name: "OpenAI - GPT-3.5 Turbo",
94
+ value: "openai/gpt-3.5-turbo",
95
+ description: "Fast GPT-3.5 Turbo model",
96
+ },
97
+ {
98
+ name: "Anthropic - Claude 3.5 Sonnet",
99
+ value: "anthropic/claude-3.5-sonnet",
100
+ description: "Anthropic's Claude 3.5 Sonnet",
101
+ },
102
+ {
103
+ name: "Anthropic - Claude 3 Opus",
104
+ value: "anthropic/claude-3-opus",
105
+ description: "Anthropic's Claude 3 Opus",
106
+ },
107
+ {
108
+ name: "Anthropic - Claude 3 Sonnet",
109
+ value: "anthropic/claude-3-sonnet",
110
+ description: "Anthropic's Claude 3 Sonnet",
111
+ },
112
+ {
113
+ name: "Anthropic - Claude 3 Haiku",
114
+ value: "anthropic/claude-3-haiku",
115
+ description: "Fast Claude 3 Haiku model",
116
+ },
117
+ {
118
+ name: "Google - Gemini Pro 1.5",
119
+ value: "google/gemini-pro-1.5",
120
+ description: "Google Gemini Pro 1.5",
121
+ },
122
+ {
123
+ name: "Google - Gemini Pro",
124
+ value: "google/gemini-pro",
125
+ description: "Google Gemini Pro",
126
+ },
127
+ {
128
+ name: "Google - Gemini Flash 1.5",
129
+ value: "google/gemini-flash-1.5",
130
+ description: "Fast Gemini Flash 1.5",
131
+ },
132
+ {
133
+ name: "Meta - Llama 3.1 405B",
134
+ value: "meta-llama/llama-3.1-405b-instruct",
135
+ description: "Meta Llama 3.1 405B Instruct",
136
+ },
137
+ {
138
+ name: "Meta - Llama 3.1 70B",
139
+ value: "meta-llama/llama-3.1-70b-instruct",
140
+ description: "Meta Llama 3.1 70B Instruct",
141
+ },
142
+ {
143
+ name: "Meta - Llama 3 70B",
144
+ value: "meta-llama/llama-3-70b-instruct",
145
+ description: "Meta Llama 3 70B Instruct",
146
+ },
147
+ {
148
+ name: "Mistral AI - Mistral Large",
149
+ value: "mistralai/mistral-large",
150
+ description: "Mistral AI Large model",
151
+ },
152
+ {
153
+ name: "Mistral AI - Mixtral 8x7B",
154
+ value: "mistralai/mixtral-8x7b-instruct",
155
+ description: "Mistral Mixtral 8x7B Instruct",
156
+ },
157
+ {
158
+ name: "Mistral AI - Mistral 7B",
159
+ value: "mistralai/mistral-7b-instruct",
160
+ description: "Mistral 7B Instruct",
161
+ },
162
+ {
163
+ name: "Cohere - Command R+",
164
+ value: "cohere/command-r-plus",
165
+ description: "Cohere Command R+",
166
+ },
167
+ {
168
+ name: "Perplexity - Sonar",
169
+ value: "perplexity/sonar",
170
+ description: "Perplexity Sonar model",
171
+ },
172
+ {
173
+ name: "xAI - Grok Beta",
174
+ value: "x-ai/grok-beta",
175
+ description: "xAI Grok Beta",
176
+ },
177
+ ],
178
+ default: "openai/gpt-4o-mini",
179
+ description: "Select a model or type any OpenRouter model ID. See https://openrouter.ai/models for all available models. Examples: 'openai/gpt-4o', 'anthropic/claude-3.5-sonnet', 'google/gemini-pro-1.5'",
180
+ },
181
+ {
182
+ displayName: "Messages",
183
+ name: "messages",
184
+ type: "fixedCollection",
185
+ typeOptions: {
186
+ multipleValues: true,
187
+ },
188
+ default: {},
189
+ options: [
190
+ {
191
+ name: "message",
192
+ displayName: "Message",
193
+ values: [
194
+ {
195
+ displayName: "Role",
196
+ name: "role",
197
+ type: "options",
198
+ options: [
199
+ {
200
+ name: "System",
201
+ value: "system",
202
+ description: "System message to set behavior",
203
+ },
204
+ {
205
+ name: "User",
206
+ value: "user",
207
+ description: "User message",
208
+ },
209
+ {
210
+ name: "Assistant",
211
+ value: "assistant",
212
+ description: "Assistant message (for conversation history)",
213
+ },
214
+ ],
215
+ default: "user",
216
+ description: "The role of the message",
217
+ },
218
+ {
219
+ displayName: "Content",
220
+ name: "content",
221
+ type: "string",
222
+ default: "",
223
+ typeOptions: {
224
+ rows: 4,
225
+ },
226
+ description: "The content of the message",
227
+ },
228
+ ],
229
+ },
230
+ ],
231
+ description: "The messages to send to the model",
232
+ },
233
+ {
234
+ displayName: "Options",
235
+ name: "options",
236
+ type: "collection",
237
+ placeholder: "Add Option",
238
+ default: {},
239
+ options: [
240
+ {
241
+ displayName: "Temperature",
242
+ name: "temperature",
243
+ type: "number",
244
+ typeOptions: {
245
+ minValue: 0,
246
+ maxValue: 2,
247
+ numberStepSize: 0.1,
248
+ },
249
+ default: 1,
250
+ description: "Controls randomness. Lower values make output more deterministic",
251
+ },
252
+ {
253
+ displayName: "Max Tokens",
254
+ name: "max_tokens",
255
+ type: "number",
256
+ typeOptions: {
257
+ minValue: 1,
258
+ },
259
+ default: 2048,
260
+ description: "Maximum number of tokens to generate",
261
+ },
262
+ {
263
+ displayName: "Top P",
264
+ name: "top_p",
265
+ type: "number",
266
+ typeOptions: {
267
+ minValue: 0,
268
+ maxValue: 1,
269
+ numberStepSize: 0.1,
270
+ },
271
+ default: 1,
272
+ description: "Nucleus sampling: consider tokens with top_p probability mass",
273
+ },
274
+ {
275
+ displayName: "Frequency Penalty",
276
+ name: "frequency_penalty",
277
+ type: "number",
278
+ typeOptions: {
279
+ minValue: -2,
280
+ maxValue: 2,
281
+ numberStepSize: 0.1,
282
+ },
283
+ default: 0,
284
+ description: "Penalize tokens based on their frequency in the text so far",
285
+ },
286
+ {
287
+ displayName: "Presence Penalty",
288
+ name: "presence_penalty",
289
+ type: "number",
290
+ typeOptions: {
291
+ minValue: -2,
292
+ maxValue: 2,
293
+ numberStepSize: 0.1,
294
+ },
295
+ default: 0,
296
+ description: "Penalize tokens based on whether they appear in the text so far",
297
+ },
298
+ ],
299
+ description: "Additional options for the chat completion",
300
+ },
301
+ ],
302
+ };
303
+ }
304
+ async execute() {
305
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
306
+ const items = this.getInputData();
307
+ const returnData = [];
308
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
309
+ try {
310
+ // Get authentication type
311
+ const authentication = this.getNodeParameter("authentication", itemIndex);
312
+ // Get authentication header
313
+ let authHeader;
314
+ if (authentication === "oAuth2") {
315
+ // OAuth2 authentication
316
+ const credentials = (await this.getCredentials("agnicWalletOAuth2Api", itemIndex));
317
+ authHeader = `Bearer ${String(credentials.oauthTokenData.access_token)}`;
318
+ }
319
+ else {
320
+ // API Key authentication
321
+ const credentials = await this.getCredentials("agnicWalletApi", itemIndex);
322
+ const { apiToken } = credentials;
323
+ authHeader = `Bearer ${String(apiToken)}`;
324
+ }
325
+ // Get model parameter (supports both dropdown selection and custom input)
326
+ const modelParam = this.getNodeParameter("model", itemIndex);
327
+ const model = modelParam === null || modelParam === void 0 ? void 0 : modelParam.trim();
328
+ if (!model || model === "") {
329
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Model must be specified. Enter an OpenRouter model ID (e.g., 'openai/gpt-4o' or 'anthropic/claude-3.5-sonnet'). See https://openrouter.ai/models for all available models.", { itemIndex });
330
+ }
331
+ // Get messages
332
+ const messagesConfig = this.getNodeParameter("messages", itemIndex, {});
333
+ if (!messagesConfig.message || messagesConfig.message.length === 0) {
334
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "At least one message is required", { itemIndex });
335
+ }
336
+ const messages = messagesConfig.message.map((msg) => ({
337
+ role: msg.role,
338
+ content: msg.content,
339
+ }));
340
+ // Get options
341
+ const options = this.getNodeParameter("options", itemIndex, {});
342
+ // Build request body
343
+ const requestBody = {
344
+ model: model.trim(),
345
+ messages,
346
+ };
347
+ if (options.temperature !== undefined) {
348
+ requestBody.temperature = options.temperature;
349
+ }
350
+ if (options.max_tokens !== undefined) {
351
+ requestBody.max_tokens = options.max_tokens;
352
+ }
353
+ if (options.top_p !== undefined) {
354
+ requestBody.top_p = options.top_p;
355
+ }
356
+ if (options.frequency_penalty !== undefined) {
357
+ requestBody.frequency_penalty = options.frequency_penalty;
358
+ }
359
+ if (options.presence_penalty !== undefined) {
360
+ requestBody.presence_penalty = options.presence_penalty;
361
+ }
362
+ // Make request to AgnicPay AI Gateway
363
+ const apiUrl = "https://api.agnicpay.xyz/v1/chat/completions";
364
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`[AgnicAI] Calling AgnicPay AI Gateway with model: ${model}`);
365
+ const response = await this.helpers.httpRequest({
366
+ method: "POST",
367
+ url: apiUrl,
368
+ headers: {
369
+ "Content-Type": "application/json",
370
+ Authorization: authHeader,
371
+ },
372
+ body: requestBody,
373
+ json: true,
374
+ });
375
+ // Format response
376
+ const formattedResponse = {
377
+ ...response,
378
+ content: ((_d = (_c = (_b = response.choices) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.content) ||
379
+ ((_f = (_e = response.choices) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.text) ||
380
+ response.content,
381
+ role: ((_j = (_h = (_g = response.choices) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.message) === null || _j === void 0 ? void 0 : _j.role) || "assistant",
382
+ };
383
+ returnData.push({
384
+ json: formattedResponse,
385
+ pairedItem: {
386
+ item: itemIndex,
387
+ },
388
+ });
389
+ }
390
+ catch (error) {
391
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
392
+ // Extract more detailed error information if available
393
+ let detailedError = errorMessage;
394
+ if (error && typeof error === "object" && "response" in error) {
395
+ const responseError = error;
396
+ if ((_k = responseError.response) === null || _k === void 0 ? void 0 : _k.body) {
397
+ detailedError = JSON.stringify(responseError.response.body);
398
+ }
399
+ else if ((_l = responseError.response) === null || _l === void 0 ? void 0 : _l.statusCode) {
400
+ detailedError = `HTTP ${responseError.response.statusCode}: ${errorMessage}`;
401
+ }
402
+ }
403
+ if (this.continueOnFail()) {
404
+ returnData.push({
405
+ json: {
406
+ error: detailedError,
407
+ },
408
+ pairedItem: {
409
+ item: itemIndex,
410
+ },
411
+ });
412
+ continue;
413
+ }
414
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), detailedError, {
415
+ itemIndex,
416
+ });
417
+ }
418
+ }
419
+ return [returnData];
420
+ }
421
+ }
422
+ exports.AgnicAI = AgnicAI;
Binary file
@@ -0,0 +1,12 @@
1
+ import { INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData } from "n8n-workflow";
2
+ /**
3
+ * AgnicAI Chat Model Node for n8n
4
+ *
5
+ * Uses LangChain's ChatOpenAI class with AgnicPay's OpenAI-compatible endpoint.
6
+ * This approach is identical to how n8n's built-in OpenAI Chat Model works,
7
+ * just pointing to AgnicPay's AI Gateway instead.
8
+ */
9
+ export declare class AgnicAILanguageModel implements INodeType {
10
+ description: INodeTypeDescription;
11
+ supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
12
+ }