@axiom-lattice/gateway 2.1.70 → 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 +12 -0
- package/dist/index.js +33 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/controllers/workflow-tracking.ts +30 -20
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,34 +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
|
-
data: { answers },
|
|
440
|
-
message: "Clarification answers submitted",
|
|
441
|
-
},
|
|
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",
|
|
442
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");
|
|
443
458
|
});
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
success: false,
|
|
448
|
-
message: "Failed to resume workflow",
|
|
449
|
-
error: error instanceof Error ? error.message : String(error),
|
|
450
|
-
});
|
|
451
|
-
}
|
|
459
|
+
}).catch((error) => {
|
|
460
|
+
request.log.error(error, "Background resume failed");
|
|
461
|
+
});
|
|
452
462
|
|
|
453
463
|
// 4. 立即返回成功(不等待 agent 执行完成)
|
|
454
464
|
return reply.status(200).send({
|