bc39ffa265
- Introduce `@oh-my-pi/omptype` as a new ArkType-compatible schema validation package featuring a lazy JIT runtime, JSON Schema emission, and compatibility adapters. - Replace `arktype` across workspace packages and test utilities with `@oh-my-pi/omptype`. - Add benchmark suites, tests, and documentation for the new validation engine and adapters. - Update workspace build, test runner, and release configurations to include the new package.
30 lines
993 B
TypeScript
30 lines
993 B
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { type } from "@oh-my-pi/omptype";
|
|
import type { Tool } from "@oh-my-pi/pi-ai/types";
|
|
import { validateToolArguments } from "@oh-my-pi/pi-ai/utils/validation";
|
|
|
|
describe("Eval-tool language whitespace normalization", () => {
|
|
it("trims a trailing newline on the ArkType-emitted language enum", () => {
|
|
const tool: Tool = {
|
|
name: "eval",
|
|
description: "",
|
|
parameters: type({
|
|
language: type("'py' | 'js' | 'rb' | 'jl'").describe(""),
|
|
code: type("string").describe(""),
|
|
"title?": type("string").describe(""),
|
|
}),
|
|
};
|
|
|
|
const result = validateToolArguments(tool, {
|
|
type: "toolCall",
|
|
id: "call-eval-language-newline",
|
|
name: "eval",
|
|
arguments: { language: "js\n", code: "console.log('hi')", title: "smoke" },
|
|
}) as { language: string; code: string; title?: string };
|
|
|
|
expect(result.language).toBe("js");
|
|
expect(result.code).toBe("console.log('hi')");
|
|
expect(result.title).toBe("smoke");
|
|
});
|
|
});
|