@axiom-lattice/gateway 2.1.15 → 2.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -223,71 +223,8 @@ async function resume_stream({
223
223
  };
224
224
  }
225
225
 
226
- // src/stores/assistant_store.ts
227
- var AssistantStore = class {
228
- constructor() {
229
- this.assistants = /* @__PURE__ */ new Map();
230
- }
231
- /**
232
- * Get all assistants
233
- */
234
- getAllAssistants() {
235
- return Array.from(this.assistants.values());
236
- }
237
- /**
238
- * Get assistant by ID
239
- */
240
- getAssistantById(id) {
241
- return this.assistants.get(id);
242
- }
243
- /**
244
- * Create a new assistant
245
- */
246
- createAssistant(id, data) {
247
- const now = /* @__PURE__ */ new Date();
248
- const assistant = {
249
- id,
250
- name: data.name,
251
- description: data.description,
252
- graphDefinition: data.graphDefinition,
253
- createdAt: now,
254
- updatedAt: now
255
- };
256
- this.assistants.set(id, assistant);
257
- return assistant;
258
- }
259
- /**
260
- * Update an existing assistant
261
- */
262
- updateAssistant(id, updates) {
263
- const existing = this.assistants.get(id);
264
- if (!existing) {
265
- return null;
266
- }
267
- const updated = {
268
- ...existing,
269
- ...updates,
270
- updatedAt: /* @__PURE__ */ new Date()
271
- };
272
- this.assistants.set(id, updated);
273
- return updated;
274
- }
275
- /**
276
- * Delete an assistant by ID
277
- */
278
- deleteAssistant(id) {
279
- return this.assistants.delete(id);
280
- }
281
- /**
282
- * Check if assistant exists
283
- */
284
- hasAssistant(id) {
285
- return this.assistants.has(id);
286
- }
287
- };
288
- var assistantStore = new AssistantStore();
289
-
290
226
  // src/controllers/assistant.ts
227
+ import { getStoreLattice } from "@axiom-lattice/core";
291
228
  import { randomUUID } from "crypto";
292
229
  import { getAllAgentConfigs } from "@axiom-lattice/core";
