@cognipeer/agent-sdk 0.6.0 → 0.6.2

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
@@ -254,6 +254,48 @@ type AgentOptions = {
254
254
  usageConverter?: (finalMessage: AIMessage, fullState: SmartState, model: any) => any;
255
255
  outputSchema?: ZodSchema<any>;
256
256
  tracing?: TracingConfig;
257
+ /**
258
+ * Unified reasoning configuration. Controls both:
259
+ * - Provider-native reasoning (OpenAI reasoning_effort, Anthropic thinking, Gemini thinkingConfig)
260
+ * - Post-turn reflection (a short textual insight from the model after each tool turn)
261
+ *
262
+ * When omitted or `enabled=false` the agent behaves exactly as before.
263
+ */
264
+ reasoning?: ReasoningConfig;
265
+ };
266
+ type ReasoningLevel = "low" | "medium" | "high";
267
+ type ReflectionCadence = "off" | "every_turn" | "after_tool" | "on_branch";
268
+ type ReflectionConfig = {
269
+ enabled?: boolean;
270
+ cadence?: ReflectionCadence;
271
+ /**
272
+ * - "piggyback" (default) — appends a short user-style "reflect now" message to the existing
273
+ * transcript, reusing provider prompt cache. No tools. Returned text becomes a reflection record.
274
+ * - "separate" — dedicated tool-free call with a compact prompt (cheaper, smaller cache hit).
275
+ */
276
+ mode?: "piggyback" | "separate";
277
+ maxTokens?: number;
278
+ maxChars?: number;
279
+ keepLast?: number;
280
+ /** When true reflection messages are compressible by the summarizer. Default false. */
281
+ summarize?: boolean;
282
+ promptTemplate?: string;
283
+ /** When true emits `reflection` SmartAgent events. Default true. */
284
+ emitEvents?: boolean;
285
+ };
286
+ type NativeReasoningConfig = {
287
+ effort?: "minimal" | "low" | "medium" | "high";
288
+ budgetTokens?: number;
289
+ includeThoughts?: boolean;
290
+ providerExtras?: Record<string, any>;
291
+ };
292
+ type ReasoningConfig = {
293
+ enabled?: boolean;
294
+ level?: ReasoningLevel;
295
+ /** Pass `false` to disable provider-native reasoning while keeping reflection. */
296
+ native?: NativeReasoningConfig | false;
297
+ /** Pass `false` to fully disable reflection. */
298
+ reflection?: ReflectionConfig | false;
257
299
  };
258
300
  type BuiltInRuntimeProfile = "fast" | "balanced" | "deep" | "research";
259
301
  type RuntimeProfile = BuiltInRuntimeProfile | "custom";
@@ -341,8 +383,6 @@ type SmartAgentContextConfig = {
341
383
  policy?: ContextPolicy;
342
384
  lastTurnsToKeep?: number;
343
385
  toolResponsePolicy?: ToolResponseRetentionPolicy;
344
- archiveLargeToolResponses?: boolean;
345
- retrieveArchivedToolResponseOnDemand?: boolean;
346
386
  budget?: SmartAgentBudgetConfig;
347
387
  };
348
388
  type SmartAgentPlanningConfig = {
@@ -388,8 +428,8 @@ type SmartAgentToolResponseConfig = {
388
428
  toolResponseRetentionByTool?: Record<string, ToolResponseRetentionPolicy>;
389
429
  /** Tool names whose responses are never reduced by the summarizer or hard cap. */
390
430
  criticalTools?: string[];
431
+ /** Controls whether Zod-backed tool schemas fail fast or warn on invalid args. */
391
432
  schemaValidation?: "strict" | "warn";
392
- retryOnSchemaError?: boolean;
393
433
  };
394
434
  type SmartAgentCustomProfileConfig = {
395
435
  extends?: BuiltInRuntimeProfile;
@@ -441,6 +481,10 @@ type SmartAgentOptions = {
441
481
  usageConverter?: (finalMessage: AIMessage, fullState: SmartState, model: any) => any;
442
482
  outputSchema?: ZodSchema<any>;
443
483
  tracing?: TracingConfig;
484
+ /**
485
+ * Unified reasoning configuration. Same shape as on `AgentOptions`. See `ReasoningConfig`.
486
+ */
487
+ reasoning?: ReasoningConfig;
444
488
  };
445
489
  type AgentRuntimeConfig = {
446
490
  name?: string;
@@ -739,6 +783,34 @@ type SmartState = AgentState & {
739
783
  adherenceScore?: number;
740
784
  } | null;
741
785
  planVersion?: number;
786
+ /**
787
+ * Post-turn reflection records produced by the reflection node. The SDK keeps the full
788
+ * history here (even when only `keepLast` are re-injected into the prompt) so callers
789
+ * can render them in a task/run timeline.
790
+ */
791
+ reflections?: ReflectionRecord[];
792
+ };
793
+ type ReflectionRecord = {
794
+ id: string;
795
+ turn: number;
796
+ /** Plain-text reflection produced by the model. */
797
+ text: string;
798
+ createdAt: string;
799
+ durationMs?: number;
800
+ /** Index of the last message present when this reflection was taken. */
801
+ anchorMessageIndex?: number;
802
+ /** Trigger cadence that fired this reflection. */
803
+ trigger?: ReflectionCadence;
804
+ /** Token usage for this specific reflection call. */
805
+ usage?: {
806
+ inputTokens?: number;
807
+ outputTokens?: number;
808
+ cachedInputTokens?: number;
809
+ totalTokens?: number;
810
+ reasoningTokens?: number;
811
+ };
812
+ /** Optional tool call ids / names the reflection commented on (for UI linking). */
813
+ toolCallIds?: string[];
742
814
  };
743
815
  type ToolCallEvent = {
744
816
  type: "tool_call";
@@ -918,7 +990,23 @@ type GuardrailEvent = {
918
990
  reason?: string;
919
991
  details?: Record<string, any>;
920
992
  };
921
- type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
993
+ type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent | ReflectionEvent;
994
+ type ReflectionEvent = {
995
+ type: "reflection";
996
+ id: string;
997
+ turn: number;
998
+ text: string;
999
+ trigger?: ReflectionCadence;
1000
+ durationMs?: number;
1001
+ usage?: {
1002
+ inputTokens?: number;
1003
+ outputTokens?: number;
1004
+ cachedInputTokens?: number;
1005
+ totalTokens?: number;
1006
+ reasoningTokens?: number;
1007
+ };
1008
+ toolCallIds?: string[];
1009
+ };
922
1010
  type CancellationTokenLike = {
923
1011
  readonly isCancellationRequested: boolean;
924
1012
  onCancellationRequested?: (listener: () => void) => {
@@ -1471,6 +1559,28 @@ type ChatCompletionRequest = {
1471
1559
  };
1472
1560
  stream?: boolean;
1473
1561
  extra?: Record<string, any>;
1562
+ /**
1563
+ * Unified native-reasoning request config. Each provider maps this to its
1564
+ * own shape:
1565
+ * - OpenAI o-series: body.reasoning_effort = effort
1566
+ * - OpenAI Responses: body.reasoning = { effort }
1567
+ * - Anthropic: body.thinking = { type: "enabled", budget_tokens }
1568
+ * - Google / Vertex: body.generationConfig.thinkingConfig = { thinkingBudget, includeThoughts }
1569
+ *
1570
+ * Providers silently ignore unsupported fields.
1571
+ */
1572
+ reasoning?: ReasoningRequestConfig;
1573
+ };
1574
+ type ReasoningEffort = "minimal" | "low" | "medium" | "high";
1575
+ type ReasoningRequestConfig = {
1576
+ /** Qualitative effort hint (mapped per-provider). */
1577
+ effort?: ReasoningEffort;
1578
+ /** Explicit per-call token budget for reasoning/thinking. */
1579
+ budgetTokens?: number;
1580
+ /** Whether the provider should expose its reasoning/thought summary to the caller. Default false. */
1581
+ includeThoughts?: boolean;
1582
+ /** Provider-specific passthrough merged on top of the mapped shape. */
1583
+ providerExtras?: Record<string, any>;
1474
1584
  };
1475
1585
  type TokenUsage = {
1476
1586
  inputTokens: number;
@@ -1669,6 +1779,8 @@ type NativeModelOptions = {
1669
1779
  maxTokens?: number;
1670
1780
  /** Provider-specific extras passed on every request */
1671
1781
  extra?: Record<string, any>;
1782
+ /** Unified native reasoning config applied by default (per-call overrides supported). */
1783
+ reasoning?: ReasoningRequestConfig;
1672
1784
  };
1673
1785
  /**
1674
1786
  * Creates a BaseChatModel from a native provider.
@@ -1706,4 +1818,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
1706
1818
  */
1707
1819
  declare function createProvider(config: ProviderConfig): BaseProvider;
1708
1820
 
1709
- export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuiltInRuntimeProfile, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ContextPolicy, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, type SerializableSmartState, 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 StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, 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 TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, VertexProvider, type VertexProviderConfig, agentVerdictRule, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createProvider, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, emptyUsage, evaluateGuardrails, fileSink, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, httpSink, isSmartModel, jsonSchemaRule, normalizeSmartAgentOptions, otlpSink, readMemoryFacts, regexRule, resolveMemoryStore, resolveStrategy, resolveToolApprovalState, restoreSnapshot, runSmartAgentEvalHarness, startStreamingSession, traceSessionToOtlp, withTools, writeSummaryFactsToMemory };
1821
+ export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuiltInRuntimeProfile, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ContextPolicy, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, 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, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, type SerializableSmartState, 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 StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, 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 TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, VertexProvider, type VertexProviderConfig, agentVerdictRule, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createProvider, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, emptyUsage, evaluateGuardrails, fileSink, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, httpSink, isSmartModel, jsonSchemaRule, normalizeSmartAgentOptions, otlpSink, readMemoryFacts, regexRule, resolveMemoryStore, resolveStrategy, resolveToolApprovalState, restoreSnapshot, runSmartAgentEvalHarness, startStreamingSession, traceSessionToOtlp, withTools, writeSummaryFactsToMemory };
package/dist/index.d.ts CHANGED
@@ -254,6 +254,48 @@ type AgentOptions = {
254
254
  usageConverter?: (finalMessage: AIMessage, fullState: SmartState, model: any) => any;
255
255
  outputSchema?: ZodSchema<any>;
256
256
  tracing?: TracingConfig;
257
+ /**
258
+ * Unified reasoning configuration. Controls both:
259
+ * - Provider-native reasoning (OpenAI reasoning_effort, Anthropic thinking, Gemini thinkingConfig)
260
+ * - Post-turn reflection (a short textual insight from the model after each tool turn)
261
+ *
262
+ * When omitted or `enabled=false` the agent behaves exactly as before.
263
+ */
264
+ reasoning?: ReasoningConfig;
265
+ };
266
+ type ReasoningLevel = "low" | "medium" | "high";
267
+ type ReflectionCadence = "off" | "every_turn" | "after_tool" | "on_branch";
268
+ type ReflectionConfig = {
269
+ enabled?: boolean;
270
+ cadence?: ReflectionCadence;
271
+ /**
272
+ * - "piggyback" (default) — appends a short user-style "reflect now" message to the existing
273
+ * transcript, reusing provider prompt cache. No tools. Returned text becomes a reflection record.
274
+ * - "separate" — dedicated tool-free call with a compact prompt (cheaper, smaller cache hit).
275
+ */
276
+ mode?: "piggyback" | "separate";
277
+ maxTokens?: number;
278
+ maxChars?: number;
279
+ keepLast?: number;
280
+ /** When true reflection messages are compressible by the summarizer. Default false. */
281
+ summarize?: boolean;
282
+ promptTemplate?: string;
283
+ /** When true emits `reflection` SmartAgent events. Default true. */
284
+ emitEvents?: boolean;
285
+ };
286
+ type NativeReasoningConfig = {
287
+ effort?: "minimal" | "low" | "medium" | "high";
288
+ budgetTokens?: number;
289
+ includeThoughts?: boolean;
290
+ providerExtras?: Record<string, any>;
291
+ };
292
+ type ReasoningConfig = {
293
+ enabled?: boolean;
294
+ level?: ReasoningLevel;
295
+ /** Pass `false` to disable provider-native reasoning while keeping reflection. */
296
+ native?: NativeReasoningConfig | false;
297
+ /** Pass `false` to fully disable reflection. */
298
+ reflection?: ReflectionConfig | false;
257
299
  };
258
300
  type BuiltInRuntimeProfile = "fast" | "balanced" | "deep" | "research";
259
301
  type RuntimeProfile = BuiltInRuntimeProfile | "custom";
@@ -341,8 +383,6 @@ type SmartAgentContextConfig = {
341
383
  policy?: ContextPolicy;
342
384
  lastTurnsToKeep?: number;
343
385
  toolResponsePolicy?: ToolResponseRetentionPolicy;
344
- archiveLargeToolResponses?: boolean;
345
- retrieveArchivedToolResponseOnDemand?: boolean;
346
386
  budget?: SmartAgentBudgetConfig;
347
387
  };
348
388
  type SmartAgentPlanningConfig = {
@@ -388,8 +428,8 @@ type SmartAgentToolResponseConfig = {
388
428
  toolResponseRetentionByTool?: Record<string, ToolResponseRetentionPolicy>;
389
429
  /** Tool names whose responses are never reduced by the summarizer or hard cap. */
390
430
  criticalTools?: string[];
431
+ /** Controls whether Zod-backed tool schemas fail fast or warn on invalid args. */
391
432
  schemaValidation?: "strict" | "warn";
392
- retryOnSchemaError?: boolean;
393
433
  };
394
434
  type SmartAgentCustomProfileConfig = {
395
435
  extends?: BuiltInRuntimeProfile;
@@ -441,6 +481,10 @@ type SmartAgentOptions = {
441
481
  usageConverter?: (finalMessage: AIMessage, fullState: SmartState, model: any) => any;
442
482
  outputSchema?: ZodSchema<any>;
443
483
  tracing?: TracingConfig;
484
+ /**
485
+ * Unified reasoning configuration. Same shape as on `AgentOptions`. See `ReasoningConfig`.
486
+ */
487
+ reasoning?: ReasoningConfig;
444
488
  };
445
489
  type AgentRuntimeConfig = {
446
490
  name?: string;
@@ -739,6 +783,34 @@ type SmartState = AgentState & {
739
783
  adherenceScore?: number;
740
784
  } | null;
741
785
  planVersion?: number;
786
+ /**
787
+ * Post-turn reflection records produced by the reflection node. The SDK keeps the full
788
+ * history here (even when only `keepLast` are re-injected into the prompt) so callers
789
+ * can render them in a task/run timeline.
790
+ */
791
+ reflections?: ReflectionRecord[];
792
+ };
793
+ type ReflectionRecord = {
794
+ id: string;
795
+ turn: number;
796
+ /** Plain-text reflection produced by the model. */
797
+ text: string;
798
+ createdAt: string;
799
+ durationMs?: number;
800
+ /** Index of the last message present when this reflection was taken. */
801
+ anchorMessageIndex?: number;
802
+ /** Trigger cadence that fired this reflection. */
803
+ trigger?: ReflectionCadence;
804
+ /** Token usage for this specific reflection call. */
805
+ usage?: {
806
+ inputTokens?: number;
807
+ outputTokens?: number;
808
+ cachedInputTokens?: number;
809
+ totalTokens?: number;
810
+ reasoningTokens?: number;
811
+ };
812
+ /** Optional tool call ids / names the reflection commented on (for UI linking). */
813
+ toolCallIds?: string[];
742
814
  };
743
815
  type ToolCallEvent = {
744
816
  type: "tool_call";
@@ -918,7 +990,23 @@ type GuardrailEvent = {
918
990
  reason?: string;
919
991
  details?: Record<string, any>;
920
992
  };
921
- type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent;
993
+ type SmartAgentEvent = ToolCallEvent | ToolApprovalEvent | PlanEvent | SummarizationEvent | FinalAnswerEvent | MetadataEvent | HandoffEvent | GuardrailEvent | ProgressEvent | StreamEvent | CancelledEvent | ReflectionEvent;
994
+ type ReflectionEvent = {
995
+ type: "reflection";
996
+ id: string;
997
+ turn: number;
998
+ text: string;
999
+ trigger?: ReflectionCadence;
1000
+ durationMs?: number;
1001
+ usage?: {
1002
+ inputTokens?: number;
1003
+ outputTokens?: number;
1004
+ cachedInputTokens?: number;
1005
+ totalTokens?: number;
1006
+ reasoningTokens?: number;
1007
+ };
1008
+ toolCallIds?: string[];
1009
+ };
922
1010
  type CancellationTokenLike = {
923
1011
  readonly isCancellationRequested: boolean;
924
1012
  onCancellationRequested?: (listener: () => void) => {
@@ -1471,6 +1559,28 @@ type ChatCompletionRequest = {
1471
1559
  };
1472
1560
  stream?: boolean;
1473
1561
  extra?: Record<string, any>;
1562
+ /**
1563
+ * Unified native-reasoning request config. Each provider maps this to its
1564
+ * own shape:
1565
+ * - OpenAI o-series: body.reasoning_effort = effort
1566
+ * - OpenAI Responses: body.reasoning = { effort }
1567
+ * - Anthropic: body.thinking = { type: "enabled", budget_tokens }
1568
+ * - Google / Vertex: body.generationConfig.thinkingConfig = { thinkingBudget, includeThoughts }
1569
+ *
1570
+ * Providers silently ignore unsupported fields.
1571
+ */
1572
+ reasoning?: ReasoningRequestConfig;
1573
+ };
1574
+ type ReasoningEffort = "minimal" | "low" | "medium" | "high";
1575
+ type ReasoningRequestConfig = {
1576
+ /** Qualitative effort hint (mapped per-provider). */
1577
+ effort?: ReasoningEffort;
1578
+ /** Explicit per-call token budget for reasoning/thinking. */
1579
+ budgetTokens?: number;
1580
+ /** Whether the provider should expose its reasoning/thought summary to the caller. Default false. */
1581
+ includeThoughts?: boolean;
1582
+ /** Provider-specific passthrough merged on top of the mapped shape. */
1583
+ providerExtras?: Record<string, any>;
1474
1584
  };
1475
1585
  type TokenUsage = {
1476
1586
  inputTokens: number;
@@ -1669,6 +1779,8 @@ type NativeModelOptions = {
1669
1779
  maxTokens?: number;
1670
1780
  /** Provider-specific extras passed on every request */
1671
1781
  extra?: Record<string, any>;
1782
+ /** Unified native reasoning config applied by default (per-call overrides supported). */
1783
+ reasoning?: ReasoningRequestConfig;
1672
1784
  };
1673
1785
  /**
1674
1786
  * Creates a BaseChatModel from a native provider.
@@ -1706,4 +1818,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
1706
1818
  */
1707
1819
  declare function createProvider(config: ProviderConfig): BaseProvider;
1708
1820
 
1709
- export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuiltInRuntimeProfile, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ContextPolicy, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, type SerializableSmartState, 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 StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, 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 TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, VertexProvider, type VertexProviderConfig, agentVerdictRule, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createProvider, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, emptyUsage, evaluateGuardrails, fileSink, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, httpSink, isSmartModel, jsonSchemaRule, normalizeSmartAgentOptions, otlpSink, readMemoryFacts, regexRule, resolveMemoryStore, resolveStrategy, resolveToolApprovalState, restoreSnapshot, runSmartAgentEvalHarness, startStreamingSession, traceSessionToOtlp, withTools, writeSummaryFactsToMemory };
1821
+ export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuiltInRuntimeProfile, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ContextPolicy, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, 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, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, type SerializableSmartState, 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 StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, 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 TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, VertexProvider, type VertexProviderConfig, agentVerdictRule, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createProvider, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, emptyUsage, evaluateGuardrails, fileSink, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, httpSink, isSmartModel, jsonSchemaRule, normalizeSmartAgentOptions, otlpSink, readMemoryFacts, regexRule, resolveMemoryStore, resolveStrategy, resolveToolApprovalState, restoreSnapshot, runSmartAgentEvalHarness, startStreamingSession, traceSessionToOtlp, withTools, writeSummaryFactsToMemory };