@nestbox-ai/cli 1.0.48 → 1.0.49
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/package.json +7 -1
- package/.github/workflows/generate-client.yml +0 -43
- package/.github/workflows/test.yml +0 -54
- package/.nestboxrc +0 -5
- package/src/commands/agent/apiUtils.ts +0 -113
- package/src/commands/agent/create.ts +0 -271
- package/src/commands/agent/deploy.ts +0 -523
- package/src/commands/agent/index.ts +0 -8
- package/src/commands/agent/list.ts +0 -104
- package/src/commands/agent/remove.ts +0 -103
- package/src/commands/agent/yaml-schema.ts +0 -57
- package/src/commands/agent.ts +0 -21
- package/src/commands/auth/index.ts +0 -3
- package/src/commands/auth/login.ts +0 -184
- package/src/commands/auth/logout.ts +0 -110
- package/src/commands/auth.ts +0 -12
- package/src/commands/compute/apiUtils.ts +0 -28
- package/src/commands/compute/create.ts +0 -195
- package/src/commands/compute/delete.ts +0 -147
- package/src/commands/compute/index.ts +0 -7
- package/src/commands/compute/list.ts +0 -117
- package/src/commands/compute.ts +0 -19
- package/src/commands/document/apiUtils.ts +0 -22
- package/src/commands/document/collectionCreate.ts +0 -46
- package/src/commands/document/collectionDelete.ts +0 -45
- package/src/commands/document/collectionGet.ts +0 -47
- package/src/commands/document/collectionList.ts +0 -52
- package/src/commands/document/collectionUpdate.ts +0 -53
- package/src/commands/document/docAdd.ts +0 -56
- package/src/commands/document/docDelete.ts +0 -47
- package/src/commands/document/docGet.ts +0 -49
- package/src/commands/document/docSearch.ts +0 -70
- package/src/commands/document/docUpdate.ts +0 -56
- package/src/commands/document/docUploadFile.ts +0 -55
- package/src/commands/document/index.ts +0 -17
- package/src/commands/document.ts +0 -48
- package/src/commands/generate/project.ts +0 -199
- package/src/commands/generate.ts +0 -15
- package/src/commands/image/apiUtils.ts +0 -22
- package/src/commands/image/display.ts +0 -34
- package/src/commands/image/index.ts +0 -4
- package/src/commands/image/list.ts +0 -61
- package/src/commands/image.ts +0 -15
- package/src/commands/project/add.ts +0 -47
- package/src/commands/project/apiUtils.ts +0 -20
- package/src/commands/project/index.ts +0 -5
- package/src/commands/project/list.ts +0 -78
- package/src/commands/project/use.ts +0 -45
- package/src/commands/project.ts +0 -19
- package/src/index.ts +0 -39
- package/src/types/agentType.ts +0 -7
- package/src/types/agentYaml.ts +0 -107
- package/src/types/auth.ts +0 -12
- package/src/types/statusMapping.ts +0 -8
- package/src/utils/agent.ts +0 -170
- package/src/utils/api.ts +0 -64
- package/src/utils/auth.ts +0 -140
- package/src/utils/config.ts +0 -37
- package/src/utils/error.ts +0 -168
- package/src/utils/plopGenerator.ts +0 -133
- package/src/utils/project.ts +0 -88
- package/src/utils/user.ts +0 -28
- package/src/utils/validation.ts +0 -22
- package/templates/base-js/index.js.hbs +0 -30
- package/templates/base-js/nestbox-agents.yaml.hbs +0 -12
- package/templates/base-js/package.json +0 -15
- package/templates/base-py/main.py.hbs +0 -42
- package/templates/base-py/nestbox-agents.yaml.hbs +0 -12
- package/templates/base-py/pyproject.toml +0 -19
- package/templates/base-ts/eslint.config.mjs +0 -27
- package/templates/base-ts/nestbox-agents.yaml.hbs +0 -12
- package/templates/base-ts/nestbox.config.json +0 -9
- package/templates/base-ts/package.json +0 -24
- package/templates/base-ts/src/index.ts.hbs +0 -29
- package/templates/base-ts/tsconfig.json +0 -14
- package/templates/chatbot-js/index.js.hbs +0 -18
- package/templates/chatbot-js/package-lock.json +0 -1571
- package/templates/chatbot-js/package.json +0 -15
- package/templates/chatbot-py/main.py.hbs +0 -42
- package/templates/chatbot-py/nestbox-agents.yaml.hbs +0 -12
- package/templates/chatbot-py/pyproject.toml +0 -19
- package/templates/chatbot-ts/eslint.config.mjs +0 -27
- package/templates/chatbot-ts/package.json +0 -24
- package/templates/chatbot-ts/src/index.ts.hbs +0 -18
- package/templates/chatbot-ts/tsconfig.json +0 -14
- package/test/README.md +0 -52
- package/test/agent.test.ts +0 -154
- package/test/auth.test.ts +0 -71
- package/test/compute.test.ts +0 -135
- package/test/document.test.ts +0 -217
- package/test/generate.test.ts +0 -67
- package/test/image.test.ts +0 -107
- package/test/mocks.ts +0 -122
- package/test/project.test.ts +0 -108
- package/test/setup.ts +0 -121
- package/tsconfig.json +0 -118
- package/vitest.config.d.ts +0 -2
- package/vitest.config.js +0 -23
- package/vitest.config.js.map +0 -1
- package/vitest.config.ts +0 -21
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import nodePlop from "node-plop";
|
|
4
|
-
|
|
5
|
-
export interface TemplateConfig {
|
|
6
|
-
name: string;
|
|
7
|
-
description: string;
|
|
8
|
-
prompts: any[];
|
|
9
|
-
actions: any[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const kebabize = (str: string) =>
|
|
13
|
-
str.replace(
|
|
14
|
-
/[A-Z]+(?![a-z])|[A-Z]/g,
|
|
15
|
-
($, ofs) => (ofs ? "-" : "") + $.toLowerCase()
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Generate project using plop.js templates
|
|
20
|
-
*/
|
|
21
|
-
export async function generateWithPlop(
|
|
22
|
-
templateType: string,
|
|
23
|
-
language: string,
|
|
24
|
-
targetFolder: string,
|
|
25
|
-
projectName?: string,
|
|
26
|
-
agentName?: string
|
|
27
|
-
): Promise<{ agentNameInYaml: string }> {
|
|
28
|
-
// Create the target directory
|
|
29
|
-
if (!fs.existsSync(targetFolder)) {
|
|
30
|
-
fs.mkdirSync(targetFolder, { recursive: true });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Set up plop programmatically
|
|
34
|
-
const plop = await nodePlop("", {
|
|
35
|
-
destBasePath: targetFolder,
|
|
36
|
-
force: false,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Template mapping
|
|
40
|
-
const templateMapping: Record<string, string> = {
|
|
41
|
-
agent: "base",
|
|
42
|
-
chatbot: "chatbot",
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const mappedTemplateType = templateMapping[templateType] || templateType;
|
|
46
|
-
const templatePath = path.resolve(
|
|
47
|
-
__dirname,
|
|
48
|
-
`../../templates/${mappedTemplateType}-${language}`
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
if (!fs.existsSync(templatePath)) {
|
|
52
|
-
throw new Error(`Template not found: ${templatePath}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Configure the generator
|
|
56
|
-
const generatorName = `${mappedTemplateType}-${language}`;
|
|
57
|
-
|
|
58
|
-
// Get the main template file path and target name
|
|
59
|
-
const mainTemplateFile =
|
|
60
|
-
language === "ts" ? "src/index.ts.hbs" : "index.js.hbs";
|
|
61
|
-
const targetFileName = language === "ts" ? "src/index.ts" : "index.js";
|
|
62
|
-
|
|
63
|
-
plop.setGenerator(generatorName, {
|
|
64
|
-
description: `Generate a new ${mappedTemplateType} project in ${language}`,
|
|
65
|
-
prompts: [],
|
|
66
|
-
actions: [
|
|
67
|
-
// Copy all non-template files
|
|
68
|
-
{
|
|
69
|
-
type: "addMany",
|
|
70
|
-
destination: ".",
|
|
71
|
-
base: templatePath,
|
|
72
|
-
templateFiles: `${templatePath}/**/*`,
|
|
73
|
-
globOptions: {
|
|
74
|
-
dot: true,
|
|
75
|
-
ignore: ["**/node_modules/**", "**/*.hbs"],
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
type: "add",
|
|
80
|
-
path: targetFileName,
|
|
81
|
-
templateFile: path.join(templatePath, mainTemplateFile),
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
type: "add",
|
|
85
|
-
path: "nestbox-agents.yaml",
|
|
86
|
-
templateFile: path.join(templatePath, "nestbox-agents.yaml.hbs"),
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Run the generator
|
|
92
|
-
const generator = plop.getGenerator(generatorName);
|
|
93
|
-
const agentNameFinal =
|
|
94
|
-
agentName || (templateType === "agent" ? "myAgent" : "myChatbot");
|
|
95
|
-
const agentNameInYaml = kebabize(agentNameFinal);
|
|
96
|
-
await generator.runActions({
|
|
97
|
-
name: projectName || path.basename(targetFolder),
|
|
98
|
-
agentName: agentNameFinal,
|
|
99
|
-
agentNameInYaml,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Update package.json with project name if provided
|
|
103
|
-
if (projectName) {
|
|
104
|
-
const packageJsonPath = path.join(targetFolder, "package.json");
|
|
105
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
106
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
107
|
-
packageJson.name = projectName;
|
|
108
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
agentNameInYaml,
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* List available templates
|
|
119
|
-
*/
|
|
120
|
-
export function listAvailableTemplates(): string[] {
|
|
121
|
-
const templatesDir = path.resolve(__dirname, "../../templates");
|
|
122
|
-
if (!fs.existsSync(templatesDir)) {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return fs
|
|
127
|
-
.readdirSync(templatesDir)
|
|
128
|
-
.filter((item) => {
|
|
129
|
-
const itemPath = path.join(templatesDir, item);
|
|
130
|
-
return fs.statSync(itemPath).isDirectory();
|
|
131
|
-
})
|
|
132
|
-
.map((item) => item.replace(/\.(ts|js)$/, ""));
|
|
133
|
-
}
|
package/src/utils/project.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { ProjectsApi } from "@nestbox-ai/admin";
|
|
2
|
-
import ora from "ora";
|
|
3
|
-
import { readNestboxConfig } from "./config";
|
|
4
|
-
|
|
5
|
-
interface ProjectInfo {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface CommandOptions {
|
|
11
|
-
instance: string;
|
|
12
|
-
project?: string;
|
|
13
|
-
collection?: string;
|
|
14
|
-
name?: string;
|
|
15
|
-
metadata?: string;
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface ResolveProjectOptions extends CommandOptions {
|
|
20
|
-
showSpinner?: boolean; // New option to control spinner visibility
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function resolveProject(
|
|
24
|
-
projectsApi: ProjectsApi,
|
|
25
|
-
options: ResolveProjectOptions
|
|
26
|
-
): Promise<ProjectInfo> {
|
|
27
|
-
// Default to showing spinner if not specified
|
|
28
|
-
const showSpinner = options.showSpinner !== false;
|
|
29
|
-
const spinner = showSpinner ? ora('Resolving project...').start() : null;
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const projectsResponse = await projectsApi.projectControllerGetAllProjects();
|
|
33
|
-
const allProjects = projectsResponse.data?.data?.projects;
|
|
34
|
-
|
|
35
|
-
if (!allProjects || allProjects.length === 0) {
|
|
36
|
-
if (spinner) spinner.fail('No projects found.');
|
|
37
|
-
throw new Error('No projects found');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let projectId = options.project;
|
|
41
|
-
let projectName = '';
|
|
42
|
-
|
|
43
|
-
if (projectId) {
|
|
44
|
-
const byId = allProjects.find((p) => p.id === projectId);
|
|
45
|
-
const byName = allProjects.find((p) => p.name === projectId);
|
|
46
|
-
|
|
47
|
-
if (byId) {
|
|
48
|
-
projectName = byId.name;
|
|
49
|
-
projectId = byId.id;
|
|
50
|
-
} else if (byName) {
|
|
51
|
-
projectName = byName.name;
|
|
52
|
-
projectId = byName.id;
|
|
53
|
-
} else {
|
|
54
|
-
if (spinner) spinner.fail(`Project not found with ID or name: ${projectId}`);
|
|
55
|
-
throw new Error(`Project not found with ID or name: ${projectId}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (spinner) spinner.succeed(`Using project: ${projectName} (ID: ${projectId})`);
|
|
59
|
-
} else {
|
|
60
|
-
const config = readNestboxConfig();
|
|
61
|
-
const defaultProjectName = config.projects?.default;
|
|
62
|
-
|
|
63
|
-
if (!defaultProjectName) {
|
|
64
|
-
if (spinner) spinner.fail('No project specified and no default project set. Please provide a project ID or set a default project.');
|
|
65
|
-
throw new Error('No project specified and no default project set');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const defaultProject = allProjects.find((p) => p.name === defaultProjectName);
|
|
69
|
-
|
|
70
|
-
if (!defaultProject) {
|
|
71
|
-
if (spinner) spinner.fail(`Default project "${defaultProjectName}" not found.`);
|
|
72
|
-
throw new Error(`Default project "${defaultProjectName}" not found.`);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
projectId = defaultProject.id;
|
|
76
|
-
projectName = defaultProject.name;
|
|
77
|
-
if (spinner) spinner.succeed(`Using default project: ${projectName} (ID: ${projectId})`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return { id: projectId, name: projectName };
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (spinner && spinner.isSpinning) {
|
|
83
|
-
// If spinner was already stopped with fail, we don't need to fail it again
|
|
84
|
-
spinner.fail('Failed to resolve project');
|
|
85
|
-
}
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
}
|
package/src/utils/user.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { getAuthToken } from "./auth";
|
|
3
|
-
|
|
4
|
-
export async function userData() {
|
|
5
|
-
try {
|
|
6
|
-
const authData = getAuthToken();
|
|
7
|
-
|
|
8
|
-
if (!authData || !authData.serverUrl || !authData.token) {
|
|
9
|
-
throw new Error("No authentication data found. Please login first.");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const response = await axios.get(
|
|
13
|
-
`${authData.serverUrl}/user/me`,
|
|
14
|
-
{
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `${authData.token}`,
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
return response.data;
|
|
22
|
-
} catch (error: any) {
|
|
23
|
-
console.error("Error fetching user data:", error.message || "Unknown error");
|
|
24
|
-
if (error.response) {
|
|
25
|
-
}
|
|
26
|
-
throw error; // Rethrow to allow caller to handle the error
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/utils/validation.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates if a string is a valid JavaScript/TypeScript function name
|
|
3
|
-
*/
|
|
4
|
-
export function isValidFunctionName(name: string): boolean {
|
|
5
|
-
// Check if it's a valid JavaScript identifier
|
|
6
|
-
const validIdentifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
7
|
-
|
|
8
|
-
// Check if it's not a reserved keyword
|
|
9
|
-
const reservedKeywords = [
|
|
10
|
-
'abstract', 'arguments', 'await', 'boolean', 'break', 'byte', 'case', 'catch',
|
|
11
|
-
'char', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do',
|
|
12
|
-
'double', 'else', 'enum', 'eval', 'export', 'extends', 'false', 'final',
|
|
13
|
-
'finally', 'float', 'for', 'function', 'goto', 'if', 'implements', 'import',
|
|
14
|
-
'in', 'instanceof', 'int', 'interface', 'let', 'long', 'native', 'new',
|
|
15
|
-
'null', 'package', 'private', 'protected', 'public', 'return', 'short',
|
|
16
|
-
'static', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws',
|
|
17
|
-
'transient', 'true', 'try', 'typeof', 'var', 'void', 'volatile', 'while',
|
|
18
|
-
'with', 'yield'
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
return validIdentifierRegex.test(name) && !reservedKeywords.includes(name.toLowerCase());
|
|
22
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var { useAgent } = require('@nestbox-ai/functions');
|
|
2
|
-
var { OpenAI } = require('openai');
|
|
3
|
-
|
|
4
|
-
const MODEL_NAME = 'openai/gpt-oss-20b';
|
|
5
|
-
|
|
6
|
-
const client = new OpenAI({
|
|
7
|
-
baseURL: 'http://localhost:8000/v1',
|
|
8
|
-
apiKey: 'sk-xxxxxx'
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
var {{agentName}} = useAgent(async (context, events) => {
|
|
12
|
-
|
|
13
|
-
const response = await client.chat.completions.create({
|
|
14
|
-
model: MODEL_NAME,
|
|
15
|
-
messages: [
|
|
16
|
-
{
|
|
17
|
-
role: "user",
|
|
18
|
-
content: "Why is the sky blue?"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
});
|
|
22
|
-
const result = response.choices[0].message.content;
|
|
23
|
-
if (!result) {
|
|
24
|
-
events.emitQueryFailed({ data: { error: 'No response from model' } });
|
|
25
|
-
} else {
|
|
26
|
-
events.emitQueryCompleted({ data: result });
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
module.exports = { {{agentName}} };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
agents:
|
|
2
|
-
- name: {{ agentNameInYaml }}
|
|
3
|
-
description: Our new agent {{ agentNameInYaml }} that uses the nestbox API
|
|
4
|
-
entry: {{agentName}}
|
|
5
|
-
inputSchema:
|
|
6
|
-
type: object
|
|
7
|
-
properties:
|
|
8
|
-
content:
|
|
9
|
-
type: string
|
|
10
|
-
description: The content of the input as string
|
|
11
|
-
minLength: 10
|
|
12
|
-
maxLength: 5000
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "app",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
-
},
|
|
8
|
-
"author": "",
|
|
9
|
-
"license": "ISC",
|
|
10
|
-
"description": "",
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@nestbox-ai/functions": "^2.0.0",
|
|
13
|
-
"openai": "^6.5.0"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from nestbox_ai_functions import use_agent
|
|
2
|
-
from openai import OpenAI
|
|
3
|
-
|
|
4
|
-
MODEL_NAME = "openai/gpt-oss-20b"
|
|
5
|
-
|
|
6
|
-
client = OpenAI(
|
|
7
|
-
base_url="http://localhost:8000/v1",
|
|
8
|
-
api_key="sk-xxxxxx"
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
@use_agent
|
|
12
|
-
async def {{agentName}}(context, events):
|
|
13
|
-
try:
|
|
14
|
-
response = client.chat.completions.create(
|
|
15
|
-
model=MODEL_NAME,
|
|
16
|
-
messages=[
|
|
17
|
-
{
|
|
18
|
-
"role": "user",
|
|
19
|
-
"content": "Why is the sky blue?"
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
result = response.choices[0].message.content if response.choices else None
|
|
25
|
-
|
|
26
|
-
if not result:
|
|
27
|
-
await events.emitQueryFailed({
|
|
28
|
-
"data": {
|
|
29
|
-
"error": "No response from model"
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
else:
|
|
33
|
-
await events.emitQueryCompleted({
|
|
34
|
-
"data": result
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
except Exception as e:
|
|
38
|
-
await events.emitQueryFailed({
|
|
39
|
-
"data": {
|
|
40
|
-
"error": str(e)
|
|
41
|
-
}
|
|
42
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
agents:
|
|
2
|
-
- name: {{ agentNameInYaml }}
|
|
3
|
-
description: Our new agent {{ agentNameInYaml }} that uses the nestbox API
|
|
4
|
-
entry: {{agentName}}
|
|
5
|
-
inputSchema:
|
|
6
|
-
type: object
|
|
7
|
-
properties:
|
|
8
|
-
content:
|
|
9
|
-
type: string
|
|
10
|
-
description: The content of the input as string
|
|
11
|
-
minLength: 10
|
|
12
|
-
maxLength: 5000
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61.0"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "app"
|
|
7
|
-
version = "1.0.0"
|
|
8
|
-
description = "Nestbox AI Python Agent"
|
|
9
|
-
requires-python = ">=3.9"
|
|
10
|
-
|
|
11
|
-
dependencies = [
|
|
12
|
-
"nestbox-ai-functions>=2.0.3",
|
|
13
|
-
"openai>=1.40.0",
|
|
14
|
-
"httpx>=0.27.0",
|
|
15
|
-
"anyio>=4.0.0"
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
[tool.setuptools]
|
|
19
|
-
packages = ["."]
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import tsParser from "@typescript-eslint/parser";
|
|
2
|
-
import eslintPluginTs from "@typescript-eslint/eslint-plugin";
|
|
3
|
-
|
|
4
|
-
export default [
|
|
5
|
-
{
|
|
6
|
-
files: ["**/*.ts"],
|
|
7
|
-
languageOptions: {
|
|
8
|
-
parser: tsParser,
|
|
9
|
-
parserOptions: {
|
|
10
|
-
ecmaVersion: "latest",
|
|
11
|
-
sourceType: "module",
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
plugins: {
|
|
15
|
-
"@typescript-eslint": eslintPluginTs,
|
|
16
|
-
},
|
|
17
|
-
rules: {
|
|
18
|
-
...eslintPluginTs.configs.recommended.rules,
|
|
19
|
-
// Optional custom rules:
|
|
20
|
-
// '@typescript-eslint/no-explicit-any': 'warn',
|
|
21
|
-
// '@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
ignores: ["dist/", "node_modules/"],
|
|
26
|
-
},
|
|
27
|
-
];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
agents:
|
|
2
|
-
- name: {{ agentNameInYaml }}
|
|
3
|
-
description: Our new agent {{ agentNameInYaml }} that uses the nestbox API
|
|
4
|
-
entry: {{agentName}}
|
|
5
|
-
inputSchema:
|
|
6
|
-
type: object
|
|
7
|
-
properties:
|
|
8
|
-
content:
|
|
9
|
-
type: string
|
|
10
|
-
description: The content of the input as string
|
|
11
|
-
minLength: 10
|
|
12
|
-
maxLength: 5000
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "app-ts",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "tsc",
|
|
7
|
-
"start": "node dist/index.js",
|
|
8
|
-
"dev": "ts-node src/index.ts",
|
|
9
|
-
"lint": "eslint ."
|
|
10
|
-
},
|
|
11
|
-
"author": "",
|
|
12
|
-
"license": "ISC",
|
|
13
|
-
"description": "",
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@nestbox-ai/functions": "^2.0.0",
|
|
16
|
-
"openai": "^6.5.0"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@typescript-eslint/eslint-plugin": "^8.31.0",
|
|
20
|
-
"@typescript-eslint/parser": "^8.31.0",
|
|
21
|
-
"eslint": "^9.25.1",
|
|
22
|
-
"typescript": "^5.8.3"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AgentContext, AgentEvents, useAgent } from "@nestbox-ai/functions";
|
|
2
|
-
import OpenAI from 'openai';
|
|
3
|
-
|
|
4
|
-
const MODEL_NAME = 'openai/gpt-oss-20b';
|
|
5
|
-
|
|
6
|
-
const client = new OpenAI({
|
|
7
|
-
baseURL: 'http://localhost:8000/v1',
|
|
8
|
-
apiKey: 'sk-xxxxxx'
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export const {{agentName}} = useAgent(
|
|
12
|
-
async (context: AgentContext, events: AgentEvents) => {
|
|
13
|
-
const response = await client.chat.completions.create({
|
|
14
|
-
model: MODEL_NAME,
|
|
15
|
-
messages: [
|
|
16
|
-
{
|
|
17
|
-
role: "user",
|
|
18
|
-
content: "Why is the sky blue?"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
});
|
|
22
|
-
const result = response.choices[0].message.content;
|
|
23
|
-
if (!result) {
|
|
24
|
-
events.emitQueryFailed({ data: { error: 'No response from model' } });
|
|
25
|
-
} else {
|
|
26
|
-
events.emitQueryCompleted({ data: result });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
4
|
-
"module": "commonjs", /* Specify what module code is generated. */
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
8
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
9
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
10
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
11
|
-
},
|
|
12
|
-
"include": ["src"],
|
|
13
|
-
"exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"],
|
|
14
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var { useChatbot } = require('@nestbox-ai/functions');
|
|
2
|
-
var { Ollama } = require('ollama');
|
|
3
|
-
|
|
4
|
-
const ollama = new Ollama()
|
|
5
|
-
|
|
6
|
-
var {{agentName}} = useChatbot(async (context, events) => {
|
|
7
|
-
|
|
8
|
-
const response = await ollama.chat({
|
|
9
|
-
messages: context.messages,
|
|
10
|
-
model: 'gemma3:27b',
|
|
11
|
-
stream: false,
|
|
12
|
-
});
|
|
13
|
-
const result = response.message.content;
|
|
14
|
-
|
|
15
|
-
events.emitQueryCompleted({ data: result });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
module.exports = { {{agentName}} };
|