@ynhcj/xiaoyi-channel 0.0.190-next → 0.0.191-next
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/dist/index.js +30 -17
- package/dist/src/outbound.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -184,23 +184,36 @@ function registerSubagentHooks(api) {
|
|
|
184
184
|
// This is the PRIMARY delivery tracking mechanism. When all expected
|
|
185
185
|
// subagents have ended and parent has settled, we finalize the A2A session.
|
|
186
186
|
api.on("subagent_ended", async (event, ctx) => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
187
|
+
try {
|
|
188
|
+
const requesterSessionKey = ctx?.requesterSessionKey;
|
|
189
|
+
if (!requesterSessionKey) {
|
|
190
|
+
console.log(`[XY-SUBAGENT-END] no requesterSessionKey in ctx`);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const transition = markSubagentEnded(requesterSessionKey);
|
|
194
|
+
console.log(`[XY-SUBAGENT-END] ended, targetSessionKey=${event?.targetSessionKey?.slice(0, 30)}, outcome=${event?.outcome}, complete=${transition?.isComplete ?? false}, shouldFinalize=${transition?.shouldFinalize ?? false}, transition=${!!transition}`);
|
|
195
|
+
if (transition?.shouldFinalize) {
|
|
196
|
+
console.log(`[XY-SUBAGENT-END] Starting finalization...`);
|
|
197
|
+
const [{ resolveXYConfig }, { deliverSubagentFinalResult }, { getXYRuntime }] = await Promise.all([
|
|
198
|
+
import("./src/config.js"),
|
|
199
|
+
import("./src/outbound.js"),
|
|
200
|
+
import("./src/runtime.js"),
|
|
201
|
+
]);
|
|
202
|
+
const rt = getXYRuntime();
|
|
203
|
+
console.log(`[XY-SUBAGENT-END] Runtime config type: ${typeof rt.config}, keys: ${rt.config ? Object.keys(rt.config).slice(0, 5).join(',') : 'null'}`);
|
|
204
|
+
const cfg = rt.config;
|
|
205
|
+
const config = resolveXYConfig(cfg);
|
|
206
|
+
console.log(`[XY-SUBAGENT-END] XY config resolved, wsUrl=${config.wsUrl?.slice(0, 20)}`);
|
|
207
|
+
await deliverSubagentFinalResult({
|
|
208
|
+
config,
|
|
209
|
+
state: transition.state,
|
|
210
|
+
reason: "all-subagents-ended-after-parent-settled",
|
|
211
|
+
});
|
|
212
|
+
console.log(`[XY-SUBAGENT-END] Finalized A2A session after all subagents ended`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
console.error(`[XY-SUBAGENT-END] Error in subagent_ended hook:`, err instanceof Error ? `${err.name}: ${err.message}\n${err.stack}` : String(err));
|
|
204
217
|
}
|
|
205
218
|
});
|
|
206
219
|
}
|
package/dist/src/outbound.js
CHANGED
|
@@ -20,7 +20,7 @@ export async function deliverSubagentFinalResult(params) {
|
|
|
20
20
|
const log = logger.withContext(state.sessionId, state.taskId);
|
|
21
21
|
const finalText = state.completionTexts.length > 0
|
|
22
22
|
? state.completionTexts.join("\n\n")
|
|
23
|
-
: (text ?? ""
|
|
23
|
+
: (text || undefined) ?? "子任务已完成";
|
|
24
24
|
await sendStatusUpdate({
|
|
25
25
|
config,
|
|
26
26
|
sessionId: state.sessionId,
|