@absolutejs/ai 0.5.0 → 0.6.0

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,3 +1,4 @@
1
1
  import type { AIProviderConfig } from "../../../types/ai";
2
2
  import type { AnthropicConfig } from "../../../types/anthropic";
3
+ export declare const CONTEXT_MANAGEMENT_BETA = "context-management-2025-06-27";
3
4
  export declare const anthropic: (config: AnthropicConfig) => AIProviderConfig;
@@ -228,6 +228,22 @@ export type ReasoningConfig = {
228
228
  budgetTokens?: number;
229
229
  effort?: ReasoningEffort;
230
230
  };
231
+ /** Clear the results of older tool calls once the request grows large
232
+ * (Anthropic context editing). The provider drops old tool results
233
+ * server-side and the history you hold stays whole. Clearing rewrites the
234
+ * prompt cache, so it pays only for long runs: set the trigger well above a
235
+ * typical run's size. Ignored by providers without it. */
236
+ export type AIToolResultClearing = {
237
+ /** Clear once the input reaches this many tokens. */
238
+ triggerInputTokens: number;
239
+ /** Keep this many most recent tool calls and results. Default 3. */
240
+ keepToolUses?: number;
241
+ /** Skip clearing unless at least this many tokens would go, so a rewrite
242
+ * of the cache is worth it. */
243
+ clearAtLeastInputTokens?: number;
244
+ /** Tools whose results are never cleared. */
245
+ excludeTools?: string[];
246
+ };
231
247
  export type AIProviderStreamParams = {
232
248
  /** Override transport retries for operations whose host owns attempt accounting. */
233
249
  maxRetries?: number;
@@ -275,6 +291,8 @@ export type AIProviderStreamParams = {
275
291
  seed?: number;
276
292
  signal?: AbortSignal;
277
293
  stopSequences?: string[];
294
+ /** See AIToolResultClearing. */
295
+ toolResultClearing?: AIToolResultClearing;
278
296
  systemPrompt?: string;
279
297
  temperature?: number;
280
298
  toolChoice?: AIProviderToolChoice;
@@ -358,6 +376,8 @@ export type AIProviderToolDefinition = {
358
376
  name: string;
359
377
  description: string;
360
378
  input_schema: Record<string, unknown>;
379
+ /** See AIToolDefinition.deferLoading. */
380
+ deferLoading?: boolean;
361
381
  };
362
382
  export type AIProviderConfig = {
363
383
  inputCapacity?: {
@@ -396,6 +416,12 @@ export type AIToolDefinition = {
396
416
  input: Record<string, unknown>;
397
417
  handler: (input: unknown) => Promise<AIToolOutput> | AIToolOutput;
398
418
  annotations?: AIToolAnnotations;
419
+ /** Keep this tool out of the prompt until the model searches for it
420
+ * (Anthropic tool search). It costs nothing on a request that never needs
421
+ * it, and the prompt cache survives its loading. Providers without tool
422
+ * search send it like any other tool. At least one tool must stay
423
+ * loaded. */
424
+ deferLoading?: boolean;
399
425
  };
400
426
  export type AIToolMap = Record<string, AIToolDefinition>;
401
427
  export type AIAttachment = {
@@ -657,6 +683,8 @@ export type StreamAIOptions = {
657
683
  promptCaching?: boolean;
658
684
  /** Provider-specific options forwarded to every model turn. */
659
685
  providerOptions?: Record<string, unknown>;
686
+ /** See AIToolResultClearing. */
687
+ toolResultClearing?: AIToolResultClearing;
660
688
  tools?: AIToolMap;
661
689
  /** Portable reasoning effort — translated per provider/model. */
662
690
  reasoning?: ReasoningConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/ai",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "homepage": "https://github.com/absolutejs/ai",
5
5
  "bugs": {
6
6
  "url": "https://github.com/absolutejs/ai/issues"