@inkeep/agents-cli 0.1.0 → 0.1.2
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/LICENSE.md +22 -17
- package/README.md +1 -13
- package/dist/__tests__/config-validation.test.js +7 -15
- package/dist/__tests__/utils/ts-loader.test.js +0 -1
- package/dist/commands/pull.js +0 -8
- package/dist/config.d.ts +6 -36
- package/dist/config.js +9 -292
- package/dist/index.d.ts +2 -2
- package/dist/index.js +37359 -96
- package/dist/index.js.map +7 -0
- package/dist/utils/ts-loader.js +0 -1
- package/package.json +22 -21
- package/dist/__tests__/commands/pull-retry.test.d.ts +0 -1
- package/dist/__tests__/commands/pull-retry.test.js +0 -156
- package/dist/__tests__/utils/port-manager.test.d.ts +0 -1
- package/dist/__tests__/utils/port-manager.test.js +0 -144
- package/dist/commands/mcp-list.d.ts +0 -4
- package/dist/commands/mcp-list.js +0 -156
- package/dist/commands/mcp-start-simple.d.ts +0 -5
- package/dist/commands/mcp-start-simple.js +0 -193
- package/dist/commands/mcp-start.d.ts +0 -5
- package/dist/commands/mcp-start.js +0 -217
- package/dist/commands/mcp-status.d.ts +0 -1
- package/dist/commands/mcp-status.js +0 -96
- package/dist/commands/mcp-stop.d.ts +0 -5
- package/dist/commands/mcp-stop.js +0 -160
- package/dist/utils/port-manager.d.ts +0 -43
- package/dist/utils/port-manager.js +0 -92
package/LICENSE.md
CHANGED
|
@@ -5,47 +5,52 @@ This file is automatically copied from the root LICENSE.md during build.
|
|
|
5
5
|
Any changes should be made to the root LICENSE.md file.
|
|
6
6
|
-->
|
|
7
7
|
|
|
8
|
-
Elastic License
|
|
9
|
-
|
|
8
|
+
# Inkeep SDK – Elastic License 2.0 with Supplemental Terms
|
|
9
|
+
|
|
10
|
+
NOTE: The Inkeep SDK is licensed under the Elastic License 2.0 (ELv2), subject to Supplemental Terms included in [SUPPLEMENTAL_TERMS.md](SUPPLEMENTAL_TERMS.md). In the event of conflict, the Supplemental Terms control.
|
|
11
|
+
|
|
12
|
+
# Elastic License 2.0
|
|
13
|
+
|
|
14
|
+
## Acceptance
|
|
10
15
|
By using the software, you agree to all of the terms and conditions below.
|
|
11
16
|
|
|
12
|
-
Copyright License
|
|
17
|
+
## Copyright License
|
|
13
18
|
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below.
|
|
14
19
|
|
|
15
|
-
Limitations
|
|
20
|
+
## Limitations
|
|
16
21
|
You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
|
|
17
22
|
|
|
18
23
|
You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
|
|
19
24
|
|
|
20
25
|
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
21
26
|
|
|
22
|
-
Patents
|
|
27
|
+
## Patents
|
|
23
28
|
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
24
29
|
|
|
25
|
-
Notices
|
|
30
|
+
## Notices
|
|
26
31
|
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
27
32
|
|
|
28
33
|
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
29
34
|
|
|
30
|
-
No Other Rights
|
|
35
|
+
## No Other Rights
|
|
31
36
|
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
32
37
|
|
|
33
|
-
Termination
|
|
38
|
+
## Termination
|
|
34
39
|
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
35
40
|
|
|
36
|
-
No Liability
|
|
37
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim
|
|
41
|
+
## No Liability
|
|
42
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
38
43
|
|
|
39
|
-
Definitions
|
|
40
|
-
The licensor is the entity offering these terms, and the software is the software the licensor makes available under these terms, including any portion of it.
|
|
44
|
+
## Definitions
|
|
45
|
+
The **licensor** is the entity offering these terms, and the **software** is the software the licensor makes available under these terms, including any portion of it.
|
|
41
46
|
|
|
42
|
-
you refers to the individual or entity agreeing to these terms.
|
|
47
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
43
48
|
|
|
44
|
-
your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
49
|
+
**your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
45
50
|
|
|
46
|
-
your licenses are all the licenses granted to you for the software under these terms.
|
|
51
|
+
**your licenses** are all the licenses granted to you for the software under these terms.
|
|
47
52
|
|
|
48
|
-
use means anything you do with the software requiring one of your licenses.
|
|
53
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
49
54
|
|
|
50
|
-
trademark means trademarks, service marks, and similar rights.
|
|
55
|
+
**trademark** means trademarks, service marks, and similar rights.
|
|
51
56
|
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ A command-line interface for managing and interacting with Inkeep Agent Framewor
|
|
|
67
67
|
### Configuration Sources (priority order)
|
|
68
68
|
|
|
69
69
|
1. **Command-line flags** - Highest priority (e.g., `--tenant-id`, `--api-url`)
|
|
70
|
-
2. **Environment variables** - `
|
|
70
|
+
2. **Environment variables** - `INKEEP_API_URL`
|
|
71
71
|
3. **`.env` file** - In current directory
|
|
72
72
|
4. **Config file** - `inkeep.config.ts` or `.inkeeprc.ts/js`
|
|
73
73
|
5. **Defaults** - Lowest priority (api-url defaults to `http://localhost:3002`)
|
|
@@ -77,14 +77,12 @@ A command-line interface for managing and interacting with Inkeep Agent Framewor
|
|
|
77
77
|
Create a `.env` file in your project directory:
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
INKEEP_TENANT_ID=your-tenant-id
|
|
81
80
|
INKEEP_API_URL=http://localhost:3002
|
|
82
81
|
```
|
|
83
82
|
|
|
84
83
|
Or export them in your shell:
|
|
85
84
|
|
|
86
85
|
```bash
|
|
87
|
-
export INKEEP_TENANT_ID=your-tenant-id
|
|
88
86
|
export INKEEP_API_URL=http://localhost:3002
|
|
89
87
|
```
|
|
90
88
|
|
|
@@ -372,7 +370,6 @@ inkeep push graph.js --url https://staging-api.example.com
|
|
|
372
370
|
```bash
|
|
373
371
|
# Using environment variables
|
|
374
372
|
export INKEEP_API_URL=https://api.example.com
|
|
375
|
-
export INKEEP_TENANT_ID=prod-tenant
|
|
376
373
|
inkeep list-graphs
|
|
377
374
|
```
|
|
378
375
|
|
|
@@ -436,15 +433,6 @@ agents-cli/
|
|
|
436
433
|
|
|
437
434
|
### Common Issues
|
|
438
435
|
|
|
439
|
-
**"No tenant ID configured"**
|
|
440
|
-
```bash
|
|
441
|
-
# Set tenant ID
|
|
442
|
-
inkeep tenant your-tenant-id
|
|
443
|
-
|
|
444
|
-
# Or use environment variable
|
|
445
|
-
export INKEEP_TENANT_ID=your-tenant-id
|
|
446
|
-
```
|
|
447
|
-
|
|
448
436
|
**"Failed to fetch graphs" or connection errors**
|
|
449
437
|
```bash
|
|
450
438
|
# Check if backend is running
|
|
@@ -15,9 +15,8 @@ describe('Configuration Validation', () => {
|
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
vi.clearAllMocks();
|
|
17
17
|
process.env = { ...originalEnv };
|
|
18
|
-
delete process.env.INKEEP_TENANT_ID;
|
|
19
18
|
delete process.env.INKEEP_API_URL;
|
|
20
|
-
delete process.env.
|
|
19
|
+
delete process.env.INKEEP_AGENTS_MANAGE_API_URL;
|
|
21
20
|
delete process.env.INKEEP_EXECUTION_API_URL;
|
|
22
21
|
});
|
|
23
22
|
afterEach(() => {
|
|
@@ -36,20 +35,17 @@ describe('Configuration Validation', () => {
|
|
|
36
35
|
expect(config.sources.executionApiUrl).toBe('command-line flag (--execution-api-url)');
|
|
37
36
|
});
|
|
38
37
|
it('should use environment variables when no flags provided', async () => {
|
|
39
|
-
process.env.
|
|
40
|
-
process.env.INKEEP_MANAGEMENT_API_URL = 'http://localhost:9090';
|
|
38
|
+
process.env.INKEEP_AGENTS_MANAGE_API_URL = 'http://localhost:9090';
|
|
41
39
|
process.env.INKEEP_EXECUTION_API_URL = 'http://localhost:9091';
|
|
42
40
|
const config = await validateConfiguration(undefined, undefined, undefined, undefined);
|
|
43
41
|
expect(config.tenantId).toBe('env-tenant');
|
|
44
42
|
expect(config.managementApiUrl).toBe('http://localhost:9090');
|
|
45
43
|
expect(config.executionApiUrl).toBe('http://localhost:9091');
|
|
46
|
-
expect(config.sources.
|
|
47
|
-
expect(config.sources.managementApiUrl).toBe('environment variable (INKEEP_MANAGEMENT_API_URL)');
|
|
44
|
+
expect(config.sources.managementApiUrl).toBe('environment variable (INKEEP_AGENTS_MANAGE_API_URL)');
|
|
48
45
|
expect(config.sources.executionApiUrl).toBe('environment variable (INKEEP_EXECUTION_API_URL)');
|
|
49
46
|
});
|
|
50
47
|
it('should allow command-line flags to override environment variables', async () => {
|
|
51
|
-
process.env.
|
|
52
|
-
process.env.INKEEP_MANAGEMENT_API_URL = 'http://localhost:9090';
|
|
48
|
+
process.env.INKEEP_AGENTS_MANAGE_API_URL = 'http://localhost:9090';
|
|
53
49
|
process.env.INKEEP_EXECUTION_API_URL = 'http://localhost:9091';
|
|
54
50
|
const config = await validateConfiguration('cli-tenant', 'http://cli-management', 'http://cli-execution', undefined);
|
|
55
51
|
expect(config.tenantId).toBe('cli-tenant');
|
|
@@ -80,24 +76,20 @@ describe('Configuration Validation', () => {
|
|
|
80
76
|
expect(config.sources.configFile).toBeUndefined();
|
|
81
77
|
});
|
|
82
78
|
it('should correctly identify environment variable sources', async () => {
|
|
83
|
-
process.env.
|
|
84
|
-
process.env.INKEEP_MANAGEMENT_API_URL = 'http://env-management';
|
|
79
|
+
process.env.INKEEP_AGENTS_MANAGE_API_URL = 'http://env-management';
|
|
85
80
|
process.env.INKEEP_EXECUTION_API_URL = 'http://env-execution';
|
|
86
81
|
const config = await validateConfiguration(undefined, undefined, undefined, undefined);
|
|
87
|
-
expect(config.sources.
|
|
88
|
-
expect(config.sources.managementApiUrl).toBe('environment variable (INKEEP_MANAGEMENT_API_URL)');
|
|
82
|
+
expect(config.sources.managementApiUrl).toBe('environment variable (INKEEP_AGENTS_MANAGE_API_URL)');
|
|
89
83
|
expect(config.sources.executionApiUrl).toBe('environment variable (INKEEP_EXECUTION_API_URL)');
|
|
90
84
|
});
|
|
91
85
|
it('should correctly identify mixed sources with env and flag', async () => {
|
|
92
|
-
process.env.
|
|
93
|
-
process.env.INKEEP_MANAGEMENT_API_URL = 'http://env-management';
|
|
86
|
+
process.env.INKEEP_AGENTS_MANAGE_API_URL = 'http://env-management';
|
|
94
87
|
process.env.INKEEP_EXECUTION_API_URL = 'http://env-execution';
|
|
95
88
|
// Override only the management API URL with a flag
|
|
96
89
|
const config = await validateConfiguration(undefined, 'http://override-management', undefined, undefined);
|
|
97
90
|
expect(config.tenantId).toBe('env-tenant');
|
|
98
91
|
expect(config.managementApiUrl).toBe('http://override-management');
|
|
99
92
|
expect(config.executionApiUrl).toBe('http://env-execution');
|
|
100
|
-
expect(config.sources.tenantId).toBe('environment variable (INKEEP_TENANT_ID)');
|
|
101
93
|
expect(config.sources.managementApiUrl).toBe('command-line flag (--management-api-url)');
|
|
102
94
|
expect(config.sources.executionApiUrl).toBe('environment variable (INKEEP_EXECUTION_API_URL)');
|
|
103
95
|
});
|
|
@@ -189,7 +189,6 @@ export const complexConfig = {
|
|
|
189
189
|
const moduleContent = `
|
|
190
190
|
export const envValue = process.env.ENVIRONMENT;
|
|
191
191
|
export const dbFileName = process.env.DB_FILE_NAME;
|
|
192
|
-
export const tenantId = process.env.INKEEP_TENANT_ID;
|
|
193
192
|
`;
|
|
194
193
|
writeFileSync(testGraphFile, moduleContent);
|
|
195
194
|
try {
|
package/dist/commands/pull.js
CHANGED
|
@@ -101,14 +101,6 @@ export async function convertTypeScriptToJson(graphPath) {
|
|
|
101
101
|
// Get the graph instance
|
|
102
102
|
const graphKey = graphExports[0];
|
|
103
103
|
const graph = module[graphKey];
|
|
104
|
-
// Inject configuration into the graph
|
|
105
|
-
// if (typeof graph.setConfig === 'function') {
|
|
106
|
-
// graph.setConfig(
|
|
107
|
-
// process.env.TENANT_ID || 'inkeep',
|
|
108
|
-
// process.env.PROJECT_ID || 'cm8q9j9l0005gs601sm5eg58l',
|
|
109
|
-
// process.env.MANAGEMENT_API_URL || 'http://localhost:3002'
|
|
110
|
-
// );
|
|
111
|
-
// }
|
|
112
104
|
// Get the full graph definition using the same method as push
|
|
113
105
|
return await graph.toFullGraphDefinition();
|
|
114
106
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,43 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
projectId?: string;
|
|
5
|
-
managementApiUrl?: string;
|
|
6
|
-
executionApiUrl?: string;
|
|
7
|
-
outputDirectory?: string;
|
|
8
|
-
modelSettings?: ModelSettings;
|
|
9
|
-
}
|
|
10
|
-
export interface ValidatedConfiguration {
|
|
1
|
+
import { ModelSettings } from '@inkeep/agents-core';
|
|
2
|
+
|
|
3
|
+
interface InkeepConfig {
|
|
11
4
|
tenantId: string;
|
|
12
5
|
projectId: string;
|
|
13
6
|
managementApiUrl: string;
|
|
14
7
|
executionApiUrl: string;
|
|
15
8
|
outputDirectory?: string;
|
|
16
9
|
modelSettings?: ModelSettings;
|
|
17
|
-
sources: {
|
|
18
|
-
tenantId: string;
|
|
19
|
-
projectId: string;
|
|
20
|
-
managementApiUrl: string;
|
|
21
|
-
executionApiUrl: string;
|
|
22
|
-
configFile?: string;
|
|
23
|
-
};
|
|
24
10
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export
|
|
28
|
-
export declare function getManagementApiUrl(overrideUrl?: string, configPath?: string): Promise<string>;
|
|
29
|
-
export declare function getExecutionApiUrl(overrideUrl?: string, configPath?: string): Promise<string>;
|
|
30
|
-
/**
|
|
31
|
-
* Validates configuration according to these rules:
|
|
32
|
-
* 1. If --config-file-path is provided, use it (cannot be combined with --tenant-id)
|
|
33
|
-
* 2. If --tenant-id AND --management-api-url AND --execution-api-url are provided, use them (cannot be combined with --config-file-path)
|
|
34
|
-
* 3. If only --management-api-url and --execution-api-url are provided, it overrides the managementApiUrl and executionApiUrl from default config
|
|
35
|
-
* 4. Otherwise, look for default config file (inkeep.config.ts)
|
|
36
|
-
*
|
|
37
|
-
* @param tenantIdFlag - tenantId from command line flag
|
|
38
|
-
* @param managementApiUrlFlag - managementApiUrl from command line flag
|
|
39
|
-
* @param executionApiUrlFlag - executionApiUrl from command line flag
|
|
40
|
-
* @param configFilePath - explicit path to config file
|
|
41
|
-
* @returns configuration with tenantId, managementApiUrl, and sources used
|
|
42
|
-
*/
|
|
43
|
-
export declare function validateConfiguration(tenantIdFlag?: string, managementApiUrlFlag?: string, executionApiUrlFlag?: string, configFilePath?: string): Promise<ValidatedConfiguration>;
|
|
11
|
+
declare function defineConfig(config: InkeepConfig): InkeepConfig;
|
|
12
|
+
|
|
13
|
+
export { type InkeepConfig, defineConfig };
|
package/dist/config.js
CHANGED
|
@@ -1,292 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function findConfigFile(startPath = process.cwd()) {
|
|
11
|
-
let currentPath = resolve(startPath);
|
|
12
|
-
const root = '/';
|
|
13
|
-
const configNames = ['inkeep.config.ts', 'inkeep.config.js', '.inkeeprc.ts', '.inkeeprc.js'];
|
|
14
|
-
while (currentPath !== root) {
|
|
15
|
-
// Check for config files at this level
|
|
16
|
-
for (const configName of configNames) {
|
|
17
|
-
const configPath = join(currentPath, configName);
|
|
18
|
-
if (existsSync(configPath)) {
|
|
19
|
-
return configPath;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const parentPath = dirname(currentPath);
|
|
23
|
-
if (parentPath === currentPath) {
|
|
24
|
-
break; // Reached filesystem root
|
|
25
|
-
}
|
|
26
|
-
currentPath = parentPath;
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
async function loadConfigFromFile(configPath) {
|
|
31
|
-
let resolvedPath;
|
|
32
|
-
if (configPath) {
|
|
33
|
-
// User specified a config path
|
|
34
|
-
resolvedPath = resolve(process.cwd(), configPath);
|
|
35
|
-
if (!existsSync(resolvedPath)) {
|
|
36
|
-
throw new Error(`Config file not found: ${resolvedPath}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// Search for config file
|
|
41
|
-
resolvedPath = findConfigFile();
|
|
42
|
-
if (!resolvedPath) {
|
|
43
|
-
// No config file found
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const fileUrl = pathToFileURL(resolvedPath).href;
|
|
49
|
-
const module = await import(fileUrl);
|
|
50
|
-
// Support both default export and named export
|
|
51
|
-
const config = module.default || module.config;
|
|
52
|
-
if (!config) {
|
|
53
|
-
throw new Error(`No config exported from ${resolvedPath}`);
|
|
54
|
-
}
|
|
55
|
-
return config;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
// If loading a TypeScript file fails, try using the ts-loader utility
|
|
59
|
-
try {
|
|
60
|
-
const { loadTypeScriptModule } = await import('./utils/ts-loader.js');
|
|
61
|
-
const module = await loadTypeScriptModule(resolvedPath);
|
|
62
|
-
return module.default || module.config || null;
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
console.warn(`Warning: Failed to load config file ${resolvedPath}:`, error);
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export async function loadConfig(configPath) {
|
|
71
|
-
// Default config
|
|
72
|
-
const config = {
|
|
73
|
-
managementApiUrl: 'http://localhost:3002',
|
|
74
|
-
executionApiUrl: 'http://localhost:3003',
|
|
75
|
-
};
|
|
76
|
-
// Try to load from inkeep.config.ts or specified config file
|
|
77
|
-
const fileConfig = await loadConfigFromFile(configPath);
|
|
78
|
-
if (fileConfig) {
|
|
79
|
-
Object.assign(config, fileConfig);
|
|
80
|
-
}
|
|
81
|
-
// Override with environment variables if present
|
|
82
|
-
if (process.env.INKEEP_TENANT_ID) {
|
|
83
|
-
config.tenantId = process.env.INKEEP_TENANT_ID;
|
|
84
|
-
}
|
|
85
|
-
if (process.env.INKEEP_PROJECT_ID) {
|
|
86
|
-
config.projectId = process.env.INKEEP_PROJECT_ID;
|
|
87
|
-
}
|
|
88
|
-
if (process.env.INKEEP_MANAGEMENT_API_URL) {
|
|
89
|
-
config.managementApiUrl = process.env.INKEEP_MANAGEMENT_API_URL;
|
|
90
|
-
}
|
|
91
|
-
if (process.env.INKEEP_EXECUTION_API_URL) {
|
|
92
|
-
config.executionApiUrl = process.env.INKEEP_EXECUTION_API_URL;
|
|
93
|
-
}
|
|
94
|
-
if (process.env.INKEEP_EXECUTION_API_URL) {
|
|
95
|
-
config.executionApiUrl = process.env.INKEEP_EXECUTION_API_URL;
|
|
96
|
-
}
|
|
97
|
-
return config;
|
|
98
|
-
}
|
|
99
|
-
export async function getTenantId(configPath) {
|
|
100
|
-
const config = await loadConfig(configPath);
|
|
101
|
-
return config.tenantId;
|
|
102
|
-
}
|
|
103
|
-
export async function getProjectId(configPath) {
|
|
104
|
-
const config = await loadConfig(configPath);
|
|
105
|
-
return config.projectId || 'default';
|
|
106
|
-
}
|
|
107
|
-
export async function getManagementApiUrl(overrideUrl, configPath) {
|
|
108
|
-
// Priority: override > config/env > default
|
|
109
|
-
if (overrideUrl) {
|
|
110
|
-
return overrideUrl;
|
|
111
|
-
}
|
|
112
|
-
const config = await loadConfig(configPath);
|
|
113
|
-
return config.managementApiUrl || 'http://localhost:3002';
|
|
114
|
-
}
|
|
115
|
-
export async function getExecutionApiUrl(overrideUrl, configPath) {
|
|
116
|
-
// Priority: override > config/env > default
|
|
117
|
-
if (overrideUrl) {
|
|
118
|
-
return overrideUrl;
|
|
119
|
-
}
|
|
120
|
-
const config = await loadConfig(configPath);
|
|
121
|
-
return config.executionApiUrl || 'http://localhost:3003';
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Validates configuration according to these rules:
|
|
125
|
-
* 1. If --config-file-path is provided, use it (cannot be combined with --tenant-id)
|
|
126
|
-
* 2. If --tenant-id AND --management-api-url AND --execution-api-url are provided, use them (cannot be combined with --config-file-path)
|
|
127
|
-
* 3. If only --management-api-url and --execution-api-url are provided, it overrides the managementApiUrl and executionApiUrl from default config
|
|
128
|
-
* 4. Otherwise, look for default config file (inkeep.config.ts)
|
|
129
|
-
*
|
|
130
|
-
* @param tenantIdFlag - tenantId from command line flag
|
|
131
|
-
* @param managementApiUrlFlag - managementApiUrl from command line flag
|
|
132
|
-
* @param executionApiUrlFlag - executionApiUrl from command line flag
|
|
133
|
-
* @param configFilePath - explicit path to config file
|
|
134
|
-
* @returns configuration with tenantId, managementApiUrl, and sources used
|
|
135
|
-
*/
|
|
136
|
-
export async function validateConfiguration(tenantIdFlag, managementApiUrlFlag, executionApiUrlFlag, configFilePath) {
|
|
137
|
-
// Validation: Cannot combine --config-file-path with --tenant-id
|
|
138
|
-
if (configFilePath && tenantIdFlag) {
|
|
139
|
-
throw new Error('Invalid configuration combination:\n' +
|
|
140
|
-
'Cannot use --config-file-path with --tenant-id.\n' +
|
|
141
|
-
'Please use either:\n' +
|
|
142
|
-
' 1. --config-file-path alone\n' +
|
|
143
|
-
' 2. --tenant-id with --management-api-url and --execution-api-url\n' +
|
|
144
|
-
' 3. Default config file (inkeep.config.ts)');
|
|
145
|
-
}
|
|
146
|
-
// Case 1: Explicit config file path provided
|
|
147
|
-
if (configFilePath) {
|
|
148
|
-
const config = await loadConfig(configFilePath);
|
|
149
|
-
const tenantId = config.tenantId;
|
|
150
|
-
const projectId = config.projectId || 'default';
|
|
151
|
-
const managementApiUrl = managementApiUrlFlag || config.managementApiUrl; // Allow ---management-api-url to override
|
|
152
|
-
const executionApiUrl = executionApiUrlFlag || config.executionApiUrl; // Allow --execution-api-url to override
|
|
153
|
-
if (!tenantId) {
|
|
154
|
-
throw new Error(`Tenant ID is missing from configuration file: ${configFilePath}\n` +
|
|
155
|
-
'Please ensure your config file exports a valid configuration with tenantId.');
|
|
156
|
-
}
|
|
157
|
-
if (!managementApiUrl) {
|
|
158
|
-
throw new Error(`Management API URL is missing from configuration file: ${configFilePath}\n` +
|
|
159
|
-
'Please ensure your config file exports a valid configuration with managementApiUrl.');
|
|
160
|
-
}
|
|
161
|
-
if (!executionApiUrl) {
|
|
162
|
-
throw new Error(`Execution API URL is missing from configuration file: ${configFilePath}\n` +
|
|
163
|
-
'Please ensure your config file exports a valid configuration with executionApiUrl.');
|
|
164
|
-
}
|
|
165
|
-
const sources = {
|
|
166
|
-
tenantId: `config file (${configFilePath})`,
|
|
167
|
-
projectId: config.projectId ? `config file (${configFilePath})` : 'default',
|
|
168
|
-
managementApiUrl: managementApiUrlFlag
|
|
169
|
-
? 'command-line flag (--management-api-url)'
|
|
170
|
-
: `config file (${configFilePath})`,
|
|
171
|
-
executionApiUrl: executionApiUrlFlag
|
|
172
|
-
? 'command-line flag (--execution-api-url)'
|
|
173
|
-
: `config file (${configFilePath})`,
|
|
174
|
-
configFile: configFilePath,
|
|
175
|
-
};
|
|
176
|
-
return {
|
|
177
|
-
tenantId,
|
|
178
|
-
projectId,
|
|
179
|
-
managementApiUrl,
|
|
180
|
-
executionApiUrl,
|
|
181
|
-
modelSettings: config.modelSettings || undefined,
|
|
182
|
-
outputDirectory: config.outputDirectory,
|
|
183
|
-
sources,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
// Case 2: Both --tenant-id and --management-api-url and --execution-api-url provided
|
|
187
|
-
if (tenantIdFlag && managementApiUrlFlag && executionApiUrlFlag) {
|
|
188
|
-
const sources = {
|
|
189
|
-
tenantId: 'command-line flag (--tenant-id)',
|
|
190
|
-
projectId: 'default',
|
|
191
|
-
managementApiUrl: 'command-line flag (--management-api-url)',
|
|
192
|
-
executionApiUrl: 'command-line flag (--execution-api-url)',
|
|
193
|
-
};
|
|
194
|
-
return {
|
|
195
|
-
tenantId: tenantIdFlag,
|
|
196
|
-
projectId: 'default',
|
|
197
|
-
managementApiUrl: managementApiUrlFlag,
|
|
198
|
-
executionApiUrl: executionApiUrlFlag,
|
|
199
|
-
modelSettings: undefined,
|
|
200
|
-
sources,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
// Case 3: Only --tenant-id provided (invalid)
|
|
204
|
-
if (tenantIdFlag && !managementApiUrlFlag && !executionApiUrlFlag) {
|
|
205
|
-
throw new Error('Invalid configuration:\n' +
|
|
206
|
-
'--tenant-id requires --management-api-url and --execution-api-url to be provided as well.\n' +
|
|
207
|
-
'Please provide both --tenant-id and --management-api-url and --execution-api-url together.');
|
|
208
|
-
}
|
|
209
|
-
// Case 4: Try to load from default config file
|
|
210
|
-
const config = await loadConfig();
|
|
211
|
-
const tenantId = config.tenantId;
|
|
212
|
-
const projectId = config.projectId || 'default';
|
|
213
|
-
const managementApiUrl = managementApiUrlFlag || config.managementApiUrl; // Allow --management-api-url to override
|
|
214
|
-
const executionApiUrl = executionApiUrlFlag || config.executionApiUrl; // Allow --execution-api-url to override
|
|
215
|
-
if (!tenantId) {
|
|
216
|
-
// Check if a default config file exists
|
|
217
|
-
const configFile = findConfigFile();
|
|
218
|
-
if (!configFile) {
|
|
219
|
-
throw new Error('No configuration found. Please use one of:\n' +
|
|
220
|
-
' 1. Create "inkeep.config.ts" by running "inkeep init"\n' +
|
|
221
|
-
' 2. Provide --config-file-path to specify a config file\n' +
|
|
222
|
-
' 3. Provide both --tenant-id and --management-api-url and --execution-api-url flags\n' +
|
|
223
|
-
' 4. Set INKEEP_TENANT_ID and INKEEP_API_URL environment variables');
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
throw new Error(`Tenant ID is missing from configuration file: ${configFile}\n` +
|
|
227
|
-
'Please either:\n' +
|
|
228
|
-
' 1. Update your configuration file with a tenantId\n' +
|
|
229
|
-
' 2. Provide both --tenant-id and --management-api-url and --execution-api-url flags\n' +
|
|
230
|
-
' 3. Set INKEEP_TENANT_ID environment variable');
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (!managementApiUrl) {
|
|
234
|
-
throw new Error('Management API URL is missing. Please either:\n' +
|
|
235
|
-
' 1. Provide --management-api-url flag\n' +
|
|
236
|
-
' 2. Set INKEEP_MANAGEMENT_API_URL environment variable\n' +
|
|
237
|
-
' 3. Add managementApiUrl to your configuration file');
|
|
238
|
-
}
|
|
239
|
-
if (!executionApiUrl) {
|
|
240
|
-
throw new Error('Execution API URL is missing. Please either:\n' +
|
|
241
|
-
' 1. Provide --execution-api-url flag\n' +
|
|
242
|
-
' 2. Set INKEEP_EXECUTION_API_URL environment variable\n' +
|
|
243
|
-
' 3. Add executionApiUrl to your configuration file');
|
|
244
|
-
}
|
|
245
|
-
// Determine sources for Case 4
|
|
246
|
-
const configFile = findConfigFile();
|
|
247
|
-
let tenantIdSource = configFile ? `config file (${configFile})` : 'unknown';
|
|
248
|
-
let managementApiUrlSource = configFile ? `config file (${configFile})` : 'default';
|
|
249
|
-
let executionApiUrlSource = configFile ? `config file (${configFile})` : 'default';
|
|
250
|
-
// Check if environment variables were used
|
|
251
|
-
if (process.env.INKEEP_TENANT_ID === tenantId) {
|
|
252
|
-
tenantIdSource = 'environment variable (INKEEP_TENANT_ID)';
|
|
253
|
-
}
|
|
254
|
-
if (managementApiUrlFlag) {
|
|
255
|
-
managementApiUrlSource = 'command-line flag (--management-api-url)';
|
|
256
|
-
}
|
|
257
|
-
else if (process.env.INKEEP_MANAGEMENT_API_URL === managementApiUrl) {
|
|
258
|
-
managementApiUrlSource = 'environment variable (INKEEP_MANAGEMENT_API_URL)';
|
|
259
|
-
}
|
|
260
|
-
else if (managementApiUrl === 'http://localhost:3002' && !configFile) {
|
|
261
|
-
managementApiUrlSource = 'default value';
|
|
262
|
-
}
|
|
263
|
-
if (executionApiUrlFlag) {
|
|
264
|
-
executionApiUrlSource = 'command-line flag (--execution-api-url)';
|
|
265
|
-
}
|
|
266
|
-
else if (process.env.INKEEP_EXECUTION_API_URL === executionApiUrl) {
|
|
267
|
-
executionApiUrlSource = 'environment variable (INKEEP_EXECUTION_API_URL)';
|
|
268
|
-
}
|
|
269
|
-
else if (executionApiUrl === 'http://localhost:3003' && !configFile) {
|
|
270
|
-
executionApiUrlSource = 'default value';
|
|
271
|
-
}
|
|
272
|
-
const sources = {
|
|
273
|
-
tenantId: tenantIdSource,
|
|
274
|
-
projectId: config.projectId
|
|
275
|
-
? configFile
|
|
276
|
-
? `config file (${configFile})`
|
|
277
|
-
: 'config'
|
|
278
|
-
: 'default',
|
|
279
|
-
managementApiUrl: managementApiUrlSource,
|
|
280
|
-
executionApiUrl: executionApiUrlSource,
|
|
281
|
-
configFile: configFile || undefined,
|
|
282
|
-
};
|
|
283
|
-
return {
|
|
284
|
-
tenantId,
|
|
285
|
-
projectId,
|
|
286
|
-
managementApiUrl,
|
|
287
|
-
executionApiUrl,
|
|
288
|
-
modelSettings: config.modelSettings || undefined,
|
|
289
|
-
outputDirectory: config.outputDirectory,
|
|
290
|
-
sources,
|
|
291
|
-
};
|
|
292
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/config.ts
|
|
4
|
+
function defineConfig(config) {
|
|
5
|
+
return config;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
defineConfig
|
|
9
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {}
|
|
1
|
+
|
|
2
|
+
export { }
|