@axiom-lattice/local-stores 1.0.2 → 1.0.3

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/local-stores@1.0.2 build /home/runner/work/agentic/agentic/packages/local-stores
2
+ > @axiom-lattice/local-stores@1.0.3 build /home/runner/work/agentic/agentic/packages/local-stores
3
3
  > tsup src/index.ts --format cjs,esm --dts --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,13 +8,13 @@
8
8
  CLI Target: es2020
9
9
  CJS Build start
10
10
  ESM Build start
11
- ESM dist/index.mjs 105.95 KB
12
- ESM dist/index.mjs.map 200.72 KB
13
- ESM ⚡️ Build success in 483ms
14
- CJS dist/index.js 109.14 KB
15
- CJS dist/index.js.map 203.12 KB
16
- CJS ⚡️ Build success in 494ms
11
+ CJS dist/index.js 116.70 KB
12
+ CJS dist/index.js.map 216.87 KB
13
+ CJS ⚡️ Build success in 482ms
14
+ ESM dist/index.mjs 113.47 KB
15
+ ESM dist/index.mjs.map 214.41 KB
16
+ ESM ⚡️ Build success in 484ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 16091ms
19
- DTS dist/index.d.ts 24.07 KB
20
- DTS dist/index.d.mts 24.07 KB
18
+ DTS ⚡️ Build success in 15568ms
19
+ DTS dist/index.d.ts 24.92 KB
20
+ DTS dist/index.d.mts 24.92 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @axiom-lattice/local-stores
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c99a06: big changes
8
+ - Updated dependencies [0c99a06]
9
+ - @axiom-lattice/core@2.1.81
10
+ - @axiom-lattice/protocols@2.1.43
11
+
3
12
  ## 1.0.2
4
13
 
5
14
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SqlJsStatic, Database } from 'sql.js';
2
2
  import { SqliteSaver } from '@langchain/langgraph-checkpoint-sqlite';
3
- import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, WorkspaceStore, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, ProjectStore, Project, CreateProjectRequest, UpdateProjectRequest, UserStore, User, CreateUserRequest, UpdateUserRequest, TenantStore, Tenant, CreateTenantRequest, UpdateTenantRequest, UserTenantLinkStore, UserTenantLink, CreateUserTenantLinkRequest, UpdateUserTenantLinkRequest, DatabaseConfigStore, DatabaseConfigEntry, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, MetricsServerConfigStore, MetricsServerConfigEntry, CreateMetricsServerConfigRequest, UpdateMetricsServerConfigRequest, McpServerConfigStore, McpServerConfigEntry, CreateMcpServerConfigRequest, UpdateMcpServerConfigRequest, WorkflowTrackingStore, CreateWorkflowRunRequest, WorkflowRun, UpdateWorkflowRunRequest, CreateRunStepRequest, RunStep, UpdateRunStepRequest, StepType, EvalStore, EvalProject, CreateEvalProjectRequest, EvalSuite, CreateEvalSuiteRequest, EvalCase, CreateEvalCaseRequest, EvalRun, CreateEvalRunRequest, EvalRunResult, EvalProjectReport, BindingRegistry, Binding, CreateBindingInput, ChannelInstallationStore, ChannelInstallation, ChannelInstallationType, CreateChannelInstallationRequest, UpdateChannelInstallationRequest, A2AApiKeyStore, A2AApiKeyRecord, CreateA2AApiKeyInput, A2AApiKeyEntry, SkillStore, SkillStoreContext, Skill, CreateSkillRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType } from '@axiom-lattice/protocols';
3
+ import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, WorkspaceStore, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, ProjectStore, Project, CreateProjectRequest, UpdateProjectRequest, UserStore, User, CreateUserRequest, UpdateUserRequest, TenantStore, Tenant, CreateTenantRequest, UpdateTenantRequest, UserTenantLinkStore, UserTenantLink, CreateUserTenantLinkRequest, UpdateUserTenantLinkRequest, DatabaseConfigStore, DatabaseConfigEntry, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, MetricsServerConfigStore, MetricsServerConfigEntry, CreateMetricsServerConfigRequest, UpdateMetricsServerConfigRequest, McpServerConfigStore, McpServerConfigEntry, CreateMcpServerConfigRequest, UpdateMcpServerConfigRequest, WorkflowTrackingStore, CreateWorkflowRunRequest, WorkflowRun, UpdateWorkflowRunRequest, CreateRunStepRequest, RunStep, UpdateRunStepRequest, StepType, EvalStore, EvalProject, CreateEvalProjectRequest, EvalSuite, CreateEvalSuiteRequest, EvalCase, CreateEvalCaseRequest, EvalRun, CreateEvalRunRequest, EvalRunResult, EvalProjectReport, BindingRegistry, Binding, CreateBindingInput, ChannelInstallationStore, ChannelInstallation, ChannelInstallationType, CreateChannelInstallationRequest, UpdateChannelInstallationRequest, A2AApiKeyStore, A2AApiKeyRecord, CreateA2AApiKeyInput, A2AApiKeyEntry, SkillStore, SkillStoreContext, Skill, CreateSkillRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType, TaskStore, CreateTaskRequest, TaskItem, TaskListFilter, UpdateTaskRequest } from '@axiom-lattice/protocols';
4
4
  import { IMessageQueueStore, AddMessageParams, PendingMessage, ThreadInfo } from '@axiom-lattice/core';
