@bpinhosilva/agent-orchestrator 1.0.0-alpha.32 → 1.0.0-alpha.33

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cli/commands/index.d.ts +2 -0
  3. package/dist/cli/commands/index.js +17 -0
  4. package/dist/cli/commands/logs.command.d.ts +2 -0
  5. package/dist/cli/commands/logs.command.js +92 -0
  6. package/dist/cli/commands/migrate.command.d.ts +2 -0
  7. package/dist/cli/commands/migrate.command.js +109 -0
  8. package/dist/cli/commands/run.command.d.ts +2 -0
  9. package/dist/cli/commands/run.command.js +97 -0
  10. package/dist/cli/commands/setup.command.d.ts +2 -0
  11. package/dist/cli/commands/setup.command.js +54 -0
  12. package/dist/cli/commands/status.command.d.ts +2 -0
  13. package/dist/cli/commands/status.command.js +23 -0
  14. package/dist/cli/commands/stop.command.d.ts +2 -0
  15. package/dist/cli/commands/stop.command.js +27 -0
  16. package/dist/cli/constants.d.ts +10 -0
  17. package/dist/cli/constants.js +51 -0
  18. package/dist/cli/env.d.ts +5 -0
  19. package/dist/cli/env.js +119 -0
  20. package/dist/cli/index.d.ts +3 -24
  21. package/dist/cli/index.js +19 -821
  22. package/dist/cli/process-manager.d.ts +9 -0
  23. package/dist/cli/process-manager.js +289 -0
  24. package/dist/cli/setup/admin.d.ts +7 -0
  25. package/dist/cli/setup/admin.js +149 -0
  26. package/dist/cli/setup/index.d.ts +2 -0
  27. package/dist/cli/setup/index.js +83 -0
  28. package/dist/cli/setup/prompts.d.ts +22 -0
  29. package/dist/cli/setup/prompts.js +218 -0
  30. package/dist/cli/setup/validators.d.ts +5 -0
  31. package/dist/cli/setup/validators.js +50 -0
  32. package/dist/cli/types.d.ts +98 -0
  33. package/dist/cli/types.js +4 -0
  34. package/dist/cli/utils.d.ts +3 -0
  35. package/dist/cli/utils.js +71 -0
  36. package/dist/migrations/1775487994565-20260406-AddMissingIndexesAndFKActions.d.ts +6 -0
  37. package/dist/migrations/1775487994565-20260406-AddMissingIndexesAndFKActions.js +123 -0
  38. package/dist/ui/assets/{AgentFleet-B9ZQHHad.js → AgentFleet-CAPR8X0_.js} +1 -1
  39. package/dist/ui/assets/{ConfirmDialog-BaFe6hWm.js → ConfirmDialog-DFNE1Ulb.js} +1 -1
  40. package/dist/ui/assets/{Profile-Dy_gmcSy.js → Profile-CW1w6WHT.js} +1 -1
  41. package/dist/ui/assets/{ProjectDetail-CE4h0Hhe.js → ProjectDetail-CqaebA9k.js} +1 -1
  42. package/dist/ui/assets/{Providers-CJkMiYXs.js → Providers-Dnd0Nu5d.js} +1 -1
  43. package/dist/ui/assets/{Scheduler-CsrAlyah.js → Scheduler-D6X1T24q.js} +1 -1
  44. package/dist/ui/assets/{Settings-C_xisf8p.js → Settings-CrHHDhsq.js} +1 -1
  45. package/dist/ui/assets/{TaskDetail-BQ7gWS-A.js → TaskDetail-CBJEpiIF.js} +1 -1
  46. package/dist/ui/assets/{TaskManager-DSC1aVcJ.js → TaskManager-DWqHRwWQ.js} +1 -1
  47. package/dist/ui/assets/{UserDetail-CYkZ1V6I.js → UserDetail-BWLv8D4I.js} +1 -1
  48. package/dist/ui/assets/{Users-S2ODYJFx.js → Users-BORCFzN3.js} +1 -1
  49. package/dist/ui/assets/{index-BImV2VVd.js → index-ozQxWpPV.js} +3 -3
  50. package/dist/ui/index.html +1 -1
  51. package/package.json +11 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.0.0-alpha.33](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.32...v1.0.0-alpha.33) (2026-04-06)
