@yrpri/api 9.0.121 → 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/controllers/domains.cjs +1 -0
- package/models/user.cjs +17 -2
- package/package.json +1 -1
- package/scripts/agents/generateAgentWorkflowTemplateFromAgentClass.d.ts +1 -0
- package/scripts/agents/generateAgentWorkflowTemplateFromAgentClass.js +86 -0
- package/scripts/domains/createDomain.d.ts +1 -0
- package/scripts/domains/createDomain.js +31 -0
package/controllers/domains.cjs
CHANGED
|
@@ -808,6 +808,7 @@ function updateDomainProperties(domain, req) {
|
|
|
808
808
|
domain.set('configuration.ga4Tag', (req.body.ga4Tag && req.body.ga4Tag !== "") ? req.body.ga4Tag : null);
|
|
809
809
|
domain.set('configuration.useLoginOnDomainIfNotLoggedIn', truthValueFromBody(req.body.useLoginOnDomainIfNotLoggedIn));
|
|
810
810
|
domain.set('configuration.forceElectronicIds', truthValueFromBody(req.body.forceElectronicIds));
|
|
811
|
+
domain.set('configuration.doNotCreateElectronicIdUsersAutomatically', truthValueFromBody(req.body.doNotCreateElectronicIdUsersAutomatically));
|
|
811
812
|
if (req.body.google_analytics_code && req.body.google_analytics_code !== "") {
|
|
812
813
|
domain.google_analytics_code = req.body.google_analytics_code;
|
|
813
814
|
}
|
package/models/user.cjs
CHANGED
|
@@ -114,7 +114,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
114
114
|
User.serializeSamlUser = (profile, req, callback) => {
|
|
115
115
|
log.info("Serialize SAML user", { context: 'serializeSamlUser', profile: profile });
|
|
116
116
|
if (profile.UserSSN) {
|
|
117
|
-
sequelize.models.User.serializeIslandIsSamlUser(profile, callback);
|
|
117
|
+
sequelize.models.User.serializeIslandIsSamlUser(profile, req, callback);
|
|
118
118
|
}
|
|
119
119
|
else if (profile["urn:mynj:userCode"] || profile.issuer === 'https://my.state.nj.us/idp/shibboleth') {
|
|
120
120
|
sequelize.models.User.serializeMyNJSamlUser(profile, req, callback);
|
|
@@ -188,6 +188,11 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
188
188
|
},
|
|
189
189
|
(seriesCallback) => {
|
|
190
190
|
if (!user) {
|
|
191
|
+
if (req.ypDomain.configuration &&
|
|
192
|
+
req.ypDomain.configuration.doNotCreateElectronicIdUsersAutomatically) {
|
|
193
|
+
seriesCallback("customError");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
191
196
|
sequelize.models.User.create({
|
|
192
197
|
ssn: profile["urn:mynj:userCode"],
|
|
193
198
|
name: profile.FirstName + ' ' + profile.LastName,
|
|
@@ -227,7 +232,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
227
232
|
}
|
|
228
233
|
});
|
|
229
234
|
};
|
|
230
|
-
User.serializeIslandIsSamlUser = (profile, callback) => {
|
|
235
|
+
User.serializeIslandIsSamlUser = (profile, req, callback) => {
|
|
231
236
|
log.info("User Serialized In Serialize IslandIs SAML User", { context: 'serializeSamlUser', profile: profile });
|
|
232
237
|
let user;
|
|
233
238
|
async.series([
|
|
@@ -252,6 +257,11 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
252
257
|
},
|
|
253
258
|
(seriesCallback) => {
|
|
254
259
|
if (!user) {
|
|
260
|
+
if (req.ypDomain.configuration &&
|
|
261
|
+
req.ypDomain.configuration.doNotCreateElectronicIdUsersAutomatically) {
|
|
262
|
+
seriesCallback("customError");
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
255
265
|
sequelize.models.User.create({
|
|
256
266
|
ssn: profile.UserSSN,
|
|
257
267
|
name: profile.Name,
|
|
@@ -309,6 +319,11 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
309
319
|
},
|
|
310
320
|
(seriesCallback) => {
|
|
311
321
|
if (!user) {
|
|
322
|
+
if (req.ypDomain.configuration &&
|
|
323
|
+
req.ypDomain.configuration.doNotCreateElectronicIdUsersAutomatically) {
|
|
324
|
+
seriesCallback("customError");
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
312
327
|
sequelize.models.User.create({
|
|
313
328
|
ssn: profile.nationalRegisterId,
|
|
314
329
|
name: profile.name,
|
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
|
+
})();
|