@axiom-lattice/local-stores 1.0.1
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 +20 -0
- package/CHANGELOG.md +10 -0
- package/LICENSE +201 -0
- package/dist/index.d.mts +547 -0
- package/dist/index.d.ts +547 -0
- package/dist/index.js +3372 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3308 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +42 -0
- package/src/createLocalStoreConfig.ts +81 -0
- package/src/database.ts +259 -0
- package/src/index.ts +44 -0
- package/src/stores/LocalA2AApiKeyStore.ts +177 -0
- package/src/stores/LocalAssistantStore.ts +149 -0
- package/src/stores/LocalChannelBindingStore.ts +204 -0
- package/src/stores/LocalChannelInstallationStore.ts +170 -0
- package/src/stores/LocalDatabaseConfigStore.ts +183 -0
- package/src/stores/LocalEvalStore.ts +510 -0
- package/src/stores/LocalMcpServerConfigStore.ts +223 -0
- package/src/stores/LocalMetricsServerConfigStore.ts +162 -0
- package/src/stores/LocalProjectStore.ts +150 -0
- package/src/stores/LocalScheduleStorage.ts +287 -0
- package/src/stores/LocalSkillStore.ts +188 -0
- package/src/stores/LocalTenantStore.ts +128 -0
- package/src/stores/LocalThreadMessageQueueStore.ts +172 -0
- package/src/stores/LocalThreadStore.ts +149 -0
- package/src/stores/LocalUserStore.ts +136 -0
- package/src/stores/LocalUserTenantLinkStore.ts +135 -0
- package/src/stores/LocalWorkflowTrackingStore.ts +299 -0
- package/src/stores/LocalWorkspaceStore.ts +143 -0
- package/tsconfig.json +23 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import { SqlJsStatic, Database } from 'sql.js';
|
|
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';
|
|
4
|
+
import { IMessageQueueStore, AddMessageParams, PendingMessage, ThreadInfo } from '@axiom-lattice/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shared SQLite database connection for local stores using sql.js (WASM).
|
|
8
|
+
*
|
|
9
|
+
* sql.js is a pure JavaScript/WASM SQLite implementation that requires
|
|
10
|
+
* no native dependencies. The database is persisted to a file on disk.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { initDatabase, closeDatabase } from "@axiom-lattice/local-stores";
|
|
15
|
+
*
|
|
16
|
+
* await initDatabase({ dbPath: "~/.axiom/lattice.db" });
|
|
17
|
+
* // ... create stores using getDatabase() ...
|
|
18
|
+
* await closeDatabase();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
interface LocalStoreOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Path to the SQLite database file.
|
|
25
|
+
* Supports `~` for home directory expansion.
|
|
26
|
+
* @default "~/.axiom/lattice.db"
|
|
27
|
+
*/
|
|
28
|
+
dbPath?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A thin wrapper around sql.js that provides an API similar to better-sqlite3.
|
|
32
|
+
*/
|
|
33
|
+
declare class DatabaseWrapper {
|
|
34
|
+
private db;
|
|
35
|
+
private dbPath;
|
|
36
|
+
constructor(sql: SqlJsStatic, dbPath: string);
|
|
37
|
+
/**
|
|
38
|
+
* Execute a SQL statement and return the wrapper for chaining (run).
|
|
39
|
+
* Automatically persists changes to disk.
|
|
40
|
+
*/
|
|
41
|
+
run(sql: string, ...params: any[]): RunResult;
|
|
42
|
+
/**
|
|
43
|
+
* Prepare and execute a query returning all matching rows as objects.
|
|
44
|
+
*/
|
|
45
|
+
prepare(sql: string): StatementWrapper;
|
|
46
|
+
/**
|
|
47
|
+
* Execute raw SQL (for DDL statements).
|
|
48
|
+
*/
|
|
49
|
+
exec(sql: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Persist the database to disk.
|
|
52
|
+
*/
|
|
53
|
+
save(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Close the database.
|
|
56
|
+
*/
|
|
57
|
+
close(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get the underlying sql.js database instance.
|
|
60
|
+
*/
|
|
61
|
+
getRawDb(): Database;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Wraps a prepared statement with a better-sqlite3-like API.
|
|
65
|
+
*/
|
|
66
|
+
declare class StatementWrapper {
|
|
67
|
+
private db;
|
|
68
|
+
private sql;
|
|
69
|
+
private parent;
|
|
70
|
+
constructor(db: Database, sql: string, parent?: DatabaseWrapper);
|
|
71
|
+
/**
|
|
72
|
+
* Execute and return all rows as objects.
|
|
73
|
+
*/
|
|
74
|
+
all(...params: any[]): unknown[];
|
|
75
|
+
/**
|
|
76
|
+
* Execute and return the first row as an object, or undefined.
|
|
77
|
+
*/
|
|
78
|
+
get(...params: any[]): unknown;
|
|
79
|
+
/**
|
|
80
|
+
* Execute without returning rows (INSERT/UPDATE/DELETE).
|
|
81
|
+
* Automatically persists changes to disk.
|
|
82
|
+
*/
|
|
83
|
+
run(...params: any[]): RunResult;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Result of a run operation.
|
|
87
|
+
*/
|
|
88
|
+
declare class RunResult {
|
|
89
|
+
private db;
|
|
90
|
+
constructor(db: Database);
|
|
91
|
+
/** Number of rows modified by the last INSERT/UPDATE/DELETE. */
|
|
92
|
+
get changes(): number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Initialize the shared SQLite database.
|
|
96
|
+
* Must be called (and awaited) before using any stores.
|
|
97
|
+
*/
|
|
98
|
+
declare function initDatabase(options?: LocalStoreOptions): Promise<DatabaseWrapper>;
|
|
99
|
+
/**
|
|
100
|
+
* Get the shared database instance.
|
|
101
|
+
* Must be called after `await initDatabase()`.
|
|
102
|
+
*/
|
|
103
|
+
declare function getDatabase(): DatabaseWrapper;
|
|
104
|
+
/**
|
|
105
|
+
* Persist and close the database connection.
|
|
106
|
+
*/
|
|
107
|
+
declare function closeDatabase(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Execute a CREATE TABLE IF NOT EXISTS statement.
|
|
110
|
+
* Helper for idempotent schema initialization.
|
|
111
|
+
*/
|
|
112
|
+
declare function ensureTable(db: DatabaseWrapper, ddl: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* ISO timestamp helper — returns current time as ISO string.
|
|
115
|
+
*/
|
|
116
|
+
declare function nowISO(): string;
|
|
117
|
+
/**
|
|
118
|
+
* Parse an ISO timestamp string back to a Date object.
|
|
119
|
+
*/
|
|
120
|
+
declare function parseISO(iso: string): Date;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Local SQLite implementation of ThreadStore.
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
declare class LocalThreadStore implements ThreadStore {
|
|
127
|
+
private db;
|
|
128
|
+
constructor(db: DatabaseWrapper);
|
|
129
|
+
getThreadsByAssistantId(tenantId: string, assistantId: string, metadataFilter?: Record<string, string>): Promise<Thread[]>;
|
|
130
|
+
getThreadById(tenantId: string, threadId: string): Promise<Thread | undefined>;
|
|
131
|
+
createThread(tenantId: string, assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
|
|
132
|
+
updateThread(tenantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
|
|
133
|
+
deleteThread(tenantId: string, threadId: string): Promise<boolean>;
|
|
134
|
+
hasThread(tenantId: string, threadId: string): Promise<boolean>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Local SQLite implementation of AssistantStore.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
declare class LocalAssistantStore implements AssistantStore {
|
|
142
|
+
private db;
|
|
143
|
+
constructor(db: DatabaseWrapper);
|
|
144
|
+
getAllAssistants(tenantId: string): Promise<Assistant[]>;
|
|
145
|
+
getAssistantById(tenantId: string, id: string): Promise<Assistant | null>;
|
|
146
|
+
createAssistant(tenantId: string, id: string, data: CreateAssistantRequest): Promise<Assistant>;
|
|
147
|
+
updateAssistant(tenantId: string, id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
|
|
148
|
+
deleteAssistant(tenantId: string, id: string): Promise<boolean>;
|
|
149
|
+
hasAssistant(tenantId: string, id: string): Promise<boolean>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Local SQLite implementation of WorkspaceStore.
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
declare class LocalWorkspaceStore implements WorkspaceStore {
|
|
157
|
+
private db;
|
|
158
|
+
constructor(db: DatabaseWrapper);
|
|
159
|
+
getAllWorkspaces(tenantId: string): Promise<Workspace[]>;
|
|
160
|
+
getWorkspaceById(tenantId: string, id: string): Promise<Workspace | null>;
|
|
161
|
+
createWorkspace(tenantId: string, id: string, data: CreateWorkspaceRequest): Promise<Workspace>;
|
|
162
|
+
updateWorkspace(tenantId: string, id: string, updates: UpdateWorkspaceRequest): Promise<Workspace | null>;
|
|
163
|
+
deleteWorkspace(tenantId: string, id: string): Promise<boolean>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Local SQLite implementation of ProjectStore.
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
declare class LocalProjectStore implements ProjectStore {
|
|
171
|
+
private db;
|
|
172
|
+
constructor(db: DatabaseWrapper);
|
|
173
|
+
getProjectsByWorkspace(tenantId: string, workspaceId: string): Promise<Project[]>;
|
|
174
|
+
getProjectById(tenantId: string, id: string): Promise<Project | null>;
|
|
175
|
+
createProject(tenantId: string, workspaceId: string, id: string, data: CreateProjectRequest): Promise<Project>;
|
|
176
|
+
updateProject(tenantId: string, id: string, updates: UpdateProjectRequest): Promise<Project | null>;
|
|
177
|
+
deleteProject(tenantId: string, id: string): Promise<boolean>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Local SQLite implementation of UserStore.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
declare class LocalUserStore implements UserStore {
|
|
185
|
+
private db;
|
|
186
|
+
constructor(db: DatabaseWrapper);
|
|
187
|
+
getAllUsers(): Promise<User[]>;
|
|
188
|
+
getUserById(id: string): Promise<User | null>;
|
|
189
|
+
getUserByEmail(email: string): Promise<User | null>;
|
|
190
|
+
createUser(id: string, data: CreateUserRequest): Promise<User>;
|
|
191
|
+
updateUser(id: string, updates: UpdateUserRequest): Promise<User | null>;
|
|
192
|
+
deleteUser(id: string): Promise<boolean>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Local SQLite implementation of TenantStore.
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
declare class LocalTenantStore implements TenantStore {
|
|
200
|
+
private db;
|
|
201
|
+
constructor(db: DatabaseWrapper);
|
|
202
|
+
getAllTenants(): Promise<Tenant[]>;
|
|
203
|
+
getTenantById(id: string): Promise<Tenant | null>;
|
|
204
|
+
createTenant(id: string, data: CreateTenantRequest): Promise<Tenant>;
|
|
205
|
+
updateTenant(id: string, updates: UpdateTenantRequest): Promise<Tenant | null>;
|
|
206
|
+
deleteTenant(id: string): Promise<boolean>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Local SQLite implementation of UserTenantLinkStore.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
declare class LocalUserTenantLinkStore implements UserTenantLinkStore {
|
|
214
|
+
private db;
|
|
215
|
+
constructor(db: DatabaseWrapper);
|
|
216
|
+
getTenantsByUser(userId: string): Promise<UserTenantLink[]>;
|
|
217
|
+
getUsersByTenant(tenantId: string): Promise<UserTenantLink[]>;
|
|
218
|
+
getLink(userId: string, tenantId: string): Promise<UserTenantLink | null>;
|
|
219
|
+
createLink(data: CreateUserTenantLinkRequest): Promise<UserTenantLink>;
|
|
220
|
+
updateLink(userId: string, tenantId: string, updates: UpdateUserTenantLinkRequest): Promise<UserTenantLink | null>;
|
|
221
|
+
deleteLink(userId: string, tenantId: string): Promise<boolean>;
|
|
222
|
+
hasLink(userId: string, tenantId: string): Promise<boolean>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Local SQLite implementation of DatabaseConfigStore.
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
declare class LocalDatabaseConfigStore implements DatabaseConfigStore {
|
|
230
|
+
private db;
|
|
231
|
+
constructor(db: DatabaseWrapper);
|
|
232
|
+
getAllConfigs(tenantId: string): Promise<DatabaseConfigEntry[]>;
|
|
233
|
+
getAllConfigsWithoutTenant(): Promise<DatabaseConfigEntry[]>;
|
|
234
|
+
getConfigById(tenantId: string, id: string): Promise<DatabaseConfigEntry | null>;
|
|
235
|
+
getConfigByKey(tenantId: string, key: string): Promise<DatabaseConfigEntry | null>;
|
|
236
|
+
createConfig(tenantId: string, id: string, data: CreateDatabaseConfigRequest): Promise<DatabaseConfigEntry>;
|
|
237
|
+
updateConfig(tenantId: string, id: string, updates: Partial<UpdateDatabaseConfigRequest>): Promise<DatabaseConfigEntry | null>;
|
|
238
|
+
deleteConfig(tenantId: string, id: string): Promise<boolean>;
|
|
239
|
+
hasConfig(tenantId: string, id: string): Promise<boolean>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Local SQLite implementation of MetricsServerConfigStore.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
declare class LocalMetricsServerConfigStore implements MetricsServerConfigStore {
|
|
247
|
+
private db;
|
|
248
|
+
constructor(db: DatabaseWrapper);
|
|
249
|
+
getAllConfigs(tenantId: string): Promise<MetricsServerConfigEntry[]>;
|
|
250
|
+
getAllConfigsWithoutTenant(): Promise<MetricsServerConfigEntry[]>;
|
|
251
|
+
getConfigById(tenantId: string, id: string): Promise<MetricsServerConfigEntry | null>;
|
|
252
|
+
getConfigByKey(tenantId: string, key: string): Promise<MetricsServerConfigEntry | null>;
|
|
253
|
+
createConfig(tenantId: string, id: string, data: CreateMetricsServerConfigRequest): Promise<MetricsServerConfigEntry>;
|
|
254
|
+
updateConfig(tenantId: string, id: string, updates: Partial<UpdateMetricsServerConfigRequest>): Promise<MetricsServerConfigEntry | null>;
|
|
255
|
+
deleteConfig(tenantId: string, id: string): Promise<boolean>;
|
|
256
|
+
hasConfig(tenantId: string, id: string): Promise<boolean>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Local SQLite implementation of McpServerConfigStore.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
declare class LocalMcpServerConfigStore implements McpServerConfigStore {
|
|
264
|
+
private db;
|
|
265
|
+
constructor(db: DatabaseWrapper);
|
|
266
|
+
getAllConfigs(tenantId: string): Promise<McpServerConfigEntry[]>;
|
|
267
|
+
getAllConfigsWithoutTenant(): Promise<McpServerConfigEntry[]>;
|
|
268
|
+
getConfigById(tenantId: string, id: string): Promise<McpServerConfigEntry | null>;
|
|
269
|
+
getConfigByKey(tenantId: string, key: string): Promise<McpServerConfigEntry | null>;
|
|
270
|
+
createConfig(tenantId: string, id: string, data: CreateMcpServerConfigRequest): Promise<McpServerConfigEntry>;
|
|
271
|
+
updateConfig(tenantId: string, id: string, updates: Partial<UpdateMcpServerConfigRequest>): Promise<McpServerConfigEntry | null>;
|
|
272
|
+
deleteConfig(tenantId: string, id: string): Promise<boolean>;
|
|
273
|
+
hasConfig(tenantId: string, id: string): Promise<boolean>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Local SQLite implementation of WorkflowTrackingStore.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
declare class LocalWorkflowTrackingStore implements WorkflowTrackingStore {
|
|
281
|
+
private db;
|
|
282
|
+
constructor(db: DatabaseWrapper);
|
|
283
|
+
createWorkflowRun(request: CreateWorkflowRunRequest): Promise<WorkflowRun>;
|
|
284
|
+
getWorkflowRun(runId: string): Promise<WorkflowRun | null>;
|
|
285
|
+
updateWorkflowRun(runId: string, updates: UpdateWorkflowRunRequest): Promise<WorkflowRun | null>;
|
|
286
|
+
deleteWorkflowRun(runId: string): Promise<void>;
|
|
287
|
+
getWorkflowRunsByThreadId(tenantId: string, threadId: string): Promise<WorkflowRun[]>;
|
|
288
|
+
getWorkflowRunsByAssistantId(tenantId: string, assistantId: string): Promise<WorkflowRun[]>;
|
|
289
|
+
getWorkflowRunsByTenantId(tenantId: string): Promise<WorkflowRun[]>;
|
|
290
|
+
createRunStep(request: CreateRunStepRequest): Promise<RunStep>;
|
|
291
|
+
updateRunStep(runId: string, stepId: string, updates: UpdateRunStepRequest): Promise<RunStep | null>;
|
|
292
|
+
getRunSteps(runId: string): Promise<RunStep[]>;
|
|
293
|
+
getRunStepsByType(runId: string, stepType: StepType): Promise<RunStep[]>;
|
|
294
|
+
getInterruptedSteps(runId: string): Promise<RunStep[]>;
|
|
295
|
+
private getStepById;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Local SQLite implementation of EvalStore.
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
declare class LocalEvalStore implements EvalStore {
|
|
303
|
+
private db;
|
|
304
|
+
constructor(db: DatabaseWrapper);
|
|
305
|
+
getProjectsByTenant(tenantId: string): Promise<EvalProject[]>;
|
|
306
|
+
getProjectById(tenantId: string, id: string): Promise<EvalProject | null>;
|
|
307
|
+
createProject(tenantId: string, id: string, data: CreateEvalProjectRequest): Promise<EvalProject>;
|
|
308
|
+
updateProject(tenantId: string, id: string, updates: Partial<CreateEvalProjectRequest>): Promise<EvalProject | null>;
|
|
309
|
+
deleteProject(tenantId: string, id: string): Promise<boolean>;
|
|
310
|
+
getSuitesByProject(tenantId: string, projectId: string): Promise<EvalSuite[]>;
|
|
311
|
+
getSuiteById(tenantId: string, id: string): Promise<EvalSuite | null>;
|
|
312
|
+
createSuite(tenantId: string, projectId: string, id: string, data: CreateEvalSuiteRequest): Promise<EvalSuite>;
|
|
313
|
+
updateSuite(tenantId: string, id: string, updates: Partial<CreateEvalSuiteRequest>): Promise<EvalSuite | null>;
|
|
314
|
+
deleteSuite(tenantId: string, id: string): Promise<boolean>;
|
|
315
|
+
getCasesBySuite(tenantId: string, suiteId: string): Promise<EvalCase[]>;
|
|
316
|
+
getCaseById(tenantId: string, id: string): Promise<EvalCase | null>;
|
|
317
|
+
createCase(tenantId: string, suiteId: string, id: string, data: CreateEvalCaseRequest): Promise<EvalCase>;
|
|
318
|
+
updateCase(tenantId: string, id: string, updates: Partial<CreateEvalCaseRequest>): Promise<EvalCase | null>;
|
|
319
|
+
deleteCase(tenantId: string, id: string): Promise<boolean>;
|
|
320
|
+
getRunsByTenant(tenantId: string, opts?: {
|
|
321
|
+
projectId?: string;
|
|
322
|
+
status?: string;
|
|
323
|
+
}): Promise<EvalRun[]>;
|
|
324
|
+
getRunById(tenantId: string, id: string): Promise<EvalRun | null>;
|
|
325
|
+
createRun(tenantId: string, projectId: string, id: string, data: CreateEvalRunRequest): Promise<EvalRun>;
|
|
326
|
+
updateRunStatus(tenantId: string, id: string, updates: {
|
|
327
|
+
status?: EvalRun["status"];
|
|
328
|
+
passedCases?: number;
|
|
329
|
+
failedCases?: number;
|
|
330
|
+
avgScore?: number;
|
|
331
|
+
error?: string;
|
|
332
|
+
completedAt?: Date;
|
|
333
|
+
}): Promise<EvalRun | null>;
|
|
334
|
+
deleteRun(tenantId: string, id: string): Promise<boolean>;
|
|
335
|
+
getResultsByRun(tenantId: string, runId: string): Promise<EvalRunResult[]>;
|
|
336
|
+
private getRunResultById;
|
|
337
|
+
createRunResult(tenantId: string, runId: string, id: string, data: Omit<EvalRunResult, "id" | "runId" | "createdAt">): Promise<EvalRunResult>;
|
|
338
|
+
updateRunResult(tenantId: string, id: string, updates: Partial<EvalRunResult>): Promise<EvalRunResult | null>;
|
|
339
|
+
getProjectReport(tenantId: string, projectId: string): Promise<EvalProjectReport | null>;
|
|
340
|
+
private mapRowToProject;
|
|
341
|
+
private mapRowToSuite;
|
|
342
|
+
private mapRowToCase;
|
|
343
|
+
private mapRowToRun;
|
|
344
|
+
private mapRowToRunResult;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Local SQLite implementation of ChannelBindingStore (BindingRegistry).
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
declare class LocalChannelBindingStore implements BindingRegistry {
|
|
352
|
+
private db;
|
|
353
|
+
constructor(db: DatabaseWrapper);
|
|
354
|
+
resolve(params: {
|
|
355
|
+
channel: string;
|
|
356
|
+
senderId: string;
|
|
357
|
+
channelInstallationId: string;
|
|
358
|
+
tenantId: string;
|
|
359
|
+
}): Promise<Binding | null>;
|
|
360
|
+
create(input: CreateBindingInput): Promise<Binding>;
|
|
361
|
+
update(id: string, patch: Partial<Binding>): Promise<Binding>;
|
|
362
|
+
delete(id: string): Promise<void>;
|
|
363
|
+
list(params: {
|
|
364
|
+
channel?: string;
|
|
365
|
+
agentId?: string;
|
|
366
|
+
tenantId: string;
|
|
367
|
+
channelInstallationId?: string;
|
|
368
|
+
limit?: number;
|
|
369
|
+
offset?: number;
|
|
370
|
+
}): Promise<Binding[]>;
|
|
371
|
+
import(bindings: CreateBindingInput[]): Promise<Binding[]>;
|
|
372
|
+
export(params: {
|
|
373
|
+
tenantId: string;
|
|
374
|
+
}): Promise<Binding[]>;
|
|
375
|
+
private getById;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Local SQLite implementation of ChannelInstallationStore.
|
|
380
|
+
*/
|
|
381
|
+
|
|
382
|
+
declare class LocalChannelInstallationStore implements ChannelInstallationStore {
|
|
383
|
+
private db;
|
|
384
|
+
constructor(db: DatabaseWrapper);
|
|
385
|
+
getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
|
|
386
|
+
getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
|
|
387
|
+
createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
|
|
388
|
+
updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
|
|
389
|
+
deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Local SQLite implementation of A2AApiKeyStore.
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
declare class LocalA2AApiKeyStore implements A2AApiKeyStore {
|
|
397
|
+
private db;
|
|
398
|
+
constructor(db: DatabaseWrapper);
|
|
399
|
+
findByKey(key: string): Promise<A2AApiKeyRecord | null>;
|
|
400
|
+
list(params: {
|
|
401
|
+
tenantId?: string;
|
|
402
|
+
limit?: number;
|
|
403
|
+
offset?: number;
|
|
404
|
+
}): Promise<A2AApiKeyRecord[]>;
|
|
405
|
+
create(input: CreateA2AApiKeyInput): Promise<A2AApiKeyRecord>;
|
|
406
|
+
disable(id: string): Promise<A2AApiKeyRecord>;
|
|
407
|
+
enable(id: string): Promise<A2AApiKeyRecord>;
|
|
408
|
+
rotate(id: string): Promise<A2AApiKeyRecord>;
|
|
409
|
+
delete(id: string): Promise<void>;
|
|
410
|
+
loadIntoMap(): Promise<Map<string, A2AApiKeyEntry>>;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Local SQLite implementation of IMessageQueueStore.
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
declare class LocalThreadMessageQueueStore implements IMessageQueueStore {
|
|
418
|
+
private db;
|
|
419
|
+
constructor(db: DatabaseWrapper);
|
|
420
|
+
addMessage(params: AddMessageParams): Promise<PendingMessage>;
|
|
421
|
+
addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
|
|
422
|
+
getPendingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
423
|
+
getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
|
|
424
|
+
getQueueSize(threadId: string): Promise<number>;
|
|
425
|
+
getThreadsWithPendingMessages(): Promise<ThreadInfo[]>;
|
|
426
|
+
removeMessage(messageId: string): Promise<boolean>;
|
|
427
|
+
clearMessages(threadId: string): Promise<void>;
|
|
428
|
+
markProcessing(messageId: string): Promise<void>;
|
|
429
|
+
resetProcessingToPending(threadId: string): Promise<number>;
|
|
430
|
+
private getById;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Local SQLite implementation of SkillStore.
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
declare class LocalSkillStore implements SkillStore {
|
|
438
|
+
private db;
|
|
439
|
+
constructor(db: DatabaseWrapper);
|
|
440
|
+
getAllSkills(tenantId: string, _context?: SkillStoreContext): Promise<Skill[]>;
|
|
441
|
+
getSkillById(tenantId: string, id: string, _context?: SkillStoreContext): Promise<Skill | null>;
|
|
442
|
+
createSkill(tenantId: string, id: string, data: CreateSkillRequest, _context?: SkillStoreContext): Promise<Skill>;
|
|
443
|
+
updateSkill(tenantId: string, id: string, updates: Partial<CreateSkillRequest>, _context?: SkillStoreContext): Promise<Skill | null>;
|
|
444
|
+
deleteSkill(tenantId: string, id: string, _context?: SkillStoreContext): Promise<boolean>;
|
|
445
|
+
hasSkill(tenantId: string, id: string, _context?: SkillStoreContext): Promise<boolean>;
|
|
446
|
+
searchByMetadata(tenantId: string, metadataKey: string, metadataValue: string, _context?: SkillStoreContext): Promise<Skill[]>;
|
|
447
|
+
filterByCompatibility(tenantId: string, compatibility: string, _context?: SkillStoreContext): Promise<Skill[]>;
|
|
448
|
+
filterByLicense(tenantId: string, license: string, _context?: SkillStoreContext): Promise<Skill[]>;
|
|
449
|
+
getSubSkills(tenantId: string, parentSkillName: string, _context?: SkillStoreContext): Promise<Skill[]>;
|
|
450
|
+
listSkillResources?(_tenantId: string, _id: string, _context?: SkillStoreContext): Promise<string[]>;
|
|
451
|
+
loadSkillResource?(_tenantId: string, _id: string, _resourcePath: string, _context?: SkillStoreContext): Promise<string | null>;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Local SQLite implementation of ScheduleStorage.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
declare class LocalScheduleStorage implements ScheduleStorage {
|
|
459
|
+
private db;
|
|
460
|
+
constructor(db: DatabaseWrapper);
|
|
461
|
+
save(task: ScheduledTaskDefinition): Promise<void>;
|
|
462
|
+
get(taskId: string): Promise<ScheduledTaskDefinition | null>;
|
|
463
|
+
update(taskId: string, updates: Partial<ScheduledTaskDefinition>): Promise<void>;
|
|
464
|
+
delete(taskId: string): Promise<void>;
|
|
465
|
+
getActiveTasks(): Promise<ScheduledTaskDefinition[]>;
|
|
466
|
+
getTasksByType(taskType: string): Promise<ScheduledTaskDefinition[]>;
|
|
467
|
+
getTasksByStatus(status: ScheduledTaskStatus): Promise<ScheduledTaskDefinition[]>;
|
|
468
|
+
getTasksByExecutionType(executionType: ScheduleExecutionType): Promise<ScheduledTaskDefinition[]>;
|
|
469
|
+
getTasksByAssistantId(assistantId: string): Promise<ScheduledTaskDefinition[]>;
|
|
470
|
+
getTasksByThreadId(threadId: string): Promise<ScheduledTaskDefinition[]>;
|
|
471
|
+
getAllTasks(filters?: {
|
|
472
|
+
tenantId?: string;
|
|
473
|
+
status?: ScheduledTaskStatus;
|
|
474
|
+
executionType?: ScheduleExecutionType;
|
|
475
|
+
taskType?: string;
|
|
476
|
+
assistantId?: string;
|
|
477
|
+
threadId?: string;
|
|
478
|
+
limit?: number;
|
|
479
|
+
offset?: number;
|
|
480
|
+
}): Promise<ScheduledTaskDefinition[]>;
|
|
481
|
+
countTasks(filters?: {
|
|
482
|
+
tenantId?: string;
|
|
483
|
+
status?: ScheduledTaskStatus;
|
|
484
|
+
executionType?: ScheduleExecutionType;
|
|
485
|
+
taskType?: string;
|
|
486
|
+
assistantId?: string;
|
|
487
|
+
threadId?: string;
|
|
488
|
+
}): Promise<number>;
|
|
489
|
+
deleteOldTasks(olderThanMs: number): Promise<number>;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* createLocalStoreConfig
|
|
494
|
+
*
|
|
495
|
+
* Creates a map of all local SQLite store instances from a single database,
|
|
496
|
+
* ready to pass directly to configureStores().
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ```ts
|
|
500
|
+
* import { createLocalStoreConfig } from "@axiom-lattice/local-stores";
|
|
501
|
+
* import { configureStores } from "@axiom-lattice/core";
|
|
502
|
+
*
|
|
503
|
+
* const stores = await createLocalStoreConfig({ dbPath: "~/.axiom/lattice.db" });
|
|
504
|
+
* await configureStores(stores);
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
interface LocalStoreConfigOptions {
|
|
509
|
+
/**
|
|
510
|
+
* Path to the SQLite database file.
|
|
511
|
+
* Supports `~` for home directory expansion.
|
|
512
|
+
* @default "~/.axiom/lattice.db"
|
|
513
|
+
*/
|
|
514
|
+
dbPath?: string;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Creates a full set of local (SQLite-backed) stores sharing a single database.
|
|
518
|
+
*
|
|
519
|
+
* @returns An object with all store instances, ready for `configureStores()`.
|
|
520
|
+
*
|
|
521
|
+
* @remarks
|
|
522
|
+
* - The `schedule` key is registered via ScheduleLatticeManager (not StoreLatticeManager).
|
|
523
|
+
* - Call `closeDatabase()` from `@axiom-lattice/local-stores` to gracefully close the connection.
|
|
524
|
+
*/
|
|
525
|
+
declare function createLocalStoreConfig(options?: LocalStoreConfigOptions): Promise<{
|
|
526
|
+
thread: LocalThreadStore;
|
|
527
|
+
assistant: LocalAssistantStore;
|
|
528
|
+
workspace: LocalWorkspaceStore;
|
|
529
|
+
project: LocalProjectStore;
|
|
530
|
+
user: LocalUserStore;
|
|
531
|
+
tenant: LocalTenantStore;
|
|
532
|
+
userTenantLink: LocalUserTenantLinkStore;
|
|
533
|
+
database: LocalDatabaseConfigStore;
|
|
534
|
+
metrics: LocalMetricsServerConfigStore;
|
|
535
|
+
mcp: LocalMcpServerConfigStore;
|
|
536
|
+
workflowTracking: LocalWorkflowTrackingStore;
|
|
537
|
+
eval: LocalEvalStore;
|
|
538
|
+
channelBinding: LocalChannelBindingStore;
|
|
539
|
+
channelInstallation: LocalChannelInstallationStore;
|
|
540
|
+
a2aApiKey: LocalA2AApiKeyStore;
|
|
541
|
+
threadMessageQueue: LocalThreadMessageQueueStore;
|
|
542
|
+
skill: LocalSkillStore;
|
|
543
|
+
schedule: LocalScheduleStorage;
|
|
544
|
+
checkpoint: SqliteSaver;
|
|
545
|
+
}>;
|
|
546
|
+
|
|
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 };
|