taskforce-aiagent
Version:
TaskForce is a modular, open-source, production-ready TypeScript agent framework for orchestrating AI agents, LLM-powered autonomous agents, task pipelines, dynamic toolchains, RAG workflows and memory/retrieval systems.
67 lines (66 loc) • 2.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-nocheck
const helper_1 = require("./helper");
describe("normalizeInput", () => {
it("should flatten a JSON string to key: value pairs", () => {
expect((0, helper_1.normalizeInput)('{"foo":"bar","num":1}')).toBe("foo: bar, num: 1");
});
it("should clean up curly-brace content in normal string", () => {
expect((0, helper_1.normalizeInput)("foo {removeMe} bar")).toBe("foo bar");
});
});
describe("interpolateTemplate", () => {
it("should interpolate variable in braces", () => {
expect((0, helper_1.interpolateTemplate)("Hi, {user}!", { user: "Taskforce" })).toBe("Hi, Taskforce!");
});
it("should keep unknown keys as is", () => {
expect((0, helper_1.interpolateTemplate)("Hello {foo}", {})).toBe("Hello {foo}");
});
});
describe("checkDelegate", () => {
it("should detect DELEGATE syntax", () => {
expect((0, helper_1.checkDelegate)('DELEGATE(Agent1, "Do something")')).toBe(true);
expect((0, helper_1.checkDelegate)("not a delegate")).toBe(false);
});
});
describe("checkTool", () => {
it("should detect TOOL syntax", () => {
expect((0, helper_1.checkTool)('TOOL(SearchTool, {"query": "test"})')).toBe(true);
expect((0, helper_1.checkTool)("TOOL()")).toBe(false);
expect((0, helper_1.checkTool)("no tool here")).toBe(false);
});
});
describe("cleanMarkdownJson", () => {
it("should clean markdown JSON block", () => {
expect((0, helper_1.cleanMarkdownJson)('```json\n{"foo":1}\n```')).toBe('{"foo":1}');
expect((0, helper_1.cleanMarkdownJson)('```json{"foo":1}```')).toBe('{"foo":1}');
});
});
describe("parseCSV", () => {
it("should parse CSV into objects", () => {
const csv = "a,b\n1,2\n3,4";
expect((0, helper_1.parseCSV)(csv)).toEqual([
{ a: "1", b: "2" },
{ a: "3", b: "4" },
]);
});
});
describe("cleanFinalContext", () => {
it("should remove special fields", () => {
const input = { foo: 1, __replanReason__: "x", __replanCount__: 2 };
expect((0, helper_1.cleanFinalContext)(input)).toEqual({ foo: 1 });
});
});
describe("getSafeReplacer", () => {
it("should stringify objects with circular refs safely", () => {
const obj = { foo: "bar" };
obj.self = obj;
expect(JSON.stringify(obj, (0, helper_1.getSafeReplacer)())).toContain("[Circular]");
});
});
describe("parseXML", () => {
it("should handle error and return input string", () => {
expect((0, helper_1.parseXML)("<broken>")).toBe("<broken>");
});
});