293
230
  function convertAgentConfigToAssistant(config) {
@@ -308,7 +245,9 @@ async function getAssistantList(request, reply) {
308
245
  const codeConfiguredAssistants = agentConfigs.map(
309
246
  convertAgentConfigToAssistant
310
247
  );
311
- const storedAssistants = assistantStore.getAllAssistants();
248
+ const storeLattice = getStoreLattice("default", "assistant");
249
+ const assistantStore = storeLattice.store;
250
+ const storedAssistants = await assistantStore.getAllAssistants();
312
251
  const assistantMap = /* @__PURE__ */ new Map();
313
252
  codeConfiguredAssistants.forEach((assistant) => {
314
253
  assistantMap.set(assistant.id, assistant);
@@ -328,7 +267,9 @@ async function getAssistantList(request, reply) {
328
267
  }
329
268
  async function getAssistant(request, reply) {
330
269
  const { id } = request.params;
331
- let assistant = assistantStore.getAssistantById(id);
270
+ const storeLattice = getStoreLattice("default", "assistant");
271
+ const assistantStore = storeLattice.store;
272
+ let assistant = await assistantStore.getAssistantById(id);
332
273
  if (!assistant) {
333
274
  const agentConfigs = await getAllAgentConfigs();
334
275
  const agentConfig = agentConfigs.find((config) => config.key === id);
@@ -363,7 +304,9 @@ async function createAssistant(request, reply) {
363
304
  });
364
305
  }
365
306
  const id = randomUUID();
366
- const newAssistant = assistantStore.createAssistant(id, data);
307
+ const storeLattice = getStoreLattice("default", "assistant");
308
+ const assistantStore = storeLattice.store;
309
+ const newAssistant = await assistantStore.createAssistant(id, data);
367
310
  return reply.status(201).send({
368
311
  success: true,
369
312
  message: "Successfully created assistant",
@@ -381,13 +324,16 @@ async function updateAssistant(request, reply) {
381
324
  message: "Cannot update code-configured assistant. Only stored assistants can be updated."
382
325
  });
383
326
  }
384
- if (!assistantStore.hasAssistant(id)) {
327
+ const storeLattice = getStoreLattice("default", "assistant");
328
+ const assistantStore = storeLattice.store;
329
+ const exists = await assistantStore.hasAssistant(id);
330
+ if (!exists) {
385
331
  return reply.status(404).send({
386
332
  success: false,
387
333
  message: "Assistant not found"
388
334
  });
389
335
  }
390
- const updatedAssistant = assistantStore.updateAssistant(id, updates);
336
+ const updatedAssistant = await assistantStore.updateAssistant(id, updates);
391
337
  if (!updatedAssistant) {
392
338
  return reply.status(500).send({
393
339
  success: false,
@@ -410,13 +356,16 @@ async function deleteAssistant(request, reply) {
410
356
  message: "Cannot delete code-configured assistant. Only stored assistants can be deleted."
411
357
  });
412
358
  }
413
- if (!assistantStore.hasAssistant(id)) {
359
+ const storeLattice = getStoreLattice("default", "assistant");
360
+ const assistantStore = storeLattice.store;
361
+ const exists = await assistantStore.hasAssistant(id);
362
+ if (!exists) {
414
363
  return reply.status(404).send({
415
364
  success: false,
416
365
  message: "Assistant not found"
417
366
  });
418
367
  }
419
- const deleted = assistantStore.deleteAssistant(id);
368
+ const deleted = await assistantStore.deleteAssistant(id);
420
369
  if (!deleted) {
421
370
  return reply.status(500).send({
422
371
  success: false,
@@ -749,102 +698,14 @@ var triggerAgentTask = async (request, reply) => {
749
698
  }
750
699
  };
751
700
 
752
- // src/stores/thread_store.ts
753
- var ThreadStore = class {
754
- constructor() {
755
- // Map<assistantId, Map<threadId, Thread>>
756
- this.threads = /* @__PURE__ */ new Map();
757
- }
758
- /**
759
- * Get all threads for a specific assistant
760
- */
761
- getThreadsByAssistantId(assistantId) {
762
- const assistantThreads = this.threads.get(assistantId);
763
- if (!assistantThreads) {
764
- return [];
765
- }
766
- return Array.from(assistantThreads.values());
767
- }
768
- /**
769
- * Get a thread by ID for a specific assistant
770
- */
771
- getThreadById(assistantId, threadId) {
772
- const assistantThreads = this.threads.get(assistantId);
773
- if (!assistantThreads) {
774
- return void 0;
775
- }
776
- return assistantThreads.get(threadId);
777
- }
778
- /**
779
- * Create a new thread for an assistant
780
- */
781
- createThread(assistantId, threadId, data) {
782
- const now = /* @__PURE__ */ new Date();
783
- const thread = {
784
- id: threadId,
785
- assistantId,
786
- metadata: data.metadata || {},
787
- createdAt: now,
788
- updatedAt: now
789
- };
790
- if (!this.threads.has(assistantId)) {
791
- this.threads.set(assistantId, /* @__PURE__ */ new Map());
792
- }
793
- const assistantThreads = this.threads.get(assistantId);
794
- assistantThreads.set(threadId, thread);
795
- return thread;
796
- }
797
- /**
798
- * Update an existing thread
799
- */
800
- updateThread(assistantId, threadId, updates) {
801
- const assistantThreads = this.threads.get(assistantId);
802
- if (!assistantThreads) {
803
- return null;
804
- }
805
- const existing = assistantThreads.get(threadId);
806
- if (!existing) {
807
- return null;
808
- }
809
- const updated = {
810
- ...existing,
811
- metadata: {
812
- ...existing.metadata,
813
- ...updates.metadata || {}
814
- },
815
- updatedAt: /* @__PURE__ */ new Date()
816
- };
817
- assistantThreads.set(threadId, updated);
818
- return updated;
819
- }
820
- /**
821
- * Delete a thread by ID
822
- */
823
- deleteThread(assistantId, threadId) {
824
- const assistantThreads = this.threads.get(assistantId);
825
- if (!assistantThreads) {
826
- return false;
827
- }
828
- return assistantThreads.delete(threadId);
829
- }
830
- /**
831
- * Check if thread exists
832
- */
833
- hasThread(assistantId, threadId) {
834
- const assistantThreads = this.threads.get(assistantId);
835
- if (!assistantThreads) {
836
- return false;
837
- }
838
- return assistantThreads.has(threadId);
839
- }
840
- };
841
- var threadStore = new ThreadStore();
842
-
843
701
  // src/controllers/threads.ts
702
+ import { getStoreLattice as getStoreLattice2 } from "@axiom-lattice/core";
844
703
  import { randomUUID as randomUUID2 } from "crypto";
845
704
  async function getThreadList(request, reply) {
846
705
  const { assistantId } = request.params;
847
- const threads = threadStore.getThreadsByAssistantId(assistantId);
706
+ const storeLattice = getStoreLattice2("default", "thread");
707
+ const threadStore = storeLattice.store;
708
+ const threads = await threadStore.getThreadsByAssistantId(assistantId);
848
709
  return {
849
710
  success: true,
850
711
  message: "Successfully retrieved thread list",
@@ -856,7 +717,9 @@ async function getThreadList(request, reply) {
856
717
  }
857
718
  async function getThread(request, reply) {
858
719
  const { assistantId, threadId } = request.params;
859
- const thread = threadStore.getThreadById(assistantId, threadId);
720
+ const storeLattice = getStoreLattice2("default", "thread");
721
+ const threadStore = storeLattice.store;
722
+ const thread = await threadStore.getThreadById(assistantId, threadId);
860
723
  if (!thread) {
861
724
  return reply.status(404).send({
862
725
  success: false,
@@ -873,7 +736,9 @@ async function createThread(request, reply) {
873
736
  const { assistantId } = request.params;
874
737
  const data = request.body;
875
738
  const threadId = randomUUID2();
876
- const newThread = threadStore.createThread(assistantId, threadId, data);
739
+ const storeLattice = getStoreLattice2("default", "thread");
740
+ const threadStore = storeLattice.store;
741
+ const newThread = await threadStore.createThread(assistantId, threadId, data);
877
742
  return reply.status(201).send({
878
743
  success: true,
879
744
  message: "Successfully created thread",
@@ -883,13 +748,16 @@ async function createThread(request, reply) {
883
748
  async function updateThread(request, reply) {
884
749
  const { assistantId, threadId } = request.params;
885
750
  const updates = request.body;
886
- if (!threadStore.hasThread(assistantId, threadId)) {
751
+ const storeLattice = getStoreLattice2("default", "thread");
752
+ const threadStore = storeLattice.store;
753
+ const exists = await threadStore.hasThread(assistantId, threadId);
754
+ if (!exists) {
887
755
  return reply.status(404).send({
888
756
  success: false,
889
757
  message: "Thread not found"
890
758
  });
891
759
  }
892
- const updatedThread = threadStore.updateThread(
760
+ const updatedThread = await threadStore.updateThread(
893
761
  assistantId,
894
762
  threadId,
895
763
  updates
@@ -908,13 +776,16 @@ async function updateThread(request, reply) {
908
776
  }
909
777
  async function deleteThread(request, reply) {
910
778
  const { assistantId, threadId } = request.params;
911
- if (!threadStore.hasThread(assistantId, threadId)) {
779
+ const storeLattice = getStoreLattice2("default", "thread");
780
+ const threadStore = storeLattice.store;
781
+ const exists = await threadStore.hasThread(assistantId, threadId);
782
+ if (!exists) {
912
783
  return reply.status(404).send({
913
784
  success: false,
914
785
  message: "Thread not found"
915
786
  });
916
787
  }
917
- const deleted = threadStore.deleteThread(assistantId, threadId);
788
+ const deleted = await threadStore.deleteThread(assistantId, threadId);
918
789
  if (!deleted) {
919
790
  return reply.status(500).send({
920
791
  success: false,