fd06fe07ae
- Swapped legacy `zodToWireSchema` for `toolWireSchema` to normalize tool schemas. - Updated `getSchemaPropertyKeys` in `tool-index.ts` to process schemas via `toolWireSchema`. - Refactored tool token estimation in `context-usage.ts` to utilize the new schema helper. - Fixed ArkType assertion checks in test helpers to correctly verify instances against `arkType.errors`. - Aligned test suites and mock specifications with raw schema-based parameters instead of manually stringified JSON structures.
22 lines
653 B
TypeScript
22 lines
653 B
TypeScript
import { expect } from "bun:test";
|
|
import { type as arkType, type Type } from "arktype";
|
|
|
|
function formatIssues(error: unknown): string {
|
|
if (error instanceof Error) {
|
|
return error.message;
|
|
}
|
|
return String(error);
|
|
}
|
|
|
|
export function expectAcpStructure(schema: Type, value: unknown): void {
|
|
const result = schema(value);
|
|
const isValid = !(result instanceof arkType.errors);
|
|
expect(isValid, isValid ? undefined : formatIssues(result)).toBe(true);
|
|
}
|
|
|
|
export function expectAcpStructureRejects(schema: Type, value: unknown): void {
|
|
const result = schema(value);
|
|
const isValid = !(result instanceof arkType.errors);
|
|
expect(isValid).toBe(false);
|
|
}
|