@yrpri/api 9.0.138 → 9.0.139

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.
@@ -41,6 +41,8 @@ export declare class PolicySynthAgentsController {
41
41
  controlAgent: (req: express.Request, res: express.Response) => Promise<void>;
42
42
  getAgentStatus: (req: express.Request, res: express.Response) => Promise<void>;
43
43
  updateAgentStatus: (req: express.Request, res: express.Response) => Promise<void>;
44
+ private recursiveDeleteAgent;
45
+ deleteAgent: (req: YpRequest, res: express.Response) => Promise<void>;
44
46
  startAgentProcessing: (req: express.Request, res: express.Response) => Promise<void>;
45
47
  pauseAgentProcessing: (req: express.Request, res: express.Response) => Promise<void>;
46
48
  getAgentCosts: (req: express.Request, res: express.Response) => Promise<void>;
@@ -6,6 +6,7 @@ import { AgentConnectorManager } from "@policysynth/agents/operations/agentConne
6
6
  import { AgentRegistryManager } from "@policysynth/agents/operations/agentRegistryManager.js";
7
7
  import { PsAiModel } from "@policysynth/agents/dbModels/aiModel.js";
8
8
  import auth from "../../authorization.cjs";
9
+ import { PsAgent } from "@policysynth/agents/dbModels/agent.js";
9
10
  import { NewAiModelSetup } from "../managers/newAiModelSetup.js";
10
11
  export class PolicySynthAgentsController {
11
12
  constructor(wsClients) {
@@ -315,6 +316,22 @@ export class PolicySynthAgentsController {
315
316
  res.status(500).send("Internal Server Error");
316
317
  }
317
318
  };
319
+ this.deleteAgent = async (req, res) => {
320
+ try {
321
+ const agentId = parseInt(req.params.agentId);
322
+ await this.recursiveDeleteAgent(agentId);
323
+ res.json({ message: "Agent deleted" });
324
+ }
325
+ catch (error) {
326
+ console.error("Error deleting agent:", error);
327
+ if (error instanceof Error) {
328
+ res.status(500).json({ error: error.message });
329
+ }
330
+ else {
331
+ res.status(500).json({ error: "An unexpected error occurred" });
332
+ }
333
+ }
334
+ };
318
335
  this.startAgentProcessing = async (req, res) => {
319
336
  const agentId = parseInt(req.params.id);
320
337
  try {
@@ -409,5 +426,19 @@ export class PolicySynthAgentsController {
409
426
  this.router.get("/:groupId/:agentId/memory", auth.can("edit group"), this.getAgentMemory);
410
427
  this.router.post("/:groupId/:agentId/inputConnectors/existing", auth.can("edit group"), this.addExistingConnector);
411
428
  this.router.post("/:groupId/:agentId/outputConnectors/existing", auth.can("edit group"), this.addExistingConnector);
429
+ this.router.delete("/:groupId/:agentId", auth.can("edit group"), this.deleteAgent);
430
+ }
431
+ async recursiveDeleteAgent(agentId) {
432
+ const agent = await PsAgent.findByPk(agentId, {
433
+ include: [{ model: PsAgent, as: "SubAgents" }],
434
+ });
435
+ if (!agent)
436
+ return;
437
+ if (agent.SubAgents) {
438
+ for (const sub of agent.SubAgents) {
439
+ await this.recursiveDeleteAgent(sub.id);
440
+ }
441
+ }
442
+ await agent.destroy();
412
443
  }
413
444
  }
@@ -371,9 +371,9 @@ export class NewAiModelSetup {
371
371
  modelSize: PsAiModelSize.Medium,
372
372
  provider: "openai",
373
373
  prices: {
374
- costInTokensPerMillion: 10.0,
375
- costOutTokensPerMillion: 40.0,
376
- costInCachedContextTokensPerMillion: 2.5,
374
+ costInTokensPerMillion: 2.0,
375
+ costOutTokensPerMillion: 8.0,
376
+ costInCachedContextTokensPerMillion: 0.5,
377
377
  currency: "USD",
378
378
  },
379
379
  maxTokensOut: 100000,
@@ -570,45 +570,8 @@ export class NewAiModelSetup {
570
570
  await gemini20Flash.save();
571
571
  console.log("Google model already exists: Gemini 2.0 Flash");
572
572
  }
573
- const gemini25ProPreview1 = await PsAiModel.findOne({
574
- where: { name: "Gemini 2.5 Pro Preview 1" },
575
- });
576
- const gemini25ProPreview1Config = {
577
- type: PsAiModelType.TextReasoning,
578
- modelSize: PsAiModelSize.Large,
579
- provider: "google",
580
- prices: {
581
- costInTokensPerMillion: 1.25,
582
- costOutTokensPerMillion: 10,
583
- costInCachedContextTokensPerMillion: 0.875,
584
- longContextTokenThreshold: 200000,
585
- longContextCostInTokensPerMillion: 2.5,
586
- longContextCostInCachedContextTokensPerMillion: 1.75,
587
- longContextCostOutTokensPerMillion: 15,
588
- currency: "USD",
589
- },
590
- model: "gemini-2.5-pro-preview-04-17",
591
- active: true,
592
- maxTokensOut: 100000,
593
- defaultTemperature: 0.0
594
- };
595
- if (!gemini25ProPreview1) {
596
- await PsAiModel.create({
597
- name: "Gemini 2.5 Pro Preview 1",
598
- organization_id: 1,
599
- user_id: userId,
600
- configuration: gemini25ProPreview1Config,
601
- });
602
- console.log("Created Google model: Gemini 2.5 Pro Preview 1");
603
- }
604
- else {
605
- gemini25ProPreview1.set("configuration", gemini25ProPreview1Config);
606
- gemini25ProPreview1.changed("configuration", true);
607
- await gemini25ProPreview1.save();
608
- console.log("Google model already exists: Gemini 2.5 Pro Preview 1");
609
- }
610
- const gemini25ProPreview2 = await PsAiModel.findOne({
611
- where: { name: "Gemini 2.5 Pro Preview 2" },
573
+ const gemini25Pro = await PsAiModel.findOne({
574
+ where: { name: "Gemini 2.5 Pro" },
612
575
  });
613
576
  const gemini25ProConfig = {
614
577
  type: PsAiModelType.TextReasoning,
@@ -624,14 +587,14 @@ export class NewAiModelSetup {
624
587
  longContextCostOutTokensPerMillion: 15,
625
588
  currency: "USD",
626
589
  },
627
- model: "gemini-2.5-pro-preview-05-06",
590
+ model: "gemini-2.5-pro",
628
591
  active: true,
629
592
  maxTokensOut: 100000,
630
593
  defaultTemperature: 0.0
631
594
  };
632
- if (!gemini25ProPreview2) {
595
+ if (!gemini25Pro) {
633
596
  await PsAiModel.create({
634
- name: "Gemini 2.5 Pro Preview 2",
597
+ name: "Gemini 2.5 Pro",
635
598
  organization_id: 1,
636
599
  user_id: userId,
637
600
  configuration: gemini25ProConfig,
@@ -639,48 +602,11 @@ export class NewAiModelSetup {
639
602
  console.log("Created Google model: Gemini 2.5 Pro");
640
603
  }
641
604
  else {
642
- gemini25ProPreview2.set("configuration", gemini25ProConfig);
643
- gemini25ProPreview2.changed("configuration", true);
644
- await gemini25ProPreview2.save();
605
+ gemini25Pro.set("configuration", gemini25ProConfig);
606
+ gemini25Pro.changed("configuration", true);
607
+ await gemini25Pro.save();
645
608
  console.log("Google model already exists: Gemini 2.5 Pro");
646
609
  }
647
- const gemini25ProFinalPreview = await PsAiModel.findOne({
648
- where: { name: "Gemini 2.5 Pro Final Preview" },
649
- });
650
- const gemini25ProFinalConfig = {
651
- type: PsAiModelType.TextReasoning,
652
- modelSize: PsAiModelSize.Large,
653
- provider: "google",
654
- prices: {
655
- costInTokensPerMillion: 1.25,
656
- costOutTokensPerMillion: 10,
657
- costInCachedContextTokensPerMillion: 0.875,
658
- longContextTokenThreshold: 200000,
659
- longContextCostInTokensPerMillion: 2.5,
660
- longContextCostInCachedContextTokensPerMillion: 1.75,
661
- longContextCostOutTokensPerMillion: 15,
662
- currency: "USD",
663
- },
664
- model: "gemini-2.5-pro-preview-06-05",
665
- active: true,
666
- maxTokensOut: 100000,
667
- defaultTemperature: 0.0,
668
- };
669
- if (!gemini25ProFinalPreview) {
670
- await PsAiModel.create({
671
- name: "Gemini 2.5 Pro Final Preview",
672
- organization_id: 1,
673
- user_id: userId,
674
- configuration: gemini25ProFinalConfig,
675
- });
676
- console.log("Created Google model: Gemini 2.5 Pro Final Preview");
677
- }
678
- else {
679
- gemini25ProFinalPreview.set("configuration", gemini25ProFinalConfig);
680
- gemini25ProFinalPreview.changed("configuration", true);
681
- await gemini25ProFinalPreview.save();
682
- console.log("Google model already exists: Gemini 2.5 Pro Final Preview");
683
- }
684
610
  const gemini25FlashPreview1 = await PsAiModel.findOne({
685
611
  where: { name: "Gemini 2.5 Flash Preview 1" },
686
612
  });
@@ -858,9 +784,7 @@ export class NewAiModelSetup {
858
784
  { name: "Gemini 1.5 Pro 2", envKey: "GEMINI_API_KEY" },
859
785
  { name: "Gemini 1.5 Flash 2", envKey: "GEMINI_API_KEY" },
860
786
  { name: "Gemini 2.0 Flash", envKey: "GEMINI_API_KEY" },
861
- { name: "Gemini 2.5 Pro Preview 1", envKey: "GEMINI_API_KEY" },
862
- { name: "Gemini 2.5 Pro Preview 2", envKey: "GEMINI_API_KEY" },
863
- { name: "Gemini 2.5 Pro Final Preview", envKey: "GEMINI_API_KEY" },
787
+ { name: "Gemini 2.5 Pro", envKey: "GEMINI_API_KEY" },
864
788
  { name: "Gemini 2.5 Flash Preview 1", envKey: "GEMINI_API_KEY" },
865
789
  { name: "Gemini 2.5 Flash Preview", envKey: "GEMINI_API_KEY" },
866
790
  { name: "o1 24", envKey: "OPENAI_API_KEY" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yrpri/api",
3
- "version": "9.0.138",
3
+ "version": "9.0.139",
4
4
  "license": "MIT",
5
5
  "author": "Robert Bjarnason & Citizens Foundation",
6
6
  "repository": {
@@ -75,15 +75,15 @@ import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
75
75
  parent_agent_id: topLevelAgent.id,
76
76
  configuration: {},
77
77
  });
78
- // Add Gemini 2.5 Pro Preview 2 model
78
+ // Add Gemini 2.5 Pro model
79
79
  const geminiReasoning = await PsAiModel.findOne({
80
- where: { name: "Gemini 2.5 Pro Preview 2" },
80
+ where: { name: "Gemini 2.5 Pro" },
81
81
  });
82
82
  if (geminiReasoning) {
83
83
  await psAgent.addAiModel(geminiReasoning);
84
84
  }
85
85
  else {
86
- throw new Error("Gemini 2.5 Pro Preview 2 model not found");
86
+ throw new Error("Gemini 2.5 Pro model not found");
87
87
  }
88
88
  // Add Gemini 2.0 Flash model
89
89
  const geminiFlash = await PsAiModel.findOne({