@yrpri/api 9.0.122 → 9.0.123
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/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PsAgentClass, PsAgent, PsAiModel } from "@policysynth/agents/dbModels/index.js";
|
|
2
|
+
import models from "../../models/index.cjs";
|
|
3
|
+
import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
|
|
4
|
+
(async () => {
|
|
5
|
+
const [domainIdArg, agentClassIdArg] = process.argv.slice(2);
|
|
6
|
+
if (!domainIdArg || !agentClassIdArg) {
|
|
7
|
+
console.error("Usage: ts-node generateAgentWorkflowTemplateFromAgentClass.ts <domainId> <psAgentClassId>");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const domainId = Number(domainIdArg);
|
|
11
|
+
const agentClassId = Number(agentClassIdArg);
|
|
12
|
+
if (isNaN(domainId) || isNaN(agentClassId)) {
|
|
13
|
+
console.error("Both domainId and psAgentClassId must be valid numbers");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
await NewAiModelSetup.initializeModels();
|
|
18
|
+
const domain = await models.Domain.findByPk(domainId);
|
|
19
|
+
if (!domain) {
|
|
20
|
+
throw new Error(`Domain ${domainId} not found`);
|
|
21
|
+
}
|
|
22
|
+
// Create Community
|
|
23
|
+
const community = await models.Community.create({
|
|
24
|
+
domain_id: domainId,
|
|
25
|
+
name: `Agent Workflow Template ${Date.now()}`,
|
|
26
|
+
hostname: `agent-workflow-${Date.now()}`,
|
|
27
|
+
access: 1,
|
|
28
|
+
user_id: 1,
|
|
29
|
+
ip_address: "127.0.0.1",
|
|
30
|
+
user_agent: "generateAgentWorkflowTemplateFromAgentClass.ts",
|
|
31
|
+
configuration: {},
|
|
32
|
+
});
|
|
33
|
+
// Create Workflow Group
|
|
34
|
+
const group = await models.Group.create({
|
|
35
|
+
community_id: community.id,
|
|
36
|
+
name: "Agent Workflow",
|
|
37
|
+
access: 0,
|
|
38
|
+
user_id: 1,
|
|
39
|
+
ip_address: "127.0.0.1",
|
|
40
|
+
user_agent: "generateAgentWorkflowTemplateFromAgentClass.ts",
|
|
41
|
+
configuration: { groupType: 3, agents: {} },
|
|
42
|
+
});
|
|
43
|
+
// Create PsAgent from class
|
|
44
|
+
const agentClass = await PsAgentClass.findByPk(agentClassId);
|
|
45
|
+
if (!agentClass) {
|
|
46
|
+
throw new Error(`PsAgentClass ${agentClassId} not found`);
|
|
47
|
+
}
|
|
48
|
+
const psAgent = await PsAgent.create({
|
|
49
|
+
user_id: agentClass.user_id,
|
|
50
|
+
class_id: agentClass.id,
|
|
51
|
+
group_id: group.id,
|
|
52
|
+
configuration: {},
|
|
53
|
+
});
|
|
54
|
+
// Add Gemini 2.5 Pro Preview 2 model
|
|
55
|
+
const geminiReasoning = await PsAiModel.findOne({
|
|
56
|
+
where: { name: "Gemini 2.5 Pro Preview 2" },
|
|
57
|
+
});
|
|
58
|
+
if (geminiReasoning) {
|
|
59
|
+
await psAgent.addAiModel(geminiReasoning);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new Error("Gemini 2.5 Pro Preview 2 model not found");
|
|
63
|
+
}
|
|
64
|
+
// Add Gemini 2.0 Flash model
|
|
65
|
+
const geminiFlash = await PsAiModel.findOne({
|
|
66
|
+
where: { name: "Gemini 2.0 Flash" },
|
|
67
|
+
});
|
|
68
|
+
if (geminiFlash) {
|
|
69
|
+
await psAgent.addAiModel(geminiFlash);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
throw new Error("Gemini 2.0 Flash model not found");
|
|
73
|
+
}
|
|
74
|
+
// Update group configuration with top level agent id
|
|
75
|
+
group.configuration.agents = { topLevelAgentId: psAgent.id };
|
|
76
|
+
group.changed("configuration", true);
|
|
77
|
+
await group.save();
|
|
78
|
+
console.log(`Created community ${community.id}, group ${group.id}, agent ${psAgent.id}`);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error(error);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
await models.sequelize.close();
|
|
85
|
+
}
|
|
86
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import models from '../../models/index.cjs';
|
|
2
|
+
(async () => {
|
|
3
|
+
try {
|
|
4
|
+
const [userId, domainName, name] = process.argv.slice(2);
|
|
5
|
+
if (!domainName || !name) {
|
|
6
|
+
console.log('Usage: node createDomain.js <user_id> <domain_name> "<name>"');
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
const existing = await models.Domain.findOne({ where: { domain_name: domainName } });
|
|
10
|
+
if (existing) {
|
|
11
|
+
console.error(`Domain with domain_name ${domainName} already exists`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const domain = await models.Domain.create({
|
|
15
|
+
domain_name: domainName,
|
|
16
|
+
name,
|
|
17
|
+
access: 1,
|
|
18
|
+
user_id: parseInt(userId),
|
|
19
|
+
ip_address: '127.0.0.1',
|
|
20
|
+
user_agent: 'cli-script',
|
|
21
|
+
default_locale: 'en',
|
|
22
|
+
configuration: {}
|
|
23
|
+
});
|
|
24
|
+
console.log(`Created domain ${domain.name} with id ${domain.id}`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.error(err);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
})();
|