@cognipeer/agent-sdk 0.12.0 → 0.14.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ZodError, ZodSchema, z, ZodTypeAny } from 'zod';
2
2
  import { JSONSchema7 } from 'json-schema';
3
+ import { P as ProviderType, M as ModelRuleLearnedEvent, E as EmbeddingRequest, a as EmbeddingResponse, C as ChatCompletionRequest, b as ChatCompletionResponse, c as ChatCompletionChunk, J as JevProviderConfig, O as OpenAICompatibleProviderConfig, d as OpenAIProviderConfig, R as RulePatch, U as UnifiedMessage, T as ToolDefinition, e as TokenUsage, A as AnthropicProviderConfig, f as AzureProviderConfig, B as BedrockProviderConfig, V as VertexProviderConfig, g as ReasoningRequestConfig, h as ProviderConfig, i as ProviderError } from './model-rules-Bg9nSqyN.cjs';
4
+ export { a4 as AudioContent, I as EffortMapping, a0 as EmbeddingInputType, $ as EmbeddingUsage, a3 as FileContent, Z as FinishReason, a2 as ImageContent, v as MAX_ADJUSTMENTS, k as MODEL_RULES, W as MaxTokensParam, D as ModelRule, F as ModelRules, Q as OffMechanism, Y as ParsedModelError, _ as ProviderResponseFields, a5 as ProviderToolCall, a6 as ProviderTransportConfig, H as ReasoningEffort, N as ReasoningStyle, G as ResolvedModelRule, K as RuleFamily, L as RuleSource, X as SamplingField, S as TemperatureRule, a1 as TextContent, n as allowsSampling, o as applyDropParams, u as asModelRequestError, z as clearLearnedModelRules, p as effortBudget, j as emptyUsage, x as getLearnedModelRulePatch, w as listLearnedModelRules, m as mapReasoningEffort, q as mergeRulePatch, l as modelIdCandidates, s as parseModelError, y as rememberModelRulePatch, r as resolveModelRule, t as runWithModelAdjustments } from './model-rules-Bg9nSqyN.cjs';
3
5
 
4
6
  /** Describes what a model/provider natively supports. */
5
7
  type ModelCapabilities = {
@@ -242,7 +244,7 @@ declare function describeContentPart(part: unknown): string | undefined;
242
244
  * `content`, else its JSON).
243
245
  */
244
246
  declare function contentPartToText(part: unknown, fallback?: (part: unknown) => string): string;
245
- declare function contentToString(content: string | ContentPart$1[] | any): string;
247
+ declare function contentToString(content: string | ContentPart[] | any): string;
246
248
  declare function extractMessageText(message: any): string;
247
249
  /**
248
250
  * The text a hook should reason about: the text parts only, joined.
@@ -252,7 +254,7 @@ declare function extractMessageText(message: any): string;
252
254
  * that string would be scoring the SDK's own placeholder text, and a redactor
253
255
  * rewriting it would bake the placeholder into the message.
254
256
  */
255
- declare function textFromContent(content: string | ContentPart$1[] | unknown): string;
257
+ declare function textFromContent(content: string | ContentPart[] | unknown): string;
256
258
  /**
257
259
  * Rewrite the text of a message's content, leaving every other part exactly as
258
260
  * it was — same objects, same order.
@@ -261,7 +263,7 @@ declare function textFromContent(content: string | ContentPart$1[] | unknown): s
261
263
  * string over a multi-part `content` is the silent version of this operation:
262
264
  * the run still answers, it just answers without the image the user attached.
263
265
  */
264
- declare function mapTextParts(content: string | ContentPart$1[] | unknown, fn: (text: string) => string): string | ContentPart$1[] | unknown;
266
+ declare function mapTextParts(content: string | ContentPart[] | unknown, fn: (text: string) => string): string | ContentPart[] | unknown;
265
267
  /**
266
268
  * Put a whole replacement text back into a multi-part content.
267
269
  *
@@ -272,9 +274,9 @@ declare function mapTextParts(content: string | ContentPart$1[] | unknown, fn: (
272
274
  * plugin that needs exact multi-part fidelity should return `content` instead,
273
275
  * which is why that field exists.
274
276
  */
275
- declare function replaceTextContent(content: string | ContentPart$1[] | unknown, text: string): string | ContentPart$1[] | unknown;
277
+ declare function replaceTextContent(content: string | ContentPart[] | unknown, text: string): string | ContentPart[] | unknown;
276
278
  /** Every non-text part of a message, normalized for policy code. */
277
- declare function collectAttachments(content: string | ContentPart$1[] | unknown): MediaAttachment[];
279
+ declare function collectAttachments(content: string | ContentPart[] | unknown): MediaAttachment[];
278
280
 
279
281
  /**
280
282
  * Plugin layer — type surface.
@@ -382,7 +384,7 @@ interface HookMap {
382
384
  /** Concatenated text parts. Empty string for a media-only turn. */
383
385
  text: string;
384
386
  /** The full content, string or parts. Return `content` to rewrite it exactly. */
385
- content: string | ContentPart$1[];
387
+ content: string | ContentPart[];
386
388
  /** Every non-text part, normalized across the unified and legacy shapes. */
387
389
  attachments: MediaAttachment[];
388
390
  message: Message;
