@solidxai/core 0.1.23-beta.0 → 0.1.23-beta.1
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/CHANGELOG.md +803 -0
- package/dist/controllers/agent-config-version.controller.d.ts +29 -0
- package/dist/controllers/agent-config-version.controller.d.ts.map +1 -1
- package/dist/controllers/agent-config-version.controller.js +1 -1
- package/dist/controllers/agent-config-version.controller.js.map +1 -1
- package/dist/dtos/create-sms-template.dto.d.ts +1 -0
- package/dist/dtos/create-sms-template.dto.d.ts.map +1 -1
- package/dist/dtos/create-sms-template.dto.js +8 -1
- package/dist/dtos/create-sms-template.dto.js.map +1 -1
- package/dist/dtos/update-sms-template.dto.d.ts +1 -0
- package/dist/dtos/update-sms-template.dto.d.ts.map +1 -1
- package/dist/dtos/update-sms-template.dto.js +7 -1
- package/dist/dtos/update-sms-template.dto.js.map +1 -1
- package/dist/entities/sms-template.entity.d.ts +1 -0
- package/dist/entities/sms-template.entity.d.ts.map +1 -1
- package/dist/entities/sms-template.entity.js +6 -1
- package/dist/entities/sms-template.entity.js.map +1 -1
- package/dist/helpers/agent-general-config-comparison.d.ts +35 -0
- package/dist/helpers/agent-general-config-comparison.d.ts.map +1 -0
- package/dist/helpers/agent-general-config-comparison.js +27 -0
- package/dist/helpers/agent-general-config-comparison.js.map +1 -0
- package/dist/helpers/agent-general-config-comparison.spec.d.ts +2 -0
- package/dist/helpers/agent-general-config-comparison.spec.d.ts.map +1 -0
- package/dist/helpers/agent-general-config-comparison.spec.js +42 -0
- package/dist/helpers/agent-general-config-comparison.spec.js.map +1 -0
- package/dist/helpers/agent-tool-comparison.d.ts +40 -0
- package/dist/helpers/agent-tool-comparison.d.ts.map +1 -0
- package/dist/helpers/agent-tool-comparison.js +78 -0
- package/dist/helpers/agent-tool-comparison.js.map +1 -0
- package/dist/helpers/agent-tool-comparison.spec.d.ts +2 -0
- package/dist/helpers/agent-tool-comparison.spec.d.ts.map +1 -0
- package/dist/helpers/agent-tool-comparison.spec.js +61 -0
- package/dist/helpers/agent-tool-comparison.spec.js.map +1 -0
- package/dist/seeders/seed-data/solid-core-metadata.json +30 -0
- package/dist/services/agent-config-version-record.service.d.ts +30 -0
- package/dist/services/agent-config-version-record.service.d.ts.map +1 -1
- package/dist/services/agent-config-version-record.service.js +112 -7
- package/dist/services/agent-config-version-record.service.js.map +1 -1
- package/dist/services/agent-config-version-record.service.spec.d.ts +2 -0
- package/dist/services/agent-config-version-record.service.spec.d.ts.map +1 -0
- package/dist/services/agent-config-version-record.service.spec.js +56 -0
- package/dist/services/agent-config-version-record.service.spec.js.map +1 -0
- package/dist/services/agent-registry-deployment.spec.d.ts +2 -0
- package/dist/services/agent-registry-deployment.spec.d.ts.map +1 -0
- package/dist/services/agent-registry-deployment.spec.js +41 -0
- package/dist/services/agent-registry-deployment.spec.js.map +1 -0
- package/dist/services/agent-registry.service.d.ts.map +1 -1
- package/dist/services/agent-registry.service.js +3 -2
- package/dist/services/agent-registry.service.js.map +1 -1
- package/package.json +1 -1
- package/src/controllers/agent-config-version.controller.ts +1 -1
- package/src/dtos/create-sms-template.dto.ts +5 -0
- package/src/dtos/update-sms-template.dto.ts +5 -0
- package/src/entities/sms-template.entity.ts +2 -0
- package/src/helpers/agent-general-config-comparison.spec.ts +42 -0
- package/src/helpers/agent-general-config-comparison.ts +27 -0
- package/src/helpers/agent-tool-comparison.spec.ts +61 -0
- package/src/helpers/agent-tool-comparison.ts +71 -0
- package/src/seeders/seed-data/solid-core-metadata.json +30 -0
- package/src/services/agent-config-version-record.service.spec.ts +54 -0
- package/src/services/agent-config-version-record.service.ts +114 -9
- package/src/services/agent-registry-deployment.spec.ts +37 -0
- package/src/services/agent-registry.service.ts +5 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const agent_tool_comparison_1 = require("./agent-tool-comparison");
|
|
4
|
+
const at = (day) => new Date(`2026-11-${day}T12:00:00Z`);
|
|
5
|
+
const link = { id: 10, agentId: 1, toolId: 2, requiresApproval: true, createdAt: at(10) };
|
|
6
|
+
const audit = (overrides) => ({
|
|
7
|
+
messageId: 1, linkId: 10, eventType: 'audit_update', createdAt: at(15),
|
|
8
|
+
fieldName: 'requiresApproval', oldValue: 'false', newValue: 'true', ...overrides,
|
|
9
|
+
});
|
|
10
|
+
describe('toolLinksAt', () => {
|
|
11
|
+
it('resolves approval before and at the edit boundary', () => {
|
|
12
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(14), [link], [audit({})]).get(2)?.requiresApproval).toBe(false);
|
|
13
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(15), [link], [audit({})]).get(2)?.requiresApproval).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
it('excludes links created after a version even without audit history', () => {
|
|
16
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(11), [{ ...link, createdAt: at(12) }], []).size).toBe(0);
|
|
17
|
+
});
|
|
18
|
+
it('restores soft and hard deleted links from complete delete messages', () => {
|
|
19
|
+
const entries = [
|
|
20
|
+
audit({ eventType: 'audit_delete', fieldName: 'agentRegistry', oldValue: '1', newValue: null }),
|
|
21
|
+
audit({ eventType: 'audit_delete', fieldName: 'agentToolRegistry', oldValue: '2', newValue: null }),
|
|
22
|
+
audit({ eventType: 'audit_delete', oldValue: 'true', newValue: null }),
|
|
23
|
+
];
|
|
24
|
+
const current = [{ ...link, deletedAt: at(15) }];
|
|
25
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(14), current, entries).get(2)?.requiresApproval).toBe(true);
|
|
26
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(15), current, entries).size).toBe(0);
|
|
27
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(14), [], entries).has(2)).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
it('keeps delete and re-add events on different links independent', () => {
|
|
30
|
+
const current = [{ ...link, deletedAt: at(14) }, { ...link, id: 11, createdAt: at(16), requiresApproval: false }];
|
|
31
|
+
const entries = [
|
|
32
|
+
audit({ eventType: 'audit_delete', createdAt: at(14), oldValue: 'true', newValue: null }),
|
|
33
|
+
audit({ messageId: 2, linkId: 11, eventType: 'audit_insert', createdAt: at(16), oldValue: null, newValue: 'false' }),
|
|
34
|
+
];
|
|
35
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(13), current, entries).get(2)?.requiresApproval).toBe(true);
|
|
36
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(15), current, entries).size).toBe(0);
|
|
37
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(17), current, entries).get(2)?.requiresApproval).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
it('resolves tool and agent reassignments', () => {
|
|
40
|
+
const entries = [audit({ fieldName: 'agentToolRegistry', oldValue: '2', newValue: '3' }),
|
|
41
|
+
audit({ messageId: 2, createdAt: at(17), fieldName: 'agentRegistry', oldValue: '1', newValue: '4' })];
|
|
42
|
+
const current = [{ ...link, agentId: 4, toolId: 3 }];
|
|
43
|
+
expect([...(0, agent_tool_comparison_1.toolLinksAt)(1, at(14), current, entries).keys()]).toEqual([2]);
|
|
44
|
+
expect([...(0, agent_tool_comparison_1.toolLinksAt)(1, at(16), current, entries).keys()]).toEqual([3]);
|
|
45
|
+
expect((0, agent_tool_comparison_1.toolLinksAt)(1, at(18), current, entries).size).toBe(0);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('toolFieldAt', () => {
|
|
49
|
+
const entries = [audit({ fieldName: 'sourceCode', oldValue: 'original', newValue: 'version two' }),
|
|
50
|
+
audit({ messageId: 2, createdAt: at(19), fieldName: 'sourceCode', oldValue: 'version two', newValue: 'later edit' })];
|
|
51
|
+
it('resolves historical source, ignoring edits after the selected versions', () => {
|
|
52
|
+
expect((0, agent_tool_comparison_1.toolFieldAt)(entries, 'sourceCode', at(14), 'current')).toBe('original');
|
|
53
|
+
expect((0, agent_tool_comparison_1.toolFieldAt)(entries, 'sourceCode', at(15), 'current')).toBe('version two');
|
|
54
|
+
expect((0, agent_tool_comparison_1.toolFieldAt)(entries, 'sourceCode', at(20), 'current')).toBe('later edit');
|
|
55
|
+
});
|
|
56
|
+
it('falls back to current values only for fields without history', () => {
|
|
57
|
+
expect((0, agent_tool_comparison_1.toolFieldAt)(entries, 'name', at(14), 'tool')).toBe('tool');
|
|
58
|
+
expect((0, agent_tool_comparison_1.toolFieldAt)(entries, 'description', at(14), null)).toBe('');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=agent-tool-comparison.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool-comparison.spec.js","sourceRoot":"","sources":["../../src/helpers/agent-tool-comparison.spec.ts"],"names":[],"mappings":";;AAAA,mEAAiG;AAEjG,MAAM,EAAE,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;AACjE,MAAM,IAAI,GAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACzG,MAAM,KAAK,GAAG,CAAC,SAAiC,EAAiB,EAAE,CAAC,CAAC;IACjE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC;IACtE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS;CACnF,CAAC,CAAC;AAEH,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QACzD,MAAM,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,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACpE,MAAM,CAAC,IAAA,mCAAW,EAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,CAAC,IAAA,mCAAW,EAAC,OAAO,EAAE,aAAa,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { toolFieldAt, toolLinksAt, ToolLinkAudit, ToolLinkState } from './agent-tool-comparison';\n\nconst at = (day: number) => new Date(`2026-11-${day}T12:00:00Z`);\nconst link: ToolLinkState = { id: 10, agentId: 1, toolId: 2, requiresApproval: true, createdAt: at(10) };\nconst audit = (overrides: Partial<ToolLinkAudit>): ToolLinkAudit => ({\n messageId: 1, linkId: 10, eventType: 'audit_update', createdAt: at(15),\n fieldName: 'requiresApproval', oldValue: 'false', newValue: 'true', ...overrides,\n});\n\ndescribe('toolLinksAt', () => {\n it('resolves approval before and at the edit boundary', () => {\n expect(toolLinksAt(1, at(14), [link], [audit({})]).get(2)?.requiresApproval).toBe(false);\n expect(toolLinksAt(1, at(15), [link], [audit({})]).get(2)?.requiresApproval).toBe(true);\n });\n it('excludes links created after a version even without audit history', () => {\n expect(toolLinksAt(1, at(11), [{ ...link, createdAt: at(12) }], []).size).toBe(0);\n });\n it('restores soft and hard deleted links from complete delete messages', () => {\n const entries = [\n audit({ eventType: 'audit_delete', fieldName: 'agentRegistry', oldValue: '1', newValue: null }),\n audit({ eventType: 'audit_delete', fieldName: 'agentToolRegistry', oldValue: '2', newValue: null }),\n audit({ eventType: 'audit_delete', oldValue: 'true', newValue: null }),\n ];\n const current = [{ ...link, deletedAt: at(15) }];\n expect(toolLinksAt(1, at(14), current, entries).get(2)?.requiresApproval).toBe(true);\n expect(toolLinksAt(1, at(15), current, entries).size).toBe(0);\n expect(toolLinksAt(1, at(14), [], entries).has(2)).toBe(true);\n });\n it('keeps delete and re-add events on different links independent', () => {\n const current = [{ ...link, deletedAt: at(14) }, { ...link, id: 11, createdAt: at(16), requiresApproval: false }];\n const entries = [\n audit({ eventType: 'audit_delete', createdAt: at(14), oldValue: 'true', newValue: null }),\n audit({ messageId: 2, linkId: 11, eventType: 'audit_insert', createdAt: at(16), oldValue: null, newValue: 'false' }),\n ];\n expect(toolLinksAt(1, at(13), current, entries).get(2)?.requiresApproval).toBe(true);\n expect(toolLinksAt(1, at(15), current, entries).size).toBe(0);\n expect(toolLinksAt(1, at(17), current, entries).get(2)?.requiresApproval).toBe(false);\n });\n it('resolves tool and agent reassignments', () => {\n const entries = [audit({ fieldName: 'agentToolRegistry', oldValue: '2', newValue: '3' }),\n audit({ messageId: 2, createdAt: at(17), fieldName: 'agentRegistry', oldValue: '1', newValue: '4' })];\n const current = [{ ...link, agentId: 4, toolId: 3 }];\n expect([...toolLinksAt(1, at(14), current, entries).keys()]).toEqual([2]);\n expect([...toolLinksAt(1, at(16), current, entries).keys()]).toEqual([3]);\n expect(toolLinksAt(1, at(18), current, entries).size).toBe(0);\n });\n});\n\ndescribe('toolFieldAt', () => {\n const entries = [audit({ fieldName: 'sourceCode', oldValue: 'original', newValue: 'version two' }),\n audit({ messageId: 2, createdAt: at(19), fieldName: 'sourceCode', oldValue: 'version two', newValue: 'later edit' })];\n it('resolves historical source, ignoring edits after the selected versions', () => {\n expect(toolFieldAt(entries, 'sourceCode', at(14), 'current')).toBe('original');\n expect(toolFieldAt(entries, 'sourceCode', at(15), 'current')).toBe('version two');\n expect(toolFieldAt(entries, 'sourceCode', at(20), 'current')).toBe('later edit');\n });\n it('falls back to current values only for fields without history', () => {\n expect(toolFieldAt(entries, 'name', at(14), 'tool')).toBe('tool');\n expect(toolFieldAt(entries, 'description', at(14), null)).toBe('');\n });\n});\n"]}
|
|
@@ -4371,6 +4371,20 @@
|
|
|
4371
4371
|
"html:HTML"
|
|
4372
4372
|
]
|
|
4373
4373
|
},
|
|
4374
|
+
{
|
|
4375
|
+
"name": "isTransactional",
|
|
4376
|
+
"displayName": "Is Transactional",
|
|
4377
|
+
"type": "boolean",
|
|
4378
|
+
"ormType": "boolean",
|
|
4379
|
+
"defaultValue": "false",
|
|
4380
|
+
"required": false,
|
|
4381
|
+
"unique": false,
|
|
4382
|
+
"index": false,
|
|
4383
|
+
"private": false,
|
|
4384
|
+
"encrypt": false,
|
|
4385
|
+
"columnName": "is_transactional",
|
|
4386
|
+
"isSystem": true
|
|
4387
|
+
},
|
|
4374
4388
|
{
|
|
4375
4389
|
"name": "smsProviderTemplateId",
|
|
4376
4390
|
"displayName": "SMS Provider Template Id",
|
|
@@ -20764,6 +20778,15 @@
|
|
|
20764
20778
|
"isSearchable": false
|
|
20765
20779
|
}
|
|
20766
20780
|
},
|
|
20781
|
+
{
|
|
20782
|
+
"type": "field",
|
|
20783
|
+
"attrs": {
|
|
20784
|
+
"name": "isTransactional",
|
|
20785
|
+
"label": "Is Transactional",
|
|
20786
|
+
"sortable": true,
|
|
20787
|
+
"isSearchable": false
|
|
20788
|
+
}
|
|
20789
|
+
},
|
|
20767
20790
|
{
|
|
20768
20791
|
"type": "field",
|
|
20769
20792
|
"attrs": {
|
|
@@ -20877,6 +20900,13 @@
|
|
|
20877
20900
|
"label": "Sms Provider Template Id"
|
|
20878
20901
|
}
|
|
20879
20902
|
},
|
|
20903
|
+
{
|
|
20904
|
+
"type": "field",
|
|
20905
|
+
"attrs": {
|
|
20906
|
+
"name": "isTransactional",
|
|
20907
|
+
"label": "Is Transactional"
|
|
20908
|
+
}
|
|
20909
|
+
},
|
|
20880
20910
|
{
|
|
20881
20911
|
"type": "field",
|
|
20882
20912
|
"attrs": {
|
|
@@ -50,6 +50,35 @@ export declare class AgentConfigVersionRecordService extends CRUDService<AgentCo
|
|
|
50
50
|
status: string;
|
|
51
51
|
rows: any[];
|
|
52
52
|
};
|
|
53
|
+
tools: {
|
|
54
|
+
title: string;
|
|
55
|
+
status: string;
|
|
56
|
+
rows: {
|
|
57
|
+
id: string;
|
|
58
|
+
status: string;
|
|
59
|
+
diffKey: string;
|
|
60
|
+
left: {
|
|
61
|
+
label: string;
|
|
62
|
+
summary: string;
|
|
63
|
+
};
|
|
64
|
+
right: {
|
|
65
|
+
label: string;
|
|
66
|
+
summary: string;
|
|
67
|
+
};
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
generalConfiguration: {
|
|
71
|
+
title: string;
|
|
72
|
+
status: string;
|
|
73
|
+
fields: {
|
|
74
|
+
key: string;
|
|
75
|
+
label: string;
|
|
76
|
+
status: string;
|
|
77
|
+
left: string;
|
|
78
|
+
right: string;
|
|
79
|
+
emptyLabel: string;
|
|
80
|
+
}[];
|
|
81
|
+
};
|
|
53
82
|
modelConfiguration: {
|
|
54
83
|
title: string;
|
|
55
84
|
status: string;
|
|
@@ -57,6 +86,7 @@ export declare class AgentConfigVersionRecordService extends CRUDService<AgentCo
|
|
|
57
86
|
};
|
|
58
87
|
};
|
|
59
88
|
}>;
|
|
89
|
+
private getToolComparison;
|
|
60
90
|
getComparisonDiff(agentId: number, leftVersionId: number, rightVersionId: number, diffKey?: string): Promise<{
|
|
61
91
|
diffKey: string;
|
|
62
92
|
title: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-config-version-record.service.d.ts","sourceRoot":"","sources":["../../src/services/agent-config-version-record.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAY,aAAa,EAAM,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-config-version-record.service.d.ts","sourceRoot":"","sources":["../../src/services/agent-config-version-record.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAY,aAAa,EAAM,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAW7F,qBACa,+BAAgC,SAAQ,WAAW,CAAC,kBAAkB,CAAC;IAG5E,QAAQ,CAAC,aAAa,EAAE,aAAa;IACrC,QAAQ,CAAC,IAAI,EAAE,4BAA4B;IAC3C,QAAQ,CAAC,SAAS,EAAE,SAAS;gBAFpB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,4BAA4B,EAClC,SAAS,EAAE,SAAS;IAK3B,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiOpE,iBAAiB;IA8DzB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,SAAiB;;;;;;;;;;;;;;;;;;;;CA0GnH"}
|
|
@@ -20,6 +20,10 @@ const typeorm_2 = require("typeorm");
|
|
|
20
20
|
const crud_service_1 = require("./crud.service");
|
|
21
21
|
const agent_config_version_repository_1 = require("../repository/agent-config-version.repository");
|
|
22
22
|
const agent_registry_repository_1 = require("../repository/agent-registry.repository");
|
|
23
|
+
const agent_tool_repository_1 = require("../repository/agent-tool.repository");
|
|
24
|
+
const agent_tool_registry_repository_1 = require("../repository/agent-tool-registry.repository");
|
|
25
|
+
const agent_tool_comparison_1 = require("../helpers/agent-tool-comparison");
|
|
26
|
+
const agent_general_config_comparison_1 = require("../helpers/agent-general-config-comparison");
|
|
23
27
|
const agent_skill_repository_1 = require("../repository/agent-skill.repository");
|
|
24
28
|
const agent_skill_registry_repository_1 = require("../repository/agent-skill-registry.repository");
|
|
25
29
|
const chatter_message_repository_1 = require("../repository/chatter-message.repository");
|
|
@@ -37,7 +41,7 @@ let AgentConfigVersionRecordService = class AgentConfigVersionRecordService exte
|
|
|
37
41
|
throw new common_1.BadRequestException('Provide a positive agent ID and two different config-version IDs.');
|
|
38
42
|
}
|
|
39
43
|
const activeUser = this.moduleRef.get(request_context_service_1.RequestContextService, { strict: false }).getActiveUser();
|
|
40
|
-
const models = ['agentRegistry', 'agentConfigVersion', 'agentSkill', 'agentSkillRegistry', 'chatterMessage', 'chatterMessageDetails'];
|
|
44
|
+
const models = ['agentRegistry', 'agentConfigVersion', 'agentSkill', 'agentSkillRegistry', 'agentTool', 'agentToolRegistry', 'chatterMessage', 'chatterMessageDetails'];
|
|
41
45
|
if (!activeUser || models.some((model) => !this.crudHelperService.hasReadPermissionOnModel(activeUser, model))) {
|
|
42
46
|
throw new common_1.ForbiddenException('You do not have permission to compare these configurations.');
|
|
43
47
|
}
|
|
@@ -48,7 +52,8 @@ let AgentConfigVersionRecordService = class AgentConfigVersionRecordService exte
|
|
|
48
52
|
order: { createdAt: 'ASC', id: 'ASC' },
|
|
49
53
|
}),
|
|
50
54
|
this.moduleRef.get(agent_registry_repository_1.AgentRegistryRepository, { strict: false }).findOne({
|
|
51
|
-
where: { id: agentId }, select: { id: true,
|
|
55
|
+
where: { id: agentId }, select: { id: true, reasoningModelKey: true, fastModelKey: true,
|
|
56
|
+
...Object.fromEntries(Object.keys(agent_general_config_comparison_1.AGENT_GENERAL_CONFIG_FIELDS).map((field) => [field, true])) },
|
|
52
57
|
}),
|
|
53
58
|
]);
|
|
54
59
|
if (!agent || versions.length !== 2) {
|
|
@@ -57,14 +62,15 @@ let AgentConfigVersionRecordService = class AgentConfigVersionRecordService exte
|
|
|
57
62
|
const [older, newer] = versions;
|
|
58
63
|
const chatter = this.moduleRef.get(chatter_message_repository_1.ChatterMessageRepository, { strict: false });
|
|
59
64
|
const query = await chatter.createSecurityRuleAwareQueryBuilder('entity');
|
|
60
|
-
const
|
|
65
|
+
const historicalFields = ['reasoningModelKey', 'fastModelKey', ...Object.keys(agent_general_config_comparison_1.AGENT_GENERAL_CONFIG_FIELDS)];
|
|
66
|
+
const fields = ['systemPrompt', ...historicalFields];
|
|
61
67
|
const agentRegistryEntries = await query.innerJoin('entity.chatterMessageDetails', 'detail')
|
|
62
68
|
.andWhere('entity.messageType = :messageType', { messageType: 'audit' })
|
|
63
69
|
.andWhere('entity.coModelName = :modelName', { modelName: 'agentRegistry' })
|
|
64
70
|
.andWhere('entity.coModelEntityId = :agentId', { agentId })
|
|
65
71
|
.andWhere('detail.fieldName IN (:...fields)', { fields })
|
|
66
72
|
.andWhere(new typeorm_2.Brackets((where) => {
|
|
67
|
-
where.where('detail.fieldName IN (:...
|
|
73
|
+
where.where('detail.fieldName IN (:...historicalFields)', { historicalFields })
|
|
68
74
|
.orWhere("detail.fieldName = 'systemPrompt' AND entity.createdAt > :start AND entity.createdAt <= :end");
|
|
69
75
|
}))
|
|
70
76
|
.setParameters({ start: local_date_time_transformer_1.LocalDateTimeTransformer.to(older.createdAt), end: local_date_time_transformer_1.LocalDateTimeTransformer.to(newer.createdAt) })
|
|
@@ -77,7 +83,7 @@ let AgentConfigVersionRecordService = class AgentConfigVersionRecordService exte
|
|
|
77
83
|
.addOrderBy('entity.id', 'ASC')
|
|
78
84
|
.addOrderBy('detail.id', 'ASC')
|
|
79
85
|
.getRawMany();
|
|
80
|
-
const agentRegistryChanges =
|
|
86
|
+
const agentRegistryChanges = Object.fromEntries(fields.map((field) => [field, []]));
|
|
81
87
|
for (const entry of agentRegistryEntries) {
|
|
82
88
|
agentRegistryChanges[entry.fieldName].push({
|
|
83
89
|
...entry,
|
|
@@ -218,6 +224,7 @@ let AgentConfigVersionRecordService = class AgentConfigVersionRecordService exte
|
|
|
218
224
|
left: values[0][index] || null, right: values[1][index] || null })),
|
|
219
225
|
});
|
|
220
226
|
}
|
|
227
|
+
const toolRows = await this.getToolComparison(agentId, older.createdAt, newer.createdAt);
|
|
221
228
|
const headers = versions.map((version) => ({ id: version.id, versionNumber: version.versionNumber,
|
|
222
229
|
name: version.name ?? null, description: version.description ?? null, createdAt: version.createdAt.toISOString() }));
|
|
223
230
|
return { schemaVersion: 1, agent: { id: agent.id, name: agent.name, title: agent.title },
|
|
@@ -227,17 +234,115 @@ let AgentConfigVersionRecordService = class AgentConfigVersionRecordService exte
|
|
|
227
234
|
left: { label: 'System prompt', summary: promptChanged ? 'Previous instructions' : 'No recorded changes' },
|
|
228
235
|
right: { label: 'System prompt', summary: promptChanged ? 'Updated instructions' : 'No recorded changes' } },
|
|
229
236
|
skills: { title: 'Skills', status: skillRows.some((row) => row.status !== 'matched') ? 'changed' : 'matched', rows: skillRows },
|
|
237
|
+
tools: { title: 'Tools', status: toolRows.some((row) => row.status !== 'matched') ? 'changed' : 'matched', rows: toolRows },
|
|
238
|
+
generalConfiguration: (0, agent_general_config_comparison_1.compareAgentGeneralConfig)(agent, Object.values(agentRegistryChanges).flat(), older.createdAt, newer.createdAt),
|
|
230
239
|
modelConfiguration: { title: 'Model configuration', status: groups.some((group) => group.status === 'changed') ? 'changed' : 'matched', groups },
|
|
231
240
|
},
|
|
232
241
|
};
|
|
233
242
|
}
|
|
243
|
+
async getToolComparison(agentId, older, newer) {
|
|
244
|
+
const chatter = this.moduleRef.get(chatter_message_repository_1.ChatterMessageRepository, { strict: false });
|
|
245
|
+
const links = await this.moduleRef.get(agent_tool_repository_1.AgentToolRepository, { strict: false }).find({
|
|
246
|
+
where: { agentRegistry: { id: agentId } }, withDeleted: true,
|
|
247
|
+
relations: { agentToolRegistry: true },
|
|
248
|
+
select: { id: true, createdAt: true, deletedAt: true, requiresApproval: true, agentToolRegistry: { id: true } },
|
|
249
|
+
});
|
|
250
|
+
const currentIds = links.map((link) => link.id);
|
|
251
|
+
const query = await chatter.createSecurityRuleAwareQueryBuilder('entity');
|
|
252
|
+
query.andWhere('entity.messageType = :messageType', { messageType: 'audit' })
|
|
253
|
+
.andWhere('entity.coModelName = :modelName', { modelName: 'agentTool' });
|
|
254
|
+
const identities = query.clone().leftJoin('entity.chatterMessageDetails', 'identityDetail')
|
|
255
|
+
.select('entity.coModelEntityId').distinct(true)
|
|
256
|
+
.andWhere(new typeorm_2.Brackets((where) => {
|
|
257
|
+
where.where('entity.modelUserKey LIKE :agentKey')
|
|
258
|
+
.orWhere("identityDetail.fieldName = 'agentToolKey' AND (identityDetail.oldValue LIKE :agentKey OR identityDetail.newValue LIKE :agentKey)")
|
|
259
|
+
.orWhere("identityDetail.fieldName = 'agentRegistry' AND (identityDetail.oldValue = :agentValue OR identityDetail.newValue = :agentValue)");
|
|
260
|
+
if (currentIds.length)
|
|
261
|
+
where.orWhere('entity.coModelEntityId IN (:...currentIds)', { currentIds });
|
|
262
|
+
})).setParameters({ agentKey: `${agentId}:%`, agentValue: String(agentId) });
|
|
263
|
+
const raw = await query.leftJoin('entity.chatterMessageDetails', 'detail')
|
|
264
|
+
.andWhere(`entity.coModelEntityId IN (${identities.getQuery()})`).setParameters(identities.getParameters())
|
|
265
|
+
.select('entity.id', 'messageId').addSelect('entity.coModelEntityId', 'linkId')
|
|
266
|
+
.addSelect('entity.messageSubType', 'eventType').addSelect('entity.modelUserKey', 'key')
|
|
267
|
+
.addSelect('entity.createdAt', 'createdAt').addSelect('detail.fieldName', 'fieldName')
|
|
268
|
+
.addSelect('detail.oldValue', 'oldValue').addSelect('detail.newValue', 'newValue')
|
|
269
|
+
.orderBy('entity.createdAt', 'ASC').addOrderBy('entity.id', 'ASC').addOrderBy('detail.id', 'ASC').getRawMany();
|
|
270
|
+
const entries = raw.map((entry) => ({ ...entry, messageId: Number(entry.messageId), linkId: Number(entry.linkId), createdAt: local_date_time_transformer_1.LocalDateTimeTransformer.from(entry.createdAt) }));
|
|
271
|
+
const current = links.map((link) => ({ ...link, agentId, toolId: link.agentToolRegistry.id }));
|
|
272
|
+
const left = (0, agent_tool_comparison_1.toolLinksAt)(agentId, older, current, entries);
|
|
273
|
+
const right = (0, agent_tool_comparison_1.toolLinksAt)(agentId, newer, current, entries);
|
|
274
|
+
const ids = [...new Set([...left.keys(), ...right.keys()])].sort((a, b) => a - b);
|
|
275
|
+
if (!ids.length)
|
|
276
|
+
return [];
|
|
277
|
+
const catalog = await this.moduleRef.get(agent_tool_registry_repository_1.AgentToolRegistryRepository, { strict: false }).find({
|
|
278
|
+
where: { id: (0, typeorm_2.In)(ids) }, withDeleted: true, select: { id: true, name: true },
|
|
279
|
+
});
|
|
280
|
+
const catalogQuery = await chatter.createSecurityRuleAwareQueryBuilder('entity');
|
|
281
|
+
const changes = await catalogQuery.innerJoin('entity.chatterMessageDetails', 'detail')
|
|
282
|
+
.andWhere('entity.messageType = :messageType', { messageType: 'audit' })
|
|
283
|
+
.andWhere('entity.coModelName = :modelName', { modelName: 'agentToolRegistry' })
|
|
284
|
+
.andWhere('entity.coModelEntityId IN (:...ids)', { ids })
|
|
285
|
+
.andWhere('detail.fieldName IN (:...fields)', { fields: Object.keys(agent_tool_comparison_1.TOOL_COMPARISON_FIELDS) })
|
|
286
|
+
.select('entity.coModelEntityId', 'toolId').addSelect('entity.createdAt', 'createdAt')
|
|
287
|
+
.addSelect('detail.fieldName', 'fieldName')
|
|
288
|
+
.addSelect("CASE WHEN detail.fieldName = 'name' THEN detail.oldValue ELSE NULL END", 'oldValue')
|
|
289
|
+
.addSelect("CASE WHEN detail.fieldName = 'name' THEN detail.newValue ELSE NULL END", 'newValue')
|
|
290
|
+
.orderBy('entity.createdAt', 'ASC').addOrderBy('entity.id', 'ASC').addOrderBy('detail.id', 'ASC').getRawMany();
|
|
291
|
+
for (const entry of changes)
|
|
292
|
+
entry.createdAt = local_date_time_transformer_1.LocalDateTimeTransformer.from(entry.createdAt);
|
|
293
|
+
return ids.map((id) => {
|
|
294
|
+
const before = left.get(id), after = right.get(id);
|
|
295
|
+
const history = changes.filter((entry) => Number(entry.toolId) === id);
|
|
296
|
+
const changed = history.some((entry) => entry.createdAt > older && entry.createdAt <= newer);
|
|
297
|
+
const status = !before ? 'added' : !after ? 'removed' : changed || before.requiresApproval !== after.requiresApproval ? 'changed' : 'matched';
|
|
298
|
+
const sides = [before, after].map((link, index) => link ? {
|
|
299
|
+
label: (0, agent_tool_comparison_1.toolFieldAt)(history, 'name', index === 0 ? older : newer, catalog.find((tool) => tool.id === id)?.name) || `Tool ${id}`,
|
|
300
|
+
summary: link.requiresApproval ? 'Requires approval' : 'No approval required',
|
|
301
|
+
} : null);
|
|
302
|
+
return { id: String(id), status, diffKey: status === 'matched' ? null : `tool:${id}`, left: sides[0], right: sides[1] };
|
|
303
|
+
});
|
|
304
|
+
}
|
|
234
305
|
async getComparisonDiff(agentId, leftVersionId, rightVersionId, diffKey = 'systemPrompt') {
|
|
235
306
|
const skillId = /^skill:[1-9]\d*$/.test(diffKey) ? Number(diffKey.slice(6)) : null;
|
|
236
|
-
|
|
237
|
-
|
|
307
|
+
const toolId = /^tool:[1-9]\d*$/.test(diffKey) ? Number(diffKey.slice(5)) : null;
|
|
308
|
+
if (diffKey !== 'systemPrompt' && ![skillId, toolId].some((id) => Number.isSafeInteger(id) && id > 0)) {
|
|
309
|
+
throw new common_1.BadRequestException('Provide systemPrompt, skill:<id>, or tool:<id> as the diff key.');
|
|
238
310
|
}
|
|
239
311
|
const comparison = await this.getComparison(agentId, leftVersionId, rightVersionId);
|
|
240
312
|
const { left, right } = comparison.versions;
|
|
313
|
+
if (toolId !== null) {
|
|
314
|
+
const row = comparison.sections.tools.rows.find((item) => item.id === String(toolId));
|
|
315
|
+
if (!row || row.status === 'matched')
|
|
316
|
+
throw new common_1.NotFoundException('There are no recorded changes for this tool in the comparison.');
|
|
317
|
+
const query = await this.moduleRef.get(chatter_message_repository_1.ChatterMessageRepository, { strict: false }).createSecurityRuleAwareQueryBuilder('entity');
|
|
318
|
+
const [rawEntries, tool] = await Promise.all([
|
|
319
|
+
query.innerJoin('entity.chatterMessageDetails', 'detail')
|
|
320
|
+
.andWhere('entity.messageType = :messageType', { messageType: 'audit' })
|
|
321
|
+
.andWhere('entity.coModelName = :modelName', { modelName: 'agentToolRegistry' })
|
|
322
|
+
.andWhere('entity.coModelEntityId = :toolId', { toolId })
|
|
323
|
+
.andWhere('detail.fieldName IN (:...fields)', { fields: Object.keys(agent_tool_comparison_1.TOOL_COMPARISON_FIELDS) })
|
|
324
|
+
.select('entity.createdAt', 'createdAt').addSelect('detail.fieldName', 'fieldName')
|
|
325
|
+
.addSelect('detail.oldValue', 'oldValue').addSelect('detail.newValue', 'newValue')
|
|
326
|
+
.orderBy('entity.createdAt', 'ASC').addOrderBy('entity.id', 'ASC').addOrderBy('detail.id', 'ASC').getRawMany(),
|
|
327
|
+
this.moduleRef.get(agent_tool_registry_repository_1.AgentToolRegistryRepository, { strict: false }).findOne({
|
|
328
|
+
where: { id: toolId }, withDeleted: true, relations: { module: true, tags: true },
|
|
329
|
+
}),
|
|
330
|
+
]);
|
|
331
|
+
if (!tool && !rawEntries.length)
|
|
332
|
+
throw new common_1.NotFoundException('The historical configuration for this tool is unavailable.');
|
|
333
|
+
const entries = rawEntries.map((entry) => ({ ...entry, createdAt: local_date_time_transformer_1.LocalDateTimeTransformer.from(entry.createdAt) }));
|
|
334
|
+
const settings = [row.left, row.right].map((side) => side ? String(side.summary === 'Requires approval') : '');
|
|
335
|
+
const rows = [{ id: 'requiresApproval', title: 'Requires approval', oldValue: settings[0], newValue: settings[1] }];
|
|
336
|
+
for (const [field, title] of Object.entries(agent_tool_comparison_1.TOOL_COMPARISON_FIELDS)) {
|
|
337
|
+
const fallback = field === 'module' ? tool?.module?.id : field === 'tags' ? tool?.tags?.map((tag) => tag.id).join(', ') : tool?.[field];
|
|
338
|
+
const values = [left, right].map((version, index) => (index === 0 ? row.left : row.right)
|
|
339
|
+
? (0, agent_tool_comparison_1.toolFieldAt)(entries, field, new Date(version.createdAt), fallback) : '');
|
|
340
|
+
const changed = entries.some((entry) => entry.fieldName === field && entry.createdAt > new Date(left.createdAt) && entry.createdAt <= new Date(right.createdAt));
|
|
341
|
+
if (changed || values[0] !== values[1])
|
|
342
|
+
rows.push({ id: field, title, oldValue: values[0], newValue: values[1] });
|
|
343
|
+
}
|
|
344
|
+
return { diffKey, title: row.right?.label || row.left?.label || `Tool ${toolId}`, language: 'text', oldValue: '', newValue: '', rows };
|
|
345
|
+
}
|
|
241
346
|
if (skillId !== null) {
|
|
242
347
|
const row = comparison.sections.skills.rows.find((item) => item.id === String(skillId));
|
|
243
348
|
if (!row || row.status === 'matched') {
|