fix: recover subagent waits after transport drops

Fix subagent recovery and session state reconciliation.

Thanks @ZiPengWei.
This commit is contained in:
wzp
2026-04-25 15:12:20 +08:00
committed by GitHub
parent 5376a4a5d6
commit 845040214e
20 changed files with 1283 additions and 49 deletions

View File

@@ -892,6 +892,33 @@ describe("normalizeFeishuTarget", () => {
});
});
describe("feishuPlugin.messaging.resolveDeliveryTarget", () => {
it("routes direct conversations to user targets", () => {
expect(
feishuPlugin.messaging?.resolveDeliveryTarget?.({
conversationId: "ou_123",
}),
).toEqual({ to: "user:ou_123" });
});
it("routes group conversations to chat targets", () => {
expect(
feishuPlugin.messaging?.resolveDeliveryTarget?.({
conversationId: "oc_123",
}),
).toEqual({ to: "chat:oc_123" });
});
it("routes topic conversations to parent chat plus thread id", () => {
expect(
feishuPlugin.messaging?.resolveDeliveryTarget?.({
conversationId: "oc_123:topic:omt_456",
parentConversationId: "oc_123",
}),
).toEqual({ to: "chat:oc_123", threadId: "omt_456" });
});
});
describe("looksLikeFeishuId", () => {
it("accepts provider-prefixed user targets", () => {
expect(looksLikeFeishuId("feishu:user:ou_123")).toBe(true);

View File

@@ -1134,6 +1134,20 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount, FeishuProbeResul
setupWizard: feishuSetupWizard,
messaging: {
normalizeTarget: (raw) => normalizeFeishuTarget(raw) ?? undefined,
resolveDeliveryTarget: ({ conversationId, parentConversationId }) => {
const directId = parseFeishuDirectConversationId(conversationId);
if (directId) {
return { to: `user:${directId}` };
}
const parsed = parseFeishuConversationId({ conversationId, parentConversationId });
if (parsed?.topicId) {
return {
to: `chat:${parentConversationId?.trim() || parsed.chatId}`,
threadId: parsed.topicId,
};
}
return { to: `chat:${parsed?.chatId ?? conversationId.trim()}` };
},
resolveSessionConversation: ({ kind, rawId }) =>
resolveFeishuSessionConversation({ kind, rawId }),
resolveOutboundSessionRoute: (params) => resolveFeishuOutboundSessionRoute(params),