@axiom-lattice/local-stores 1.0.21 → 1.0.24
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +24 -0
- package/dist/index.d.mts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +162 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/createLocalStoreConfig.ts +2 -0
- package/src/index.ts +1 -0
- package/src/stores/LocalConnectionStore.ts +7 -0
- package/src/stores/LocalEvalStore.ts +8 -0
- package/src/stores/LocalTaskStore.ts +46 -4
- package/src/stores/LocalTaskWorkItemStore.ts +113 -0
package/dist/index.mjs
CHANGED
|
@@ -1156,6 +1156,12 @@ var LocalConnectionStore = class {
|
|
|
1156
1156
|
this.db = db;
|
|
1157
1157
|
ensureTable(db, DDL9);
|
|
1158
1158
|
}
|
|
1159
|
+
async listByTenant(tenantId) {
|
|
1160
|
+
const rows = this.db.prepare(
|
|
1161
|
+
`SELECT * FROM connection_configs WHERE tenant_id = ? ORDER BY created_at`
|
|
1162
|
+
).all(tenantId);
|
|
1163
|
+
return rows.map((r) => this.mapRow(r));
|
|
1164
|
+
}
|
|
1159
1165
|
async listByType(tenantId, type) {
|
|
1160
1166
|
const rows = this.db.prepare(
|
|
1161
1167
|
`SELECT * FROM connection_configs WHERE tenant_id = ? AND type = ? ORDER BY created_at`
|
|
@@ -2347,6 +2353,13 @@ var LocalEvalStore = class {
|
|
|
2347
2353
|
).run(...vals);
|
|
2348
2354
|
return this.getRunResultById(tenantId, id);
|
|
2349
2355
|
}
|
|
2356
|
+
async deleteRunResult(tenantId, id) {
|
|
2357
|
+
const result = this.db.prepare(
|
|
2358
|
+
`DELETE FROM lt_eval_run_results
|
|
2359
|
+
WHERE id = ? AND run_id IN (SELECT id FROM lt_eval_runs WHERE tenant_id = ?)`
|
|
2360
|
+
).run(id, tenantId);
|
|
2361
|
+
return result.changes > 0;
|
|
2362
|
+
}
|
|
2350
2363
|
// -------------------------------------------------------------------------
|
|
2351
2364
|
// Reports
|
|
2352
2365
|
// -------------------------------------------------------------------------
|
|
@@ -3555,6 +3568,12 @@ CREATE TABLE IF NOT EXISTS lt_tasks (
|
|
|
3555
3568
|
parent_id TEXT,
|
|
3556
3569
|
source_id TEXT,
|
|
3557
3570
|
context TEXT,
|
|
3571
|
+
require_review INTEGER DEFAULT 0,
|
|
3572
|
+
dependencies TEXT,
|
|
3573
|
+
result TEXT,
|
|
3574
|
+
failure_reason TEXT,
|
|
3575
|
+
workspace_id TEXT,
|
|
3576
|
+
project_id TEXT,
|
|
3558
3577
|
created_at TEXT NOT NULL,
|
|
3559
3578
|
updated_at TEXT NOT NULL,
|
|
3560
3579
|
PRIMARY KEY (tenant_id, id)
|
|
@@ -3575,6 +3594,12 @@ function mapRowToTask2(row) {
|
|
|
3575
3594
|
parentId: row.parent_id ?? void 0,
|
|
3576
3595
|
sourceId: row.source_id ?? void 0,
|
|
3577
3596
|
context: row.context ? JSON.parse(row.context) : void 0,
|
|
3597
|
+
requireReview: row.require_review === 1 ? true : row.require_review ? true : void 0,
|
|
3598
|
+
dependencies: row.dependencies ? JSON.parse(row.dependencies) : void 0,
|
|
3599
|
+
result: row.result || void 0,
|
|
3600
|
+
failureReason: row.failure_reason || void 0,
|
|
3601
|
+
workspaceId: row.workspace_id ?? void 0,
|
|
3602
|
+
projectId: row.project_id ?? void 0,
|
|
3578
3603
|
createdAt: parseISO(row.created_at),
|
|
3579
3604
|
updatedAt: parseISO(row.updated_at)
|
|
3580
3605
|
};
|
|
@@ -3583,13 +3608,19 @@ var LocalTaskStore = class {
|
|
|
3583
3608
|
constructor(db) {
|
|
3584
3609
|
this.db = db;
|
|
3585
3610
|
ensureTable(db, DDL20);
|
|
3611
|
+
this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN require_review INTEGER DEFAULT 0;`);
|
|
3612
|
+
this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN dependencies TEXT;`);
|
|
3613
|
+
this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN result TEXT;`);
|
|
3614
|
+
this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN failure_reason TEXT;`);
|
|
3615
|
+
this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN workspace_id TEXT;`);
|
|
3616
|
+
this.db.exec(`ALTER TABLE lt_tasks ADD COLUMN project_id TEXT;`);
|
|
3586
3617
|
}
|
|
3587
3618
|
async create(params) {
|
|
3588
3619
|
const id = randomUUID5();
|
|
3589
3620
|
const now = nowISO();
|
|
3590
3621
|
this.db.prepare(
|
|
3591
|
-
`INSERT INTO lt_tasks (id, tenant_id, owner_type, owner_id, title, description, status, priority, due_date, metadata, parent_id, source_id, context, created_at, updated_at)
|
|
3592
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
3622
|
+
`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)
|
|
3623
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
3593
3624
|
).run(
|
|
3594
3625
|
id,
|
|
3595
3626
|
params.tenantId,
|
|
@@ -3604,6 +3635,12 @@ var LocalTaskStore = class {
|
|
|
3604
3635
|
params.parentId || null,
|
|
3605
3636
|
params.sourceId || null,
|
|
3606
3637
|
params.context ? JSON.stringify(params.context) : null,
|
|
3638
|
+
params.requireReview ? 1 : 0,
|
|
3639
|
+
params.dependencies ? JSON.stringify(params.dependencies) : null,
|
|
3640
|
+
params.result || null,
|
|
3641
|
+
params.failureReason || null,
|
|
3642
|
+
params.workspaceId || null,
|
|
3643
|
+
params.projectId || null,
|
|
3607
3644
|
now,
|
|
3608
3645
|
now
|
|
3609
3646
|
);
|
|
@@ -3627,13 +3664,23 @@ var LocalTaskStore = class {
|
|
|
3627
3664
|
params.push(filter.ownerId);
|
|
3628
3665
|
}
|
|
3629
3666
|
if (filter.status) {
|
|
3630
|
-
|
|
3631
|
-
|
|
3667
|
+
const statuses = filter.status.split(",").map((s) => s.trim()).filter(Boolean);
|
|
3668
|
+
const placeholders = statuses.map(() => "?").join(", ");
|
|
3669
|
+
conditions.push(`status IN (${placeholders})`);
|
|
3670
|
+
params.push(...statuses);
|
|
3632
3671
|
}
|
|
3633
3672
|
if (filter.priority) {
|
|
3634
3673
|
conditions.push("priority = ?");
|
|
3635
3674
|
params.push(filter.priority);
|
|
3636
3675
|
}
|
|
3676
|
+
if (filter.workspaceId) {
|
|
3677
|
+
conditions.push("workspace_id = ?");
|
|
3678
|
+
params.push(filter.workspaceId);
|
|
3679
|
+
}
|
|
3680
|
+
if (filter.projectId) {
|
|
3681
|
+
conditions.push("project_id = ?");
|
|
3682
|
+
params.push(filter.projectId);
|
|
3683
|
+
}
|
|
3637
3684
|
if (filter.parentId) {
|
|
3638
3685
|
conditions.push("parent_id = ?");
|
|
3639
3686
|
params.push(filter.parentId);
|
|
@@ -3709,6 +3756,30 @@ var LocalTaskStore = class {
|
|
|
3709
3756
|
setClauses.push("owner_id = ?");
|
|
3710
3757
|
values.push(updates.ownerId);
|
|
3711
3758
|
}
|
|
3759
|
+
if (updates.requireReview !== void 0) {
|
|
3760
|
+
setClauses.push("require_review = ?");
|
|
3761
|
+
values.push(updates.requireReview ? 1 : 0);
|
|
3762
|
+
}
|
|
3763
|
+
if (updates.dependencies !== void 0) {
|
|
3764
|
+
setClauses.push("dependencies = ?");
|
|
3765
|
+
values.push(JSON.stringify(updates.dependencies));
|
|
3766
|
+
}
|
|
3767
|
+
if (updates.result !== void 0) {
|
|
3768
|
+
setClauses.push("result = ?");
|
|
3769
|
+
values.push(updates.result);
|
|
3770
|
+
}
|
|
3771
|
+
if (updates.failureReason !== void 0) {
|
|
3772
|
+
setClauses.push("failure_reason = ?");
|
|
3773
|
+
values.push(updates.failureReason);
|
|
3774
|
+
}
|
|
3775
|
+
if (updates.workspaceId !== void 0) {
|
|
3776
|
+
setClauses.push("workspace_id = ?");
|
|
3777
|
+
values.push(updates.workspaceId);
|
|
3778
|
+
}
|
|
3779
|
+
if (updates.projectId !== void 0) {
|
|
3780
|
+
setClauses.push("project_id = ?");
|
|
3781
|
+
values.push(updates.projectId);
|
|
3782
|
+
}
|
|
3712
3783
|
if (setClauses.length === 1) return existing;
|
|
3713
3784
|
values.push(tenantId, id);
|
|
3714
3785
|
this.db.prepare(
|
|
@@ -3724,6 +3795,90 @@ var LocalTaskStore = class {
|
|
|
3724
3795
|
}
|
|
3725
3796
|
};
|
|
3726
3797
|
|
|
3798
|
+
// src/stores/LocalTaskWorkItemStore.ts
|
|
3799
|
+
import { v4 as uuid2 } from "uuid";
|
|
3800
|
+
var DDL21 = `
|
|
3801
|
+
CREATE TABLE IF NOT EXISTS lt_task_work_items (
|
|
3802
|
+
id TEXT NOT NULL,
|
|
3803
|
+
tenant_id TEXT NOT NULL,
|
|
3804
|
+
task_id TEXT NOT NULL,
|
|
3805
|
+
action TEXT NOT NULL,
|
|
3806
|
+
actor TEXT NOT NULL,
|
|
3807
|
+
thread_id TEXT,
|
|
3808
|
+
summary TEXT,
|
|
3809
|
+
detail TEXT,
|
|
3810
|
+
attempt INTEGER,
|
|
3811
|
+
workspace_id TEXT,
|
|
3812
|
+
project_id TEXT,
|
|
3813
|
+
created_at TEXT NOT NULL,
|
|
3814
|
+
PRIMARY KEY (tenant_id, id)
|
|
3815
|
+
);
|
|
3816
|
+
`;
|
|
3817
|
+
function mapRowToWorkItem(row) {
|
|
3818
|
+
return {
|
|
3819
|
+
id: row.id,
|
|
3820
|
+
tenantId: row.tenant_id,
|
|
3821
|
+
taskId: row.task_id,
|
|
3822
|
+
action: row.action,
|
|
3823
|
+
actor: row.actor,
|
|
3824
|
+
threadId: row.thread_id ?? void 0,
|
|
3825
|
+
summary: row.summary ?? void 0,
|
|
3826
|
+
detail: row.detail ? JSON.parse(row.detail) : void 0,
|
|
3827
|
+
attempt: row.attempt ?? void 0,
|
|
3828
|
+
workspaceId: row.workspace_id ?? void 0,
|
|
3829
|
+
projectId: row.project_id ?? void 0,
|
|
3830
|
+
createdAt: parseISO(row.created_at)
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
var LocalTaskWorkItemStore = class {
|
|
3834
|
+
constructor(db) {
|
|
3835
|
+
this.db = db;
|
|
3836
|
+
ensureTable(db, DDL21);
|
|
3837
|
+
this.db.exec(`ALTER TABLE lt_task_work_items ADD COLUMN workspace_id TEXT;`);
|
|
3838
|
+
this.db.exec(`ALTER TABLE lt_task_work_items ADD COLUMN project_id TEXT;`);
|
|
3839
|
+
}
|
|
3840
|
+
async create(params) {
|
|
3841
|
+
const id = uuid2();
|
|
3842
|
+
const now = nowISO();
|
|
3843
|
+
this.db.prepare(
|
|
3844
|
+
`INSERT INTO lt_task_work_items (id, tenant_id, task_id, action, actor, thread_id, summary, detail, attempt, workspace_id, project_id, created_at)
|
|
3845
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
3846
|
+
).run(
|
|
3847
|
+
id,
|
|
3848
|
+
params.tenantId,
|
|
3849
|
+
params.taskId,
|
|
3850
|
+
params.action,
|
|
3851
|
+
params.actor,
|
|
3852
|
+
params.threadId || null,
|
|
3853
|
+
params.summary || null,
|
|
3854
|
+
params.detail ? JSON.stringify(params.detail) : null,
|
|
3855
|
+
params.attempt ?? null,
|
|
3856
|
+
params.workspaceId || null,
|
|
3857
|
+
params.projectId || null,
|
|
3858
|
+
now
|
|
3859
|
+
);
|
|
3860
|
+
const row = this.db.prepare(
|
|
3861
|
+
`SELECT * FROM lt_task_work_items WHERE tenant_id = ? AND id = ?`
|
|
3862
|
+
).get(params.tenantId, id);
|
|
3863
|
+
return mapRowToWorkItem(row);
|
|
3864
|
+
}
|
|
3865
|
+
async list(filter) {
|
|
3866
|
+
const conditions = ["tenant_id = ?", "task_id = ?"];
|
|
3867
|
+
const params = [filter.tenantId, filter.taskId];
|
|
3868
|
+
if (filter.action) {
|
|
3869
|
+
conditions.push("action = ?");
|
|
3870
|
+
params.push(filter.action);
|
|
3871
|
+
}
|
|
3872
|
+
const where = conditions.join(" AND ");
|
|
3873
|
+
const limit = filter.limit || 100;
|
|
3874
|
+
const offset = filter.offset || 0;
|
|
3875
|
+
const rows = this.db.prepare(
|
|
3876
|
+
`SELECT * FROM lt_task_work_items WHERE ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`
|
|
3877
|
+
).all(...params, limit, offset);
|
|
3878
|
+
return rows.map(mapRowToWorkItem);
|
|
3879
|
+
}
|
|
3880
|
+
};
|
|
3881
|
+
|
|
3727
3882
|
// src/createLocalStoreConfig.ts
|
|
3728
3883
|
async function createLocalStoreConfig(options = {}) {
|
|
3729
3884
|
const dbPath = options.dbPath || "~/.axiom/lattice.db";
|
|
@@ -3749,6 +3904,7 @@ async function createLocalStoreConfig(options = {}) {
|
|
|
3749
3904
|
skill: new LocalSkillStore(db),
|
|
3750
3905
|
schedule: new LocalScheduleStorage(db),
|
|
3751
3906
|
task: new LocalTaskStore(db),
|
|
3907
|
+
taskWorkItem: new LocalTaskWorkItemStore(db),
|
|
3752
3908
|
checkpoint: SqliteSaver.fromConnString(dbPath)
|
|
3753
3909
|
};
|
|
3754
3910
|
}
|
|
@@ -3767,6 +3923,7 @@ export {
|
|
|
3767
3923
|
LocalScheduleStorage,
|
|
3768
3924
|
LocalSkillStore,
|
|
3769
3925
|
LocalTaskStore,
|
|
3926
|
+
LocalTaskWorkItemStore,
|
|
3770
3927
|
LocalTenantStore,
|
|
3771
3928
|
LocalThreadMessageQueueStore,
|
|
3772
3929
|
LocalThreadStore,
|