@cogitator-ai/config 0.1.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/LICENSE +21 -0
- package/README.md +76 -0
- package/dist/__tests__/env.test.d.ts +2 -0
- package/dist/__tests__/env.test.d.ts.map +1 -0
- package/dist/__tests__/env.test.js +68 -0
- package/dist/__tests__/env.test.js.map +1 -0
- package/dist/__tests__/schema.test.d.ts +2 -0
- package/dist/__tests__/schema.test.d.ts.map +1 -0
- package/dist/__tests__/schema.test.js +71 -0
- package/dist/__tests__/schema.test.js.map +1 -0
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +76 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/env.d.ts +6 -0
- package/dist/loaders/env.d.ts.map +1 -0
- package/dist/loaders/env.js +74 -0
- package/dist/loaders/env.js.map +1 -0
- package/dist/loaders/yaml.d.ts +6 -0
- package/dist/loaders/yaml.d.ts.map +1 -0
- package/dist/loaders/yaml.js +25 -0
- package/dist/loaders/yaml.js.map +1 -0
- package/dist/schema.d.ts +406 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +33 -0
- package/dist/schema.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cogitator Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @cogitator-ai/config
|
|
2
|
+
|
|
3
|
+
Configuration loading for Cogitator. Supports YAML files, environment variables, and programmatic overrides.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @cogitator-ai/config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### YAML Configuration
|
|
14
|
+
|
|
15
|
+
Create `cogitator.yml`:
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
defaultModel: ollama/llama3.2:3b
|
|
19
|
+
memory:
|
|
20
|
+
adapter: redis
|
|
21
|
+
redis:
|
|
22
|
+
url: redis://localhost:6379
|
|
23
|
+
logging:
|
|
24
|
+
level: info
|
|
25
|
+
format: json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Load Configuration
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { loadConfig } from '@cogitator-ai/config';
|
|
32
|
+
|
|
33
|
+
const config = await loadConfig({
|
|
34
|
+
configPath: './cogitator.yml',
|
|
35
|
+
overrides: {
|
|
36
|
+
logging: { level: 'debug' },
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Environment Variables
|
|
42
|
+
|
|
43
|
+
Environment variables with `COGITATOR_` prefix are automatically loaded:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
COGITATOR_DEFAULT_MODEL=openai/gpt-4o
|
|
47
|
+
COGITATOR_LOGGING_LEVEL=debug
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Priority Order
|
|
51
|
+
|
|
52
|
+
1. Programmatic overrides (highest)
|
|
53
|
+
2. Environment variables
|
|
54
|
+
3. YAML config file
|
|
55
|
+
4. Defaults (lowest)
|
|
56
|
+
|
|
57
|
+
## Schema Validation
|
|
58
|
+
|
|
59
|
+
Configuration is validated using Zod schemas:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { configSchema } from '@cogitator-ai/config';
|
|
63
|
+
|
|
64
|
+
const result = configSchema.safeParse(rawConfig);
|
|
65
|
+
if (!result.success) {
|
|
66
|
+
console.error(result.error.issues);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
See the [Cogitator documentation](https://github.com/eL1fe/cogitator) for full API reference.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/env.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
+
import { loadEnvConfig } from '../loaders/env';
|
|
3
|
+
describe('loadEnvConfig()', () => {
|
|
4
|
+
const originalEnv = process.env;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
vi.resetModules();
|
|
7
|
+
process.env = { ...originalEnv };
|
|
8
|
+
});
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
process.env = originalEnv;
|
|
11
|
+
});
|
|
12
|
+
it('returns empty config when no env vars set', () => {
|
|
13
|
+
const keysToDelete = Object.keys(process.env).filter((key) => key.startsWith('COGITATOR_') ||
|
|
14
|
+
['OPENAI_API_KEY', 'ANTHROPIC_API_KEY', 'OLLAMA_HOST'].includes(key));
|
|
15
|
+
for (const key of keysToDelete) {
|
|
16
|
+
process.env[key] = undefined;
|
|
17
|
+
}
|
|
18
|
+
const config = loadEnvConfig();
|
|
19
|
+
expect(config.llm).toBeUndefined();
|
|
20
|
+
expect(config.limits).toBeUndefined();
|
|
21
|
+
});
|
|
22
|
+
it('loads LLM default provider from env', () => {
|
|
23
|
+
process.env.COGITATOR_LLM_DEFAULT_PROVIDER = 'openai';
|
|
24
|
+
process.env.COGITATOR_LLM_DEFAULT_MODEL = 'gpt-4';
|
|
25
|
+
const config = loadEnvConfig();
|
|
26
|
+
expect(config.llm?.defaultProvider).toBe('openai');
|
|
27
|
+
expect(config.llm?.defaultModel).toBe('gpt-4');
|
|
28
|
+
});
|
|
29
|
+
it('loads Ollama config from COGITATOR_ prefix', () => {
|
|
30
|
+
process.env.COGITATOR_OLLAMA_BASE_URL = 'http://localhost:11434';
|
|
31
|
+
const config = loadEnvConfig();
|
|
32
|
+
expect(config.llm?.providers?.ollama?.baseUrl).toBe('http://localhost:11434');
|
|
33
|
+
});
|
|
34
|
+
it('loads Ollama config from standard OLLAMA_HOST', () => {
|
|
35
|
+
delete process.env.COGITATOR_OLLAMA_BASE_URL;
|
|
36
|
+
process.env.OLLAMA_HOST = 'http://192.168.1.100:11434';
|
|
37
|
+
const config = loadEnvConfig();
|
|
38
|
+
expect(config.llm?.providers?.ollama?.baseUrl).toBe('http://192.168.1.100:11434');
|
|
39
|
+
});
|
|
40
|
+
it('loads OpenAI config from standard OPENAI_API_KEY', () => {
|
|
41
|
+
delete process.env.COGITATOR_OPENAI_API_KEY;
|
|
42
|
+
process.env.OPENAI_API_KEY = 'sk-test-key';
|
|
43
|
+
const config = loadEnvConfig();
|
|
44
|
+
expect(config.llm?.providers?.openai?.apiKey).toBe('sk-test-key');
|
|
45
|
+
});
|
|
46
|
+
it('loads Anthropic config from standard ANTHROPIC_API_KEY', () => {
|
|
47
|
+
delete process.env.COGITATOR_ANTHROPIC_API_KEY;
|
|
48
|
+
process.env.ANTHROPIC_API_KEY = 'sk-ant-test-key';
|
|
49
|
+
const config = loadEnvConfig();
|
|
50
|
+
expect(config.llm?.providers?.anthropic?.apiKey).toBe('sk-ant-test-key');
|
|
51
|
+
});
|
|
52
|
+
it('loads limits from env', () => {
|
|
53
|
+
process.env.COGITATOR_LIMITS_MAX_CONCURRENT_RUNS = '5';
|
|
54
|
+
process.env.COGITATOR_LIMITS_DEFAULT_TIMEOUT = '30000';
|
|
55
|
+
process.env.COGITATOR_LIMITS_MAX_TOKENS_PER_RUN = '100000';
|
|
56
|
+
const config = loadEnvConfig();
|
|
57
|
+
expect(config.limits?.maxConcurrentRuns).toBe(5);
|
|
58
|
+
expect(config.limits?.defaultTimeout).toBe(30000);
|
|
59
|
+
expect(config.limits?.maxTokensPerRun).toBe(100000);
|
|
60
|
+
});
|
|
61
|
+
it('COGITATOR_ prefix takes precedence over standard env vars', () => {
|
|
62
|
+
process.env.OPENAI_API_KEY = 'standard-key';
|
|
63
|
+
process.env.COGITATOR_OPENAI_API_KEY = 'cogitator-key';
|
|
64
|
+
const config = loadEnvConfig();
|
|
65
|
+
expect(config.llm?.providers?.openai?.apiKey).toBe('cogitator-key');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=env.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.test.js","sourceRoot":"","sources":["../../src/__tests__/env.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE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C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { CogitatorConfigSchema, LLMProviderSchema } from '../schema';
|
|
3
|
+
describe('LLMProviderSchema', () => {
|
|
4
|
+
it('accepts valid providers', () => {
|
|
5
|
+
expect(LLMProviderSchema.parse('ollama')).toBe('ollama');
|
|
6
|
+
expect(LLMProviderSchema.parse('openai')).toBe('openai');
|
|
7
|
+
expect(LLMProviderSchema.parse('anthropic')).toBe('anthropic');
|
|
8
|
+
expect(LLMProviderSchema.parse('google')).toBe('google');
|
|
9
|
+
expect(LLMProviderSchema.parse('vllm')).toBe('vllm');
|
|
10
|
+
});
|
|
11
|
+
it('rejects invalid providers', () => {
|
|
12
|
+
expect(() => LLMProviderSchema.parse('invalid')).toThrow();
|
|
13
|
+
expect(() => LLMProviderSchema.parse('')).toThrow();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe('CogitatorConfigSchema', () => {
|
|
17
|
+
it('accepts empty config', () => {
|
|
18
|
+
const result = CogitatorConfigSchema.parse({});
|
|
19
|
+
expect(result).toEqual({});
|
|
20
|
+
});
|
|
21
|
+
it('accepts full config', () => {
|
|
22
|
+
const config = {
|
|
23
|
+
llm: {
|
|
24
|
+
defaultProvider: 'ollama',
|
|
25
|
+
defaultModel: 'llama3.1:8b',
|
|
26
|
+
providers: {
|
|
27
|
+
ollama: { baseUrl: 'http://localhost:11434' },
|
|
28
|
+
openai: { apiKey: 'sk-xxx', baseUrl: 'https://api.openai.com/v1' },
|
|
29
|
+
anthropic: { apiKey: 'sk-ant-xxx' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
limits: {
|
|
33
|
+
maxConcurrentRuns: 10,
|
|
34
|
+
defaultTimeout: 30000,
|
|
35
|
+
maxTokensPerRun: 100000,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const result = CogitatorConfigSchema.parse(config);
|
|
39
|
+
expect(result.llm?.defaultProvider).toBe('ollama');
|
|
40
|
+
expect(result.llm?.providers?.ollama?.baseUrl).toBe('http://localhost:11434');
|
|
41
|
+
expect(result.limits?.maxConcurrentRuns).toBe(10);
|
|
42
|
+
});
|
|
43
|
+
it('accepts partial config', () => {
|
|
44
|
+
const config = {
|
|
45
|
+
llm: {
|
|
46
|
+
defaultProvider: 'openai',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const result = CogitatorConfigSchema.parse(config);
|
|
50
|
+
expect(result.llm?.defaultProvider).toBe('openai');
|
|
51
|
+
expect(result.llm?.providers).toBeUndefined();
|
|
52
|
+
expect(result.limits).toBeUndefined();
|
|
53
|
+
});
|
|
54
|
+
it('rejects invalid provider', () => {
|
|
55
|
+
const config = {
|
|
56
|
+
llm: {
|
|
57
|
+
defaultProvider: 'invalid-provider',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
expect(() => CogitatorConfigSchema.parse(config)).toThrow();
|
|
61
|
+
});
|
|
62
|
+
it('rejects negative limits', () => {
|
|
63
|
+
const config = {
|
|
64
|
+
limits: {
|
|
65
|
+
maxConcurrentRuns: -1,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
expect(() => CogitatorConfigSchema.parse(config)).toThrow();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=schema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.test.js","sourceRoot":"","sources":["../../src/__tests__/schema.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAErE,QAAQ,CAAC,mBAAmB,EAAE,G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,0BAA0B,EAAE,GAAG,EAAE;QAClC,MAAM,MAAM,GAAG;YACb,GAAG,EAAE;gBACH,eAAe,EAAE,kBAAkB;aACpC;SACF,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG;YACb,MAAM,EAAE;gBACN,iBAAiB,EAAE,CAAC,CAAC;aACtB;SACF,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration loading and merging
|
|
3
|
+
*/
|
|
4
|
+
import type { CogitatorConfig } from '@cogitator-ai/types';
|
|
5
|
+
import { type CogitatorConfigInput } from './schema';
|
|
6
|
+
export interface LoadConfigOptions {
|
|
7
|
+
/** Path to YAML config file */
|
|
8
|
+
configPath?: string;
|
|
9
|
+
/** Skip loading from environment variables */
|
|
10
|
+
skipEnv?: boolean;
|
|
11
|
+
/** Skip loading from YAML file */
|
|
12
|
+
skipYaml?: boolean;
|
|
13
|
+
/** Override config values */
|
|
14
|
+
overrides?: CogitatorConfigInput;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Load and merge configuration from multiple sources
|
|
18
|
+
*
|
|
19
|
+
* Priority (highest to lowest):
|
|
20
|
+
* 1. Overrides passed in options
|
|
21
|
+
* 2. Environment variables
|
|
22
|
+
* 3. YAML config file
|
|
23
|
+
* 4. Defaults
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadConfig(options?: LoadConfigOptions): CogitatorConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Create a config builder for fluent configuration
|
|
28
|
+
*/
|
|
29
|
+
export declare function defineConfig(config: CogitatorConfigInput): CogitatorConfig;
|
|
30
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAyB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAI5E,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,eAAe,CA2B3E;AAoCD;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,eAAe,CAM1E"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration loading and merging
|
|
3
|
+
*/
|
|
4
|
+
import { CogitatorConfigSchema } from './schema';
|
|
5
|
+
import { loadYamlConfig } from './loaders/yaml';
|
|
6
|
+
import { loadEnvConfig } from './loaders/env';
|
|
7
|
+
/**
|
|
8
|
+
* Load and merge configuration from multiple sources
|
|
9
|
+
*
|
|
10
|
+
* Priority (highest to lowest):
|
|
11
|
+
* 1. Overrides passed in options
|
|
12
|
+
* 2. Environment variables
|
|
13
|
+
* 3. YAML config file
|
|
14
|
+
* 4. Defaults
|
|
15
|
+
*/
|
|
16
|
+
export function loadConfig(options = {}) {
|
|
17
|
+
const configs = [];
|
|
18
|
+
if (!options.skipYaml) {
|
|
19
|
+
const yamlConfig = loadYamlConfig(options.configPath);
|
|
20
|
+
if (yamlConfig) {
|
|
21
|
+
configs.push(yamlConfig);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!options.skipEnv) {
|
|
25
|
+
const envConfig = loadEnvConfig();
|
|
26
|
+
configs.push(envConfig);
|
|
27
|
+
}
|
|
28
|
+
if (options.overrides) {
|
|
29
|
+
configs.push(options.overrides);
|
|
30
|
+
}
|
|
31
|
+
const merged = mergeConfigs(configs);
|
|
32
|
+
const result = CogitatorConfigSchema.safeParse(merged);
|
|
33
|
+
if (!result.success) {
|
|
34
|
+
throw new Error(`Invalid configuration: ${result.error.message}`);
|
|
35
|
+
}
|
|
36
|
+
return result.data;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Deep merge multiple config objects
|
|
40
|
+
*/
|
|
41
|
+
function mergeConfigs(configs) {
|
|
42
|
+
const result = {};
|
|
43
|
+
for (const config of configs) {
|
|
44
|
+
deepMerge(result, config);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
function deepMerge(target, source) {
|
|
49
|
+
for (const key of Object.keys(source)) {
|
|
50
|
+
const sourceValue = source[key];
|
|
51
|
+
const targetValue = target[key];
|
|
52
|
+
if (sourceValue === undefined) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (isObject(sourceValue) && isObject(targetValue)) {
|
|
56
|
+
deepMerge(targetValue, sourceValue);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
target[key] = sourceValue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function isObject(value) {
|
|
64
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a config builder for fluent configuration
|
|
68
|
+
*/
|
|
69
|
+
export function defineConfig(config) {
|
|
70
|
+
const result = CogitatorConfigSchema.safeParse(config);
|
|
71
|
+
if (!result.success) {
|
|
72
|
+
throw new Error(`Invalid configuration: ${result.error.message}`);
|
|
73
|
+
}
|
|
74
|
+
return result.data;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAA6B,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAa9C;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,UAA6B,EAAE;IACxD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACtD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,aAAa,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAErC,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,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CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cogitator-ai/config
|
|
3
|
+
*
|
|
4
|
+
* Configuration loading for Cogitator (YAML, env)
|
|
5
|
+
*/
|
|
6
|
+
export { loadConfig, defineConfig, type LoadConfigOptions } from './config';
|
|
7
|
+
export { CogitatorConfigSchema, LLMConfigSchema, LimitsConfigSchema, ProvidersConfigSchema, LLMProviderSchema, type CogitatorConfigInput, type CogitatorConfigOutput, } from './schema';
|
|
8
|
+
export { loadYamlConfig } from './loaders/yaml';
|
|
9
|
+
export { loadEnvConfig } from './loaders/env';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cogitator-ai/config
|
|
3
|
+
*
|
|
4
|
+
* Configuration loading for Cogitator (YAML, env)
|
|
5
|
+
*/
|
|
6
|
+
export { loadConfig, defineConfig } from './config';
|
|
7
|
+
export { CogitatorConfigSchema, LLMConfigSchema, LimitsConfigSchema, ProvidersConfigSchema, LLMProviderSchema, } from './schema';
|
|
8
|
+
export { loadYamlConfig } from './loaders/yaml';
|
|
9
|
+
export { loadEnvConfig } from './loaders/env';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAA0B,MAAM,UAAU,CAAC;AAC5E,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,GAGlB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/loaders/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AA4BtD,wBAAgB,aAAa,IAAI,oBAAoB,CAyBpD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable configuration loader
|
|
3
|
+
*/
|
|
4
|
+
const ENV_PREFIX = 'COGITATOR_';
|
|
5
|
+
export function loadEnvConfig() {
|
|
6
|
+
const config = {};
|
|
7
|
+
const defaultProvider = getEnv('LLM_DEFAULT_PROVIDER');
|
|
8
|
+
const defaultModel = getEnv('LLM_DEFAULT_MODEL');
|
|
9
|
+
if (defaultProvider || defaultModel) {
|
|
10
|
+
config.llm = {
|
|
11
|
+
...config.llm,
|
|
12
|
+
defaultProvider: defaultProvider,
|
|
13
|
+
defaultModel,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const providers = loadProviderConfigs();
|
|
17
|
+
if (Object.keys(providers).length > 0) {
|
|
18
|
+
config.llm = { ...config.llm, providers };
|
|
19
|
+
}
|
|
20
|
+
const limits = loadLimitsConfig();
|
|
21
|
+
if (Object.keys(limits).length > 0) {
|
|
22
|
+
config.limits = limits;
|
|
23
|
+
}
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
26
|
+
function loadProviderConfigs() {
|
|
27
|
+
const providers = {};
|
|
28
|
+
const ollamaBaseUrl = getEnv('OLLAMA_BASE_URL') ?? process.env.OLLAMA_HOST;
|
|
29
|
+
if (ollamaBaseUrl) {
|
|
30
|
+
providers.ollama = { baseUrl: ollamaBaseUrl };
|
|
31
|
+
}
|
|
32
|
+
const openaiApiKey = getEnv('OPENAI_API_KEY') ?? process.env.OPENAI_API_KEY;
|
|
33
|
+
const openaiBaseUrl = getEnv('OPENAI_BASE_URL') ?? process.env.OPENAI_BASE_URL;
|
|
34
|
+
if (openaiApiKey) {
|
|
35
|
+
providers.openai = { apiKey: openaiApiKey, baseUrl: openaiBaseUrl };
|
|
36
|
+
}
|
|
37
|
+
const anthropicApiKey = getEnv('ANTHROPIC_API_KEY') ?? process.env.ANTHROPIC_API_KEY;
|
|
38
|
+
if (anthropicApiKey) {
|
|
39
|
+
providers.anthropic = { apiKey: anthropicApiKey };
|
|
40
|
+
}
|
|
41
|
+
const googleApiKey = getEnv('GOOGLE_API_KEY') ?? process.env.GOOGLE_API_KEY;
|
|
42
|
+
if (googleApiKey) {
|
|
43
|
+
providers.google = { apiKey: googleApiKey };
|
|
44
|
+
}
|
|
45
|
+
const vllmBaseUrl = getEnv('VLLM_BASE_URL');
|
|
46
|
+
if (vllmBaseUrl) {
|
|
47
|
+
providers.vllm = { baseUrl: vllmBaseUrl };
|
|
48
|
+
}
|
|
49
|
+
return providers;
|
|
50
|
+
}
|
|
51
|
+
function loadLimitsConfig() {
|
|
52
|
+
const limits = {};
|
|
53
|
+
const maxConcurrentRuns = getEnvNumber('LIMITS_MAX_CONCURRENT_RUNS');
|
|
54
|
+
const defaultTimeout = getEnvNumber('LIMITS_DEFAULT_TIMEOUT');
|
|
55
|
+
const maxTokensPerRun = getEnvNumber('LIMITS_MAX_TOKENS_PER_RUN');
|
|
56
|
+
if (maxConcurrentRuns !== undefined)
|
|
57
|
+
limits.maxConcurrentRuns = maxConcurrentRuns;
|
|
58
|
+
if (defaultTimeout !== undefined)
|
|
59
|
+
limits.defaultTimeout = defaultTimeout;
|
|
60
|
+
if (maxTokensPerRun !== undefined)
|
|
61
|
+
limits.maxTokensPerRun = maxTokensPerRun;
|
|
62
|
+
return limits;
|
|
63
|
+
}
|
|
64
|
+
function getEnv(key) {
|
|
65
|
+
return process.env[`${ENV_PREFIX}${key}`];
|
|
66
|
+
}
|
|
67
|
+
function getEnvNumber(key) {
|
|
68
|
+
const value = getEnv(key);
|
|
69
|
+
if (value === undefined)
|
|
70
|
+
return undefined;
|
|
71
|
+
const num = parseInt(value, 10);
|
|
72
|
+
return isNaN(num) ? undefined : num;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/loaders/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,UAAU,GAAG,YAAY,CAAC;AA0BhC,MAAM,UAAU,aAAa;IAC3B,MAAM,MAAM,GAAyB,EAAE,CAAC;IAExC,MAAM,eAAe,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;IACvD,MAAM,YAAY,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAEjD,IAAI,eAAe,IAAI,YAAY,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,GAAG;YACX,GAAG,MAAM,CAAC,GAAG;YACb,eAAe,EAAE,eAA8B;YAC/C,YAAY;SACb,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,mBAAmB,EAAE,CAAC;IACxC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MA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aml.d.ts","sourceRoot":"","sources":["../../src/loaders/yaml.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAItD,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAe/E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML configuration loader
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
5
|
+
import { parse } from 'yaml';
|
|
6
|
+
const DEFAULT_CONFIG_NAMES = ['cogitator.yaml', 'cogitator.yml', '.cogitator.yaml', '.cogitator.yml'];
|
|
7
|
+
export function loadYamlConfig(configPath) {
|
|
8
|
+
if (configPath) {
|
|
9
|
+
if (!existsSync(configPath)) {
|
|
10
|
+
throw new Error(`Config file not found: ${configPath}`);
|
|
11
|
+
}
|
|
12
|
+
return parseYamlFile(configPath);
|
|
13
|
+
}
|
|
14
|
+
for (const name of DEFAULT_CONFIG_NAMES) {
|
|
15
|
+
if (existsSync(name)) {
|
|
16
|
+
return parseYamlFile(name);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function parseYamlFile(path) {
|
|
22
|
+
const content = readFileSync(path, 'utf-8');
|
|
23
|
+
return parse(content);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=yaml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../src/loaders/yaml.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG7B,MAAM,oBAAoB,GAAG,CAAC,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;AAEtG,MAAM,UAAU,cAAc,CAAC,UAAmB;IAChD,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,oBAAoB,EAAE,CAAC;QACxC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAyB,CAAC;AAChD,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema using Zod
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export declare const LLMProviderSchema: z.ZodEnum<["ollama", "openai", "anthropic", "google", "vllm"]>;
|
|
6
|
+
export declare const ProvidersConfigSchema: z.ZodObject<{
|
|
7
|
+
ollama: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
baseUrl: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
}, {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
}>>;
|
|
14
|
+
openai: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
apiKey: z.ZodString;
|
|
16
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
baseUrl?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
apiKey: string;
|
|
22
|
+
baseUrl?: string | undefined;
|
|
23
|
+
}>>;
|
|
24
|
+
anthropic: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
apiKey: z.ZodString;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
apiKey: string;
|
|
28
|
+
}, {
|
|
29
|
+
apiKey: string;
|
|
30
|
+
}>>;
|
|
31
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
32
|
+
apiKey: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
apiKey: string;
|
|
35
|
+
}, {
|
|
36
|
+
apiKey: string;
|
|
37
|
+
}>>;
|
|
38
|
+
vllm: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
baseUrl: z.ZodString;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
baseUrl: string;
|
|
42
|
+
}, {
|
|
43
|
+
baseUrl: string;
|
|
44
|
+
}>>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
ollama?: {
|
|
47
|
+
baseUrl: string;
|
|
48
|
+
} | undefined;
|
|
49
|
+
openai?: {
|
|
50
|
+
apiKey: string;
|
|
51
|
+
baseUrl?: string | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
anthropic?: {
|
|
54
|
+
apiKey: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
google?: {
|
|
57
|
+
apiKey: string;
|
|
58
|
+
} | undefined;
|
|
59
|
+
vllm?: {
|
|
60
|
+
baseUrl: string;
|
|
61
|
+
} | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
ollama?: {
|
|
64
|
+
baseUrl: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
openai?: {
|
|
67
|
+
apiKey: string;
|
|
68
|
+
baseUrl?: string | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
anthropic?: {
|
|
71
|
+
apiKey: string;
|
|
72
|
+
} | undefined;
|
|
73
|
+
google?: {
|
|
74
|
+
apiKey: string;
|
|
75
|
+
} | undefined;
|
|
76
|
+
vllm?: {
|
|
77
|
+
baseUrl: string;
|
|
78
|
+
} | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
export declare const LLMConfigSchema: z.ZodObject<{
|
|
81
|
+
defaultProvider: z.ZodOptional<z.ZodEnum<["ollama", "openai", "anthropic", "google", "vllm"]>>;
|
|
82
|
+
defaultModel: z.ZodOptional<z.ZodString>;
|
|
83
|
+
providers: z.ZodOptional<z.ZodObject<{
|
|
84
|
+
ollama: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
baseUrl: z.ZodString;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
baseUrl: string;
|
|
88
|
+
}, {
|
|
89
|
+
baseUrl: string;
|
|
90
|
+
}>>;
|
|
91
|
+
openai: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
apiKey: z.ZodString;
|
|
93
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
apiKey: string;
|
|
96
|
+
baseUrl?: string | undefined;
|
|
97
|
+
}, {
|
|
98
|
+
apiKey: string;
|
|
99
|
+
baseUrl?: string | undefined;
|
|
100
|
+
}>>;
|
|
101
|
+
anthropic: z.ZodOptional<z.ZodObject<{
|
|
102
|
+
apiKey: z.ZodString;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
apiKey: string;
|
|
105
|
+
}, {
|
|
106
|
+
apiKey: string;
|
|
107
|
+
}>>;
|
|
108
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
apiKey: z.ZodString;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
apiKey: string;
|
|
112
|
+
}, {
|
|
113
|
+
apiKey: string;
|
|
114
|
+
}>>;
|
|
115
|
+
vllm: z.ZodOptional<z.ZodObject<{
|
|
116
|
+
baseUrl: z.ZodString;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
baseUrl: string;
|
|
119
|
+
}, {
|
|
120
|
+
baseUrl: string;
|
|
121
|
+
}>>;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
ollama?: {
|
|
124
|
+
baseUrl: string;
|
|
125
|
+
} | undefined;
|
|
126
|
+
openai?: {
|
|
127
|
+
apiKey: string;
|
|
128
|
+
baseUrl?: string | undefined;
|
|
129
|
+
} | undefined;
|
|
130
|
+
anthropic?: {
|
|
131
|
+
apiKey: string;
|
|
132
|
+
} | undefined;
|
|
133
|
+
google?: {
|
|
134
|
+
apiKey: string;
|
|
135
|
+
} | undefined;
|
|
136
|
+
vllm?: {
|
|
137
|
+
baseUrl: string;
|
|
138
|
+
} | undefined;
|
|
139
|
+
}, {
|
|
140
|
+
ollama?: {
|
|
141
|
+
baseUrl: string;
|
|
142
|
+
} | undefined;
|
|
143
|
+
openai?: {
|
|
144
|
+
apiKey: string;
|
|
145
|
+
baseUrl?: string | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
anthropic?: {
|
|
148
|
+
apiKey: string;
|
|
149
|
+
} | undefined;
|
|
150
|
+
google?: {
|
|
151
|
+
apiKey: string;
|
|
152
|
+
} | undefined;
|
|
153
|
+
vllm?: {
|
|
154
|
+
baseUrl: string;
|
|
155
|
+
} | undefined;
|
|
156
|
+
}>>;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
defaultProvider?: "ollama" | "openai" | "anthropic" | "google" | "vllm" | undefined;
|
|
159
|
+
defaultModel?: string | undefined;
|
|
160
|
+
providers?: {
|
|
161
|
+
ollama?: {
|
|
162
|
+
baseUrl: string;
|
|
163
|
+
} | undefined;
|
|
164
|
+
openai?: {
|
|
165
|
+
apiKey: string;
|
|
166
|
+
baseUrl?: string | undefined;
|
|
167
|
+
} | undefined;
|
|
168
|
+
anthropic?: {
|
|
169
|
+
apiKey: string;
|
|
170
|
+
} | undefined;
|
|
171
|
+
google?: {
|
|
172
|
+
apiKey: string;
|
|
173
|
+
} | undefined;
|
|
174
|
+
vllm?: {
|
|
175
|
+
baseUrl: string;
|
|
176
|
+
} | undefined;
|
|
177
|
+
} | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
defaultProvider?: "ollama" | "openai" | "anthropic" | "google" | "vllm" | undefined;
|
|
180
|
+
defaultModel?: string | undefined;
|
|
181
|
+
providers?: {
|
|
182
|
+
ollama?: {
|
|
183
|
+
baseUrl: string;
|
|
184
|
+
} | undefined;
|
|
185
|
+
openai?: {
|
|
186
|
+
apiKey: string;
|
|
187
|
+
baseUrl?: string | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
anthropic?: {
|
|
190
|
+
apiKey: string;
|
|
191
|
+
} | undefined;
|
|
192
|
+
google?: {
|
|
193
|
+
apiKey: string;
|
|
194
|
+
} | undefined;
|
|
195
|
+
vllm?: {
|
|
196
|
+
baseUrl: string;
|
|
197
|
+
} | undefined;
|
|
198
|
+
} | undefined;
|
|
199
|
+
}>;
|
|
200
|
+
export declare const LimitsConfigSchema: z.ZodObject<{
|
|
201
|
+
maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
defaultTimeout: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
maxTokensPerRun: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
}, "strip", z.ZodTypeAny, {
|
|
205
|
+
maxConcurrentRuns?: number | undefined;
|
|
206
|
+
defaultTimeout?: number | undefined;
|
|
207
|
+
maxTokensPerRun?: number | undefined;
|
|
208
|
+
}, {
|
|
209
|
+
maxConcurrentRuns?: number | undefined;
|
|
210
|
+
defaultTimeout?: number | undefined;
|
|
211
|
+
maxTokensPerRun?: number | undefined;
|
|
212
|
+
}>;
|
|
213
|
+
export declare const CogitatorConfigSchema: z.ZodObject<{
|
|
214
|
+
llm: z.ZodOptional<z.ZodObject<{
|
|
215
|
+
defaultProvider: z.ZodOptional<z.ZodEnum<["ollama", "openai", "anthropic", "google", "vllm"]>>;
|
|
216
|
+
defaultModel: z.ZodOptional<z.ZodString>;
|
|
217
|
+
providers: z.ZodOptional<z.ZodObject<{
|
|
218
|
+
ollama: z.ZodOptional<z.ZodObject<{
|
|
219
|
+
baseUrl: z.ZodString;
|
|
220
|
+
}, "strip", z.ZodTypeAny, {
|
|
221
|
+
baseUrl: string;
|
|
222
|
+
}, {
|
|
223
|
+
baseUrl: string;
|
|
224
|
+
}>>;
|
|
225
|
+
openai: z.ZodOptional<z.ZodObject<{
|
|
226
|
+
apiKey: z.ZodString;
|
|
227
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
|
229
|
+
apiKey: string;
|
|
230
|
+
baseUrl?: string | undefined;
|
|
231
|
+
}, {
|
|
232
|
+
apiKey: string;
|
|
233
|
+
baseUrl?: string | undefined;
|
|
234
|
+
}>>;
|
|
235
|
+
anthropic: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
apiKey: z.ZodString;
|
|
237
|
+
}, "strip", z.ZodTypeAny, {
|
|
238
|
+
apiKey: string;
|
|
239
|
+
}, {
|
|
240
|
+
apiKey: string;
|
|
241
|
+
}>>;
|
|
242
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
243
|
+
apiKey: z.ZodString;
|
|
244
|
+
}, "strip", z.ZodTypeAny, {
|
|
245
|
+
apiKey: string;
|
|
246
|
+
}, {
|
|
247
|
+
apiKey: string;
|
|
248
|
+
}>>;
|
|
249
|
+
vllm: z.ZodOptional<z.ZodObject<{
|
|
250
|
+
baseUrl: z.ZodString;
|
|
251
|
+
}, "strip", z.ZodTypeAny, {
|
|
252
|
+
baseUrl: string;
|
|
253
|
+
}, {
|
|
254
|
+
baseUrl: string;
|
|
255
|
+
}>>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
ollama?: {
|
|
258
|
+
baseUrl: string;
|
|
259
|
+
} | undefined;
|
|
260
|
+
openai?: {
|
|
261
|
+
apiKey: string;
|
|
262
|
+
baseUrl?: string | undefined;
|
|
263
|
+
} | undefined;
|
|
264
|
+
anthropic?: {
|
|
265
|
+
apiKey: string;
|
|
266
|
+
} | undefined;
|
|
267
|
+
google?: {
|
|
268
|
+
apiKey: string;
|
|
269
|
+
} | undefined;
|
|
270
|
+
vllm?: {
|
|
271
|
+
baseUrl: string;
|
|
272
|
+
} | undefined;
|
|
273
|
+
}, {
|
|
274
|
+
ollama?: {
|
|
275
|
+
baseUrl: string;
|
|
276
|
+
} | undefined;
|
|
277
|
+
openai?: {
|
|
278
|
+
apiKey: string;
|
|
279
|
+
baseUrl?: string | undefined;
|
|
280
|
+
} | undefined;
|
|
281
|
+
anthropic?: {
|
|
282
|
+
apiKey: string;
|
|
283
|
+
} | undefined;
|
|
284
|
+
google?: {
|
|
285
|
+
apiKey: string;
|
|
286
|
+
} | undefined;
|
|
287
|
+
vllm?: {
|
|
288
|
+
baseUrl: string;
|
|
289
|
+
} | undefined;
|
|
290
|
+
}>>;
|
|
291
|
+
}, "strip", z.ZodTypeAny, {
|
|
292
|
+
defaultProvider?: "ollama" | "openai" | "anthropic" | "google" | "vllm" | undefined;
|
|
293
|
+
defaultModel?: string | undefined;
|
|
294
|
+
providers?: {
|
|
295
|
+
ollama?: {
|
|
296
|
+
baseUrl: string;
|
|
297
|
+
} | undefined;
|
|
298
|
+
openai?: {
|
|
299
|
+
apiKey: string;
|
|
300
|
+
baseUrl?: string | undefined;
|
|
301
|
+
} | undefined;
|
|
302
|
+
anthropic?: {
|
|
303
|
+
apiKey: string;
|
|
304
|
+
} | undefined;
|
|
305
|
+
google?: {
|
|
306
|
+
apiKey: string;
|
|
307
|
+
} | undefined;
|
|
308
|
+
vllm?: {
|
|
309
|
+
baseUrl: string;
|
|
310
|
+
} | undefined;
|
|
311
|
+
} | undefined;
|
|
312
|
+
}, {
|
|
313
|
+
defaultProvider?: "ollama" | "openai" | "anthropic" | "google" | "vllm" | undefined;
|
|
314
|
+
defaultModel?: string | undefined;
|
|
315
|
+
providers?: {
|
|
316
|
+
ollama?: {
|
|
317
|
+
baseUrl: string;
|
|
318
|
+
} | undefined;
|
|
319
|
+
openai?: {
|
|
320
|
+
apiKey: string;
|
|
321
|
+
baseUrl?: string | undefined;
|
|
322
|
+
} | undefined;
|
|
323
|
+
anthropic?: {
|
|
324
|
+
apiKey: string;
|
|
325
|
+
} | undefined;
|
|
326
|
+
google?: {
|
|
327
|
+
apiKey: string;
|
|
328
|
+
} | undefined;
|
|
329
|
+
vllm?: {
|
|
330
|
+
baseUrl: string;
|
|
331
|
+
} | undefined;
|
|
332
|
+
} | undefined;
|
|
333
|
+
}>>;
|
|
334
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
335
|
+
maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
|
|
336
|
+
defaultTimeout: z.ZodOptional<z.ZodNumber>;
|
|
337
|
+
maxTokensPerRun: z.ZodOptional<z.ZodNumber>;
|
|
338
|
+
}, "strip", z.ZodTypeAny, {
|
|
339
|
+
maxConcurrentRuns?: number | undefined;
|
|
340
|
+
defaultTimeout?: number | undefined;
|
|
341
|
+
maxTokensPerRun?: number | undefined;
|
|
342
|
+
}, {
|
|
343
|
+
maxConcurrentRuns?: number | undefined;
|
|
344
|
+
defaultTimeout?: number | undefined;
|
|
345
|
+
maxTokensPerRun?: number | undefined;
|
|
346
|
+
}>>;
|
|
347
|
+
}, "strip", z.ZodTypeAny, {
|
|
348
|
+
llm?: {
|
|
349
|
+
defaultProvider?: "ollama" | "openai" | "anthropic" | "google" | "vllm" | undefined;
|
|
350
|
+
defaultModel?: string | undefined;
|
|
351
|
+
providers?: {
|
|
352
|
+
ollama?: {
|
|
353
|
+
baseUrl: string;
|
|
354
|
+
} | undefined;
|
|
355
|
+
openai?: {
|
|
356
|
+
apiKey: string;
|
|
357
|
+
baseUrl?: string | undefined;
|
|
358
|
+
} | undefined;
|
|
359
|
+
anthropic?: {
|
|
360
|
+
apiKey: string;
|
|
361
|
+
} | undefined;
|
|
362
|
+
google?: {
|
|
363
|
+
apiKey: string;
|
|
364
|
+
} | undefined;
|
|
365
|
+
vllm?: {
|
|
366
|
+
baseUrl: string;
|
|
367
|
+
} | undefined;
|
|
368
|
+
} | undefined;
|
|
369
|
+
} | undefined;
|
|
370
|
+
limits?: {
|
|
371
|
+
maxConcurrentRuns?: number | undefined;
|
|
372
|
+
defaultTimeout?: number | undefined;
|
|
373
|
+
maxTokensPerRun?: number | undefined;
|
|
374
|
+
} | undefined;
|
|
375
|
+
}, {
|
|
376
|
+
llm?: {
|
|
377
|
+
defaultProvider?: "ollama" | "openai" | "anthropic" | "google" | "vllm" | undefined;
|
|
378
|
+
defaultModel?: string | undefined;
|
|
379
|
+
providers?: {
|
|
380
|
+
ollama?: {
|
|
381
|
+
baseUrl: string;
|
|
382
|
+
} | undefined;
|
|
383
|
+
openai?: {
|
|
384
|
+
apiKey: string;
|
|
385
|
+
baseUrl?: string | undefined;
|
|
386
|
+
} | undefined;
|
|
387
|
+
anthropic?: {
|
|
388
|
+
apiKey: string;
|
|
389
|
+
} | undefined;
|
|
390
|
+
google?: {
|
|
391
|
+
apiKey: string;
|
|
392
|
+
} | undefined;
|
|
393
|
+
vllm?: {
|
|
394
|
+
baseUrl: string;
|
|
395
|
+
} | undefined;
|
|
396
|
+
} | undefined;
|
|
397
|
+
} | undefined;
|
|
398
|
+
limits?: {
|
|
399
|
+
maxConcurrentRuns?: number | undefined;
|
|
400
|
+
defaultTimeout?: number | undefined;
|
|
401
|
+
maxTokensPerRun?: number | undefined;
|
|
402
|
+
} | undefined;
|
|
403
|
+
}>;
|
|
404
|
+
export type CogitatorConfigInput = z.input<typeof CogitatorConfigSchema>;
|
|
405
|
+
export type CogitatorConfigOutput = z.output<typeof CogitatorConfigSchema>;
|
|
406
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB,gEAM5B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI1B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGhC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACzE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema using Zod
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export const LLMProviderSchema = z.enum([
|
|
6
|
+
'ollama',
|
|
7
|
+
'openai',
|
|
8
|
+
'anthropic',
|
|
9
|
+
'google',
|
|
10
|
+
'vllm',
|
|
11
|
+
]);
|
|
12
|
+
export const ProvidersConfigSchema = z.object({
|
|
13
|
+
ollama: z.object({ baseUrl: z.string() }).optional(),
|
|
14
|
+
openai: z.object({ apiKey: z.string(), baseUrl: z.string().optional() }).optional(),
|
|
15
|
+
anthropic: z.object({ apiKey: z.string() }).optional(),
|
|
16
|
+
google: z.object({ apiKey: z.string() }).optional(),
|
|
17
|
+
vllm: z.object({ baseUrl: z.string() }).optional(),
|
|
18
|
+
});
|
|
19
|
+
export const LLMConfigSchema = z.object({
|
|
20
|
+
defaultProvider: LLMProviderSchema.optional(),
|
|
21
|
+
defaultModel: z.string().optional(),
|
|
22
|
+
providers: ProvidersConfigSchema.optional(),
|
|
23
|
+
});
|
|
24
|
+
export const LimitsConfigSchema = z.object({
|
|
25
|
+
maxConcurrentRuns: z.number().positive().optional(),
|
|
26
|
+
defaultTimeout: z.number().positive().optional(),
|
|
27
|
+
maxTokensPerRun: z.number().positive().optional(),
|
|
28
|
+
});
|
|
29
|
+
export const CogitatorConfigSchema = z.object({
|
|
30
|
+
llm: LLMConfigSchema.optional(),
|
|
31
|
+
limits: LimitsConfigSchema.optional(),
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC;IACtC,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpD,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,C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@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cogitator-ai/config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Configuration loading for Cogitator (YAML, env)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"yaml": "^2.3.4",
|
|
19
|
+
"zod": "^3.22.4",
|
|
20
|
+
"@cogitator-ai/types": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.3.0",
|
|
24
|
+
"vitest": "^1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/eL1fe/cogitator.git",
|
|
32
|
+
"directory": "packages/config"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest"
|
|
44
|
+
}
|
|
45
|
+
}
|