@@ -398,7 +400,7 @@ interface HookMap {
398
400
  */
399
401
  text?: string;
400
402
  /** Full control over the parts: reorder, drop an attachment, rewrite per part. */
401
- content?: string | ContentPart$1[];
403
+ content?: string | ContentPart[];
402
404
  /** Extra system-level context appended for this turn only. */
403
405
  additionalContext?: string;
404
406
  decision?: "allow" | "deny";
@@ -1128,7 +1130,7 @@ type ImageURL = {
1128
1130
  media_type?: string;
1129
1131
  detail?: 'auto' | 'low' | 'high';
1130
1132
  } | string;
1131
- type ContentPart$1 = {
1133
+ type ContentPart = {
1132
1134
  type: 'text';
1133
1135
  text: string;
1134
1136
  } | {
@@ -1188,7 +1190,7 @@ type RunnableConfig = {
1188
1190
  type BaseMessage = {
1189
1191
  role: string;
1190
1192
  name?: string;
1191
- content: string | ContentPart$1[];
1193
+ content: string | ContentPart[];
1192
1194
  tool_calls?: any;
1193
1195
  tool_call_id?: string;
1194
1196
  [key: string]: any;
@@ -1467,7 +1469,7 @@ type ReflectionConfig = {
1467
1469
  };
1468
1470
  type NativeReasoningConfig = {
1469
1471
  /** `none` is OFF — a value that gets SENT. See ReasoningEffort in providers/types.ts. */
1470
- effort?: "none" | "minimal" | "low" | "medium" | "high";
1472
+ effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
1471
1473
  budgetTokens?: number;
1472
1474
  includeThoughts?: boolean;
1473
1475
  providerExtras?: Record<string, any>;
@@ -2014,7 +2016,12 @@ type TraceEventRecord = {
2014
2016
  role?: string;
2015
2017
  version?: string;
2016
2018
  };
2017
- status: "success" | "error" | "skipped" | "retry";
2019
+ /**
2020
+ * `pending`: a step that is waiting on someone outside the run — a tool
2021
+ * approval or a question to the user that was asked when the run paused.
2022
+ * The answer is recorded as a separate event when the run resumes.
2023
+ */
2024
+ status: "success" | "error" | "skipped" | "retry" | "pending";
2018
2025
  durationMs?: number;
2019
2026
  inputTokens?: number;
2020
2027
  outputTokens?: number;
@@ -2067,7 +2074,36 @@ type TraceSessionSummary = {
2067
2074
  totalBytesOut: number;
2068
2075
  eventCounts: Record<string, number>;
2069
2076
  };
2070
- type TraceSessionStatus = "in_progress" | "success" | "error" | "partial";
2077
+ /**
2078
+ * `paused`: the run stopped to wait for a tool approval or an answer from the
2079
+ * user. Its trace continues — same session id, the next sequence numbers — in
2080
+ * the invoke that resumes it (see `TraceContinuation`).
2081
+ * `in_progress` on a finalized session: an internal leg of a longer turn
2082
+ * (the smart agent's summarization bounce) whose next leg continues it.
2083
+ */
2084
+ type TraceSessionStatus = "in_progress" | "success" | "error" | "partial" | "paused";
2085
+ /**
2086
+ * Where a paused (or mid-turn) trace session left off, carried on the
2087
+ * returned state as `ctx.__traceContinuation` so the invoke that resumes the
2088
+ * run records into the SAME session instead of opening a new one. Plain JSON:
2089
+ * it survives snapshots and a caller's own persistence of the paused state.
2090
+ */
2091
+ type TraceContinuation = {
2092
+ v: 1;
2093
+ sessionId: string;
2094
+ traceId?: string;
2095
+ rootSpanId?: string;
2096
+ threadId?: string;
2097
+ /** Epoch ms of the session's first part. */
2098
+ startedAt: number;
2099
+ /** Sequence number the next event takes. */
2100
+ nextSequence: number;
2101
+ /** 1-based number of the part that just ended. */
2102
+ part: number;
2103
+ /** Totals so far — a continued session reports cumulative totals. */
2104
+ summary: TraceSessionSummary;
2105
+ errors: TraceErrorRecord[];
2106
+ };
2071
2107
  type TraceSinkSnapshot = {
2072
2108
  type: "file";
2073
2109
  path: string;
@@ -2109,6 +2145,17 @@ type TraceSessionFile = {
2109
2145
  events: TraceEventRecord[];
2110
2146
  status: TraceSessionStatus;
2111
2147
  errors: TraceErrorRecord[];
2148
+ /**
2149
+ * Present when this payload continues a session an earlier invoke started
2150
+ * (a run resumed after a pause): `events` holds only this part's events,
2151
+ * numbered from `firstSequence`, while `summary`, `startedAt` and `errors`
2152
+ * cover the whole session. A sink should APPEND these events to the ones it
2153
+ * already has for `sessionId`, not replace them.
2154
+ */
2155
+ continuation?: {
2156
+ part: number;
2157
+ firstSequence: number;
2158
+ };
2112
2159
  };
2113
2160
  type ResolvedTraceSink = {
2114
2161
  type: "file";
@@ -2159,6 +2206,10 @@ type TraceSessionRuntime = {
2159
2206
  summary: TraceSessionSummary;
2160
2207
  status: TraceSessionStatus;
2161
2208
  errors: TraceErrorRecord[];
2209
+ /** Events recorded by earlier parts of this session (see `TraceContinuation`). */
2210
+ sequenceOffset?: number;
2211
+ /** 1-based part number; 1 for a session that starts with this invoke. */
2212
+ part?: number;
2162
2213
  fileBaseDir?: string;
2163
2214
  fileSessionDir?: string;
2164
2215
  };
@@ -3308,496 +3359,6 @@ type CreateGuardrailOptions = {
3308
3359
  };
3309
3360
  declare function createGuardrail(options: CreateGuardrailOptions): ConversationGuardrail;
3310
3361
 
3311
- type MessageRole = "system" | "user" | "assistant" | "tool";
3312
- type TextContent = {
3313
- type: "text";
3314
- text: string;
3315
- };
3316
- type ImageContent = {
3317
- type: "image";
3318
- source: {
3319
- type: "base64";
3320
- mediaType: string;
3321
- data: string;
3322
- } | {
3323
- type: "url";
3324
- url: string;
3325
- mediaType?: string;
3326
- };
3327
- };
3328
- /**
3329
- * A document attachment (PDF, DOCX, CSV, …). Providers map this to their
3330
- * native document blocks: Gemini `inlineData`/`fileData`, Anthropic
3331
- * `document`, OpenAI Chat Completions `file` / Responses `input_file`,
3332
- * Bedrock Converse `document`. Providers without document support degrade
3333
- * to a text placeholder referencing the file name/URL.
3334
- */
3335
- type FileContent = {
3336
- type: "file";
3337
- source: {
3338
- type: "base64";
3339
- mediaType: string;
3340
- data: string;
3341
- } | {
3342
- type: "url";
3343
- url: string;
3344
- mediaType?: string;
3345
- };
3346
- /** Original file name, when known (required by some providers, e.g. Bedrock). */
3347
- fileName?: string;
3348
- };
3349
- /**
3350
- * An audio attachment. Gemini accepts it as `inlineData`/`fileData`; OpenAI
3351
- * audio-capable models as `input_audio`. Providers without audio support
3352
- * degrade to a text placeholder.
3353
- */
3354
- type AudioContent = {
3355
- type: "audio";
3356
- source: {
3357
- type: "base64";
3358
- mediaType: string;
3359
- data: string;
3360
- } | {
3361
- type: "url";
3362
- url: string;
3363
- mediaType?: string;
3364
- };
3365
- };
3366
- type ContentPart = TextContent | ImageContent | FileContent | AudioContent;
3367
- type ToolCall = {
3368
- id: string;
3369
- name: string;
3370
- arguments: string;
3371
- /** Gemini `thoughtSignature` attached to a functionCall part; must be echoed back on the next turn. */
3372
- thoughtSignature?: string;
3373
- /** Position of the call within the assistant turn. Set on streamed deltas so a consumer can frame them (OpenAI `tool_calls[].index`). */
3374
- index?: number;
3375
- };
3376
- /**
3377
- * A provider-native reasoning/thinking block. Captured from the model response
3378
- * and replayed verbatim on subsequent turns (required by Anthropic extended
3379
- * thinking when tools are involved — the `signature` must round-trip intact).
3380
- */
3381
- type ReasoningBlock = {
3382
- type: "thinking" | "redacted_thinking";
3383
- /** Plain-text thinking content (absent for redacted blocks). */
3384
- text?: string;
3385
- /** Cryptographic signature Anthropic requires to be echoed back verbatim. */
3386
- signature?: string;
3387
- /** Opaque payload for redacted_thinking blocks. */
3388
- data?: string;
3389
- };
3390
- /** Captured reasoning payload attached to assistant turns / responses. */
3391
- type ReasoningPayload = {
3392
- /** Verbatim provider blocks to replay on the next turn. */
3393
- blocks?: ReasoningBlock[];
3394
- /** Human-readable reasoning summary, when the provider exposes one. */
3395
- summary?: string;
3396
- };
3397
- type UnifiedMessage = {
3398
- role: MessageRole;
3399
- content: string | ContentPart[];
3400
- name?: string;
3401
- toolCalls?: ToolCall[];
3402
- toolCallId?: string;
3403
- /** Native reasoning blocks to replay verbatim (Anthropic/Bedrock thinking). */
3404
- reasoning?: ReasoningPayload;
3405
- };
3406
- type ToolDefinition = {
3407
- name: string;
3408
- description: string;
3409
- parameters: Record<string, any>;
3410
- strict?: boolean;
3411
- };
3412
- type ChatCompletionRequest = {
3413
- model: string;
3414
- messages: UnifiedMessage[];
3415
- temperature?: number;
3416
- maxTokens?: number;
3417
- topP?: number;
3418
- stop?: string[];
3419
- /** OpenAI-family only; other providers ignore it. */
3420
- presencePenalty?: number;
3421
- /** OpenAI-family only; other providers ignore it. */
3422
- frequencyPenalty?: number;
3423
- tools?: ToolDefinition[];
3424
- toolChoice?: "auto" | "required" | "none" | {
3425
- name: string;
3426
- };
3427
- responseFormat?: {
3428
- type: "json_schema" | "json_object" | "text";
3429
- schema?: Record<string, any>;
3430
- name?: string;
3431
- };
3432
- stream?: boolean;
3433
- /**
3434
- * Streaming only. `false` opts out of `stream_options.include_usage` on
3435
- * OpenAI-shaped endpoints (some servers reject the option). Default true.
3436
- */
3437
- streamUsage?: boolean;
3438
- /** OpenAI-family: deterministic sampling seed. Passed through. */
3439
- seed?: number;
3440
- /** OpenAI-family: number of choices. Pass-through only; only choice 0 is parsed. */
3441
- n?: number;
3442
- /** OpenAI-family: allow/forbid parallel tool calls. Passed through when set. */
3443
- parallelToolCalls?: boolean;
3444
- /** OpenAI-family: return token log probabilities. Passed through. */
3445
- logprobs?: boolean;
3446
- /** OpenAI-family: how many top log probabilities per token. Passed through. */
3447
- topLogprobs?: number;
3448
- extra?: Record<string, any>;
3449
- /**
3450
- * Unified native-reasoning request config. Each provider maps this to its
3451
- * own shape:
3452
- * - OpenAI o-series: body.reasoning_effort = effort
3453
- * - OpenAI Responses: body.reasoning = { effort }
3454
- * - Anthropic: body.thinking = { type: "enabled", budget_tokens }
3455
- * - Google / Vertex: body.generationConfig.thinkingConfig = { thinkingBudget, includeThoughts }
3456
- *
3457
- * Providers silently ignore unsupported fields.
3458
- */
3459
- reasoning?: ReasoningRequestConfig;
3460
- /**
3461
- * Cancels the HTTP request (and an in-flight stream) when it aborts. The agent
3462
- * loop sets it from the run's cancellation token / abort signal; a caller using
3463
- * a provider directly can pass its own. It is never serialised into the body.
3464
- */
3465
- signal?: AbortSignal;
3466
- };
3467
- /**
3468
- * `none` is OFF, and it is a value rather than the absence of one.
3469
- *
3470
- * On a thinking-by-default model — every Qwen3 under vLLM, gpt-5.1 and newer on
3471
- * OpenAI — sending no reasoning field leaves the model thinking. So "do not
3472
- * think" is an instruction that has to travel: `reasoning_effort:"none"` on
3473
- * OpenAI, `thinkingBudget:0` on Gemini, and no thinking block at all on
3474
- * Anthropic (where thinking is opt-in and the absence IS off). Omitting
3475
- * `effort` still means "say nothing about reasoning", which is the different
3476
- * and equally necessary state.
3477
- */
3478
- type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high";
3479
- type ReasoningRequestConfig = {
3480
- /** Qualitative effort hint (mapped per-provider). */
3481
- effort?: ReasoningEffort;
3482
- /** Explicit per-call token budget for reasoning/thinking. */
3483
- budgetTokens?: number;
3484
- /**
3485
- * Gemini 3 style discrete thinking level (e.g. "low" | "high"). Sent as
3486
- * `thinkingConfig.thinkingLevel` and replaces the derived `thinkingBudget`
3487
- * (the API rejects both together). Ignored by other providers.
3488
- */
3489
- thinkingLevel?: string;
3490
- /** Whether the provider should expose its reasoning/thought summary to the caller. Gemini: default false. Claude adaptive thinking (5.x): default summarized (`thinking.display = "summarized"`) unless this is `false`; never added when the caller passes an explicit `extra.thinking`. */
3491
- includeThoughts?: boolean;
3492
- /** Provider-specific passthrough merged on top of the mapped shape. */
3493
- providerExtras?: Record<string, any>;
3494
- };
3495
- type TokenUsage = {
3496
- inputTokens: number;
3497
- outputTokens: number;
3498
- totalTokens: number;
3499
- cachedInputTokens: number;
3500
- cachedWriteTokens: number;
3501
- cachedOutputTokens: number;
3502
- reasoningTokens: number;
3503
- };
3504
- declare function emptyUsage(): TokenUsage;
3505
- type FinishReason = "stop" | "tool_calls" | "length" | "content_filter" | "error";
3506
- type ProviderResponseFields = {
3507
- system_fingerprint?: string;
3508
- service_tier?: string;
3509
- annotations?: any[];
3510
- refusal?: string | null;
3511
- logprobs?: any;
3512
- [key: string]: any;
3513
- };
3514
- type ChatCompletionResponse = {
3515
- id: string;
3516
- model: string;
3517
- content: string | null;
3518
- toolCalls: ToolCall[];
3519
- usage: TokenUsage;
3520
- finishReason: FinishReason;
3521
- /** The provider's own finish/stop reason string, unnormalised (e.g. "end_turn", "function_call"). */
3522
- rawFinishReason?: string;
3523
- /**
3524
- * Provider response fields the unified shape has no slot for, kept when present:
3525
- * `system_fingerprint`, `service_tier`, `annotations`, `refusal`, `logprobs`.
3526
- */
3527
- providerFields?: ProviderResponseFields;
3528
- /** Native reasoning blocks + summary captured from the response, if any. */
3529
- reasoning?: ReasoningPayload;
3530
- raw: any;
3531
- };
3532
- type ChatCompletionChunk = {
3533
- id: string;
3534
- model: string;
3535
- delta: {
3536
- content?: string;
3537
- toolCalls?: Partial<ToolCall>[];
3538
- /** Incremental reasoning text / signature deltas (Anthropic thinking). */
3539
- reasoning?: ReasoningPayload;
3540
- };
3541
- usage?: TokenUsage;
3542
- finishReason?: FinishReason;
3543
- /** The provider's own finish reason string, unnormalised. Present on the chunk that carries it. */
3544
- rawFinishReason?: string;
3545
- /** See ChatCompletionResponse.providerFields; per-chunk (fingerprint, tier, delta refusal/annotations, logprobs). */
3546
- providerFields?: ProviderResponseFields;
3547
- };
3548
- /** Why the text is being embedded; mapped to each provider's own task/input type. */
3549
- type EmbeddingInputType = "search_document" | "search_query" | "classification" | "clustering" | "semantic_similarity" | "question_answering" | "fact_verification" | "code_retrieval_query" | (string & {});
3550
- type EmbeddingRequest = {
3551
- /** Model id (OpenAI/compatible), deployment name (Azure), model id (Bedrock), model name (Vertex). */
3552
- model: string;
3553
- /** Texts to embed. One vector per entry, in the same order. */
3554
- input: string[];
3555
- /** Requested output dimensions, for models that support shortening (OpenAI v3, Titan v2, Cohere v4, Gemini). */
3556
- dimensions?: number;
3557
- /** OpenAI-shaped endpoints: wire encoding. Vectors are always returned as number[] either way. */
3558
- encodingFormat?: "float" | "base64";
3559
- /** Task hint (Cohere on Bedrock, Gemini on Vertex). Ignored by providers without one. */
3560
- inputType?: EmbeddingInputType;
3561
- /** Max texts per HTTP request. Defaults per provider (OpenAI 2048, Vertex 100, Gemini-embedding 1, Titan 1). */
3562
- batchSize?: number;
3563
- /** Provider-specific fields merged into each request body (escape hatch). */
3564
- extra?: Record<string, any>;
3565
- signal?: AbortSignal;
3566
- };
3567
- type EmbeddingUsage = {
3568
- inputTokens: number;
3569
- totalTokens: number;
3570
- };
3571
- type EmbeddingResponse = {
3572
- model: string;
3573
- /** One vector per input, in input order. */
3574
- vectors: number[][];
3575
- usage: EmbeddingUsage;
3576
- /** Raw provider responses, one per HTTP request made. */
3577
- raw: any[];
3578
- };
3579
- type ProviderRetryConfig = {
3580
- /** Maximum retries on 429/5xx (default 3). */
3581
- maxRetries?: number;
3582
- /** Initial delay between retries in ms (default 500, doubled each attempt). */
3583
- baseDelayMs?: number;
3584
- /** Hard cap on a single retry delay in ms (default 8000). */
3585
- maxDelayMs?: number;
3586
- /** Custom predicate to opt in/out of a specific retry. */
3587
- shouldRetry?: (error: any, attempt: number) => boolean;
3588
- };
3589
- /** Transport options shared by every provider config. */
3590
- type ProviderTransportConfig = {
3591
- /**
3592
- * Custom `fetch` used at EVERY HTTP call site of the provider (chat, stream,
3593
- * Responses, token exchange). Lets a host inject an SSRF-safe or proxied
3594
- * fetch. Defaults to the global `fetch`.
3595
- */
3596
- fetch?: typeof fetch;
3597
- /**
3598
- * Per-request timeout in ms, measured until the response headers arrive
3599
- * (an established stream is not cut by it). Default: none.
3600
- */
3601
- timeoutMs?: number;
3602
- };
3603
- type OpenAIProviderConfig = ProviderTransportConfig & {
3604
- /**
3605
- * Which token-limit field to send: `max_tokens` or `max_completion_tokens`.
3606
- * `auto` (default) uses `max_completion_tokens` for o-series / gpt-5 models
3607
- * and `max_tokens` otherwise.
3608
- */
3609
- maxTokensParam?: "auto" | "max_tokens" | "max_completion_tokens";
3610
- provider: "openai";
3611
- apiKey: string;
3612
- baseURL?: string;
3613
- organization?: string;
3614
- defaultModel?: string;
3615
- defaultHeaders?: Record<string, string>;
3616
- retry?: ProviderRetryConfig;
3617
- /**
3618
- * @deprecated Use `api: "chat" | "responses" | "auto"`. Kept as an alias:
3619
- * `never` = chat, `always` = responses, `auto` = the name-based heuristic.
3620
- * When `api` is also set, `api` wins.
3621
- *
3622
- * WHICH API a reasoning-carrying request is addressed to.
3623
- *
3624
- * auto (the default for OpenAI and Azure) route to the Responses API when
3625
- * the request carries `reasoning` AND the model name looks like an
3626
- * o-series/gpt-5 reasoning model.
3627
- * never always Chat Completions. `reasoning` is still mapped, as
3628
- * `reasoning_effort` plus any `providerExtras`.
3629
- * always always Responses, whatever the model is called.
3630
- *
3631
- * `auto` is a name-based guess, and it decides far more than where reasoning
3632
- * goes: Responses is a different request shape (`input` not `messages`,
3633
- * `text.format` not `response_format`, flat tool objects) and a different
3634
- * response parse. A caller with its own measurements of the Chat Completions
3635
- * body — a gateway, a proxy, an on-prem server that serves one and not the
3636
- * other, or anything that has tuned `extra` — must be able to say so, rather
3637
- * than discover that asking for less thinking silently changed the transport.
3638
- *
3639
- * Applies to any OpenAI-shaped endpoint, which is also why the guess is weak
3640
- * where it matters most: a self-hosted model is named by whoever served it.
3641
- */
3642
- responsesApi?: "auto" | "never" | "always";
3643
- /** @internal Set by OpenAICompatibleProvider: `auto` then means Chat Completions. */
3644
- _autoMeansChat?: boolean;
3645
- /**
3646
- * Which upstream API requests are sent to. `"auto"` (default) keeps the
3647
- * 0.11 behaviour of each class: OpenAI and Azure use Responses when the
3648
- * request carries `reasoning` and the model name looks like an o-series /
3649
- * gpt-5 model, otherwise Chat Completions; OpenAI-compatible always uses
3650
- * Chat Completions (the model name is the server operator's). `"chat"` always
3651
- * sends Chat Completions. `"responses"`
3652
- * sends every request to the Responses API (`POST /responses`) and streams it
3653
- * over real SSE (text, tool-call arguments and reasoning-summary deltas;
3654
- * set `responsesStreaming: false` to get one non-streaming call instead).
3655
- * Works on `OpenAIProvider`, `AzureProvider` and `OpenAICompatibleProvider`.
3656
- * When set, it wins over the deprecated `responsesApi`.
3657
- */
3658
- api?: "chat" | "responses" | "auto";
3659
- /**
3660
- * Models that go to the Responses API, named explicitly. Opt-in; unset by
3661
- * default.
3662
- *
3663
- * A string matches the request's model (or `defaultModel`) exactly; a RegExp
3664
- * is tested against it. A match routes the request to Responses whether or
3665
- * not it carries `reasoning` — the case this exists for is a model that
3666
- * reasons by default and rejects function tools on Chat Completions, where
3667
- * sending no reasoning field does not help. `responsesApi: "never"` still
3668
- * wins; under `"always"` the routing is unchanged.
3669
- *
3670
- * Requests for a matched model also get, on the Responses body only:
3671
- * - Chat Completions spellings arriving through `extra`, which /responses
3672
- * rejects with a 400, re-spelled with their values unchanged:
3673
- * `reasoning_effort` → `reasoning.effort` (a request `reasoning` effort
3674
- * still wins), `max_tokens` / `max_completion_tokens` →
3675
- * `max_output_tokens`, `response_format` → `text.format`, and
3676
- * `stream_options.include_usage` dropped.
3677
- * - real SSE streaming, when `responsesStreaming` is also true.
3678
- *
3679
- * Honoured by `OpenAIProvider`, `AzureProvider` and
3680
- * `OpenAICompatibleProvider` alike.
3681
- */
3682
- responsesApiModels?: Array<string | RegExp>;
3683
- /**
3684
- * Stream Responses API output as it arrives (text, tool-call argument and
3685
- * reasoning-summary deltas) for `api: "responses"` and for models in
3686
- * `responsesApiModels`. Default true with `api: "responses"`, false
3687
- * otherwise (one non-streaming Responses call emitted as a single chunk).
3688
- * Has no effect on Chat Completions requests.
3689
- */
3690
- responsesStreaming?: boolean;
3691
- };
3692
- type AnthropicProviderConfig = ProviderTransportConfig & {
3693
- provider: "anthropic";
3694
- apiKey: string;
3695
- baseURL?: string;
3696
- defaultModel?: string;
3697
- defaultHeaders?: Record<string, string>;
3698
- anthropicVersion?: string;
3699
- retry?: ProviderRetryConfig;
3700
- /**
3701
- * Prompt caching configuration. When enabled, places cache_control:
3702
- * ephemeral breakpoints on the system prompt and the final tool definition,
3703
- * which is the recommended Anthropic recipe for static system + tools.
3704
- */
3705
- prompt_caching?: {
3706
- enabled: boolean;
3707
- };
3708
- /**
3709
- * Thinking request shape. `auto` (default) picks per model id: Claude 5.x
3710
- * and newer use `thinking:{type:"adaptive"}` + `output_config.effort`, older
3711
- * models use `thinking:{type:"enabled", budget_tokens}`. Force one with
3712
- * `adaptive` / `budget`. On the specific 400 for the wrong shape the
3713
- * provider retries once with the other form.
3714
- */
3715
- thinkingMode?: "auto" | "adaptive" | "budget";
3716
- };
3717
- type AzureProviderConfig = ProviderTransportConfig & {
3718
- provider: "azure";
3719
- retry?: ProviderRetryConfig;
3720
- /** See OpenAIProviderConfig.maxTokensParam. */
3721
- maxTokensParam?: "auto" | "max_tokens" | "max_completion_tokens";
3722
- apiKey: string;
3723
- endpoint: string;
3724
- apiVersion?: string;
3725
- deploymentName?: string;
3726
- defaultModel?: string;
3727
- defaultHeaders?: Record<string, string>;
3728
- /** See OpenAIProviderConfig.api. Default "auto". */
3729
- api?: "chat" | "responses" | "auto";
3730
- /** @deprecated Use `api`. */
3731
- responsesApi?: "auto" | "never" | "always";
3732
- responsesApiModels?: Array<string | RegExp>;
3733
- responsesStreaming?: boolean;
3734
- };
3735
- type OpenAICompatibleProviderConfig = ProviderTransportConfig & {
3736
- provider: "openai-compatible";
3737
- organization?: string;
3738
- retry?: ProviderRetryConfig;
3739
- /** @deprecated Use `api`. Default: see `api`. */
3740
- responsesApi?: "auto" | "never" | "always";
3741
- /** See OpenAIProviderConfig.api. Default "auto". */
3742
- api?: "chat" | "responses" | "auto";
3743
- responsesApiModels?: Array<string | RegExp>;
3744
- responsesStreaming?: boolean;
3745
- /** See OpenAIProviderConfig.maxTokensParam. Compatible servers default to `auto`. */
3746
- maxTokensParam?: "auto" | "max_tokens" | "max_completion_tokens";
3747
- apiKey: string;
3748
- baseURL: string;
3749
- defaultModel?: string;
3750
- defaultHeaders?: Record<string, string>;
3751
- };
3752
- type BedrockProviderConfig = ProviderTransportConfig & {
3753
- provider: "bedrock";
3754
- region: string;
3755
- /** Thinking request shape for Claude models: `auto` (by model id), `adaptive` or `budget`. */
3756
- thinkingMode?: "auto" | "adaptive" | "budget";
3757
- accessKeyId?: string;
3758
- secretAccessKey?: string;
3759
- sessionToken?: string;
3760
- defaultModel?: string;
3761
- defaultHeaders?: Record<string, string>;
3762
- retry?: ProviderRetryConfig;
3763
- /**
3764
- * Insert Bedrock Converse `cachePoint` blocks at the end of the system
3765
- * prompt and tools list. Only supported by models that implement Converse
3766
- * prompt caching (most Anthropic Claude variants on Bedrock).
3767
- */
3768
- prompt_caching?: {
3769
- enabled: boolean;
3770
- };
3771
- };
3772
- type VertexProviderConfig = ProviderTransportConfig & {
3773
- provider: "vertex";
3774
- projectId: string;
3775
- location?: string;
3776
- accessToken?: string;
3777
- serviceAccountJson?: string | Record<string, any>;
3778
- defaultModel?: string;
3779
- defaultHeaders?: Record<string, string>;
3780
- /** Retry policy for 429/5xx (default 3 retries, exponential backoff). */
3781
- retry?: ProviderRetryConfig;
3782
- };
3783
- type JevProviderConfig = ProviderTransportConfig & {
3784
- provider: "jev";
3785
- apiKey: string;
3786
- /** Defaults to https://api.typesafe.ai. */
3787
- baseURL?: string;
3788
- defaultModel?: string;
3789
- defaultHeaders?: Record<string, string>;
3790
- retry?: ProviderRetryConfig;
3791
- };
3792
- type ProviderConfig = OpenAIProviderConfig | AnthropicProviderConfig | AzureProviderConfig | OpenAICompatibleProviderConfig | BedrockProviderConfig | VertexProviderConfig | JevProviderConfig;
3793
- type ProviderType = ProviderConfig["provider"];
3794
- declare class ProviderError extends Error {
3795
- readonly provider: string;
3796
- readonly statusCode?: number | undefined;
3797
- readonly responseBody?: any | undefined;
3798
- constructor(message: string, provider: string, statusCode?: number | undefined, responseBody?: any | undefined);
3799
- }
3800
-
3801
3362
  type ProviderRetryPolicy = {
3802
3363
  /** Maximum number of retries on 429/5xx responses. Default: 3. */
3803
3364
  maxRetries?: number;
@@ -3818,10 +3379,13 @@ declare abstract class BaseProvider {
3818
3379
  protected fetchImpl?: typeof fetch;
3819
3380
  /** Per-request timeout in ms (config.timeoutMs). Undefined = no timeout. */
3820
3381
  protected timeoutMs?: number;
3382
+ /** Called when a 400 taught the provider a per-model adjustment (config.onModelRuleLearned). */
3383
+ protected onModelRuleLearned?: (event: ModelRuleLearnedEvent) => void;
3821
3384
  /** Applies the transport options shared by every provider config. */
3822
3385
  protected configureTransport(config: {
3823
3386
  fetch?: typeof fetch;
3824
3387
  timeoutMs?: number;
3388
+ onModelRuleLearned?: (event: ModelRuleLearnedEvent) => void;
3825
3389
  }): void;
3826
3390
  /**
3827
3391
  * The single HTTP entry point for every provider call site. Uses the
@@ -5849,13 +5413,20 @@ declare function buildToolDefinitionsSection(toolDefinitions: Array<{
5849
5413
  * Exported for provider/node code that assembles sections itself.
5850
5414
  */
5851
5415
  declare function buildResponseFormatSection(responseFormat: Record<string, any> | undefined, strategy?: "native" | "tool_based"): TraceResponseFormatSection | undefined;
5416
+ /**
5417
+ * Reads a `ctx.__traceContinuation` value back, or undefined when it is not
5418
+ * one. It arrives from caller-persisted state, so every field is checked.
5419
+ */
5420
+ declare function readTraceContinuation(value: unknown): TraceContinuation | undefined;
5421
+ /** Where `session` leaves off, for the invoke that will continue it. */
5422
+ declare function traceContinuationOf(session: TraceSessionRuntime): TraceContinuation;
5852
5423
  /**
5853
5424
  * Start a streaming trace session. Should be called before recording events in streaming mode.
5854
5425
  * This sends the session start to the remote endpoint immediately.
5855
5426
  */
5856
5427
  declare function startStreamingSession(session: TraceSessionRuntime | undefined, agentRuntime?: AgentRuntimeConfig): Promise<void>;
5857
5428
 
5858
- /** True for Claude model ids of major version 5+ (or the `fable` line). */
5429
+ /** True when the model's rule uses `thinking:{type:"adaptive"}` + `output_config.effort` (Claude 4.6+ / 5.x). */
5859
5430
  declare function supportsAdaptiveThinking(model: unknown): boolean;
5860
5431
 
5861
5432
  declare class OpenAIProvider extends BaseProvider {
@@ -5893,7 +5464,11 @@ declare class OpenAIProvider extends BaseProvider {
5893
5464
  /** POST /embeddings, batched (default 2048 inputs per request, the OpenAI cap). */
5894
5465
  embed(request: EmbeddingRequest): Promise<EmbeddingResponse>;
5895
5466
  protected embeddingsFetch(body: Record<string, any>, signal?: AbortSignal): Promise<Response>;
5896
- protected buildRequestBody(request: ChatCompletionRequest, stream: boolean): Record<string, any>;
5467
+ /** Chat Completions call that corrects itself from the provider's own 400s (see models/adjust.ts). */
5468
+ private fetchChat;
5469
+ /** Same for the Responses API. */
5470
+ private fetchResponses;
5471
+ protected buildRequestBody(request: ChatCompletionRequest, stream: boolean, overlay?: RulePatch): Record<string, any>;
5897
5472
  protected completeResponses(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
5898
5473
  /** Real Responses SSE streaming, for models opted in through
5899
5474
  * `responsesApiModels` with `responsesStreaming` on. Emits the same chunk
@@ -5903,7 +5478,7 @@ declare class OpenAIProvider extends BaseProvider {
5903
5478
  * (taken from the completed response, exactly as the non-streaming parse
5904
5479
  * reads it). */
5905
5480
  private streamResponses;
5906
- protected buildResponsesBody(request: ChatCompletionRequest): Record<string, any>;
5481
+ protected buildResponsesBody(request: ChatCompletionRequest, overlay?: RulePatch): Record<string, any>;
5907
5482
  /** Maps a unified message to a Responses API `input` item. */
5908
5483
  protected toResponsesInput(m: UnifiedMessage): Record<string, any>;
5909
5484
  protected responsesFetch(body: Record<string, any>, signal?: AbortSignal): Promise<Response>;
@@ -6148,4 +5723,26 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
6148
5723
  */
6149
5724
  declare function createProvider(config: ProviderConfig): BaseProvider;
6150
5725
 
6151
- export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentPlugin, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type ApprovalTransport, type AudioContent, type AuditEntry, type AuditLogConfig, type AzureContentSafetyConfig, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, type BedrockGuardrailConfig, BedrockProvider, type BedrockProviderConfig, type BudgetGuardConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type CapabilityStatus, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type CheckpointPluginConfig, type CheckpointStore, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CognipeerGuardrailConfig, type CompressToolOutputParams, type ContextBuilder, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type ConversationPluginConfig, type ConversationStore, type CostEstimator, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, type EmbeddingInputType, type EmbeddingRequest, type EmbeddingResponse, type EmbeddingUsage, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FileContent, type FinalAnswerEvent, type FinishReason, type GateResult, type GuardrailCallContext, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailJudgeEngine, type GuardrailOutcome, GuardrailPhase, type GuardrailPhaseName, type GuardrailPluginOptions, type GuardrailRequest, type GuardrailRule, type GuardrailRuleResult, type GuardrailTransport, type GuardrailVerdict, type GuardrailViolation, HOOK_CONTRACT_VERSION, HOOK_NAMES, type HandoffDescriptor, type HandoffEvent, type HookContext, type HookDecision, type HookHandler, type HookMap, type HookName, type HookRegistrations, HookTimeoutError, type HttpGuardrailOptions, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InjectionScan, type InvokeConfig, type JevClientLike, type JevEngineOptions, type JevNoulAnswer, JevProvider, type JevProviderConfig, type JevQuestion, type JevSystemOneRequest, type JevSystemOneResult, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LangfuseBuildContext, type LangfuseEvent, type LangfuseEventKind, type LangfuseTracingConfig, type LanguageGuardConfig, type LoadSkillsOptions, type MaybePromise, type McpConfig, type McpConnection, type MediaAttachment, type MediaKind$1 as MediaKind, type MediaPolicyConfig, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MessageUsage, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, type OpenAIModerationConfig, OpenAIProvider, type OpenAIProviderConfig, type OtelTracingConfig, type OutputGuardConfig, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PiiDetector, type PiiEntity, type PiiRedactionConfig, type PlanEvent, type PlanStepRecord, type PlanningMode, type PluginContributions, type PluginEvent, type PluginFailureMode, type PluginHost, type PluginHostOptions, type PluginLogger, type PluginProvides, type PluginRunHost, type PluginSetupContext, type PortkeyGatewayConfig, type PortkeyGuardrailConfig, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type PromptInjectionFamily, type PromptInjectionGuardConfig, type PromptSource, type ProviderConfig, ProviderError, type ProviderResponseFields, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderTransportConfig, type ProviderType, type RateLimitConfig, type ReasoningConfig, type ReasoningLevel, type RedactionResult, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailConfig, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type ResponseCacheConfig, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SdkCapabilities, type SerializableSmartState, type SessionMetrics, type SessionMetricsConfig, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillSource, type SkillToolDeps, type SkillToolHeader, type SlotName, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StrictRestorers, type StrictTransform, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummarizerInput, type SummarizerResult, type SummarizerStrategy, type SummaryFactItem, type SummaryIntegrityCheck, TOOL_INPUT_DIGEST_KEY, type TextContent, type TokenCounter, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInputDigestOptions, type ToolInputDigestResult, type ToolInputRetentionPolicy, type ToolInterface, type ToolPolicyConfig, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, type ToolRule, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessagePart, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDefinition, type TraceToolDefinitionsSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, type VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, type WebhookApprovalConfig, agentVerdictRule, appendBoundTools, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, loadSkillsFromDisk, mapConsoleHookVerdict, mapTextParts, mcp, mediaKindOf, mediaPolicy, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseSkillFrontmatter, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, redactText, regexGuardrail, regexRule, replaceTextContent, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
5726
+ type ModelRequestErrorCode = "unsupported_parameter" | "unsupported_value" | "model_request_invalid";
5727
+ type ModelRequestErrorInit = {
5728
+ status?: number;
5729
+ code: ModelRequestErrorCode;
5730
+ param?: string;
5731
+ value?: unknown;
5732
+ supportedValues?: string[];
5733
+ provider: string;
5734
+ model: string;
5735
+ message: string;
5736
+ responseBody?: unknown;
5737
+ };
5738
+ declare class ModelRequestError extends ProviderError {
5739
+ readonly status: number;
5740
+ readonly code: ModelRequestErrorCode;
5741
+ readonly param?: string;
5742
+ readonly value?: unknown;
5743
+ readonly supportedValues?: string[];
5744
+ readonly model: string;
5745
+ constructor(init: ModelRequestErrorInit);
5746
+ }
5747
+
5748
+ export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentPlugin, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, AnthropicProviderConfig, type ApprovalTransport, type AuditEntry, type AuditLogConfig, type AzureContentSafetyConfig, AzureProvider, AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, type BedrockGuardrailConfig, BedrockProvider, BedrockProviderConfig, type BudgetGuardConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type CapabilityStatus, ChatCompletionChunk, ChatCompletionRequest, ChatCompletionResponse, type CheckpointPluginConfig, type CheckpointStore, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CognipeerGuardrailConfig, type CompressToolOutputParams, type ContextBuilder, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type ConversationPluginConfig, type ConversationStore, type CostEstimator, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, EmbeddingRequest, EmbeddingResponse, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type GateResult, type GuardrailCallContext, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailJudgeEngine, type GuardrailOutcome, GuardrailPhase, type GuardrailPhaseName, type GuardrailPluginOptions, type GuardrailRequest, type GuardrailRule, type GuardrailRuleResult, type GuardrailTransport, type GuardrailVerdict, type GuardrailViolation, HOOK_CONTRACT_VERSION, HOOK_NAMES, type HandoffDescriptor, type HandoffEvent, type HookContext, type HookDecision, type HookHandler, type HookMap, type HookName, type HookRegistrations, HookTimeoutError, type HttpGuardrailOptions, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, InMemoryMemoryStore, type InjectionScan, type InvokeConfig, type JevClientLike, type JevEngineOptions, type JevNoulAnswer, JevProvider, JevProviderConfig, type JevQuestion, type JevSystemOneRequest, type JevSystemOneResult, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LangfuseBuildContext, type LangfuseEvent, type LangfuseEventKind, type LangfuseTracingConfig, type LanguageGuardConfig, type LoadSkillsOptions, type MaybePromise, type McpConfig, type McpConnection, type MediaAttachment, type MediaKind$1 as MediaKind, type MediaPolicyConfig, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MessageUsage, type MetadataEvent, type ModelCapabilities, ModelRequestError, type ModelRequestErrorCode, type ModelRequestErrorInit, ModelRuleLearnedEvent, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, OpenAICompatibleProviderConfig, type OpenAIModerationConfig, OpenAIProvider, OpenAIProviderConfig, type OtelTracingConfig, type OutputGuardConfig, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PiiDetector, type PiiEntity, type PiiRedactionConfig, type PlanEvent, type PlanStepRecord, type PlanningMode, type PluginContributions, type PluginEvent, type PluginFailureMode, type PluginHost, type PluginHostOptions, type PluginLogger, type PluginProvides, type PluginRunHost, type PluginSetupContext, type PortkeyGatewayConfig, type PortkeyGuardrailConfig, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type PromptInjectionFamily, type PromptInjectionGuardConfig, type PromptSource, ProviderConfig, ProviderError, ToolDefinition as ProviderToolDefinition, ProviderType, type RateLimitConfig, type ReasoningConfig, type ReasoningLevel, type RedactionResult, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailConfig, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type ResponseCacheConfig, type RestoreSnapshotOptions, RulePatch, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SdkCapabilities, type SerializableSmartState, type SessionMetrics, type SessionMetricsConfig, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillSource, type SkillToolDeps, type SkillToolHeader, type SlotName, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StrictRestorers, type StrictTransform, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummarizerInput, type SummarizerResult, type SummarizerStrategy, type SummaryFactItem, type SummaryIntegrityCheck, TOOL_INPUT_DIGEST_KEY, type TokenCounter, TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInputDigestOptions, type ToolInputDigestResult, type ToolInputRetentionPolicy, type ToolInterface, type ToolPolicyConfig, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, type ToolRule, type TraceContinuation, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessagePart, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDefinition, type TraceToolDefinitionsSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, type WebhookApprovalConfig, agentVerdictRule, appendBoundTools, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, loadSkillsFromDisk, mapConsoleHookVerdict, mapTextParts, mcp, mediaKindOf, mediaPolicy, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseSkillFrontmatter, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, redactText, regexGuardrail, regexRule, replaceTextContent, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };