@inkeep/create-agents 0.26.2 → 0.28.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.
- package/dist/utils.js +36 -6
- package/package.json +2 -2
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { exec } from 'node:child_process';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { promisify } from 'node:util';
|
|
4
5
|
import * as p from '@clack/prompts';
|
|
@@ -6,6 +7,27 @@ import { ANTHROPIC_MODELS, GOOGLE_MODELS, OPENAI_MODELS } from '@inkeep/agents-c
|
|
|
6
7
|
import fs from 'fs-extra';
|
|
7
8
|
import color from 'picocolors';
|
|
8
9
|
import { cloneTemplate, getAvailableTemplates } from './templates.js';
|
|
10
|
+
// Shared validation utility
|
|
11
|
+
const DIRECTORY_VALIDATION = {
|
|
12
|
+
pattern: /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/,
|
|
13
|
+
reservedNames: /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i,
|
|
14
|
+
minLength: 1,
|
|
15
|
+
maxLength: 255,
|
|
16
|
+
validate(value) {
|
|
17
|
+
if (!value || value.trim() === '')
|
|
18
|
+
return 'Directory name is required';
|
|
19
|
+
if (value.length < this.minLength || value.length > this.maxLength) {
|
|
20
|
+
return `Directory name must be between ${this.minLength} and ${this.maxLength} characters`;
|
|
21
|
+
}
|
|
22
|
+
if (this.reservedNames.test(value)) {
|
|
23
|
+
return 'Directory name cannot be a reserved system name';
|
|
24
|
+
}
|
|
25
|
+
if (!this.pattern.test(value)) {
|
|
26
|
+
return 'Directory name can only contain letters, numbers, and hyphens (-), and underscores (_) and must start with a letter or number';
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
9
31
|
const execAsync = promisify(exec);
|
|
10
32
|
export const defaultGoogleModelConfigurations = {
|
|
11
33
|
base: {
|
|
@@ -72,12 +94,7 @@ export const createAgents = async (args = {}) => {
|
|
|
72
94
|
message: 'What do you want to name your agents directory?',
|
|
73
95
|
placeholder: 'agents',
|
|
74
96
|
defaultValue: 'agents',
|
|
75
|
-
validate: (value) =>
|
|
76
|
-
if (!value || value.trim() === '') {
|
|
77
|
-
return 'Directory name is required';
|
|
78
|
-
}
|
|
79
|
-
return undefined;
|
|
80
|
-
},
|
|
97
|
+
validate: (value) => DIRECTORY_VALIDATION.validate(value),
|
|
81
98
|
});
|
|
82
99
|
if (p.isCancel(dirResponse)) {
|
|
83
100
|
p.cancel('Operation cancelled');
|
|
@@ -85,6 +102,13 @@ export const createAgents = async (args = {}) => {
|
|
|
85
102
|
}
|
|
86
103
|
dirName = dirResponse;
|
|
87
104
|
}
|
|
105
|
+
else {
|
|
106
|
+
// Validate the provided dirName
|
|
107
|
+
const validationError = DIRECTORY_VALIDATION.validate(dirName);
|
|
108
|
+
if (validationError) {
|
|
109
|
+
throw new Error(validationError);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
88
112
|
if (!anthropicKey && !openAiKey && !googleKey) {
|
|
89
113
|
const providerChoice = await p.select({
|
|
90
114
|
message: 'Which AI provider would you like to use?',
|
|
@@ -260,6 +284,7 @@ async function createWorkspaceStructure() {
|
|
|
260
284
|
async function createEnvironmentFiles(config) {
|
|
261
285
|
// Convert to forward slashes for cross-platform SQLite URI compatibility
|
|
262
286
|
const dbPath = process.cwd().replace(/\\/g, '/');
|
|
287
|
+
const jwtSigningSecret = crypto.randomBytes(32).toString('hex');
|
|
263
288
|
const envContent = `# Environment
|
|
264
289
|
ENVIRONMENT=development
|
|
265
290
|
|
|
@@ -285,6 +310,9 @@ OTEL_EXPORTER_OTLP_TRACES_HEADERS="signoz-ingestion-key=<your-ingestion-key>"
|
|
|
285
310
|
|
|
286
311
|
# Nango Configuration
|
|
287
312
|
NANGO_SECRET_KEY=
|
|
313
|
+
|
|
314
|
+
# JWT Signing Secret
|
|
315
|
+
INKEEP_AGENTS_JWT_SIGNING_SECRET=${jwtSigningSecret}
|
|
288
316
|
`;
|
|
289
317
|
await fs.writeFile('.env', envContent);
|
|
290
318
|
}
|
|
@@ -318,6 +346,8 @@ async function installDependencies() {
|
|
|
318
346
|
async function initializeGit() {
|
|
319
347
|
try {
|
|
320
348
|
await execAsync('git init');
|
|
349
|
+
await execAsync('git add .');
|
|
350
|
+
await execAsync('git commit -m "Initial commit from inkeep/create-agents"');
|
|
321
351
|
}
|
|
322
352
|
catch (error) {
|
|
323
353
|
console.error('Error initializing git:', error instanceof Error ? error.message : 'Unknown error');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/create-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Create an Inkeep Agent Framework project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"fs-extra": "^11.0.0",
|
|
35
35
|
"picocolors": "^1.0.0",
|
|
36
36
|
"drizzle-kit": "^0.31.5",
|
|
37
|
-
"@inkeep/agents-core": "0.
|
|
37
|
+
"@inkeep/agents-core": "0.28.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/degit": "^2.8.6",
|