@axiom-lattice/local-stores 1.0.1 → 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.1 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.66 KB
12
- ESM dist/index.mjs.map 200.09 KB
13
- ESM ⚡️ Build success in 399ms
14
- CJS dist/index.js 108.84 KB
15
- CJS dist/index.js.map 202.50 KB
16
- CJS ⚡️ Build success in 407ms
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 16019ms
19
- DTS dist/index.d.ts 24.00 KB
20
- DTS dist/index.d.mts 24.00 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,23 @@
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
+
12
+ ## 1.0.2
13
+
14
+ ### Patch Changes
15
+
16
+ - b4bdb6c: up new
17
+ - Updated dependencies [b4bdb6c]
18
+ - @axiom-lattice/protocols@2.1.42
19
+ - @axiom-lattice/core@2.1.80
20
+
3
21
  ## 1.0.1
4
22
 
5
23
  ### 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
  /**
@@ -288,6 +289,7 @@ declare class LocalWorkflowTrackingStore implements WorkflowTrackingStore {
288
289
  getWorkflowRunsByAssistantId(tenantId: string, assistantId: string): Promise<WorkflowRun[]>;
289
290
  getWorkflowRunsByTenantId(tenantId: string): Promise<WorkflowRun[]>;
290
291
  createRunStep(request: CreateRunStepRequest): Promise<RunStep>;
292
+ upsertRunStep(request: CreateRunStepRequest): Promise<RunStep>;
291
293
  updateRunStep(runId: string, stepId: string, updates: UpdateRunStepRequest): Promise<RunStep | null>;
292
294
  getRunSteps(runId: string): Promise<RunStep[]>;
293
295
  getRunStepsByType(runId: string, stepType: StepType): Promise<RunStep[]>;
@@ -384,6 +386,7 @@ declare class LocalChannelInstallationStore implements ChannelInstallationStore
384
386
  constructor(db: DatabaseWrapper);
385
387
  getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
386
388
  getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
389
+ getAllInstallations(channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
387
390
  createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
388
391
  updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
389
392
  deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
@@ -489,6 +492,24 @@ declare class LocalScheduleStorage implements ScheduleStorage {
489
492
  deleteOldTasks(olderThanMs: number): Promise<number>;
490
493
  }
491
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
+
492
513
  /**
493
514
  * createLocalStoreConfig
494
515
  *
@@ -541,7 +562,8 @@ declare function createLocalStoreConfig(options?: LocalStoreConfigOptions): Prom
541
562
  threadMessageQueue: LocalThreadMessageQueueStore;
542
563
  skill: LocalSkillStore;
543
564
  schedule: LocalScheduleStorage;
565
+ task: LocalTaskStore;
544
566
  checkpoint: SqliteSaver;
545
567
  }>;
546
568
 
547
- 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
  /**
@@ -288,6 +289,7 @@ declare class LocalWorkflowTrackingStore implements WorkflowTrackingStore {
288
289
  getWorkflowRunsByAssistantId(tenantId: string, assistantId: string): Promise<WorkflowRun[]>;
289
290
  getWorkflowRunsByTenantId(tenantId: string): Promise<WorkflowRun[]>;
290
291
  createRunStep(request: CreateRunStepRequest): Promise<RunStep>;
292
+ upsertRunStep(request: CreateRunStepRequest): Promise<RunStep>;
291
293
  updateRunStep(runId: string, stepId: string, updates: UpdateRunStepRequest): Promise<RunStep | null>;
292
294
  getRunSteps(runId: string): Promise<RunStep[]>;
293
295
  getRunStepsByType(runId: string, stepType: StepType): Promise<RunStep[]>;
@@ -384,6 +386,7 @@ declare class LocalChannelInstallationStore implements ChannelInstallationStore
384
386
  constructor(db: DatabaseWrapper);
385
387
  getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
386
388
  getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
389
+ getAllInstallations(channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
387
390
  createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
388
391
  updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
389
392
  deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
@@ -489,6 +492,24 @@ declare class LocalScheduleStorage implements ScheduleStorage {
489
492
  deleteOldTasks(olderThanMs: number): Promise<number>;
490
493
  }
491
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
+
492
513
  /**
493
514
  * createLocalStoreConfig
494
515
  *
@@ -541,7 +562,8 @@ declare function createLocalStoreConfig(options?: LocalStoreConfigOptions): Prom
541
562
  threadMessageQueue: LocalThreadMessageQueueStore;
542
563
  skill: LocalSkillStore;
543
564
  schedule: LocalScheduleStorage;
565
+ task: LocalTaskStore;
544
566
  checkpoint: SqliteSaver;
545
567
  }>;
546
568
 
547
- 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,
@@ -1570,6 +1590,22 @@ var LocalWorkflowTrackingStore = class {
1570
1590
  updatedAt: parseISO(now)
1571
1591
  };
1572
1592
  }
1593
+ async upsertRunStep(request) {
1594
+ const row = this.db.prepare(
1595
+ `SELECT * FROM lt_workflow_steps WHERE run_id = ? AND step_type = ? AND step_name = ?`
1596
+ ).get(request.runId, request.stepType, request.stepName);
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
+ }
1607
+ return this.createRunStep(request);
1608
+ }
1573
1609
  async updateRunStep(runId, stepId, updates) {
1574
1610
  const setClauses = [];
1575
1611
  const values = [];
@@ -1655,6 +1691,7 @@ function mapRowToStep(row) {
1655
1691
  tenantId: row.tenant_id,
1656
1692
  stepType: row.step_type,
1657
1693
  stepName: row.step_name,
1694
+ threadId: row.thread_id,
1658
1695
  edgeFrom: row.edge_from || void 0,
1659
1696
  edgeTo: row.edge_to || void 0,
1660
1697
  edgePurpose: row.edge_purpose || void 0,
@@ -2440,6 +2477,19 @@ var LocalChannelInstallationStore = class {
2440
2477
  }
2441
2478
  return rows.map(mapRow);
2442
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
+ }
2443
2493
  async createInstallation(tenantId, installationId, data) {
2444
2494
  const now = nowISO();
2445
2495
  this.db.prepare(
@@ -2689,6 +2739,8 @@ CREATE TABLE IF NOT EXISTS lt_thread_message_queue (
2689
2739
  thread_id TEXT NOT NULL,
2690
2740
  tenant_id TEXT NOT NULL,
2691
2741
  assistant_id TEXT NOT NULL,
2742
+ workspace_id TEXT,
2743
+ project_id TEXT,
2692
2744
  message_content TEXT NOT NULL,
2693
2745
  message_type TEXT NOT NULL DEFAULT 'human',
2694
2746
  sequence_order INTEGER NOT NULL DEFAULT 0,
@@ -2714,13 +2766,15 @@ var LocalThreadMessageQueueStore = class {
2714
2766
  ).get(params.threadId);
2715
2767
  const nextSeq = seqRow.next_seq;
2716
2768
  this.db.prepare(
2717
- `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)
2718
- 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
2719
2771
  ).run(
2720
2772
  id,
2721
2773
  params.threadId,
2722
2774
  params.tenantId,
2723
2775
  params.assistantId,
2776
+ params.workspaceId || null,
2777
+ params.projectId || null,
2724
2778
  JSON.stringify(params.content),
2725
2779
  params.type || "human",
2726
2780
  nextSeq,
@@ -2738,13 +2792,15 @@ var LocalThreadMessageQueueStore = class {
2738
2792
  `SELECT COALESCE(MAX(sequence_order), 0) + 1 as next_seq FROM lt_thread_message_queue WHERE thread_id = ?`
2739
2793
  ).get(params.threadId);
2740
2794
  this.db.prepare(
2741
- `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)
2742
- 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, ?, ?, ?)`
2743
2797
  ).run(
2744
2798
  id,
2745
2799
  params.threadId,
2746
2800
  params.tenantId,
2747
2801
  params.assistantId,
2802
+ params.workspaceId || null,
2803
+ params.projectId || null,
2748
2804
  JSON.stringify(params.content),
2749
2805
  params.type || "human",
2750
2806
  seqRow.next_seq,
@@ -2774,12 +2830,14 @@ var LocalThreadMessageQueueStore = class {
2774
2830
  }
2775
2831
  async getThreadsWithPendingMessages() {
2776
2832
  const rows = this.db.prepare(
2777
- `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`
2778
2834
  ).all();
2779
2835
  return rows.map((r) => ({
2780
2836
  tenantId: r.tenant_id,
2781
2837
  assistantId: r.assistant_id,
2782
- threadId: r.thread_id
2838
+ threadId: r.thread_id,
2839
+ workspaceId: r.workspace_id || void 0,
2840
+ projectId: r.project_id || void 0
2783
2841
  }));
2784
2842
  }
2785
2843
  async removeMessage(messageId) {
@@ -3312,6 +3370,192 @@ function mapRowToTask(row) {
3312
3370
  };
3313
3371
  }
3314
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
+
3315
3559
  // src/createLocalStoreConfig.ts
3316
3560
  async function createLocalStoreConfig(options = {}) {
3317
3561
  const dbPath = options.dbPath || "~/.axiom/lattice.db";
@@ -3335,6 +3579,7 @@ async function createLocalStoreConfig(options = {}) {
3335
3579
  threadMessageQueue: new LocalThreadMessageQueueStore(db),
3336
3580
  skill: new LocalSkillStore(db),
3337
3581
  schedule: new LocalScheduleStorage(db),
3582
+ task: new LocalTaskStore(db),
3338
3583
  checkpoint: import_langgraph_checkpoint_sqlite.SqliteSaver.fromConnString(dbPath)
3339
3584
  };
3340
3585
  }
@@ -3352,6 +3597,7 @@ async function createLocalStoreConfig(options = {}) {
3352
3597
  LocalProjectStore,
3353
3598
  LocalScheduleStorage,
3354
3599
  LocalSkillStore,
3600
+ LocalTaskStore,
3355
3601
  LocalTenantStore,
3356
3602
  LocalThreadMessageQueueStore,
3357
3603
  LocalThreadStore,