@codelia/core 0.1.13 → 0.1.15

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.
package/dist/index.d.cts CHANGED
@@ -54,12 +54,30 @@ type ToolCall = {
54
54
  /**
55
55
  * Tool Definition
56
56
  */
57
- type ToolDefinition = {
57
+ type FunctionToolDefinition = {
58
+ type?: "function";
58
59
  name: string;
59
60
  description: string;
60
61
  parameters: JSONSchema7;
61
62
  strict?: boolean;
62
63
  };
64
+ type HostedSearchUserLocation = {
65
+ city?: string;
66
+ country?: string;
67
+ region?: string;
68
+ timezone?: string;
69
+ };
70
+ type HostedSearchToolDefinition = {
71
+ type: "hosted_search";
72
+ name: string;
73
+ provider?: "openai" | "anthropic" | "openrouter" | "google";
74
+ search_context_size?: "low" | "medium" | "high";
75
+ allowed_domains?: string[];
76
+ blocked_domains?: string[];
77
+ max_uses?: number;
78
+ user_location?: HostedSearchUserLocation;
79
+ };
80
+ type ToolDefinition = FunctionToolDefinition | HostedSearchToolDefinition;
63
81
  type ToolChoice = "auto" | "required" | "none" | string;
64
82
  type JsonValue = string | number | boolean | null | {
65
83
  [key: string]: JsonValue;
@@ -201,12 +219,15 @@ type ChatInvokeInput = {
201
219
  toolChoice?: ToolChoice | null;
202
220
  signal?: AbortSignal;
203
221
  };
222
+ type ChatInvokeContext = {
223
+ sessionKey?: string;
224
+ };
204
225
  interface BaseChatModel<P extends ProviderName = ProviderName, O = unknown> {
205
226
  readonly provider: P;
206
227
  readonly model: string;
207
228
  ainvoke(input: ChatInvokeInput & {
208
229
  options?: O;
209
- }): Promise<ChatInvokeCompletion>;
230
+ }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
210
231
  }
211
232
 
212
233
  type ModelSpec = {
@@ -246,6 +267,7 @@ type CompactionConfig = {
246
267
  type ToolOutputCacheConfig = {
247
268
  enabled?: boolean;
248
269
  contextBudgetTokens?: number | null;
270
+ totalBudgetTrim?: boolean;
249
271
  maxMessageBytes?: number;
250
272
  maxLineLength?: number;
251
273
  };
@@ -425,6 +447,7 @@ type LlmRequestRecord = {
425
447
  tools?: ToolDefinition[] | null;
426
448
  tool_choice?: ToolChoice | null;
427
449
  model?: string;
450
+ session_key?: string;
428
451
  };
429
452
  meta?: Record<string, unknown>;
430
453
  };
@@ -510,6 +533,7 @@ type AgentRunOptions = {
510
533
  type AgentOptions = {
511
534
  llm: BaseChatModel;
512
535
  tools: Tool[];
536
+ hostedTools?: ToolDefinition[];
513
537
  systemPrompt?: string;
514
538
  maxIterations?: number;
515
539
  toolChoice?: ToolChoice;
@@ -528,6 +552,7 @@ type AgentOptions = {
528
552
  declare class Agent {
529
553
  private readonly llm;
530
554
  private readonly tools;
555
+ private readonly hostedTools;
531
556
  private readonly systemPrompt?;
532
557
  private readonly maxIterations;
533
558
  private readonly toolChoice?;
@@ -549,6 +574,8 @@ declare class Agent {
549
574
  private processToolMessage;
550
575
  private buildToolContext;
551
576
  private recordLlmRequest;
577
+ private resolveSessionKey;
578
+ private buildInvokeContext;
552
579
  private recordLlmResponse;
553
580
  run(message: string | ContentPart[], options?: AgentRunOptions): Promise<string>;
554
581
  runStream(message: string | ContentPart[], options?: AgentRunOptions): AsyncGenerator<AgentEvent>;
@@ -599,10 +626,15 @@ declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$1, Ant
599
626
  readonly model: string;
600
627
  private readonly client;
601
628
  private readonly defaultMaxTokens;
629
+ private debugInvokeSeq;
630
+ private lastDebugRequestPayload;
602
631
  constructor(options?: ChatAnthropicOptions);
603
632
  ainvoke(input: ChatInvokeInput & {
604
633
  options?: AnthropicInvokeOptions;
605
- }, verbose?: boolean): Promise<ChatInvokeCompletion>;
634
+ }, _context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
635
+ private nextDebugInvokeSeq;
636
+ private debugRequestIfEnabled;
637
+ private debugResponseIfEnabled;
606
638
  }
607
639
 
608
640
  declare const PROVIDER_NAME: "openai";
@@ -624,10 +656,15 @@ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME, OpenAIIn
624
656
  private readonly client;
625
657
  private readonly defaultReasoningEffort?;
626
658
  private readonly defaultTextVerbosity?;
659
+ private debugInvokeSeq;
660
+ private lastDebugRequestPayload;
627
661
  constructor(options?: ChatOpenAIOptions);
628
662
  ainvoke(input: ChatInvokeInput & {
629
663
  options?: OpenAIInvokeOptions;
630
- }, verbose?: boolean): Promise<ChatInvokeCompletion>;
664
+ }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
665
+ private nextDebugInvokeSeq;
666
+ private debugRequestIfEnabled;
667
+ private debugResponseIfEnabled;
631
668
  }
632
669
 
633
670
  declare const ANTHROPIC_DEFAULT_MODEL = "claude-sonnet-4-5";
@@ -650,4 +687,4 @@ declare class TaskComplete extends Error {
650
687
  constructor(finalMessage?: string);
651
688
  }
652
689
 
653
- export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeInput, ChatOpenAI, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, listModels, registerModels, resolveModel, stringifyContent, stringifyContentParts };
690
+ export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeContext, type ChatInvokeInput, ChatOpenAI, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, listModels, registerModels, resolveModel, stringifyContent, stringifyContentParts };
package/dist/index.d.ts CHANGED
@@ -54,12 +54,30 @@ type ToolCall = {
54
54
  /**
55
55
  * Tool Definition
56
56
  */
57
- type ToolDefinition = {
57
+ type FunctionToolDefinition = {
58
+ type?: "function";
58
59
  name: string;
59
60
  description: string;
60
61
  parameters: JSONSchema7;
61
62
  strict?: boolean;
62
63
  };
64
+ type HostedSearchUserLocation = {
65
+ city?: string;
66
+ country?: string;
67
+ region?: string;
68
+ timezone?: string;
69
+ };
70
+ type HostedSearchToolDefinition = {
71
+ type: "hosted_search";
72
+ name: string;
73
+ provider?: "openai" | "anthropic" | "openrouter" | "google";
74
+ search_context_size?: "low" | "medium" | "high";
75
+ allowed_domains?: string[];
76
+ blocked_domains?: string[];
77
+ max_uses?: number;
78
+ user_location?: HostedSearchUserLocation;
79
+ };
80
+ type ToolDefinition = FunctionToolDefinition | HostedSearchToolDefinition;
63
81
  type ToolChoice = "auto" | "required" | "none" | string;
64
82
  type JsonValue = string | number | boolean | null | {
65
83
  [key: string]: JsonValue;
@@ -201,12 +219,15 @@ type ChatInvokeInput = {
201
219
  toolChoice?: ToolChoice | null;
202
220
  signal?: AbortSignal;
203
221
  };
222
+ type ChatInvokeContext = {
223
+ sessionKey?: string;
224
+ };
204
225
  interface BaseChatModel<P extends ProviderName = ProviderName, O = unknown> {
205
226
  readonly provider: P;
206
227
  readonly model: string;
207
228
  ainvoke(input: ChatInvokeInput & {
208
229
  options?: O;
209
- }): Promise<ChatInvokeCompletion>;
230
+ }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
210
231
  }
211
232
 
212
233
  type ModelSpec = {
@@ -246,6 +267,7 @@ type CompactionConfig = {
246
267
  type ToolOutputCacheConfig = {
247
268
  enabled?: boolean;
248
269
  contextBudgetTokens?: number | null;
270
+ totalBudgetTrim?: boolean;
249
271
  maxMessageBytes?: number;
250
272
  maxLineLength?: number;
251
273
  };
@@ -425,6 +447,7 @@ type LlmRequestRecord = {
425
447
  tools?: ToolDefinition[] | null;
426
448
  tool_choice?: ToolChoice | null;
427
449
  model?: string;
450
+ session_key?: string;
428
451
  };
429
452
  meta?: Record<string, unknown>;
430
453
  };
@@ -510,6 +533,7 @@ type AgentRunOptions = {
510
533
  type AgentOptions = {
511
534
  llm: BaseChatModel;
512
535
  tools: Tool[];
536
+ hostedTools?: ToolDefinition[];
513
537
  systemPrompt?: string;
514
538
  maxIterations?: number;
515
539
  toolChoice?: ToolChoice;
@@ -528,6 +552,7 @@ type AgentOptions = {
528
552
  declare class Agent {
529
553
  private readonly llm;
530
554
  private readonly tools;
555
+ private readonly hostedTools;
531
556
  private readonly systemPrompt?;
532
557
  private readonly maxIterations;
533
558
  private readonly toolChoice?;
@@ -549,6 +574,8 @@ declare class Agent {
549
574
  private processToolMessage;
550
575
  private buildToolContext;
551
576
  private recordLlmRequest;
577
+ private resolveSessionKey;
578
+ private buildInvokeContext;
552
579
  private recordLlmResponse;
553
580
  run(message: string | ContentPart[], options?: AgentRunOptions): Promise<string>;
554
581
  runStream(message: string | ContentPart[], options?: AgentRunOptions): AsyncGenerator<AgentEvent>;
@@ -599,10 +626,15 @@ declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$1, Ant
599
626
  readonly model: string;
600
627
  private readonly client;
601
628
  private readonly defaultMaxTokens;
629
+ private debugInvokeSeq;
630
+ private lastDebugRequestPayload;
602
631
  constructor(options?: ChatAnthropicOptions);
603
632
  ainvoke(input: ChatInvokeInput & {
604
633
  options?: AnthropicInvokeOptions;
605
- }, verbose?: boolean): Promise<ChatInvokeCompletion>;
634
+ }, _context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
635
+ private nextDebugInvokeSeq;
636
+ private debugRequestIfEnabled;
637
+ private debugResponseIfEnabled;
606
638
  }
607
639
 
608
640
  declare const PROVIDER_NAME: "openai";
@@ -624,10 +656,15 @@ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME, OpenAIIn
624
656
  private readonly client;
625
657
  private readonly defaultReasoningEffort?;
626
658
  private readonly defaultTextVerbosity?;
659
+ private debugInvokeSeq;
660
+ private lastDebugRequestPayload;
627
661
  constructor(options?: ChatOpenAIOptions);
628
662
  ainvoke(input: ChatInvokeInput & {
629
663
  options?: OpenAIInvokeOptions;
630
- }, verbose?: boolean): Promise<ChatInvokeCompletion>;
664
+ }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
665
+ private nextDebugInvokeSeq;
666
+ private debugRequestIfEnabled;
667
+ private debugResponseIfEnabled;
631
668
  }
632
669
 
633
670
  declare const ANTHROPIC_DEFAULT_MODEL = "claude-sonnet-4-5";
@@ -650,4 +687,4 @@ declare class TaskComplete extends Error {
650
687
  constructor(finalMessage?: string);
651
688
  }
652
689
 
653
- export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeInput, ChatOpenAI, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, listModels, registerModels, resolveModel, stringifyContent, stringifyContentParts };
690
+ export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, type ChatInvokeContext, type ChatInvokeInput, ChatOpenAI, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCost, type ModelEntry, type ModelLimits, type ModelMetadataIndex, type ModelMetadataService, type ModelRegistry, type ModelSpec, OPENAI_DEFAULT_MODEL, OPENAI_DEFAULT_REASONING_EFFORT, OPENAI_MODELS, type ResolveStorageOptions, type RunContextRecord, type RunEndRecord, type RunErrorRecord, type RunEventStoreFactory, type RunEventStoreInit, type RunStartRecord, type RunStatusRecord, type SessionHeader, type SessionRecord, type SessionState, type SessionStateStore, type SessionStateSummary, type SessionStore, type StorageLayout, type StoragePathService, type StoragePaths, type StringifyContentMode, type StringifyContentOptions, TaskComplete, type Tool, type ToolContext, type ToolDefinition, type ToolExecution, type ToolOutputCacheConfig, type ToolOutputCacheReadOptions, type ToolOutputCacheRecord, type ToolOutputCacheSearchOptions, ToolOutputCacheService, type ToolOutputCacheStore, type ToolOutputRecord, type ToolOutputRef, type ToolPermissionDecision, type ToolPermissionHook, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, listModels, registerModels, resolveModel, stringifyContent, stringifyContentParts };