@codelia/core 0.1.83 → 0.1.85

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.
Files changed (4) hide show
  1. package/dist/index.cjs +3615 -2483
  2. package/dist/index.d.ts +314 -155
  3. package/dist/index.js +3619 -2494
  4. package/package.json +4 -3
package/dist/index.d.ts CHANGED
@@ -1,51 +1,17 @@
1
1
  import * as _codelia_shared_types from '@codelia/shared-types';
2
- import { LlmCallTiming, ProviderName, ModelFastMode, AgentEvent, SessionStateSummary as SessionStateSummary$1, ModelReasoningLevel } from '@codelia/shared-types';
3
- export { AgentEvent, FinalResponseEvent, LlmRetryEvent, LlmStatusEvent, ReasoningEvent, StepCompleteEvent, StepStartEvent, TextEvent, ToolCallEvent, ToolResultEvent } from '@codelia/shared-types';
2
+ import { ContentPart, TextPart, LlmCallTiming, ProviderName, ImagePart, ModelFastMode, AgentEvent, RunErrorInfo, SessionStateSummary as SessionStateSummary$1, ContextUsage, ModelReasoningLevel } from '@codelia/shared-types';
3
+ export { AgentEvent, AttachmentRefPart, ContentPart, FinalResponseEvent, HiddenUserMessageEvent, LlmRetryEvent, LlmStatusEvent, ReasoningDeltaEvent, ReasoningEvent, SteerAppliedEvent, StepCompleteEvent, StepStartEvent, TextDeltaEvent, TextEvent, ToolCallEvent, ToolResultEvent } from '@codelia/shared-types';
4
4
  import { JSONSchema7 } from 'json-schema';
5
5
  import { ZodSchema } from 'zod';
6
6
  import { Logger } from 'openai/client';
7
7
  import Anthropic from '@anthropic-ai/sdk';
8
8
  import { MessageCreateParamsNonStreaming, OutputConfig } from '@anthropic-ai/sdk/resources/messages/messages';
9
+ import { ResponsesProviderConfig } from '@codelia/config';
10
+ import { ResponseCreateParamsBase, ResponsesClientEvent, ResponseTextConfig } from 'openai/resources/responses/responses';
11
+ import { GoogleGenAI } from '@google/genai';
9
12
  import OpenAI, { ClientOptions } from 'openai';
10
- import { ResponsesClientEvent, ResponseCreateParamsBase, ResponseTextConfig } from 'openai/resources/responses/responses';
11
13
  import { ResponsesWS } from 'openai/resources/responses/ws';
12
14
  import { ReasoningEffort } from 'openai/resources/shared';
13
- import { ResponsesProviderConfig } from '@codelia/config';
14
-
15
- /**
16
- * Message Content Parts
17
- */
18
- type ImageRefPart = {
19
- type: "image_ref";
20
- image_ref: _codelia_shared_types.ImageArtifactRef;
21
- detail?: "auto" | "low" | "high";
22
- };
23
- type TextPart = {
24
- type: "text";
25
- text: string;
26
- };
27
- type ImagePart = {
28
- type: "image_url";
29
- image_url: {
30
- url: string;
31
- detail?: "auto" | "low" | "high";
32
- media_type?: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
33
- };
34
- };
35
- type DocumentPart = {
36
- type: "document";
37
- source: {
38
- data: string;
39
- media_type: "application/pdf";
40
- };
41
- };
42
- type OtherPart = {
43
- type: "other";
44
- provider: string;
45
- kind: string;
46
- payload: unknown;
47
- };
48
- type ContentPart = TextPart | ImagePart | ImageRefPart | DocumentPart | OtherPart;
49
15
 
50
16
  /**
51
17
  * Tool Call
@@ -104,7 +70,7 @@ type ToolChoice = "auto" | "required" | "none" | string;
104
70
  type JsonValue = string | number | boolean | null | {
105
71
  [key: string]: JsonValue;
106
72
  } | JsonValue[];
107
- type ToolResult = {
73
+ type ToolResult = ({
108
74
  type: "text";
109
75
  text: string;
110
76
  } | {
@@ -113,6 +79,9 @@ type ToolResult = {
113
79
  } | {
114
80
  type: "json";
115
81
  value: unknown;
82
+ }) & {
83
+ /** Optional transcript and diagnostics text for this result. */
84
+ display_content?: string;
116
85
  };
