@inkeep/create-agents 0.29.6 → 0.29.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.
- package/dist/utils.js +80 -6
- package/package.json +2 -2
package/dist/utils.js
CHANGED
|
@@ -29,6 +29,8 @@ const DIRECTORY_VALIDATION = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
const execAsync = promisify(exec);
|
|
32
|
+
const manageApiPort = '3002';
|
|
33
|
+
const runApiPort = '3003';
|
|
32
34
|
export const defaultGoogleModelConfigurations = {
|
|
33
35
|
base: {
|
|
34
36
|
model: GOOGLE_MODELS.GEMINI_2_5_FLASH,
|
|
@@ -65,8 +67,6 @@ export const defaultAnthropicModelConfigurations = {
|
|
|
65
67
|
export const createAgents = async (args = {}) => {
|
|
66
68
|
let { dirName, openAiKey, anthropicKey, googleKey, template, customProjectId, disableGit } = args;
|
|
67
69
|
const tenantId = 'default';
|
|
68
|
-
const manageApiPort = '3002';
|
|
69
|
-
const runApiPort = '3003';
|
|
70
70
|
let projectId;
|
|
71
71
|
let templateName;
|
|
72
72
|
if (customProjectId) {
|
|
@@ -215,8 +215,6 @@ export const createAgents = async (args = {}) => {
|
|
|
215
215
|
openAiKey,
|
|
216
216
|
anthropicKey,
|
|
217
217
|
googleKey,
|
|
218
|
-
manageApiPort: manageApiPort || '3002',
|
|
219
|
-
runApiPort: runApiPort || '3003',
|
|
220
218
|
modelSettings: defaultModelSettings,
|
|
221
219
|
customProject: !!customProjectId,
|
|
222
220
|
disableGit: disableGit,
|
|
@@ -264,8 +262,8 @@ export const createAgents = async (args = {}) => {
|
|
|
264
262
|
` cd ${dirName}\n` +
|
|
265
263
|
` pnpm dev # Start development servers\n\n` +
|
|
266
264
|
`${color.yellow('Available services:')}\n` +
|
|
267
|
-
` • Manage API: http://localhost
|
|
268
|
-
` • Run API: http://localhost
|
|
265
|
+
` • Manage API: http://localhost:3002\n` +
|
|
266
|
+
` • Run API: http://localhost:3003\n` +
|
|
269
267
|
` • Manage UI: Available with management API\n` +
|
|
270
268
|
`\n${color.yellow('Configuration:')}\n` +
|
|
271
269
|
` • Edit .env for environment variables\n` +
|
|
@@ -353,7 +351,58 @@ async function initializeGit() {
|
|
|
353
351
|
console.error('Error initializing git:', error instanceof Error ? error.message : 'Unknown error');
|
|
354
352
|
}
|
|
355
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Check if a port is available
|
|
356
|
+
*/
|
|
357
|
+
async function isPortAvailable(port) {
|
|
358
|
+
const net = await import('node:net');
|
|
359
|
+
return new Promise((resolve) => {
|
|
360
|
+
const server = net.createServer();
|
|
361
|
+
server.once('error', () => {
|
|
362
|
+
resolve(false);
|
|
363
|
+
});
|
|
364
|
+
server.once('listening', () => {
|
|
365
|
+
server.close();
|
|
366
|
+
resolve(true);
|
|
367
|
+
});
|
|
368
|
+
server.listen(port);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Display port conflict error and exit
|
|
373
|
+
*/
|
|
374
|
+
function displayPortConflictError(unavailablePorts) {
|
|
375
|
+
let errorMessage = '';
|
|
376
|
+
if (unavailablePorts.runApi) {
|
|
377
|
+
errorMessage += `${color.red(`Run API port ${runApiPort} is already in use`)}\n`;
|
|
378
|
+
}
|
|
379
|
+
if (unavailablePorts.manageApi) {
|
|
380
|
+
errorMessage += `${color.red(`Manage API port ${manageApiPort} is already in use`)}\n`;
|
|
381
|
+
}
|
|
382
|
+
p.cancel(`\n${color.red('✗ Port conflicts detected')}\n\n` +
|
|
383
|
+
`${errorMessage}\n` +
|
|
384
|
+
`${color.yellow('Please free up the ports and try again.')}\n`);
|
|
385
|
+
process.exit(1);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Check port availability and display errors if needed
|
|
389
|
+
*/
|
|
390
|
+
async function checkPortsAvailability() {
|
|
391
|
+
const [runApiAvailable, manageApiAvailable] = await Promise.all([
|
|
392
|
+
isPortAvailable(Number(runApiPort)),
|
|
393
|
+
isPortAvailable(Number(manageApiPort)),
|
|
394
|
+
]);
|
|
395
|
+
if (!runApiAvailable || !manageApiAvailable) {
|
|
396
|
+
displayPortConflictError({
|
|
397
|
+
runApi: !runApiAvailable,
|
|
398
|
+
manageApi: !manageApiAvailable,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
356
402
|
async function setupProjectInDatabase(config) {
|
|
403
|
+
// Proactively check if ports are available BEFORE starting servers
|
|
404
|
+
await checkPortsAvailability();
|
|
405
|
+
// Start development servers in background
|
|
357
406
|
const { spawn } = await import('node:child_process');
|
|
358
407
|
const devProcess = spawn('pnpm', ['dev:apis'], {
|
|
359
408
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
@@ -363,6 +412,31 @@ async function setupProjectInDatabase(config) {
|
|
|
363
412
|
windowsHide: true,
|
|
364
413
|
});
|
|
365
414
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
415
|
+
// Track if port errors occur during startup (as a safety fallback)
|
|
416
|
+
const portErrors = { runApi: false, manageApi: false };
|
|
417
|
+
// Regex patterns for detecting port errors in output
|
|
418
|
+
const portErrorPatterns = {
|
|
419
|
+
runApi: new RegExp(`(EADDRINUSE.*:${runApiPort}|port ${runApiPort}.*already|Port ${runApiPort}.*already|run-api.*Error.*Port)`, 'i'),
|
|
420
|
+
manageApi: new RegExp(`(EADDRINUSE.*:${manageApiPort}|port ${manageApiPort}.*already|Port ${manageApiPort}.*already|manage-api.*Error.*Port)`, 'i'),
|
|
421
|
+
};
|
|
422
|
+
// Monitor output for port errors (fallback in case ports become unavailable between check and start)
|
|
423
|
+
const checkForPortErrors = (data) => {
|
|
424
|
+
const output = data.toString();
|
|
425
|
+
if (portErrorPatterns.runApi.test(output)) {
|
|
426
|
+
portErrors.runApi = true;
|
|
427
|
+
}
|
|
428
|
+
if (portErrorPatterns.manageApi.test(output)) {
|
|
429
|
+
portErrors.manageApi = true;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
devProcess.stdout.on('data', checkForPortErrors);
|
|
433
|
+
// Give servers time to start
|
|
434
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
435
|
+
// Check if any port errors occurred during startup
|
|
436
|
+
if (portErrors.runApi || portErrors.manageApi) {
|
|
437
|
+
displayPortConflictError(portErrors);
|
|
438
|
+
}
|
|
439
|
+
// Run inkeep push
|
|
366
440
|
try {
|
|
367
441
|
await execAsync(`pnpm inkeep push --project src/projects/${config.projectId} --config src/inkeep.config.ts`);
|
|
368
442
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/create-agents",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.7",
|
|
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.29.
|
|
37
|
+
"@inkeep/agents-core": "0.29.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/degit": "^2.8.6",
|