@cognipeer/agent-sdk 0.9.2 → 0.9.3
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.cjs +80 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.mjs +80 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1217,7 +1217,35 @@ type TraceToolDefinitionsSection = {
|
|
|
1217
1217
|
/** Set when the tool list itself was truncated to fit the size budget. */
|
|
1218
1218
|
truncated?: boolean;
|
|
1219
1219
|
};
|
|
1220
|
-
|
|
1220
|
+
/**
|
|
1221
|
+
* The structured-output contract bound to one model call — the other half of
|
|
1222
|
+
* the request that decides the SHAPE of the answer (the tool menu being the
|
|
1223
|
+
* first half). Without it a trace cannot distinguish "the model chose to write
|
|
1224
|
+
* prose" from "nothing ever asked it for JSON", and any replay of the call
|
|
1225
|
+
* (evaluation, prompt optimization) silently runs under a looser contract than
|
|
1226
|
+
* production did.
|
|
1227
|
+
*
|
|
1228
|
+
* Rides on the `ai_call` event, never per session: a run can enforce a schema
|
|
1229
|
+
* on its final turn only, and each call records the contract it actually sent.
|
|
1230
|
+
*/
|
|
1231
|
+
type TraceResponseFormatSection = {
|
|
1232
|
+
id?: string;
|
|
1233
|
+
kind: "response_format";
|
|
1234
|
+
label: string;
|
|
1235
|
+
/** `json_schema` | `json_object` | `text` — the wire `response_format.type`. */
|
|
1236
|
+
type: string;
|
|
1237
|
+
/** Which strategy produced it: native `response_format` or the `response` tool. */
|
|
1238
|
+
strategy?: "native" | "tool_based";
|
|
1239
|
+
/** `json_schema.name` when the provider takes a named schema. */
|
|
1240
|
+
schemaName?: string;
|
|
1241
|
+
/** `json_schema.strict` — whether the provider enforces the schema. */
|
|
1242
|
+
strict?: boolean;
|
|
1243
|
+
/** The JSON Schema as sent. Dropped (with `truncated`) when over budget. */
|
|
1244
|
+
schema?: Record<string, any>;
|
|
1245
|
+
/** Set when `schema` was dropped to fit the section size budget. */
|
|
1246
|
+
truncated?: boolean;
|
|
1247
|
+
};
|
|
1248
|
+
type TraceDataSection = TraceMessageSection | TraceToolCallSection | TraceToolResultSection | TraceToolResponseSection | TraceSummarySection | TraceMetadataSection | TraceToolDefinitionsSection | TraceResponseFormatSection;
|
|
1221
1249
|
type TraceEventRecord = {
|
|
1222
1250
|
sessionId: string;
|
|
1223
1251
|
id: string;
|
|
@@ -1240,6 +1268,21 @@ type TraceEventRecord = {
|
|
|
1240
1268
|
outputTokens?: number;
|
|
1241
1269
|
totalTokens?: number;
|
|
1242
1270
|
cachedInputTokens?: number;
|
|
1271
|
+
/**
|
|
1272
|
+
* Reasoning tokens billed inside `outputTokens` (a SUBSET of it, matching
|
|
1273
|
+
* OpenAI's `completion_tokens_details.reasoning_tokens`). Recorded because
|
|
1274
|
+
* on a reasoning model they are routinely most of the output bill while
|
|
1275
|
+
* being invisible in the response text — a spend investigation that only
|
|
1276
|
+
* sees `outputTokens` cannot explain where the money went.
|
|
1277
|
+
*/
|
|
1278
|
+
reasoningTokens?: number;
|
|
1279
|
+
/**
|
|
1280
|
+
* Why the model stopped: `stop` | `tool_calls` | `length` | `content_filter`
|
|
1281
|
+
* | `error`. `length` is the single most common explanation for a truncated
|
|
1282
|
+
* or unparseable structured response, and without it that failure is
|
|
1283
|
+
* indistinguishable from a model that simply answered badly.
|
|
1284
|
+
*/
|
|
1285
|
+
finishReason?: string;
|
|
1243
1286
|
requestBytes?: number;
|
|
1244
1287
|
responseBytes?: number;
|
|
1245
1288
|
model?: string;
|
|
@@ -2672,7 +2715,6 @@ declare class NativeJsonSchemaStrategy implements StructuredOutputStrategy {
|
|
|
2672
2715
|
readonly kind: "native";
|
|
2673
2716
|
private resolveJsonPointer;
|
|
2674
2717
|
private unwrapRootObjectSchema;
|
|
2675
|
-
private normalizeOpenAIStrictSchema;
|
|
2676
2718
|
/**
|
|
2677
2719
|
* Convert a Zod schema to the JSON Schema object used in response_format.
|
|
2678
2720
|
*/
|
|
@@ -2947,6 +2989,16 @@ declare function buildToolDefinitionsSection(toolDefinitions: Array<{
|
|
|
2947
2989
|
description?: string;
|
|
2948
2990
|
parameters?: Record<string, any>;
|
|
2949
2991
|
}>): TraceToolDefinitionsSection | undefined;
|
|
2992
|
+
/**
|
|
2993
|
+
* Build the `response_format` section for one model call, or undefined when
|
|
2994
|
+
* nothing usable was supplied.
|
|
2995
|
+
*
|
|
2996
|
+
* Accepts either the invoke-options wrapper produced by
|
|
2997
|
+
* `NativeJsonSchemaStrategy.buildResponseFormat()` (`{ response_format: {…} }`)
|
|
2998
|
+
* or a bare `response_format` object, so callers can pass whatever they hold.
|
|
2999
|
+
* Exported for provider/node code that assembles sections itself.
|
|
3000
|
+
*/
|
|
3001
|
+
declare function buildResponseFormatSection(responseFormat: Record<string, any> | undefined, strategy?: "native" | "tool_based"): TraceResponseFormatSection | undefined;
|
|
2950
3002
|
/**
|
|
2951
3003
|
* Start a streaming trace session. Should be called before recording events in streaming mode.
|
|
2952
3004
|
* This sends the session start to the remote endpoint immediately.
|
|
@@ -3462,4 +3514,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
|
|
|
3462
3514
|
*/
|
|
3463
3515
|
declare function createProvider(config: ProviderConfig): BaseProvider;
|
|
3464
3516
|
|
|
3465
|
-
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, 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 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 GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, 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, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, 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 SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, 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 ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, 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, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, coerceToolArgs, cognipeerSink, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, preopenSkills, preopenToolCallId, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, summarizeObject, tokenize, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
3517
|
+
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, 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 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 GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, 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, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, 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 SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, 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 ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, 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, agentVerdictRule, appendBoundTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, coerceToolArgs, cognipeerSink, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, preopenSkills, preopenToolCallId, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, summarizeObject, tokenize, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, withTools, withinDepth, writeSummaryFactsToMemory };
|
package/dist/index.d.ts
CHANGED
|
@@ -1217,7 +1217,35 @@ type TraceToolDefinitionsSection = {
|
|
|
1217
1217
|
/** Set when the tool list itself was truncated to fit the size budget. */
|
|
1218
1218
|
truncated?: boolean;
|
|
1219
1219
|
};
|
|
1220
|
-
|
|
1220
|
+
/**
|
|
1221
|
+
* The structured-output contract bound to one model call — the other half of
|
|
1222
|
+
* the request that decides the SHAPE of the answer (the tool menu being the
|
|
1223
|
+
* first half). Without it a trace cannot distinguish "the model chose to write
|
|
1224
|
+
* prose" from "nothing ever asked it for JSON", and any replay of the call
|
|
1225
|
+
* (evaluation, prompt optimization) silently runs under a looser contract than
|
|
1226
|
+
* production did.
|
|
1227
|
+
*
|
|
1228
|
+
* Rides on the `ai_call` event, never per session: a run can enforce a schema
|
|
1229
|
+
* on its final turn only, and each call records the contract it actually sent.
|
|
1230
|
+
*/
|
|
1231
|
+
type TraceResponseFormatSection = {
|
|
1232
|
+
id?: string;
|
|
1233
|
+
kind: "response_format";
|
|
1234
|
+
label: string;
|
|
1235
|
+
/** `json_schema` | `json_object` | `text` — the wire `response_format.type`. */
|
|
1236
|
+
type: string;
|
|
1237
|
+
/** Which strategy produced it: native `response_format` or the `response` tool. */
|
|
1238
|
+
strategy?: "native" | "tool_based";
|
|
1239
|
+
/** `json_schema.name` when the provider takes a named schema. */
|
|
1240
|
+
schemaName?: string;
|
|
1241
|
+
/** `json_schema.strict` — whether the provider enforces the schema. */
|
|
1242
|
+
strict?: boolean;
|
|
1243
|
+
/** The JSON Schema as sent. Dropped (with `truncated`) when over budget. */
|
|
1244
|
+
schema?: Record<string, any>;
|
|
1245
|
+
/** Set when `schema` was dropped to fit the section size budget. */
|
|
1246
|
+
truncated?: boolean;
|
|
1247
|
+
};
|
|
1248
|
+
type TraceDataSection = TraceMessageSection | TraceToolCallSection | TraceToolResultSection | TraceToolResponseSection | TraceSummarySection | TraceMetadataSection | TraceToolDefinitionsSection | TraceResponseFormatSection;
|
|
1221
1249
|
type TraceEventRecord = {
|
|
1222
1250
|
sessionId: string;
|
|
1223
1251
|
id: string;
|
|
@@ -1240,6 +1268,21 @@ type TraceEventRecord = {
|
|
|
1240
1268
|
outputTokens?: number;
|
|
1241
1269
|
totalTokens?: number;
|
|
1242
1270
|
cachedInputTokens?: number;
|
|
1271
|
+
/**
|
|
1272
|
+
* Reasoning tokens billed inside `outputTokens` (a SUBSET of it, matching
|
|
1273
|
+
* OpenAI's `completion_tokens_details.reasoning_tokens`). Recorded because
|
|
1274
|
+
* on a reasoning model they are routinely most of the output bill while
|
|
1275
|
+
* being invisible in the response text — a spend investigation that only
|
|
1276
|
+
* sees `outputTokens` cannot explain where the money went.
|
|
1277
|
+
*/
|
|
1278
|
+
reasoningTokens?: number;
|
|
1279
|
+
/**
|
|
1280
|
+
* Why the model stopped: `stop` | `tool_calls` | `length` | `content_filter`
|
|
1281
|
+
* | `error`. `length` is the single most common explanation for a truncated
|
|
1282
|
+
* or unparseable structured response, and without it that failure is
|
|
1283
|
+
* indistinguishable from a model that simply answered badly.
|
|
1284
|
+
*/
|
|
1285
|
+
finishReason?: string;
|
|
1243
1286
|
requestBytes?: number;
|
|
1244
1287
|
responseBytes?: number;
|
|
1245
1288
|
model?: string;
|
|
@@ -2672,7 +2715,6 @@ declare class NativeJsonSchemaStrategy implements StructuredOutputStrategy {
|
|
|
2672
2715
|
readonly kind: "native";
|
|
2673
2716
|
private resolveJsonPointer;
|
|
2674
2717
|
private unwrapRootObjectSchema;
|
|
2675
|
-
private normalizeOpenAIStrictSchema;
|
|
2676
2718
|
/**
|
|
2677
2719
|
* Convert a Zod schema to the JSON Schema object used in response_format.
|
|
2678
2720
|
*/
|
|
@@ -2947,6 +2989,16 @@ declare function buildToolDefinitionsSection(toolDefinitions: Array<{
|
|
|
2947
2989
|
description?: string;
|
|
2948
2990
|
parameters?: Record<string, any>;
|
|
2949
2991
|
}>): TraceToolDefinitionsSection | undefined;
|
|
2992
|
+
/**
|
|
2993
|
+
* Build the `response_format` section for one model call, or undefined when
|
|
2994
|
+
* nothing usable was supplied.
|
|
2995
|
+
*
|
|
2996
|
+
* Accepts either the invoke-options wrapper produced by
|
|
2997
|
+
* `NativeJsonSchemaStrategy.buildResponseFormat()` (`{ response_format: {…} }`)
|
|
2998
|
+
* or a bare `response_format` object, so callers can pass whatever they hold.
|
|
2999
|
+
* Exported for provider/node code that assembles sections itself.
|
|
3000
|
+
*/
|
|
3001
|
+
declare function buildResponseFormatSection(responseFormat: Record<string, any> | undefined, strategy?: "native" | "tool_based"): TraceResponseFormatSection | undefined;
|
|
2950
3002
|
/**
|
|
2951
3003
|
* Start a streaming trace session. Should be called before recording events in streaming mode.
|
|
2952
3004
|
* This sends the session start to the remote endpoint immediately.
|
|
@@ -3462,4 +3514,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
|
|
|
3462
3514
|
*/
|
|
3463
3515
|
declare function createProvider(config: ProviderConfig): BaseProvider;
|
|
3464
3516
|
|
|
3465
|
-
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, 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 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 GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, 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, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, 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 SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, 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 ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, 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, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, coerceToolArgs, cognipeerSink, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, preopenSkills, preopenToolCallId, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, summarizeObject, tokenize, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
3517
|
+
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, 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 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 GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, 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, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, 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 SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, 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 ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, 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, agentVerdictRule, appendBoundTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, coerceToolArgs, cognipeerSink, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, preopenSkills, preopenToolCallId, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, summarizeObject, tokenize, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, withTools, withinDepth, writeSummaryFactsToMemory };
|
package/dist/index.mjs
CHANGED
|
@@ -284,63 +284,16 @@ var NativeJsonSchemaStrategy = class {
|
|
|
284
284
|
}
|
|
285
285
|
return resolvedSchema;
|
|
286
286
|
}
|
|
287
|
-
normalizeOpenAIStrictSchema(schema) {
|
|
288
|
-
const visit = (node) => {
|
|
289
|
-
if (!node || typeof node !== "object") return node;
|
|
290
|
-
if (Array.isArray(node)) {
|
|
291
|
-
return node.map(visit);
|
|
292
|
-
}
|
|
293
|
-
const clone2 = { ...node };
|
|
294
|
-
if (clone2.properties && typeof clone2.properties === "object") {
|
|
295
|
-
const normalizedProperties = {};
|
|
296
|
-
for (const [key, value] of Object.entries(clone2.properties)) {
|
|
297
|
-
normalizedProperties[key] = visit(value);
|
|
298
|
-
}
|
|
299
|
-
clone2.properties = normalizedProperties;
|
|
300
|
-
clone2.required = Object.keys(normalizedProperties);
|
|
301
|
-
if (clone2.additionalProperties === void 0) {
|
|
302
|
-
clone2.additionalProperties = false;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if (clone2.items) {
|
|
306
|
-
clone2.items = visit(clone2.items);
|
|
307
|
-
}
|
|
308
|
-
if (clone2.definitions && typeof clone2.definitions === "object") {
|
|
309
|
-
const normalizedDefinitions = {};
|
|
310
|
-
for (const [key, value] of Object.entries(clone2.definitions)) {
|
|
311
|
-
normalizedDefinitions[key] = visit(value);
|
|
312
|
-
}
|
|
313
|
-
clone2.definitions = normalizedDefinitions;
|
|
314
|
-
}
|
|
315
|
-
if (clone2.$defs && typeof clone2.$defs === "object") {
|
|
316
|
-
const normalizedDefs = {};
|
|
317
|
-
for (const [key, value] of Object.entries(clone2.$defs)) {
|
|
318
|
-
normalizedDefs[key] = visit(value);
|
|
319
|
-
}
|
|
320
|
-
clone2.$defs = normalizedDefs;
|
|
321
|
-
}
|
|
322
|
-
for (const compositeKey of ["anyOf", "oneOf", "allOf"]) {
|
|
323
|
-
if (Array.isArray(clone2[compositeKey])) {
|
|
324
|
-
clone2[compositeKey] = clone2[compositeKey].map(visit);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return clone2;
|
|
328
|
-
};
|
|
329
|
-
return visit(schema);
|
|
330
|
-
}
|
|
331
287
|
/**
|
|
332
288
|
* Convert a Zod schema to the JSON Schema object used in response_format.
|
|
333
289
|
*/
|
|
334
290
|
toJsonSchema(schema, name = "structured_response") {
|
|
335
291
|
const result = zodToJsonSchema(schema, {
|
|
336
292
|
name,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
$refStrategy: "extract-to-root",
|
|
340
|
-
nullableStrategy: "property"
|
|
293
|
+
target: "openAi",
|
|
294
|
+
$refStrategy: "root"
|
|
341
295
|
});
|
|
342
|
-
|
|
343
|
-
return this.unwrapRootObjectSchema(normalized);
|
|
296
|
+
return this.unwrapRootObjectSchema(result);
|
|
344
297
|
}
|
|
345
298
|
/**
|
|
346
299
|
* Build response_format configuration for the model call.
|
|
@@ -1251,6 +1204,8 @@ function eventToOtlpSpan(event) {
|
|
|
1251
1204
|
stringAttr("cognipeer.actor.name", event.actor?.name),
|
|
1252
1205
|
stringAttr("cognipeer.actor.role", event.actor?.role),
|
|
1253
1206
|
stringAttr("cognipeer.model", event.model),
|
|
1207
|
+
intAttr("cognipeer.tokens.reasoning", event.reasoningTokens),
|
|
1208
|
+
stringAttr("cognipeer.finish_reason", event.finishReason),
|
|
1254
1209
|
stringAttr("cognipeer.provider", event.provider),
|
|
1255
1210
|
stringAttr("cognipeer.tool.details", event.toolDetails ? JSON.stringify(event.toolDetails) : void 0),
|
|
1256
1211
|
intAttr("cognipeer.tokens.input", event.inputTokens),
|
|
@@ -1478,6 +1433,8 @@ function defaultSectionLabel(kind) {
|
|
|
1478
1433
|
return "Details";
|
|
1479
1434
|
case "tool_definitions":
|
|
1480
1435
|
return "Tool Definitions";
|
|
1436
|
+
case "response_format":
|
|
1437
|
+
return "Response Format";
|
|
1481
1438
|
default:
|
|
1482
1439
|
return "Section";
|
|
1483
1440
|
}
|
|
@@ -1535,6 +1492,42 @@ function buildToolDefinitionsSection(toolDefinitions) {
|
|
|
1535
1492
|
}
|
|
1536
1493
|
return section;
|
|
1537
1494
|
}
|
|
1495
|
+
var RESPONSE_FORMAT_MAX_SECTION_BYTES = 64 * 1024;
|
|
1496
|
+
var RESPONSE_FORMAT_MAX_NAME_CHARS = 200;
|
|
1497
|
+
function buildResponseFormatSection(responseFormat, strategy) {
|
|
1498
|
+
if (!responseFormat || typeof responseFormat !== "object" || Array.isArray(responseFormat)) return void 0;
|
|
1499
|
+
const raw = responseFormat.response_format ?? responseFormat.responseFormat ?? responseFormat;
|
|
1500
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
1501
|
+
const type = typeof raw.type === "string" && raw.type.trim().length > 0 ? raw.type.trim() : void 0;
|
|
1502
|
+
const jsonSchema = raw.json_schema ?? raw.jsonSchema;
|
|
1503
|
+
const schemaSource = jsonSchema && typeof jsonSchema === "object" ? jsonSchema : raw;
|
|
1504
|
+
const schema = schemaSource.schema && typeof schemaSource.schema === "object" && !Array.isArray(schemaSource.schema) ? schemaSource.schema : void 0;
|
|
1505
|
+
if (!type && !schema) return void 0;
|
|
1506
|
+
const section = {
|
|
1507
|
+
kind: "response_format",
|
|
1508
|
+
label: "Response Format",
|
|
1509
|
+
type: type ?? (schema ? "json_schema" : "unknown"),
|
|
1510
|
+
...strategy ? { strategy } : {},
|
|
1511
|
+
...typeof schemaSource.name === "string" && schemaSource.name.length > 0 ? { schemaName: schemaSource.name.slice(0, RESPONSE_FORMAT_MAX_NAME_CHARS) } : {},
|
|
1512
|
+
...typeof schemaSource.strict === "boolean" ? { strict: schemaSource.strict } : {}
|
|
1513
|
+
};
|
|
1514
|
+
if (schema) {
|
|
1515
|
+
try {
|
|
1516
|
+
section.schema = JSON.parse(JSON.stringify(schema));
|
|
1517
|
+
} catch {
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
try {
|
|
1521
|
+
if (section.schema && Buffer$1.byteLength(JSON.stringify(section), "utf8") > RESPONSE_FORMAT_MAX_SECTION_BYTES) {
|
|
1522
|
+
delete section.schema;
|
|
1523
|
+
section.truncated = true;
|
|
1524
|
+
}
|
|
1525
|
+
} catch {
|
|
1526
|
+
delete section.schema;
|
|
1527
|
+
section.truncated = true;
|
|
1528
|
+
}
|
|
1529
|
+
return section;
|
|
1530
|
+
}
|
|
1538
1531
|
function buildMessageLabel(role, index) {
|
|
1539
1532
|
const normalized = role?.trim().length ? role.trim() : "message";
|
|
1540
1533
|
const base = `${normalized.charAt(0).toUpperCase()}${normalized.slice(1)} Message`;
|
|
@@ -1730,6 +1723,7 @@ function recordTraceEvent(session, event) {
|
|
|
1730
1723
|
if (!Number.isNaN(cachedInputTokens ?? NaN) && cachedInputTokens !== void 0) {
|
|
1731
1724
|
session.summary.totalCachedInputTokens += cachedInputTokens;
|
|
1732
1725
|
}
|
|
1726
|
+
const reasoningTokens = event.reasoningTokens !== void 0 ? Number(event.reasoningTokens) : void 0;
|
|
1733
1727
|
const totalTokens = event.totalTokens !== void 0 ? Number(event.totalTokens) : void 0;
|
|
1734
1728
|
const requestBytes = event.requestBytes !== void 0 ? Number(event.requestBytes) : void 0;
|
|
1735
1729
|
if (!Number.isNaN(requestBytes ?? NaN) && requestBytes !== void 0) {
|
|
@@ -1755,6 +1749,13 @@ function recordTraceEvent(session, event) {
|
|
|
1755
1749
|
if (menuSection) sections = ensureUniqueSections(id, [...sections ?? [], menuSection]);
|
|
1756
1750
|
}
|
|
1757
1751
|
}
|
|
1752
|
+
if (event.responseFormat) {
|
|
1753
|
+
const existing = (sections ?? []).some((section) => section.kind === "response_format");
|
|
1754
|
+
if (!existing) {
|
|
1755
|
+
const formatSection = buildResponseFormatSection(event.responseFormat, event.responseFormatStrategy);
|
|
1756
|
+
if (formatSection) sections = ensureUniqueSections(id, [...sections ?? [], formatSection]);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1758
1759
|
}
|
|
1759
1760
|
const resolvedModel = event.model ?? inferModelFromMessages(event.messageList);
|
|
1760
1761
|
const resolvedProvider = event.provider ?? inferProviderFromMessages(event.messageList);
|
|
@@ -1785,6 +1786,11 @@ function recordTraceEvent(session, event) {
|
|
|
1785
1786
|
...totalTokens !== void 0 && { totalTokens },
|
|
1786
1787
|
...cachedInputTokens !== void 0 && { cachedInputTokens }
|
|
1787
1788
|
},
|
|
1789
|
+
// Absent, never zeroed for ai_call the way the four above are: a model
|
|
1790
|
+
// that does no reasoning and one whose provider reports nothing are
|
|
1791
|
+
// different facts, and a zero would erase the difference.
|
|
1792
|
+
...reasoningTokens !== void 0 && !Number.isNaN(reasoningTokens) ? { reasoningTokens } : {},
|
|
1793
|
+
...event.finishReason ? { finishReason: event.finishReason } : {},
|
|
1788
1794
|
requestBytes,
|
|
1789
1795
|
responseBytes,
|
|
1790
1796
|
model: resolvedModel,
|
|
@@ -3882,6 +3888,18 @@ function createAgentCoreNode(opts) {
|
|
|
3882
3888
|
}
|
|
3883
3889
|
}
|
|
3884
3890
|
const responseFormat = runtime.responseFormat;
|
|
3891
|
+
let traceResponseFormat = responseFormat;
|
|
3892
|
+
let traceResponseFormatStrategy = responseFormat ? "native" : void 0;
|
|
3893
|
+
if (!traceResponseFormat && runtime.outputSchema) {
|
|
3894
|
+
const responseTool = traceToolDefinitions?.find((tool) => tool.name === "response");
|
|
3895
|
+
if (responseTool?.parameters) {
|
|
3896
|
+
traceResponseFormat = {
|
|
3897
|
+
type: "json_schema",
|
|
3898
|
+
json_schema: { name: "response", strict: false, schema: responseTool.parameters }
|
|
3899
|
+
};
|
|
3900
|
+
traceResponseFormatStrategy = "tool_based";
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3885
3903
|
const reasoningForCall = state.ctx?.__reasoning;
|
|
3886
3904
|
const reasoningInvokeOpts = reasoningForCall ? { reasoning: reasoningForCall } : void 0;
|
|
3887
3905
|
const extractText2 = (chunk) => {
|
|
@@ -3941,7 +3959,9 @@ function createAgentCoreNode(opts) {
|
|
|
3941
3959
|
provider: getProviderName(runtime.model || opts.model),
|
|
3942
3960
|
error: { message: err?.message || String(err), stack: err?.stack },
|
|
3943
3961
|
messageList: state.messages,
|
|
3944
|
-
toolDefinitions: traceToolDefinitions
|
|
3962
|
+
toolDefinitions: traceToolDefinitions,
|
|
3963
|
+
responseFormat: traceResponseFormat,
|
|
3964
|
+
responseFormatStrategy: traceResponseFormatStrategy
|
|
3945
3965
|
});
|
|
3946
3966
|
throw err;
|
|
3947
3967
|
}
|
|
@@ -3956,6 +3976,7 @@ function createAgentCoreNode(opts) {
|
|
|
3956
3976
|
const shouldLogResponse = !!traceSession && traceSession.resolvedConfig.logData;
|
|
3957
3977
|
const responsePayload = shouldLogResponse ? sanitizeTracePayload(response) : void 0;
|
|
3958
3978
|
const responseBytes = responsePayload !== void 0 ? estimatePayloadBytes(responsePayload) : void 0;
|
|
3979
|
+
const finishReason = response?.response_metadata?.finish_reason ?? response?.response_metadata?.finishReason ?? response?.finishReason;
|
|
3959
3980
|
recordTraceEvent(traceSession, {
|
|
3960
3981
|
type: "ai_call",
|
|
3961
3982
|
label: "Assistant Response",
|
|
@@ -3965,12 +3986,18 @@ function createAgentCoreNode(opts) {
|
|
|
3965
3986
|
outputTokens: normalized?.completion_tokens,
|
|
3966
3987
|
totalTokens: normalized?.total_tokens,
|
|
3967
3988
|
cachedInputTokens: normalized?.prompt_tokens_details?.cached_tokens,
|
|
3989
|
+
// A subset of completion_tokens, and on a reasoning model routinely most
|
|
3990
|
+
// of the output bill while being invisible in the response text.
|
|
3991
|
+
reasoningTokens: normalized?.completion_tokens_details?.reasoning_tokens,
|
|
3992
|
+
finishReason: typeof finishReason === "string" ? finishReason : void 0,
|
|
3968
3993
|
requestBytes: promptBytes,
|
|
3969
3994
|
responseBytes,
|
|
3970
3995
|
model: modelName,
|
|
3971
3996
|
provider: getProviderName(runtime.model || opts.model),
|
|
3972
3997
|
messageList: messagesWithResponse,
|
|
3973
|
-
toolDefinitions: traceToolDefinitions
|
|
3998
|
+
toolDefinitions: traceToolDefinitions,
|
|
3999
|
+
responseFormat: traceResponseFormat,
|
|
4000
|
+
responseFormatStrategy: traceResponseFormatStrategy
|
|
3974
4001
|
});
|
|
3975
4002
|
if (normalized) {
|
|
3976
4003
|
recordUsage(state, modelName, normalized);
|
|
@@ -11753,6 +11780,6 @@ function createProvider(config) {
|
|
|
11753
11780
|
}
|
|
11754
11781
|
}
|
|
11755
11782
|
|
|
11756
|
-
export { ASK_USER_TOOL_NAME, AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, 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, GuardrailPhase, InMemoryMemoryStore, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, PREOPEN_TOOL_CALL_PREFIX, ProviderError, SMALL_TIER_SKILL_POLICY, StructuredOutputManager, TOOL_INPUT_DIGEST_KEY, ToolBasedStrategy, VertexProvider, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, coerceToolArgs, cognipeerSink, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, preopenSkills, preopenToolCallId, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, summarizeObject, tokenize, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
11783
|
+
export { ASK_USER_TOOL_NAME, AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, 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, GuardrailPhase, InMemoryMemoryStore, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, PREOPEN_TOOL_CALL_PREFIX, ProviderError, SMALL_TIER_SKILL_POLICY, StructuredOutputManager, TOOL_INPUT_DIGEST_KEY, ToolBasedStrategy, VertexProvider, agentVerdictRule, appendBoundTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, coerceToolArgs, cognipeerSink, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, preopenSkills, preopenToolCallId, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, summarizeObject, tokenize, traceSessionToOtlp, validateReasoningConfig, validateToolArgs, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
11757
11784
|
//# sourceMappingURL=index.mjs.map
|
|
11758
11785
|
//# sourceMappingURL=index.mjs.map
|