@axiom-lattice/gateway 2.1.71 → 2.1.72
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 +6 -0
- package/dist/index.js +32 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/controllers/workflow-tracking.ts +30 -29
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply } from "fastify";
|
|
2
2
|
import { getStoreLattice, agentInstanceManager } from "@axiom-lattice/core";
|
|
3
3
|
import type { WorkflowTrackingStore, WorkflowRun, RunStep } from "@axiom-lattice/protocols";
|
|
4
|
+
import { MessageChunkTypes } from "@axiom-lattice/protocols";
|
|
4
5
|
|
|
5
6
|
function getTenantId(request: FastifyRequest): string {
|
|
6
7
|
const userTenantId = (request as any).user?.tenantId;
|
|
@@ -421,43 +422,43 @@ export async function replyInboxTask(
|
|
|
421
422
|
});
|
|
422
423
|
}
|
|
423
424
|
|
|
424
|
-
// 2. 获取 Agent
|
|
425
|
+
// 2. 获取 Agent 实例(补齐参数,与 createRun 一致)
|
|
426
|
+
const workspace_id = request.headers["x-workspace-id"] as string;
|
|
427
|
+
const project_id = request.headers["x-project-id"] as string;
|
|
425
428
|
const agent = agentInstanceManager.getAgent({
|
|
426
429
|
assistant_id: run.assistantId,
|
|
427
430
|
thread_id: run.threadId,
|
|
428
431
|
tenant_id: tenantId,
|
|
432
|
+
workspace_id,
|
|
433
|
+
project_id,
|
|
429
434
|
});
|
|
430
435
|
|
|
431
|
-
// 3.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
// 添加 resume 消息到队列
|
|
441
|
-
await agent.addMessage({
|
|
442
|
-
input: { message: "Clarification answers submitted" },
|
|
443
|
-
command: {
|
|
444
|
-
resume: {
|
|
445
|
-
action: "submit",
|
|
446
|
-
data: { answers },
|
|
447
|
-
message: "Clarification answers submitted",
|
|
448
|
-
},
|
|
436
|
+
// 3. 直接在后台触发 resume 执行(不等待,不阻塞 HTTP 响应)
|
|
437
|
+
agent.addMessage({
|
|
438
|
+
input: { message: "Clarification answers submitted" },
|
|
439
|
+
command: {
|
|
440
|
+
resume: {
|
|
441
|
+
action: "submit",
|
|
442
|
+
data: { answers },
|
|
443
|
+
message: "Clarification answers submitted",
|
|
449
444
|
},
|
|
445
|
+
},
|
|
446
|
+
}).then((result) => {
|
|
447
|
+
// addMessage 成功后,触发 chunkStream 消费(驱动执行)
|
|
448
|
+
// 不 await stream,让它在后台运行
|
|
449
|
+
const stream = agent.chunkStream(
|
|
450
|
+
result.messageId,
|
|
451
|
+
[MessageChunkTypes.MESSAGE_COMPLETED]
|
|
452
|
+
);
|
|
453
|
+
// 消费 stream 但不阻塞(后台驱动 agent 执行)
|
|
454
|
+
(async () => {
|
|
455
|
+
for await (const _ of stream) { /* 丢弃 chunks */ }
|
|
456
|
+
})().catch((error) => {
|
|
457
|
+
request.log.error(error, "Background chunk stream error");
|
|
450
458
|
});
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
} catch (error) {
|
|
455
|
-
return reply.status(400).send({
|
|
456
|
-
success: false,
|
|
457
|
-
message: "Failed to resume workflow",
|
|
458
|
-
error: error instanceof Error ? error.message : String(error),
|
|
459
|
-
});
|
|
460
|
-
}
|
|
459
|
+
}).catch((error) => {
|
|
460
|
+
request.log.error(error, "Background resume failed");
|
|
461
|
+
});
|
|
461
462
|
|
|
462
463
|
// 4. 立即返回成功(不等待 agent 执行完成)
|
|
463
464
|
return reply.status(200).send({
|