@@ -475,6 +475,38 @@ describe("normalizeCronJobCreate", () => {
|
475 | 475 | expect(validateCronAddParams(normalized)).toBe(true); |
476 | 476 | }); |
477 | 477 | |
| 478 | +it("promotes implicit text payloads with agentTurn hints to agentTurn create jobs", () => { |
| 479 | +const normalized = normalizeCronJobCreate({ |
| 480 | +name: "implicit-agent-turn", |
| 481 | +schedule: { kind: "every", everyMs: 60_000 }, |
| 482 | +payload: { |
| 483 | +text: " summarize the build ", |
| 484 | +model: " openai/gpt-5 ", |
| 485 | +fallbacks: [" anthropic/claude-haiku-3-5 "], |
| 486 | +thinking: " high ", |
| 487 | +timeoutSeconds: 45, |
| 488 | +lightContext: true, |
| 489 | +toolsAllow: [" read "], |
| 490 | +allowUnsafeExternalContent: true, |
| 491 | +}, |
| 492 | +}) as unknown as Record<string, unknown>; |
| 493 | + |
| 494 | +expect(normalized.sessionTarget).toBe("isolated"); |
| 495 | +expect((normalized.delivery as Record<string, unknown>).mode).toBe("announce"); |
| 496 | +expect(normalized.payload).toEqual({ |
| 497 | +kind: "agentTurn", |
| 498 | +message: "summarize the build", |
| 499 | +model: "openai/gpt-5", |
| 500 | +fallbacks: ["anthropic/claude-haiku-3-5"], |
| 501 | +thinking: "high", |
| 502 | +timeoutSeconds: 45, |
| 503 | +lightContext: true, |
| 504 | +toolsAllow: ["read"], |
| 505 | +allowUnsafeExternalContent: true, |
| 506 | +}); |
| 507 | +expect(validateCronAddParams(normalized)).toBe(true); |
| 508 | +}); |
| 509 | + |
478 | 510 | it("prunes agentTurn-only payload fields from systemEvent create jobs", () => { |
479 | 511 | const normalized = normalizeCronJobCreate({ |
480 | 512 | name: "system-event-prune", |
@@ -843,6 +875,22 @@ describe("normalizeCronJobPatch", () => {
|
843 | 875 | expect(validateCronUpdateParams({ id: "job-1", patch: normalized })).toBe(true); |
844 | 876 | }); |
845 | 877 | |
| 878 | +it("promotes implicit text payloads with agentTurn hints to agentTurn patches", () => { |
| 879 | +const normalized = normalizeCronJobPatch({ |
| 880 | +payload: { |
| 881 | +text: " continue the report ", |
| 882 | +toolsAllow: [" read "], |
| 883 | +}, |
| 884 | +}) as unknown as Record<string, unknown>; |
| 885 | + |
| 886 | +expect(normalized.payload).toEqual({ |
| 887 | +kind: "agentTurn", |
| 888 | +message: "continue the report", |
| 889 | +toolsAllow: ["read"], |
| 890 | +}); |
| 891 | +expect(validateCronUpdateParams({ id: "job-1", patch: normalized })).toBe(true); |
| 892 | +}); |
| 893 | + |
846 | 894 | it("preserves null sessionKey patches and trims string values", () => { |
847 | 895 | const trimmed = normalizeCronJobPatch({ |
848 | 896 | sessionKey: " agent:main:telegram:group:-100123 ", |
|