@codelia/core 0.1.67 → 0.1.69

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
@@ -223,7 +223,7 @@ type AgentServices = {
223
223
  toolOutputCacheStore?: ToolOutputCacheStore | null;
224
224
  };
225
225
 
226
- type ProviderName = "openai" | "anthropic" | "openrouter" | "google";
226
+ type ProviderName = "openai" | "anthropic" | "openrouter" | "google" | "zai";
227
227
  type ChatInvokeInput = {
228
228
  messages: BaseMessage[];
229
229
  model?: string;
@@ -384,6 +384,7 @@ type SessionHeader = {
384
384
  name?: string;
385
385
  reasoning?: string;
386
386
  fast?: boolean;
387
+ source?: "config" | "session";
387
388
  };
388
389
  prompts?: {
389
390
  system?: string;
@@ -513,6 +514,7 @@ type RunEndRecord = {
513
514
  };
514
515
  type SessionRecord = SessionHeader | RunStartRecord | RunContextRecord | AgentEventRecord | ToolOutputRecord | LlmRequestRecord | LlmResponseRecord | RunStatusRecord | RunErrorRecord | RunEndRecord;
515
516
  type SessionStore = {
517
+ filePath?: string;
516
518
  append: (record: SessionRecord) => Promise<void> | void;
517
519
  };
518
520
  type RunEventStoreInit = {
@@ -635,7 +637,7 @@ interface StoragePathService {
635
637
  resolvePaths(options?: ResolveStorageOptions): StoragePaths;
636
638
  }
637
639
 
638
- declare const PROVIDER_NAME$2: "anthropic";
640
+ declare const PROVIDER_NAME$3: "anthropic";
639
641
  type AnthropicMessageCreateParams = MessageCreateParamsNonStreaming & {
640
642
  speed?: "standard" | "fast" | null;
641
643
  betas?: string[];
@@ -653,8 +655,8 @@ type ChatAnthropicOptions = {
653
655
  reasoningFallbackApplied?: boolean;
654
656
  reasoningBudgetPreset?: string;
655
657
  };
656
- declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$2, AnthropicInvokeOptions> {
657
- readonly provider: typeof PROVIDER_NAME$2;
658
+ declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$3, AnthropicInvokeOptions> {
659
+ readonly provider: typeof PROVIDER_NAME$3;
658
660
  readonly model: string;
659
661
  private readonly client;
660
662
  private readonly defaultMaxTokens;
@@ -684,7 +686,7 @@ type OpenAiResponsesWsLike = {
684
686
  }): void;
685
687
  };
686
688
 
687
- declare const PROVIDER_NAME$1: "openai";
689
+ declare const PROVIDER_NAME$2: "openai";
688
690
  type OpenAITextVerbosity = Exclude<ResponseTextConfig["verbosity"], null>;
689
691
  type OpenAIInvokeOptions = Omit<ResponseCreateParamsBase, "model" | "input" | "tools" | "tool_choice" | "stream"> & {
690
692
  reasoningEffort?: ReasoningEffort;
@@ -710,8 +712,8 @@ type ChatOpenAIOptions = {
710
712
  websocketConnectTimeoutMs?: number;
711
713
  websocketResponseIdleTimeoutMs?: number;
712
714
  };
713
- declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$1, OpenAIInvokeOptions> {
714
- readonly provider: typeof PROVIDER_NAME$1;
715
+ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$2, OpenAIInvokeOptions> {
716
+ readonly provider: typeof PROVIDER_NAME$2;
715
717
  readonly model: string;
716
718
  private readonly providerModel;
717
719
  private readonly client;
@@ -754,7 +756,7 @@ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$1, OpenAI
754
756
  private getHttpStreamDebugObserver;
755
757
  }
756
758
 
757
- declare const PROVIDER_NAME: "openrouter";
759
+ declare const PROVIDER_NAME$1: "openrouter";
758
760
  type OpenRouterTextVerbosity = Exclude<ResponseTextConfig["verbosity"], null>;
759
761
  type OpenRouterInvokeOptions = Omit<ResponseCreateParamsBase, "model" | "input" | "tools" | "tool_choice" | "stream"> & {
760
762
  reasoningEffort?: ReasoningEffort;
@@ -771,8 +773,8 @@ type ChatOpenRouterOptions = {
771
773
  reasoningFallbackApplied?: boolean;
772
774
  textVerbosity?: OpenRouterTextVerbosity;
773
775
  };
774
- declare class ChatOpenRouter implements BaseChatModel<typeof PROVIDER_NAME, OpenRouterInvokeOptions> {
775
- readonly provider: typeof PROVIDER_NAME;
776
+ declare class ChatOpenRouter implements BaseChatModel<typeof PROVIDER_NAME$1, OpenRouterInvokeOptions> {
777
+ readonly provider: typeof PROVIDER_NAME$1;
776
778
  readonly model: string;
777
779
  private readonly client;
778
780
  private readonly defaultReasoningEffort?;
@@ -789,6 +791,48 @@ declare class ChatOpenRouter implements BaseChatModel<typeof PROVIDER_NAME, Open
789
791
  private debugResponseIfEnabled;
790
792
  }
791
793
 
794
+ type ZaiReasoningEffort = "high" | "max";
795
+
796
+ declare const PROVIDER_NAME: "zai";
797
+ type ZaiInvokeOptions = {
798
+ max_tokens?: number;
799
+ temperature?: number;
800
+ top_p?: number;
801
+ reasoningEffort?: ZaiReasoningEffort | null;
802
+ [key: string]: unknown;
803
+ };
804
+ type ChatZaiOptions = {
805
+ apiKey?: string;
806
+ baseURL?: string;
807
+ fetch?: typeof fetch;
808
+ model?: string;
809
+ timeoutMs?: number | null;
810
+ reasoningEffort?: ZaiReasoningEffort | null;
811
+ reasoningLevelRequested?: "low" | "medium" | "high" | "xhigh";
812
+ reasoningLevelApplied?: "high" | "xhigh";
813
+ reasoningFallbackApplied?: boolean;
814
+ };
815
+ declare class ChatZai implements BaseChatModel<typeof PROVIDER_NAME, ZaiInvokeOptions> {
816
+ readonly provider: typeof PROVIDER_NAME;
817
+ readonly model: string;
818
+ private readonly apiKey?;
819
+ private readonly baseURL;
820
+ private readonly fetchImpl;
821
+ private readonly timeoutMs;
822
+ private readonly defaultReasoningEffort;
823
+ private readonly reasoningLevelMeta;
824
+ private debugInvokeSeq;
825
+ private lastDebugRequestPayload;
826
+ constructor(options?: ChatZaiOptions);
827
+ ainvoke(input: ChatInvokeInput & {
828
+ options?: ZaiInvokeOptions;
829
+ }, _context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
830
+ private streamRequest;
831
+ private nextDebugInvokeSeq;
832
+ private debugRequestIfEnabled;
833
+ private debugResponseIfEnabled;
834
+ }
835
+
792
836
  declare const ANTHROPIC_DEFAULT_MODEL = "claude-sonnet-4-5";
793
837
  declare const ANTHROPIC_MODELS: ModelSpec[];
794
838
 
@@ -798,6 +842,10 @@ declare const OPENAI_DEFAULT_MODEL = "gpt-5.5";
798
842
  declare const OPENAI_DEFAULT_REASONING_EFFORT = "medium";
799
843
  declare const OPENAI_MODELS: ModelSpec[];
800
844
 
845
+ declare const ZAI_DEFAULT_MODEL = "glm-5.2";
846
+ declare const ZAI_REASONING_EFFORT_MODELS: Set<string>;
847
+ declare const ZAI_MODELS: ModelSpec[];
848
+
801
849
  declare const DEFAULT_MODEL_REGISTRY: ModelRegistry;
802
850
 
803
851
  declare const getDefaultSystemPromptPath: () => string;
@@ -809,4 +857,4 @@ declare class TaskComplete extends Error {
809
857
  constructor(finalMessage?: string);
810
858
  }
811
859
 
812
- 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, ChatOpenRouter, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCapabilities, 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 ToolChoice, 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, type ToolResult, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, isUsableModelSpec, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };
860
+ 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, ChatOpenRouter, ChatZai, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCapabilities, 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 ToolChoice, 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, type ToolResult, ZAI_DEFAULT_MODEL, ZAI_MODELS, ZAI_REASONING_EFFORT_MODELS, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, isUsableModelSpec, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };
package/dist/index.d.ts CHANGED
@@ -223,7 +223,7 @@ type AgentServices = {
223
223
  toolOutputCacheStore?: ToolOutputCacheStore | null;
224
224
  };
225
225
 
226
- type ProviderName = "openai" | "anthropic" | "openrouter" | "google";
226
+ type ProviderName = "openai" | "anthropic" | "openrouter" | "google" | "zai";
227
227
  type ChatInvokeInput = {
228
228
  messages: BaseMessage[];
229
229
  model?: string;
@@ -384,6 +384,7 @@ type SessionHeader = {
384
384
  name?: string;
385
385
  reasoning?: string;
386
386
  fast?: boolean;
387
+ source?: "config" | "session";
387
388
  };
388
389
  prompts?: {
389
390
  system?: string;
@@ -513,6 +514,7 @@ type RunEndRecord = {
513
514
  };
514
515
  type SessionRecord = SessionHeader | RunStartRecord | RunContextRecord | AgentEventRecord | ToolOutputRecord | LlmRequestRecord | LlmResponseRecord | RunStatusRecord | RunErrorRecord | RunEndRecord;
515
516
  type SessionStore = {
517
+ filePath?: string;
516
518
  append: (record: SessionRecord) => Promise<void> | void;
517
519
  };
518
520
  type RunEventStoreInit = {
@@ -635,7 +637,7 @@ interface StoragePathService {
635
637
  resolvePaths(options?: ResolveStorageOptions): StoragePaths;
636
638
  }
637
639
 
638
- declare const PROVIDER_NAME$2: "anthropic";
640
+ declare const PROVIDER_NAME$3: "anthropic";
639
641
  type AnthropicMessageCreateParams = MessageCreateParamsNonStreaming & {
640
642
  speed?: "standard" | "fast" | null;
641
643
  betas?: string[];
@@ -653,8 +655,8 @@ type ChatAnthropicOptions = {
653
655
  reasoningFallbackApplied?: boolean;
654
656
  reasoningBudgetPreset?: string;
655
657
  };
656
- declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$2, AnthropicInvokeOptions> {
657
- readonly provider: typeof PROVIDER_NAME$2;
658
+ declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$3, AnthropicInvokeOptions> {
659
+ readonly provider: typeof PROVIDER_NAME$3;
658
660
  readonly model: string;
659
661
  private readonly client;
660
662
  private readonly defaultMaxTokens;
@@ -684,7 +686,7 @@ type OpenAiResponsesWsLike = {
684
686
  }): void;
685
687
  };
686
688
 
687
- declare const PROVIDER_NAME$1: "openai";
689
+ declare const PROVIDER_NAME$2: "openai";
688
690
  type OpenAITextVerbosity = Exclude<ResponseTextConfig["verbosity"], null>;
689
691
  type OpenAIInvokeOptions = Omit<ResponseCreateParamsBase, "model" | "input" | "tools" | "tool_choice" | "stream"> & {
690
692
  reasoningEffort?: ReasoningEffort;
@@ -710,8 +712,8 @@ type ChatOpenAIOptions = {
710
712
  websocketConnectTimeoutMs?: number;
711
713
  websocketResponseIdleTimeoutMs?: number;
712
714
  };
713
- declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$1, OpenAIInvokeOptions> {
714
- readonly provider: typeof PROVIDER_NAME$1;
715
+ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$2, OpenAIInvokeOptions> {
716
+ readonly provider: typeof PROVIDER_NAME$2;
715
717
  readonly model: string;
716
718
  private readonly providerModel;
717
719
  private readonly client;
@@ -754,7 +756,7 @@ declare class ChatOpenAI implements BaseChatModel<typeof PROVIDER_NAME$1, OpenAI
754
756
  private getHttpStreamDebugObserver;
755
757
  }
756
758
 
757
- declare const PROVIDER_NAME: "openrouter";
759
+ declare const PROVIDER_NAME$1: "openrouter";
758
760
  type OpenRouterTextVerbosity = Exclude<ResponseTextConfig["verbosity"], null>;
759
761
  type OpenRouterInvokeOptions = Omit<ResponseCreateParamsBase, "model" | "input" | "tools" | "tool_choice" | "stream"> & {
760
762
  reasoningEffort?: ReasoningEffort;
@@ -771,8 +773,8 @@ type ChatOpenRouterOptions = {
771
773
  reasoningFallbackApplied?: boolean;
772
774
  textVerbosity?: OpenRouterTextVerbosity;
773
775
  };
774
- declare class ChatOpenRouter implements BaseChatModel<typeof PROVIDER_NAME, OpenRouterInvokeOptions> {
775
- readonly provider: typeof PROVIDER_NAME;
776
+ declare class ChatOpenRouter implements BaseChatModel<typeof PROVIDER_NAME$1, OpenRouterInvokeOptions> {
777
+ readonly provider: typeof PROVIDER_NAME$1;
776
778
  readonly model: string;
777
779
  private readonly client;
778
780
  private readonly defaultReasoningEffort?;
@@ -789,6 +791,48 @@ declare class ChatOpenRouter implements BaseChatModel<typeof PROVIDER_NAME, Open
789
791
  private debugResponseIfEnabled;
790
792
  }
791
793
 
794
+ type ZaiReasoningEffort = "high" | "max";
795
+
796
+ declare const PROVIDER_NAME: "zai";
797
+ type ZaiInvokeOptions = {
798
+ max_tokens?: number;
799
+ temperature?: number;
800
+ top_p?: number;
801
+ reasoningEffort?: ZaiReasoningEffort | null;
802
+ [key: string]: unknown;
803
+ };
804
+ type ChatZaiOptions = {
805
+ apiKey?: string;
806
+ baseURL?: string;
807
+ fetch?: typeof fetch;
808
+ model?: string;
809
+ timeoutMs?: number | null;
810
+ reasoningEffort?: ZaiReasoningEffort | null;
811
+ reasoningLevelRequested?: "low" | "medium" | "high" | "xhigh";
812
+ reasoningLevelApplied?: "high" | "xhigh";
813
+ reasoningFallbackApplied?: boolean;
814
+ };
815
+ declare class ChatZai implements BaseChatModel<typeof PROVIDER_NAME, ZaiInvokeOptions> {
816
+ readonly provider: typeof PROVIDER_NAME;
817
+ readonly model: string;
818
+ private readonly apiKey?;
819
+ private readonly baseURL;
820
+ private readonly fetchImpl;
821
+ private readonly timeoutMs;
822
+ private readonly defaultReasoningEffort;
823
+ private readonly reasoningLevelMeta;
824
+ private debugInvokeSeq;
825
+ private lastDebugRequestPayload;
826
+ constructor(options?: ChatZaiOptions);
827
+ ainvoke(input: ChatInvokeInput & {
828
+ options?: ZaiInvokeOptions;
829
+ }, _context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
830
+ private streamRequest;
831
+ private nextDebugInvokeSeq;
832
+ private debugRequestIfEnabled;
833
+ private debugResponseIfEnabled;
834
+ }
835
+
792
836
  declare const ANTHROPIC_DEFAULT_MODEL = "claude-sonnet-4-5";
793
837
  declare const ANTHROPIC_MODELS: ModelSpec[];
794
838
 
@@ -798,6 +842,10 @@ declare const OPENAI_DEFAULT_MODEL = "gpt-5.5";
798
842
  declare const OPENAI_DEFAULT_REASONING_EFFORT = "medium";
799
843
  declare const OPENAI_MODELS: ModelSpec[];
800
844
 
845
+ declare const ZAI_DEFAULT_MODEL = "glm-5.2";
846
+ declare const ZAI_REASONING_EFFORT_MODELS: Set<string>;
847
+ declare const ZAI_MODELS: ModelSpec[];
848
+
801
849
  declare const DEFAULT_MODEL_REGISTRY: ModelRegistry;
802
850
 
803
851
  declare const getDefaultSystemPromptPath: () => string;
@@ -809,4 +857,4 @@ declare class TaskComplete extends Error {
809
857
  constructor(finalMessage?: string);
810
858
  }
811
859
 
812
- 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, ChatOpenRouter, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCapabilities, 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 ToolChoice, 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, type ToolResult, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, isUsableModelSpec, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };
860
+ 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, ChatOpenRouter, ChatZai, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type LlmRequestRecord, type LlmResponseRecord, type ModelCapabilities, 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 ToolChoice, 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, type ToolResult, ZAI_DEFAULT_MODEL, ZAI_MODELS, ZAI_REASONING_EFFORT_MODELS, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, isUsableModelSpec, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };