@axiom-lattice/gateway 2.1.4 → 2.1.6
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 +16 -0
- package/dist/index.js +103 -252
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -257
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
- package/src/controllers/agent_task.ts +1 -1
- package/src/services/agent_task_consumer.ts +86 -12
- package/src/services/queue_service.ts +70 -10
- package/src/services/AgentManager.ts +0 -46
- package/src/services/agent_task_types.ts +0 -2
- package/src/services/event_bus.ts +0 -62
- package/src/services/queue_service_memory.ts +0 -85
- package/src/services/queue_service_redis.ts +0 -86
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.6 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
|
+
[32mCJS[39m [1mdist/index.js [22m[32m38.84 KB[39m
|
|
13
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m76.54 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 142ms
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m36.61 KB[39m
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m76.45 KB[39m
|
|
17
|
+
[32mESM[39m ⚡️ Build success in 149ms
|
|
18
18
|
[34mDTS[39m Build start
|
|
19
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
+
[32mDTS[39m ⚡️ Build success in 5936ms
|
|
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,21 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ee11051: run subagent in another thread
|
|
8
|
+
- Updated dependencies [ee11051]
|
|
9
|
+
- @axiom-lattice/protocols@2.1.2
|
|
10
|
+
- @axiom-lattice/core@2.1.4
|
|
11
|
+
- @axiom-lattice/queue-redis@1.0.1
|
|
12
|
+
|
|
13
|
+
## 2.1.5
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- e26477f: fix redis connect issue
|
|
18
|
+
|
|
3
19
|
## 2.1.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -534,245 +534,8 @@ var getAgentGraph = async (request, reply) => {
|
|
|
534
534
|
}
|
|
535
535
|
};
|
|
536
536
|
|
|
537
|
-
// src/services/agent_task_types.ts
|
|
538
|
-
var AGENT_TASK_EVENT = "agent:execute";
|
|
539
|
-
|
|
540
|
-
// src/services/event_bus.ts
|
|
541
|
-
var import_events = require("events");
|
|
542
|
-
|
|
543
|
-
// src/services/queue_service_memory.ts
|
|
544
|
-
var queue_service_memory_exports = {};
|
|
545
|
-
__export(queue_service_memory_exports, {
|
|
546
|
-
popAgentTaskFromQueue: () => popAgentTaskFromQueue,
|
|
547
|
-
pushAgentTaskToQueue: () => pushAgentTaskToQueue
|
|
548
|
-
});
|
|
549
|
-
var queue_name = process.env.QUEUE_NAME || "tasks";
|
|
550
|
-
var queues = /* @__PURE__ */ new Map();
|
|
551
|
-
var ensureQueue = (queueName) => {
|
|
552
|
-
if (!queues.has(queueName)) {
|
|
553
|
-
queues.set(queueName, []);
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
var sendToQueue = async (queueName, message) => {
|
|
557
|
-
try {
|
|
558
|
-
ensureQueue(queueName);
|
|
559
|
-
const queue = queues.get(queueName);
|
|
560
|
-
queue.unshift(message);
|
|
561
|
-
const result = queue.length;
|
|
562
|
-
console.log("lPush (memory)", result);
|
|
563
|
-
return { data: result, error: null };
|
|
564
|
-
} catch (error) {
|
|
565
|
-
console.error(error);
|
|
566
|
-
return { data: null, error };
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
var popFromQueue = async (queueName) => {
|
|
570
|
-
try {
|
|
571
|
-
ensureQueue(queueName);
|
|
572
|
-
const queue = queues.get(queueName);
|
|
573
|
-
const message = queue.pop();
|
|
574
|
-
if (message) {
|
|
575
|
-
return { data: message, error: null };
|
|
576
|
-
}
|
|
577
|
-
return { data: null, error: null };
|
|
578
|
-
} catch (error) {
|
|
579
|
-
console.error(error);
|
|
580
|
-
return { data: null, error };
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
var createTenantQueue = async () => {
|
|
584
|
-
try {
|
|
585
|
-
ensureQueue(queue_name);
|
|
586
|
-
const queue = queues.get(queue_name);
|
|
587
|
-
const exists = queue !== void 0;
|
|
588
|
-
return { success: true, queue_name };
|
|
589
|
-
} catch (error) {
|
|
590
|
-
console.error(error);
|
|
591
|
-
return { success: false, error };
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
var pushAgentTaskToQueue = async (agentTask) => {
|
|
595
|
-
const tenantId = agentTask["x-tenant-id"];
|
|
596
|
-
try {
|
|
597
|
-
await createTenantQueue();
|
|
598
|
-
const result = await sendToQueue(`${queue_name}`, agentTask);
|
|
599
|
-
return result;
|
|
600
|
-
} catch (error) {
|
|
601
|
-
console.error(error);
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
var popAgentTaskFromQueue = async () => {
|
|
606
|
-
const result = await popFromQueue(`${queue_name}`);
|
|
607
|
-
return result;
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
// src/services/queue_service_redis.ts
|
|
611
|
-
var queue_service_redis_exports = {};
|
|
612
|
-
__export(queue_service_redis_exports, {
|
|
613
|
-
popAgentTaskFromQueue: () => popAgentTaskFromQueue2,
|
|
614
|
-
pushAgentTaskToQueue: () => pushAgentTaskToQueue2
|
|
615
|
-
});
|
|
616
|
-
var import_redis = require("redis");
|
|
617
|
-
var queue_name2 = process.env.QUEUE_NAME || "tasks";
|
|
618
|
-
var redisOptions = {
|
|
619
|
-
url: process.env.REDIS_URL || "redis://localhost:6379",
|
|
620
|
-
password: process.env.REDIS_PASSWORD
|
|
621
|
-
};
|
|
622
|
-
var redisClient = (0, import_redis.createClient)(redisOptions);
|
|
623
|
-
(async () => {
|
|
624
|
-
redisClient.on(
|
|
625
|
-
"error",
|
|
626
|
-
(err) => console.error("Redis Client Error", err)
|
|
627
|
-
);
|
|
628
|
-
try {
|
|
629
|
-
await redisClient.connect();
|
|
630
|
-
console.log("Redis connection successful");
|
|
631
|
-
} catch (error) {
|
|
632
|
-
console.error("Redis connection failed:", error);
|
|
633
|
-
}
|
|
634
|
-
})();
|
|
635
|
-
var sendToQueue2 = async (queueName, message) => {
|
|
636
|
-
try {
|
|
637
|
-
const result = await redisClient.lPush(queueName, JSON.stringify(message));
|
|
638
|
-
console.log("lPush", result);
|
|
639
|
-
return { data: result, error: null };
|
|
640
|
-
} catch (error) {
|
|
641
|
-
console.error(error);
|
|
642
|
-
return { data: null, error };
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
var popFromQueue2 = async (queueName) => {
|
|
646
|
-
try {
|
|
647
|
-
const message = await redisClient.rPop(queueName);
|
|
648
|
-
if (message) {
|
|
649
|
-
return { data: JSON.parse(message), error: null };
|
|
650
|
-
}
|
|
651
|
-
return { data: null, error: null };
|
|
652
|
-
} catch (error) {
|
|
653
|
-
console.error(error);
|
|
654
|
-
return { data: null, error };
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
var createTenantQueue2 = async () => {
|
|
658
|
-
try {
|
|
659
|
-
const exists = await redisClient.exists(queue_name2);
|
|
660
|
-
return { success: true, queue_name: queue_name2 };
|
|
661
|
-
} catch (error) {
|
|
662
|
-
console.error(error);
|
|
663
|
-
return { success: false, error };
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
var pushAgentTaskToQueue2 = async (agentTask) => {
|
|
667
|
-
const tenantId = agentTask["x-tenant-id"];
|
|
668
|
-
try {
|
|
669
|
-
await createTenantQueue2();
|
|
670
|
-
const result = await sendToQueue2(`${queue_name2}`, agentTask);
|
|
671
|
-
return result;
|
|
672
|
-
} catch (error) {
|
|
673
|
-
console.error(error);
|
|
674
|
-
return null;
|
|
675
|
-
}
|
|
676
|
-
};
|
|
677
|
-
var popAgentTaskFromQueue2 = async () => {
|
|
678
|
-
const result = await popFromQueue2(`${queue_name2}`);
|
|
679
|
-
return result;
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
// src/services/queue_service.ts
|
|
683
|
-
var queueServiceType = process.env.QUEUE_SERVICE_TYPE || "memory";
|
|
684
|
-
var setQueueServiceType = (type) => {
|
|
685
|
-
queueServiceType = type;
|
|
686
|
-
console.log(`Queue service type set to: ${type}`);
|
|
687
|
-
};
|
|
688
|
-
var getQueueService = () => {
|
|
689
|
-
return queueServiceType === "redis" ? queue_service_redis_exports : queue_service_memory_exports;
|
|
690
|
-
};
|
|
691
|
-
var pushAgentTaskToQueue3 = async (agentTask) => {
|
|
692
|
-
const service = getQueueService();
|
|
693
|
-
return service.pushAgentTaskToQueue(agentTask);
|
|
694
|
-
};
|
|
695
|
-
var popAgentTaskFromQueue3 = async () => {
|
|
696
|
-
const service = getQueueService();
|
|
697
|
-
return service.popAgentTaskFromQueue();
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
// src/services/event_bus.ts
|
|
701
|
-
var EventBus = class {
|
|
702
|
-
constructor() {
|
|
703
|
-
this.emitter = new import_events.EventEmitter();
|
|
704
|
-
this.emitter.setMaxListeners(100);
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* 发布事件
|
|
708
|
-
* @param eventName 事件名称
|
|
709
|
-
* @param data 事件数据
|
|
710
|
-
*/
|
|
711
|
-
publish(eventName, data, useQueue = false) {
|
|
712
|
-
if (useQueue) {
|
|
713
|
-
pushAgentTaskToQueue3(data);
|
|
714
|
-
} else {
|
|
715
|
-
this.emitter.emit(eventName, data);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* 订阅事件
|
|
720
|
-
* @param eventName 事件名称
|
|
721
|
-
* @param callback 回调函数
|
|
722
|
-
*/
|
|
723
|
-
subscribe(eventName, callback) {
|
|
724
|
-
this.emitter.on(eventName, callback);
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* 取消订阅事件
|
|
728
|
-
* @param eventName 事件名称
|
|
729
|
-
* @param callback 回调函数
|
|
730
|
-
*/
|
|
731
|
-
unsubscribe(eventName, callback) {
|
|
732
|
-
this.emitter.off(eventName, callback);
|
|
733
|
-
}
|
|
734
|
-
/**
|
|
735
|
-
* 只订阅一次事件
|
|
736
|
-
* @param eventName 事件名称
|
|
737
|
-
* @param callback 回调函数
|
|
738
|
-
*/
|
|
739
|
-
subscribeOnce(eventName, callback) {
|
|
740
|
-
this.emitter.once(eventName, callback);
|
|
741
|
-
}
|
|
742
|
-
};
|
|
743
|
-
var eventBus = new EventBus();
|
|
744
|
-
var event_bus_default = eventBus;
|
|
745
|
-
|
|
746
|
-
// src/services/AgentManager.ts
|
|
747
|
-
var AgentManager = class _AgentManager {
|
|
748
|
-
constructor() {
|
|
749
|
-
this.agents = [];
|
|
750
|
-
}
|
|
751
|
-
static getInstance() {
|
|
752
|
-
if (!_AgentManager.instance) {
|
|
753
|
-
_AgentManager.instance = new _AgentManager();
|
|
754
|
-
}
|
|
755
|
-
return _AgentManager.instance;
|
|
756
|
-
}
|
|
757
|
-
callAgentInQueue(queue) {
|
|
758
|
-
return new Promise((resolve, reject) => {
|
|
759
|
-
try {
|
|
760
|
-
event_bus_default.publish(
|
|
761
|
-
AGENT_TASK_EVENT,
|
|
762
|
-
{
|
|
763
|
-
...queue
|
|
764
|
-
},
|
|
765
|
-
true
|
|
766
|
-
);
|
|
767
|
-
resolve(true);
|
|
768
|
-
} catch (error) {
|
|
769
|
-
reject(error);
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
};
|
|
774
|
-
|
|
775
537
|
// src/controllers/agent_task.ts
|
|
538
|
+
var import_core2 = require("@axiom-lattice/core");
|
|
776
539
|
var triggerAgentTask = async (request, reply) => {
|
|
777
540
|
try {
|
|
778
541
|
const { assistant_id, thread_id, input, command } = request.body;
|
|
@@ -791,7 +554,7 @@ var triggerAgentTask = async (request, reply) => {
|
|
|
791
554
|
});
|
|
792
555
|
return;
|
|
793
556
|
}
|
|
794
|
-
const agentManager = AgentManager.getInstance();
|
|
557
|
+
const agentManager = import_core2.AgentManager.getInstance();
|
|
795
558
|
const result = await agentManager.callAgentInQueue({
|
|
796
559
|
assistant_id,
|
|
797
560
|
thread_id,
|
|
@@ -1225,7 +988,52 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
1225
988
|
await app2.register(import_swagger_ui.default, swaggerUiConfig);
|
|
1226
989
|
};
|
|
1227
990
|
|
|
991
|
+
// src/services/queue_service.ts
|
|
992
|
+
var import_core3 = require("@axiom-lattice/core");
|
|
993
|
+
var import_protocols = require("@axiom-lattice/protocols");
|
|
994
|
+
var import_queue_redis = require("@axiom-lattice/queue-redis");
|
|
995
|
+
var DEFAULT_QUEUE_KEY = "default";
|
|
996
|
+
var queueServiceType = process.env.QUEUE_SERVICE_TYPE || "memory";
|
|
997
|
+
var setQueueServiceType = (type) => {
|
|
998
|
+
queueServiceType = type;
|
|
999
|
+
console.log(`Queue service type set to: ${type}`);
|
|
1000
|
+
const queueName = process.env.QUEUE_NAME || "tasks";
|
|
1001
|
+
const config = {
|
|
1002
|
+
name: "Default Queue Service",
|
|
1003
|
+
description: `Default ${type} queue service`,
|
|
1004
|
+
type: type === "redis" ? import_protocols.QueueType.REDIS : import_protocols.QueueType.MEMORY,
|
|
1005
|
+
queueName,
|
|
1006
|
+
options: type === "redis" ? {
|
|
1007
|
+
redisUrl: process.env.REDIS_URL,
|
|
1008
|
+
redisPassword: process.env.REDIS_PASSWORD
|
|
1009
|
+
} : void 0
|
|
1010
|
+
};
|
|
1011
|
+
if (import_core3.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
|
|
1012
|
+
import_core3.queueLatticeManager.removeLattice(DEFAULT_QUEUE_KEY);
|
|
1013
|
+
}
|
|
1014
|
+
let client;
|
|
1015
|
+
if (type === "redis") {
|
|
1016
|
+
client = new import_queue_redis.RedisQueueClient(queueName, {
|
|
1017
|
+
redisUrl: process.env.REDIS_URL,
|
|
1018
|
+
redisPassword: process.env.REDIS_PASSWORD
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
(0, import_core3.registerQueueLattice)(DEFAULT_QUEUE_KEY, config, client);
|
|
1022
|
+
};
|
|
1023
|
+
var getQueueService = () => {
|
|
1024
|
+
if (!import_core3.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
|
|
1025
|
+
setQueueServiceType(queueServiceType);
|
|
1026
|
+
}
|
|
1027
|
+
return (0, import_core3.getQueueLattice)(DEFAULT_QUEUE_KEY);
|
|
1028
|
+
};
|
|
1029
|
+
var popAgentTaskFromQueue = async () => {
|
|
1030
|
+
const queue = getQueueService();
|
|
1031
|
+
const result = await queue.pop();
|
|
1032
|
+
return result;
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1228
1035
|
// src/services/agent_task_consumer.ts
|
|
1036
|
+
var import_core4 = require("@axiom-lattice/core");
|
|
1229
1037
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
1230
1038
|
const {
|
|
1231
1039
|
assistant_id,
|
|
@@ -1261,16 +1069,59 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
1261
1069
|
if (!response.ok) {
|
|
1262
1070
|
throw new Error(`API\u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`);
|
|
1263
1071
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1072
|
+
const contentType = response.headers.get("content-type");
|
|
1073
|
+
if (contentType?.includes("text/event-stream")) {
|
|
1074
|
+
const reader = response.body?.getReader();
|
|
1075
|
+
const decoder = new TextDecoder();
|
|
1076
|
+
if (!reader) {
|
|
1077
|
+
throw new Error("Response body is not readable");
|
|
1078
|
+
}
|
|
1079
|
+
let buffer = "";
|
|
1080
|
+
let streamEnded = false;
|
|
1081
|
+
try {
|
|
1082
|
+
while (true) {
|
|
1083
|
+
const { done, value } = await reader.read();
|
|
1084
|
+
if (done) {
|
|
1085
|
+
streamEnded = true;
|
|
1086
|
+
console.log(
|
|
1087
|
+
`SSE\u6D41\u5DF2\u7ED3\u675F [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
1088
|
+
);
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
} catch (streamError) {
|
|
1093
|
+
console.error("Error reading SSE stream:", streamError);
|
|
1094
|
+
throw streamError;
|
|
1095
|
+
} finally {
|
|
1096
|
+
reader.releaseLock();
|
|
1097
|
+
}
|
|
1098
|
+
if (callback_event) {
|
|
1099
|
+
const state = await agent_state({ assistant_id, thread_id });
|
|
1100
|
+
import_core4.eventBus.publish(callback_event, {
|
|
1101
|
+
success: true,
|
|
1102
|
+
state,
|
|
1103
|
+
config: { assistant_id, thread_id, tenant_id }
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
console.log(
|
|
1107
|
+
`\u4EFB\u52A1\u5904\u7406\u6210\u529F [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
1108
|
+
);
|
|
1109
|
+
return true;
|
|
1110
|
+
} else {
|
|
1111
|
+
await response.text();
|
|
1112
|
+
if (callback_event) {
|
|
1113
|
+
const state = await agent_state({ assistant_id, thread_id });
|
|
1114
|
+
import_core4.eventBus.publish(callback_event, {
|
|
1115
|
+
success: true,
|
|
1116
|
+
state,
|
|
1117
|
+
config: { assistant_id, thread_id, tenant_id }
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
console.log(
|
|
1121
|
+
`\u4EFB\u52A1\u5904\u7406\u6210\u529F [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
1122
|
+
);
|
|
1123
|
+
return true;
|
|
1269
1124
|
}
|
|
1270
|
-
console.log(
|
|
1271
|
-
`\u4EFB\u52A1\u5904\u7406\u6210\u529F [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
1272
|
-
);
|
|
1273
|
-
return true;
|
|
1274
1125
|
} catch (error) {
|
|
1275
1126
|
console.error(
|
|
1276
1127
|
`Agent\u4EFB\u52A1\u6267\u884C\u5931\u8D25: ${assistant_id}, \u7EBF\u7A0B: ${thread_id}`,
|
|
@@ -1287,7 +1138,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
1287
1138
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
1288
1139
|
}
|
|
1289
1140
|
if (callback_event) {
|
|
1290
|
-
|
|
1141
|
+
import_core4.eventBus.publish(callback_event, {
|
|
1291
1142
|
success: false,
|
|
1292
1143
|
error: error instanceof Error ? error.message : String(error),
|
|
1293
1144
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -1325,7 +1176,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
1325
1176
|
* 初始化事件监听和队列轮询
|
|
1326
1177
|
*/
|
|
1327
1178
|
initialize() {
|
|
1328
|
-
|
|
1179
|
+
import_core4.eventBus.subscribe(import_core4.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
1329
1180
|
this.startPollingQueue();
|
|
1330
1181
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
1331
1182
|
}
|
|
@@ -1368,7 +1219,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
1368
1219
|
*/
|
|
1369
1220
|
async processNextTask() {
|
|
1370
1221
|
try {
|
|
1371
|
-
const queueResult = await
|
|
1222
|
+
const queueResult = await popAgentTaskFromQueue();
|
|
1372
1223
|
if (queueResult && queueResult.data) {
|
|
1373
1224
|
const taskItem = queueResult.data;
|
|
1374
1225
|
if (taskItem && typeof taskItem === "object") {
|
|
@@ -1444,7 +1295,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
1444
1295
|
handleAgentTask(taskRequest).catch((error) => {
|
|
1445
1296
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
1446
1297
|
if (taskRequest.callback_event) {
|
|
1447
|
-
|
|
1298
|
+
import_core4.eventBus.publish(taskRequest.callback_event, {
|
|
1448
1299
|
success: false,
|
|
1449
1300
|
error: error instanceof Error ? error.message : String(error),
|
|
1450
1301
|
config: {
|