@bpinhosilva/agent-orchestrator 1.0.0-alpha.28 → 1.0.0-alpha.29

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/agents/default-provider-models.d.ts +11 -0
  3. package/dist/agents/default-provider-models.js +17 -0
  4. package/dist/agents/implementations/claude.agent.js +2 -1
  5. package/dist/agents/implementations/gemini.agent.js +2 -1
  6. package/dist/database/migration-sql.utils.d.ts +2 -0
  7. package/dist/database/migration-sql.utils.js +11 -0
  8. package/dist/migrations/1775266979821-InitialSchema.d.ts +1 -0
  9. package/dist/migrations/1775266979821-InitialSchema.js +46 -204
  10. package/dist/migrations/1775268200000-SeedDefaultProvidersAndModels.d.ts +8 -0
  11. package/dist/migrations/1775268200000-SeedDefaultProvidersAndModels.js +45 -0
  12. package/dist/migrations/1775269500000-BackfillDefaultModelProviderIds.d.ts +9 -0
  13. package/dist/migrations/1775269500000-BackfillDefaultModelProviderIds.js +51 -0
  14. package/dist/ui/assets/AgentFleet-BK16qSVb.js +1 -0
  15. package/dist/ui/assets/{ConfirmDialog-C1bkNgZT.js → ConfirmDialog-CAb4bA6D.js} +2 -2
  16. package/dist/ui/assets/Profile-CR2v0N6L.js +1 -0
  17. package/dist/ui/assets/{ProjectDetail-U4T3kwT6.js → ProjectDetail-KyqWvAT1.js} +1 -1
  18. package/dist/ui/assets/Providers-CUSKu0A6.js +1 -0
  19. package/dist/ui/assets/Scheduler-DLC1PTRB.js +1 -0
  20. package/dist/ui/assets/{TaskDetail-CEKuDv4W.js → TaskDetail-O6ZsA0nQ.js} +1 -1
  21. package/dist/ui/assets/{TaskManager-vYV5vdM4.js → TaskManager-CDN6O6Yh.js} +2 -2
  22. package/dist/ui/assets/index-BfqRKMgT.css +2 -0
  23. package/dist/ui/assets/index-tztXTZhU.js +2 -0
  24. package/dist/ui/assets/providers-CVpZdX9Z.js +1 -0
  25. package/dist/ui/index.html +2 -2
  26. package/package.json +1 -1
  27. package/dist/ui/assets/AgentFleet-2bUM5tS8.js +0 -1
  28. package/dist/ui/assets/Profile-GA-ikEkL.js +0 -1
  29. package/dist/ui/assets/Providers-Dr8fFIru.js +0 -1
  30. package/dist/ui/assets/Scheduler-D1seGplm.js +0 -1
  31. package/dist/ui/assets/index-CVlXsOAm.js +0 -2
  32. package/dist/ui/assets/index-CoqfjJsB.css +0 -2
  33. package/dist/ui/assets/providers-_o5m2NEh.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.0.0-alpha.29](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.28...v1.0.0-alpha.29) (2026-04-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * **migrations:** add seed and backfill migrations ([5991146](https://github.com/bpinhosilva/agent-orchestrator/commit/5991146cbb3bc971bddf73295dcf7dbd3e2b74e4))
7
+
1
8
  # [1.0.0-alpha.28](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.27...v1.0.0-alpha.28) (2026-04-04)
2
9
 
3
10
 
@@ -0,0 +1,11 @@
1
+ export declare const DEFAULT_PROVIDER_MODELS: readonly [{
2
+ readonly providerName: "google";
3
+ readonly models: readonly ["gemini-2.5-flash-lite", "gemini-2.5-flash-image"];
4
+ }, {
5
+ readonly providerName: "anthropic";
6
+ readonly models: readonly ["claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5"];
7
+ }];
8
+ export declare const DEFAULT_MODEL_BY_PROVIDER: {
9
+ readonly google: "gemini-2.5-flash-lite";
10
+ readonly anthropic: "claude-opus-4-6";
11
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_MODEL_BY_PROVIDER = exports.DEFAULT_PROVIDER_MODELS = void 0;
4
+ exports.DEFAULT_PROVIDER_MODELS = [
5
+ {
6
+ providerName: 'google',
7
+ models: ['gemini-2.5-flash-lite', 'gemini-2.5-flash-image'],
8
+ },
9
+ {
10
+ providerName: 'anthropic',
11
+ models: ['claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5'],
12
+ },
13
+ ];
14
+ exports.DEFAULT_MODEL_BY_PROVIDER = {
15
+ google: exports.DEFAULT_PROVIDER_MODELS[0].models[0],
16
+ anthropic: exports.DEFAULT_PROVIDER_MODELS[1].models[0],
17
+ };
@@ -17,6 +17,7 @@ exports.ClaudeAgent = void 0;
17
17
  const claude_agent_sdk_1 = require("@anthropic-ai/claude-agent-sdk");
18
18
  const common_1 = require("@nestjs/common");
19
19
  const config_1 = require("@nestjs/config");
20
+ const default_provider_models_1 = require("../default-provider-models");
20
21
  const agent_registry_1 = require("../registry/agent.registry");
21
22
  let ClaudeAgent = ClaudeAgent_1 = class ClaudeAgent {
22
23
  configService;
@@ -27,7 +28,7 @@ let ClaudeAgent = ClaudeAgent_1 = class ClaudeAgent {
27
28
  role;
28
29
  provider = 'anthropic';
29
30
  model;
30
- constructor(configService, model = 'claude-opus-4-6') {
31
+ constructor(configService, model = default_provider_models_1.DEFAULT_MODEL_BY_PROVIDER.anthropic) {
31
32
  this.configService = configService;
32
33
  this.model = model;
33
34
  }
@@ -17,6 +17,7 @@ exports.GeminiAgent = void 0;
17
17
  const genai_1 = require("@google/genai");
18
18
  const common_1 = require("@nestjs/common");
19
19
  const config_1 = require("@nestjs/config");
20
+ const default_provider_models_1 = require("../default-provider-models");
20
21
  const agent_registry_1 = require("../registry/agent.registry");
21
22
  let GeminiAgent = GeminiAgent_1 = class GeminiAgent {
22
23
  configService;
@@ -29,7 +30,7 @@ let GeminiAgent = GeminiAgent_1 = class GeminiAgent {
29
30
  provider = 'google';
30
31
  model;
31
32
  enableGrounding = true;
32
- constructor(configService, model = 'gemini-2.5-flash-lite') {
33
+ constructor(configService, model = default_provider_models_1.DEFAULT_MODEL_BY_PROVIDER.google) {
33
34
  this.configService = configService;
34
35
  this.model = model;
35
36
  }
@@ -0,0 +1,2 @@
1
+ import { QueryRunner } from 'typeorm';
2
+ export declare function normalizeMigrationSqlForDriver(driverType: QueryRunner['connection']['options']['type'], sql: string): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeMigrationSqlForDriver = normalizeMigrationSqlForDriver;
4
+ function normalizeMigrationSqlForDriver(driverType, sql) {
5
+ if (driverType !== 'postgres') {
6
+ return sql;
7
+ }
8
+ return sql
9
+ .replace(/DEFAULT\s+\(datetime\('now'\)\)/g, 'DEFAULT CURRENT_TIMESTAMP')
10
+ .replace(/\bdatetime\b/g, 'timestamp');
11
+ }
@@ -1,6 +1,7 @@
1
1
  import { MigrationInterface, QueryRunner } from 'typeorm';
2
2
  export declare class InitialSchema1775266979821 implements MigrationInterface {
3
3
  name: string;
4
+ private execute;
4
5
  up(queryRunner: QueryRunner): Promise<void>;
5
6
  down(queryRunner: QueryRunner): Promise<void>;
6
7
  }
@@ -1,215 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InitialSchema1775266979821 = void 0;
4
+ const migration_sql_utils_1 = require("../database/migration-sql.utils");
4
5
  class InitialSchema1775266979821 {
5
6
  name = 'InitialSchema1775266979821';
7
+ async execute(queryRunner, sql) {
8
+ await queryRunner.query((0, migration_sql_utils_1.normalizeMigrationSqlForDriver)(queryRunner.connection.options.type, sql));
9
+ }
6
10
  async up(queryRunner) {
7
- await queryRunner.query(`CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "last_name" varchar NOT NULL, "email" varchar NOT NULL, "password" varchar, "role" varchar NOT NULL DEFAULT ('user'), "avatar" varchar NOT NULL DEFAULT ('avatar-01'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE ("email"))`);
8
- await queryRunner.query(`CREATE TABLE "providers" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_d735474e539e674ba3702eddc44" UNIQUE ("name"))`);
9
- await queryRunner.query(`CREATE TABLE "models" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar)`);
10
- await queryRunner.query(`CREATE INDEX "IDX_2ce64b8d909a4385f26bcd363b" ON "models" ("providerId") `);
11
- await queryRunner.query(`CREATE TABLE "agents" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "systemInstructions" text, "role" text, "status" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar, "modelId" varchar, CONSTRAINT "UQ_1ea6b2ce044724d3254d19ab922" UNIQUE ("name"))`);
12
- await queryRunner.query(`CREATE INDEX "IDX_e927e225423f493fb58dc146cf" ON "agents" ("providerId") `);
13
- await queryRunner.query(`CREATE INDEX "IDX_ef998451a458221d3c409b3792" ON "agents" ("modelId") `);
14
- await queryRunner.query(`CREATE TABLE "project_members" ("id" varchar PRIMARY KEY NOT NULL, "role" varchar NOT NULL DEFAULT ('member'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "projectId" varchar, "userId" varchar, CONSTRAINT "UQ_326b2a901eb18ac24eabc9b0581" UNIQUE ("projectId", "userId"))`);
15
- await queryRunner.query(`CREATE INDEX "IDX_d19892d8f03928e5bfc7313780" ON "project_members" ("projectId") `);
16
- await queryRunner.query(`CREATE INDEX "IDX_08d1346ff91abba68e5a637cfd" ON "project_members" ("userId") `);
17
- await queryRunner.query(`CREATE TABLE "projects" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('planning','active','on_hold','completed','archived') ) NOT NULL DEFAULT ('planning'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "ownerAgentId" varchar)`);
18
- await queryRunner.query(`CREATE INDEX "IDX_6cb68059ab1223de4f03f9a726" ON "projects" ("ownerAgentId") `);
19
- await queryRunner.query(`CREATE INDEX "IDX_a27865a7be17886e3088f4a650" ON "projects" ("status") `);
20
- await queryRunner.query(`CREATE TABLE "task_comments" ("id" varchar PRIMARY KEY NOT NULL, "content" text NOT NULL, "authorType" varchar CHECK( "authorType" IN ('user','agent') ) NOT NULL, "artifacts" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "taskId" varchar NOT NULL, "authorUserId" varchar, "authorAgentId" varchar)`);
21
- await queryRunner.query(`CREATE INDEX "IDX_70a6d3ec52a15e0ff43d4ad353" ON "task_comments" ("authorUserId") `);
22
- await queryRunner.query(`CREATE INDEX "IDX_c2d5d4e5e1e33278318fa6b2b0" ON "task_comments" ("authorAgentId") `);
23
- await queryRunner.query(`CREATE INDEX "IDX_0a2203f600be90963a165d1432" ON "task_comments" ("taskId", "createdAt") `);
24
- await queryRunner.query(`CREATE TABLE "tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('backlog','in-progress','review','done','archived') ) NOT NULL DEFAULT ('backlog'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cost_estimate" float NOT NULL DEFAULT (0), "llm_latency" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar, "projectId" varchar NOT NULL)`);
25
- await queryRunner.query(`CREATE INDEX "IDX_9a16d2c86252529f622fa53f1e" ON "tasks" ("assigneeId") `);
26
- await queryRunner.query(`CREATE INDEX "IDX_7a097552fe4fba313996835706" ON "tasks" ("projectId", "updatedAt") `);
27
- await queryRunner.query(`CREATE INDEX "IDX_4105de371d2c7ca094a830e5cd" ON "tasks" ("projectId", "status", "updatedAt") `);
28
- await queryRunner.query(`CREATE TABLE "recurrent_tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('active','paused','error') ) NOT NULL DEFAULT ('active'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cronExpression" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar NOT NULL, "projectId" varchar)`);
29
- await queryRunner.query(`CREATE INDEX "IDX_0f9f543bd40419122e69aeff00" ON "recurrent_tasks" ("projectId") `);
30
- await queryRunner.query(`CREATE INDEX "IDX_a03520bcf60ada1a46bf548e22" ON "recurrent_tasks" ("status") `);
31
- await queryRunner.query(`CREATE TABLE "recurrent_task_execs" ("id" varchar PRIMARY KEY NOT NULL, "status" varchar CHECK( "status" IN ('running','success','failure','canceled') ) NOT NULL DEFAULT ('running'), "result" text, "latencyMs" integer, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "recurrentTaskId" varchar NOT NULL)`);
32
- await queryRunner.query(`CREATE INDEX "IDX_f5bb7be33ddb87ac0f04807b4a" ON "recurrent_task_execs" ("recurrentTaskId") `);
33
- await queryRunner.query(`CREATE TABLE "artifacts" ("id" varchar PRIMARY KEY NOT NULL, "originalName" varchar NOT NULL, "mimeType" varchar NOT NULL, "filePath" varchar NOT NULL, "metadata" text)`);
34
- await queryRunner.query(`CREATE TABLE "refresh_tokens" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "token" text NOT NULL, "issuedAt" datetime NOT NULL DEFAULT (datetime('now')), "expiresAt" datetime NOT NULL, "absoluteExpiry" datetime NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "revokedAt" datetime)`);
35
- await queryRunner.query(`CREATE INDEX "IDX_070d648bde98d061fd6e9d176d" ON "refresh_tokens" ("userId", "revokedAt") `);
36
- await queryRunner.query(`CREATE INDEX "IDX_ec511b89bba27b211e32a2a12f" ON "refresh_tokens" ("userId", "expiresAt") `);
37
- await queryRunner.query(`DROP INDEX "IDX_2ce64b8d909a4385f26bcd363b"`);
38
- await queryRunner.query(`CREATE TABLE "temporary_models" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar, CONSTRAINT "FK_2ce64b8d909a4385f26bcd363b3" FOREIGN KEY ("providerId") REFERENCES "providers" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
39
- await queryRunner.query(`INSERT INTO "temporary_models"("id", "name", "createdAt", "updatedAt", "providerId") SELECT "id", "name", "createdAt", "updatedAt", "providerId" FROM "models"`);
40
- await queryRunner.query(`DROP TABLE "models"`);
41
- await queryRunner.query(`ALTER TABLE "temporary_models" RENAME TO "models"`);
42
- await queryRunner.query(`CREATE INDEX "IDX_2ce64b8d909a4385f26bcd363b" ON "models" ("providerId") `);
43
- await queryRunner.query(`DROP INDEX "IDX_e927e225423f493fb58dc146cf"`);
44
- await queryRunner.query(`DROP INDEX "IDX_ef998451a458221d3c409b3792"`);
45
- await queryRunner.query(`CREATE TABLE "temporary_agents" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "systemInstructions" text, "role" text, "status" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar, "modelId" varchar, CONSTRAINT "UQ_1ea6b2ce044724d3254d19ab922" UNIQUE ("name"), CONSTRAINT "FK_e927e225423f493fb58dc146cf0" FOREIGN KEY ("providerId") REFERENCES "providers" ("id") ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT "FK_ef998451a458221d3c409b37923" FOREIGN KEY ("modelId") REFERENCES "models" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`);
46
- await queryRunner.query(`INSERT INTO "temporary_agents"("id", "name", "description", "systemInstructions", "role", "status", "createdAt", "updatedAt", "providerId", "modelId") SELECT "id", "name", "description", "systemInstructions", "role", "status", "createdAt", "updatedAt", "providerId", "modelId" FROM "agents"`);
47
- await queryRunner.query(`DROP TABLE "agents"`);
48
- await queryRunner.query(`ALTER TABLE "temporary_agents" RENAME TO "agents"`);
49
- await queryRunner.query(`CREATE INDEX "IDX_e927e225423f493fb58dc146cf" ON "agents" ("providerId") `);
50
- await queryRunner.query(`CREATE INDEX "IDX_ef998451a458221d3c409b3792" ON "agents" ("modelId") `);
51
- await queryRunner.query(`DROP INDEX "IDX_d19892d8f03928e5bfc7313780"`);
52
- await queryRunner.query(`DROP INDEX "IDX_08d1346ff91abba68e5a637cfd"`);
53
- await queryRunner.query(`CREATE TABLE "temporary_project_members" ("id" varchar PRIMARY KEY NOT NULL, "role" varchar NOT NULL DEFAULT ('member'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "projectId" varchar, "userId" varchar, CONSTRAINT "UQ_326b2a901eb18ac24eabc9b0581" UNIQUE ("projectId", "userId"), CONSTRAINT "FK_d19892d8f03928e5bfc7313780c" FOREIGN KEY ("projectId") REFERENCES "projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_08d1346ff91abba68e5a637cfdb" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
54
- await queryRunner.query(`INSERT INTO "temporary_project_members"("id", "role", "createdAt", "projectId", "userId") SELECT "id", "role", "createdAt", "projectId", "userId" FROM "project_members"`);
55
- await queryRunner.query(`DROP TABLE "project_members"`);
56
- await queryRunner.query(`ALTER TABLE "temporary_project_members" RENAME TO "project_members"`);
57
- await queryRunner.query(`CREATE INDEX "IDX_d19892d8f03928e5bfc7313780" ON "project_members" ("projectId") `);
58
- await queryRunner.query(`CREATE INDEX "IDX_08d1346ff91abba68e5a637cfd" ON "project_members" ("userId") `);
59
- await queryRunner.query(`DROP INDEX "IDX_6cb68059ab1223de4f03f9a726"`);
60
- await queryRunner.query(`DROP INDEX "IDX_a27865a7be17886e3088f4a650"`);
61
- await queryRunner.query(`CREATE TABLE "temporary_projects" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('planning','active','on_hold','completed','archived') ) NOT NULL DEFAULT ('planning'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "ownerAgentId" varchar, CONSTRAINT "FK_6cb68059ab1223de4f03f9a7268" FOREIGN KEY ("ownerAgentId") REFERENCES "agents" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`);
62
- await queryRunner.query(`INSERT INTO "temporary_projects"("id", "title", "description", "status", "createdAt", "updatedAt", "ownerAgentId") SELECT "id", "title", "description", "status", "createdAt", "updatedAt", "ownerAgentId" FROM "projects"`);
63
- await queryRunner.query(`DROP TABLE "projects"`);
64
- await queryRunner.query(`ALTER TABLE "temporary_projects" RENAME TO "projects"`);
65
- await queryRunner.query(`CREATE INDEX "IDX_6cb68059ab1223de4f03f9a726" ON "projects" ("ownerAgentId") `);
66
- await queryRunner.query(`CREATE INDEX "IDX_a27865a7be17886e3088f4a650" ON "projects" ("status") `);
67
- await queryRunner.query(`DROP INDEX "IDX_70a6d3ec52a15e0ff43d4ad353"`);
68
- await queryRunner.query(`DROP INDEX "IDX_c2d5d4e5e1e33278318fa6b2b0"`);
69
- await queryRunner.query(`DROP INDEX "IDX_0a2203f600be90963a165d1432"`);
70
- await queryRunner.query(`CREATE TABLE "temporary_task_comments" ("id" varchar PRIMARY KEY NOT NULL, "content" text NOT NULL, "authorType" varchar CHECK( "authorType" IN ('user','agent') ) NOT NULL, "artifacts" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "taskId" varchar NOT NULL, "authorUserId" varchar, "authorAgentId" varchar, CONSTRAINT "FK_ba265816ca1d93f51083e06c520" FOREIGN KEY ("taskId") REFERENCES "tasks" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_70a6d3ec52a15e0ff43d4ad3532" FOREIGN KEY ("authorUserId") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT "FK_c2d5d4e5e1e33278318fa6b2b05" FOREIGN KEY ("authorAgentId") REFERENCES "agents" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`);
71
- await queryRunner.query(`INSERT INTO "temporary_task_comments"("id", "content", "authorType", "artifacts", "createdAt", "updatedAt", "taskId", "authorUserId", "authorAgentId") SELECT "id", "content", "authorType", "artifacts", "createdAt", "updatedAt", "taskId", "authorUserId", "authorAgentId" FROM "task_comments"`);
72
- await queryRunner.query(`DROP TABLE "task_comments"`);
73
- await queryRunner.query(`ALTER TABLE "temporary_task_comments" RENAME TO "task_comments"`);
74
- await queryRunner.query(`CREATE INDEX "IDX_70a6d3ec52a15e0ff43d4ad353" ON "task_comments" ("authorUserId") `);
75
- await queryRunner.query(`CREATE INDEX "IDX_c2d5d4e5e1e33278318fa6b2b0" ON "task_comments" ("authorAgentId") `);
76
- await queryRunner.query(`CREATE INDEX "IDX_0a2203f600be90963a165d1432" ON "task_comments" ("taskId", "createdAt") `);
77
- await queryRunner.query(`DROP INDEX "IDX_9a16d2c86252529f622fa53f1e"`);
78
- await queryRunner.query(`DROP INDEX "IDX_7a097552fe4fba313996835706"`);
79
- await queryRunner.query(`DROP INDEX "IDX_4105de371d2c7ca094a830e5cd"`);
80
- await queryRunner.query(`CREATE TABLE "temporary_tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('backlog','in-progress','review','done','archived') ) NOT NULL DEFAULT ('backlog'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cost_estimate" float NOT NULL DEFAULT (0), "llm_latency" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar, "projectId" varchar NOT NULL, CONSTRAINT "FK_9a16d2c86252529f622fa53f1e3" FOREIGN KEY ("assigneeId") REFERENCES "agents" ("id") ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT "FK_e08fca67ca8966e6b9914bf2956" FOREIGN KEY ("projectId") REFERENCES "projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
81
- await queryRunner.query(`INSERT INTO "temporary_tasks"("id", "title", "description", "status", "priority", "cost_estimate", "llm_latency", "createdAt", "updatedAt", "assigneeId", "projectId") SELECT "id", "title", "description", "status", "priority", "cost_estimate", "llm_latency", "createdAt", "updatedAt", "assigneeId", "projectId" FROM "tasks"`);
82
- await queryRunner.query(`DROP TABLE "tasks"`);
83
- await queryRunner.query(`ALTER TABLE "temporary_tasks" RENAME TO "tasks"`);
84
- await queryRunner.query(`CREATE INDEX "IDX_9a16d2c86252529f622fa53f1e" ON "tasks" ("assigneeId") `);
85
- await queryRunner.query(`CREATE INDEX "IDX_7a097552fe4fba313996835706" ON "tasks" ("projectId", "updatedAt") `);
86
- await queryRunner.query(`CREATE INDEX "IDX_4105de371d2c7ca094a830e5cd" ON "tasks" ("projectId", "status", "updatedAt") `);
87
- await queryRunner.query(`DROP INDEX "IDX_0f9f543bd40419122e69aeff00"`);
88
- await queryRunner.query(`DROP INDEX "IDX_a03520bcf60ada1a46bf548e22"`);
89
- await queryRunner.query(`CREATE TABLE "temporary_recurrent_tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('active','paused','error') ) NOT NULL DEFAULT ('active'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cronExpression" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar NOT NULL, "projectId" varchar, CONSTRAINT "FK_9ec101b70a5f9612b0757d87c83" FOREIGN KEY ("assigneeId") REFERENCES "agents" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_0f9f543bd40419122e69aeff006" FOREIGN KEY ("projectId") REFERENCES "projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
90
- await queryRunner.query(`INSERT INTO "temporary_recurrent_tasks"("id", "title", "description", "status", "priority", "cronExpression", "createdAt", "updatedAt", "assigneeId", "projectId") SELECT "id", "title", "description", "status", "priority", "cronExpression", "createdAt", "updatedAt", "assigneeId", "projectId" FROM "recurrent_tasks"`);
91
- await queryRunner.query(`DROP TABLE "recurrent_tasks"`);
92
- await queryRunner.query(`ALTER TABLE "temporary_recurrent_tasks" RENAME TO "recurrent_tasks"`);
93
- await queryRunner.query(`CREATE INDEX "IDX_0f9f543bd40419122e69aeff00" ON "recurrent_tasks" ("projectId") `);
94
- await queryRunner.query(`CREATE INDEX "IDX_a03520bcf60ada1a46bf548e22" ON "recurrent_tasks" ("status") `);
95
- await queryRunner.query(`DROP INDEX "IDX_f5bb7be33ddb87ac0f04807b4a"`);
96
- await queryRunner.query(`CREATE TABLE "temporary_recurrent_task_execs" ("id" varchar PRIMARY KEY NOT NULL, "status" varchar CHECK( "status" IN ('running','success','failure','canceled') ) NOT NULL DEFAULT ('running'), "result" text, "latencyMs" integer, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "recurrentTaskId" varchar NOT NULL, CONSTRAINT "FK_f5bb7be33ddb87ac0f04807b4ab" FOREIGN KEY ("recurrentTaskId") REFERENCES "recurrent_tasks" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
97
- await queryRunner.query(`INSERT INTO "temporary_recurrent_task_execs"("id", "status", "result", "latencyMs", "createdAt", "updatedAt", "recurrentTaskId") SELECT "id", "status", "result", "latencyMs", "createdAt", "updatedAt", "recurrentTaskId" FROM "recurrent_task_execs"`);
98
- await queryRunner.query(`DROP TABLE "recurrent_task_execs"`);
99
- await queryRunner.query(`ALTER TABLE "temporary_recurrent_task_execs" RENAME TO "recurrent_task_execs"`);
100
- await queryRunner.query(`CREATE INDEX "IDX_f5bb7be33ddb87ac0f04807b4a" ON "recurrent_task_execs" ("recurrentTaskId") `);
101
- await queryRunner.query(`DROP INDEX "IDX_070d648bde98d061fd6e9d176d"`);
102
- await queryRunner.query(`DROP INDEX "IDX_ec511b89bba27b211e32a2a12f"`);
103
- await queryRunner.query(`CREATE TABLE "temporary_refresh_tokens" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "token" text NOT NULL, "issuedAt" datetime NOT NULL DEFAULT (datetime('now')), "expiresAt" datetime NOT NULL, "absoluteExpiry" datetime NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "revokedAt" datetime, CONSTRAINT "FK_610102b60fea1455310ccd299de" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
104
- await queryRunner.query(`INSERT INTO "temporary_refresh_tokens"("id", "userId", "token", "issuedAt", "expiresAt", "absoluteExpiry", "createdAt", "revokedAt") SELECT "id", "userId", "token", "issuedAt", "expiresAt", "absoluteExpiry", "createdAt", "revokedAt" FROM "refresh_tokens"`);
105
- await queryRunner.query(`DROP TABLE "refresh_tokens"`);
106
- await queryRunner.query(`ALTER TABLE "temporary_refresh_tokens" RENAME TO "refresh_tokens"`);
107
- await queryRunner.query(`CREATE INDEX "IDX_070d648bde98d061fd6e9d176d" ON "refresh_tokens" ("userId", "revokedAt") `);
108
- await queryRunner.query(`CREATE INDEX "IDX_ec511b89bba27b211e32a2a12f" ON "refresh_tokens" ("userId", "expiresAt") `);
11
+ await this.execute(queryRunner, `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "last_name" varchar NOT NULL, "email" varchar NOT NULL, "password" varchar, "role" varchar NOT NULL DEFAULT ('user'), "avatar" varchar NOT NULL DEFAULT ('avatar-01'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE ("email"))`);
12
+ await this.execute(queryRunner, `CREATE TABLE "providers" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_d735474e539e674ba3702eddc44" UNIQUE ("name"))`);
13
+ await this.execute(queryRunner, `CREATE TABLE "models" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar, CONSTRAINT "FK_2ce64b8d909a4385f26bcd363b3" FOREIGN KEY ("providerId") REFERENCES "providers" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
14
+ await this.execute(queryRunner, `CREATE INDEX "IDX_2ce64b8d909a4385f26bcd363b" ON "models" ("providerId") `);
15
+ await this.execute(queryRunner, `CREATE TABLE "agents" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "systemInstructions" text, "role" text, "status" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar, "modelId" varchar, CONSTRAINT "UQ_1ea6b2ce044724d3254d19ab922" UNIQUE ("name"), CONSTRAINT "FK_e927e225423f493fb58dc146cf0" FOREIGN KEY ("providerId") REFERENCES "providers" ("id") ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT "FK_ef998451a458221d3c409b37923" FOREIGN KEY ("modelId") REFERENCES "models" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`);
16
+ await this.execute(queryRunner, `CREATE INDEX "IDX_e927e225423f493fb58dc146cf" ON "agents" ("providerId") `);
17
+ await this.execute(queryRunner, `CREATE INDEX "IDX_ef998451a458221d3c409b3792" ON "agents" ("modelId") `);
18
+ await this.execute(queryRunner, `CREATE TABLE "projects" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('planning','active','on_hold','completed','archived') ) NOT NULL DEFAULT ('planning'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "ownerAgentId" varchar, CONSTRAINT "FK_6cb68059ab1223de4f03f9a7268" FOREIGN KEY ("ownerAgentId") REFERENCES "agents" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`);
19
+ await this.execute(queryRunner, `CREATE INDEX "IDX_6cb68059ab1223de4f03f9a726" ON "projects" ("ownerAgentId") `);
20
+ await this.execute(queryRunner, `CREATE INDEX "IDX_a27865a7be17886e3088f4a650" ON "projects" ("status") `);
21
+ await this.execute(queryRunner, `CREATE TABLE "project_members" ("id" varchar PRIMARY KEY NOT NULL, "role" varchar NOT NULL DEFAULT ('member'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "projectId" varchar, "userId" varchar, CONSTRAINT "UQ_326b2a901eb18ac24eabc9b0581" UNIQUE ("projectId", "userId"), CONSTRAINT "FK_d19892d8f03928e5bfc7313780c" FOREIGN KEY ("projectId") REFERENCES "projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_08d1346ff91abba68e5a637cfdb" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
22
+ await this.execute(queryRunner, `CREATE INDEX "IDX_d19892d8f03928e5bfc7313780" ON "project_members" ("projectId") `);
23
+ await this.execute(queryRunner, `CREATE INDEX "IDX_08d1346ff91abba68e5a637cfd" ON "project_members" ("userId") `);
24
+ await this.execute(queryRunner, `CREATE TABLE "tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('backlog','in-progress','review','done','archived') ) NOT NULL DEFAULT ('backlog'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cost_estimate" float NOT NULL DEFAULT (0), "llm_latency" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar, "projectId" varchar NOT NULL, CONSTRAINT "FK_9a16d2c86252529f622fa53f1e3" FOREIGN KEY ("assigneeId") REFERENCES "agents" ("id") ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT "FK_e08fca67ca8966e6b9914bf2956" FOREIGN KEY ("projectId") REFERENCES "projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
25
+ await this.execute(queryRunner, `CREATE INDEX "IDX_9a16d2c86252529f622fa53f1e" ON "tasks" ("assigneeId") `);
26
+ await this.execute(queryRunner, `CREATE INDEX "IDX_7a097552fe4fba313996835706" ON "tasks" ("projectId", "updatedAt") `);
27
+ await this.execute(queryRunner, `CREATE INDEX "IDX_4105de371d2c7ca094a830e5cd" ON "tasks" ("projectId", "status", "updatedAt") `);
28
+ await this.execute(queryRunner, `CREATE TABLE "task_comments" ("id" varchar PRIMARY KEY NOT NULL, "content" text NOT NULL, "authorType" varchar CHECK( "authorType" IN ('user','agent') ) NOT NULL, "artifacts" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "taskId" varchar NOT NULL, "authorUserId" varchar, "authorAgentId" varchar, CONSTRAINT "FK_ba265816ca1d93f51083e06c520" FOREIGN KEY ("taskId") REFERENCES "tasks" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_70a6d3ec52a15e0ff43d4ad3532" FOREIGN KEY ("authorUserId") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT "FK_c2d5d4e5e1e33278318fa6b2b05" FOREIGN KEY ("authorAgentId") REFERENCES "agents" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`);
29
+ await this.execute(queryRunner, `CREATE INDEX "IDX_70a6d3ec52a15e0ff43d4ad353" ON "task_comments" ("authorUserId") `);
30
+ await this.execute(queryRunner, `CREATE INDEX "IDX_c2d5d4e5e1e33278318fa6b2b0" ON "task_comments" ("authorAgentId") `);
31
+ await this.execute(queryRunner, `CREATE INDEX "IDX_0a2203f600be90963a165d1432" ON "task_comments" ("taskId", "createdAt") `);
32
+ await this.execute(queryRunner, `CREATE TABLE "recurrent_tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('active','paused','error') ) NOT NULL DEFAULT ('active'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cronExpression" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar NOT NULL, "projectId" varchar, CONSTRAINT "FK_9ec101b70a5f9612b0757d87c83" FOREIGN KEY ("assigneeId") REFERENCES "agents" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_0f9f543bd40419122e69aeff006" FOREIGN KEY ("projectId") REFERENCES "projects" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
33
+ await this.execute(queryRunner, `CREATE INDEX "IDX_0f9f543bd40419122e69aeff00" ON "recurrent_tasks" ("projectId") `);
34
+ await this.execute(queryRunner, `CREATE INDEX "IDX_a03520bcf60ada1a46bf548e22" ON "recurrent_tasks" ("status") `);
35
+ await this.execute(queryRunner, `CREATE TABLE "recurrent_task_execs" ("id" varchar PRIMARY KEY NOT NULL, "status" varchar CHECK( "status" IN ('running','success','failure','canceled') ) NOT NULL DEFAULT ('running'), "result" text, "latencyMs" integer, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "recurrentTaskId" varchar NOT NULL, CONSTRAINT "FK_f5bb7be33ddb87ac0f04807b4ab" FOREIGN KEY ("recurrentTaskId") REFERENCES "recurrent_tasks" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
36
+ await this.execute(queryRunner, `CREATE INDEX "IDX_f5bb7be33ddb87ac0f04807b4a" ON "recurrent_task_execs" ("recurrentTaskId") `);
37
+ await this.execute(queryRunner, `CREATE TABLE "artifacts" ("id" varchar PRIMARY KEY NOT NULL, "originalName" varchar NOT NULL, "mimeType" varchar NOT NULL, "filePath" varchar NOT NULL, "metadata" text)`);
38
+ await this.execute(queryRunner, `CREATE TABLE "refresh_tokens" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "token" text NOT NULL, "issuedAt" datetime NOT NULL DEFAULT (datetime('now')), "expiresAt" datetime NOT NULL, "absoluteExpiry" datetime NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "revokedAt" datetime, CONSTRAINT "FK_610102b60fea1455310ccd299de" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
39
+ await this.execute(queryRunner, `CREATE INDEX "IDX_070d648bde98d061fd6e9d176d" ON "refresh_tokens" ("userId", "revokedAt") `);
40
+ await this.execute(queryRunner, `CREATE INDEX "IDX_ec511b89bba27b211e32a2a12f" ON "refresh_tokens" ("userId", "expiresAt") `);
109
41
  }
110
42
  async down(queryRunner) {
111
- await queryRunner.query(`DROP INDEX "IDX_ec511b89bba27b211e32a2a12f"`);
112
- await queryRunner.query(`DROP INDEX "IDX_070d648bde98d061fd6e9d176d"`);
113
- await queryRunner.query(`ALTER TABLE "refresh_tokens" RENAME TO "temporary_refresh_tokens"`);
114
- await queryRunner.query(`CREATE TABLE "refresh_tokens" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "token" text NOT NULL, "issuedAt" datetime NOT NULL DEFAULT (datetime('now')), "expiresAt" datetime NOT NULL, "absoluteExpiry" datetime NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "revokedAt" datetime)`);
115
- await queryRunner.query(`INSERT INTO "refresh_tokens"("id", "userId", "token", "issuedAt", "expiresAt", "absoluteExpiry", "createdAt", "revokedAt") SELECT "id", "userId", "token", "issuedAt", "expiresAt", "absoluteExpiry", "createdAt", "revokedAt" FROM "temporary_refresh_tokens"`);
116
- await queryRunner.query(`DROP TABLE "temporary_refresh_tokens"`);
117
- await queryRunner.query(`CREATE INDEX "IDX_ec511b89bba27b211e32a2a12f" ON "refresh_tokens" ("userId", "expiresAt") `);
118
- await queryRunner.query(`CREATE INDEX "IDX_070d648bde98d061fd6e9d176d" ON "refresh_tokens" ("userId", "revokedAt") `);
119
- await queryRunner.query(`DROP INDEX "IDX_f5bb7be33ddb87ac0f04807b4a"`);
120
- await queryRunner.query(`ALTER TABLE "recurrent_task_execs" RENAME TO "temporary_recurrent_task_execs"`);
121
- await queryRunner.query(`CREATE TABLE "recurrent_task_execs" ("id" varchar PRIMARY KEY NOT NULL, "status" varchar CHECK( "status" IN ('running','success','failure','canceled') ) NOT NULL DEFAULT ('running'), "result" text, "latencyMs" integer, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "recurrentTaskId" varchar NOT NULL)`);
122
- await queryRunner.query(`INSERT INTO "recurrent_task_execs"("id", "status", "result", "latencyMs", "createdAt", "updatedAt", "recurrentTaskId") SELECT "id", "status", "result", "latencyMs", "createdAt", "updatedAt", "recurrentTaskId" FROM "temporary_recurrent_task_execs"`);
123
- await queryRunner.query(`DROP TABLE "temporary_recurrent_task_execs"`);
124
- await queryRunner.query(`CREATE INDEX "IDX_f5bb7be33ddb87ac0f04807b4a" ON "recurrent_task_execs" ("recurrentTaskId") `);
125
- await queryRunner.query(`DROP INDEX "IDX_a03520bcf60ada1a46bf548e22"`);
126
- await queryRunner.query(`DROP INDEX "IDX_0f9f543bd40419122e69aeff00"`);
127
- await queryRunner.query(`ALTER TABLE "recurrent_tasks" RENAME TO "temporary_recurrent_tasks"`);
128
- await queryRunner.query(`CREATE TABLE "recurrent_tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('active','paused','error') ) NOT NULL DEFAULT ('active'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cronExpression" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar NOT NULL, "projectId" varchar)`);
129
- await queryRunner.query(`INSERT INTO "recurrent_tasks"("id", "title", "description", "status", "priority", "cronExpression", "createdAt", "updatedAt", "assigneeId", "projectId") SELECT "id", "title", "description", "status", "priority", "cronExpression", "createdAt", "updatedAt", "assigneeId", "projectId" FROM "temporary_recurrent_tasks"`);
130
- await queryRunner.query(`DROP TABLE "temporary_recurrent_tasks"`);
131
- await queryRunner.query(`CREATE INDEX "IDX_a03520bcf60ada1a46bf548e22" ON "recurrent_tasks" ("status") `);
132
- await queryRunner.query(`CREATE INDEX "IDX_0f9f543bd40419122e69aeff00" ON "recurrent_tasks" ("projectId") `);
133
- await queryRunner.query(`DROP INDEX "IDX_4105de371d2c7ca094a830e5cd"`);
134
- await queryRunner.query(`DROP INDEX "IDX_7a097552fe4fba313996835706"`);
135
- await queryRunner.query(`DROP INDEX "IDX_9a16d2c86252529f622fa53f1e"`);
136
- await queryRunner.query(`ALTER TABLE "tasks" RENAME TO "temporary_tasks"`);
137
- await queryRunner.query(`CREATE TABLE "tasks" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('backlog','in-progress','review','done','archived') ) NOT NULL DEFAULT ('backlog'), "priority" varchar CHECK( "priority" IN ('0','1','2','3') ) NOT NULL DEFAULT (2), "cost_estimate" float NOT NULL DEFAULT (0), "llm_latency" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "assigneeId" varchar, "projectId" varchar NOT NULL)`);
138
- await queryRunner.query(`INSERT INTO "tasks"("id", "title", "description", "status", "priority", "cost_estimate", "llm_latency", "createdAt", "updatedAt", "assigneeId", "projectId") SELECT "id", "title", "description", "status", "priority", "cost_estimate", "llm_latency", "createdAt", "updatedAt", "assigneeId", "projectId" FROM "temporary_tasks"`);
139
- await queryRunner.query(`DROP TABLE "temporary_tasks"`);
140
- await queryRunner.query(`CREATE INDEX "IDX_4105de371d2c7ca094a830e5cd" ON "tasks" ("projectId", "status", "updatedAt") `);
141
- await queryRunner.query(`CREATE INDEX "IDX_7a097552fe4fba313996835706" ON "tasks" ("projectId", "updatedAt") `);
142
- await queryRunner.query(`CREATE INDEX "IDX_9a16d2c86252529f622fa53f1e" ON "tasks" ("assigneeId") `);
143
- await queryRunner.query(`DROP INDEX "IDX_0a2203f600be90963a165d1432"`);
144
- await queryRunner.query(`DROP INDEX "IDX_c2d5d4e5e1e33278318fa6b2b0"`);
145
- await queryRunner.query(`DROP INDEX "IDX_70a6d3ec52a15e0ff43d4ad353"`);
146
- await queryRunner.query(`ALTER TABLE "task_comments" RENAME TO "temporary_task_comments"`);
147
- await queryRunner.query(`CREATE TABLE "task_comments" ("id" varchar PRIMARY KEY NOT NULL, "content" text NOT NULL, "authorType" varchar CHECK( "authorType" IN ('user','agent') ) NOT NULL, "artifacts" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "taskId" varchar NOT NULL, "authorUserId" varchar, "authorAgentId" varchar)`);
148
- await queryRunner.query(`INSERT INTO "task_comments"("id", "content", "authorType", "artifacts", "createdAt", "updatedAt", "taskId", "authorUserId", "authorAgentId") SELECT "id", "content", "authorType", "artifacts", "createdAt", "updatedAt", "taskId", "authorUserId", "authorAgentId" FROM "temporary_task_comments"`);
149
- await queryRunner.query(`DROP TABLE "temporary_task_comments"`);
150
- await queryRunner.query(`CREATE INDEX "IDX_0a2203f600be90963a165d1432" ON "task_comments" ("taskId", "createdAt") `);
151
- await queryRunner.query(`CREATE INDEX "IDX_c2d5d4e5e1e33278318fa6b2b0" ON "task_comments" ("authorAgentId") `);
152
- await queryRunner.query(`CREATE INDEX "IDX_70a6d3ec52a15e0ff43d4ad353" ON "task_comments" ("authorUserId") `);
153
- await queryRunner.query(`DROP INDEX "IDX_a27865a7be17886e3088f4a650"`);
154
- await queryRunner.query(`DROP INDEX "IDX_6cb68059ab1223de4f03f9a726"`);
155
- await queryRunner.query(`ALTER TABLE "projects" RENAME TO "temporary_projects"`);
156
- await queryRunner.query(`CREATE TABLE "projects" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text NOT NULL, "status" varchar CHECK( "status" IN ('planning','active','on_hold','completed','archived') ) NOT NULL DEFAULT ('planning'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "ownerAgentId" varchar)`);
157
- await queryRunner.query(`INSERT INTO "projects"("id", "title", "description", "status", "createdAt", "updatedAt", "ownerAgentId") SELECT "id", "title", "description", "status", "createdAt", "updatedAt", "ownerAgentId" FROM "temporary_projects"`);
158
- await queryRunner.query(`DROP TABLE "temporary_projects"`);
159
- await queryRunner.query(`CREATE INDEX "IDX_a27865a7be17886e3088f4a650" ON "projects" ("status") `);
160
- await queryRunner.query(`CREATE INDEX "IDX_6cb68059ab1223de4f03f9a726" ON "projects" ("ownerAgentId") `);
161
- await queryRunner.query(`DROP INDEX "IDX_08d1346ff91abba68e5a637cfd"`);
162
- await queryRunner.query(`DROP INDEX "IDX_d19892d8f03928e5bfc7313780"`);
163
- await queryRunner.query(`ALTER TABLE "project_members" RENAME TO "temporary_project_members"`);
164
- await queryRunner.query(`CREATE TABLE "project_members" ("id" varchar PRIMARY KEY NOT NULL, "role" varchar NOT NULL DEFAULT ('member'), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "projectId" varchar, "userId" varchar, CONSTRAINT "UQ_326b2a901eb18ac24eabc9b0581" UNIQUE ("projectId", "userId"))`);
165
- await queryRunner.query(`INSERT INTO "project_members"("id", "role", "createdAt", "projectId", "userId") SELECT "id", "role", "createdAt", "projectId", "userId" FROM "temporary_project_members"`);
166
- await queryRunner.query(`DROP TABLE "temporary_project_members"`);
167
- await queryRunner.query(`CREATE INDEX "IDX_08d1346ff91abba68e5a637cfd" ON "project_members" ("userId") `);
168
- await queryRunner.query(`CREATE INDEX "IDX_d19892d8f03928e5bfc7313780" ON "project_members" ("projectId") `);
169
- await queryRunner.query(`DROP INDEX "IDX_ef998451a458221d3c409b3792"`);
170
- await queryRunner.query(`DROP INDEX "IDX_e927e225423f493fb58dc146cf"`);
171
- await queryRunner.query(`ALTER TABLE "agents" RENAME TO "temporary_agents"`);
172
- await queryRunner.query(`CREATE TABLE "agents" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "systemInstructions" text, "role" text, "status" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar, "modelId" varchar, CONSTRAINT "UQ_1ea6b2ce044724d3254d19ab922" UNIQUE ("name"))`);
173
- await queryRunner.query(`INSERT INTO "agents"("id", "name", "description", "systemInstructions", "role", "status", "createdAt", "updatedAt", "providerId", "modelId") SELECT "id", "name", "description", "systemInstructions", "role", "status", "createdAt", "updatedAt", "providerId", "modelId" FROM "temporary_agents"`);
174
- await queryRunner.query(`DROP TABLE "temporary_agents"`);
175
- await queryRunner.query(`CREATE INDEX "IDX_ef998451a458221d3c409b3792" ON "agents" ("modelId") `);
176
- await queryRunner.query(`CREATE INDEX "IDX_e927e225423f493fb58dc146cf" ON "agents" ("providerId") `);
177
- await queryRunner.query(`DROP INDEX "IDX_2ce64b8d909a4385f26bcd363b"`);
178
- await queryRunner.query(`ALTER TABLE "models" RENAME TO "temporary_models"`);
179
- await queryRunner.query(`CREATE TABLE "models" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "providerId" varchar)`);
180
- await queryRunner.query(`INSERT INTO "models"("id", "name", "createdAt", "updatedAt", "providerId") SELECT "id", "name", "createdAt", "updatedAt", "providerId" FROM "temporary_models"`);
181
- await queryRunner.query(`DROP TABLE "temporary_models"`);
182
- await queryRunner.query(`CREATE INDEX "IDX_2ce64b8d909a4385f26bcd363b" ON "models" ("providerId") `);
183
- await queryRunner.query(`DROP INDEX "IDX_ec511b89bba27b211e32a2a12f"`);
184
- await queryRunner.query(`DROP INDEX "IDX_070d648bde98d061fd6e9d176d"`);
185
- await queryRunner.query(`DROP TABLE "refresh_tokens"`);
186
- await queryRunner.query(`DROP TABLE "artifacts"`);
187
- await queryRunner.query(`DROP INDEX "IDX_f5bb7be33ddb87ac0f04807b4a"`);
188
- await queryRunner.query(`DROP TABLE "recurrent_task_execs"`);
189
- await queryRunner.query(`DROP INDEX "IDX_a03520bcf60ada1a46bf548e22"`);
190
- await queryRunner.query(`DROP INDEX "IDX_0f9f543bd40419122e69aeff00"`);
191
- await queryRunner.query(`DROP TABLE "recurrent_tasks"`);
192
- await queryRunner.query(`DROP INDEX "IDX_4105de371d2c7ca094a830e5cd"`);
193
- await queryRunner.query(`DROP INDEX "IDX_7a097552fe4fba313996835706"`);
194
- await queryRunner.query(`DROP INDEX "IDX_9a16d2c86252529f622fa53f1e"`);
195
- await queryRunner.query(`DROP TABLE "tasks"`);
196
- await queryRunner.query(`DROP INDEX "IDX_0a2203f600be90963a165d1432"`);
197
- await queryRunner.query(`DROP INDEX "IDX_c2d5d4e5e1e33278318fa6b2b0"`);
198
- await queryRunner.query(`DROP INDEX "IDX_70a6d3ec52a15e0ff43d4ad353"`);
199
- await queryRunner.query(`DROP TABLE "task_comments"`);
200
- await queryRunner.query(`DROP INDEX "IDX_a27865a7be17886e3088f4a650"`);
201
- await queryRunner.query(`DROP INDEX "IDX_6cb68059ab1223de4f03f9a726"`);
202
- await queryRunner.query(`DROP TABLE "projects"`);
203
- await queryRunner.query(`DROP INDEX "IDX_08d1346ff91abba68e5a637cfd"`);
204
- await queryRunner.query(`DROP INDEX "IDX_d19892d8f03928e5bfc7313780"`);
205
- await queryRunner.query(`DROP TABLE "project_members"`);
206
- await queryRunner.query(`DROP INDEX "IDX_ef998451a458221d3c409b3792"`);
207
- await queryRunner.query(`DROP INDEX "IDX_e927e225423f493fb58dc146cf"`);
208
- await queryRunner.query(`DROP TABLE "agents"`);
209
- await queryRunner.query(`DROP INDEX "IDX_2ce64b8d909a4385f26bcd363b"`);
210
- await queryRunner.query(`DROP TABLE "models"`);
211
- await queryRunner.query(`DROP TABLE "providers"`);
212
- await queryRunner.query(`DROP TABLE "users"`);
43
+ await this.execute(queryRunner, `DROP TABLE "refresh_tokens"`);
44
+ await this.execute(queryRunner, `DROP TABLE "artifacts"`);
45
+ await this.execute(queryRunner, `DROP TABLE "recurrent_task_execs"`);
46
+ await this.execute(queryRunner, `DROP TABLE "recurrent_tasks"`);
47
+ await this.execute(queryRunner, `DROP TABLE "task_comments"`);
48
+ await this.execute(queryRunner, `DROP TABLE "tasks"`);
49
+ await this.execute(queryRunner, `DROP TABLE "project_members"`);
50
+ await this.execute(queryRunner, `DROP TABLE "projects"`);
51
+ await this.execute(queryRunner, `DROP TABLE "agents"`);
52
+ await this.execute(queryRunner, `DROP TABLE "models"`);
53
+ await this.execute(queryRunner, `DROP TABLE "providers"`);
54
+ await this.execute(queryRunner, `DROP TABLE "users"`);
213
55
  }
214
56
  }
215
57
  exports.InitialSchema1775266979821 = InitialSchema1775266979821;
@@ -0,0 +1,8 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class SeedDefaultProvidersAndModels1775268200000 implements MigrationInterface {
3
+ name: string;
4
+ private escapeSqlLiteral;
5
+ private getIdRow;
6
+ up(queryRunner: QueryRunner): Promise<void>;
7
+ down(queryRunner: QueryRunner): Promise<void>;
8
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeedDefaultProvidersAndModels1775268200000 = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const default_provider_models_1 = require("../agents/default-provider-models");
6
+ class SeedDefaultProvidersAndModels1775268200000 {
7
+ name = 'SeedDefaultProvidersAndModels1775268200000';
8
+ escapeSqlLiteral(value) {
9
+ return `'${value.replace(/'/g, "''")}'`;
10
+ }
11
+ async getIdRow(queryRunner, sql) {
12
+ const rows = (await queryRunner.query(sql));
13
+ return rows[0] ?? null;
14
+ }
15
+ async up(queryRunner) {
16
+ for (const seed of default_provider_models_1.DEFAULT_PROVIDER_MODELS) {
17
+ const existingProvider = await this.getIdRow(queryRunner, `SELECT "id" FROM "providers" WHERE "name" = ${this.escapeSqlLiteral(seed.providerName)}`);
18
+ const providerId = existingProvider?.id ?? (0, crypto_1.randomUUID)();
19
+ if (!existingProvider) {
20
+ await queryRunner.query(`INSERT INTO "providers" ("id", "name") VALUES (${this.escapeSqlLiteral(providerId)}, ${this.escapeSqlLiteral(seed.providerName)})`);
21
+ }
22
+ for (const modelName of seed.models) {
23
+ const existingModel = await this.getIdRow(queryRunner, `SELECT "id" FROM "models" WHERE "name" = ${this.escapeSqlLiteral(modelName)} AND "providerId" = ${this.escapeSqlLiteral(providerId)}`);
24
+ if (existingModel) {
25
+ continue;
26
+ }
27
+ await queryRunner.query(`INSERT INTO "models" ("id", "name", "providerId") VALUES (${this.escapeSqlLiteral((0, crypto_1.randomUUID)())}, ${this.escapeSqlLiteral(modelName)}, ${this.escapeSqlLiteral(providerId)})`);
28
+ }
29
+ }
30
+ }
31
+ async down(queryRunner) {
32
+ const providerNames = default_provider_models_1.DEFAULT_PROVIDER_MODELS.map((seed) => seed.providerName);
33
+ const modelNames = default_provider_models_1.DEFAULT_PROVIDER_MODELS.flatMap((seed) => seed.models);
34
+ const providerNamesList = providerNames.map((name) => this.escapeSqlLiteral(name));
35
+ const modelNamesList = modelNames.map((name) => this.escapeSqlLiteral(name));
36
+ const providers = (await queryRunner.query(`SELECT "id" FROM "providers" WHERE "name" IN (${providerNamesList.join(', ')})`));
37
+ const providerIds = providers.map((provider) => provider.id);
38
+ const providerIdsList = providerIds.map((id) => this.escapeSqlLiteral(id));
39
+ if (providerIds.length > 0) {
40
+ await queryRunner.query(`DELETE FROM "models" WHERE "providerId" IN (${providerIdsList.join(', ')}) AND "name" IN (${modelNamesList.join(', ')})`);
41
+ }
42
+ await queryRunner.query(`DELETE FROM "providers" WHERE "name" IN (${providerNamesList.join(', ')})`);
43
+ }
44
+ }
45
+ exports.SeedDefaultProvidersAndModels1775268200000 = SeedDefaultProvidersAndModels1775268200000;
@@ -0,0 +1,9 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class BackfillDefaultModelProviderIds1775269500000 implements MigrationInterface {
3
+ name: string;
4
+ private escapeSqlLiteral;
5
+ private isIdRow;
6
+ private getProviderIdsByName;
7
+ up(queryRunner: QueryRunner): Promise<void>;
8
+ down(queryRunner: QueryRunner): Promise<void>;
9
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BackfillDefaultModelProviderIds1775269500000 = void 0;
4
+ const default_provider_models_1 = require("../agents/default-provider-models");
5
+ class BackfillDefaultModelProviderIds1775269500000 {
6
+ name = 'BackfillDefaultModelProviderIds1775269500000';
7
+ escapeSqlLiteral(value) {
8
+ return `'${value.replace(/'/g, "''")}'`;
9
+ }
10
+ isIdRow(row) {
11
+ return (typeof row === 'object' &&
12
+ row !== null &&
13
+ 'id' in row &&
14
+ typeof row.id === 'string');
15
+ }
16
+ async getProviderIdsByName(queryRunner, providerName) {
17
+ const rows = await queryRunner.query(`SELECT "id" FROM "providers" WHERE "name" = ${this.escapeSqlLiteral(providerName)}`);
18
+ if (!Array.isArray(rows)) {
19
+ return [];
20
+ }
21
+ const providerIds = [];
22
+ for (const row of rows) {
23
+ if (this.isIdRow(row)) {
24
+ providerIds.push(row.id);
25
+ }
26
+ }
27
+ return providerIds;
28
+ }
29
+ async up(queryRunner) {
30
+ for (const seed of default_provider_models_1.DEFAULT_PROVIDER_MODELS) {
31
+ const [providerId] = await this.getProviderIdsByName(queryRunner, seed.providerName);
32
+ if (!providerId) {
33
+ continue;
34
+ }
35
+ const modelNames = seed.models.map((modelName) => this.escapeSqlLiteral(modelName));
36
+ await queryRunner.query(`UPDATE "models"
37
+ SET "providerId" = ${this.escapeSqlLiteral(providerId)}
38
+ WHERE "providerId" IS NULL
39
+ AND "name" IN (${modelNames.join(', ')})`);
40
+ }
41
+ }
42
+ async down(queryRunner) {
43
+ const modelNames = default_provider_models_1.DEFAULT_PROVIDER_MODELS
44
+ .flatMap((seed) => seed.models)
45
+ .map((modelName) => this.escapeSqlLiteral(modelName));
46
+ await queryRunner.query(`UPDATE "models"
47
+ SET "providerId" = NULL
48
+ WHERE "name" IN (${modelNames.join(', ')})`);
49
+ }
50
+ }
51
+ exports.BackfillDefaultModelProviderIds1775269500000 = BackfillDefaultModelProviderIds1775269500000;