@earendil-works/pi-ai 0.79.3 → 0.79.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAavF,KAAK,QAAQ,CACZ,SAAS,SAAS,aAAa,EAC/B,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,IAC9C,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS;IAAE,GAAG,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,CAAC,IAAI,SAAS,GAAG,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAEjH,wBAAgB,QAAQ,CAAC,SAAS,SAAS,aAAa,EAAE,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,EAC1G,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,QAAQ,GACf,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAGtC;AAED,wBAAgB,YAAY,IAAI,aAAa,EAAE,CAE9C;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,aAAa,EACxD,QAAQ,EAAE,SAAS,GACjB,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAGhE;AAED,wBAAgB,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAO/F;AAID,wBAAgB,0BAA0B,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,EAAE,CASrG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,GAAG,EAClD,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,KAAK,EAAE,kBAAkB,GACvB,kBAAkB,CAgBpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAS,GAAG,EAC9C,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EACjC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/B,OAAO,CAGT","sourcesContent":["import { MODELS } from \"./models.generated.ts\";\nimport type { Api, KnownProvider, Model, ModelThinkingLevel, Usage } from \"./types.ts\";\n\nconst modelRegistry: Map<string, Map<string, Model<Api>>> = new Map();\n\n// Initialize registry from MODELS on module load\nfor (const [provider, models] of Object.entries(MODELS)) {\n\tconst providerModels = new Map<string, Model<Api>>();\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tproviderModels.set(id, model as Model<Api>);\n\t}\n\tmodelRegistry.set(provider, providerModels);\n}\n\ntype ModelApi<\n\tTProvider extends KnownProvider,\n\tTModelId extends keyof (typeof MODELS)[TProvider],\n> = (typeof MODELS)[TProvider][TModelId] extends { api: infer TApi } ? (TApi extends Api ? TApi : never) : never;\n\nexport function getModel<TProvider extends KnownProvider, TModelId extends keyof (typeof MODELS)[TProvider]>(\n\tprovider: TProvider,\n\tmodelId: TModelId,\n): Model<ModelApi<TProvider, TModelId>> {\n\tconst providerModels = modelRegistry.get(provider);\n\treturn providerModels?.get(modelId as string) as Model<ModelApi<TProvider, TModelId>>;\n}\n\nexport function getProviders(): KnownProvider[] {\n\treturn Array.from(modelRegistry.keys()) as KnownProvider[];\n}\n\nexport function getModels<TProvider extends KnownProvider>(\n\tprovider: TProvider,\n): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[] {\n\tconst models = modelRegistry.get(provider);\n\treturn models ? (Array.from(models.values()) as Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[]) : [];\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\tusage.cost.input = (model.cost.input / 1000000) * usage.input;\n\tusage.cost.output = (model.cost.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (model.cost.cacheWrite / 1000000) * usage.cacheWrite;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\nconst EXTENDED_THINKING_LEVELS: ModelThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"];\n\nexport function getSupportedThinkingLevels<TApi extends Api>(model: Model<TApi>): ModelThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn EXTENDED_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\") return mapped !== undefined;\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tlevel: ModelThinkingLevel,\n): ModelThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\tfor (let i = requestedIndex; i < EXTENDED_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\treturn availableLevels[0] ?? \"off\";\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual<TApi extends Api>(\n\ta: Model<TApi> | null | undefined,\n\tb: Model<TApi> | null | undefined,\n): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider === b.provider;\n}\n"]}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAavF,KAAK,QAAQ,CACZ,SAAS,SAAS,aAAa,EAC/B,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,IAC9C,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS;IAAE,GAAG,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,CAAC,IAAI,SAAS,GAAG,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAEjH,wBAAgB,QAAQ,CAAC,SAAS,SAAS,aAAa,EAAE,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,EAC1G,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,QAAQ,GACf,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAGtC;AAED,wBAAgB,YAAY,IAAI,aAAa,EAAE,CAE9C;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,aAAa,EACxD,QAAQ,EAAE,SAAS,GACjB,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAGhE;AAED,wBAAgB,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAU/F;AAID,wBAAgB,0BAA0B,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,EAAE,CASrG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,GAAG,EAClD,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,KAAK,EAAE,kBAAkB,GACvB,kBAAkB,CAgBpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAS,GAAG,EAC9C,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EACjC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/B,OAAO,CAGT","sourcesContent":["import { MODELS } from \"./models.generated.ts\";\nimport type { Api, KnownProvider, Model, ModelThinkingLevel, Usage } from \"./types.ts\";\n\nconst modelRegistry: Map<string, Map<string, Model<Api>>> = new Map();\n\n// Initialize registry from MODELS on module load\nfor (const [provider, models] of Object.entries(MODELS)) {\n\tconst providerModels = new Map<string, Model<Api>>();\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tproviderModels.set(id, model as Model<Api>);\n\t}\n\tmodelRegistry.set(provider, providerModels);\n}\n\ntype ModelApi<\n\tTProvider extends KnownProvider,\n\tTModelId extends keyof (typeof MODELS)[TProvider],\n> = (typeof MODELS)[TProvider][TModelId] extends { api: infer TApi } ? (TApi extends Api ? TApi : never) : never;\n\nexport function getModel<TProvider extends KnownProvider, TModelId extends keyof (typeof MODELS)[TProvider]>(\n\tprovider: TProvider,\n\tmodelId: TModelId,\n): Model<ModelApi<TProvider, TModelId>> {\n\tconst providerModels = modelRegistry.get(provider);\n\treturn providerModels?.get(modelId as string) as Model<ModelApi<TProvider, TModelId>>;\n}\n\nexport function getProviders(): KnownProvider[] {\n\treturn Array.from(modelRegistry.keys()) as KnownProvider[];\n}\n\nexport function getModels<TProvider extends KnownProvider>(\n\tprovider: TProvider,\n): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[] {\n\tconst models = modelRegistry.get(provider);\n\treturn models ? (Array.from(models.values()) as Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[]) : [];\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\t// Anthropic charges 2x base input for 1h cache writes.\n\tconst longWrite = usage.cacheWrite1h ?? 0;\n\tconst shortWrite = usage.cacheWrite - longWrite;\n\tusage.cost.input = (model.cost.input / 1000000) * usage.input;\n\tusage.cost.output = (model.cost.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (model.cost.cacheWrite * shortWrite + model.cost.input * 2 * longWrite) / 1000000;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\nconst EXTENDED_THINKING_LEVELS: ModelThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"];\n\nexport function getSupportedThinkingLevels<TApi extends Api>(model: Model<TApi>): ModelThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn EXTENDED_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\") return mapped !== undefined;\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tlevel: ModelThinkingLevel,\n): ModelThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = EXTENDED_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\tfor (let i = requestedIndex; i < EXTENDED_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = EXTENDED_THINKING_LEVELS[i];\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\treturn availableLevels[0] ?? \"off\";\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual<TApi extends Api>(\n\ta: Model<TApi> | null | undefined,\n\tb: Model<TApi> | null | undefined,\n): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider === b.provider;\n}\n"]}
@@ -4544,6 +4544,7 @@ export declare const MODELS: {
4544
4544
  reasoning: true;
4545
4545
  thinkingLevelMap: {
4546
4546
  xhigh: string;
4547
+ minimal: string;
4547
4548
  };
4548
4549
  input: ("image" | "text")[];
4549
4550
  cost: {
@@ -4574,6 +4575,7 @@ export declare const MODELS: {
4574
4575
  reasoning: true;
4575
4576
  thinkingLevelMap: {
4576
4577
  xhigh: string;
4578
+ minimal: string;
4577
4579
  };
4578
4580
  input: ("image" | "text")[];
4579
4581
  cost: {
@@ -4653,6 +4655,10 @@ export declare const MODELS: {
4653
4655
  forceAdaptiveThinking: true;
4654
4656
  };
4655
4657
  reasoning: true;
4658
+ thinkingLevelMap: {
4659
+ minimal: string;
4660
+ xhigh: string;
4661
+ };
4656
4662
  input: ("image" | "text")[];
4657
4663
  cost: {
4658
4664
  input: number;
@@ -5375,6 +5381,54 @@ export declare const MODELS: {
5375
5381
  contextWindow: number;
5376
5382
  maxTokens: number;
5377
5383
  };
5384
+ readonly "gemma-4-E2B-it": {
5385
+ id: string;
5386
+ name: string;
5387
+ api: "google-generative-ai";
5388
+ provider: string;
5389
+ baseUrl: string;
5390
+ reasoning: true;
5391
+ thinkingLevelMap: {
5392
+ off: null;
5393
+ minimal: string;
5394
+ low: null;
5395
+ medium: null;
5396
+ high: string;
5397
+ };
5398
+ input: ("image" | "text")[];
5399
+ cost: {
5400
+ input: number;
5401
+ output: number;
5402
+ cacheRead: number;
5403
+ cacheWrite: number;
5404
+ };
5405
+ contextWindow: number;
5406
+ maxTokens: number;
5407
+ };
5408
+ readonly "gemma-4-E4B-it": {
5409
+ id: string;
5410
+ name: string;
5411
+ api: "google-generative-ai";
5412
+ provider: string;
5413
+ baseUrl: string;
5414
+ reasoning: true;
5415
+ thinkingLevelMap: {
5416
+ off: null;
5417
+ minimal: string;
5418
+ low: null;
5419
+ medium: null;
5420
+ high: string;
5421
+ };
5422
+ input: ("image" | "text")[];
5423
+ cost: {
5424
+ input: number;
5425
+ output: number;
5426
+ cacheRead: number;
5427
+ cacheWrite: number;
5428
+ };
5429
+ contextWindow: number;
5430
+ maxTokens: number;
5431
+ };
5378
5432
  };
5379
5433
  readonly "google-vertex": {
5380
5434
  readonly "gemini-1.5-flash": {
@@ -8880,6 +8934,7 @@ export declare const MODELS: {
8880
8934
  baseUrl: string;
8881
8935
  compat: {
8882
8936
  maxTokensField: "max_tokens";
8937
+ supportsLongCacheRetention: false;
8883
8938
  requiresReasoningContentOnAssistantMessages: true;
8884
8939
  thinkingFormat: "deepseek";
8885
8940
  };
@@ -8938,6 +8993,7 @@ export declare const MODELS: {
8938
8993
  baseUrl: string;
8939
8994
  compat: {
8940
8995
  maxTokensField: "max_tokens";
8996
+ supportsLongCacheRetention: false;
8941
8997
  requiresReasoningContentOnAssistantMessages: true;
8942
8998
  thinkingFormat: "deepseek";
8943
8999
  };
@@ -9429,6 +9485,7 @@ export declare const MODELS: {
9429
9485
  baseUrl: string;
9430
9486
  compat: {
9431
9487
  maxTokensField: "max_tokens";
9488
+ supportsLongCacheRetention: false;
9432
9489
  };
9433
9490
  reasoning: true;
9434
9491
  input: ("image" | "text")[];
@@ -9451,6 +9508,7 @@ export declare const MODELS: {
9451
9508
  thinkingFormat: "deepseek";
9452
9509
  supportsReasoningEffort: false;
9453
9510
  maxTokensField: "max_tokens";
9511
+ supportsLongCacheRetention: false;
9454
9512
  };
9455
9513
  reasoning: true;
9456
9514
  input: ("image" | "text")[];
@@ -9511,6 +9569,7 @@ export declare const MODELS: {
9511
9569
  baseUrl: string;
9512
9570
  compat: {
9513
9571
  maxTokensField: "max_tokens";
9572
+ supportsLongCacheRetention: false;
9514
9573
  };
9515
9574
  reasoning: true;
9516
9575
  input: "text"[];
@@ -9707,6 +9766,7 @@ export declare const MODELS: {
9707
9766
  thinkingFormat: "deepseek";
9708
9767
  supportsReasoningEffort: false;
9709
9768
  maxTokensField: "max_tokens";
9769
+ supportsLongCacheRetention: false;
9710
9770
  };
9711
9771
  reasoning: true;
9712
9772
  thinkingLevelMap: {
@@ -14640,6 +14700,37 @@ export declare const MODELS: {
14640
14700
  contextWindow: number;
14641
14701
  maxTokens: number;
14642
14702
  };
14703
+ readonly "moonshotai/Kimi-K2.7-Code": {
14704
+ id: string;
14705
+ name: string;
14706
+ api: "openai-completions";
14707
+ provider: string;
14708
+ baseUrl: string;
14709
+ compat: {
14710
+ supportsStore: false;
14711
+ supportsDeveloperRole: false;
14712
+ supportsReasoningEffort: false;
14713
+ maxTokensField: "max_tokens";
14714
+ supportsStrictMode: false;
14715
+ supportsLongCacheRetention: false;
14716
+ thinkingFormat: "together";
14717
+ };
14718
+ reasoning: true;
14719
+ thinkingLevelMap: {
14720
+ minimal: null;
14721
+ low: null;
14722
+ medium: null;
14723
+ };
14724
+ input: "text"[];
14725
+ cost: {
14726
+ input: number;
14727
+ output: number;
14728
+ cacheRead: number;
14729
+ cacheWrite: number;
14730
+ };
14731
+ contextWindow: number;
14732
+ maxTokens: number;
14733
+ };
14643
14734
  readonly "nvidia/nemotron-3-ultra-550b-a55b": {
14644
14735
  id: string;
14645
14736
  name: string;
@@ -18338,6 +18429,28 @@ export declare const MODELS: {
18338
18429
  contextWindow: number;
18339
18430
  maxTokens: number;
18340
18431
  };
18432
+ readonly "glm-5.2": {
18433
+ id: string;
18434
+ name: string;
18435
+ api: "openai-completions";
18436
+ provider: string;
18437
+ baseUrl: string;
18438
+ compat: {
18439
+ supportsDeveloperRole: false;
18440
+ thinkingFormat: "zai";
18441
+ zaiToolStream: true;
18442
+ };
18443
+ reasoning: true;
18444
+ input: "text"[];
18445
+ cost: {
18446
+ input: number;
18447
+ output: number;
18448
+ cacheRead: number;
18449
+ cacheWrite: number;
18450
+ };
18451
+ contextWindow: number;
18452
+ maxTokens: number;
18453
+ };
18341
18454
  readonly "glm-5v-turbo": {
18342
18455
  id: string;
18343
18456
  name: string;
@@ -18449,6 +18562,28 @@ export declare const MODELS: {
18449
18562
  contextWindow: number;
18450
18563
  maxTokens: number;
18451
18564
  };
18565
+ readonly "glm-5.2": {
18566
+ id: string;
18567
+ name: string;
18568
+ api: "openai-completions";
18569
+ provider: string;
18570
+ baseUrl: string;
18571
+ compat: {
18572
+ supportsDeveloperRole: false;
18573
+ thinkingFormat: "zai";
18574
+ zaiToolStream: true;
18575
+ };
18576
+ reasoning: true;
18577
+ input: "text"[];
18578
+ cost: {
18579
+ input: number;
18580
+ output: number;
18581
+ cacheRead: number;
18582
+ cacheWrite: number;
18583
+ };
18584
+ contextWindow: number;
18585
+ maxTokens: number;
18586
+ };
18452
18587
  readonly "glm-5v-turbo": {
18453
18588
  id: string;
18454
18589
  name: string;