@axiom-lattice/gateway 2.1.47 → 2.1.49
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 +7 -7
- package/CHANGELOG.md +20 -0
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/controllers/memory.ts +9 -1
- package/src/controllers/run.ts +4 -4
- package/src/index.ts +11 -0
- package/src/services/agent_task_consumer.ts +9 -2
package/dist/index.mjs
CHANGED
|
@@ -202,6 +202,7 @@ import { v4 } from "uuid";
|
|
|
202
202
|
import {
|
|
203
203
|
agentInstanceManager as agentInstanceManager2
|
|
204
204
|
} from "@axiom-lattice/core";
|
|
205
|
+
import { MessageChunkTypes } from "@axiom-lattice/protocols";
|
|
205
206
|
var createRun = async (request, reply) => {
|
|
206
207
|
try {
|
|
207
208
|
const {
|
|
@@ -246,9 +247,8 @@ var createRun = async (request, reply) => {
|
|
|
246
247
|
command,
|
|
247
248
|
custom_run_config
|
|
248
249
|
});
|
|
249
|
-
const stream = agent.chunkStream(result.messageId);
|
|
250
|
+
const stream = agent.chunkStream(result.messageId, [MessageChunkTypes.MESSAGE_COMPLETED]);
|
|
250
251
|
for await (const chunk of stream) {
|
|
251
|
-
console.log(input.message, chunk.data.content);
|
|
252
252
|
const success = reply.raw.write(`data: ${JSON.stringify(chunk)}
|
|
253
253
|
|
|
254
254
|
`);
|
|
@@ -317,7 +317,7 @@ var resumeStream = async (request, reply) => {
|
|
|
317
317
|
workspace_id,
|
|
318
318
|
project_id
|
|
319
319
|
});
|
|
320
|
-
const stream = agent.chunkStream(message_id,
|
|
320
|
+
const stream = agent.chunkStream(message_id, [MessageChunkTypes.THREAD_IDLE]);
|
|
321
321
|
for await (const chunk of stream) {
|
|
322
322
|
reply.raw.write(`data: ${JSON.stringify(chunk)}
|
|
323
323
|
|
|
@@ -450,9 +450,13 @@ var getAgentState = async (request, reply) => {
|
|
|
450
450
|
reply.status(500).send(result);
|
|
451
451
|
return;
|
|
452
452
|
}
|
|
453
|
+
const normalizedPendingMessages = pendingMessages.map((msg) => ({
|
|
454
|
+
...msg,
|
|
455
|
+
content: typeof msg.content === "object" && msg.content !== null ? msg.content.message || JSON.stringify(msg.content) : String(msg.content || "")
|
|
456
|
+
}));
|
|
453
457
|
const mergedResult = {
|
|
454
458
|
...result,
|
|
455
|
-
pendingMessages
|
|
459
|
+
pendingMessages: normalizedPendingMessages
|
|
456
460
|
};
|
|
457
461
|
reply.send(mergedResult);
|
|
458
462
|
} catch (error) {
|
|
@@ -4932,8 +4936,6 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
4932
4936
|
console.log(
|
|
4933
4937
|
`\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
4934
4938
|
);
|
|
4935
|
-
const apiUrl = AgentTaskConsumer.agent_run_endpoint;
|
|
4936
|
-
console.log(`apiUrl: ${apiUrl}`);
|
|
4937
4939
|
const agent = agentInstanceManager4.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: runConfig?.workspaceId, project_id: runConfig?.projectId, custom_run_config: runConfig });
|
|
4938
4940
|
await agent.addMessage({ input, command }, QueueMode.STEER);
|
|
4939
4941
|
if (callback_event) {
|
|
@@ -4944,6 +4946,13 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
4944
4946
|
config: { assistant_id, thread_id, tenant_id }
|
|
4945
4947
|
});
|
|
4946
4948
|
});
|
|
4949
|
+
agent.subscribeOnce("message:interrupted", (evt) => {
|
|
4950
|
+
eventBus2.publish(callback_event, {
|
|
4951
|
+
success: true,
|
|
4952
|
+
state: evt.state,
|
|
4953
|
+
config: { assistant_id, thread_id, tenant_id }
|
|
4954
|
+
});
|
|
4955
|
+
});
|
|
4947
4956
|
}
|
|
4948
4957
|
return true;
|
|
4949
4958
|
} catch (error) {
|
|
@@ -5145,7 +5154,8 @@ import {
|
|
|
5145
5154
|
loggerLatticeManager,
|
|
5146
5155
|
sandboxLatticeManager as sandboxLatticeManager2,
|
|
5147
5156
|
sqlDatabaseManager as sqlDatabaseManager2,
|
|
5148
|
-
getStoreLattice as getStoreLattice12
|
|
5157
|
+
getStoreLattice as getStoreLattice12,
|
|
5158
|
+
agentInstanceManager as agentInstanceManager5
|
|
5149
5159
|
} from "@axiom-lattice/core";
|
|
5150
5160
|
import {
|
|
5151
5161
|
LoggerType
|
|
@@ -5297,6 +5307,13 @@ var start = async (config) => {
|
|
|
5297
5307
|
agentTaskConsumer.startPollingQueue();
|
|
5298
5308
|
}
|
|
5299
5309
|
}
|
|
5310
|
+
try {
|
|
5311
|
+
logger.info("Starting agent instance recovery...");
|
|
5312
|
+
const restoreStats = await agentInstanceManager5.restore();
|
|
5313
|
+
logger.info(`Agent recovery complete: ${restoreStats.restored} threads restored, ${restoreStats.errors} errors`);
|
|
5314
|
+
} catch (error) {
|
|
5315
|
+
logger.error("Agent recovery failed", { error });
|
|
5316
|
+
}
|
|
5300
5317
|
} catch (err) {
|
|
5301
5318
|
logger.error("Server start failed", { error: err });
|
|
5302
5319
|
process.exit(1);
|