docs: document remaining agent tool tests · openclaw/openclaw@f39aff1
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Agent step tests cover nested session handoff, transcript bookkeeping, and |
| 2 | +// MCP runtime retirement after completed nested turns. |
1 | 3 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { CallGatewayOptions } from "../../gateway/call.js"; |
3 | 5 | import { runAgentStep, testing } from "./agent-step.js"; |
@@ -26,6 +28,8 @@ describe("runAgentStep", () => {
|
26 | 28 | }); |
27 | 29 | |
28 | 30 | it("retires bundle MCP runtime after successful nested agent steps", async () => { |
| 31 | +// Nested steps disable automatic delivery and carry provenance so the reply |
| 32 | +// returns through the message tool path instead of the channel. |
29 | 33 | const gatewayCalls: CallGatewayOptions[] = []; |
30 | 34 | testing.setDepsForTest({ |
31 | 35 | callGateway: async <T = unknown>(opts: CallGatewayOptions): Promise<T> => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Cron tool tests cover schedule guidance, scoped job operations, delivery |
| 2 | +// context inheritance, session routing, and agent id ownership. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const { callGatewayMock, extractDeliveryInfoMock } = vi.hoisted(() => ({ |
@@ -177,6 +179,8 @@ describe("cron tool", () => {
|
177 | 179 | }); |
178 | 180 | |
179 | 181 | it("allows scoped isolated cron runs to remove the current job", async () => { |
| 182 | +// Self-removal scope lets a cron-triggered run clean up its own schedule |
| 183 | +// without granting broad cron mutation access. |
180 | 184 | const tool = createTestCronTool({ selfRemoveOnlyJobId: "job-current" }); |
181 | 185 | |
182 | 186 | await tool.execute("call-self-remove", { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Music background tests cover task-run creation, progress recording, and |
| 2 | +// completion delivery through announcement agents or direct fallback sends. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { MUSIC_GENERATION_TASK_KIND } from "../music-generation-task-status.js"; |
3 | 5 | import { |
@@ -22,6 +24,8 @@ const {
|
22 | 24 | } = await import("./music-generate-background.js"); |
23 | 25 | |
24 | 26 | function getDeliveredInternalEvents(): Array<Record<string, unknown>> { |
| 27 | +// Completion agents receive internal events; tests inspect them to keep the |
| 28 | +// visible-reply media contract explicit. |
25 | 29 | const params = announceDeliveryMocks.deliverSubagentAnnouncement.mock.calls.at(0)?.[0] as |
26 | 30 | | { internalEvents?: unknown } |
27 | 31 | | undefined; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Music generation tool tests cover provider selection, task lifecycle updates, |
| 2 | +// duplicate guards, media persistence, and result delivery metadata. |
1 | 3 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { OpenClawConfig } from "../../config/config.js"; |
3 | 5 | import * as mediaStore from "../../media/store.js"; |
@@ -41,6 +43,8 @@ const musicGenerationRuntimeMocks = vi.hoisted(() => ({
|
41 | 43 | })); |
42 | 44 | |
43 | 45 | const musicGenerateBackgroundMocks = vi.hoisted(() => ({ |
| 46 | +// Mirror the background lifecycle contract so tool tests can assert task-run |
| 47 | +// effects without spawning detached completion workers. |
44 | 48 | musicGenerationTaskLifecycle: { |
45 | 49 | createTaskRun: ( |
46 | 50 | params: Parameters<typeof musicGenerateBackground.createMusicGenerationTaskRun>[0], |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Nodes tool tests cover gateway-scoped node actions, media payload writing, |
| 2 | +// numeric schema guardrails, and pairing approval scopes. |
1 | 3 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const gatewayMocks = vi.hoisted(() => ({ |
@@ -68,6 +70,8 @@ function mockNodePairApproveFlow(pendingRequest: {
|
68 | 70 | requiredApproveScopes?: string[]; |
69 | 71 | commands?: string[]; |
70 | 72 | }): void { |
| 73 | +// Pairing approval is two-step by design: list pending requests under the |
| 74 | +// operator scope, then approve with the request's required scopes. |
71 | 75 | gatewayMocks.callGatewayTool.mockImplementation(async (method, _opts, params, extra) => { |
72 | 76 | if (method === "node.pair.list") { |
73 | 77 | return { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// TTS tool tests cover guidance, speech runtime arguments, delivery metadata, |
| 2 | +// timeout validation, and reply-directive defusing. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import * as ttsRuntime from "../../tts/tts.js"; |
3 | 5 | import { createTtsTool } from "./tts-tool.js"; |
@@ -12,6 +14,8 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
12 | 14 | } |
13 | 15 | |
14 | 16 | function latestTextToSpeechArgs(): Record<string, unknown> { |
| 17 | +// Speech runtime args are the public handoff between the model-facing tool |
| 18 | +// and provider-specific synthesis backends. |
15 | 19 | return requireRecord(textToSpeechSpy.mock.calls.at(-1)?.[0], "text-to-speech args"); |
16 | 20 | } |
17 | 21 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Web search tests cover model-facing schema limits, provider-specific time |
| 2 | +// filters, unsupported filter errors, and scoped provider config merging. |
1 | 3 | import { describe, expect, it } from "vitest"; |
2 | 4 | import { |
3 | 5 | MAX_SEARCH_COUNT, |
@@ -202,6 +204,8 @@ describe("web_search scoped config merge", () => {
|
202 | 204 | |
203 | 205 | expect(merged?.brave).toEqual({ apiKey: "brave-test-key" }); |
204 | 206 | expect(merged?.apiKey).toBe("brave-test-key"); |
| 207 | +// Injected provider detail is available to runtime validation but hidden |
| 208 | +// from ordinary config serialization. |
205 | 209 | expect(Object.keys(merged ?? {})).toEqual(["provider", "apiKey"]); |
206 | 210 | expect(Object.getOwnPropertyDescriptor(merged, "brave")?.enumerable).toBe(false); |
207 | 211 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Web tool runtime-context tests cover late-bound config snapshots and |
| 2 | +// plugin-owner lookups for search/fetch provider selection. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | resolveWebFetchToolRuntimeContext, |
@@ -23,6 +25,8 @@ vi.mock("../../secrets/runtime-state.js", () => ({
|
23 | 25 | })); |
24 | 26 | |
25 | 27 | function latestOwnerLookupParams(): Record<string, unknown> { |
| 28 | +// Owner lookups are the evidence for whether runtime providers stay enabled |
| 29 | +// or a configured plugin takes over the tool call. |
26 | 30 | const params = mocks.resolveManifestContractOwnerPluginId.mock.calls.at(-1)?.[0]; |
27 | 31 | if (!params || typeof params !== "object") { |
28 | 32 | throw new Error("expected owner lookup params"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Web readability tests cover plugin extractor dispatch, per-config resolver |
| 2 | +// caching, and loader/extractor failure fallback. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const { resolvePluginWebContentExtractorsMock } = vi.hoisted(() => ({ |
@@ -40,6 +42,8 @@ describe("web fetch readability", () => {
|
40 | 42 | }); |
41 | 43 | |
42 | 44 | it("reuses extractor resolution for repeated calls with the same config object", async () => { |
| 45 | +// Extractor manifests are process-stable for a config snapshot; repeated |
| 46 | +// reads should not re-run plugin discovery on the fetch hot path. |
43 | 47 | const config = {}; |
44 | 48 | resolvePluginWebContentExtractorsMock.mockReturnValue([ |
45 | 49 | { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。