5
5
 
6
6
  /**
@@ -147,6 +147,7 @@ declare class LocalAssistantStore implements AssistantStore {
147
147
  updateAssistant(tenantId: string, id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
148
148
  deleteAssistant(tenantId: string, id: string): Promise<boolean>;
149
149
  hasAssistant(tenantId: string, id: string): Promise<boolean>;
150
+ getByOwner(tenantId: string, userId: string): Promise<Assistant | null>;
150
151
  }
151
152
 
152
153
  /**
@@ -385,6 +386,7 @@ declare class LocalChannelInstallationStore implements ChannelInstallationStore
385
386
  constructor(db: DatabaseWrapper);
386
387
  getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
387
388
  getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
389
+ getAllInstallations(channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
388
390
  createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
389
391
  updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
390
392
  deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
@@ -490,6 +492,24 @@ declare class LocalScheduleStorage implements ScheduleStorage {
490
492
  deleteOldTasks(olderThanMs: number): Promise<number>;
491
493
  }
492
494
 
495
+ /**
496
+ * Local SQLite implementation of TaskStore.
497
+ */
498
+
499
+ declare class LocalTaskStore implements TaskStore {
500
+ private db;
501
+ constructor(db: DatabaseWrapper);
502
+ create(params: CreateTaskRequest & {
503
+ tenantId: string;
504
+ ownerType: string;
505
+ ownerId: string;
506
+ }): Promise<TaskItem>;
507
+ getById(tenantId: string, id: string): Promise<TaskItem | null>;
508
+ list(filter: TaskListFilter): Promise<TaskItem[]>;
509
+ update(tenantId: string, id: string, updates: UpdateTaskRequest): Promise<TaskItem | null>;
510
+ delete(tenantId: string, id: string): Promise<boolean>;
511
+ }
512
+
493
513
  /**
494
514
  * createLocalStoreConfig
495
515
  *
@@ -542,7 +562,8 @@ declare function createLocalStoreConfig(options?: LocalStoreConfigOptions): Prom
542
562
  threadMessageQueue: LocalThreadMessageQueueStore;
543
563
  skill: LocalSkillStore;
544
564
  schedule: LocalScheduleStorage;
565
+ task: LocalTaskStore;
545
566
  checkpoint: SqliteSaver;
546
567
  }>;
547
568
 
548
- export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
569
+ export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTaskStore, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SqlJsStatic, Database } from 'sql.js';
2
2
  import { SqliteSaver } from '@langchain/langgraph-checkpoint-sqlite';
3
- import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, WorkspaceStore, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, ProjectStore, Project, CreateProjectRequest, UpdateProjectRequest, UserStore, User, CreateUserRequest, UpdateUserRequest, TenantStore, Tenant, CreateTenantRequest, UpdateTenantRequest, UserTenantLinkStore, UserTenantLink, CreateUserTenantLinkRequest, UpdateUserTenantLinkRequest, DatabaseConfigStore, DatabaseConfigEntry, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, MetricsServerConfigStore, MetricsServerConfigEntry, CreateMetricsServerConfigRequest, UpdateMetricsServerConfigRequest, McpServerConfigStore, McpServerConfigEntry, CreateMcpServerConfigRequest, UpdateMcpServerConfigRequest, WorkflowTrackingStore, CreateWorkflowRunRequest, WorkflowRun, UpdateWorkflowRunRequest, CreateRunStepRequest, RunStep, UpdateRunStepRequest, StepType, EvalStore, EvalProject, CreateEvalProjectRequest, EvalSuite, CreateEvalSuiteRequest, EvalCase, CreateEvalCaseRequest, EvalRun, CreateEvalRunRequest, EvalRunResult, EvalProjectReport, BindingRegistry, Binding, CreateBindingInput, ChannelInstallationStore, ChannelInstallation, ChannelInstallationType, CreateChannelInstallationRequest, UpdateChannelInstallationRequest, A2AApiKeyStore, A2AApiKeyRecord, CreateA2AApiKeyInput, A2AApiKeyEntry, SkillStore, SkillStoreContext, Skill, CreateSkillRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType } from '@axiom-lattice/protocols';
3
+ import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, WorkspaceStore, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, ProjectStore, Project, CreateProjectRequest, UpdateProjectRequest, UserStore, User, CreateUserRequest, UpdateUserRequest, TenantStore, Tenant, CreateTenantRequest, UpdateTenantRequest, UserTenantLinkStore, UserTenantLink, CreateUserTenantLinkRequest, UpdateUserTenantLinkRequest, DatabaseConfigStore, DatabaseConfigEntry, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, MetricsServerConfigStore, MetricsServerConfigEntry, CreateMetricsServerConfigRequest, UpdateMetricsServerConfigRequest, McpServerConfigStore, McpServerConfigEntry, CreateMcpServerConfigRequest, UpdateMcpServerConfigRequest, WorkflowTrackingStore, CreateWorkflowRunRequest, WorkflowRun, UpdateWorkflowRunRequest, CreateRunStepRequest, RunStep, UpdateRunStepRequest, StepType, EvalStore, EvalProject, CreateEvalProjectRequest, EvalSuite, CreateEvalSuiteRequest, EvalCase, CreateEvalCaseRequest, EvalRun, CreateEvalRunRequest, EvalRunResult, EvalProjectReport, BindingRegistry, Binding, CreateBindingInput, ChannelInstallationStore, ChannelInstallation, ChannelInstallationType, CreateChannelInstallationRequest, UpdateChannelInstallationRequest, A2AApiKeyStore, A2AApiKeyRecord, CreateA2AApiKeyInput, A2AApiKeyEntry, SkillStore, SkillStoreContext, Skill, CreateSkillRequest, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType, TaskStore, CreateTaskRequest, TaskItem, TaskListFilter, UpdateTaskRequest } from '@axiom-lattice/protocols';
4
4
  import { IMessageQueueStore, AddMessageParams, PendingMessage, ThreadInfo } from '@axiom-lattice/core';
5
5
 
6
6
  /**
@@ -147,6 +147,7 @@ declare class LocalAssistantStore implements AssistantStore {
147
147
  updateAssistant(tenantId: string, id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
148
148
  deleteAssistant(tenantId: string, id: string): Promise<boolean>;
149
149
  hasAssistant(tenantId: string, id: string): Promise<boolean>;
150
+ getByOwner(tenantId: string, userId: string): Promise<Assistant | null>;
150
151
  }
151
152
 
152
153
  /**
@@ -385,6 +386,7 @@ declare class LocalChannelInstallationStore implements ChannelInstallationStore
385
386
  constructor(db: DatabaseWrapper);
386
387
  getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
387
388
  getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
389
+ getAllInstallations(channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
388
390
  createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
389
391
  updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
390
392
  deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
@@ -490,6 +492,24 @@ declare class LocalScheduleStorage implements ScheduleStorage {
490
492
  deleteOldTasks(olderThanMs: number): Promise<number>;
491
493
  }
492
494
 
495
+ /**
496
+ * Local SQLite implementation of TaskStore.
497
+ */
498
+
499
+ declare class LocalTaskStore implements TaskStore {
500
+ private db;
501
+ constructor(db: DatabaseWrapper);
502
+ create(params: CreateTaskRequest & {
503
+ tenantId: string;
504
+ ownerType: string;
505
+ ownerId: string;
506
+ }): Promise<TaskItem>;
507
+ getById(tenantId: string, id: string): Promise<TaskItem | null>;
508
+ list(filter: TaskListFilter): Promise<TaskItem[]>;
509
+ update(tenantId: string, id: string, updates: UpdateTaskRequest): Promise<TaskItem | null>;
510
+ delete(tenantId: string, id: string): Promise<boolean>;
511
+ }
512
+
493
513
  /**
494
514
  * createLocalStoreConfig
495
515
  *
@@ -542,7 +562,8 @@ declare function createLocalStoreConfig(options?: LocalStoreConfigOptions): Prom
542
562
  threadMessageQueue: LocalThreadMessageQueueStore;
543
563
  skill: LocalSkillStore;
544
564
  schedule: LocalScheduleStorage;
565
+ task: LocalTaskStore;
545
566
  checkpoint: SqliteSaver;
546
567
  }>;
547
568
 
548
- export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
569
+ export { DatabaseWrapper, LocalA2AApiKeyStore, LocalAssistantStore, LocalChannelBindingStore, LocalChannelInstallationStore, LocalDatabaseConfigStore, LocalEvalStore, LocalMcpServerConfigStore, LocalMetricsServerConfigStore, LocalProjectStore, LocalScheduleStorage, LocalSkillStore, type LocalStoreConfigOptions, type LocalStoreOptions, LocalTaskStore, LocalTenantStore, LocalThreadMessageQueueStore, LocalThreadStore, LocalUserStore, LocalUserTenantLinkStore, LocalWorkflowTrackingStore, LocalWorkspaceStore, RunResult, StatementWrapper, closeDatabase, createLocalStoreConfig, ensureTable, getDatabase, initDatabase, nowISO, parseISO };
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  LocalProjectStore: () => LocalProjectStore,
43
43
  LocalScheduleStorage: () => LocalScheduleStorage,
44
44
  LocalSkillStore: () => LocalSkillStore,
45
+ LocalTaskStore: () => LocalTaskStore,
45
46
  LocalTenantStore: () => LocalTenantStore,
46
47
  LocalThreadMessageQueueStore: () => LocalThreadMessageQueueStore,
47
48
  LocalThreadStore: () => LocalThreadStore,
@@ -341,6 +342,7 @@ CREATE TABLE IF NOT EXISTS lt_assistants (
341
342
  name TEXT NOT NULL,
342
343
  description TEXT,
343
344
  graph_definition TEXT NOT NULL,
345
+ owner_user_id TEXT,
344
346
  created_at TEXT NOT NULL,
345
347
  updated_at TEXT NOT NULL,
346
348
  PRIMARY KEY (tenant_id, id)
@@ -366,20 +368,22 @@ var LocalAssistantStore = class {
366
368
  async createAssistant(tenantId, id, data) {
367
369
  const now = nowISO();
368
370
  this.db.prepare(
369
- `INSERT INTO lt_assistants (id, tenant_id, name, description, graph_definition, created_at, updated_at)
370
- VALUES (?, ?, ?, ?, ?, ?, ?)
371
+ `INSERT INTO lt_assistants (id, tenant_id, name, description, graph_definition, owner_user_id, created_at, updated_at)
372
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
371
373
  ON CONFLICT(tenant_id, id) DO UPDATE SET
372
374
  name = excluded.name,
373
375
  description = excluded.description,
374
376
  graph_definition = excluded.graph_definition,
377
+ owner_user_id = excluded.owner_user_id,
375
378
  updated_at = excluded.updated_at`
376
- ).run(id, tenantId, data.name, data.description || null, JSON.stringify(data.graphDefinition), now, now);
379
+ ).run(id, tenantId, data.name, data.description || null, JSON.stringify(data.graphDefinition), data.ownerUserId || null, now, now);
377
380
  return {
378
381
  id,
379
382
  tenantId,
380
383
  name: data.name,
381
384
  description: data.description,
382
385
  graphDefinition: data.graphDefinition,
386
+ ownerUserId: data.ownerUserId,
383
387
  createdAt: parseISO(now),
384
388
  updatedAt: parseISO(now)
385
389
  };
@@ -401,6 +405,10 @@ var LocalAssistantStore = class {
401
405
  setClauses.push("graph_definition = ?");
402
406
  values.push(JSON.stringify(updates.graphDefinition));
403
407
  }
408
+ if (updates.ownerUserId !== void 0) {
409
+ setClauses.push("owner_user_id = ?");
410
+ values.push(updates.ownerUserId || null);
411
+ }
404
412
  if (setClauses.length === 0) return existing;
405
413
  const now = nowISO();
406
414
  setClauses.push("updated_at = ?");
@@ -423,6 +431,12 @@ var LocalAssistantStore = class {
423
431
  ).get(tenantId, id);
424
432
  return row !== void 0;
425
433
  }
434
+ async getByOwner(tenantId, userId) {
435
+ const row = this.db.prepare(
436
+ `SELECT * FROM lt_assistants WHERE tenant_id = ? AND owner_user_id = ? LIMIT 1`
437
+ ).get(tenantId, userId);
438
+ return row ? mapRowToAssistant(row) : null;
439
+ }
426
440
  };
427
441
  function mapRowToAssistant(row) {
428
442
  return {
@@ -431,6 +445,7 @@ function mapRowToAssistant(row) {
431
445
  name: row.name,
432
446
  description: row.description || void 0,
433
447
  graphDefinition: JSON.parse(row.graph_definition),
448
+ ownerUserId: row.owner_user_id || void 0,
434
449
  createdAt: parseISO(row.created_at),
435
450
  updatedAt: parseISO(row.updated_at)
436
451
  };
@@ -1419,6 +1434,7 @@ CREATE TABLE IF NOT EXISTS lt_workflow_steps (
1419
1434
  tenant_id TEXT NOT NULL,
1420
1435
  step_type TEXT NOT NULL,
1421
1436
  step_name TEXT NOT NULL,
1437
+ thread_id TEXT,
1422
1438
  edge_from TEXT,
1423
1439
  edge_to TEXT,
1424
1440
  edge_purpose TEXT,
@@ -1434,6 +1450,8 @@ CREATE TABLE IF NOT EXISTS lt_workflow_steps (
1434
1450
  PRIMARY KEY (run_id, id)
1435
1451
  );
1436
1452
  CREATE INDEX IF NOT EXISTS idx_lt_ws_type ON lt_workflow_steps(run_id, step_type);
1453
+ -- Backfill for existing databases that don't have the column
1454
+ ALTER TABLE lt_workflow_steps ADD COLUMN IF NOT EXISTS thread_id TEXT;
1437
1455
  `;
1438
1456
  var LocalWorkflowTrackingStore = class {
1439
1457
  constructor(db) {
@@ -1538,14 +1556,15 @@ var LocalWorkflowTrackingStore = class {
1538
1556
  const now = nowISO();
1539
1557
  const id = `step_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
1540
1558
  this.db.prepare(
1541
- `INSERT INTO lt_workflow_steps (id, run_id, tenant_id, step_type, step_name, edge_from, edge_to, edge_purpose, input, status, started_at, created_at, updated_at)
1542
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'running', ?, ?, ?)`
1559
+ `INSERT INTO lt_workflow_steps (id, run_id, tenant_id, step_type, step_name, thread_id, edge_from, edge_to, edge_purpose, input, status, started_at, created_at, updated_at)
1560
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'running', ?, ?, ?)`
1543
1561
  ).run(
1544
1562
  id,
1545
1563
  request.runId,
1546
1564
  request.tenantId,
1547
1565
  request.stepType,
1548
1566
  request.stepName,
1567
+ request.threadId || null,
1549
1568
  request.edgeFrom || null,
1550
1569
  request.edgeTo || null,
1551
1570
  request.edgePurpose || null,
@@ -1560,6 +1579,7 @@ var LocalWorkflowTrackingStore = class {
1560
1579
  tenantId: request.tenantId,
1561
1580
  stepType: request.stepType,
1562
1581
  stepName: request.stepName,
1582
+ threadId: request.threadId,
1563
1583
  edgeFrom: request.edgeFrom,
1564
1584
  edgeTo: request.edgeTo,
1565
1585
  edgePurpose: request.edgePurpose,
@@ -1574,7 +1594,16 @@ var LocalWorkflowTrackingStore = class {
1574
1594
  const row = this.db.prepare(
1575
1595
  `SELECT * FROM lt_workflow_steps WHERE run_id = ? AND step_type = ? AND step_name = ?`
1576
1596
  ).get(request.runId, request.stepType, request.stepName);
1577
- if (row) return mapRowToStep(row);
1597
+ if (row) {
1598
+ const existing = mapRowToStep(row);
1599
+ if (!existing.threadId && request.threadId) {
1600
+ this.db.prepare(
1601
+ `UPDATE lt_workflow_steps SET thread_id = ?, updated_at = ? WHERE run_id = ? AND id = ?`
1602
+ ).run(request.threadId, nowISO(), request.runId, existing.id);
1603
+ existing.threadId = request.threadId;
1604
+ }
1605
+ return existing;
1606
+ }
1578
1607
  return this.createRunStep(request);
1579
1608
  }
1580
1609
  async updateRunStep(runId, stepId, updates) {
@@ -1662,6 +1691,7 @@ function mapRowToStep(row) {
1662
1691
  tenantId: row.tenant_id,
1663
1692
  stepType: row.step_type,
1664
1693
  stepName: row.step_name,
1694
+ threadId: row.thread_id,
1665
1695
  edgeFrom: row.edge_from || void 0,
1666
1696
  edgeTo: row.edge_to || void 0,
1667
1697
  edgePurpose: row.edge_purpose || void 0,
@@ -2447,6 +2477,19 @@ var LocalChannelInstallationStore = class {
2447
2477
  }
2448
2478
  return rows.map(mapRow);
2449
2479
  }
2480
+ async getAllInstallations(channel) {
2481
+ let rows;
2482
+ if (channel) {
2483
+ rows = this.db.prepare(
2484
+ `SELECT * FROM lt_channel_installations WHERE channel = ? ORDER BY created_at DESC`
2485
+ ).all(channel);
2486
+ } else {
2487
+ rows = this.db.prepare(
2488
+ `SELECT * FROM lt_channel_installations ORDER BY created_at DESC`
2489
+ ).all();
2490
+ }
2491
+ return rows.map(mapRow);
2492
+ }
2450
2493
  async createInstallation(tenantId, installationId, data) {
2451
2494
  const now = nowISO();
2452
2495
  this.db.prepare(
@@ -2696,6 +2739,8 @@ CREATE TABLE IF NOT EXISTS lt_thread_message_queue (
2696
2739
  thread_id TEXT NOT NULL,
2697
2740
  tenant_id TEXT NOT NULL,
2698
2741
  assistant_id TEXT NOT NULL,
2742
+ workspace_id TEXT,
2743
+ project_id TEXT,
2699
2744
  message_content TEXT NOT NULL,
2700
2745
  message_type TEXT NOT NULL DEFAULT 'human',
2701
2746
  sequence_order INTEGER NOT NULL DEFAULT 0,
@@ -2721,13 +2766,15 @@ var LocalThreadMessageQueueStore = class {
2721
2766
  ).get(params.threadId);
2722
2767
  const nextSeq = seqRow.next_seq;
2723
2768
  this.db.prepare(
2724
- `INSERT INTO lt_thread_message_queue (id, thread_id, tenant_id, assistant_id, message_content, message_type, sequence_order, priority, command, custom_run_config, created_at)
2725
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
2769
+ `INSERT INTO lt_thread_message_queue (id, thread_id, tenant_id, assistant_id, workspace_id, project_id, message_content, message_type, sequence_order, priority, command, custom_run_config, created_at)
2770
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
2726
2771
  ).run(
2727
2772
  id,
2728
2773
  params.threadId,
2729
2774
  params.tenantId,
2730
2775
  params.assistantId,
2776
+ params.workspaceId || null,
2777
+ params.projectId || null,
2731
2778
  JSON.stringify(params.content),
2732
2779
  params.type || "human",
2733
2780
  nextSeq,
@@ -2745,13 +2792,15 @@ var LocalThreadMessageQueueStore = class {
2745
2792
  `SELECT COALESCE(MAX(sequence_order), 0) + 1 as next_seq FROM lt_thread_message_queue WHERE thread_id = ?`
2746
2793
  ).get(params.threadId);
2747
2794
  this.db.prepare(
2748
- `INSERT INTO lt_thread_message_queue (id, thread_id, tenant_id, assistant_id, message_content, message_type, sequence_order, priority, command, custom_run_config, created_at)
2749
- VALUES (?, ?, ?, ?, ?, ?, ?, 100, ?, ?, ?)`
2795
+ `INSERT INTO lt_thread_message_queue (id, thread_id, tenant_id, assistant_id, workspace_id, project_id, message_content, message_type, sequence_order, priority, command, custom_run_config, created_at)
2796
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 100, ?, ?, ?)`
2750
2797
  ).run(
2751
2798
  id,
2752
2799
  params.threadId,
2753
2800
  params.tenantId,
2754
2801
  params.assistantId,
2802
+ params.workspaceId || null,
2803
+ params.projectId || null,
2755
2804
  JSON.stringify(params.content),
2756
2805
  params.type || "human",
2757
2806
  seqRow.next_seq,
@@ -2781,12 +2830,14 @@ var LocalThreadMessageQueueStore = class {
2781
2830
  }
2782
2831
  async getThreadsWithPendingMessages() {
2783
2832
  const rows = this.db.prepare(
2784
- `SELECT DISTINCT tenant_id, assistant_id, thread_id FROM lt_thread_message_queue WHERE status IN ('pending', 'processing') ORDER BY thread_id`
2833
+ `SELECT DISTINCT ON (thread_id) tenant_id, assistant_id, thread_id, workspace_id, project_id FROM lt_thread_message_queue WHERE status IN ('pending', 'processing') ORDER BY thread_id`
2785
2834
  ).all();
2786
2835
  return rows.map((r) => ({
2787
2836
  tenantId: r.tenant_id,
2788
2837
  assistantId: r.assistant_id,
2789
- threadId: r.thread_id
2838
+ threadId: r.thread_id,
2839
+ workspaceId: r.workspace_id || void 0,
2840
+ projectId: r.project_id || void 0
2790
2841
  }));
2791
2842
  }
2792
2843
  async removeMessage(messageId) {
@@ -3319,6 +3370,192 @@ function mapRowToTask(row) {
3319
3370
  };
3320
3371
  }
3321
3372
 
3373
+ // src/stores/LocalTaskStore.ts
3374
+ var import_crypto5 = require("crypto");
3375
+ var DDL19 = `
3376
+ CREATE TABLE IF NOT EXISTS lt_tasks (
3377
+ id TEXT NOT NULL,
3378
+ tenant_id TEXT NOT NULL,
3379
+ owner_type TEXT NOT NULL DEFAULT 'user',
3380
+ owner_id TEXT NOT NULL,
3381
+ title TEXT NOT NULL,
3382
+ description TEXT,
3383
+ status TEXT NOT NULL DEFAULT 'pending',
3384
+ priority TEXT NOT NULL DEFAULT 'medium',
3385
+ due_date TEXT,
3386
+ metadata TEXT,
3387
+ parent_id TEXT,
3388
+ source_id TEXT,
3389
+ context TEXT,
3390
+ created_at TEXT NOT NULL,
3391
+ updated_at TEXT NOT NULL,
3392
+ PRIMARY KEY (tenant_id, id)
3393
+ );
3394
+ `;
3395
+ function mapRowToTask2(row) {
3396
+ return {
3397
+ id: row.id,
3398
+ tenantId: row.tenant_id,
3399
+ ownerType: row.owner_type,
3400
+ ownerId: row.owner_id,
3401
+ title: row.title,
3402
+ description: row.description ?? void 0,
3403
+ status: row.status,
3404
+ priority: row.priority,
3405
+ dueDate: row.due_date ?? void 0,
3406
+ metadata: row.metadata ? JSON.parse(row.metadata) : void 0,
3407
+ parentId: row.parent_id ?? void 0,
3408
+ sourceId: row.source_id ?? void 0,
3409
+ context: row.context ? JSON.parse(row.context) : void 0,
3410
+ createdAt: parseISO(row.created_at),
3411
+ updatedAt: parseISO(row.updated_at)
3412
+ };
3413
+ }
3414
+ var LocalTaskStore = class {
3415
+ constructor(db) {
3416
+ this.db = db;
3417
+ ensureTable(db, DDL19);
3418
+ }
3419
+ async create(params) {
3420
+ const id = (0, import_crypto5.randomUUID)();
3421
+ const now = nowISO();
3422
+ this.db.prepare(
3423
+ `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)
3424
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
3425
+ ).run(
3426
+ id,
3427
+ params.tenantId,
3428
+ params.ownerType,
3429
+ params.ownerId,
3430
+ params.title,
3431
+ params.description || null,
3432
+ params.status || "pending",
3433
+ params.priority || "medium",
3434
+ params.dueDate || null,
3435
+ params.metadata ? JSON.stringify(params.metadata) : null,
3436
+ params.parentId || null,
3437
+ params.sourceId || null,
3438
+ params.context ? JSON.stringify(params.context) : null,
3439
+ now,
3440
+ now
3441
+ );
3442
+ return await this.getById(params.tenantId, id);
3443
+ }
3444
+ async getById(tenantId, id) {
3445
+ const row = this.db.prepare(
3446
+ `SELECT * FROM lt_tasks WHERE tenant_id = ? AND id = ?`
3447
+ ).get(tenantId, id);
3448
+ return row ? mapRowToTask2(row) : null;
3449
+ }
3450
+ async list(filter) {
3451
+ const conditions = ["tenant_id = ?"];
3452
+ const params = [filter.tenantId];
3453
+ if (filter.ownerType) {
3454
+ conditions.push("owner_type = ?");
3455
+ params.push(filter.ownerType);
3456
+ }
3457
+ if (filter.ownerId) {
3458
+ conditions.push("owner_id = ?");
3459
+ params.push(filter.ownerId);
3460
+ }
3461
+ if (filter.status) {
3462
+ conditions.push("status = ?");
3463
+ params.push(filter.status);
3464
+ }
3465
+ if (filter.priority) {
3466
+ conditions.push("priority = ?");
3467
+ params.push(filter.priority);
3468
+ }
3469
+ if (filter.parentId) {
3470
+ conditions.push("parent_id = ?");
3471
+ params.push(filter.parentId);
3472
+ }
3473
+ if (filter.sourceId) {
3474
+ conditions.push("source_id = ?");
3475
+ params.push(filter.sourceId);
3476
+ }
3477
+ if (filter.metadata) {
3478
+ for (const [key, value] of Object.entries(filter.metadata)) {
3479
+ const safeKey = key.replace(/[^a-zA-Z0-9_]/g, "");
3480
+ if (safeKey) {
3481
+ conditions.push(`json_extract(metadata, '$.${safeKey}') = ?`);
3482
+ params.push(String(value));
3483
+ }
3484
+ }
3485
+ }
3486
+ const where = conditions.join(" AND ");
3487
+ const limit = filter.limit || 100;
3488
+ const offset = filter.offset || 0;
3489
+ const rows = this.db.prepare(
3490
+ `SELECT * FROM lt_tasks WHERE ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`
3491
+ ).all(...params, limit, offset);
3492
+ return rows.map(mapRowToTask2);
3493
+ }
3494
+ async update(tenantId, id, updates) {
3495
+ const existing = await this.getById(tenantId, id);
3496
+ if (!existing) return null;
3497
+ const now = nowISO();
3498
+ const setClauses = ["updated_at = ?"];
3499
+ const values = [now];
3500
+ if (updates.title !== void 0) {
3501
+ setClauses.push("title = ?");
3502
+ values.push(updates.title);
3503
+ }
3504
+ if (updates.description !== void 0) {
3505
+ setClauses.push("description = ?");
3506
+ values.push(updates.description);
3507
+ }
3508
+ if (updates.status !== void 0) {
3509
+ setClauses.push("status = ?");
3510
+ values.push(updates.status);
3511
+ }
3512
+ if (updates.priority !== void 0) {
3513
+ setClauses.push("priority = ?");
3514
+ values.push(updates.priority);
3515
+ }
3516
+ if (updates.dueDate !== void 0) {
3517
+ setClauses.push("due_date = ?");
3518
+ values.push(updates.dueDate);
3519
+ }
3520
+ if (updates.metadata !== void 0) {
3521
+ setClauses.push("metadata = ?");
3522
+ values.push(JSON.stringify(updates.metadata));
3523
+ }
3524
+ if (updates.parentId !== void 0) {
3525
+ setClauses.push("parent_id = ?");
3526
+ values.push(updates.parentId);
3527
+ }
3528
+ if (updates.sourceId !== void 0) {
3529
+ setClauses.push("source_id = ?");
3530
+ values.push(updates.sourceId);
3531
+ }
3532
+ if (updates.context !== void 0) {
3533
+ setClauses.push("context = ?");
3534
+ values.push(JSON.stringify(updates.context));
3535
+ }
3536
+ if (updates.ownerType !== void 0) {
3537
+ setClauses.push("owner_type = ?");
3538
+ values.push(updates.ownerType);
3539
+ }
3540
+ if (updates.ownerId !== void 0) {
3541
+ setClauses.push("owner_id = ?");
3542
+ values.push(updates.ownerId);
3543
+ }
3544
+ if (setClauses.length === 1) return existing;
3545
+ values.push(tenantId, id);
3546
+ this.db.prepare(
3547
+ `UPDATE lt_tasks SET ${setClauses.join(", ")} WHERE tenant_id = ? AND id = ?`
3548
+ ).run(...values);
3549
+ return this.getById(tenantId, id);
3550
+ }
3551
+ async delete(tenantId, id) {
3552
+ const result = this.db.prepare(
3553
+ `DELETE FROM lt_tasks WHERE tenant_id = ? AND id = ?`
3554
+ ).run(tenantId, id);
3555
+ return result.changes > 0;
3556
+ }
3557
+ };
3558
+
3322
3559
  // src/createLocalStoreConfig.ts
3323
3560
  async function createLocalStoreConfig(options = {}) {
3324
3561
  const dbPath = options.dbPath || "~/.axiom/lattice.db";
@@ -3342,6 +3579,7 @@ async function createLocalStoreConfig(options = {}) {
3342
3579
  threadMessageQueue: new LocalThreadMessageQueueStore(db),
3343
3580
  skill: new LocalSkillStore(db),
3344
3581
  schedule: new LocalScheduleStorage(db),
3582
+ task: new LocalTaskStore(db),
3345
3583
  checkpoint: import_langgraph_checkpoint_sqlite.SqliteSaver.fromConnString(dbPath)
3346
3584
  };
3347
3585
  }
@@ -3359,6 +3597,7 @@ async function createLocalStoreConfig(options = {}) {
3359
3597
  LocalProjectStore,
3360
3598
  LocalScheduleStorage,
3361
3599
  LocalSkillStore,
3600
+ LocalTaskStore,
3362
3601
  LocalTenantStore,
3363
3602
  LocalThreadMessageQueueStore,
3364
3603
  LocalThreadStore,