@cogitator-ai/core 0.19.2 → 0.19.4
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/package.json +19 -18
- package/dist/tools/self-config.d.ts +0 -9
- package/dist/tools/self-config.d.ts.map +0 -1
- package/dist/tools/self-config.js +0 -62
- package/dist/tools/self-config.js.map +0 -1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogitator-ai/core",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
4
4
|
"description": "Core runtime for Cogitator AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,22 +14,14 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"dev": "tsc --watch",
|
|
20
|
-
"clean": "rm -rf dist",
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"test:watch": "vitest"
|
|
24
|
-
},
|
|
25
17
|
"dependencies": {
|
|
26
18
|
"@anthropic-ai/sdk": "^0.74.0",
|
|
27
|
-
"@cogitator-ai/memory": "workspace:*",
|
|
28
|
-
"@cogitator-ai/models": "workspace:*",
|
|
29
|
-
"@cogitator-ai/types": "workspace:*",
|
|
30
19
|
"nanoid": "^5.0.4",
|
|
31
20
|
"openai": "^6.22.0",
|
|
32
|
-
"zod": "^4.3.6"
|
|
21
|
+
"zod": "^4.3.6",
|
|
22
|
+
"@cogitator-ai/memory": "0.6.22",
|
|
23
|
+
"@cogitator-ai/models": "17.1.9",
|
|
24
|
+
"@cogitator-ai/types": "0.22.3"
|
|
33
25
|
},
|
|
34
26
|
"optionalDependencies": {
|
|
35
27
|
"pg": "^8.18.0"
|
|
@@ -39,15 +31,16 @@
|
|
|
39
31
|
"@types/node": "^25.0.10",
|
|
40
32
|
"@types/pg": "^8.10.9",
|
|
41
33
|
"typescript": "^5.3.0",
|
|
42
|
-
"vitest": "^4.0.18"
|
|
34
|
+
"vitest": "^4.0.18",
|
|
35
|
+
"@cogitator-ai/sandbox": "0.2.29"
|
|
43
36
|
},
|
|
44
37
|
"peerDependencies": {
|
|
45
38
|
"@aws-sdk/client-bedrock-runtime": "^3.0.0",
|
|
46
|
-
"@cogitator-ai/sandbox": "workspace:*",
|
|
47
39
|
"better-sqlite3": "^11.0.0",
|
|
48
40
|
"langfuse": "^3.0.0",
|
|
49
41
|
"nodemailer": "^6.0.0",
|
|
50
|
-
"pg": "^8.0.0"
|
|
42
|
+
"pg": "^8.0.0",
|
|
43
|
+
"@cogitator-ai/sandbox": "0.2.29"
|
|
51
44
|
},
|
|
52
45
|
"peerDependenciesMeta": {
|
|
53
46
|
"@aws-sdk/client-bedrock-runtime": {
|
|
@@ -78,5 +71,13 @@
|
|
|
78
71
|
"access": "public",
|
|
79
72
|
"registry": "https://npm.pkg.github.com"
|
|
80
73
|
},
|
|
81
|
-
"license": "MIT"
|
|
82
|
-
|
|
74
|
+
"license": "MIT",
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "tsc",
|
|
77
|
+
"dev": "tsc --watch",
|
|
78
|
+
"clean": "rm -rf dist",
|
|
79
|
+
"typecheck": "tsc --noEmit",
|
|
80
|
+
"test": "vitest run",
|
|
81
|
+
"test:watch": "vitest"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '@cogitator-ai/types';
|
|
2
|
-
export declare function createSelfConfigTools(opts: {
|
|
3
|
-
configPath: string;
|
|
4
|
-
parseYaml: (s: string) => unknown;
|
|
5
|
-
stringifyYaml: (o: unknown) => string;
|
|
6
|
-
validateConfig: (o: unknown) => unknown;
|
|
7
|
-
onConfigUpdated?: () => void;
|
|
8
|
-
}): Tool[];
|
|
9
|
-
//# sourceMappingURL=self-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"self-config.d.ts","sourceRoot":"","sources":["../../src/tools/self-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AA0BhD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAClC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IACtC,cAAc,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B,GAAG,IAAI,EAAE,CA2CT"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { tool } from '../tool.js';
|
|
4
|
-
function deepMerge(target, source) {
|
|
5
|
-
const result = { ...target };
|
|
6
|
-
for (const key of Object.keys(source)) {
|
|
7
|
-
const srcVal = source[key];
|
|
8
|
-
const tgtVal = target[key];
|
|
9
|
-
if (srcVal !== null &&
|
|
10
|
-
typeof srcVal === 'object' &&
|
|
11
|
-
!Array.isArray(srcVal) &&
|
|
12
|
-
tgtVal !== null &&
|
|
13
|
-
typeof tgtVal === 'object' &&
|
|
14
|
-
!Array.isArray(tgtVal)) {
|
|
15
|
-
result[key] = deepMerge(tgtVal, srcVal);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
result[key] = srcVal;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
export function createSelfConfigTools(opts) {
|
|
24
|
-
const { configPath, parseYaml, stringifyYaml, validateConfig, onConfigUpdated } = opts;
|
|
25
|
-
const configRead = tool({
|
|
26
|
-
name: 'config_read',
|
|
27
|
-
description: 'Read the current assistant configuration (cogitator.yml)',
|
|
28
|
-
parameters: z.object({}),
|
|
29
|
-
execute: async () => {
|
|
30
|
-
const raw = readFileSync(configPath, 'utf-8');
|
|
31
|
-
return { config: parseYaml(raw) };
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
const configUpdate = tool({
|
|
35
|
-
name: 'config_update',
|
|
36
|
-
description: 'Update assistant configuration. Provide a partial config object that will be deep-merged with the current config. Changes are validated before saving. The assistant will restart automatically after a successful update.',
|
|
37
|
-
parameters: z.object({
|
|
38
|
-
updates: z
|
|
39
|
-
.record(z.string(), z.unknown())
|
|
40
|
-
.describe('Partial config to deep-merge with current config'),
|
|
41
|
-
}),
|
|
42
|
-
execute: async ({ updates }) => {
|
|
43
|
-
const raw = readFileSync(configPath, 'utf-8');
|
|
44
|
-
const current = parseYaml(raw);
|
|
45
|
-
const merged = deepMerge(current, updates);
|
|
46
|
-
try {
|
|
47
|
-
validateConfig(merged);
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
return {
|
|
51
|
-
success: false,
|
|
52
|
-
error: `Validation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
writeFileSync(configPath, stringifyYaml(merged));
|
|
56
|
-
onConfigUpdated?.();
|
|
57
|
-
return { success: true, message: 'Config updated. Restarting...' };
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
return [configRead, configUpdate];
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=self-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"self-config.js","sourceRoot":"","sources":["../../src/tools/self-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,SAAS,SAAS,CAChB,MAA+B,EAC/B,MAA+B;IAE/B,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3B,IACE,MAAM,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