docs: document media cron tool tests · openclaw/openclaw@5c71f21
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Common parameter tests cover shared action gates and typed argument readers |
| 2 | +// used by channel/tool adapters. |
1 | 3 | import { describe, expect, it } from "vitest"; |
2 | 4 | import { |
3 | 5 | createActionGate, |
@@ -47,6 +49,8 @@ describe("readNumberParam", () => {
|
47 | 49 | }); |
48 | 50 | |
49 | 51 | it("keeps partial parse behavior by default", () => { |
| 52 | +// Some legacy channel tools pass identifiers with numeric prefixes; strict |
| 53 | +// parsing is opt-in for new bounded fields. |
50 | 54 | const params = { messageId: "42abc" }; |
51 | 55 | expect(readNumberParam(params, "messageId")).toBe(42); |
52 | 56 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Cron flat-parameter tests cover model-friendly shorthand recovery before |
| 2 | +// gateway cron RPC dispatch. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const { callGatewayToolMock } = vi.hoisted(() => ({ |
@@ -93,6 +95,8 @@ describe("cron tool flat-params", () => {
|
93 | 95 | }); |
94 | 96 | |
95 | 97 | it("leaves out-of-range flat atMs for gateway validation", async () => { |
| 98 | +// The gateway owns final schedule validation; flat recovery should preserve |
| 99 | +// the supplied value instead of silently coercing an invalid date. |
96 | 100 | const tool = createCronTool(undefined, { callGatewayTool: callGatewayToolMock }); |
97 | 101 | const invalidAtMs = 8_640_000_000_000_001; |
98 | 102 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Cron tool schema tests cover the provider-facing parameter shape and runtime |
| 2 | +// validation compatibility for cron jobs. |
1 | 3 | import { Value } from "typebox/value"; |
2 | 4 | import { describe, expect, it } from "vitest"; |
3 | 5 | import { normalizeToolParameterSchema } from "../agent-tools.schema.js"; |
@@ -110,6 +112,8 @@ describe("CronToolSchema", () => {
|
110 | 112 | }); |
111 | 113 | |
112 | 114 | it("describes cron expressions as local wall-clock time in the supplied timezone", () => { |
| 115 | +// Cron expressions are interpreted by the gateway scheduler; model-facing |
| 116 | +// docs must not encourage UTC conversion by the agent. |
113 | 117 | const jobExpr = propertyAt(schemaRecord, "job.schedule.expr"); |
114 | 118 | const patchExpr = propertyAt(schemaRecord, "patch.schedule.expr"); |
115 | 119 | const jobTz = propertyAt(schemaRecord, "job.schedule.tz"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Goal tool tests cover goal accounting projection and correct session-store |
| 2 | +// routing for global and scoped sessions. |
1 | 3 | import fs from "node:fs/promises"; |
2 | 4 | import os from "node:os"; |
3 | 5 | import path from "node:path"; |
@@ -18,6 +20,8 @@ async function createStoreConfig(): Promise<{ config: OpenClawConfig; template:
|
18 | 20 | |
19 | 21 | describe("goal tools", () => { |
20 | 22 | it("keeps get_goal read-only when accounting changes are projected", async () => { |
| 23 | +// Budget-limited status can be derived for display without mutating the |
| 24 | +// stored active goal record. |
21 | 25 | const { config, template } = await createStoreConfig(); |
22 | 26 | const storePath = resolveStorePath(template, { agentId: "research" }); |
23 | 27 | await upsertSessionEntry({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Background media generation tests cover detached task completion, requester |
| 2 | +// wake delivery, and direct media fallback behavior. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const subagentAnnounceDeliveryMocks = vi.hoisted(() => ({ |
@@ -32,6 +34,8 @@ describe("shouldDetachMediaGenerationTask", () => {
|
32 | 34 | |
33 | 35 | describe("scheduleMediaGenerationTaskCompletion", () => { |
34 | 36 | it("keeps a generated media task active until completion delivery finishes", async () => { |
| 37 | +// Mark completion only after the requester wake has been attempted; otherwise |
| 38 | +// task status can say done before the visible media reaches the requester. |
35 | 39 | const order: string[] = []; |
36 | 40 | const scheduled: Array<() => Promise<void>> = []; |
37 | 41 | const completeTaskRun = vi.fn(() => { |
@@ -497,6 +501,8 @@ describe("createMediaGenerationTaskLifecycle", () => {
|
497 | 501 | }); |
498 | 502 | |
499 | 503 | it("does not direct-deliver generated media after requester abandonment", async () => { |
| 504 | +// Abandoned requester sessions are terminal; direct delivery would re-open a |
| 505 | +// conversation the task lifecycle already decided to stop. |
500 | 506 | subagentAnnounceDeliveryMocks.deliverSubagentAnnouncement.mockResolvedValueOnce({ |
501 | 507 | delivered: false, |
502 | 508 | path: "none", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Shared media tool tests cover root separation, provider availability, and |
| 2 | +// model-registry normalization for generation/understanding tools. |
1 | 3 | import path from "node:path"; |
2 | 4 | import { pathToFileURL } from "node:url"; |
3 | 5 | import { afterEach, describe, expect, it, vi } from "vitest"; |
@@ -85,6 +87,8 @@ describe("resolveMediaToolLocalRoots", () => {
|
85 | 87 | }); |
86 | 88 | |
87 | 89 | it("keeps channel inbound attachment roots separate from local roots", () => { |
| 90 | +// Inbound channel roots may include broad chat attachment folders; keep them |
| 91 | +// out of local filesystem allowlists unless the channel context asks. |
88 | 92 | const accountRoot = path.join("/tmp", "openclaw-imessage-work"); |
89 | 93 | const sharedRoot = path.join("/tmp", "openclaw-imessage-shared"); |
90 | 94 | const cfg = { |
@@ -150,6 +154,8 @@ describe("resolveModelFromRegistry", () => {
|
150 | 154 | }); |
151 | 155 | |
152 | 156 | it("falls back to provider-prefixed custom model IDs", () => { |
| 157 | +// Custom providers can store ids with provider prefixes; try both forms so |
| 158 | +// callers can pass the short local model id. |
153 | 159 | const foundModel = { provider: "kimchi", id: "kimchi/claude-opus-4-6" }; |
154 | 160 | const { calls, registry } = createModelRegistryStub((_, modelId) => |
155 | 161 | modelId === "kimchi/claude-opus-4-6" ? foundModel : null, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Music generation status tests cover duplicate guards and explicit status |
| 2 | +// actions for background music tasks. |
1 | 3 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import * as musicGenerationRuntime from "../../music-generation/runtime.js"; |
3 | 5 | import { |
@@ -45,6 +47,8 @@ describe("createMusicGenerateTool status actions", () => {
|
45 | 47 | }); |
46 | 48 | |
47 | 49 | it("returns active task status instead of starting a duplicate generation", () => { |
| 50 | +// Duplicate guard responses prevent agents from launching parallel provider |
| 51 | +// jobs while a matching request is still running. |
48 | 52 | taskRuntimeInternalMocks.listTasksForOwnerKey.mockReturnValue([ |
49 | 53 | { |
50 | 54 | taskId: "task-active", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Video generation status tests cover duplicate guards and explicit status |
| 2 | +// actions for background video tasks. |
1 | 3 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import * as videoGenerationRuntime from "../../video-generation/runtime.js"; |
3 | 5 | import { |
@@ -148,6 +150,8 @@ describe("createVideoGenerateTool status actions", () => {
|
148 | 150 | }); |
149 | 151 | |
150 | 152 | it("returns recent succeeded video status instead of starting a duplicate generation", () => { |
| 153 | +// A recently completed request is still a duplicate from the user's |
| 154 | +// perspective; report status instead of spending another provider call. |
151 | 155 | const now = Date.now(); |
152 | 156 | recordRecentMediaGenerationTaskStartForSession({ |
153 | 157 | sessionKey: "agent:main:discord:direct:123", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。