




















@@ -1,3 +1,5 @@
1+// PDF tool tests cover model discovery, input validation, managed inbound refs,
2+// native document providers, extraction fallback, and model-facing schema.
13import fs from "node:fs/promises";
24import os from "node:os";
35import path from "node:path";
@@ -116,6 +118,8 @@ async function stubPdfToolInfra(
116118modelFound?: boolean;
117119},
118120) {
121+// Keep PDF tool tests focused on orchestration; provider discovery, auth, and
122+// remote media loading are replaced with narrow spies at the module boundary.
119123const loadSpy = vi.spyOn(webMedia, "loadWebMediaRaw");
120124if (params?.mockLoad !== false) {
121125loadSpy.mockResolvedValue(FAKE_PDF_MEDIA as never);
@@ -156,6 +160,8 @@ async function stubPdfToolInfra(
156160async function withManagedInboundPdf(
157161run: (params: { stateDir: string; mediaId: string; mediaPath: string }) => Promise<void>,
158162) {
163+// Managed inbound PDFs live under state and may be addressed by claim-check
164+// IDs or absolute paths even when workspace-only policy is active.
159165const stateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-pdf-managed-inbound-"));
160166const inboundDir = path.join(stateDir, "media", "inbound");
161167const mediaId = "claim-check-test.pdf";
@@ -483,6 +489,8 @@ describe("createPdfTool", () => {
483489});
484490485491it("uses native PDF path without eager extraction", async () => {
492+// Document-capable providers receive the PDF bytes directly; extraction is
493+// reserved for text-only model paths.
486494await withTempPdfAgentDir(async (agentDir) => {
487495const workspaceDir = path.join(agentDir, "workspace");
488496await stubPdfToolInfra(agentDir, { provider: "anthropic", input: ["text", "document"] });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。