@axiom-lattice/gateway 2.1.10 → 2.1.12
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 +8 -8
- package/CHANGELOG.md +14 -0
- package/dist/index.js +432 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +418 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/controllers/assistant.ts +274 -3
- package/src/controllers/threads.ts +189 -0
- package/src/routes/index.ts +54 -1
- package/src/services/agent_service.ts +1 -3
- package/src/stores/assistant_store.ts +82 -0
- package/src/stores/thread_store.ts +115 -0
- package/src/types/index.ts +14 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.12 build /home/runner/work/agentic/agentic/packages/gateway
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m46.92 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m100.58 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 131ms
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m49.24 KB[39m
|
|
16
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m100.67 KB[39m
|
|
17
|
+
[32mCJS[39m ⚡️ Build success in 131ms
|
|
18
18
|
[34mDTS[39m Build start
|
|
19
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
+
[32mDTS[39m ⚡️ Build success in 7072ms
|
|
20
20
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.32 KB[39m
|
|
21
21
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.32 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2d9f075: lattice app
|
|
8
|
+
|
|
9
|
+
## 2.1.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 548951e: fix files shared context
|
|
14
|
+
- Updated dependencies [548951e]
|
|
15
|
+
- @axiom-lattice/core@2.1.8
|
|
16
|
+
|
|
3
17
|
## 2.1.10
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -100,11 +100,10 @@ async function agent_stream({
|
|
|
100
100
|
run_id
|
|
101
101
|
}) {
|
|
102
102
|
const runnable_agent = (0, import_core.getAgentClient)(assistant_id);
|
|
103
|
-
const {
|
|
103
|
+
const { message, ...rest } = input;
|
|
104
104
|
let messages = [];
|
|
105
105
|
if (!command) {
|
|
106
106
|
const humanMessage = new import_messages.HumanMessage(message);
|
|
107
|
-
humanMessage.additional_kwargs = { files };
|
|
108
107
|
messages = [humanMessage];
|
|
109
108
|
}
|
|
110
109
|
const chunkBuffer = getOrCreateChunkBuffer();
|
|
@@ -209,7 +208,6 @@ async function agent_messages({
|
|
|
209
208
|
id: message.id,
|
|
210
209
|
role: message.getType(),
|
|
211
210
|
content: message.content,
|
|
212
|
-
files: message.additional_kwargs.files,
|
|
213
211
|
...message.lc_kwargs
|
|
214
212
|
}));
|
|
215
213
|
const new_messages = messagesArray;
|
|
@@ -250,6 +248,226 @@ async function resume_stream({
|
|
|
250
248
|
};
|
|
251
249
|
}
|
|
252
250
|
|
|
251
|
+
// src/stores/assistant_store.ts
|
|
252
|
+
var AssistantStore = class {
|
|
253
|
+
constructor() {
|
|
254
|
+
this.assistants = /* @__PURE__ */ new Map();
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get all assistants
|
|
258
|
+
*/
|
|
259
|
+
getAllAssistants() {
|
|
260
|
+
return Array.from(this.assistants.values());
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get assistant by ID
|
|
264
|
+
*/
|
|
265
|
+
getAssistantById(id) {
|
|
266
|
+
return this.assistants.get(id);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Create a new assistant
|
|
270
|
+
*/
|
|
271
|
+
createAssistant(id, data) {
|
|
272
|
+
const now = /* @__PURE__ */ new Date();
|
|
273
|
+
const assistant = {
|
|
274
|
+
id,
|
|
275
|
+
name: data.name,
|
|
276
|
+
description: data.description,
|
|
277
|
+
graphDefinition: data.graphDefinition,
|
|
278
|
+
createdAt: now,
|
|
279
|
+
updatedAt: now
|
|
280
|
+
};
|
|
281
|
+
this.assistants.set(id, assistant);
|
|
282
|
+
return assistant;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Update an existing assistant
|
|
286
|
+
*/
|
|
287
|
+
updateAssistant(id, updates) {
|
|
288
|
+
const existing = this.assistants.get(id);
|
|
289
|
+
if (!existing) {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
const updated = {
|
|
293
|
+
...existing,
|
|
294
|
+
...updates,
|
|
295
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
296
|
+
};
|
|
297
|
+
this.assistants.set(id, updated);
|
|
298
|
+
return updated;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Delete an assistant by ID
|
|
302
|
+
*/
|
|
303
|
+
deleteAssistant(id) {
|
|
304
|
+
return this.assistants.delete(id);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Check if assistant exists
|
|
308
|
+
*/
|
|
309
|
+
hasAssistant(id) {
|
|
310
|
+
return this.assistants.has(id);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
var assistantStore = new AssistantStore();
|
|
314
|
+
|
|
315
|
+
// src/controllers/assistant.ts
|
|
316
|
+
var import_crypto = require("crypto");
|
|
317
|
+
var import_core2 = require("@axiom-lattice/core");
|
|
318
|
+
function convertAgentConfigToAssistant(config) {
|
|
319
|
+
return {
|
|
320
|
+
id: config.key,
|
|
321
|
+
name: config.name,
|
|
322
|
+
description: config.description,
|
|
323
|
+
graphDefinition: config,
|
|
324
|
+
// Store the full config as graphDefinition
|
|
325
|
+
createdAt: /* @__PURE__ */ new Date(0),
|
|
326
|
+
// Code-configured agents have no creation date
|
|
327
|
+
updatedAt: /* @__PURE__ */ new Date(0)
|
|
328
|
+
// Code-configured agents have no update date
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
async function getAssistantList(request, reply) {
|
|
332
|
+
const agentConfigs = await (0, import_core2.getAllAgentConfigs)();
|
|
333
|
+
const codeConfiguredAssistants = agentConfigs.map(
|
|
334
|
+
convertAgentConfigToAssistant
|
|
335
|
+
);
|
|
336
|
+
const storedAssistants = assistantStore.getAllAssistants();
|
|
337
|
+
const assistantMap = /* @__PURE__ */ new Map();
|
|
338
|
+
codeConfiguredAssistants.forEach((assistant) => {
|
|
339
|
+
assistantMap.set(assistant.id, assistant);
|
|
340
|
+
});
|
|
341
|
+
storedAssistants.forEach((assistant) => {
|
|
342
|
+
assistantMap.set(assistant.id, assistant);
|
|
343
|
+
});
|
|
344
|
+
const allAssistants = Array.from(assistantMap.values());
|
|
345
|
+
return {
|
|
346
|
+
success: true,
|
|
347
|
+
message: "Successfully retrieved assistant list",
|
|
348
|
+
data: {
|
|
349
|
+
records: allAssistants,
|
|
350
|
+
total: allAssistants.length
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
async function getAssistant(request, reply) {
|
|
355
|
+
const { id } = request.params;
|
|
356
|
+
let assistant = assistantStore.getAssistantById(id);
|
|
357
|
+
if (!assistant) {
|
|
358
|
+
const agentConfigs = await (0, import_core2.getAllAgentConfigs)();
|
|
359
|
+
const agentConfig = agentConfigs.find((config) => config.key === id);
|
|
360
|
+
if (agentConfig) {
|
|
361
|
+
assistant = convertAgentConfigToAssistant(agentConfig);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (!assistant) {
|
|
365
|
+
return reply.status(404).send({
|
|
366
|
+
success: false,
|
|
367
|
+
message: "Assistant not found"
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
success: true,
|
|
372
|
+
message: "Successfully retrieved assistant",
|
|
373
|
+
data: assistant
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
async function createAssistant(request, reply) {
|
|
377
|
+
const data = request.body;
|
|
378
|
+
if (!data.name) {
|
|
379
|
+
return reply.status(400).send({
|
|
380
|
+
success: false,
|
|
381
|
+
message: "name is required"
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
if (!data.graphDefinition) {
|
|
385
|
+
return reply.status(400).send({
|
|
386
|
+
success: false,
|
|
387
|
+
message: "graphDefinition is required"
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
const id = (0, import_crypto.randomUUID)();
|
|
391
|
+
const newAssistant = assistantStore.createAssistant(id, data);
|
|
392
|
+
return reply.status(201).send({
|
|
393
|
+
success: true,
|
|
394
|
+
message: "Successfully created assistant",
|
|
395
|
+
data: newAssistant
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
async function updateAssistant(request, reply) {
|
|
399
|
+
const { id } = request.params;
|
|
400
|
+
const updates = request.body;
|
|
401
|
+
const agentConfigs = await (0, import_core2.getAllAgentConfigs)();
|
|
402
|
+
const isCodeConfigured = agentConfigs.some((config) => config.key === id);
|
|
403
|
+
if (isCodeConfigured) {
|
|
404
|
+
return reply.status(403).send({
|
|
405
|
+
success: false,
|
|
406
|
+
message: "Cannot update code-configured assistant. Only stored assistants can be updated."
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
if (!assistantStore.hasAssistant(id)) {
|
|
410
|
+
return reply.status(404).send({
|
|
411
|
+
success: false,
|
|
412
|
+
message: "Assistant not found"
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
const updatedAssistant = assistantStore.updateAssistant(id, updates);
|
|
416
|
+
if (!updatedAssistant) {
|
|
417
|
+
return reply.status(500).send({
|
|
418
|
+
success: false,
|
|
419
|
+
message: "Failed to update assistant"
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
return {
|
|
423
|
+
success: true,
|
|
424
|
+
message: "Successfully updated assistant",
|
|
425
|
+
data: updatedAssistant
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
async function deleteAssistant(request, reply) {
|
|
429
|
+
const { id } = request.params;
|
|
430
|
+
const agentConfigs = await (0, import_core2.getAllAgentConfigs)();
|
|
431
|
+
const isCodeConfigured = agentConfigs.some((config) => config.key === id);
|
|
432
|
+
if (isCodeConfigured) {
|
|
433
|
+
return reply.status(403).send({
|
|
434
|
+
success: false,
|
|
435
|
+
message: "Cannot delete code-configured assistant. Only stored assistants can be deleted."
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
if (!assistantStore.hasAssistant(id)) {
|
|
439
|
+
return reply.status(404).send({
|
|
440
|
+
success: false,
|
|
441
|
+
message: "Assistant not found"
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
const deleted = assistantStore.deleteAssistant(id);
|
|
445
|
+
if (!deleted) {
|
|
446
|
+
return reply.status(500).send({
|
|
447
|
+
success: false,
|
|
448
|
+
message: "Failed to delete assistant"
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
success: true,
|
|
453
|
+
message: "Successfully deleted assistant"
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
var getAgentGraph = async (request, reply) => {
|
|
457
|
+
try {
|
|
458
|
+
const { assistantId } = request.params;
|
|
459
|
+
const imageData = await draw_graph(assistantId);
|
|
460
|
+
reply.header("Content-Type", "application/json").send({
|
|
461
|
+
image: imageData
|
|
462
|
+
});
|
|
463
|
+
} catch (error) {
|
|
464
|
+
reply.status(500).send({
|
|
465
|
+
success: false,
|
|
466
|
+
error: error.message || "Failed to get agent graph"
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
|
|
253
471
|
// src/controllers/run.ts
|
|
254
472
|
var import_uuid2 = require("uuid");
|
|
255
473
|
var createRun = async (request, reply) => {
|
|
@@ -517,24 +735,8 @@ var clearMemory = async (request, reply) => {
|
|
|
517
735
|
}
|
|
518
736
|
};
|
|
519
737
|
|
|
520
|
-
// src/controllers/assistant.ts
|
|
521
|
-
var getAgentGraph = async (request, reply) => {
|
|
522
|
-
try {
|
|
523
|
-
const { assistantId } = request.params;
|
|
524
|
-
const imageData = await draw_graph(assistantId);
|
|
525
|
-
reply.header("Content-Type", "application/json").send({
|
|
526
|
-
image: imageData
|
|
527
|
-
});
|
|
528
|
-
} catch (error) {
|
|
529
|
-
reply.status(500).send({
|
|
530
|
-
success: false,
|
|
531
|
-
error: error.message || "\u83B7\u53D6\u4EE3\u7406\u56FE\u8868\u5931\u8D25"
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
|
|
536
738
|
// src/controllers/agent_task.ts
|
|
537
|
-
var
|
|
739
|
+
var import_core3 = require("@axiom-lattice/core");
|
|
538
740
|
var triggerAgentTask = async (request, reply) => {
|
|
539
741
|
try {
|
|
540
742
|
const { assistant_id, thread_id, input, command } = request.body;
|
|
@@ -553,7 +755,7 @@ var triggerAgentTask = async (request, reply) => {
|
|
|
553
755
|
});
|
|
554
756
|
return;
|
|
555
757
|
}
|
|
556
|
-
const agentManager =
|
|
758
|
+
const agentManager = import_core3.AgentManager.getInstance();
|
|
557
759
|
const result = await agentManager.callAgentInQueue({
|
|
558
760
|
assistant_id,
|
|
559
761
|
thread_id,
|
|
@@ -572,6 +774,184 @@ var triggerAgentTask = async (request, reply) => {
|
|
|
572
774
|
}
|
|
573
775
|
};
|
|
574
776
|
|
|
777
|
+
// src/stores/thread_store.ts
|
|
778
|
+
var ThreadStore = class {
|
|
779
|
+
constructor() {
|
|
780
|
+
// Map<assistantId, Map<threadId, Thread>>
|
|
781
|
+
this.threads = /* @__PURE__ */ new Map();
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Get all threads for a specific assistant
|
|
785
|
+
*/
|
|
786
|
+
getThreadsByAssistantId(assistantId) {
|
|
787
|
+
const assistantThreads = this.threads.get(assistantId);
|
|
788
|
+
if (!assistantThreads) {
|
|
789
|
+
return [];
|
|
790
|
+
}
|
|
791
|
+
return Array.from(assistantThreads.values());
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Get a thread by ID for a specific assistant
|
|
795
|
+
*/
|
|
796
|
+
getThreadById(assistantId, threadId) {
|
|
797
|
+
const assistantThreads = this.threads.get(assistantId);
|
|
798
|
+
if (!assistantThreads) {
|
|
799
|
+
return void 0;
|
|
800
|
+
}
|
|
801
|
+
return assistantThreads.get(threadId);
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Create a new thread for an assistant
|
|
805
|
+
*/
|
|
806
|
+
createThread(assistantId, threadId, data) {
|
|
807
|
+
const now = /* @__PURE__ */ new Date();
|
|
808
|
+
const thread = {
|
|
809
|
+
id: threadId,
|
|
810
|
+
assistantId,
|
|
811
|
+
metadata: data.metadata || {},
|
|
812
|
+
createdAt: now,
|
|
813
|
+
updatedAt: now
|
|
814
|
+
};
|
|
815
|
+
if (!this.threads.has(assistantId)) {
|
|
816
|
+
this.threads.set(assistantId, /* @__PURE__ */ new Map());
|
|
817
|
+
}
|
|
818
|
+
const assistantThreads = this.threads.get(assistantId);
|
|
819
|
+
assistantThreads.set(threadId, thread);
|
|
820
|
+
return thread;
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Update an existing thread
|
|
824
|
+
*/
|
|
825
|
+
updateThread(assistantId, threadId, updates) {
|
|
826
|
+
const assistantThreads = this.threads.get(assistantId);
|
|
827
|
+
if (!assistantThreads) {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
const existing = assistantThreads.get(threadId);
|
|
831
|
+
if (!existing) {
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
834
|
+
const updated = {
|
|
835
|
+
...existing,
|
|
836
|
+
metadata: {
|
|
837
|
+
...existing.metadata,
|
|
838
|
+
...updates.metadata || {}
|
|
839
|
+
},
|
|
840
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
841
|
+
};
|
|
842
|
+
assistantThreads.set(threadId, updated);
|
|
843
|
+
return updated;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Delete a thread by ID
|
|
847
|
+
*/
|
|
848
|
+
deleteThread(assistantId, threadId) {
|
|
849
|
+
const assistantThreads = this.threads.get(assistantId);
|
|
850
|
+
if (!assistantThreads) {
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
return assistantThreads.delete(threadId);
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Check if thread exists
|
|
857
|
+
*/
|
|
858
|
+
hasThread(assistantId, threadId) {
|
|
859
|
+
const assistantThreads = this.threads.get(assistantId);
|
|
860
|
+
if (!assistantThreads) {
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
return assistantThreads.has(threadId);
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
var threadStore = new ThreadStore();
|
|
867
|
+
|
|
868
|
+
// src/controllers/threads.ts
|
|
869
|
+
var import_crypto2 = require("crypto");
|
|
870
|
+
async function getThreadList(request, reply) {
|
|
871
|
+
const { assistantId } = request.params;
|
|
872
|
+
const threads = threadStore.getThreadsByAssistantId(assistantId);
|
|
873
|
+
return {
|
|
874
|
+
success: true,
|
|
875
|
+
message: "Successfully retrieved thread list",
|
|
876
|
+
data: {
|
|
877
|
+
records: threads,
|
|
878
|
+
total: threads.length
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
async function getThread(request, reply) {
|
|
883
|
+
const { assistantId, threadId } = request.params;
|
|
884
|
+
const thread = threadStore.getThreadById(assistantId, threadId);
|
|
885
|
+
if (!thread) {
|
|
886
|
+
return reply.status(404).send({
|
|
887
|
+
success: false,
|
|
888
|
+
message: "Thread not found"
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
return {
|
|
892
|
+
success: true,
|
|
893
|
+
message: "Successfully retrieved thread",
|
|
894
|
+
data: thread
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
async function createThread(request, reply) {
|
|
898
|
+
const { assistantId } = request.params;
|
|
899
|
+
const data = request.body;
|
|
900
|
+
const threadId = (0, import_crypto2.randomUUID)();
|
|
901
|
+
const newThread = threadStore.createThread(assistantId, threadId, data);
|
|
902
|
+
return reply.status(201).send({
|
|
903
|
+
success: true,
|
|
904
|
+
message: "Successfully created thread",
|
|
905
|
+
data: newThread
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
async function updateThread(request, reply) {
|
|
909
|
+
const { assistantId, threadId } = request.params;
|
|
910
|
+
const updates = request.body;
|
|
911
|
+
if (!threadStore.hasThread(assistantId, threadId)) {
|
|
912
|
+
return reply.status(404).send({
|
|
913
|
+
success: false,
|
|
914
|
+
message: "Thread not found"
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
const updatedThread = threadStore.updateThread(
|
|
918
|
+
assistantId,
|
|
919
|
+
threadId,
|
|
920
|
+
updates
|
|
921
|
+
);
|
|
922
|
+
if (!updatedThread) {
|
|
923
|
+
return reply.status(500).send({
|
|
924
|
+
success: false,
|
|
925
|
+
message: "Failed to update thread"
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
return {
|
|
929
|
+
success: true,
|
|
930
|
+
message: "Successfully updated thread",
|
|
931
|
+
data: updatedThread
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
async function deleteThread(request, reply) {
|
|
935
|
+
const { assistantId, threadId } = request.params;
|
|
936
|
+
if (!threadStore.hasThread(assistantId, threadId)) {
|
|
937
|
+
return reply.status(404).send({
|
|
938
|
+
success: false,
|
|
939
|
+
message: "Thread not found"
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
const deleted = threadStore.deleteThread(assistantId, threadId);
|
|
943
|
+
if (!deleted) {
|
|
944
|
+
return reply.status(500).send({
|
|
945
|
+
success: false,
|
|
946
|
+
message: "Failed to delete thread"
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
return {
|
|
950
|
+
success: true,
|
|
951
|
+
message: "Successfully deleted thread"
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
|
|
575
955
|
// src/schemas/index.ts
|
|
576
956
|
var getAllMemoryItemsSchema = {
|
|
577
957
|
description: "Get all memory items for an assistant thread",
|
|
@@ -775,6 +1155,11 @@ var registerLatticeRoutes = (app2) => {
|
|
|
775
1155
|
{ schema: clearMemorySchema },
|
|
776
1156
|
clearMemory
|
|
777
1157
|
);
|
|
1158
|
+
app2.get("/api/assistants", getAssistantList);
|
|
1159
|
+
app2.get("/api/assistants/:id", getAssistant);
|
|
1160
|
+
app2.post("/api/assistants", createAssistant);
|
|
1161
|
+
app2.put("/api/assistants/:id", updateAssistant);
|
|
1162
|
+
app2.delete("/api/assistants/:id", deleteAssistant);
|
|
778
1163
|
app2.get(
|
|
779
1164
|
"/api/assistants/:assistantId/graph",
|
|
780
1165
|
{ schema: getAgentGraphSchema },
|
|
@@ -785,6 +1170,20 @@ var registerLatticeRoutes = (app2) => {
|
|
|
785
1170
|
{ schema: triggerAgentTaskSchema },
|
|
786
1171
|
triggerAgentTask
|
|
787
1172
|
);
|
|
1173
|
+
app2.get("/api/assistants/:assistantId/threads", getThreadList);
|
|
1174
|
+
app2.get(
|
|
1175
|
+
"/api/assistants/:assistantId/threads/:threadId",
|
|
1176
|
+
getThread
|
|
1177
|
+
);
|
|
1178
|
+
app2.post("/api/assistants/:assistantId/threads", createThread);
|
|
1179
|
+
app2.put(
|
|
1180
|
+
"/api/assistants/:assistantId/threads/:threadId",
|
|
1181
|
+
updateThread
|
|
1182
|
+
);
|
|
1183
|
+
app2.delete(
|
|
1184
|
+
"/api/assistants/:assistantId/threads/:threadId",
|
|
1185
|
+
deleteThread
|
|
1186
|
+
);
|
|
788
1187
|
};
|
|
789
1188
|
|
|
790
1189
|
// src/logger/Logger.ts
|
|
@@ -988,7 +1387,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
988
1387
|
};
|
|
989
1388
|
|
|
990
1389
|
// src/services/queue_service.ts
|
|
991
|
-
var
|
|
1390
|
+
var import_core4 = require("@axiom-lattice/core");
|
|
992
1391
|
var import_protocols = require("@axiom-lattice/protocols");
|
|
993
1392
|
var import_queue_redis = require("@axiom-lattice/queue-redis");
|
|
994
1393
|
var DEFAULT_QUEUE_KEY = "default";
|
|
@@ -1007,8 +1406,8 @@ var setQueueServiceType = (type) => {
|
|
|
1007
1406
|
redisPassword: process.env.REDIS_PASSWORD
|
|
1008
1407
|
} : void 0
|
|
1009
1408
|
};
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1409
|
+
if (import_core4.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
|
|
1410
|
+
import_core4.queueLatticeManager.removeLattice(DEFAULT_QUEUE_KEY);
|
|
1012
1411
|
}
|
|
1013
1412
|
let client;
|
|
1014
1413
|
if (type === "redis") {
|
|
@@ -1017,13 +1416,13 @@ var setQueueServiceType = (type) => {
|
|
|
1017
1416
|
redisPassword: process.env.REDIS_PASSWORD
|
|
1018
1417
|
});
|
|
1019
1418
|
}
|
|
1020
|
-
(0,
|
|
1419
|
+
(0, import_core4.registerQueueLattice)(DEFAULT_QUEUE_KEY, config, client);
|
|
1021
1420
|
};
|
|
1022
1421
|
var getQueueService = () => {
|
|
1023
|
-
if (!
|
|
1422
|
+
if (!import_core4.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
|
|
1024
1423
|
setQueueServiceType(queueServiceType);
|
|
1025
1424
|
}
|
|
1026
|
-
return (0,
|
|
1425
|
+
return (0, import_core4.getQueueLattice)(DEFAULT_QUEUE_KEY);
|
|
1027
1426
|
};
|
|
1028
1427
|
var popAgentTaskFromQueue = async () => {
|
|
1029
1428
|
const queue = getQueueService();
|
|
@@ -1032,7 +1431,7 @@ var popAgentTaskFromQueue = async () => {
|
|
|
1032
1431
|
};
|
|
1033
1432
|
|
|
1034
1433
|
// src/services/agent_task_consumer.ts
|
|
1035
|
-
var
|
|
1434
|
+
var import_core5 = require("@axiom-lattice/core");
|
|
1036
1435
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
1037
1436
|
const {
|
|
1038
1437
|
assistant_id,
|
|
@@ -1096,7 +1495,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
1096
1495
|
}
|
|
1097
1496
|
if (callback_event) {
|
|
1098
1497
|
const state = await agent_state({ assistant_id, thread_id });
|
|
1099
|
-
|
|
1498
|
+
import_core5.eventBus.publish(callback_event, {
|
|
1100
1499
|
success: true,
|
|
1101
1500
|
state,
|
|
1102
1501
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -1110,7 +1509,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
1110
1509
|
await response.text();
|
|
1111
1510
|
if (callback_event) {
|
|
1112
1511
|
const state = await agent_state({ assistant_id, thread_id });
|
|
1113
|
-
|
|
1512
|
+
import_core5.eventBus.publish(callback_event, {
|
|
1114
1513
|
success: true,
|
|
1115
1514
|
state,
|
|
1116
1515
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -1137,7 +1536,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
1137
1536
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
1138
1537
|
}
|
|
1139
1538
|
if (callback_event) {
|
|
1140
|
-
|
|
1539
|
+
import_core5.eventBus.publish(callback_event, {
|
|
1141
1540
|
success: false,
|
|
1142
1541
|
error: error instanceof Error ? error.message : String(error),
|
|
1143
1542
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -1175,7 +1574,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
1175
1574
|
* 初始化事件监听和队列轮询
|
|
1176
1575
|
*/
|
|
1177
1576
|
initialize() {
|
|
1178
|
-
|
|
1577
|
+
import_core5.eventBus.subscribe(import_core5.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
1179
1578
|
this.startPollingQueue();
|
|
1180
1579
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
1181
1580
|
}
|
|
@@ -1294,7 +1693,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
1294
1693
|
handleAgentTask(taskRequest).catch((error) => {
|
|
1295
1694
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
1296
1695
|
if (taskRequest.callback_event) {
|
|
1297
|
-
|
|
1696
|
+
import_core5.eventBus.publish(taskRequest.callback_event, {
|
|
1298
1697
|
success: false,
|
|
1299
1698
|
error: error instanceof Error ? error.message : String(error),
|
|
1300
1699
|
config: {
|