Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@n8n_io/ai-assistant-sdk

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@n8n_io/ai-assistant-sdk - npm Package Compare versions

Comparing version 1.9.4 to 1.10.1

test/sdk.test.ts

15

CHANGELOG.md
# Changelog
## [1.10.1](https://github.com/n8n-io/ai-assistant-service/compare/ai-assistant-sdk-v1.10.0...ai-assistant-sdk-v1.10.1) (2024-10-01)
### Bug Fixes
* Add types for `askAi` request ([#170](https://github.com/n8n-io/ai-assistant-service/issues/170)) ([dd46752](https://github.com/n8n-io/ai-assistant-service/commit/dd4675275314dc1fe296ebdd3b53bda60a34d016))
## [1.10.0](https://github.com/n8n-io/ai-assistant-service/compare/ai-assistant-sdk-v1.9.4...ai-assistant-sdk-v1.10.0) (2024-09-30)
### Features
* Add `askAi` method to SDK ([#168](https://github.com/n8n-io/ai-assistant-service/issues/168)) ([929255d](https://github.com/n8n-io/ai-assistant-service/commit/929255d521ab84486d9d55307ad8d112155bc6ca))
* Add tests to SDK ([#100](https://github.com/n8n-io/ai-assistant-service/issues/100)) ([dafa0d4](https://github.com/n8n-io/ai-assistant-service/commit/dafa0d45d02a77f30410b69ee756c41ef9ea2e35))
## [1.9.4](https://github.com/n8n-io/ai-assistant-service/compare/ai-assistant-sdk-v1.9.3...ai-assistant-sdk-v1.9.4) (2024-08-14)

@@ -4,0 +19,0 @@

33

dist/index.d.ts

@@ -1,3 +0,1 @@

import { Response } from 'undici';
type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug' | 'verbose';

@@ -7,2 +5,9 @@ interface User {

}
type SchemaType = 'string' | 'number' | 'boolean' | 'bigint' | 'symbol' | 'array' | 'object' | 'function' | 'null' | 'undefined';
type Schema = {
type: SchemaType;
key?: string;
value: string | Schema[];
path: string;
};
declare namespace AiAssistantSDK {

@@ -21,2 +26,23 @@ interface ApplySuggestionResponse {

}
interface AskAiRequestPayload {
question: string;
context: {
schema: Array<{
nodeName: string;
schema: Schema;
}>;
inputSchema: {
nodeName: string;
schema: Schema;
};
pushRef: string;
ndvPushRef: string;
};
model: string;
forNode: string;
n8nVersion: string;
}
interface AskAiResponsePayload {
code: string;
}
}

@@ -49,2 +75,3 @@ declare class AiAssistantClient {

}, user: User): Promise<AiAssistantSDK.ApplySuggestionResponse>;
askAi(payload: AiAssistantSDK.AskAiRequestPayload, user: User): Promise<AiAssistantSDK.AskAiResponsePayload>;
private getHeaders;

@@ -56,2 +83,2 @@ private refreshAuthToken;

export { AiAssistantClient, AiAssistantSDK };
export { AiAssistantClient, AiAssistantSDK, type SchemaType };

25

dist/index.js

@@ -30,3 +30,3 @@ "use strict";

name: "@n8n_io/ai-assistant-sdk",
version: "1.9.4",
version: "1.10.1",
description: "n8n AI assistant SDK",

@@ -43,3 +43,3 @@ author: "",

module: "./dist/index.mjs",
packageManager: "pnpm@8.14.3",
packageManager: "pnpm@9.10.0",
scripts: {

@@ -51,14 +51,19 @@ typecheck: "tsc --noEmit",

start: "node ./dist/index.js",
test: "node --import tsx --test test/**.test.ts",
watch: "tsup src/index.ts --watch"
},
devDependencies: {
"@faker-js/faker": "^8.4.1",
"@types/node": "^22.4.0",
eslint: "^9.6.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
nock: "^14.0.0-beta.9",
prettier: "^3.3.2",
tsup: "^8.1.0",
tsx: "^4.17.0",
typescript: "^5.5.3"
},
dependencies: {
undici: "^6.19.7"
undici: "^6.19.8"
}

@@ -68,3 +73,2 @@ };

// src/index.ts
var import_undici = require("undici");
var DEFAULT_SERVICE_BASE_URL = "https://ai-assistant.n8n.io";

@@ -115,2 +119,9 @@ var AiAssistantClient = class {

}
async askAi(payload, user) {
{
const response = await this.postRequest("/v1/ask-ai", payload, user);
const data = await response.json();
return data;
}
}
getHeaders(user) {

@@ -127,3 +138,3 @@ return {

async refreshAuthToken() {
const response = await (0, import_undici.fetch)(`${this.baseUrl}/auth/token`, {
const response = await fetch(`${this.baseUrl}/auth/token`, {
method: "POST",

@@ -148,3 +159,3 @@ body: JSON.stringify({ licenseCert: this.licenseCert }),

const url = `${this.baseUrl}${endpoint}`;
let response = await (0, import_undici.fetch)(url, {
let response = await fetch(url, {
headers: this.getHeaders(user),

@@ -156,3 +167,3 @@ method: "POST",

await this.refreshAuthToken();
response = await (0, import_undici.fetch)(url, {
response = await fetch(url, {
headers: this.getHeaders(user),

@@ -159,0 +170,0 @@ method: "POST",

{
"name": "@n8n_io/ai-assistant-sdk",
"version": "1.9.4",
"version": "1.10.1",
"description": "n8n AI assistant SDK",

@@ -15,13 +15,16 @@ "author": "",

"module": "./dist/index.mjs",
"packageManager": "pnpm@8.14.3",
"devDependencies": {
"@faker-js/faker": "^8.4.1",
"@types/node": "^22.4.0",
"eslint": "^9.6.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"nock": "^14.0.0-beta.9",
"prettier": "^3.3.2",
"tsup": "^8.1.0",
"tsx": "^4.17.0",
"typescript": "^5.5.3"
},
"dependencies": {
"undici": "^6.19.7"
"undici": "^6.19.8"
},

@@ -34,4 +37,5 @@ "scripts": {

"start": "node ./dist/index.js",
"test": "node --import tsx --test test/**.test.ts",
"watch": "tsup src/index.ts --watch"
}
}
import packageJson from '../package.json';
import { fetch } from 'undici';
import type { Response } from 'undici';

@@ -10,2 +8,17 @@ // same as n8n

}
export type SchemaType =
| 'string'
| 'number'
| 'boolean'
| 'bigint'
| 'symbol'
| 'array'
| 'object'
| 'function'
| 'null'
| 'undefined';
type Schema = { type: SchemaType; key?: string; value: string | Schema[]; path: string };
export namespace AiAssistantSDK {

@@ -26,2 +39,19 @@ export interface ApplySuggestionResponse {

}
export interface AskAiRequestPayload {
question: string;
context: {
schema: Array<{ nodeName: string; schema: Schema }>;
inputSchema: { nodeName: string; schema: Schema };
pushRef: string;
ndvPushRef: string;
};
model: string;
forNode: string;
n8nVersion: string;
}
export interface AskAiResponsePayload {
code: string;
}
}

@@ -94,2 +124,15 @@

async askAi(
payload: AiAssistantSDK.AskAiRequestPayload,
user: User,
): Promise<AiAssistantSDK.AskAiResponsePayload> {
{
const response = await this.postRequest('/v1/ask-ai', payload, user);
const data = await response.json();
return data;
}
}
private getHeaders(user: User) {

@@ -96,0 +139,0 @@ return {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc