@cognipeer/agent-sdk 0.10.5 → 0.10.6

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
@@ -210,6 +210,37 @@ type MediaAttachment = {
210
210
  approxBytes?: number;
211
211
  fileName?: string;
212
212
  };
213
+ type MediaKind$1 = "image" | "audio" | "video" | "file";
214
+ /**
215
+ * What kind of attachment a content part is, or undefined for text and for
216
+ * anything that is not a media part.
217
+ *
218
+ * Covers the unified shape (`image`/`audio`/`file` with a `source`), the
219
+ * OpenAI shapes (`image_url`, `input_audio`, `file`, `input_image`, `input_file`)
220
+ * and Gemini's untyped `inlineData` / `fileData`.
221
+ */
222
+ declare function mediaKindOf(part: unknown): MediaKind$1 | undefined;
223
+ /** True when the content is an array holding at least one media part. */
224
+ declare function hasMediaPart(content: unknown): boolean;
225
+ /**
226
+ * A short, human-readable stand-in for a media part: `[image: photo.png]`,
227
+ * `[image: image/png]`, `[audio]`. Undefined for text and non-media parts.
228
+ *
229
+ * This is what anything that flattens content to TEXT must use for an
230
+ * attachment — token estimation, the summarizer's input, trace display. The
231
+ * alternative, `JSON.stringify(part)`, writes the whole base64 payload into the
232
+ * text: an image of ~400 tokens counts as 18,000 and a summarizer reads (and is
233
+ * truncated into) a wall of base64 instead of knowing a picture was there.
234
+ *
235
+ * The label is the part's own `name`, else its file id, else its media type.
236
+ */
237
+ declare function describeContentPart(part: unknown): string | undefined;
238
+ /**
239
+ * One content part as plain text: strings and text parts as they are, media as
240
+ * its placeholder, anything else through `fallback` (default: its own `text` /
241
+ * `content`, else its JSON).
242
+ */
243
+ declare function contentPartToText(part: unknown, fallback?: (part: unknown) => string): string;
213
244
  declare function contentToString(content: string | ContentPart$1[] | any): string;
214
245
  declare function extractMessageText(message: any): string;
215
246
  /**
@@ -1801,12 +1832,28 @@ type AgentRuntimeConfig = {
1801
1832
  smart?: ResolvedSmartAgentConfig;
1802
1833
  humanInTheLoop?: HumanInTheLoopRuntimeConfig;
1803
1834
  };
1835
+ /** One part of a message as it was sent: text, or an attachment (image, audio, file …). */
1836
+ type TraceMessagePart = {
1837
+ type?: string;
1838
+ text?: string;
1839
+ [key: string]: any;
1840
+ };
1804
1841
  type TraceMessageSection = {
1805
1842
  id?: string;
1806
1843
  kind: "message";
1807
1844
  label: string;
1808
1845
  role: string;
1846
+ /**
1847
+ * The message as text. An attachment appears in it as a short placeholder
1848
+ * (`[image: photo.png]`), never as its encoded payload.
1849
+ */
1809
1850
  content: string;
1851
+ /**
1852
+ * The message's structured parts, present only when it carries a non-text part
1853
+ * (an image, audio, a file). Lets a host render the attachment — a thumbnail —
1854
+ * where `content` can only name it. Text parts are included, in order.
1855
+ */
1856
+ parts?: TraceMessagePart[];
1810
1857
  metadata?: Record<string, any>;
1811
1858
  };
1812
1859
  type TraceToolCallSection = {
@@ -3255,725 +3302,847 @@ type CreateGuardrailOptions = {
3255
3302
  };
3256
3303
  declare function createGuardrail(options: CreateGuardrailOptions): ConversationGuardrail;
3257
3304
 
3258
- type RegexRuleOptions = {
3259
- id?: string;
3260
- title?: string;
3261
- description?: string;
3262
- pattern: RegExp | string;
3263
- flags?: string;
3264
- matchDisposition?: GuardrailDisposition;
3265
- selector?: (context: GuardrailContext) => string;
3266
- allowIfMatch?: boolean;
3267
- failureMessage?: string;
3305
+ type MessageRole = "system" | "user" | "assistant" | "tool";
3306
+ type TextContent = {
3307
+ type: "text";
3308
+ text: string;
3268
3309
  };
3269
- declare function regexRule(options: RegexRuleOptions): GuardrailRule;
3270
- type JsonSchemaRuleOptions = {
3271
- id?: string;
3272
- title?: string;
3273
- description?: string;
3274
- schema: JSONSchema7 | z.ZodTypeAny;
3275
- selector?: (context: GuardrailContext) => string;
3276
- disposition?: GuardrailDisposition;
3277
- allowOnParseError?: boolean;
3310
+ type ImageContent = {
3311
+ type: "image";
3312
+ source: {
3313
+ type: "base64";
3314
+ mediaType: string;
3315
+ data: string;
3316
+ } | {
3317
+ type: "url";
3318
+ url: string;
3319
+ mediaType?: string;
3320
+ };
3278
3321
  };
3279
- declare function jsonSchemaRule(options: JsonSchemaRuleOptions): GuardrailRule;
3280
- type CodeDetectionRuleOptions = {
3281
- id?: string;
3282
- title?: string;
3283
- description?: string;
3284
- selector?: (context: GuardrailContext) => string;
3285
- disposition?: GuardrailDisposition;
3286
- allowList?: Array<RegExp | string>;
3322
+ /**
3323
+ * A document attachment (PDF, DOCX, CSV, …). Providers map this to their
3324
+ * native document blocks: Gemini `inlineData`/`fileData`, Anthropic
3325
+ * `document`, OpenAI Chat Completions `file` / Responses `input_file`,
3326
+ * Bedrock Converse `document`. Providers without document support degrade
3327
+ * to a text placeholder referencing the file name/URL.
3328
+ */
3329
+ type FileContent = {
3330
+ type: "file";
3331
+ source: {
3332
+ type: "base64";
3333
+ mediaType: string;
3334
+ data: string;
3335
+ } | {
3336
+ type: "url";
3337
+ url: string;
3338
+ mediaType?: string;
3339
+ };
3340
+ /** Original file name, when known (required by some providers, e.g. Bedrock). */
3341
+ fileName?: string;
3287
3342
  };
3288
- declare function codePresenceRule(options?: CodeDetectionRuleOptions): GuardrailRule;
3289
- declare const guardianSchema: z.ZodObject<{
3290
- allow: z.ZodBoolean;
3291
- disposition: z.ZodOptional<z.ZodEnum<["allow", "warn", "block"]>>;
3292
- reason: z.ZodOptional<z.ZodString>;
3293
- details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
3294
- }, "strip", z.ZodTypeAny, {
3295
- allow: boolean;
3296
- reason?: string | undefined;
3297
- disposition?: "allow" | "block" | "warn" | undefined;
3298
- details?: Record<string, any> | undefined;
3299
- }, {
3300
- allow: boolean;
3301
- reason?: string | undefined;
3302
- disposition?: "allow" | "block" | "warn" | undefined;
3303
- details?: Record<string, any> | undefined;
3304
- }>;
3305
- type AgentRuleOptions = {
3306
- id?: string;
3307
- title?: string;
3308
- description?: string;
3309
- agent: SmartAgentInstance<z.infer<typeof guardianSchema>>;
3310
- systemPrompt?: string;
3311
- payloadBuilder?: (context: GuardrailContext) => string;
3312
- dispositionFallback?: GuardrailDisposition;
3343
+ /**
3344
+ * An audio attachment. Gemini accepts it as `inlineData`/`fileData`; OpenAI
3345
+ * audio-capable models as `input_audio`. Providers without audio support
3346
+ * degrade to a text placeholder.
3347
+ */
3348
+ type AudioContent = {
3349
+ type: "audio";
3350
+ source: {
3351
+ type: "base64";
3352
+ mediaType: string;
3353
+ data: string;
3354
+ } | {
3355
+ type: "url";
3356
+ url: string;
3357
+ mediaType?: string;
3358
+ };
3313
3359
  };
3314
- declare function agentVerdictRule(options: AgentRuleOptions): GuardrailRule;
3315
- type CustomRuleCallback = (context: GuardrailContext) => boolean | {
3316
- allow: boolean;
3317
- reason?: string;
3318
- disposition?: GuardrailDisposition;
3319
- details?: Record<string, any>;
3320
- } | Promise<boolean | {
3321
- allow: boolean;
3322
- reason?: string;
3323
- disposition?: GuardrailDisposition;
3324
- details?: Record<string, any>;
3325
- }>;
3326
- type CustomRuleOptions = {
3327
- id?: string;
3328
- title?: string;
3329
- description?: string;
3330
- callback: CustomRuleCallback;
3331
- defaultDisposition?: GuardrailDisposition;
3360
+ type ContentPart = TextContent | ImageContent | FileContent | AudioContent;
3361
+ type ToolCall = {
3362
+ id: string;
3363
+ name: string;
3364
+ arguments: string;
3332
3365
  };
3333
- declare function customCallbackRule(options: CustomRuleOptions): GuardrailRule;
3334
-
3335
- type GuardrailPresetBase = {
3336
- guardrailId?: string;
3337
- guardrailTitle?: string;
3338
- guardrailDescription?: string;
3339
- phases?: GuardrailPhase[];
3340
- haltOnViolation?: boolean;
3341
- onViolation?: ConversationGuardrail["onViolation"];
3342
- metadata?: Record<string, any>;
3366
+ /**
3367
+ * A provider-native reasoning/thinking block. Captured from the model response
3368
+ * and replayed verbatim on subsequent turns (required by Anthropic extended
3369
+ * thinking when tools are involved — the `signature` must round-trip intact).
3370
+ */
3371
+ type ReasoningBlock = {
3372
+ type: "thinking" | "redacted_thinking";
3373
+ /** Plain-text thinking content (absent for redacted blocks). */
3374
+ text?: string;
3375
+ /** Cryptographic signature Anthropic requires to be echoed back verbatim. */
3376
+ signature?: string;
3377
+ /** Opaque payload for redacted_thinking blocks. */
3378
+ data?: string;
3343
3379
  };
3344
- type RegexGuardrailOptions = GuardrailPresetBase & {
3345
- rule?: Omit<RegexRuleOptions, "pattern">;
3380
+ /** Captured reasoning payload attached to assistant turns / responses. */
3381
+ type ReasoningPayload = {
3382
+ /** Verbatim provider blocks to replay on the next turn. */
3383
+ blocks?: ReasoningBlock[];
3384
+ /** Human-readable reasoning summary, when the provider exposes one. */
3385
+ summary?: string;
3346
3386
  };
3347
- declare function createRegexGuardrail(pattern: RegExp | string, options?: RegexGuardrailOptions): ConversationGuardrail;
3348
- type JsonGuardrailOptions = GuardrailPresetBase & {
3349
- rule?: Omit<JsonSchemaRuleOptions, "schema">;
3387
+ type UnifiedMessage = {
3388
+ role: MessageRole;
3389
+ content: string | ContentPart[];
3390
+ name?: string;
3391
+ toolCalls?: ToolCall[];
3392
+ toolCallId?: string;
3393
+ /** Native reasoning blocks to replay verbatim (Anthropic/Bedrock thinking). */
3394
+ reasoning?: ReasoningPayload;
3350
3395
  };
3351
- declare function createJsonGuardrail(schema: JsonSchemaRuleOptions["schema"], options?: JsonGuardrailOptions): ConversationGuardrail;
3352
- type CodeGuardrailOptions = GuardrailPresetBase & {
3353
- rule?: CodeDetectionRuleOptions;
3396
+ type ToolDefinition = {
3397
+ name: string;
3398
+ description: string;
3399
+ parameters: Record<string, any>;
3400
+ strict?: boolean;
3354
3401
  };
3355
- declare function createCodeGuardrail(options?: CodeGuardrailOptions): ConversationGuardrail;
3356
-
3357
- /**
3358
- * Wrap a plugin factory so config flows through with full inference:
3359
- *
3360
- * const myGuard = definePlugin<{ level: number }>((cfg) => ({ name: "my-guard", ... }));
3361
- * myGuard({ level: 2 })
3362
- *
3363
- * The indirection buys nothing at runtime — it exists so the config type is
3364
- * inferred at the call site and the returned object is checked against
3365
- * `AgentPlugin` at the definition site, where the error message is useful.
3366
- */
3367
- declare function definePlugin<TConfig = void>(factory: (config: TConfig) => AgentPlugin): (config: TConfig) => AgentPlugin;
3368
- /**
3369
- * A single hook, packaged as a plugin. For the common case where naming and a
3370
- * lifecycle would be ceremony:
3371
- *
3372
- * defineHook("preToolUse", ({ toolName }) => toolName === "shell" ? { decision: "ask" } : undefined)
3373
- */
3374
- declare function defineHook<K extends HookName>(hook: K, handler: HookHandler<K>, opts?: {
3375
- name?: string;
3376
- priority?: number;
3377
- failureMode?: PluginFailureMode;
3378
- timeoutMs?: number;
3379
- inheritToSubagents?: boolean;
3402
+ type ChatCompletionRequest = {
3403
+ model: string;
3404
+ messages: UnifiedMessage[];
3405
+ temperature?: number;
3406
+ maxTokens?: number;
3407
+ topP?: number;
3408
+ stop?: string[];
3409
+ tools?: ToolDefinition[];
3410
+ toolChoice?: "auto" | "required" | "none" | {
3411
+ name: string;
3412
+ };
3413
+ responseFormat?: {
3414
+ type: "json_schema" | "json_object" | "text";
3415
+ schema?: Record<string, any>;
3416
+ name?: string;
3417
+ };
3418
+ stream?: boolean;
3419
+ extra?: Record<string, any>;
3380
3420
  /**
3381
- * Declare that this hook never returns `decision: "ask"`. Without it a
3382
- * `preToolUse` hook is assumed to be able to pause, and the whole tool
3383
- * batch is scheduled serially — silently costing an agent its parallel
3384
- * tool execution.
3421
+ * Unified native-reasoning request config. Each provider maps this to its
3422
+ * own shape:
3423
+ * - OpenAI o-series: body.reasoning_effort = effort
3424
+ * - OpenAI Responses: body.reasoning = { effort }
3425
+ * - Anthropic: body.thinking = { type: "enabled", budget_tokens }
3426
+ * - Google / Vertex: body.generationConfig.thinkingConfig = { thinkingBudget, includeThoughts }
3427
+ *
3428
+ * Providers silently ignore unsupported fields.
3385
3429
  */
3386
- mayRequireApproval?: boolean;
3387
- }): AgentPlugin;
3388
-
3430
+ reasoning?: ReasoningRequestConfig;
3431
+ /**
3432
+ * Cancels the HTTP request (and an in-flight stream) when it aborts. The agent
3433
+ * loop sets it from the run's cancellation token / abort signal; a caller using
3434
+ * a provider directly can pass its own. It is never serialised into the body.
3435
+ */
3436
+ signal?: AbortSignal;
3437
+ };
3389
3438
  /**
3390
- * What this build actually implements.
3391
- *
3392
- * A policy configured as `mode: "enforce"` whose hook is never called is worse
3393
- * than no policy: the console shows a control that does not exist. A host
3394
- * cannot infer that from the type surface, because a declared hook and a wired
3395
- * one look identical to TypeScript — so the runtime states it.
3439
+ * `none` is OFF, and it is a value rather than the absence of one.
3396
3440
  *
3397
- * This table is maintained BY HAND alongside the wiring. That is deliberate:
3398
- * deriving it from the registry would only prove that a handler was registered,
3399
- * not that any call site raises it, which is precisely the failure it exists to
3400
- * make visible.
3401
- */
3402
-
3403
- /**
3404
- * Bumped when the hook contract changes shape in a way a host must notice —
3405
- * a hook gains or loses a call site, a payload field changes meaning, a slot
3406
- * starts or stops being consumed. Independent of the package version.
3441
+ * On a thinking-by-default model — every Qwen3 under vLLM, gpt-5.1 and newer on
3442
+ * OpenAI — sending no reasoning field leaves the model thinking. So "do not
3443
+ * think" is an instruction that has to travel: `reasoning_effort:"none"` on
3444
+ * OpenAI, `thinkingBudget:0` on Gemini, and no thinking block at all on
3445
+ * Anthropic (where thinking is opt-in and the absence IS off). Omitting
3446
+ * `effort` still means "say nothing about reasoning", which is the different
3447
+ * and equally necessary state.
3407
3448
  */
3408
- declare const HOOK_CONTRACT_VERSION = 1;
3409
- type CapabilityStatus = {
3410
- /** True when a call site in the runtime actually raises this. */
3411
- implemented: boolean;
3412
- /** Why not, or what the caveat is. */
3413
- notes?: string;
3414
- };
3415
- type SdkCapabilities = {
3416
- hookContractVersion: number;
3417
- hooks: Record<HookName, CapabilityStatus>;
3418
- slots: Record<SlotName, CapabilityStatus>;
3419
- features: Record<string, CapabilityStatus>;
3449
+ type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high";
3450
+ type ReasoningRequestConfig = {
3451
+ /** Qualitative effort hint (mapped per-provider). */
3452
+ effort?: ReasoningEffort;
3453
+ /** Explicit per-call token budget for reasoning/thinking. */
3454
+ budgetTokens?: number;
3455
+ /** Whether the provider should expose its reasoning/thought summary to the caller. Default false. */
3456
+ includeThoughts?: boolean;
3457
+ /** Provider-specific passthrough merged on top of the mapped shape. */
3458
+ providerExtras?: Record<string, any>;
3420
3459
  };
3421
- /**
3422
- * Hook ids used by the Cognipeer Console's guardrail plane, mapped onto this
3423
- * SDK's hooks.
3424
- *
3425
- * The Console plane originally had one input stage, which collapsed two
3426
- * moments that behave differently: `userPromptSubmit` fires ONCE for a new
3427
- * user turn and can see attachments, while `preModelCall` fires before EVERY
3428
- * provider call — which is where the legacy `GuardrailPhase.Request` actually
3429
- * ran. A policy meant to vet what a person typed wants the first; one meant to
3430
- * vet every prompt reaching the model, including turns built from tool output,
3431
- * wants the second. Mapping both to one id silently changes how often the
3432
- * policy runs, and on a moderation-model guardrail that is a cost as well as a
3433
- * semantics bug.
3434
- *
3435
- * The Console added `prompt.pre` for the first and kept `input.pre` meaning
3436
- * the second, so every id below is single-valued.
3437
- */
3438
- declare const CONSOLE_HOOK_MAP: Readonly<Record<string, HookName | null>>;
3439
- /** What this build implements. Safe to call at any time; allocates a fresh copy. */
3440
- declare function pluginCapabilities(): SdkCapabilities;
3441
- /** Convenience for a host that only wants to know whether it can enforce. */
3442
- declare function isHookImplemented(hook: HookName): boolean;
3443
-
3444
- /**
3445
- * Guardrail transport + the plugin that drives it.
3446
- *
3447
- * Layered the way tracing sinks are layered — a transport seam, a generic HTTP
3448
- * implementation, an in-process escape hatch, and thin first-party presets on
3449
- * top (see `cognipeerGuardrail`, `portkeyGuardrail`). What is deliberately NOT
3450
- * copied from tracing is its retry policy: a trace post can afford four
3451
- * attempts at an 8s timeout because nothing waits on it, while a guardrail sits
3452
- * on the critical path of every turn and the same policy would stall an agent
3453
- * for half a minute.
3454
- */
3455
-
3456
- /**
3457
- * `tool` is the ARGUMENTS a model wants to run; `tool_result` is what came
3458
- * back. They are different surfaces with different risks — one is an action
3459
- * about to happen, the other is untrusted content entering the context — and a
3460
- * policy usually wants different rules for each.
3461
- */
3462
- type GuardrailPhaseName = "input" | "output" | "tool" | "tool_result";
3463
- type GuardrailRequest = {
3464
- phase: GuardrailPhaseName;
3465
- content: string;
3466
- /** Tool name for `tool` / `tool_result`, otherwise unset. */
3467
- subject?: string;
3468
- /** The SDK hook this check was raised from, so a preset can map it exactly. */
3469
- hook?: string;
3470
- /** Structured tool arguments, for a service that wants them un-stringified. */
3471
- toolArgs?: unknown;
3472
- /** The tool's return value, for `tool_result`. */
3473
- toolResult?: unknown;
3474
- /**
3475
- * Non-text parts of the turn — images, audio, video, files. A text-only
3476
- * policy sees the caption and nothing else, so a service that moderates
3477
- * media needs these; one that does not simply ignores the field.
3478
- *
3479
- * Inline payloads are DESCRIBED (kind, media type, size) rather than
3480
- * inlined: shipping a base64 image on every check would multiply the cost of
3481
- * the guardrail by the size of the upload. A service that needs the bytes
3482
- * should take a URL, or the caller should override `buildRequest`.
3483
- */
3484
- attachments?: MediaAttachment[];
3485
- metadata?: Record<string, unknown>;
3460
+ type TokenUsage = {
3461
+ inputTokens: number;
3462
+ outputTokens: number;
3463
+ totalTokens: number;
3464
+ cachedInputTokens: number;
3465
+ cachedWriteTokens: number;
3466
+ cachedOutputTokens: number;
3467
+ reasoningTokens: number;
3486
3468
  };
3487
- type GuardrailViolation = {
3488
- id?: string;
3489
- type?: string;
3490
- severity?: string;
3491
- detail?: string;
3469
+ declare function emptyUsage(): TokenUsage;
3470
+ type FinishReason = "stop" | "tool_calls" | "length" | "content_filter" | "error";
3471
+ type ChatCompletionResponse = {
3472
+ id: string;
3473
+ model: string;
3474
+ content: string | null;
3475
+ toolCalls: ToolCall[];
3476
+ usage: TokenUsage;
3477
+ finishReason: FinishReason;
3478
+ /** Native reasoning blocks + summary captured from the response, if any. */
3479
+ reasoning?: ReasoningPayload;
3480
+ raw: any;
3492
3481
  };
3493
- type GuardrailVerdict = {
3494
- action: "allow" | "block" | "mask";
3495
- message?: string;
3496
- /** Required when `action === "mask"`. */
3497
- maskedContent?: string;
3498
- violations?: GuardrailViolation[];
3499
- /** The untouched service response, for tracing and debugging. */
3500
- raw?: unknown;
3482
+ type ChatCompletionChunk = {
3483
+ id: string;
3484
+ model: string;
3485
+ delta: {
3486
+ content?: string;
3487
+ toolCalls?: Partial<ToolCall>[];
3488
+ /** Incremental reasoning text / signature deltas (Anthropic thinking). */
3489
+ reasoning?: ReasoningPayload;
3490
+ };
3491
+ usage?: TokenUsage;
3492
+ finishReason?: FinishReason;
3501
3493
  };
3502
- type GuardrailCallContext = {
3503
- runId: string;
3504
- agentName?: string;
3505
- /** Correlates a guardrail decision with the trace session in the console UI. */
3506
- traceId?: string;
3507
- signal?: AbortSignal;
3494
+ type ProviderRetryConfig = {
3495
+ /** Maximum retries on 429/5xx (default 3). */
3496
+ maxRetries?: number;
3497
+ /** Initial delay between retries in ms (default 500, doubled each attempt). */
3498
+ baseDelayMs?: number;
3499
+ /** Hard cap on a single retry delay in ms (default 8000). */
3500
+ maxDelayMs?: number;
3501
+ /** Custom predicate to opt in/out of a specific retry. */
3502
+ shouldRetry?: (error: any, attempt: number) => boolean;
3508
3503
  };
3509
- type GuardrailTransport = {
3510
- name: string;
3511
- /** Verdicts must come back in the same order as `requests`. */
3512
- evaluate(requests: GuardrailRequest[], ctx: GuardrailCallContext): MaybePromise<GuardrailVerdict[]>;
3504
+ type OpenAIProviderConfig = {
3505
+ provider: "openai";
3506
+ apiKey: string;
3507
+ baseURL?: string;
3508
+ organization?: string;
3509
+ defaultModel?: string;
3510
+ defaultHeaders?: Record<string, string>;
3511
+ retry?: ProviderRetryConfig;
3513
3512
  /**
3514
- * Optional setup-time handshake. When a service can say which phases carry
3515
- * active rules, every other phase skips the network entirely — usually the
3516
- * single biggest latency win available here.
3513
+ * WHICH API a reasoning-carrying request is addressed to.
3514
+ *
3515
+ * auto (default, and today's behaviour) route to the Responses API when
3516
+ * the request carries `reasoning` AND the model name looks like an
3517
+ * o-series/gpt-5 reasoning model.
3518
+ * never always Chat Completions. `reasoning` is still mapped, as
3519
+ * `reasoning_effort` plus any `providerExtras`.
3520
+ * always always Responses, whatever the model is called.
3521
+ *
3522
+ * `auto` is a name-based guess, and it decides far more than where reasoning
3523
+ * goes: Responses is a different request shape (`input` not `messages`,
3524
+ * `text.format` not `response_format`, flat tool objects) and a different
3525
+ * response parse. A caller with its own measurements of the Chat Completions
3526
+ * body — a gateway, a proxy, an on-prem server that serves one and not the
3527
+ * other, or anything that has tuned `extra` — must be able to say so, rather
3528
+ * than discover that asking for less thinking silently changed the transport.
3529
+ *
3530
+ * Applies to any OpenAI-shaped endpoint, which is also why the guess is weak
3531
+ * where it matters most: a self-hosted model is named by whoever served it.
3517
3532
  */
3518
- describe?: () => MaybePromise<{
3519
- activePhases?: GuardrailPhaseName[];
3520
- } | null | undefined>;
3521
- close?: () => MaybePromise<void>;
3522
- };
3523
- type HttpGuardrailOptions = {
3524
- url: string;
3525
- /** Static headers, or a thunk so a rotating token is read per call. */
3526
- headers?: Record<string, string> | (() => Record<string, string>);
3527
- /** Hard ceiling per attempt. Default 3000ms — this is on the critical path. */
3528
- timeoutMs?: number;
3529
- /** Retries after the first attempt. Default 1. */
3530
- retries?: number;
3531
- /** Send all pending checks in one request. Default true. */
3532
- batch?: boolean;
3533
- /** Override the wire request. Default: `{ items, runId, traceId }`. */
3534
- buildRequest?: (requests: GuardrailRequest[], ctx: GuardrailCallContext) => unknown;
3535
- /** Override response mapping. Default: `normalizeVerdicts`, which is forgiving. */
3536
- mapVerdict?: (response: unknown, requests: GuardrailRequest[]) => GuardrailVerdict[];
3533
+ responsesApi?: "auto" | "never" | "always";
3537
3534
  /**
3538
- * Status codes that carry a VERDICT rather than an error. Some services
3539
- * signal the outcome in the status line (e.g. 446 for a block); treating
3540
- * those as transport failures would route a real decision through the
3541
- * failureMode path with the wrong reason attached.
3535
+ * Models that go to the Responses API, named explicitly. Opt-in; unset by
3536
+ * default, and nothing here is inferred from a model name.
3537
+ *
3538
+ * A string matches the request's model (or `defaultModel`) exactly; a RegExp
3539
+ * is tested against it. A match routes the request to Responses whether or
3540
+ * not it carries `reasoning` — the case this exists for is a model that
3541
+ * reasons by default and rejects function tools on Chat Completions, where
3542
+ * sending no reasoning field does not help. `responsesApi: "never"` still
3543
+ * wins; under `"always"` the routing is unchanged.
3544
+ *
3545
+ * Requests for a matched model also get, on the Responses body only:
3546
+ * - Chat Completions spellings arriving through `extra`, which /responses
3547
+ * rejects with a 400, re-spelled with their values unchanged:
3548
+ * `reasoning_effort` → `reasoning.effort` (a request `reasoning` effort
3549
+ * still wins), `max_tokens` / `max_completion_tokens` →
3550
+ * `max_output_tokens`, `response_format` → `text.format`, and
3551
+ * `stream_options.include_usage` dropped.
3552
+ * - real SSE streaming, when `responsesStreaming` is also true.
3553
+ *
3554
+ * Honoured by `OpenAIProvider` itself only; `AzureProvider` and
3555
+ * `OpenAICompatibleProvider` ignore it.
3542
3556
  */
3543
- verdictStatuses?: number[];
3544
- /** Optional GET endpoint for the setup-time handshake. */
3545
- describeUrl?: string;
3546
- name?: string;
3547
- };
3548
- /**
3549
- * Accepts the shapes a guardrail service is likely to return and normalizes
3550
- * them. Being forgiving here is the point: the exact contract can change on the
3551
- * service side without a client release, and a stricter parser would turn a
3552
- * cosmetic field rename into an outage.
3553
- */
3554
- declare function normalizeVerdicts(response: unknown, requests: GuardrailRequest[]): GuardrailVerdict[];
3555
- declare function httpGuardrail(options: HttpGuardrailOptions): GuardrailTransport;
3556
- /** In-process evaluation — regex policies, a local model, Presidio, tests. */
3557
- declare function customGuardrail(evaluate: (request: GuardrailRequest, ctx: GuardrailCallContext) => MaybePromise<GuardrailVerdict | void>, name?: string): GuardrailTransport;
3558
- type GuardrailPluginOptions = {
3559
- name: string;
3560
- transport: GuardrailTransport;
3561
- /** Which surfaces to check. Default: input + output. */
3562
- apply?: GuardrailPhaseName[];
3557
+ responsesApiModels?: Array<string | RegExp>;
3563
3558
  /**
3564
- * `shadow` evaluates and reports but never blocks or masks. This is how a
3565
- * policy gets rolled out safely: measure what it would have caught first.
3559
+ * Stream Responses API output as it arrives (text and tool-call argument
3560
+ * deltas) for models in `responsesApiModels`. Default false, which keeps the
3561
+ * existing behaviour: one non-streaming Responses call, emitted as a single
3562
+ * chunk. Has no effect on any other request.
3566
3563
  */
3567
- mode?: "enforce" | "shadow";
3568
- /** Block when the service is unreachable. Default true. */
3569
- failClosed?: boolean;
3570
- timeoutMs?: number;
3571
- priority?: number;
3572
- inheritToSubagents?: boolean;
3573
- /** Memoize verdicts per run. Default true. */
3574
- cache?: boolean | {
3575
- maxEntries?: number;
3576
- };
3577
- /** Extra metadata attached to every request. */
3578
- metadata?: Record<string, unknown>;
3564
+ responsesStreaming?: boolean;
3579
3565
  };
3580
- declare function createGuardrailPlugin(options: GuardrailPluginOptions): AgentPlugin;
3581
-
3582
- /**
3583
- * Cognipeer Console guardrail — the first-party preset.
3584
- *
3585
- * Talks to the Console's HOOK plane, not its single-shot evaluator:
3586
- *
3587
- * POST {baseUrl}/api/client/v1/guardrails/hooks/evaluate
3588
- * Authorization: Bearer <api key>
3589
- * { hook, guardrail_keys, text?, tool_name?, tool_args?, tool_result?, … }
3590
- *
3591
- * Three properties of that contract shape everything below, and getting any of
3592
- * them wrong turns a working policy into a silent one:
3593
- *
3594
- * `decision` is the EFFECTIVE verdict, already neutralised in monitor mode.
3595
- * Priority runs block > redact > warn > flag > allow.
3596
- * `enforced` false means the decision was NOT applied — a dry run. Blocking
3597
- * on `decision === "block"` without checking this turns every
3598
- * monitoring policy into an enforcing one on the day it is
3599
- * switched on for observation.
3600
- * `passed` means "no blocking finding", NOT "the request was allowed".
3601
- * The two diverge in monitor mode, which is exactly when someone
3602
- * reads the wrong one.
3603
- *
3604
- * `subject` (or `redacted_text` for the text case) is filled only when the
3605
- * service actually rewrote something; when it is present it REPLACES what was
3606
- * sent rather than being merged with it.
3607
- *
3608
- * The endpoint answers 200 for a finding as readily as for a clean check, and
3609
- * only emits 246/446 when a guardrail opts into verdict status codes — so both
3610
- * are declared as verdict-carrying rather than treated as transport failures.
3611
- * An unknown key answers 404 ON PURPOSE: a vacuous allow read as "content is
3612
- * safe" is the failure the whole plane exists to avoid.
3613
- */
3614
-
3615
- type CognipeerGuardrailConfig = {
3616
- /** Guardrail keys from the Console. Defaults to `COGNIPEER_GUARDRAIL_KEYS` (comma-separated). */
3617
- guardrailKeys?: string[];
3618
- /** Convenience for the single-key case. */
3619
- guardrailKey?: string;
3620
- /** Defaults to `COGNIPEER_API_KEY`. */
3621
- apiKey?: string;
3622
- /** Defaults to `COGNIPEER_BASE_URL`, then the production console. Point at localhost for local runs. */
3623
- baseUrl?: string;
3624
- /** Override the hook-evaluate path. */
3625
- path?: string;
3626
- /** Surfaces to guard. Default: input + output. Add `"tool"` / `"tool_result"` for the tool surface. */
3627
- apply?: GuardrailPhaseName[];
3628
- /** Restrict to specific check families, e.g. `["pii"]`. */
3629
- only?: string[];
3630
- /** Override the SDK-hook → Console-hook-id mapping, merged over the default. */
3631
- hookIds?: Record<string, string>;
3632
- /** Ask the service to evaluate without enforcing. Independent of `mode`. */
3633
- shadow?: boolean;
3634
- /** `shadow` here reports locally without acting, whatever the service says. */
3635
- mode?: "enforce" | "shadow";
3636
- /** Default true — an unreachable or misconfigured policy blocks rather than silently stops guarding. */
3637
- failClosed?: boolean;
3638
- /** Per-check ceiling. Default 3000ms; also sent as `budget_ms`. */
3639
- timeoutMs?: number;
3640
- retries?: number;
3641
- priority?: number;
3642
- cache?: boolean | {
3643
- maxEntries?: number;
3566
+ type AnthropicProviderConfig = {
3567
+ provider: "anthropic";
3568
+ apiKey: string;
3569
+ baseURL?: string;
3570
+ defaultModel?: string;
3571
+ defaultHeaders?: Record<string, string>;
3572
+ anthropicVersion?: string;
3573
+ retry?: ProviderRetryConfig;
3574
+ /**
3575
+ * Prompt caching configuration. When enabled, places cache_control:
3576
+ * ephemeral breakpoints on the system prompt and the final tool definition,
3577
+ * which is the recommended Anthropic recipe for static system + tools.
3578
+ */
3579
+ prompt_caching?: {
3580
+ enabled: boolean;
3644
3581
  };
3645
- metadata?: Record<string, unknown>;
3646
- buildRequest?: (requests: GuardrailRequest[], ctx: GuardrailCallContext) => unknown;
3647
- mapVerdict?: (response: unknown, requests: GuardrailRequest[]) => GuardrailVerdict[];
3648
- name?: string;
3649
3582
  };
3650
- /** The Console's hook response, mapped onto the transport's three-valued verdict. */
3651
- declare function mapConsoleHookVerdict(response: unknown, requests: GuardrailRequest[]): GuardrailVerdict[];
3652
- declare function cognipeerGuardrail(config?: CognipeerGuardrailConfig): AgentPlugin;
3653
-
3654
- type MessageRole = "system" | "user" | "assistant" | "tool";
3655
- type TextContent = {
3656
- type: "text";
3657
- text: string;
3583
+ type AzureProviderConfig = {
3584
+ provider: "azure";
3585
+ apiKey: string;
3586
+ endpoint: string;
3587
+ apiVersion?: string;
3588
+ deploymentName?: string;
3589
+ defaultModel?: string;
3590
+ defaultHeaders?: Record<string, string>;
3658
3591
  };
3659
- type ImageContent = {
3660
- type: "image";
3661
- source: {
3662
- type: "base64";
3663
- mediaType: string;
3664
- data: string;
3665
- } | {
3666
- type: "url";
3667
- url: string;
3668
- mediaType?: string;
3669
- };
3592
+ type OpenAICompatibleProviderConfig = {
3593
+ provider: "openai-compatible";
3594
+ apiKey: string;
3595
+ baseURL: string;
3596
+ defaultModel?: string;
3597
+ defaultHeaders?: Record<string, string>;
3670
3598
  };
3671
- /**
3672
- * A document attachment (PDF, DOCX, CSV, …). Providers map this to their
3673
- * native document blocks: Gemini `inlineData`/`fileData`, Anthropic
3674
- * `document`, OpenAI Chat Completions `file` / Responses `input_file`,
3675
- * Bedrock Converse `document`. Providers without document support degrade
3676
- * to a text placeholder referencing the file name/URL.
3677
- */
3678
- type FileContent = {
3679
- type: "file";
3680
- source: {
3681
- type: "base64";
3682
- mediaType: string;
3683
- data: string;
3684
- } | {
3685
- type: "url";
3686
- url: string;
3687
- mediaType?: string;
3599
+ type BedrockProviderConfig = {
3600
+ provider: "bedrock";
3601
+ region: string;
3602
+ accessKeyId?: string;
3603
+ secretAccessKey?: string;
3604
+ sessionToken?: string;
3605
+ defaultModel?: string;
3606
+ defaultHeaders?: Record<string, string>;
3607
+ retry?: ProviderRetryConfig;
3608
+ /**
3609
+ * Insert Bedrock Converse `cachePoint` blocks at the end of the system
3610
+ * prompt and tools list. Only supported by models that implement Converse
3611
+ * prompt caching (most Anthropic Claude variants on Bedrock).
3612
+ */
3613
+ prompt_caching?: {
3614
+ enabled: boolean;
3688
3615
  };
3689
- /** Original file name, when known (required by some providers, e.g. Bedrock). */
3690
- fileName?: string;
3691
3616
  };
3692
- /**
3693
- * An audio attachment. Gemini accepts it as `inlineData`/`fileData`; OpenAI
3694
- * audio-capable models as `input_audio`. Providers without audio support
3695
- * degrade to a text placeholder.
3696
- */
3697
- type AudioContent = {
3698
- type: "audio";
3699
- source: {
3700
- type: "base64";
3701
- mediaType: string;
3702
- data: string;
3703
- } | {
3704
- type: "url";
3705
- url: string;
3706
- mediaType?: string;
3707
- };
3617
+ type VertexProviderConfig = {
3618
+ provider: "vertex";
3619
+ projectId: string;
3620
+ location?: string;
3621
+ accessToken?: string;
3622
+ serviceAccountJson?: string | Record<string, any>;
3623
+ defaultModel?: string;
3624
+ defaultHeaders?: Record<string, string>;
3708
3625
  };
3709
- type ContentPart = TextContent | ImageContent | FileContent | AudioContent;
3710
- type ToolCall = {
3711
- id: string;
3712
- name: string;
3713
- arguments: string;
3626
+ type JevProviderConfig = {
3627
+ provider: "jev";
3628
+ apiKey: string;
3629
+ /** Defaults to https://api.typesafe.ai. */
3630
+ baseURL?: string;
3631
+ defaultModel?: string;
3632
+ defaultHeaders?: Record<string, string>;
3633
+ retry?: ProviderRetryConfig;
3714
3634
  };
3715
- /**
3716
- * A provider-native reasoning/thinking block. Captured from the model response
3717
- * and replayed verbatim on subsequent turns (required by Anthropic extended
3718
- * thinking when tools are involved — the `signature` must round-trip intact).
3719
- */
3720
- type ReasoningBlock = {
3721
- type: "thinking" | "redacted_thinking";
3722
- /** Plain-text thinking content (absent for redacted blocks). */
3723
- text?: string;
3724
- /** Cryptographic signature Anthropic requires to be echoed back verbatim. */
3725
- signature?: string;
3726
- /** Opaque payload for redacted_thinking blocks. */
3727
- data?: string;
3635
+ type ProviderConfig = OpenAIProviderConfig | AnthropicProviderConfig | AzureProviderConfig | OpenAICompatibleProviderConfig | BedrockProviderConfig | VertexProviderConfig | JevProviderConfig;
3636
+ type ProviderType = ProviderConfig["provider"];
3637
+ declare class ProviderError extends Error {
3638
+ readonly provider: string;
3639
+ readonly statusCode?: number | undefined;
3640
+ readonly responseBody?: any | undefined;
3641
+ constructor(message: string, provider: string, statusCode?: number | undefined, responseBody?: any | undefined);
3642
+ }
3643
+
3644
+ type ProviderRetryPolicy = {
3645
+ /** Maximum number of retries on 429/5xx responses. Default: 3. */
3646
+ maxRetries?: number;
3647
+ /** Initial backoff in ms (doubled on each retry). Default: 500. */
3648
+ baseDelayMs?: number;
3649
+ /** Hard cap on individual delay between retries. Default: 8000. */
3650
+ maxDelayMs?: number;
3651
+ /**
3652
+ * Custom predicate to decide whether to retry. By default we retry 429
3653
+ * and 5xx responses; pass a function to broaden/narrow that set.
3654
+ */
3655
+ shouldRetry?: (error: any, attempt: number) => boolean;
3728
3656
  };
3729
- /** Captured reasoning payload attached to assistant turns / responses. */
3730
- type ReasoningPayload = {
3731
- /** Verbatim provider blocks to replay on the next turn. */
3732
- blocks?: ReasoningBlock[];
3733
- /** Human-readable reasoning summary, when the provider exposes one. */
3734
- summary?: string;
3735
- };
3736
- type UnifiedMessage = {
3737
- role: MessageRole;
3738
- content: string | ContentPart[];
3739
- name?: string;
3740
- toolCalls?: ToolCall[];
3741
- toolCallId?: string;
3742
- /** Native reasoning blocks to replay verbatim (Anthropic/Bedrock thinking). */
3743
- reasoning?: ReasoningPayload;
3744
- };
3745
- type ToolDefinition = {
3746
- name: string;
3747
- description: string;
3748
- parameters: Record<string, any>;
3749
- strict?: boolean;
3750
- };
3751
- type ChatCompletionRequest = {
3752
- model: string;
3753
- messages: UnifiedMessage[];
3754
- temperature?: number;
3755
- maxTokens?: number;
3756
- topP?: number;
3757
- stop?: string[];
3758
- tools?: ToolDefinition[];
3759
- toolChoice?: "auto" | "required" | "none" | {
3760
- name: string;
3761
- };
3762
- responseFormat?: {
3763
- type: "json_schema" | "json_object" | "text";
3764
- schema?: Record<string, any>;
3765
- name?: string;
3766
- };
3767
- stream?: boolean;
3768
- extra?: Record<string, any>;
3657
+ declare abstract class BaseProvider {
3658
+ abstract readonly providerName: ProviderType;
3659
+ protected retryPolicy: ProviderRetryPolicy;
3660
+ /** Non-streaming completion */
3661
+ abstract complete(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
3662
+ /** Streaming completion – yields incremental chunks */
3663
+ abstract completeStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
3769
3664
  /**
3770
- * Unified native-reasoning request config. Each provider maps this to its
3771
- * own shape:
3772
- * - OpenAI o-series: body.reasoning_effort = effort
3773
- * - OpenAI Responses: body.reasoning = { effort }
3774
- * - Anthropic: body.thinking = { type: "enabled", budget_tokens }
3775
- * - Google / Vertex: body.generationConfig.thinkingConfig = { thinkingBudget, includeThoughts }
3665
+ * Helper concrete providers can wrap their fetch with. Retries 429/5xx
3666
+ * with exponential backoff and respects Retry-After if the response
3667
+ * carries one.
3776
3668
  *
3777
- * Providers silently ignore unsupported fields.
3669
+ * `signal` is the call's cancellation: a run that is cancelled while the
3670
+ * provider is backing off must not sit out the delay, nor start another attempt.
3778
3671
  */
3779
- reasoning?: ReasoningRequestConfig;
3672
+ protected doFetchWithRetry(execute: () => Promise<Response>, signal?: AbortSignal): Promise<Response>;
3673
+ }
3674
+
3675
+ /** A System One question. `noul` asks for the probability of a "yes". */
3676
+ type JevQuestion = {
3677
+ type: "noul" | "choice" | "score";
3678
+ instructions?: string;
3679
+ criteria?: unknown;
3680
+ };
3681
+ type JevSystemOneRequest = {
3682
+ /** The text the questions are asked about. */
3683
+ state: string;
3684
+ questions: Record<string, JevQuestion>;
3685
+ /** Overrides the provider's `defaultModel` for this call. */
3686
+ model?: string;
3687
+ };
3688
+ type JevSystemOneResult = {
3689
+ readonly model?: string;
3690
+ readonly answers?: Record<string, {
3691
+ readonly type: string;
3692
+ readonly noul?: number;
3693
+ readonly [k: string]: unknown;
3694
+ } | undefined>;
3695
+ readonly usage?: {
3696
+ readonly input_tokens: number;
3697
+ readonly output_tokens: number;
3698
+ };
3699
+ };
3700
+ declare class JevProvider extends BaseProvider {
3701
+ readonly providerName: ProviderType;
3702
+ private readonly apiKey;
3703
+ private readonly baseURL;
3704
+ private readonly defaultModel?;
3705
+ private readonly defaultHeaders;
3706
+ constructor(config: JevProviderConfig);
3707
+ /** Ask System One questions about `state`. */
3708
+ systemOne(request: JevSystemOneRequest, options?: {
3709
+ signal?: AbortSignal;
3710
+ }): Promise<JevSystemOneResult>;
3711
+ complete(_request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
3712
+ completeStream(_request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
3713
+ }
3714
+
3715
+ type RegexRuleOptions = {
3716
+ id?: string;
3717
+ title?: string;
3718
+ description?: string;
3719
+ pattern: RegExp | string;
3720
+ flags?: string;
3721
+ matchDisposition?: GuardrailDisposition;
3722
+ selector?: (context: GuardrailContext) => string;
3723
+ allowIfMatch?: boolean;
3724
+ failureMessage?: string;
3725
+ };
3726
+ declare function regexRule(options: RegexRuleOptions): GuardrailRule;
3727
+ type JsonSchemaRuleOptions = {
3728
+ id?: string;
3729
+ title?: string;
3730
+ description?: string;
3731
+ schema: JSONSchema7 | z.ZodTypeAny;
3732
+ selector?: (context: GuardrailContext) => string;
3733
+ disposition?: GuardrailDisposition;
3734
+ allowOnParseError?: boolean;
3735
+ };
3736
+ declare function jsonSchemaRule(options: JsonSchemaRuleOptions): GuardrailRule;
3737
+ type CodeDetectionRuleOptions = {
3738
+ id?: string;
3739
+ title?: string;
3740
+ description?: string;
3741
+ selector?: (context: GuardrailContext) => string;
3742
+ disposition?: GuardrailDisposition;
3743
+ allowList?: Array<RegExp | string>;
3744
+ };
3745
+ declare function codePresenceRule(options?: CodeDetectionRuleOptions): GuardrailRule;
3746
+ declare const guardianSchema: z.ZodObject<{
3747
+ allow: z.ZodBoolean;
3748
+ disposition: z.ZodOptional<z.ZodEnum<["allow", "warn", "block"]>>;
3749
+ reason: z.ZodOptional<z.ZodString>;
3750
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
3751
+ }, "strip", z.ZodTypeAny, {
3752
+ allow: boolean;
3753
+ reason?: string | undefined;
3754
+ disposition?: "allow" | "block" | "warn" | undefined;
3755
+ details?: Record<string, any> | undefined;
3756
+ }, {
3757
+ allow: boolean;
3758
+ reason?: string | undefined;
3759
+ disposition?: "allow" | "block" | "warn" | undefined;
3760
+ details?: Record<string, any> | undefined;
3761
+ }>;
3762
+ /** Which judge backend `agentVerdictRule` uses to produce its verdict. */
3763
+ type GuardrailJudgeEngine = "llm" | "jev";
3764
+ /** Jev answer for a `noul` (yes/no probability) question. */
3765
+ type JevNoulAnswer = {
3766
+ readonly type: "noul";
3767
+ /** Probability of a "yes", from zero to one. */
3768
+ readonly noul: number;
3780
3769
  };
3781
3770
  /**
3782
- * `none` is OFF, and it is a value rather than the absence of one.
3783
- *
3784
- * On a thinking-by-default model — every Qwen3 under vLLM, gpt-5.1 and newer on
3785
- * OpenAI — sending no reasoning field leaves the model thinking. So "do not
3786
- * think" is an instruction that has to travel: `reasoning_effort:"none"` on
3787
- * OpenAI, `thinkingBudget:0` on Gemini, and no thinking block at all on
3788
- * Anthropic (where thinking is opt-in and the absence IS off). Omitting
3789
- * `effort` still means "say nothing about reasoning", which is the different
3790
- * and equally necessary state.
3771
+ * Anything with the provider's `systemOne` method: a `JevProvider`, or a stub in tests.
3791
3772
  */
3792
- type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high";
3793
- type ReasoningRequestConfig = {
3794
- /** Qualitative effort hint (mapped per-provider). */
3795
- effort?: ReasoningEffort;
3796
- /** Explicit per-call token budget for reasoning/thinking. */
3797
- budgetTokens?: number;
3798
- /** Whether the provider should expose its reasoning/thought summary to the caller. Default false. */
3799
- includeThoughts?: boolean;
3800
- /** Provider-specific passthrough merged on top of the mapped shape. */
3801
- providerExtras?: Record<string, any>;
3773
+ type JevClientLike = Pick<JevProvider, "systemOne">;
3774
+ type JevEngineOptions = {
3775
+ /** Pre-built `JevProvider` (or compatible stub). When set, `apiKey`/`baseURL`/`model` are ignored. */
3776
+ client?: JevClientLike;
3777
+ /** API key for the `JevProvider` built on first use; falls back to `TYPESAFE_API_KEY`. */
3778
+ apiKey?: string;
3779
+ /** API root; falls back to `TYPESAFE_BASE_URL`, then the provider default. */
3780
+ baseURL?: string;
3781
+ /** Model override, per call. */
3782
+ model?: string;
3783
+ /** Risk probability at or above which the message fails the rule. Defaults to 0.5. */
3784
+ threshold?: number;
3785
+ /** Customizes the `noul` question instructions, mirroring `payloadBuilder`. */
3786
+ question?: (context: GuardrailContext) => string;
3787
+ /** Optional descriptions of the yes/no outcomes passed to the `noul` question. */
3788
+ criteria?: {
3789
+ true?: string;
3790
+ false?: string;
3791
+ };
3802
3792
  };
3803
- type TokenUsage = {
3804
- inputTokens: number;
3805
- outputTokens: number;
3806
- totalTokens: number;
3807
- cachedInputTokens: number;
3808
- cachedWriteTokens: number;
3809
- cachedOutputTokens: number;
3810
- reasoningTokens: number;
3793
+ type AgentRuleOptions = {
3794
+ id?: string;
3795
+ title?: string;
3796
+ description?: string;
3797
+ /** Guardian agent. Required for the default `"llm"` engine; unused by `"jev"`. */
3798
+ agent?: SmartAgentInstance<z.infer<typeof guardianSchema>>;
3799
+ systemPrompt?: string;
3800
+ payloadBuilder?: (context: GuardrailContext) => string;
3801
+ dispositionFallback?: GuardrailDisposition;
3802
+ /** Judge backend. Defaults to `"llm"` for full backward compatibility. */
3803
+ engine?: GuardrailJudgeEngine;
3804
+ /** Configuration for the `"jev"` engine. Ignored by the `"llm"` engine. */
3805
+ jev?: JevEngineOptions;
3811
3806
  };
3812
- declare function emptyUsage(): TokenUsage;
3813
- type FinishReason = "stop" | "tool_calls" | "length" | "content_filter" | "error";
3814
- type ChatCompletionResponse = {
3815
- id: string;
3816
- model: string;
3817
- content: string | null;
3818
- toolCalls: ToolCall[];
3819
- usage: TokenUsage;
3820
- finishReason: FinishReason;
3821
- /** Native reasoning blocks + summary captured from the response, if any. */
3822
- reasoning?: ReasoningPayload;
3823
- raw: any;
3807
+ declare function agentVerdictRule(options: AgentRuleOptions): GuardrailRule;
3808
+ type CustomRuleCallback = (context: GuardrailContext) => boolean | {
3809
+ allow: boolean;
3810
+ reason?: string;
3811
+ disposition?: GuardrailDisposition;
3812
+ details?: Record<string, any>;
3813
+ } | Promise<boolean | {
3814
+ allow: boolean;
3815
+ reason?: string;
3816
+ disposition?: GuardrailDisposition;
3817
+ details?: Record<string, any>;
3818
+ }>;
3819
+ type CustomRuleOptions = {
3820
+ id?: string;
3821
+ title?: string;
3822
+ description?: string;
3823
+ callback: CustomRuleCallback;
3824
+ defaultDisposition?: GuardrailDisposition;
3824
3825
  };
3825
- type ChatCompletionChunk = {
3826
- id: string;
3827
- model: string;
3828
- delta: {
3829
- content?: string;
3830
- toolCalls?: Partial<ToolCall>[];
3831
- /** Incremental reasoning text / signature deltas (Anthropic thinking). */
3832
- reasoning?: ReasoningPayload;
3833
- };
3834
- usage?: TokenUsage;
3835
- finishReason?: FinishReason;
3826
+ declare function customCallbackRule(options: CustomRuleOptions): GuardrailRule;
3827
+
3828
+ type GuardrailPresetBase = {
3829
+ guardrailId?: string;
3830
+ guardrailTitle?: string;
3831
+ guardrailDescription?: string;
3832
+ phases?: GuardrailPhase[];
3833
+ haltOnViolation?: boolean;
3834
+ onViolation?: ConversationGuardrail["onViolation"];
3835
+ metadata?: Record<string, any>;
3836
3836
  };
3837
- type ProviderRetryConfig = {
3838
- /** Maximum retries on 429/5xx (default 3). */
3839
- maxRetries?: number;
3840
- /** Initial delay between retries in ms (default 500, doubled each attempt). */
3841
- baseDelayMs?: number;
3842
- /** Hard cap on a single retry delay in ms (default 8000). */
3843
- maxDelayMs?: number;
3844
- /** Custom predicate to opt in/out of a specific retry. */
3845
- shouldRetry?: (error: any, attempt: number) => boolean;
3837
+ type RegexGuardrailOptions = GuardrailPresetBase & {
3838
+ rule?: Omit<RegexRuleOptions, "pattern">;
3846
3839
  };
3847
- type OpenAIProviderConfig = {
3848
- provider: "openai";
3849
- apiKey: string;
3850
- baseURL?: string;
3851
- organization?: string;
3852
- defaultModel?: string;
3853
- defaultHeaders?: Record<string, string>;
3854
- retry?: ProviderRetryConfig;
3840
+ declare function createRegexGuardrail(pattern: RegExp | string, options?: RegexGuardrailOptions): ConversationGuardrail;
3841
+ type JsonGuardrailOptions = GuardrailPresetBase & {
3842
+ rule?: Omit<JsonSchemaRuleOptions, "schema">;
3843
+ };
3844
+ declare function createJsonGuardrail(schema: JsonSchemaRuleOptions["schema"], options?: JsonGuardrailOptions): ConversationGuardrail;
3845
+ type CodeGuardrailOptions = GuardrailPresetBase & {
3846
+ rule?: CodeDetectionRuleOptions;
3847
+ };
3848
+ declare function createCodeGuardrail(options?: CodeGuardrailOptions): ConversationGuardrail;
3849
+
3850
+ /**
3851
+ * Wrap a plugin factory so config flows through with full inference:
3852
+ *
3853
+ * const myGuard = definePlugin<{ level: number }>((cfg) => ({ name: "my-guard", ... }));
3854
+ * myGuard({ level: 2 })
3855
+ *
3856
+ * The indirection buys nothing at runtime — it exists so the config type is
3857
+ * inferred at the call site and the returned object is checked against
3858
+ * `AgentPlugin` at the definition site, where the error message is useful.
3859
+ */
3860
+ declare function definePlugin<TConfig = void>(factory: (config: TConfig) => AgentPlugin): (config: TConfig) => AgentPlugin;
3861
+ /**
3862
+ * A single hook, packaged as a plugin. For the common case where naming and a
3863
+ * lifecycle would be ceremony:
3864
+ *
3865
+ * defineHook("preToolUse", ({ toolName }) => toolName === "shell" ? { decision: "ask" } : undefined)
3866
+ */
3867
+ declare function defineHook<K extends HookName>(hook: K, handler: HookHandler<K>, opts?: {
3868
+ name?: string;
3869
+ priority?: number;
3870
+ failureMode?: PluginFailureMode;
3871
+ timeoutMs?: number;
3872
+ inheritToSubagents?: boolean;
3855
3873
  /**
3856
- * WHICH API a reasoning-carrying request is addressed to.
3857
- *
3858
- * auto (default, and today's behaviour) route to the Responses API when
3859
- * the request carries `reasoning` AND the model name looks like an
3860
- * o-series/gpt-5 reasoning model.
3861
- * never always Chat Completions. `reasoning` is still mapped, as
3862
- * `reasoning_effort` plus any `providerExtras`.
3863
- * always always Responses, whatever the model is called.
3864
- *
3865
- * `auto` is a name-based guess, and it decides far more than where reasoning
3866
- * goes: Responses is a different request shape (`input` not `messages`,
3867
- * `text.format` not `response_format`, flat tool objects) and a different
3868
- * response parse. A caller with its own measurements of the Chat Completions
3869
- * body — a gateway, a proxy, an on-prem server that serves one and not the
3870
- * other, or anything that has tuned `extra` — must be able to say so, rather
3871
- * than discover that asking for less thinking silently changed the transport.
3872
- *
3873
- * Applies to any OpenAI-shaped endpoint, which is also why the guess is weak
3874
- * where it matters most: a self-hosted model is named by whoever served it.
3874
+ * Declare that this hook never returns `decision: "ask"`. Without it a
3875
+ * `preToolUse` hook is assumed to be able to pause, and the whole tool
3876
+ * batch is scheduled serially — silently costing an agent its parallel
3877
+ * tool execution.
3875
3878
  */
3876
- responsesApi?: "auto" | "never" | "always";
3879
+ mayRequireApproval?: boolean;
3880
+ }): AgentPlugin;
3881
+
3882
+ /**
3883
+ * What this build actually implements.
3884
+ *
3885
+ * A policy configured as `mode: "enforce"` whose hook is never called is worse
3886
+ * than no policy: the console shows a control that does not exist. A host
3887
+ * cannot infer that from the type surface, because a declared hook and a wired
3888
+ * one look identical to TypeScript — so the runtime states it.
3889
+ *
3890
+ * This table is maintained BY HAND alongside the wiring. That is deliberate:
3891
+ * deriving it from the registry would only prove that a handler was registered,
3892
+ * not that any call site raises it, which is precisely the failure it exists to
3893
+ * make visible.
3894
+ */
3895
+
3896
+ /**
3897
+ * Bumped when the hook contract changes shape in a way a host must notice —
3898
+ * a hook gains or loses a call site, a payload field changes meaning, a slot
3899
+ * starts or stops being consumed. Independent of the package version.
3900
+ */
3901
+ declare const HOOK_CONTRACT_VERSION = 1;
3902
+ type CapabilityStatus = {
3903
+ /** True when a call site in the runtime actually raises this. */
3904
+ implemented: boolean;
3905
+ /** Why not, or what the caveat is. */
3906
+ notes?: string;
3907
+ };
3908
+ type SdkCapabilities = {
3909
+ hookContractVersion: number;
3910
+ hooks: Record<HookName, CapabilityStatus>;
3911
+ slots: Record<SlotName, CapabilityStatus>;
3912
+ features: Record<string, CapabilityStatus>;
3913
+ };
3914
+ /**
3915
+ * Hook ids used by the Cognipeer Console's guardrail plane, mapped onto this
3916
+ * SDK's hooks.
3917
+ *
3918
+ * The Console plane originally had one input stage, which collapsed two
3919
+ * moments that behave differently: `userPromptSubmit` fires ONCE for a new
3920
+ * user turn and can see attachments, while `preModelCall` fires before EVERY
3921
+ * provider call — which is where the legacy `GuardrailPhase.Request` actually
3922
+ * ran. A policy meant to vet what a person typed wants the first; one meant to
3923
+ * vet every prompt reaching the model, including turns built from tool output,
3924
+ * wants the second. Mapping both to one id silently changes how often the
3925
+ * policy runs, and on a moderation-model guardrail that is a cost as well as a
3926
+ * semantics bug.
3927
+ *
3928
+ * The Console added `prompt.pre` for the first and kept `input.pre` meaning
3929
+ * the second, so every id below is single-valued.
3930
+ */
3931
+ declare const CONSOLE_HOOK_MAP: Readonly<Record<string, HookName | null>>;
3932
+ /** What this build implements. Safe to call at any time; allocates a fresh copy. */
3933
+ declare function pluginCapabilities(): SdkCapabilities;
3934
+ /** Convenience for a host that only wants to know whether it can enforce. */
3935
+ declare function isHookImplemented(hook: HookName): boolean;
3936
+
3937
+ /**
3938
+ * Guardrail transport + the plugin that drives it.
3939
+ *
3940
+ * Layered the way tracing sinks are layered — a transport seam, a generic HTTP
3941
+ * implementation, an in-process escape hatch, and thin first-party presets on
3942
+ * top (see `cognipeerGuardrail`, `portkeyGuardrail`). What is deliberately NOT
3943
+ * copied from tracing is its retry policy: a trace post can afford four
3944
+ * attempts at an 8s timeout because nothing waits on it, while a guardrail sits
3945
+ * on the critical path of every turn and the same policy would stall an agent
3946
+ * for half a minute.
3947
+ */
3948
+
3949
+ /**
3950
+ * `tool` is the ARGUMENTS a model wants to run; `tool_result` is what came
3951
+ * back. They are different surfaces with different risks — one is an action
3952
+ * about to happen, the other is untrusted content entering the context — and a
3953
+ * policy usually wants different rules for each.
3954
+ */
3955
+ type GuardrailPhaseName = "input" | "output" | "tool" | "tool_result";
3956
+ type GuardrailRequest = {
3957
+ phase: GuardrailPhaseName;
3958
+ content: string;
3959
+ /** Tool name for `tool` / `tool_result`, otherwise unset. */
3960
+ subject?: string;
3961
+ /** The SDK hook this check was raised from, so a preset can map it exactly. */
3962
+ hook?: string;
3963
+ /** Structured tool arguments, for a service that wants them un-stringified. */
3964
+ toolArgs?: unknown;
3965
+ /** The tool's return value, for `tool_result`. */
3966
+ toolResult?: unknown;
3877
3967
  /**
3878
- * Models that go to the Responses API, named explicitly. Opt-in; unset by
3879
- * default, and nothing here is inferred from a model name.
3880
- *
3881
- * A string matches the request's model (or `defaultModel`) exactly; a RegExp
3882
- * is tested against it. A match routes the request to Responses whether or
3883
- * not it carries `reasoning` — the case this exists for is a model that
3884
- * reasons by default and rejects function tools on Chat Completions, where
3885
- * sending no reasoning field does not help. `responsesApi: "never"` still
3886
- * wins; under `"always"` the routing is unchanged.
3887
- *
3888
- * Requests for a matched model also get, on the Responses body only:
3889
- * - Chat Completions spellings arriving through `extra`, which /responses
3890
- * rejects with a 400, re-spelled with their values unchanged:
3891
- * `reasoning_effort` → `reasoning.effort` (a request `reasoning` effort
3892
- * still wins), `max_tokens` / `max_completion_tokens` →
3893
- * `max_output_tokens`, `response_format` → `text.format`, and
3894
- * `stream_options.include_usage` dropped.
3895
- * - real SSE streaming, when `responsesStreaming` is also true.
3968
+ * Non-text parts of the turn — images, audio, video, files. A text-only
3969
+ * policy sees the caption and nothing else, so a service that moderates
3970
+ * media needs these; one that does not simply ignores the field.
3896
3971
  *
3897
- * Honoured by `OpenAIProvider` itself only; `AzureProvider` and
3898
- * `OpenAICompatibleProvider` ignore it.
3972
+ * Inline payloads are DESCRIBED (kind, media type, size) rather than
3973
+ * inlined: shipping a base64 image on every check would multiply the cost of
3974
+ * the guardrail by the size of the upload. A service that needs the bytes
3975
+ * should take a URL, or the caller should override `buildRequest`.
3899
3976
  */
3900
- responsesApiModels?: Array<string | RegExp>;
3977
+ attachments?: MediaAttachment[];
3978
+ metadata?: Record<string, unknown>;
3979
+ };
3980
+ type GuardrailViolation = {
3981
+ id?: string;
3982
+ type?: string;
3983
+ severity?: string;
3984
+ detail?: string;
3985
+ };
3986
+ type GuardrailVerdict = {
3987
+ action: "allow" | "block" | "mask";
3988
+ message?: string;
3989
+ /** Required when `action === "mask"`. */
3990
+ maskedContent?: string;
3991
+ violations?: GuardrailViolation[];
3992
+ /** The untouched service response, for tracing and debugging. */
3993
+ raw?: unknown;
3994
+ };
3995
+ type GuardrailCallContext = {
3996
+ runId: string;
3997
+ agentName?: string;
3998
+ /** Correlates a guardrail decision with the trace session in the console UI. */
3999
+ traceId?: string;
4000
+ signal?: AbortSignal;
4001
+ };
4002
+ type GuardrailTransport = {
4003
+ name: string;
4004
+ /** Verdicts must come back in the same order as `requests`. */
4005
+ evaluate(requests: GuardrailRequest[], ctx: GuardrailCallContext): MaybePromise<GuardrailVerdict[]>;
3901
4006
  /**
3902
- * Stream Responses API output as it arrives (text and tool-call argument
3903
- * deltas) for models in `responsesApiModels`. Default false, which keeps the
3904
- * existing behaviour: one non-streaming Responses call, emitted as a single
3905
- * chunk. Has no effect on any other request.
4007
+ * Optional setup-time handshake. When a service can say which phases carry
4008
+ * active rules, every other phase skips the network entirely — usually the
4009
+ * single biggest latency win available here.
3906
4010
  */
3907
- responsesStreaming?: boolean;
4011
+ describe?: () => MaybePromise<{
4012
+ activePhases?: GuardrailPhaseName[];
4013
+ } | null | undefined>;
4014
+ close?: () => MaybePromise<void>;
3908
4015
  };
3909
- type AnthropicProviderConfig = {
3910
- provider: "anthropic";
3911
- apiKey: string;
3912
- baseURL?: string;
3913
- defaultModel?: string;
3914
- defaultHeaders?: Record<string, string>;
3915
- anthropicVersion?: string;
3916
- retry?: ProviderRetryConfig;
4016
+ type HttpGuardrailOptions = {
4017
+ url: string;
4018
+ /** Static headers, or a thunk so a rotating token is read per call. */
4019
+ headers?: Record<string, string> | (() => Record<string, string>);
4020
+ /** Hard ceiling per attempt. Default 3000ms — this is on the critical path. */
4021
+ timeoutMs?: number;
4022
+ /** Retries after the first attempt. Default 1. */
4023
+ retries?: number;
4024
+ /** Send all pending checks in one request. Default true. */
4025
+ batch?: boolean;
4026
+ /** Override the wire request. Default: `{ items, runId, traceId }`. */
4027
+ buildRequest?: (requests: GuardrailRequest[], ctx: GuardrailCallContext) => unknown;
4028
+ /** Override response mapping. Default: `normalizeVerdicts`, which is forgiving. */
4029
+ mapVerdict?: (response: unknown, requests: GuardrailRequest[]) => GuardrailVerdict[];
3917
4030
  /**
3918
- * Prompt caching configuration. When enabled, places cache_control:
3919
- * ephemeral breakpoints on the system prompt and the final tool definition,
3920
- * which is the recommended Anthropic recipe for static system + tools.
4031
+ * Status codes that carry a VERDICT rather than an error. Some services
4032
+ * signal the outcome in the status line (e.g. 446 for a block); treating
4033
+ * those as transport failures would route a real decision through the
4034
+ * failureMode path with the wrong reason attached.
3921
4035
  */
3922
- prompt_caching?: {
3923
- enabled: boolean;
3924
- };
3925
- };
3926
- type AzureProviderConfig = {
3927
- provider: "azure";
3928
- apiKey: string;
3929
- endpoint: string;
3930
- apiVersion?: string;
3931
- deploymentName?: string;
3932
- defaultModel?: string;
3933
- defaultHeaders?: Record<string, string>;
3934
- };
3935
- type OpenAICompatibleProviderConfig = {
3936
- provider: "openai-compatible";
3937
- apiKey: string;
3938
- baseURL: string;
3939
- defaultModel?: string;
3940
- defaultHeaders?: Record<string, string>;
4036
+ verdictStatuses?: number[];
4037
+ /** Optional GET endpoint for the setup-time handshake. */
4038
+ describeUrl?: string;
4039
+ name?: string;
3941
4040
  };
3942
- type BedrockProviderConfig = {
3943
- provider: "bedrock";
3944
- region: string;
3945
- accessKeyId?: string;
3946
- secretAccessKey?: string;
3947
- sessionToken?: string;
3948
- defaultModel?: string;
3949
- defaultHeaders?: Record<string, string>;
3950
- retry?: ProviderRetryConfig;
4041
+ /**
4042
+ * Accepts the shapes a guardrail service is likely to return and normalizes
4043
+ * them. Being forgiving here is the point: the exact contract can change on the
4044
+ * service side without a client release, and a stricter parser would turn a
4045
+ * cosmetic field rename into an outage.
4046
+ */
4047
+ declare function normalizeVerdicts(response: unknown, requests: GuardrailRequest[]): GuardrailVerdict[];
4048
+ declare function httpGuardrail(options: HttpGuardrailOptions): GuardrailTransport;
4049
+ /** In-process evaluation — regex policies, a local model, Presidio, tests. */
4050
+ declare function customGuardrail(evaluate: (request: GuardrailRequest, ctx: GuardrailCallContext) => MaybePromise<GuardrailVerdict | void>, name?: string): GuardrailTransport;
4051
+ type GuardrailPluginOptions = {
4052
+ name: string;
4053
+ transport: GuardrailTransport;
4054
+ /** Which surfaces to check. Default: input + output. */
4055
+ apply?: GuardrailPhaseName[];
3951
4056
  /**
3952
- * Insert Bedrock Converse `cachePoint` blocks at the end of the system
3953
- * prompt and tools list. Only supported by models that implement Converse
3954
- * prompt caching (most Anthropic Claude variants on Bedrock).
4057
+ * `shadow` evaluates and reports but never blocks or masks. This is how a
4058
+ * policy gets rolled out safely: measure what it would have caught first.
3955
4059
  */
3956
- prompt_caching?: {
3957
- enabled: boolean;
4060
+ mode?: "enforce" | "shadow";
4061
+ /** Block when the service is unreachable. Default true. */
4062
+ failClosed?: boolean;
4063
+ timeoutMs?: number;
4064
+ priority?: number;
4065
+ inheritToSubagents?: boolean;
4066
+ /** Memoize verdicts per run. Default true. */
4067
+ cache?: boolean | {
4068
+ maxEntries?: number;
3958
4069
  };
4070
+ /** Extra metadata attached to every request. */
4071
+ metadata?: Record<string, unknown>;
3959
4072
  };
3960
- type VertexProviderConfig = {
3961
- provider: "vertex";
3962
- projectId: string;
3963
- location?: string;
3964
- accessToken?: string;
3965
- serviceAccountJson?: string | Record<string, any>;
3966
- defaultModel?: string;
3967
- defaultHeaders?: Record<string, string>;
4073
+ declare function createGuardrailPlugin(options: GuardrailPluginOptions): AgentPlugin;
4074
+
4075
+ /**
4076
+ * Cognipeer Console guardrail — the first-party preset.
4077
+ *
4078
+ * Talks to the Console's HOOK plane, not its single-shot evaluator:
4079
+ *
4080
+ * POST {baseUrl}/api/client/v1/guardrails/hooks/evaluate
4081
+ * Authorization: Bearer <api key>
4082
+ * { hook, guardrail_keys, text?, tool_name?, tool_args?, tool_result?, … }
4083
+ *
4084
+ * Three properties of that contract shape everything below, and getting any of
4085
+ * them wrong turns a working policy into a silent one:
4086
+ *
4087
+ * `decision` is the EFFECTIVE verdict, already neutralised in monitor mode.
4088
+ * Priority runs block > redact > warn > flag > allow.
4089
+ * `enforced` false means the decision was NOT applied — a dry run. Blocking
4090
+ * on `decision === "block"` without checking this turns every
4091
+ * monitoring policy into an enforcing one on the day it is
4092
+ * switched on for observation.
4093
+ * `passed` means "no blocking finding", NOT "the request was allowed".
4094
+ * The two diverge in monitor mode, which is exactly when someone
4095
+ * reads the wrong one.
4096
+ *
4097
+ * `subject` (or `redacted_text` for the text case) is filled only when the
4098
+ * service actually rewrote something; when it is present it REPLACES what was
4099
+ * sent rather than being merged with it.
4100
+ *
4101
+ * The endpoint answers 200 for a finding as readily as for a clean check, and
4102
+ * only emits 246/446 when a guardrail opts into verdict status codes — so both
4103
+ * are declared as verdict-carrying rather than treated as transport failures.
4104
+ * An unknown key answers 404 ON PURPOSE: a vacuous allow read as "content is
4105
+ * safe" is the failure the whole plane exists to avoid.
4106
+ */
4107
+
4108
+ type CognipeerGuardrailConfig = {
4109
+ /** Guardrail keys from the Console. Defaults to `COGNIPEER_GUARDRAIL_KEYS` (comma-separated). */
4110
+ guardrailKeys?: string[];
4111
+ /** Convenience for the single-key case. */
4112
+ guardrailKey?: string;
4113
+ /** Defaults to `COGNIPEER_API_KEY`. */
4114
+ apiKey?: string;
4115
+ /** Defaults to `COGNIPEER_BASE_URL`, then the production console. Point at localhost for local runs. */
4116
+ baseUrl?: string;
4117
+ /** Override the hook-evaluate path. */
4118
+ path?: string;
4119
+ /** Surfaces to guard. Default: input + output. Add `"tool"` / `"tool_result"` for the tool surface. */
4120
+ apply?: GuardrailPhaseName[];
4121
+ /** Restrict to specific check families, e.g. `["pii"]`. */
4122
+ only?: string[];
4123
+ /** Override the SDK-hook → Console-hook-id mapping, merged over the default. */
4124
+ hookIds?: Record<string, string>;
4125
+ /** Ask the service to evaluate without enforcing. Independent of `mode`. */
4126
+ shadow?: boolean;
4127
+ /** `shadow` here reports locally without acting, whatever the service says. */
4128
+ mode?: "enforce" | "shadow";
4129
+ /** Default true — an unreachable or misconfigured policy blocks rather than silently stops guarding. */
4130
+ failClosed?: boolean;
4131
+ /** Per-check ceiling. Default 3000ms; also sent as `budget_ms`. */
4132
+ timeoutMs?: number;
4133
+ retries?: number;
4134
+ priority?: number;
4135
+ cache?: boolean | {
4136
+ maxEntries?: number;
4137
+ };
4138
+ metadata?: Record<string, unknown>;
4139
+ buildRequest?: (requests: GuardrailRequest[], ctx: GuardrailCallContext) => unknown;
4140
+ mapVerdict?: (response: unknown, requests: GuardrailRequest[]) => GuardrailVerdict[];
4141
+ name?: string;
3968
4142
  };
3969
- type ProviderConfig = OpenAIProviderConfig | AnthropicProviderConfig | AzureProviderConfig | OpenAICompatibleProviderConfig | BedrockProviderConfig | VertexProviderConfig;
3970
- type ProviderType = ProviderConfig["provider"];
3971
- declare class ProviderError extends Error {
3972
- readonly provider: string;
3973
- readonly statusCode?: number | undefined;
3974
- readonly responseBody?: any | undefined;
3975
- constructor(message: string, provider: string, statusCode?: number | undefined, responseBody?: any | undefined);
3976
- }
4143
+ /** The Console's hook response, mapped onto the transport's three-valued verdict. */
4144
+ declare function mapConsoleHookVerdict(response: unknown, requests: GuardrailRequest[]): GuardrailVerdict[];
4145
+ declare function cognipeerGuardrail(config?: CognipeerGuardrailConfig): AgentPlugin;
3977
4146
 
3978
4147
  /**
3979
4148
  * Portkey — two integration shapes, because Portkey supports two.
@@ -5505,34 +5674,6 @@ declare function buildResponseFormatSection(responseFormat: Record<string, any>
5505
5674
  */
5506
5675
  declare function startStreamingSession(session: TraceSessionRuntime | undefined, agentRuntime?: AgentRuntimeConfig): Promise<void>;
5507
5676
 
5508
- type ProviderRetryPolicy = {
5509
- /** Maximum number of retries on 429/5xx responses. Default: 3. */
5510
- maxRetries?: number;
5511
- /** Initial backoff in ms (doubled on each retry). Default: 500. */
5512
- baseDelayMs?: number;
5513
- /** Hard cap on individual delay between retries. Default: 8000. */
5514
- maxDelayMs?: number;
5515
- /**
5516
- * Custom predicate to decide whether to retry. By default we retry 429
5517
- * and 5xx responses; pass a function to broaden/narrow that set.
5518
- */
5519
- shouldRetry?: (error: any, attempt: number) => boolean;
5520
- };
5521
- declare abstract class BaseProvider {
5522
- abstract readonly providerName: ProviderType;
5523
- protected retryPolicy: ProviderRetryPolicy;
5524
- /** Non-streaming completion */
5525
- abstract complete(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
5526
- /** Streaming completion – yields incremental chunks */
5527
- abstract completeStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
5528
- /**
5529
- * Helper concrete providers can wrap their fetch with. Retries 429/5xx
5530
- * with exponential backoff and respects Retry-After if the response
5531
- * carries one.
5532
- */
5533
- protected doFetchWithRetry(execute: () => Promise<Response>): Promise<Response>;
5534
- }
5535
-
5536
5677
  declare class OpenAIProvider extends BaseProvider {
5537
5678
  readonly providerName: ProviderType;
5538
5679
  protected readonly apiKey: string;
@@ -5573,11 +5714,11 @@ declare class OpenAIProvider extends BaseProvider {
5573
5714
  protected buildResponsesBody(request: ChatCompletionRequest): Record<string, any>;
5574
5715
  /** Maps a unified message to a Responses API `input` item. */
5575
5716
  protected toResponsesInput(m: UnifiedMessage): Record<string, any>;
5576
- protected responsesFetch(body: Record<string, any>): Promise<Response>;
5717
+ protected responsesFetch(body: Record<string, any>, signal?: AbortSignal): Promise<Response>;
5577
5718
  protected parseResponsesResponse(json: any, modelId: string): ChatCompletionResponse;
5578
5719
  protected toOpenAIMessage(m: UnifiedMessage): Record<string, any>;
5579
5720
  protected toOpenAITool(t: ToolDefinition): Record<string, any>;
5580
- protected doFetch(body: Record<string, any>): Promise<Response>;
5721
+ protected doFetch(body: Record<string, any>, signal?: AbortSignal): Promise<Response>;
5581
5722
  protected parseResponse(json: any): ChatCompletionResponse;
5582
5723
  protected extractUsage(usage: any): TokenUsage;
5583
5724
  }
@@ -5620,11 +5761,11 @@ declare class AzureProvider extends OpenAIProvider {
5620
5761
  private readonly deploymentName?;
5621
5762
  private readonly azureApiKey;
5622
5763
  constructor(config: AzureProviderConfig);
5623
- protected doFetch(body: Record<string, any>): Promise<Response>;
5764
+ protected doFetch(body: Record<string, any>, signal?: AbortSignal): Promise<Response>;
5624
5765
  /** Azure exposes the Responses API at /openai/responses with api-key auth.
5625
5766
  * Reasoning summaries require a preview api-version; callers can override via
5626
5767
  * the `apiVersion` config. */
5627
- protected responsesFetch(body: Record<string, any>): Promise<Response>;
5768
+ protected responsesFetch(body: Record<string, any>, signal?: AbortSignal): Promise<Response>;
5628
5769
  }
5629
5770
 
5630
5771
  declare class OpenAICompatibleProvider extends OpenAIProvider {
@@ -5736,4 +5877,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
5736
5877
  */
5737
5878
  declare function createProvider(config: ProviderConfig): BaseProvider;
5738
5879
 
5739
- 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 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 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 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, type MediaPolicyConfig, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, 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 ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, 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 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, 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, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, loadSkillsFromDisk, mapConsoleHookVerdict, mapTextParts, mcp, 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, textFromContent, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
5880
+ 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 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 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 ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, 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, textFromContent, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };