@axiom-lattice/pg-stores 2.0.6 → 2.0.8

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/dist/index.mjs CHANGED
@@ -4015,6 +4015,26 @@ var enforceUniqueEvalProjectName = {
4015
4015
  `);
4016
4016
  }
4017
4017
  };
4018
+ var addTaskIdToEvalRuns = {
4019
+ version: 164,
4020
+ name: "add_task_id_to_eval_runs",
4021
+ up: async (client) => {
4022
+ await client.query(`
4023
+ ALTER TABLE lattice_eval_runs
4024
+ ADD COLUMN IF NOT EXISTS task_id TEXT
4025
+ `);
4026
+ await client.query(`
4027
+ CREATE INDEX IF NOT EXISTS idx_lattice_eval_runs_task_id
4028
+ ON lattice_eval_runs(task_id)
4029
+ `);
4030
+ },
4031
+ down: async (client) => {
4032
+ await client.query(`DROP INDEX IF EXISTS idx_lattice_eval_runs_task_id`);
4033
+ await client.query(`
4034
+ ALTER TABLE lattice_eval_runs DROP COLUMN IF EXISTS task_id
4035
+ `);
4036
+ }
4037
+ };
4018
4038
  var evalMigrations = [
4019
4039
  createEvalProjectsTable,
4020
4040
  createEvalSuitesTable,
@@ -4025,7 +4045,8 @@ var evalMigrations = [
4025
4045
  addEnvToEvalRuns,
4026
4046
  addInterruptColumnsToEval,
4027
4047
  addInterruptPolicyToEvalCases,
4028
- enforceUniqueEvalProjectName
4048
+ enforceUniqueEvalProjectName,
4049
+ addTaskIdToEvalRuns
4029
4050
  ];
4030
4051
 
4031
4052
  // src/stores/PostgreSQLEvalStore.ts
@@ -4153,6 +4174,7 @@ var PostgreSQLEvalStore = class {
4153
4174
  holdout: row.holdout,
4154
4175
  envProjectId: row.env_project_id,
4155
4176
  envWorkspaceId: row.env_workspace_id,
4177
+ taskId: row.task_id,
4156
4178
  createdAt: new Date(row.created_at),
4157
4179
  startedAt: row.started_at ? new Date(row.started_at) : void 0,
4158
4180
  completedAt: row.completed_at ? new Date(row.completed_at) : void 0
@@ -4520,7 +4542,7 @@ var PostgreSQLEvalStore = class {
4520
4542
  `SELECT id, project_id, tenant_id,
4521
4543
  status, concurrency, total_cases,
4522
4544
  passed_cases, failed_cases, interrupted_cases, avg_score,
4523
- error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at
4545
+ error, holdout, env_project_id, env_workspace_id, task_id, created_at, started_at, completed_at
4524
4546
  FROM lattice_eval_runs
4525
4547
  WHERE ${conditions.join(" AND ")}
4526
4548
  ORDER BY created_at DESC`,
@@ -4535,7 +4557,7 @@ var PostgreSQLEvalStore = class {
4535
4557
  `SELECT id, project_id, tenant_id,
4536
4558
  status, concurrency, total_cases,
4537
4559
  passed_cases, failed_cases, interrupted_cases, avg_score,
4538
- error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at
4560
+ error, holdout, env_project_id, env_workspace_id, task_id, created_at, started_at, completed_at
4539
4561
  FROM lattice_eval_runs
4540
4562
  WHERE id = $1 AND tenant_id = $2`,
4541
4563
  [id, tenantId]
@@ -4548,12 +4570,12 @@ var PostgreSQLEvalStore = class {
4548
4570
  const actualId = id || uuidv4();
4549
4571
  const { rows } = await this.pool.query(
4550
4572
  `INSERT INTO lattice_eval_runs
4551
- (id, project_id, tenant_id, status, concurrency, total_cases, passed_cases, failed_cases, avg_score, holdout, env_project_id, env_workspace_id, started_at)
4552
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
4573
+ (id, project_id, tenant_id, status, concurrency, total_cases, passed_cases, failed_cases, avg_score, holdout, env_project_id, env_workspace_id, task_id, started_at)
4574
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
4553
4575
  RETURNING id, project_id, tenant_id,
4554
4576
  status, concurrency, total_cases,
4555
4577
  passed_cases, failed_cases, interrupted_cases, avg_score,
4556
- error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at`,
4578
+ error, holdout, env_project_id, env_workspace_id, task_id, created_at, started_at, completed_at`,
4557
4579
  [
4558
4580
  actualId,
4559
4581
  projectId,
@@ -4567,6 +4589,7 @@ var PostgreSQLEvalStore = class {
4567
4589
  data.holdout ?? false,
4568
4590
  data.envProjectId || null,
4569
4591
  data.envWorkspaceId || null,
4592
+ data.taskId || null,
4570
4593
  /* @__PURE__ */ new Date()
4571
4594
  ]
4572
4595
  );
@@ -4614,7 +4637,7 @@ var PostgreSQLEvalStore = class {
4614
4637
  RETURNING id, project_id, tenant_id,
4615
4638
  status, concurrency, total_cases,
4616
4639
  passed_cases, failed_cases, interrupted_cases, avg_score,
4617
- error, holdout, env_project_id, env_workspace_id, created_at, started_at, completed_at`,
4640
+ error, holdout, env_project_id, env_workspace_id, task_id, created_at, started_at, completed_at`,
4618
4641
  vals
4619
4642
  );
4620
4643
  return rows.length ? this.mapRowToRun(rows[0]) : null;
@@ -6570,9 +6593,40 @@ var addTaskProjectFieldsMigration = {
6570
6593
  `);
6571
6594
  }
6572
6595
  };
6596
+ var addFilesToTasks = {
6597
+ version: 141,
6598
+ name: "add_files_to_tasks",
6599
+ up: async (client) => {
6600
+ await client.query(`
6601
+ ALTER TABLE lattice_tasks
6602
+ ADD COLUMN IF NOT EXISTS files JSONB
6603
+ `);
6604
+ },
6605
+ down: async (client) => {
6606
+ await client.query(`
6607
+ ALTER TABLE lattice_tasks DROP COLUMN IF EXISTS files
6608
+ `);
6609
+ }
6610
+ };
6611
+ var taskMigrations = [
6612
+ createTasksTable,
6613
+ addTaskFieldsMigration,
6614
+ addTaskProjectFieldsMigration,
6615
+ addFilesToTasks
6616
+ ];
6573
6617
 
6574
6618
  // src/stores/PostgreSQLTaskStore.ts
6575
6619
  import { v4 as uuidv42 } from "uuid";
6620
+ function parseTaskFiles(raw) {
6621
+ if (!raw) return void 0;
6622
+ try {
6623
+ const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
6624
+ if (!Array.isArray(parsed)) return void 0;
6625
+ return parsed;
6626
+ } catch {
6627
+ return void 0;
6628
+ }
6629
+ }
6576
6630
  function mapRowToTask(row) {
6577
6631
  return {
6578
6632
  id: row.id,
@@ -6594,6 +6648,7 @@ function mapRowToTask(row) {
6594
6648
  failureReason: row.failure_reason ?? void 0,
6595
6649
  workspaceId: row.workspace_id ?? void 0,
6596
6650
  projectId: row.project_id ?? void 0,
6651
+ files: parseTaskFiles(row.files),
6597
6652
  createdAt: new Date(row.created_at),
6598
6653
  updatedAt: new Date(row.updated_at)
6599
6654
  };
@@ -6620,6 +6675,7 @@ var PostgreSQLTaskStore = class {
6620
6675
  this.migrationManager.register(createTasksTable);
6621
6676
  this.migrationManager.register(addTaskFieldsMigration);
6622
6677
  this.migrationManager.register(addTaskProjectFieldsMigration);
6678
+ this.migrationManager.register(addFilesToTasks);
6623
6679
  if (options.autoMigrate !== false) {
6624
6680
  this.initialize().catch((error) => {
6625
6681
  console.error("Failed to initialize PostgreSQLTaskStore:", error);
@@ -6649,8 +6705,8 @@ var PostgreSQLTaskStore = class {
6649
6705
  const id = uuidv42();
6650
6706
  const now = (/* @__PURE__ */ new Date()).toISOString();
6651
6707
  await this.pool.query(
6652
- `INSERT INTO lattice_tasks (id, tenant_id, owner_type, owner_id, title, description, status, priority, due_date, metadata, parent_id, source_id, context, require_review, dependencies, result, failure_reason, workspace_id, project_id, created_at, updated_at)
6653
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)`,
6708
+ `INSERT INTO lattice_tasks (id, tenant_id, owner_type, owner_id, title, description, status, priority, due_date, metadata, parent_id, source_id, context, require_review, dependencies, result, failure_reason, workspace_id, project_id, files, created_at, updated_at)
6709
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22)`,
6654
6710
  [
6655
6711
  id,
6656
6712
  params.tenantId,
@@ -6671,6 +6727,7 @@ var PostgreSQLTaskStore = class {
6671
6727
  params.failureReason ?? null,
6672
6728
  params.workspaceId || null,
6673
6729
  params.projectId || null,
6730
+ params.files ? JSON.stringify(params.files) : null,
6674
6731
  now,
6675
6732
  now
6676
6733
  ]
@@ -6775,6 +6832,10 @@ var PostgreSQLTaskStore = class {
6775
6832
  setClauses.push(`metadata = $${paramIndex++}`);
6776
6833
  params.push(JSON.stringify(updates.metadata));
6777
6834
  }
6835
+ if (updates.files !== void 0) {
6836
+ setClauses.push(`files = $${paramIndex++}`);
6837
+ params.push(JSON.stringify(updates.files));
6838
+ }
6778
6839
  if (updates.parentId !== void 0) {
6779
6840
  setClauses.push(`parent_id = $${paramIndex++}`);
6780
6841
  params.push(updates.parentId);
@@ -7954,14 +8015,14 @@ async function createPgStoreConfig(connectionString) {
7954
8015
  mm.register(createA2AApiKeysTable);
7955
8016
  mm.register(addWorkspaceProjectToQueue);
7956
8017
  mm.register(addAssistantOwnerUserId);
7957
- mm.register(createTasksTable);
8018
+ for (const m of taskMigrations) {
8019
+ mm.register(m);
8020
+ }
7958
8021
  mm.register(createMenuItemsTable);
7959
8022
  mm.register(createSharedResourcesTable);
7960
8023
  mm.register(addFileContentType);
7961
8024
  mm.register(createCollectionsTable);
7962
- mm.register(addTaskFieldsMigration);
7963
8025
  mm.register(createTaskWorkItemsMigration);
7964
- mm.register(addTaskProjectFieldsMigration);
7965
8026
  mm.register(addWorkItemProjectFieldsMigration);
7966
8027
  mm.register(createConnectionConfigsTable);
7967
8028
  mm.register(addWorkflowRunsTenantStatusUpdatedIndex);
@@ -8585,6 +8646,7 @@ export {
8585
8646
  addScheduleTenantId,
8586
8647
  addSkillTenantId,
8587
8648
  addStepThreadId,
8649
+ addTaskIdToEvalRuns,
8588
8650
  addThreadTenantId,
8589
8651
  addWorkflowRunsTenantStatusUpdatedIndex,
8590
8652
  alterChannelInstallationsTable,