Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
import { describe, expect, it } from "vitest";
import {
collectRemoteMarkdownImages,
replaceUploadedRemoteImages,
} from "../outbound.js";
describe("dingtalk outbound markdown images", () => {
it("collects unique HTTPS images with a strict limit", () => {
const text = [
"",
"",
"",
"",
].join("\n");
expect(collectRemoteMarkdownImages(text, 2)).toEqual([
{ alt: "first", url: "https://cdn.example/one.png" },
{ alt: "second", url: "https://cdn.example/two.jpg" },
]);
});
it("rejects credentials and non-HTTPS image URLs", () => {
const text = [
"",
"",
"",
].join("\n");
expect(collectRemoteMarkdownImages(text, 4)).toEqual([
{ alt: "safe", url: "https://cdn.example/image.png" },
]);
});
it("removes only successfully uploaded image URLs", () => {
const uploaded = "https://cdn.example/uploaded.png";
const failed = "https://cdn.example/failed.png";
const text = `before\n\n\nafter`;
expect(replaceUploadedRemoteImages(text, new Set([uploaded]))).toBe(
`before\nuploaded\n\nafter`,
);
});
});