2
+
3
+
4
+ ### Features
5
+
6
+ * **cli:** refactor project, split into multiple components ([f18903b](https://github.com/bpinhosilva/agent-orchestrator/commit/f18903be0b1b09a1e651918d081d96267bfe2bc6))
7
+
1
8
  # [1.0.0-alpha.32](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.31...v1.0.0-alpha.32) (2026-04-06)
2
9
 
3
10
 
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerAllCommands(program: Command): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerAllCommands = registerAllCommands;
4
+ const setup_command_1 = require("./setup.command");
5
+ const run_command_1 = require("./run.command");
6
+ const stop_command_1 = require("./stop.command");
7
+ const status_command_1 = require("./status.command");
8
+ const logs_command_1 = require("./logs.command");
9
+ const migrate_command_1 = require("./migrate.command");
10
+ function registerAllCommands(program) {
11
+ (0, setup_command_1.registerSetupCommand)(program);
12
+ (0, run_command_1.registerRunCommand)(program);
13
+ (0, stop_command_1.registerStopCommand)(program);
14
+ (0, status_command_1.registerStatusCommand)(program);
15
+ (0, logs_command_1.registerLogsCommand)(program);
16
+ (0, migrate_command_1.registerMigrateCommand)(program);
17
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerLogsCommand(program: Command): void;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerLogsCommand = registerLogsCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const utils_1 = require("../utils");
39
+ const constants_1 = require("../constants");
40
+ function registerLogsCommand(program) {
41
+ program
42
+ .command('logs')
43
+ .description('Print the most recent orchestrator log lines')
44
+ .option('-n, --lines <count>', 'Number of log lines to print', '50')
45
+ .option('-f, --follow', 'Follow log output (like tail -f)', false)
46
+ .action((...args) => {
47
+ const opts = (0, utils_1.resolveActionOptions)(args);
48
+ try {
49
+ if (!fs.existsSync(constants_1.LOG_FILE)) {
50
+ console.log(`No log file found at ${constants_1.LOG_FILE}.`);
51
+ return;
52
+ }
53
+ const lineCount = Number(opts.lines || '50');
54
+ if (!Number.isInteger(lineCount) || lineCount < 1) {
55
+ throw new Error('The --lines option must be a positive integer.');
56
+ }
57
+ const content = fs.readFileSync(constants_1.LOG_FILE, 'utf8');
58
+ const output = (0, utils_1.tailLogLines)(content, lineCount);
59
+ if (output) {
60
+ console.log(output);
61
+ }
62
+ else if (!opts.follow) {
63
+ console.log('Log file is empty.');
64
+ }
65
+ if (opts.follow) {
66
+ let position = fs.statSync(constants_1.LOG_FILE).size;
67
+ fs.watchFile(constants_1.LOG_FILE, { interval: 200 }, () => {
68
+ try {
69
+ const stat = fs.statSync(constants_1.LOG_FILE);
70
+ if (stat.size > position) {
71
+ const length = stat.size - position;
72
+ const buffer = Buffer.alloc(length);
73
+ const fd = fs.openSync(constants_1.LOG_FILE, 'r');
74
+ fs.readSync(fd, buffer, 0, length, position);
75
+ fs.closeSync(fd);
76
+ position = stat.size;
77
+ process.stdout.write(buffer.toString('utf8'));
78
+ }
79
+ }
80
+ catch {
81
+ // log file may have been rotated; ignore
82
+ }
83
+ });
84
+ }
85
+ }
86
+ catch (err) {
87
+ const errorMessage = err instanceof Error ? err.message : String(err);
88
+ console.error(`Failed to read logs: ${errorMessage}`);
89
+ process.exit(1);
90
+ }
91
+ });
92
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerMigrateCommand(program: Command): void;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerMigrateCommand = registerMigrateCommand;
37
+ const utils_1 = require("../utils");
38
+ const migration_state_1 = require("../../database/migration-state");
39
+ async function confirmAction(message, autoConfirm = false) {
40
+ if (autoConfirm) {
41
+ return true;
42
+ }
43
+ const enquirer = await Promise.resolve().then(() => __importStar(require('enquirer')));
44
+ const { confirmed } = await enquirer.prompt({
45
+ type: 'confirm',
46
+ name: 'confirmed',
47
+ message,
48
+ initial: false,
49
+ });
50
+ return confirmed;
51
+ }
52
+ async function promptForEnter(message, autoConfirm = false) {
53
+ if (autoConfirm) {
54
+ return;
55
+ }
56
+ const enquirer = await Promise.resolve().then(() => __importStar(require('enquirer')));
57
+ await enquirer.prompt({
58
+ type: 'input',
59
+ name: 'continue',
60
+ message,
61
+ });
62
+ }
63
+ function registerMigrateCommand(program) {
64
+ program
65
+ .command('migrate')
66
+ .description('Run pending database migrations')
67
+ .option('-f, --force', 'Force re-initialization (DROP ALL DATA)')
68
+ .option('-y, --yes', 'Disable confirmation prompts')
69
+ .action(async (...args) => {
70
+ const opts = (0, utils_1.resolveActionOptions)(args);
71
+ try {
72
+ if (opts.force) {
73
+ const confirmForce = await confirmAction('Are you absolutely sure you want to DROP ALL DATA and re-initialize?', opts.yes);
74
+ if (confirmForce) {
75
+ await promptForEnter('Press Enter to confirm and start the destructive initialization...', opts.yes);
76
+ await (0, migration_state_1.runMigrations)(true);
77
+ }
78
+ else {
79
+ console.log('Force migration cancelled.');
80
+ }
81
+ return;
82
+ }
83
+ const { hasPending, isEmpty } = await (0, migration_state_1.checkPendingMigrations)({
84
+ assumePendingOnError: true,
85
+ });
86
+ if (isEmpty) {
87
+ console.log('Database is empty. Initializing...');
88
+ await (0, migration_state_1.runMigrations)();
89
+ return;
90
+ }
91
+ if (!hasPending) {
92
+ console.log('Database is already up to date.');
93
+ return;
94
+ }
95
+ const confirmMigration = await confirmAction('Pending migrations detected. Do you want to run them?', opts.yes);
96
+ if (confirmMigration) {
97
+ await (0, migration_state_1.runMigrations)();
98
+ }
99
+ else {
100
+ console.log('Migration cancelled.');
101
+ }
102
+ }
103
+ catch (err) {
104
+ const errorMessage = err instanceof Error ? err.message : String(err);
105
+ console.error(`Migration failed: ${errorMessage}`);
106
+ process.exit(1);
107
+ }
108
+ });
109
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerRunCommand(program: Command): void;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerRunCommand = registerRunCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const child_process_1 = require("child_process");
39
+ const process_manager_1 = require("../process-manager");
40
+ const env_1 = require("../env");
41
+ const constants_1 = require("../constants");
42
+ function getConfiguredPort() {
43
+ const env = (0, env_1.readEnvFile)(constants_1.ENV_PATH);
44
+ return env.PORT || '15789';
45
+ }
46
+ function registerRunCommand(program) {
47
+ program
48
+ .command('run')
49
+ .description('Start the orchestrator server in detached mode')
50
+ .action(() => {
51
+ try {
52
+ (0, process_manager_1.assertBuildExists)();
53
+ const existingProcess = (0, process_manager_1.findManagedProcess)();
54
+ if (existingProcess) {
55
+ console.log(`Orchestrator is already running.\n${(0, process_manager_1.formatProcessSummary)(existingProcess)}`);
56
+ return;
57
+ }
58
+ console.log('Starting Agent Orchestrator in background...');
59
+ if (!fs.existsSync(constants_1.PID_DIR)) {
60
+ fs.mkdirSync(constants_1.PID_DIR, { recursive: true, mode: 0o700 });
61
+ }
62
+ const logStream = fs.openSync(constants_1.LOG_FILE, 'a');
63
+ const child = (0, child_process_1.spawn)('node', [constants_1.MAIN_FILE], {
64
+ detached: true,
65
+ stdio: ['ignore', logStream, logStream],
66
+ cwd: constants_1.PACKAGE_ROOT,
67
+ env: (0, process_manager_1.getChildEnvironment)(),
68
+ });
69
+ const pid = child.pid;
70
+ if (!pid) {
71
+ throw new Error('Failed to determine spawned process PID.');
72
+ }
73
+ const port = getConfiguredPort();
74
+ (0, process_manager_1.persistProcessMetadata)({
75
+ pid,
76
+ cwd: constants_1.PACKAGE_ROOT,
77
+ mainPath: constants_1.MAIN_FILE,
78
+ port,
79
+ logFile: constants_1.LOG_FILE,
80
+ startedAt: new Date().toISOString(),
81
+ });
82
+ child.unref();
83
+ console.log(`Orchestrator started in background.\n${(0, process_manager_1.formatProcessSummary)({
84
+ pid,
85
+ source: 'metadata',
86
+ cwd: constants_1.PACKAGE_ROOT,
87
+ mainPath: constants_1.MAIN_FILE,
88
+ port,
89
+ })}`);
90
+ }
91
+ catch (err) {
92
+ const errorMessage = err instanceof Error ? err.message : String(err);
93
+ console.error(`Failed to start orchestrator: ${errorMessage}`);
94
+ process.exit(1);
95
+ }
96
+ });
97
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerSetupCommand(program: Command): void;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerSetupCommand = registerSetupCommand;
4
+ const utils_1 = require("../utils");
5
+ const index_1 = require("../setup/index");
6
+ const migration_state_1 = require("../../database/migration-state");
7
+ function registerSetupCommand(program) {
8
+ program
9
+ .command('setup')
10
+ .description('Create or update the local CLI runtime configuration')
11
+ .option('--port <port>', 'Server port for the orchestrator runtime')
12
+ .option('--db-type <type>', 'Database type: sqlite or postgres')
13
+ .option('--database-url <url>', 'PostgreSQL connection string')
14
+ .option('--db-logging', 'Enable database query logging')
15
+ .option('--provider <provider>', 'Configure a provider (gemini, anthropic)', (value, previous = []) => previous.concat(value
16
+ .split(',')
17
+ .map((item) => item.trim().toLowerCase())
18
+ .filter(Boolean)), [])
19
+ .option('--gemini-key <key>', 'Google Gemini API key')
20
+ .option('--anthropic-key <key>', 'Anthropic Claude API key')
21
+ .option('-y, --yes', 'Disable prompts and use supplied flags/defaults')
22
+ .option('--skip-admin-setup', 'Skip creating or updating the admin user')
23
+ .option('--admin-name <name>', 'Admin user name for non-interactive setup')
24
+ .option('--admin-email <email>', 'Admin user email for non-interactive setup')
25
+ .option('--admin-password <password>', 'Admin user password for non-interactive setup')
26
+ .option('--regenerate-jwt-secret', 'Generate a new JWT secret instead of preserving the existing one')
27
+ .action(async (...args) => {
28
+ const opts = (0, utils_1.resolveActionOptions)(args);
29
+ console.log('Starting setup...');
30
+ try {
31
+ await (0, index_1.handleSetup)(opts);
32
+ if (opts.yes) {
33
+ const { hasPending, isEmpty } = await (0, migration_state_1.checkPendingMigrations)({
34
+ assumePendingOnError: true,
35
+ });
36
+ if (isEmpty) {
37
+ console.log('Database is empty. Initializing...');
38
+ await (0, migration_state_1.runMigrations)();
39
+ }
40
+ else if (hasPending) {
41
+ await (0, migration_state_1.runMigrations)();
42
+ }
43
+ else {
44
+ console.log('Database is already up to date.');
45
+ }
46
+ }
47
+ }
48
+ catch (err) {
49
+ const errorMessage = err instanceof Error ? err.message : String(err);
50
+ console.error(`Setup failed: ${errorMessage}`);
51
+ process.exit(1);
52
+ }
53
+ });
54
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerStatusCommand(program: Command): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerStatusCommand = registerStatusCommand;
4
+ const process_manager_1 = require("../process-manager");
5
+ function registerStatusCommand(program) {
6
+ program
7
+ .command('status')
8
+ .description('Show the currently running orchestrator process, if any')
9
+ .action(() => {
10
+ try {
11
+ const runningProcess = (0, process_manager_1.findManagedProcess)();
12
+ if (!runningProcess) {
13
+ console.log('Orchestrator is not running.');
14
+ return;
15
+ }
16
+ console.log(`Orchestrator is running.\n${(0, process_manager_1.formatProcessSummary)(runningProcess)}`);
17
+ }
18
+ catch (err) {
19
+ const errorMessage = err instanceof Error ? err.message : String(err);
20
+ console.error(`Failed to inspect orchestrator status: ${errorMessage}`);
21
+ }
22
+ });
23
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerStopCommand(program: Command): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerStopCommand = registerStopCommand;
4
+ const process_manager_1 = require("../process-manager");
5
+ function registerStopCommand(program) {
6
+ program
7
+ .command('stop')
8
+ .description('Stop the orchestrator server after verifying the running process identity')
9
+ .action(() => {
10
+ try {
11
+ const runningProcess = (0, process_manager_1.findManagedProcess)();
12
+ if (!runningProcess) {
13
+ console.log('Orchestrator is not running.');
14
+ return;
15
+ }
16
+ console.log(`Stopping Orchestrator after verifying the exact process in ${runningProcess.cwd} (PID: ${runningProcess.pid})...`);
17
+ process.kill(runningProcess.pid, 'SIGTERM');
18
+ (0, process_manager_1.removeRuntimeState)();
19
+ console.log('Orchestrator stop signal sent.');
20
+ }
21
+ catch (err) {
22
+ const errorMessage = err instanceof Error ? err.message : String(err);
23
+ console.error(`Failed to stop orchestrator: ${errorMessage}`);
24
+ process.exit(1);
25
+ }
26
+ });
27
+ }
@@ -0,0 +1,10 @@
1
+ export { SUPPORTED_PROVIDERS } from './types';
2
+ export declare const PACKAGE_ROOT: string;
3
+ export declare const PACKAGE_JSON_PATH: string;
4
+ export declare const MAIN_FILE: string;
5
+ export declare const UI_INDEX_FILE: string;
6
+ export declare const PID_DIR: string;
7
+ export declare const PID_FILE: string;
8
+ export declare const LOG_FILE: string;
9
+ export declare const ENV_PATH: string;
10
+ export declare const PROCESS_FILE: string;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PROCESS_FILE = exports.ENV_PATH = exports.LOG_FILE = exports.PID_FILE = exports.PID_DIR = exports.UI_INDEX_FILE = exports.MAIN_FILE = exports.PACKAGE_JSON_PATH = exports.PACKAGE_ROOT = exports.SUPPORTED_PROVIDERS = void 0;
37
+ const os = __importStar(require("os"));
38
+ const path = __importStar(require("path"));
39
+ var types_1 = require("./types");
40
+ Object.defineProperty(exports, "SUPPORTED_PROVIDERS", { enumerable: true, get: function () { return types_1.SUPPORTED_PROVIDERS; } });
41
+ exports.PACKAGE_ROOT = path.resolve(__dirname, '..', '..');
42
+ exports.PACKAGE_JSON_PATH = path.join(exports.PACKAGE_ROOT, 'package.json');
43
+ exports.MAIN_FILE = path.join(exports.PACKAGE_ROOT, 'dist/main.js');
44
+ exports.UI_INDEX_FILE = path.join(exports.PACKAGE_ROOT, 'dist/ui/index.html');
45
+ // These are set at process start before any imports, so the env var is always present
46
+ exports.PID_DIR = process.env.AGENT_ORCHESTRATOR_HOME ??
47
+ path.join(os.homedir(), '.agent-orchestrator');
48
+ exports.PID_FILE = path.join(exports.PID_DIR, 'pid');
49
+ exports.LOG_FILE = path.join(exports.PID_DIR, 'server.log');
50
+ exports.ENV_PATH = path.join(exports.PID_DIR, '.env');
51
+ exports.PROCESS_FILE = path.join(exports.PID_DIR, 'process.json');
@@ -0,0 +1,5 @@
1
+ import type { BasicConfig, FileSystem } from './types';
2
+ export declare function parseEnvContent(content: string): Record<string, string>;
3
+ export declare function readEnvFile(envPath?: string, fsDep?: FileSystem): Record<string, string>;
4
+ export declare function writePrivateFile(filePath: string, content: string, fsDep?: FileSystem): void;
5
+ export declare function buildEnvContent(currentEnv: Record<string, string>, basicConfig: BasicConfig, databaseUrl: string, geminiKey: string, anthropicKey: string, jwtSecret: string, jwtRefreshSecret: string): string;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.parseEnvContent = parseEnvContent;
37
+ exports.readEnvFile = readEnvFile;
38
+ exports.writePrivateFile = writePrivateFile;
39
+ exports.buildEnvContent = buildEnvContent;
40
+ const fs = __importStar(require("fs"));
41
+ const constants_1 = require("./constants");
42
+ const realFs = fs;
43
+ function parseEnvContent(content) {
44
+ return content
45
+ .split(/\r?\n/)
46
+ .map((line) => line.trim())
47
+ .filter((line) => line && !line.startsWith('#'))
48
+ .reduce((acc, line) => {
49
+ const separatorIndex = line.indexOf('=');
50
+ if (separatorIndex === -1) {
51
+ return acc;
52
+ }
53
+ const key = line.slice(0, separatorIndex).trim();
54
+ if (!key || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))
55
+ return acc;
56
+ const value = line.slice(separatorIndex + 1).trim();
57
+ acc[key] = value;
58
+ return acc;
59
+ }, {});
60
+ }
61
+ function readEnvFile(envPath = constants_1.ENV_PATH, fsDep = realFs) {
62
+ if (!fsDep.existsSync(envPath)) {
63
+ return {};
64
+ }
65
+ try {
66
+ return parseEnvContent(fsDep.readFileSync(envPath, 'utf8'));
67
+ }
68
+ catch {
69
+ return {};
70
+ }
71
+ }
72
+ function writePrivateFile(filePath, content, fsDep = realFs) {
73
+ fsDep.writeFileSync(filePath, content, { mode: 0o600 });
74
+ fsDep.chmodSync(filePath, 0o600);
75
+ }
76
+ function buildEnvContent(currentEnv, basicConfig, databaseUrl, geminiKey, anthropicKey, jwtSecret, jwtRefreshSecret) {
77
+ const envValues = {
78
+ ...currentEnv,
79
+ NODE_ENV: 'production',
80
+ PORT: basicConfig.port,
81
+ DB_TYPE: basicConfig.dbType,
82
+ DB_LOGGING: `${basicConfig.dbLogging}`,
83
+ CHECK_PENDING_MIGRATIONS_ON_STARTUP: currentEnv.CHECK_PENDING_MIGRATIONS_ON_STARTUP || 'true',
84
+ JWT_SECRET: jwtSecret,
85
+ JWT_REFRESH_SECRET: jwtRefreshSecret,
86
+ };
87
+ if (databaseUrl.trim()) {
88
+ envValues.DATABASE_URL = databaseUrl;
89
+ }
90
+ else {
91
+ delete envValues.DATABASE_URL;
92
+ }
93
+ if (geminiKey) {
94
+ envValues.GEMINI_API_KEY = geminiKey;
95
+ }
96
+ if (anthropicKey) {
97
+ envValues.ANTHROPIC_API_KEY = anthropicKey;
98
+ }
99
+ const orderedKeys = [
100
+ 'NODE_ENV',
101
+ 'PORT',
102
+ 'DB_TYPE',
103
+ 'DB_LOGGING',
104
+ 'CHECK_PENDING_MIGRATIONS_ON_STARTUP',
105
+ 'DATABASE_URL',
106
+ 'GEMINI_API_KEY',
107
+ 'ANTHROPIC_API_KEY',
108
+ 'JWT_SECRET',
109
+ 'JWT_REFRESH_SECRET',
110
+ ];
111
+ const remainingKeys = Object.keys(envValues)
112
+ .filter((key) => !orderedKeys.includes(key))
113
+ .sort();
114
+ return [...orderedKeys, ...remainingKeys]
115
+ .filter((key) => envValues[key] !== undefined && envValues[key] !== '')
116
+ .map((key) => `${key}=${envValues[key]}`)
117
+ .join('\n')
118
+ .concat('\n');
119
+ }