117
86
  type ToolReturn = ToolResult | string | ContentPart[] | JsonValue;
118
87
 
@@ -154,6 +123,7 @@ type ToolMessage = {
154
123
  tool_call_id: string;
155
124
  tool_name: string;
156
125
  content: string | ContentPart[];
126
+ display_content?: string;
157
127
  is_error?: boolean;
158
128
  output_ref?: ToolOutputRef;
159
129
  trimmed?: boolean;
@@ -179,6 +149,114 @@ type ChatInvokeCompletion = {
179
149
  provider_meta?: unknown;
180
150
  };
181
151
 
152
+ type ProviderFailureKind = "rate_limit" | "overloaded" | "timeout" | "network" | "hard_quota" | "auth" | "permission" | "validation" | "provider" | "cancelled";
153
+ type RetryDelaySource = "retry-after" | "reset-header" | "provider-body" | "backoff";
154
+ type ProviderFailure = {
155
+ provider: ProviderName;
156
+ kind: ProviderFailureKind;
157
+ retryable: boolean;
158
+ safeMessage: string;
159
+ /** Explicit safe context only, never a raw provider message. */
160
+ detail?: string;
161
+ status?: number;
162
+ code?: string;
163
+ retryAfterMs?: number;
164
+ delaySource?: Exclude<RetryDelaySource, "backoff">;
165
+ delivery?: "none" | "buffered" | "committed";
166
+ };
167
+ type ProviderFailureClassifier = (error: unknown) => ProviderFailure | null;
168
+ declare class ProviderFailureError extends Error {
169
+ readonly failure: ProviderFailure;
170
+ readonly attempts: number;
171
+ readonly maxAttempts: number;
172
+ constructor(failure: ProviderFailure, options?: {
173
+ attempts?: number;
174
+ maxAttempts?: number;
175
+ cause?: unknown;
176
+ });
177
+ }
178
+ declare const isProviderFailureError: (error: unknown) => error is ProviderFailureError;
179
+
180
+ type ImageTokenInput = {
181
+ width?: number;
182
+ height?: number;
183
+ detail?: "auto" | "low" | "high";
184
+ };
185
+ type ImageTokenEstimate = {
186
+ tokens: number;
187
+ method: "patch" | "tile" | "fallback";
188
+ };
189
+
190
+ type LlmRetryPolicy = {
191
+ maxRetries: number;
192
+ baseDelayMs: number;
193
+ maxDelayMs: number;
194
+ maxRetryAfterMs: number;
195
+ retryWindowMs: number;
196
+ };
197
+
198
+ /**
199
+ * One provisional chunk of streamed model output. `index` numbers the streamed
200
+ * blocks of one kind in this response, in order of their first delta. It is a
201
+ * grouping key for provisional display, not a position in the completion.
202
+ */
203
+ type ChatStreamDelta = {
204
+ kind: "text" | "reasoning";
205
+ index: number;
206
+ delta: string;
207
+ };
208
+ /** Per-attempt sink for streamed deltas. Providers that do not stream ignore it. */
209
+ type ChatStreamDeltaSink = (delta: ChatStreamDelta) => void;
210
+ type ChatInvokeInput = {
211
+ messages: BaseMessage[];
212
+ model?: string;
213
+ tools?: ToolDefinition[] | null;
214
+ toolChoice?: ToolChoice | null;
215
+ signal?: AbortSignal;
216
+ /** Optional, per-attempt. Absent means providers keep their non-delta path unchanged. */
217
+ onDelta?: ChatStreamDeltaSink;
218
+ };
219
+ type ChatInvokeContext = {
220
+ sessionKey?: string;
221
+ /** One user turn; distinct from a durable session key. */
222
+ turnKey?: string;
223
+ onProviderStatus?: (event: _codelia_shared_types.LlmStatusEvent) => void;
224
+ };
225
+ interface BaseChatModel<P extends ProviderName = ProviderName, O = unknown> {
226
+ readonly provider: P;
227
+ readonly model: string;
228
+ ainvoke(input: ChatInvokeInput & {
229
+ options?: O;
230
+ }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
231
+ classifyFailure?: ProviderFailureClassifier;
232
+ /** Endpoint-owned retry policy takes precedence over Agent defaults. */
233
+ readonly retryPolicy?: Partial<LlmRetryPolicy>;
234
+ /** Optional model-specific vision estimate; never a billing usage report. */
235
+ estimateImageTokens?(image: ImageTokenInput): ImageTokenEstimate;
236
+ onHistoryCompacted?(context?: ChatInvokeContext): void | Promise<void>;
237
+ }
238
+
239
+ declare const responseDetails: {
240
+ readonly invalid_event: "The response stream contained an invalid event.";
241
+ readonly invalid_completion: "The provider returned an incomplete or invalid completion record.";
242
+ readonly after_completion: "The provider emitted output after completion.";
243
+ readonly invalid_step_index: "The response stream contained an invalid step index.";
244
+ readonly invalid_step: "The response contained a duplicate or invalid step.";
245
+ readonly out_of_order: "The response stream contained an out-of-order step.";
246
+ readonly invalid_tool_arguments: "The response contained incomplete or invalid tool arguments.";
247
+ readonly unsupported_event: "The response stream contained an unsupported event type.";
248
+ readonly invalid_delta: "The response contained an invalid output delta.";
249
+ readonly unsupported_content: "The response contained unsupported content.";
250
+ readonly unsupported_delta: "The response contained an unsupported output delta type.";
251
+ readonly incomplete: "The response stream ended before completion.";
252
+ readonly missing_step: "The response stream omitted a required step.";
253
+ readonly invalid_output: "The response contained invalid model output.";
254
+ readonly nonterminal: "The provider response did not complete in a valid terminal state.";
255
+ readonly empty: "The provider returned no model output.";
256
+ };
257
+ /** Explicitly trusted local diagnostics; never accept a provider message/body here. */
258
+ declare const createProviderResponseError: (provider: ProviderName, reason: keyof typeof responseDetails) => ProviderFailureError;
259
+
182
260
  type ToolOutputCacheRecord = {
183
261
  tool_call_id: string;
184
262
  tool_name: string;
@@ -224,6 +302,8 @@ type ModelLimits = {
224
302
  };
225
303
  type ModelCapabilities = {
226
304
  supportsFast?: boolean;
305
+ supportsVision?: boolean;
306
+ supportsTools?: boolean;
227
307
  };
228
308
  type ModelEntry = {
229
309
  provider: string;
@@ -243,8 +323,11 @@ interface ModelMetadataService {
243
323
  getAllModelEntries(): Promise<Record<string, Record<string, ModelEntry>>>;
244
324
  }
245
325
 
326
+ type ResolveImage = (ref: _codelia_shared_types.ImageArtifactRef, signal?: AbortSignal) => Promise<ImagePart>;
246
327
  type AgentServices = {
247
- resolveImage?: (ref: _codelia_shared_types.ImageArtifactRef, signal?: AbortSignal) => Promise<ImagePart>;
328
+ resolveImage?: ResolveImage;
329
+ /** Undefined shares the existing image store. Null disables copied-image resolution. */
330
+ resolveAttachmentImage?: ResolveImage | null;
248
331
  modelMetadata?: ModelMetadataService;
249
332
  toolOutputCacheStore?: ToolOutputCacheStore | null;
250
333
  monotonicNowMs?: () => number;
@@ -253,77 +336,6 @@ type AgentServices = {
253
336
  llmRetrySleep?: (delayMs: number, signal?: AbortSignal) => Promise<void>;
254
337
  };
255
338
 
256
- type ProviderFailureKind = "rate_limit" | "overloaded" | "timeout" | "network" | "hard_quota" | "auth" | "permission" | "validation" | "provider" | "cancelled";
257
- type RetryDelaySource = "retry-after" | "reset-header" | "provider-body" | "backoff";
258
- type ProviderFailure = {
259
- provider: ProviderName;
260
- kind: ProviderFailureKind;
261
- retryable: boolean;
262
- safeMessage: string;
263
- status?: number;
264
- code?: string;
265
- retryAfterMs?: number;
266
- delaySource?: Exclude<RetryDelaySource, "backoff">;
267
- delivery?: "none" | "buffered" | "committed";
268
- };
269
- type ProviderFailureClassifier = (error: unknown) => ProviderFailure | null;
270
- declare class ProviderFailureError extends Error {
271
- readonly failure: ProviderFailure;
272
- readonly attempts: number;
273
- readonly maxAttempts: number;
274
- constructor(failure: ProviderFailure, options?: {
275
- attempts?: number;
276
- maxAttempts?: number;
277
- cause?: unknown;
278
- });
279
- }
280
- declare const isProviderFailureError: (error: unknown) => error is ProviderFailureError;
281
-
282
- type LlmRetryPolicy = {
283
- maxRetries: number;
284
- baseDelayMs: number;
285
- maxDelayMs: number;
286
- maxRetryAfterMs: number;
287
- retryWindowMs: number;
288
- };
289
-
290
- type ImageTokenInput = {
291
- width?: number;
292
- height?: number;
293
- detail?: "auto" | "low" | "high";
294
- };
295
- type ImageTokenEstimate = {
296
- tokens: number;
297
- method: "patch" | "tile" | "fallback";
298
- };
299
-
300
- type ChatInvokeInput = {
301
- messages: BaseMessage[];
302
- model?: string;
303
- tools?: ToolDefinition[] | null;
304
- toolChoice?: ToolChoice | null;
305
- signal?: AbortSignal;
306
- };
307
- type ChatInvokeContext = {
308
- sessionKey?: string;
309
- /** One user turn; distinct from a durable session key. */
310
- turnKey?: string;
311
- onProviderStatus?: (event: _codelia_shared_types.LlmStatusEvent) => void;
312
- };
313
- interface BaseChatModel<P extends ProviderName = ProviderName, O = unknown> {
314
- readonly provider: P;
315
- readonly model: string;
316
- ainvoke(input: ChatInvokeInput & {
317
- options?: O;
318
- }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
319
- classifyFailure?: ProviderFailureClassifier;
320
- /** Endpoint-owned retry policy takes precedence over Agent defaults. */
321
- readonly retryPolicy?: Partial<LlmRetryPolicy>;
322
- /** Optional model-specific vision estimate; never a billing usage report. */
323
- estimateImageTokens?(image: ImageTokenInput): ImageTokenEstimate;
324
- onHistoryCompacted?(context?: ChatInvokeContext): void | Promise<void>;
325
- }
326
-
327
339
  type ModelSpec = {
328
340
  id: string;
329
341
  provider: ProviderName;
@@ -424,12 +436,15 @@ type ToolContext = {
424
436
  type DefineToolOptions<TInput, TResult extends ToolReturn = ToolReturn> = {
425
437
  name: string;
426
438
  description: string;
439
+ /** Optional transcript/diagnostic substitute for sensitive model-facing results. */
440
+ displayResult?: string;
427
441
  input: ZodSchema<TInput>;
428
442
  execute: (input: TInput, ctx: ToolContext) => Promise<TResult> | TResult;
429
443
  };
430
444
  type Tool = {
431
445
  name: string;
432
446
  description: string;
447
+ displayResult?: string;
433
448
  definition: ToolDefinition;
434
449
  executeRaw: (rawArgsJson: string, ctx: ToolContext) => Promise<ToolResult>;
435
450
  };
@@ -489,6 +504,13 @@ type SessionHeader = {
489
504
  };
490
505
  type RunStartRecord = {
491
506
  type: "run.start";
507
+ source?: "goal";
508
+ goal?: {
509
+ goal_id: string;
510
+ revision: number;
511
+ activation_id: string;
512
+ continuation_id?: string;
513
+ };
492
514
  run_id: string;
493
515
  session_id?: string;
494
516
  ts: string;
@@ -562,6 +584,16 @@ type LlmResponseRecord = {
562
584
  };
563
585
  meta?: Record<string, unknown>;
564
586
  };
587
+ /** Compact accounting only; never includes messages or opaque provider payloads. */
588
+ type LlmUsageRecord = {
589
+ type: "llm.usage";
590
+ run_id: string;
591
+ session_id?: string;
592
+ ts: string;
593
+ seq: number;
594
+ model?: LlmRequestRecord["model"];
595
+ output: Pick<LlmResponseRecord["output"], "usage" | "timing" | "stop_reason">;
596
+ };
565
597
  type RunStatusRecord = {
566
598
  type: "run.status";
567
599
  run_id: string;
@@ -574,16 +606,9 @@ type RunErrorRecord = {
574
606
  type: "run.error";
575
607
  run_id: string;
576
608
  ts: string;
577
- error: {
578
- name: string;
579
- message: string;
609
+ error: RunErrorInfo & {
580
610
  stack?: string;
581
- provider?: ProviderName;
582
611
  kind?: ProviderFailureKind;
583
- status?: number;
584
- code?: string;
585
- attempts?: number;
586
- max_attempts?: number;
587
612
  };
588
613
  meta?: Record<string, unknown>;
589
614
  };
@@ -595,7 +620,7 @@ type RunEndRecord = {
595
620
  final?: string;
596
621
  meta?: Record<string, unknown>;
597
622
  };
598
- type SessionRecord = SessionHeader | RunStartRecord | RunContextRecord | AgentEventRecord | ToolOutputRecord | LlmRequestRecord | LlmResponseRecord | RunStatusRecord | RunErrorRecord | RunEndRecord;
623
+ type SessionRecord = SessionHeader | RunStartRecord | RunContextRecord | AgentEventRecord | ToolOutputRecord | LlmRequestRecord | LlmResponseRecord | LlmUsageRecord | RunStatusRecord | RunErrorRecord | RunEndRecord;
599
624
  type SessionStore = {
600
625
  filePath?: string;
601
626
  append: (record: SessionRecord) => Promise<void> | void;
@@ -617,10 +642,36 @@ type SessionState = {
617
642
  meta?: Record<string, unknown>;
618
643
  };
619
644
  type SessionStateSummary = SessionStateSummary$1;
645
+ type ConversationMessage = {
646
+ id: string;
647
+ role: BaseMessage["role"];
648
+ text: string;
649
+ truncated: boolean;
650
+ next_offset?: number;
651
+ };
652
+ type ConversationSearchResult = {
653
+ matches: ConversationMessage[];
654
+ next_cursor?: string;
655
+ };
620
656
  type SessionStateStore = {
621
657
  load: (sessionId: string) => Promise<SessionState | null>;
622
658
  save: (state: SessionState) => Promise<void>;
623
659
  list: () => Promise<SessionStateSummary[]>;
660
+ appendMessages?: (sessionId: string, messages: BaseMessage[]) => Promise<void>;
661
+ searchMessages?: (sessionId: string, options: {
662
+ query: string;
663
+ cursor?: string;
664
+ limit?: number;
665
+ }) => Promise<ConversationSearchResult>;
666
+ readMessage?: (sessionId: string, options: {
667
+ id: string;
668
+ offset?: number;
669
+ limit?: number;
670
+ }) => Promise<ConversationMessage | null>;
671
+ updateMetadata?: (sessionId: string, patch: {
672
+ pinned?: boolean;
673
+ archived?: boolean;
674
+ }) => Promise<SessionStateSummary>;
624
675
  };
625
676
  type AgentSession = {
626
677
  run_id: string;
@@ -628,16 +679,36 @@ type AgentSession = {
628
679
  invoke_seq?: number;
629
680
  on_error?: (error: unknown, record: SessionRecord) => void;
630
681
  append: (record: SessionRecord) => void;
682
+ /** Await durable originals before admitting messages or discarding context. */
683
+ recordMessages?: (messages: BaseMessage[]) => Promise<void>;
631
684
  };
632
685
 
686
+ type PolledMessage = string | {
687
+ kind: "hidden" | "steer";
688
+ content: string | ContentPart[];
689
+ steer_id?: string;
690
+ };
691
+ type ModelCallObserver = {
692
+ started(seq: number): Promise<void>;
693
+ completed(seq: number, usage: ChatInvokeUsage | null | undefined, uncertain: boolean): Promise<void>;
694
+ };
633
695
  type AgentRunOptions = {
634
696
  /** Untrusted messages polled only between model/tool batches; never starts a nested run. */
635
- pollMessages?: () => Promise<string[]>;
697
+ pollMessages?: () => Promise<PolledMessage[]>;
698
+ /** Runtime context is presented at user priority without becoming archival chat. */
699
+ runContext?: string;
700
+ runtimeInitiated?: boolean;
701
+ modelCallObserver?: ModelCallObserver;
636
702
  session?: AgentSession;
637
703
  signal?: AbortSignal;
638
704
  forceCompaction?: boolean;
639
705
  tools?: Tool[];
640
706
  toolChoice?: ToolChoice;
707
+ /**
708
+ * Opt-in: also yield provisional `text.delta` / `reasoning.delta` events while a
709
+ * model step streams. Complete `text` / `reasoning` / `final` events are unchanged.
710
+ */
711
+ streamDeltas?: boolean;
641
712
  };
642
713
  type AgentOptions = {
643
714
  llm: BaseChatModel;
@@ -677,11 +748,18 @@ declare class Agent {
677
748
  private readonly llmRetryDependencies;
678
749
  private history;
679
750
  private usageService;
751
+ /** Tool definitions of the latest model call (includes per-run client tools). */
752
+ private lastToolDefinitions;
680
753
  private imageUsageBaseline?;
681
754
  constructor(options: AgentOptions);
682
755
  getUsageSummary(): UsageSummary;
683
756
  getContextLeftPercent(): number | null;
757
+ /** Last provider-reported usage; a new object per completed model call. */
758
+ getLastUsage(): ChatInvokeUsage | null;
759
+ /** Context window usage with an estimated per-category breakdown. */
760
+ getContextUsage(): ContextUsage;
684
761
  getHistoryMessages(): BaseMessage[];
762
+ private recordOriginals;
685
763
  replaceHistoryMessages(messages: BaseMessage[]): void;
686
764
  private checkAndCompact;
687
765
  private trimToolOutputs;
@@ -692,6 +770,8 @@ declare class Agent {
692
770
  private recordLlmResponse;
693
771
  private invokeModelWithRetry;
694
772
  run(message: string | ContentPart[], options?: AgentRunOptions): Promise<string>;
773
+ canUseVisualAttachments(): boolean;
774
+ private get attachmentImageResolver();
695
775
  runStream(message: string | ContentPart[], options?: AgentRunOptions): AsyncGenerator<AgentEvent>;
696
776
  private generateFinalResponse;
697
777
  }
@@ -769,6 +849,87 @@ declare class ChatAnthropic implements BaseChatModel<typeof PROVIDER_NAME$5, Ant
769
849
  private debugResponseIfEnabled;
770
850
  }
771
851
 
852
+ type ResponsesInvokeOptions = {
853
+ reasoningEffort?: ModelReasoningLevel;
854
+ maxOutputTokens?: number;
855
+ text?: ResponseCreateParamsBase["text"];
856
+ };
857
+ /** Stateless HTTP Responses transport, independently named and authenticated. */
858
+ declare class ChatResponses implements BaseChatModel<string, ResponsesInvokeOptions> {
859
+ readonly provider: string;
860
+ readonly model: string;
861
+ readonly retryPolicy: {
862
+ baseDelayMs?: number | undefined;
863
+ maxRetries: number;
864
+ };
865
+ private readonly client;
866
+ private readonly endpoint;
867
+ private readonly reasoningEffort?;
868
+ private readonly textVerbosity?;
869
+ constructor(options: {
870
+ provider: string;
871
+ model: string;
872
+ endpoint: ResponsesProviderConfig;
873
+ apiKey: string;
874
+ reasoningEffort?: ModelReasoningLevel;
875
+ textVerbosity?: "low" | "medium" | "high";
876
+ fetch?: typeof fetch;
877
+ });
878
+ readonly classifyFailure: (error: unknown) => ProviderFailure;
879
+ ainvoke(input: ChatInvokeInput & {
880
+ options?: ResponsesInvokeOptions;
881
+ }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
882
+ }
883
+
884
+ /** Official stateless Responses endpoint with independent API-key authentication. */
885
+ declare class ChatDeepSeek implements BaseChatModel<"deepseek", ResponsesInvokeOptions> {
886
+ readonly provider: "deepseek";
887
+ readonly model: string;
888
+ readonly retryPolicy: {
889
+ baseDelayMs?: number | undefined;
890
+ maxRetries: number;
891
+ };
892
+ private readonly transport;
893
+ private readonly requestedEffort;
894
+ constructor(options: {
895
+ apiKey: string;
896
+ model?: string;
897
+ reasoningEffort?: ModelReasoningLevel;
898
+ fetch?: typeof fetch;
899
+ });
900
+ readonly classifyFailure: (error: unknown) => ProviderFailure;
901
+ ainvoke(input: ChatInvokeInput & {
902
+ options?: ResponsesInvokeOptions;
903
+ }, context?: ChatInvokeContext): Promise<{
904
+ provider_meta: {
905
+ reasoning_requested: "low" | "high" | "medium" | "xhigh" | "max";
906
+ reasoning_applied: "low" | "high" | "max";
907
+ reasoning_effort: "low" | "high" | "max";
908
+ reasoning_fallback: boolean;
909
+ };
910
+ usage?: ChatInvokeUsage | null;
911
+ messages: BaseMessage[];
912
+ timing?: _codelia_shared_types.LlmCallTiming;
913
+ stop_reason?: string | null;
914
+ }>;
915
+ }
916
+
917
+ type ChatGoogleOptions = {
918
+ apiKey: string;
919
+ model?: string;
920
+ thinkingLevel?: "low" | "medium" | "high" | "xhigh";
921
+ client?: GoogleGenAI;
922
+ };
923
+ declare class ChatGoogle implements BaseChatModel<"google"> {
924
+ readonly provider: "google";
925
+ readonly classifyFailure: (error: unknown) => ProviderFailure;
926
+ readonly model: string;
927
+ private readonly client;
928
+ private readonly thinkingLevel?;
929
+ constructor(options: ChatGoogleOptions);
930
+ ainvoke(input: ChatInvokeInput): Promise<ChatInvokeCompletion>;
931
+ }
932
+
772
933
  declare const PROVIDER_NAME$4: "moonshot";
773
934
  type MoonshotInvokeOptions = {
774
935
  max_completion_tokens?: number;
@@ -1013,6 +1174,36 @@ declare class ChatZai implements BaseChatModel<typeof PROVIDER_NAME, ZaiInvokeOp
1013
1174
  declare const ANTHROPIC_DEFAULT_MODEL = "claude-sonnet-4-5";
1014
1175
  declare const ANTHROPIC_MODELS: ModelSpec[];
1015
1176
 
1177
+ declare const DEEPSEEK_DEFAULT_MODEL = "deepseek-flash";
1178
+ declare const DEEPSEEK_MODELS: ({
1179
+ id: string;
1180
+ provider: string;
1181
+ aliases: string[];
1182
+ contextWindow: number;
1183
+ maxInputTokens: number;
1184
+ maxOutputTokens: number;
1185
+ supportsTools: true;
1186
+ supportsReasoning: true;
1187
+ supportsJsonSchema: true;
1188
+ supportsVision: true;
1189
+ supportsFast: false;
1190
+ } | {
1191
+ id: string;
1192
+ provider: string;
1193
+ contextWindow: number;
1194
+ maxInputTokens: number;
1195
+ maxOutputTokens: number;
1196
+ supportsTools: true;
1197
+ supportsReasoning: true;
1198
+ supportsJsonSchema: true;
1199
+ supportsVision: false;
1200
+ supportsFast: false;
1201
+ aliases?: undefined;
1202
+ })[];
1203
+ /** DeepSeek documents medium/xhigh as aliases of high. */
1204
+ declare const resolveDeepSeekEffort: (requested: ModelReasoningLevel) => "low" | "high" | "max";
1205
+
1206
+ declare const GOOGLE_DEFAULT_MODEL = "gemini-3.8-flash";
1016
1207
  declare const GOOGLE_MODELS: ModelSpec[];
1017
1208
 
1018
1209
  declare const MOONSHOT_DEFAULT_MODEL = "kimi-k3";
@@ -1042,36 +1233,4 @@ declare class TaskComplete extends Error {
1042
1233
  constructor(finalMessage?: string);
1043
1234
  }
1044
1235
 
1045
- type ResponsesInvokeOptions = {
1046
- reasoningEffort?: ModelReasoningLevel;
1047
- maxOutputTokens?: number;
1048
- text?: ResponseCreateParamsBase["text"];
1049
- };
1050
- /** Stateless HTTP Responses transport, independently named and authenticated. */
1051
- declare class ChatResponses implements BaseChatModel<string, ResponsesInvokeOptions> {
1052
- readonly provider: string;
1053
- readonly model: string;
1054
- readonly retryPolicy: {
1055
- baseDelayMs?: number | undefined;
1056
- maxRetries: number;
1057
- };
1058
- private readonly client;
1059
- private readonly endpoint;
1060
- private readonly reasoningEffort?;
1061
- private readonly textVerbosity?;
1062
- constructor(options: {
1063
- provider: string;
1064
- model: string;
1065
- endpoint: ResponsesProviderConfig;
1066
- apiKey: string;
1067
- reasoningEffort?: ModelReasoningLevel;
1068
- textVerbosity?: "low" | "medium" | "high";
1069
- fetch?: typeof fetch;
1070
- });
1071
- readonly classifyFailure: (error: unknown) => ProviderFailure;
1072
- ainvoke(input: ChatInvokeInput & {
1073
- options?: ResponsesInvokeOptions;
1074
- }, context?: ChatInvokeContext): Promise<ChatInvokeCompletion>;
1075
- }
1076
-
1077
- 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, ChatMoonshot, ChatOpenAI, ChatOpenRouter, ChatResponses, ChatXai, ChatZai, type ContentPart, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_MODELS, type ImageTokenEstimate, type ImageTokenInput, type LlmRequestRecord, type LlmResponseRecord, MOONSHOT_DEFAULT_MODEL, MOONSHOT_K3_1_MODELS, MOONSHOT_MODELS, 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 ProviderFailure, type ProviderFailureClassifier, ProviderFailureError, type ProviderFailureKind, type ResolveStorageOptions, type ResponsesInvokeOptions, type RetryDelaySource, 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, ToolPermissionDenied, type ToolPermissionHook, type ToolResult, XAI_DEFAULT_MODEL, XAI_DEFAULT_REASONING_EFFORT, XAI_MODELS, ZAI_DEFAULT_MODEL, ZAI_MODELS, ZAI_REASONING_EFFORT_MODELS, applyModelMetadata, createModelRegistry, defineTool, getDefaultSystemPromptPath, isProviderFailureError, isUsableModelSpec, listModels, registerModels, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };
1236
+ export { ANTHROPIC_DEFAULT_MODEL, ANTHROPIC_MODELS, Agent, type AgentEventRecord, type AgentOptions, type AgentRunOptions, type AgentServices, type AgentSession, type BaseChatModel, type BaseMessage, ChatAnthropic, ChatDeepSeek, ChatGoogle, type ChatInvokeContext, type ChatInvokeInput, type ChatInvokeUsage, ChatMoonshot, ChatOpenAI, ChatOpenRouter, ChatResponses, type ChatStreamDelta, type ChatStreamDeltaSink, ChatXai, ChatZai, type ConversationMessage, type ConversationSearchResult, DEEPSEEK_DEFAULT_MODEL, DEEPSEEK_MODELS, DEFAULT_MODEL_REGISTRY, type DependencyKey, GOOGLE_DEFAULT_MODEL, GOOGLE_MODELS, type ImageTokenEstimate, type ImageTokenInput, type LlmRequestRecord, type LlmResponseRecord, type LlmUsageRecord, MOONSHOT_DEFAULT_MODEL, MOONSHOT_K3_1_MODELS, MOONSHOT_MODELS, 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 PolledMessage, type ProviderFailure, type ProviderFailureClassifier, ProviderFailureError, type ProviderFailureKind, type ResolveStorageOptions, type ResponsesInvokeOptions, type RetryDelaySource, 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, ToolPermissionDenied, type ToolPermissionHook, type ToolResult, XAI_DEFAULT_MODEL, XAI_DEFAULT_REASONING_EFFORT, XAI_MODELS, ZAI_DEFAULT_MODEL, ZAI_MODELS, ZAI_REASONING_EFFORT_MODELS, applyModelMetadata, createModelRegistry, createProviderResponseError, defineTool, getDefaultSystemPromptPath, isProviderFailureError, isUsableModelSpec, listModels, registerModels, resolveDeepSeekEffort, resolveModel, resolveProviderModelId, stringifyContent, stringifyContentParts, supportsFastMode };