


























@@ -19,6 +19,7 @@ vi.mock("../../config/sessions/delivery-info.js", () => ({
1919extractDeliveryInfo: extractDeliveryInfoMock,
2020}));
212122+import { GatewayClientRequestError } from "../../gateway/client.js";
2223import { buildAgentPeerSessionKey } from "../../routing/session-key.js";
2324import { createCronTool } from "./cron-tool.js";
2425@@ -333,7 +334,13 @@ describe("cron tool", () => {
333334});
334335335336const params = expectSingleGatewayCallMethod("cron.list");
336-expect(params).toEqual({ includeDisabled: true, agentId: "agent-123", limit: 200, offset: 0 });
337+expect(params).toEqual({
338+includeDisabled: true,
339+compact: true,
340+agentId: "agent-123",
341+limit: 200,
342+offset: 0,
343+});
337344expect(result.details).toEqual({
338345jobs: [{ id: "job-current", name: "current" }],
339346total: 1,
@@ -385,11 +392,23 @@ describe("cron tool", () => {
385392expect(callGatewayMock).toHaveBeenCalledTimes(2);
386393expect(readGatewayCall(0)).toEqual({
387394method: "cron.list",
388-params: { includeDisabled: true, agentId: "agent-123", limit: 200, offset: 0 },
395+params: {
396+includeDisabled: true,
397+compact: true,
398+agentId: "agent-123",
399+limit: 200,
400+offset: 0,
401+},
389402});
390403expect(readGatewayCall(1)).toEqual({
391404method: "cron.list",
392-params: { includeDisabled: true, agentId: "agent-123", limit: 200, offset: 200 },
405+params: {
406+includeDisabled: true,
407+compact: true,
408+agentId: "agent-123",
409+limit: 200,
410+offset: 200,
411+},
393412});
394413expect(result.details).toEqual({
395414jobs: [{ id: "job-current", name: "current" }],
@@ -429,7 +448,7 @@ describe("cron tool", () => {
429448});
430449431450const params = expectSingleGatewayCallMethod("cron.list");
432-expect(params).toEqual({ includeDisabled: false, agentId: "agent-123" });
451+expect(params).toEqual({ includeDisabled: false, compact: true, agentId: "agent-123" });
433452});
434453435454it("prefers explicit cron list agent id over the requester session", async () => {
@@ -444,7 +463,32 @@ describe("cron tool", () => {
444463});
445464446465const params = expectSingleGatewayCallMethod("cron.list");
447-expect(params).toEqual({ includeDisabled: true, agentId: "ops" });
466+expect(params).toEqual({ includeDisabled: true, compact: true, agentId: "ops" });
467+});
468+469+it("retries cron.list without compact for older gateways", async () => {
470+callGatewayMock
471+.mockRejectedValueOnce(
472+new GatewayClientRequestError({
473+code: "INVALID_REQUEST",
474+message: "invalid cron.list params: at root: unexpected property 'compact'",
475+}),
476+)
477+.mockResolvedValueOnce({ jobs: [] });
478+const tool = createTestCronTool({
479+agentSessionKey: "agent:agent-123:telegram:direct:channing",
480+});
481+482+await tool.execute("call-list-older-gateway", { action: "list" });
483+484+expect(readGatewayCall(0)).toEqual({
485+method: "cron.list",
486+params: { includeDisabled: false, compact: true, agentId: "agent-123" },
487+});
488+expect(readGatewayCall(1)).toEqual({
489+method: "cron.list",
490+params: { includeDisabled: false, agentId: "agent-123" },
491+});
448492});
449493450494describe("wake routing", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。