@axiom-lattice/local-stores 2.0.7 → 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
@@ -1942,6 +1942,7 @@ CREATE TABLE IF NOT EXISTS lt_eval_runs (
1942
1942
  holdout INTEGER NOT NULL DEFAULT 0,
1943
1943
  env_project_id TEXT,
1944
1944
  env_workspace_id TEXT,
1945
+ task_id TEXT,
1945
1946
  created_at TEXT NOT NULL,
1946
1947
  started_at TEXT,
1947
1948
  completed_at TEXT,
@@ -1996,6 +1997,7 @@ var LocalEvalStore = class {
1996
1997
  this.ensureColumn("lt_eval_runs", "interrupted_cases", "interrupted_cases INTEGER NOT NULL DEFAULT 0");
1997
1998
  this.ensureColumn("lt_eval_run_results", "interrupted", "interrupted INTEGER NOT NULL DEFAULT 0");
1998
1999
  this.ensureColumn("lt_eval_cases", "interrupt_policy", "interrupt_policy TEXT");
2000
+ this.ensureColumn("lt_eval_runs", "task_id", "task_id TEXT");
1999
2001
  this.db.exec(`
2000
2002
  UPDATE lt_eval_suites
2001
2003
  SET project_id = (
@@ -2297,9 +2299,9 @@ var LocalEvalStore = class {
2297
2299
  async createRun(tenantId, projectId, id, data) {
2298
2300
  const actualId = id || randomUUID();
2299
2301
  this.db.prepare(
2300
- `INSERT INTO lt_eval_runs (id, project_id, tenant_id, status, concurrency, total_cases, passed_cases, failed_cases, avg_score, holdout, env_project_id, env_workspace_id, created_at)
2301
- VALUES (?, ?, ?, 'running', ?, ?, 0, 0, 0, ?, ?, ?, ?)`
2302
- ).run(actualId, projectId, tenantId, data.concurrency, data.totalCases, data.holdout ? 1 : 0, data.envProjectId || null, data.envWorkspaceId || null, nowISO());
2302
+ `INSERT INTO lt_eval_runs (id, project_id, tenant_id, status, concurrency, total_cases, passed_cases, failed_cases, avg_score, holdout, env_project_id, env_workspace_id, task_id, created_at)
2303
+ VALUES (?, ?, ?, 'running', ?, ?, 0, 0, 0, ?, ?, ?, ?, ?)`
2304
+ ).run(actualId, projectId, tenantId, data.concurrency, data.totalCases, data.holdout ? 1 : 0, data.envProjectId || null, data.envWorkspaceId || null, data.taskId || null, nowISO());
2303
2305
  return await this.getRunById(tenantId, actualId);
2304
2306
  }
2305
2307
  async updateRunStatus(tenantId, id, updates) {
@@ -2523,6 +2525,7 @@ var LocalEvalStore = class {
2523
2525
  holdout: row.holdout ? Boolean(row.holdout) : void 0,
2524
2526
  envProjectId: row.env_project_id,
2525
2527
  envWorkspaceId: row.env_workspace_id,
2528
+ taskId: row.task_id,
2526
2529
  createdAt: parseISO(row.created_at),
2527
2530
  startedAt: row.started_at ? parseISO(row.started_at) : void 0,
2528
2531
  completedAt: row.completed_at ? parseISO(row.completed_at) : void 0
@@ -3670,11 +3673,22 @@ CREATE TABLE IF NOT EXISTS lt_tasks (
3670
3673
  failure_reason TEXT,
3671
3674
  workspace_id TEXT,
3672
3675
  project_id TEXT,
3676
+ files TEXT,
3673
3677
  created_at TEXT NOT NULL,
3674
3678
  updated_at TEXT NOT NULL,
3675
3679
  PRIMARY KEY (tenant_id, id)
3676
3680
  );
3677
3681
  `;
3682
+ function parseTaskFiles(raw) {
3683
+ if (!raw) return void 0;
3684
+ try {
3685
+ const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
3686
+ if (!Array.isArray(parsed)) return void 0;
3687
+ return parsed;
3688
+ } catch {
3689
+ return void 0;
3690
+ }
3691
+ }
3678
3692
  function mapRowToTask2(row) {
3679
3693
  return {
3680
3694
  id: row.id,
@@ -3696,6 +3710,7 @@ function mapRowToTask2(row) {
3696
3710
  failureReason: row.failure_reason || void 0,
3697
3711
  workspaceId: row.workspace_id ?? void 0,
3698
3712
  projectId: row.project_id ?? void 0,
3713
+ files: parseTaskFiles(row.files),
3699
3714
  createdAt: parseISO(row.created_at),
3700
3715
  updatedAt: parseISO(row.updated_at)
3701
3716
  };
@@ -3704,18 +3719,26 @@ var LocalTaskStore = class {
3704
3719
  constructor(db) {
3705
3720
  this.db = db;
3706
3721
  ensureTable(db, DDL20);
3707
- this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN require_review INTEGER DEFAULT 0;`);
3708
- this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN dependencies TEXT;`);
3709
- this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN result TEXT;`);
3710
- this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN failure_reason TEXT;`);
3711
- this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN workspace_id TEXT;`);
3712
- this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN project_id TEXT;`);
3722
+ this.ensureColumn("lt_tasks", "require_review", "require_review INTEGER DEFAULT 0");
3723
+ this.ensureColumn("lt_tasks", "dependencies", "dependencies TEXT");
3724
+ this.ensureColumn("lt_tasks", "result", "result TEXT");
3725
+ this.ensureColumn("lt_tasks", "failure_reason", "failure_reason TEXT");
3726
+ this.ensureColumn("lt_tasks", "workspace_id", "workspace_id TEXT");
3727
+ this.ensureColumn("lt_tasks", "project_id", "project_id TEXT");
3728
+ this.ensureColumn("lt_tasks", "files", "files TEXT");
3729
+ }
3730
+ /** Add a column if it does not exist (SQLite version compatible). */
3731
+ ensureColumn(table, column, ddl) {
3732
+ const cols = this.db.prepare(`PRAGMA table_info(${table})`).all();
3733
+ if (!cols.some((c) => c.name === column)) {
3734
+ this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${ddl}`);
3735
+ }
3713
3736
  }
3714
3737
  async create(params) {
3715
3738
  const id = randomUUID5();
3716
3739
  const now = nowISO();
3717
3740
  this.db.prepare(
3718
- `INSERT INTO lt_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)
3741
+ `INSERT INTO lt_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)
3719
3742
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
3720
3743
  ).run(
3721
3744
  id,
@@ -3737,6 +3760,7 @@ var LocalTaskStore = class {
3737
3760
  params.failureReason || null,
3738
3761
  params.workspaceId || null,
3739
3762
  params.projectId || null,
3763
+ params.files ? JSON.stringify(params.files) : null,
3740
3764
  now,
3741
3765
  now
3742
3766
  );
@@ -3789,8 +3813,14 @@ var LocalTaskStore = class {
3789
3813
  for (const [key, value] of Object.entries(filter.metadata)) {
3790
3814
  const safeKey = key.replace(/[^a-zA-Z0-9_]/g, "");
3791
3815
  if (safeKey) {
3792
- conditions.push(`json_extract(metadata, '$.${safeKey}') = ?`);
3793
- params.push(String(value));
3816
+ const strVal = String(value);
3817
+ if (strVal === "true" || strVal === "false") {
3818
+ conditions.push(`(json_extract(metadata, '$.${safeKey}') = ? OR json_extract(metadata, '$.${safeKey}') = ?)`);
3819
+ params.push(strVal, strVal === "true" ? 1 : 0);
3820
+ } else {
3821
+ conditions.push(`json_extract(metadata, '$.${safeKey}') = ?`);
3822
+ params.push(strVal);
3823
+ }
3794
3824
  }
3795
3825
  }
3796
3826
  }
@@ -3876,6 +3906,10 @@ var LocalTaskStore = class {
3876
3906
  setClauses.push("project_id = ?");
3877
3907
  values.push(updates.projectId);
3878
3908
  }
3909
+ if (updates.files !== void 0) {
3910
+ setClauses.push("files = ?");
3911
+ values.push(JSON.stringify(updates.files));
3912
+ }
3879
3913
  if (setClauses.length === 1) return existing;
3880
3914
  values.push(tenantId, id);
3881
3915
  this.db.prepare(