mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 13:14:46 +00:00
fix(cli): suppress empty delivery plans
This commit is contained in:
@@ -610,6 +610,35 @@ describe("normalizeAgentCommandReplyPayloads", () => {
|
||||
expect(deliverOutboundPayloadsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("surfaces no-visible-payload deliveryStatus after payload normalization suppresses output", async () => {
|
||||
const delivered = await deliverAgentCommandResult({
|
||||
cfg: {} as OpenClawConfig,
|
||||
deps: {} as CliDeps,
|
||||
runtime: { log: vi.fn(), error: vi.fn() } as never,
|
||||
opts: {
|
||||
message: "go",
|
||||
deliver: true,
|
||||
replyChannel: "slack",
|
||||
replyTo: "#general",
|
||||
} as AgentCommandOpts,
|
||||
outboundSession: undefined,
|
||||
sessionEntry: undefined,
|
||||
payloads: [{ text: "NO_REPLY" }],
|
||||
result: createResult(),
|
||||
});
|
||||
|
||||
expect(delivered.payloads).toEqual([]);
|
||||
expect(delivered.deliverySucceeded).toBeUndefined();
|
||||
expect(delivered.deliveryStatus).toMatchObject({
|
||||
requested: true,
|
||||
attempted: false,
|
||||
status: "suppressed",
|
||||
succeeded: true,
|
||||
reason: "no_visible_payload",
|
||||
});
|
||||
expect(deliverOutboundPayloadsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves preflight deliveryStatus when best-effort delivery has no payloads", async () => {
|
||||
const runtime = { log: vi.fn(), error: vi.fn() };
|
||||
|
||||
|
||||
@@ -503,17 +503,17 @@ export async function deliverAgentCommandResult(params: {
|
||||
throw strictPreDeliveryError;
|
||||
}
|
||||
|
||||
if (!payloads || payloads.length === 0) {
|
||||
const deliveryPayloads = projectOutboundPayloadPlanForOutbound(outboundPayloadPlan);
|
||||
if (deliveryPayloads.length === 0) {
|
||||
deliveryStatus = deliver ? (deliveryStatus ?? noVisiblePayloadStatus()) : undefined;
|
||||
emitJsonEnvelope(deliveryStatus);
|
||||
return {
|
||||
payloads: [],
|
||||
payloads: normalizedPayloads,
|
||||
meta: resultMeta,
|
||||
...(deliveryStatus ? { deliveryStatus } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
const deliveryPayloads = projectOutboundPayloadPlanForOutbound(outboundPayloadPlan);
|
||||
let deliverySucceeded = false;
|
||||
const logPayload = (payload: NormalizedOutboundPayload) => {
|
||||
if (opts.json) {
|
||||
|
||||
Reference in New Issue
Block a user