Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
fix(sdk): enforce dormant public type tests (#3424)
Shubham Srivastava95cbbb815829
diff --git a/sdk/typescript/src/types.ts b/sdk/typescript/src/types.tsindex 04738fd6d..a0dc91883 100644--- a/sdk/typescript/src/types.ts+++ b/sdk/typescript/src/types.ts@@ -72,7 +72,12 @@ export interface CompressOptions {}export interface CompressResult {- /** Compressed messages in the same format as input. */+ /**+ * Compressed messages in the same format as input. Typed `any[]` because the+ * universal `compress()` returns messages in the *input* format — it calls+ * `fromOpenAI(messages, inputFormat)`, so for Anthropic/Vercel/Gemini input+ * these are not OpenAI-shaped. See the note on `HeadroomClient.compress`.+ */messages: any[];tokensBefore: number;tokensAfter: number;diff --git a/sdk/typescript/test/types.test.ts b/sdk/typescript/test/types.test-d.tssimilarity index 95%rename from sdk/typescript/test/types.test.tsrename to sdk/typescript/test/types.test-d.tsindex a0e3dee94..f3094bee0 100644--- a/sdk/typescript/test/types.test.ts+++ b/sdk/typescript/test/types.test-d.ts@@ -123,7 +123,10 @@ describe("CompressOptions", () => {describe("CompressResult", () => {it("has all required fields with correct types", () => {expectTypeOf<CompressResult>().toHaveProperty("messages");- expectTypeOf<CompressResult["messages"]>().toEqualTypeOf<OpenAIMessage[]>();+ // Intentionally `any[]`: the universal compress() returns messages in the+ // input format (via fromOpenAI), so this field is not OpenAI-shaped in+ // general — asserting OpenAIMessage[] would misrepresent non-OpenAI results.+ expectTypeOf<CompressResult["messages"]>().toEqualTypeOf<any[]>();expectTypeOf<CompressResult["tokensBefore"]>().toBeNumber();expectTypeOf<CompressResult["tokensAfter"]>().toBeNumber();expectTypeOf<CompressResult["tokensSaved"]>().toBeNumber();@@ -173,7 +176,7 @@ describe("HeadroomClientInterface", () => {it("compress accepts messages and optional options", () => {expectTypeOf<HeadroomClientInterface["compress"]>().parameters.toEqualTypeOf<- [OpenAIMessage[], ({ model?: string } | undefined)?]+ [OpenAIMessage[], ({ model?: string; tokenBudget?: number } | undefined)?]>();});});diff --git a/sdk/typescript/tsconfig.typecheck.json b/sdk/typescript/tsconfig.typecheck.jsonnew file mode 100644index 000000000..599f44738--- /dev/null+++ b/sdk/typescript/tsconfig.typecheck.json@@ -0,0 +1,9 @@+{+ "extends": "./tsconfig.json",+ "compilerOptions": {+ "rootDir": ".",+ "noEmit": true+ },+ "include": ["src", "test/**/*.test-d.ts"],+ "exclude": ["node_modules", "dist"]+}diff --git a/sdk/typescript/vitest.config.ts b/sdk/typescript/vitest.config.tsindex 3f824fb95..b83e585ae 100644--- a/sdk/typescript/vitest.config.ts+++ b/sdk/typescript/vitest.config.ts@@ -4,5 +4,9 @@ export default defineConfig({test: {globals: true,environment: "node",+ typecheck: {+ enabled: true,+ tsconfig: "./tsconfig.typecheck.json",+ },},});