@cognipeer/agent-sdk 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +79 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.mjs +79 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2784,9 +2784,57 @@ type PlanEvent = {
|
|
|
2784
2784
|
todoList?: PlanStepRecord[];
|
|
2785
2785
|
version?: number;
|
|
2786
2786
|
adherenceScore?: number;
|
|
2787
|
+
/** Number of steps in the snapshot. */
|
|
2788
|
+
count?: number;
|
|
2789
|
+
/**
|
|
2790
|
+
* The model tool call that produced this snapshot, so a consumer can place the
|
|
2791
|
+
* plan in the transcript next to the call. Per call, not per tool object: two
|
|
2792
|
+
* plan calls in one turn each carry their own id.
|
|
2793
|
+
*/
|
|
2794
|
+
toolCallId?: string;
|
|
2787
2795
|
};
|
|
2788
2796
|
type SummarizationEvent = {
|
|
2789
2797
|
type: "summarization";
|
|
2798
|
+
/**
|
|
2799
|
+
* The identity of the pass: its synthetic `summarize_context` tool-call id
|
|
2800
|
+
* (`call_summary_<ts>_<suffix>`, unique to the pass), the same id the
|
|
2801
|
+
* transcript marker message carries. Shared by the `start` and the terminal
|
|
2802
|
+
* event of one pass, so a consumer pairs events by `id` (not by `pass`).
|
|
2803
|
+
*/
|
|
2804
|
+
id?: string;
|
|
2805
|
+
/**
|
|
2806
|
+
* `start` is emitted just before the summarizer model call, `done` when the pass
|
|
2807
|
+
* replaced context, `skipped` when a pass that started ended without replacing
|
|
2808
|
+
* anything (or failed, see `status`). Absent means `done` (events from before
|
|
2809
|
+
* this field existed). A consumer that counts passes must count only
|
|
2810
|
+
* `done`/absent.
|
|
2811
|
+
*/
|
|
2812
|
+
phase?: "start" | "done" | "skipped";
|
|
2813
|
+
/**
|
|
2814
|
+
* Summaries so far + 1 (1-based). A pass that ends `skipped` makes no summary,
|
|
2815
|
+
* so the next pass has the same number: `pass` is for display, `id` is the
|
|
2816
|
+
* identity.
|
|
2817
|
+
*/
|
|
2818
|
+
pass?: number;
|
|
2819
|
+
/** Where in the run loop the pass was triggered. */
|
|
2820
|
+
trigger?: "pre_leg" | "mid_leg" | "post_tools";
|
|
2821
|
+
/**
|
|
2822
|
+
* `ok`; `fallback` when the summarizer failed and a deterministic fallback
|
|
2823
|
+
* summary was used; `error` when the pass itself failed unexpectedly (not the
|
|
2824
|
+
* model call) and ended `skipped` just before the failure was rethrown.
|
|
2825
|
+
*/
|
|
2826
|
+
status?: "ok" | "fallback" | "error";
|
|
2827
|
+
/**
|
|
2828
|
+
* The failure's message when `status` is `fallback` or `error`, clipped to 300
|
|
2829
|
+
* characters. It is provider text for operators and logs, not for end users;
|
|
2830
|
+
* the trace keeps the whole message.
|
|
2831
|
+
*/
|
|
2832
|
+
error?: string;
|
|
2833
|
+
/** The tool results THIS pass replaced (not those of earlier passes). */
|
|
2834
|
+
compactedTools?: Array<{
|
|
2835
|
+
toolCallId: string;
|
|
2836
|
+
toolName: string;
|
|
2837
|
+
}>;
|
|
2790
2838
|
summary: string;
|
|
2791
2839
|
/** Number of messages that were compressed/summarized */
|
|
2792
2840
|
messagesCompressed?: number;
|
|
@@ -3346,6 +3394,12 @@ declare function createToolLimitFinalizeNode(_opts: SmartAgentOptions): (state:
|
|
|
3346
3394
|
|
|
3347
3395
|
/** ctx key: the last pass's model call, read (and removed) by the smart driver for `postCompact`. */
|
|
3348
3396
|
declare const LAST_SUMMARIZATION_CALL_KEY = "__lastSummarizationCall";
|
|
3397
|
+
/**
|
|
3398
|
+
* ctx key the smart driver sets, on the state it hands the node, to say where in
|
|
3399
|
+
* the run loop the pass was triggered. It is input only: the driver removes it
|
|
3400
|
+
* from the ctx the node returns, so it never reaches persisted state.
|
|
3401
|
+
*/
|
|
3402
|
+
declare const SUMMARIZATION_TRIGGER_KEY = "__summarizationTrigger";
|
|
3349
3403
|
/**
|
|
3350
3404
|
* Creates the summarization node.
|
|
3351
3405
|
*
|
|
@@ -6547,4 +6601,4 @@ declare class ModelRequestError extends ProviderError {
|
|
|
6547
6601
|
constructor(init: ModelRequestErrorInit);
|
|
6548
6602
|
}
|
|
6549
6603
|
|
|
6550
|
-
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentPlugin, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, AnthropicProviderConfig, type ApprovalTransport, type AuditEntry, type AuditLogConfig, type AzureContentSafetyConfig, AzureProvider, AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, type BedrockGuardrailConfig, BedrockProvider, BedrockProviderConfig, type BudgetGuardConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type CapabilityStatus, ChatCompletionChunk, ChatCompletionRequest, ChatCompletionResponse, type CheckpointPluginConfig, type CheckpointStore, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CognipeerGuardrailConfig, type CompressToolOutputParams, type ContextBuilder, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type ConversationPluginConfig, type ConversationStore, type CostEstimator, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, type DeferredTraceEvent, type DelegationEventStamp, type DelegationMode, type DroppedDirective, EmbeddingRequest, EmbeddingResponse, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, GENAI_SEMCONV_COMMIT, type GateResult, type GuardrailCallContext, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailJudgeEngine, type GuardrailOutcome, GuardrailPhase, type GuardrailPhaseName, type GuardrailPluginOptions, type GuardrailRequest, type GuardrailRule, type GuardrailRuleResult, type GuardrailTransport, type GuardrailVerdict, type GuardrailViolation, HOOK_CONTRACT_VERSION, HOOK_NAMES, type HandoffDescriptor, type HandoffEvent, type HookContext, type HookDecision, type HookHandler, type HookMap, type HookName, type HookRegistrations, HookTimeoutError, type HttpGuardrailOptions, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, InMemoryMemoryStore, type InjectionScan, type InvokeConfig, type JevClientLike, type JevEngineOptions, type JevNoulAnswer, JevProvider, JevProviderConfig, type JevQuestion, type JevSystemOneRequest, type JevSystemOneResult, type JsonGuardrailOptions, type JsonSchemaRuleOptions, LAST_SUMMARIZATION_CALL_KEY, type LangfuseBuildContext, type LangfuseEvent, type LangfuseEventKind, type LangfuseTracingConfig, type LanguageGuardConfig, type LoadSkillsOptions, type MaybePromise, type McpConfig, type McpConnection, type MediaAttachment, type MediaKind$1 as MediaKind, type MediaPolicyConfig, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MessageUsage, type MetadataEvent, type ModelCapabilities, ModelRequestError, type ModelRequestErrorCode, type ModelRequestErrorInit, ModelRuleLearnedEvent, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, OpenAICompatibleProviderConfig, type OpenAIModerationConfig, OpenAIProvider, OpenAIProviderConfig, type OtelTracingConfig, type OtlpContentField, type OtlpContentOptions, type OtlpContentRedactInfo, type OtlpExportOptions, type OtlpExportResult, type OtlpExportTraceServiceRequest, type OtlpExporter, type OtlpProtocol, type OtlpRetryOptions, type OtlpSemconv, type OutputGuardConfig, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PiiDetector, type PiiEntity, type PiiRedactionConfig, type PlanEvent, type PlanStepRecord, type PlanningMode, type PluginContributions, type PluginEvent, type PluginFailureMode, type PluginHost, type PluginHostOptions, type PluginLogger, type PluginProvides, type PluginRunHost, type PluginSetupContext, type PortkeyGatewayConfig, type PortkeyGuardrailConfig, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type PromptInjectionFamily, type PromptInjectionGuardConfig, type PromptSource, ProviderConfig, ProviderError, ToolDefinition as ProviderToolDefinition, ProviderType, type RateLimitConfig, type ReasoningConfig, type ReasoningLevel, type RedactionResult, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailConfig, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type ResponseCacheConfig, type RestoreSnapshotOptions, RulePatch, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SdkCapabilities, type SerializableSmartState, type SessionMetrics, type SessionMetricsConfig, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillSource, type SkillToolDeps, type SkillToolHeader, type SlotName, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StrictRestorers, type StrictTransform, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentStatus, type SubagentToolDeps, type SubagentToolNames, type SubagentUsage, type SummarizationEvent, type SummarizationMode, type SummarizerInput, type SummarizerResult, type SummarizerStrategy, type SummaryFactItem, type SummaryIntegrityCheck, TOOL_INPUT_DIGEST_KEY, type TokenCounter, TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallContext, type ToolCallEvent, type ToolInputDigestOptions, type ToolInputDigestResult, type ToolInputRetentionPolicy, type ToolInterface, type ToolPolicyConfig, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, type ToolRule, type TraceContinuation, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessagePart, type TraceMessageSection, type TraceMetadataSection, type TraceParent, type TraceParentInput, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDefinition, type TraceToolDefinitionsSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, type WebhookApprovalConfig, agentVerdictRule, appendBoundTools, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, loadSkillsFromDisk, mapConsoleHookVerdict, mapTextParts, mcp, mediaKindOf, mediaPolicy, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
6604
|
+
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentPlugin, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, AnthropicProviderConfig, type ApprovalTransport, type AuditEntry, type AuditLogConfig, type AzureContentSafetyConfig, AzureProvider, AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, type BedrockGuardrailConfig, BedrockProvider, BedrockProviderConfig, type BudgetGuardConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type CapabilityStatus, ChatCompletionChunk, ChatCompletionRequest, ChatCompletionResponse, type CheckpointPluginConfig, type CheckpointStore, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CognipeerGuardrailConfig, type CompressToolOutputParams, type ContextBuilder, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type ConversationPluginConfig, type ConversationStore, type CostEstimator, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, type DeferredTraceEvent, type DelegationEventStamp, type DelegationMode, type DroppedDirective, EmbeddingRequest, EmbeddingResponse, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, GENAI_SEMCONV_COMMIT, type GateResult, type GuardrailCallContext, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailJudgeEngine, type GuardrailOutcome, GuardrailPhase, type GuardrailPhaseName, type GuardrailPluginOptions, type GuardrailRequest, type GuardrailRule, type GuardrailRuleResult, type GuardrailTransport, type GuardrailVerdict, type GuardrailViolation, HOOK_CONTRACT_VERSION, HOOK_NAMES, type HandoffDescriptor, type HandoffEvent, type HookContext, type HookDecision, type HookHandler, type HookMap, type HookName, type HookRegistrations, HookTimeoutError, type HttpGuardrailOptions, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, InMemoryMemoryStore, type InjectionScan, type InvokeConfig, type JevClientLike, type JevEngineOptions, type JevNoulAnswer, JevProvider, JevProviderConfig, type JevQuestion, type JevSystemOneRequest, type JevSystemOneResult, type JsonGuardrailOptions, type JsonSchemaRuleOptions, LAST_SUMMARIZATION_CALL_KEY, type LangfuseBuildContext, type LangfuseEvent, type LangfuseEventKind, type LangfuseTracingConfig, type LanguageGuardConfig, type LoadSkillsOptions, type MaybePromise, type McpConfig, type McpConnection, type MediaAttachment, type MediaKind$1 as MediaKind, type MediaPolicyConfig, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MessageUsage, type MetadataEvent, type ModelCapabilities, ModelRequestError, type ModelRequestErrorCode, type ModelRequestErrorInit, ModelRuleLearnedEvent, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, OpenAICompatibleProviderConfig, type OpenAIModerationConfig, OpenAIProvider, OpenAIProviderConfig, type OtelTracingConfig, type OtlpContentField, type OtlpContentOptions, type OtlpContentRedactInfo, type OtlpExportOptions, type OtlpExportResult, type OtlpExportTraceServiceRequest, type OtlpExporter, type OtlpProtocol, type OtlpRetryOptions, type OtlpSemconv, type OutputGuardConfig, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PiiDetector, type PiiEntity, type PiiRedactionConfig, type PlanEvent, type PlanStepRecord, type PlanningMode, type PluginContributions, type PluginEvent, type PluginFailureMode, type PluginHost, type PluginHostOptions, type PluginLogger, type PluginProvides, type PluginRunHost, type PluginSetupContext, type PortkeyGatewayConfig, type PortkeyGuardrailConfig, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type PromptInjectionFamily, type PromptInjectionGuardConfig, type PromptSource, ProviderConfig, ProviderError, ToolDefinition as ProviderToolDefinition, ProviderType, type RateLimitConfig, type ReasoningConfig, type ReasoningLevel, type RedactionResult, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailConfig, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type ResponseCacheConfig, type RestoreSnapshotOptions, RulePatch, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, SUMMARIZATION_TRIGGER_KEY, type SdkCapabilities, type SerializableSmartState, type SessionMetrics, type SessionMetricsConfig, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillSource, type SkillToolDeps, type SkillToolHeader, type SlotName, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StrictRestorers, type StrictTransform, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentStatus, type SubagentToolDeps, type SubagentToolNames, type SubagentUsage, type SummarizationEvent, type SummarizationMode, type SummarizerInput, type SummarizerResult, type SummarizerStrategy, type SummaryFactItem, type SummaryIntegrityCheck, TOOL_INPUT_DIGEST_KEY, type TokenCounter, TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallContext, type ToolCallEvent, type ToolInputDigestOptions, type ToolInputDigestResult, type ToolInputRetentionPolicy, type ToolInterface, type ToolPolicyConfig, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, type ToolRule, type TraceContinuation, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessagePart, type TraceMessageSection, type TraceMetadataSection, type TraceParent, type TraceParentInput, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDefinition, type TraceToolDefinitionsSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, type WebhookApprovalConfig, agentVerdictRule, appendBoundTools, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, loadSkillsFromDisk, mapConsoleHookVerdict, mapTextParts, mcp, mediaKindOf, mediaPolicy, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
package/dist/index.d.ts
CHANGED
|
@@ -2784,9 +2784,57 @@ type PlanEvent = {
|
|
|
2784
2784
|
todoList?: PlanStepRecord[];
|
|
2785
2785
|
version?: number;
|
|
2786
2786
|
adherenceScore?: number;
|
|
2787
|
+
/** Number of steps in the snapshot. */
|
|
2788
|
+
count?: number;
|
|
2789
|
+
/**
|
|
2790
|
+
* The model tool call that produced this snapshot, so a consumer can place the
|
|
2791
|
+
* plan in the transcript next to the call. Per call, not per tool object: two
|
|
2792
|
+
* plan calls in one turn each carry their own id.
|
|
2793
|
+
*/
|
|
2794
|
+
toolCallId?: string;
|
|
2787
2795
|
};
|
|
2788
2796
|
type SummarizationEvent = {
|
|
2789
2797
|
type: "summarization";
|
|
2798
|
+
/**
|
|
2799
|
+
* The identity of the pass: its synthetic `summarize_context` tool-call id
|
|
2800
|
+
* (`call_summary_<ts>_<suffix>`, unique to the pass), the same id the
|
|
2801
|
+
* transcript marker message carries. Shared by the `start` and the terminal
|
|
2802
|
+
* event of one pass, so a consumer pairs events by `id` (not by `pass`).
|
|
2803
|
+
*/
|
|
2804
|
+
id?: string;
|
|
2805
|
+
/**
|
|
2806
|
+
* `start` is emitted just before the summarizer model call, `done` when the pass
|
|
2807
|
+
* replaced context, `skipped` when a pass that started ended without replacing
|
|
2808
|
+
* anything (or failed, see `status`). Absent means `done` (events from before
|
|
2809
|
+
* this field existed). A consumer that counts passes must count only
|
|
2810
|
+
* `done`/absent.
|
|
2811
|
+
*/
|
|
2812
|
+
phase?: "start" | "done" | "skipped";
|
|
2813
|
+
/**
|
|
2814
|
+
* Summaries so far + 1 (1-based). A pass that ends `skipped` makes no summary,
|
|
2815
|
+
* so the next pass has the same number: `pass` is for display, `id` is the
|
|
2816
|
+
* identity.
|
|
2817
|
+
*/
|
|
2818
|
+
pass?: number;
|
|
2819
|
+
/** Where in the run loop the pass was triggered. */
|
|
2820
|
+
trigger?: "pre_leg" | "mid_leg" | "post_tools";
|
|
2821
|
+
/**
|
|
2822
|
+
* `ok`; `fallback` when the summarizer failed and a deterministic fallback
|
|
2823
|
+
* summary was used; `error` when the pass itself failed unexpectedly (not the
|
|
2824
|
+
* model call) and ended `skipped` just before the failure was rethrown.
|
|
2825
|
+
*/
|
|
2826
|
+
status?: "ok" | "fallback" | "error";
|
|
2827
|
+
/**
|
|
2828
|
+
* The failure's message when `status` is `fallback` or `error`, clipped to 300
|
|
2829
|
+
* characters. It is provider text for operators and logs, not for end users;
|
|
2830
|
+
* the trace keeps the whole message.
|
|
2831
|
+
*/
|
|
2832
|
+
error?: string;
|
|
2833
|
+
/** The tool results THIS pass replaced (not those of earlier passes). */
|
|
2834
|
+
compactedTools?: Array<{
|
|
2835
|
+
toolCallId: string;
|
|
2836
|
+
toolName: string;
|
|
2837
|
+
}>;
|
|
2790
2838
|
summary: string;
|
|
2791
2839
|
/** Number of messages that were compressed/summarized */
|
|
2792
2840
|
messagesCompressed?: number;
|
|
@@ -3346,6 +3394,12 @@ declare function createToolLimitFinalizeNode(_opts: SmartAgentOptions): (state:
|
|
|
3346
3394
|
|
|
3347
3395
|
/** ctx key: the last pass's model call, read (and removed) by the smart driver for `postCompact`. */
|
|
3348
3396
|
declare const LAST_SUMMARIZATION_CALL_KEY = "__lastSummarizationCall";
|
|
3397
|
+
/**
|
|
3398
|
+
* ctx key the smart driver sets, on the state it hands the node, to say where in
|
|
3399
|
+
* the run loop the pass was triggered. It is input only: the driver removes it
|
|
3400
|
+
* from the ctx the node returns, so it never reaches persisted state.
|
|
3401
|
+
*/
|
|
3402
|
+
declare const SUMMARIZATION_TRIGGER_KEY = "__summarizationTrigger";
|
|
3349
3403
|
/**
|
|
3350
3404
|
* Creates the summarization node.
|
|
3351
3405
|
*
|
|
@@ -6547,4 +6601,4 @@ declare class ModelRequestError extends ProviderError {
|
|
|
6547
6601
|
constructor(init: ModelRequestErrorInit);
|
|
6548
6602
|
}
|
|
6549
6603
|
|
|
6550
|
-
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentPlugin, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, AnthropicProviderConfig, type ApprovalTransport, type AuditEntry, type AuditLogConfig, type AzureContentSafetyConfig, AzureProvider, AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, type BedrockGuardrailConfig, BedrockProvider, BedrockProviderConfig, type BudgetGuardConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type CapabilityStatus, ChatCompletionChunk, ChatCompletionRequest, ChatCompletionResponse, type CheckpointPluginConfig, type CheckpointStore, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CognipeerGuardrailConfig, type CompressToolOutputParams, type ContextBuilder, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type ConversationPluginConfig, type ConversationStore, type CostEstimator, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, type DeferredTraceEvent, type DelegationEventStamp, type DelegationMode, type DroppedDirective, EmbeddingRequest, EmbeddingResponse, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, GENAI_SEMCONV_COMMIT, type GateResult, type GuardrailCallContext, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailJudgeEngine, type GuardrailOutcome, GuardrailPhase, type GuardrailPhaseName, type GuardrailPluginOptions, type GuardrailRequest, type GuardrailRule, type GuardrailRuleResult, type GuardrailTransport, type GuardrailVerdict, type GuardrailViolation, HOOK_CONTRACT_VERSION, HOOK_NAMES, type HandoffDescriptor, type HandoffEvent, type HookContext, type HookDecision, type HookHandler, type HookMap, type HookName, type HookRegistrations, HookTimeoutError, type HttpGuardrailOptions, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, InMemoryMemoryStore, type InjectionScan, type InvokeConfig, type JevClientLike, type JevEngineOptions, type JevNoulAnswer, JevProvider, JevProviderConfig, type JevQuestion, type JevSystemOneRequest, type JevSystemOneResult, type JsonGuardrailOptions, type JsonSchemaRuleOptions, LAST_SUMMARIZATION_CALL_KEY, type LangfuseBuildContext, type LangfuseEvent, type LangfuseEventKind, type LangfuseTracingConfig, type LanguageGuardConfig, type LoadSkillsOptions, type MaybePromise, type McpConfig, type McpConnection, type MediaAttachment, type MediaKind$1 as MediaKind, type MediaPolicyConfig, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MessageUsage, type MetadataEvent, type ModelCapabilities, ModelRequestError, type ModelRequestErrorCode, type ModelRequestErrorInit, ModelRuleLearnedEvent, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, OpenAICompatibleProviderConfig, type OpenAIModerationConfig, OpenAIProvider, OpenAIProviderConfig, type OtelTracingConfig, type OtlpContentField, type OtlpContentOptions, type OtlpContentRedactInfo, type OtlpExportOptions, type OtlpExportResult, type OtlpExportTraceServiceRequest, type OtlpExporter, type OtlpProtocol, type OtlpRetryOptions, type OtlpSemconv, type OutputGuardConfig, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PiiDetector, type PiiEntity, type PiiRedactionConfig, type PlanEvent, type PlanStepRecord, type PlanningMode, type PluginContributions, type PluginEvent, type PluginFailureMode, type PluginHost, type PluginHostOptions, type PluginLogger, type PluginProvides, type PluginRunHost, type PluginSetupContext, type PortkeyGatewayConfig, type PortkeyGuardrailConfig, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type PromptInjectionFamily, type PromptInjectionGuardConfig, type PromptSource, ProviderConfig, ProviderError, ToolDefinition as ProviderToolDefinition, ProviderType, type RateLimitConfig, type ReasoningConfig, type ReasoningLevel, type RedactionResult, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailConfig, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type ResponseCacheConfig, type RestoreSnapshotOptions, RulePatch, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SdkCapabilities, type SerializableSmartState, type SessionMetrics, type SessionMetricsConfig, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillSource, type SkillToolDeps, type SkillToolHeader, type SlotName, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StrictRestorers, type StrictTransform, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentStatus, type SubagentToolDeps, type SubagentToolNames, type SubagentUsage, type SummarizationEvent, type SummarizationMode, type SummarizerInput, type SummarizerResult, type SummarizerStrategy, type SummaryFactItem, type SummaryIntegrityCheck, TOOL_INPUT_DIGEST_KEY, type TokenCounter, TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallContext, type ToolCallEvent, type ToolInputDigestOptions, type ToolInputDigestResult, type ToolInputRetentionPolicy, type ToolInterface, type ToolPolicyConfig, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, type ToolRule, type TraceContinuation, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessagePart, type TraceMessageSection, type TraceMetadataSection, type TraceParent, type TraceParentInput, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDefinition, type TraceToolDefinitionsSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, type WebhookApprovalConfig, agentVerdictRule, appendBoundTools, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, loadSkillsFromDisk, mapConsoleHookVerdict, mapTextParts, mcp, mediaKindOf, mediaPolicy, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
6604
|
+
export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentPlugin, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, AnthropicProviderConfig, type ApprovalTransport, type AuditEntry, type AuditLogConfig, type AzureContentSafetyConfig, AzureProvider, AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, type BedrockGuardrailConfig, BedrockProvider, BedrockProviderConfig, type BudgetGuardConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, type CancellationTokenLike, type CancelledEvent, type CapabilityStatus, ChatCompletionChunk, ChatCompletionRequest, ChatCompletionResponse, type CheckpointPluginConfig, type CheckpointStore, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CognipeerGuardrailConfig, type CompressToolOutputParams, type ContextBuilder, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type ConversationPluginConfig, type ConversationStore, type CostEstimator, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, type DeferredTraceEvent, type DelegationEventStamp, type DelegationMode, type DroppedDirective, EmbeddingRequest, EmbeddingResponse, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, GENAI_SEMCONV_COMMIT, type GateResult, type GuardrailCallContext, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailJudgeEngine, type GuardrailOutcome, GuardrailPhase, type GuardrailPhaseName, type GuardrailPluginOptions, type GuardrailRequest, type GuardrailRule, type GuardrailRuleResult, type GuardrailTransport, type GuardrailVerdict, type GuardrailViolation, HOOK_CONTRACT_VERSION, HOOK_NAMES, type HandoffDescriptor, type HandoffEvent, type HookContext, type HookDecision, type HookHandler, type HookMap, type HookName, type HookRegistrations, HookTimeoutError, type HttpGuardrailOptions, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, InMemoryMemoryStore, type InjectionScan, type InvokeConfig, type JevClientLike, type JevEngineOptions, type JevNoulAnswer, JevProvider, JevProviderConfig, type JevQuestion, type JevSystemOneRequest, type JevSystemOneResult, type JsonGuardrailOptions, type JsonSchemaRuleOptions, LAST_SUMMARIZATION_CALL_KEY, type LangfuseBuildContext, type LangfuseEvent, type LangfuseEventKind, type LangfuseTracingConfig, type LanguageGuardConfig, type LoadSkillsOptions, type MaybePromise, type McpConfig, type McpConnection, type MediaAttachment, type MediaKind$1 as MediaKind, type MediaPolicyConfig, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MessageUsage, type MetadataEvent, type ModelCapabilities, ModelRequestError, type ModelRequestErrorCode, type ModelRequestErrorInit, ModelRuleLearnedEvent, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, OpenAICompatibleProviderConfig, type OpenAIModerationConfig, OpenAIProvider, OpenAIProviderConfig, type OtelTracingConfig, type OtlpContentField, type OtlpContentOptions, type OtlpContentRedactInfo, type OtlpExportOptions, type OtlpExportResult, type OtlpExportTraceServiceRequest, type OtlpExporter, type OtlpProtocol, type OtlpRetryOptions, type OtlpSemconv, type OutputGuardConfig, PREOPEN_TOOL_CALL_PREFIX, type PendingToolApproval, type PendingUserQuestion, type PiiDetector, type PiiEntity, type PiiRedactionConfig, type PlanEvent, type PlanStepRecord, type PlanningMode, type PluginContributions, type PluginEvent, type PluginFailureMode, type PluginHost, type PluginHostOptions, type PluginLogger, type PluginProvides, type PluginRunHost, type PluginSetupContext, type PortkeyGatewayConfig, type PortkeyGuardrailConfig, type PreopenSkillsResult, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type PromptInjectionFamily, type PromptInjectionGuardConfig, type PromptSource, ProviderConfig, ProviderError, ToolDefinition as ProviderToolDefinition, ProviderType, type RateLimitConfig, type ReasoningConfig, type ReasoningLevel, type RedactionResult, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailConfig, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type ResponseCacheConfig, type RestoreSnapshotOptions, RulePatch, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, SUMMARIZATION_TRIGGER_KEY, type SdkCapabilities, type SerializableSmartState, type SessionMetrics, type SessionMetricsConfig, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillSource, type SkillToolDeps, type SkillToolHeader, type SlotName, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StrictRestorers, type StrictTransform, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentStatus, type SubagentToolDeps, type SubagentToolNames, type SubagentUsage, type SummarizationEvent, type SummarizationMode, type SummarizerInput, type SummarizerResult, type SummarizerStrategy, type SummaryFactItem, type SummaryIntegrityCheck, TOOL_INPUT_DIGEST_KEY, type TokenCounter, TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallContext, type ToolCallEvent, type ToolInputDigestOptions, type ToolInputDigestResult, type ToolInputRetentionPolicy, type ToolInterface, type ToolPolicyConfig, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetentionDeclarations, type ToolRetentionSpec, type ToolRetryPolicy, type ToolRule, type TraceContinuation, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessagePart, type TraceMessageSection, type TraceMetadataSection, type TraceParent, type TraceParentInput, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDefinition, type TraceToolDefinitionsSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, type WebhookApprovalConfig, agentVerdictRule, appendBoundTools, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, loadSkillsFromDisk, mapConsoleHookVerdict, mapTextParts, mcp, mediaKindOf, mediaPolicy, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
package/dist/index.mjs
CHANGED
|
@@ -1248,7 +1248,7 @@ function cacheWriteTokensOf(raw) {
|
|
|
1248
1248
|
init_content();
|
|
1249
1249
|
|
|
1250
1250
|
// src/version.ts
|
|
1251
|
-
var SDK_VERSION = "0.
|
|
1251
|
+
var SDK_VERSION = "0.20.0";
|
|
1252
1252
|
|
|
1253
1253
|
// src/utils/otlp/content.ts
|
|
1254
1254
|
init_content();
|
|
@@ -10865,6 +10865,13 @@ function buildModelMessages(state, config) {
|
|
|
10865
10865
|
var systemMessage = (content) => ({ role: "system", content });
|
|
10866
10866
|
var humanMessage = (content) => ({ role: "user", content });
|
|
10867
10867
|
var LAST_SUMMARIZATION_CALL_KEY = "__lastSummarizationCall";
|
|
10868
|
+
var SUMMARIZATION_TRIGGER_KEY = "__summarizationTrigger";
|
|
10869
|
+
var SUMMARIZATION_TRIGGERS = ["pre_leg", "mid_leg", "post_tools"];
|
|
10870
|
+
var MAX_EVENT_ERROR_CHARS = 300;
|
|
10871
|
+
function eventErrorText(message) {
|
|
10872
|
+
if (!message) return void 0;
|
|
10873
|
+
return message.length > MAX_EVENT_ERROR_CHARS ? `${message.slice(0, MAX_EVENT_ERROR_CHARS - 3)}...` : message;
|
|
10874
|
+
}
|
|
10868
10875
|
var MAX_MESSAGE_CHARS = 2e3;
|
|
10869
10876
|
var MAX_USER_MESSAGE_CHARS = 4e3;
|
|
10870
10877
|
function validateMessageSequence(messages) {
|
|
@@ -11191,7 +11198,7 @@ function repairStructuredSummary(previous, current, integrity) {
|
|
|
11191
11198
|
return { ...current, user_directives: directives, stable_facts: filteredFacts };
|
|
11192
11199
|
}
|
|
11193
11200
|
function createContextSummarizeNode(opts) {
|
|
11194
|
-
|
|
11201
|
+
const summarizePass = async (state, events) => {
|
|
11195
11202
|
const resolved = getResolvedSmartConfig(opts, state.agent);
|
|
11196
11203
|
const config = resolved.summarization;
|
|
11197
11204
|
if (!config.enable) return {};
|
|
@@ -11382,11 +11389,25 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11382
11389
|
...summaryPrompt,
|
|
11383
11390
|
...rawModelOutput !== void 0 ? [{ role: "assistant", content: rawModelOutput, name: "summarization_result" }] : []
|
|
11384
11391
|
]));
|
|
11392
|
+
const summaryToolCallId = `call_summary_${Date.now()}_${nanoid(6)}`;
|
|
11393
|
+
const passNumber = (Array.isArray(state.summaries) ? state.summaries.length : 0) + 1;
|
|
11394
|
+
const rawTrigger = state.ctx?.[SUMMARIZATION_TRIGGER_KEY];
|
|
11395
|
+
const trigger = SUMMARIZATION_TRIGGERS.includes(rawTrigger) ? rawTrigger : void 0;
|
|
11396
|
+
const passIdentity = {
|
|
11397
|
+
id: summaryToolCallId,
|
|
11398
|
+
pass: passNumber,
|
|
11399
|
+
...trigger ? { trigger } : {}
|
|
11400
|
+
};
|
|
11385
11401
|
const startTime = Date.now();
|
|
11386
11402
|
try {
|
|
11387
11403
|
if (!model || typeof model.invoke !== "function") {
|
|
11388
11404
|
throw new Error("Summarization model is unavailable.");
|
|
11389
11405
|
}
|
|
11406
|
+
events.started = passIdentity;
|
|
11407
|
+
try {
|
|
11408
|
+
onEvent?.({ type: "summarization", phase: "start", ...passIdentity, summary: "" });
|
|
11409
|
+
} catch {
|
|
11410
|
+
}
|
|
11390
11411
|
const langchainRunOptions = model?._lc ? { runName: "summarize_context", tags: ["cognipeer:summarization"], metadata: { cognipeer_event: "summarization" } } : void 0;
|
|
11391
11412
|
const response = langchainRunOptions ? await model.invoke(summaryPrompt, langchainRunOptions) : await model.invoke(summaryPrompt);
|
|
11392
11413
|
durationMs = Date.now() - startTime;
|
|
@@ -11428,24 +11449,9 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11428
11449
|
structuredSummary = groundDirectives(structuredSummary);
|
|
11429
11450
|
integrity = noteDroppedDirectives({ passed: true, criticalFactLoss: false, obsoleteFactRevived: false, notes: ["Fallback summary generated locally."] });
|
|
11430
11451
|
summaryText = renderStructuredSummary(structuredSummary);
|
|
11431
|
-
const errorEvent = {
|
|
11432
|
-
type: "summarization",
|
|
11433
|
-
summary: summaryText,
|
|
11434
|
-
messagesCompressed: compressableMessages.length,
|
|
11435
|
-
inputTokens: inputTokensEstimate,
|
|
11436
|
-
outputTokens: countApproxTokens(summaryText),
|
|
11437
|
-
durationMs,
|
|
11438
|
-
previousSummary: previousSummary || void 0,
|
|
11439
|
-
tokenCountBefore,
|
|
11440
|
-
tokenCountAfter: tokenCountBefore,
|
|
11441
|
-
structuredSummary,
|
|
11442
|
-
integrity,
|
|
11443
|
-
...modelName ? { model: modelName } : {},
|
|
11444
|
-
...droppedDirectives.length > 0 ? { droppedDirectives } : {}
|
|
11445
|
-
};
|
|
11446
|
-
onEvent?.(errorEvent);
|
|
11447
11452
|
summarizerError = traceErrorOf(err);
|
|
11448
11453
|
}
|
|
11454
|
+
const eventError = eventErrorText(summarizerError?.message);
|
|
11449
11455
|
const toolCallIdToAssistantIdx = /* @__PURE__ */ new Map();
|
|
11450
11456
|
messages.forEach((m, idx) => {
|
|
11451
11457
|
if (m.role === "assistant" && m.tool_calls && Array.isArray(m.tool_calls)) {
|
|
@@ -11537,10 +11543,19 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11537
11543
|
(m) => m.role === "tool" && isSummarizedToolPlaceholder(m.content) && !messages.some((orig) => orig.tool_call_id === m.tool_call_id && isSummarizedToolPlaceholder(orig.content))
|
|
11538
11544
|
);
|
|
11539
11545
|
if (actuallyCompressed.length === 0) {
|
|
11546
|
+
if (events.started) {
|
|
11547
|
+
events.ended = true;
|
|
11548
|
+
onEvent?.({
|
|
11549
|
+
type: "summarization",
|
|
11550
|
+
phase: "skipped",
|
|
11551
|
+
...passIdentity,
|
|
11552
|
+
summary: "",
|
|
11553
|
+
...fallback ? { status: "fallback", ...eventError ? { error: eventError } : {} } : {}
|
|
11554
|
+
});
|
|
11555
|
+
}
|
|
11540
11556
|
return {};
|
|
11541
11557
|
}
|
|
11542
11558
|
const validatedMessages = validateMessageSequence(newMessages);
|
|
11543
|
-
const summaryToolCallId = `call_summary_${Date.now()}`;
|
|
11544
11559
|
const assistantSummaryCall = {
|
|
11545
11560
|
role: "assistant",
|
|
11546
11561
|
// "assistant"
|
|
@@ -11569,6 +11584,11 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11569
11584
|
const tokenCountAfter = countMessagesTokens(finalMessages);
|
|
11570
11585
|
const summarizationEvent = {
|
|
11571
11586
|
type: "summarization",
|
|
11587
|
+
phase: "done",
|
|
11588
|
+
...passIdentity,
|
|
11589
|
+
status: fallback ? "fallback" : "ok",
|
|
11590
|
+
...fallback && eventError ? { error: eventError } : {},
|
|
11591
|
+
compactedTools: actuallyCompressed.filter((m) => typeof m.tool_call_id === "string" && m.tool_call_id).map((m) => ({ toolCallId: m.tool_call_id, toolName: m.name || "" })),
|
|
11572
11592
|
summary: summaryText,
|
|
11573
11593
|
messagesCompressed: compressableMessages.length,
|
|
11574
11594
|
inputTokens: inputTokensActual ?? inputTokensEstimate,
|
|
@@ -11586,6 +11606,7 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11586
11606
|
...modelName ? { model: modelName } : {},
|
|
11587
11607
|
...droppedDirectives.length > 0 ? { droppedDirectives } : {}
|
|
11588
11608
|
};
|
|
11609
|
+
events.ended = true;
|
|
11589
11610
|
onEvent?.(summarizationEvent);
|
|
11590
11611
|
traceSummarization({
|
|
11591
11612
|
type: "summarization",
|
|
@@ -11648,6 +11669,7 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11648
11669
|
fallback
|
|
11649
11670
|
}
|
|
11650
11671
|
});
|
|
11672
|
+
const { [SUMMARIZATION_TRIGGER_KEY]: _passTrigger, ...carriedCtx } = ctxWithDeferredTrace ?? state.ctx ?? {};
|
|
11651
11673
|
return {
|
|
11652
11674
|
messages: finalMessages,
|
|
11653
11675
|
summaries,
|
|
@@ -11657,7 +11679,7 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11657
11679
|
// held for the next leg. The smart driver merges ctx and removes the
|
|
11658
11680
|
// call record once the hook has seen it.
|
|
11659
11681
|
ctx: {
|
|
11660
|
-
...
|
|
11682
|
+
...carriedCtx,
|
|
11661
11683
|
[LAST_SUMMARIZATION_CALL_KEY]: {
|
|
11662
11684
|
...modelName ? { model: modelName } : {},
|
|
11663
11685
|
durationMs,
|
|
@@ -11675,6 +11697,30 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11675
11697
|
}
|
|
11676
11698
|
};
|
|
11677
11699
|
};
|
|
11700
|
+
return async (state) => {
|
|
11701
|
+
const events = {};
|
|
11702
|
+
try {
|
|
11703
|
+
return await summarizePass(state, events);
|
|
11704
|
+
} catch (err) {
|
|
11705
|
+
if (events.started && !events.ended) {
|
|
11706
|
+
events.ended = true;
|
|
11707
|
+
const onEvent = state.ctx?.__onEvent;
|
|
11708
|
+
const error = eventErrorText(traceErrorOf(err).message);
|
|
11709
|
+
try {
|
|
11710
|
+
onEvent?.({
|
|
11711
|
+
type: "summarization",
|
|
11712
|
+
phase: "skipped",
|
|
11713
|
+
...events.started,
|
|
11714
|
+
summary: "",
|
|
11715
|
+
status: "error",
|
|
11716
|
+
...error ? { error } : {}
|
|
11717
|
+
});
|
|
11718
|
+
} catch {
|
|
11719
|
+
}
|
|
11720
|
+
}
|
|
11721
|
+
throw err;
|
|
11722
|
+
}
|
|
11723
|
+
};
|
|
11678
11724
|
}
|
|
11679
11725
|
|
|
11680
11726
|
// src/index.ts
|
|
@@ -11843,9 +11889,10 @@ function createPlanTool(stateRef, toolName, description) {
|
|
|
11843
11889
|
expectedVersion: z.number().int().min(0).optional(),
|
|
11844
11890
|
todoList: z.array(todoItemWireSchema).optional()
|
|
11845
11891
|
}),
|
|
11846
|
-
func: async ({ operation, expectedVersion, todoList }) => {
|
|
11892
|
+
func: async ({ operation, expectedVersion, todoList }, context) => {
|
|
11847
11893
|
const toolStateRef = manageTodo._stateRef;
|
|
11848
11894
|
const onEvent = toolStateRef?.__onEvent;
|
|
11895
|
+
const toolCallId = context?.toolCallId || toolStateRef?.__currentToolCallId || void 0;
|
|
11849
11896
|
const emitPlanEvent = (list) => {
|
|
11850
11897
|
const version = stateRef.planVersion || 1;
|
|
11851
11898
|
const adherenceScore = stateRef.adherenceScore || 0;
|
|
@@ -11854,7 +11901,8 @@ function createPlanTool(stateRef, toolName, description) {
|
|
|
11854
11901
|
operation,
|
|
11855
11902
|
version,
|
|
11856
11903
|
adherenceScore,
|
|
11857
|
-
count: Array.isArray(list) ? list.length : 0
|
|
11904
|
+
count: Array.isArray(list) ? list.length : 0,
|
|
11905
|
+
...toolCallId ? { toolCallId } : {}
|
|
11858
11906
|
};
|
|
11859
11907
|
onEvent?.({ type: "plan", todoList: list, ...planData });
|
|
11860
11908
|
const traceSession = toolStateRef?.ctx?.__traceSession;
|
|
@@ -13515,7 +13563,7 @@ ${pluginAppend}`;
|
|
|
13515
13563
|
const toolCalls = Array.isArray(lastAssistant.tool_calls) ? lastAssistant.tool_calls : [];
|
|
13516
13564
|
return toolCalls.length === 0;
|
|
13517
13565
|
}
|
|
13518
|
-
async function trySummarize(currentState, currentRawMessages, ref) {
|
|
13566
|
+
async function trySummarize(currentState, currentRawMessages, ref, trigger) {
|
|
13519
13567
|
if (!summarizer) return { state: currentState, rawMessages: currentRawMessages, compressed: false };
|
|
13520
13568
|
const compactHost = currentState.ctx?.__plugins;
|
|
13521
13569
|
const tokensBefore = countMessagesTokens(currentState.messages || []);
|
|
@@ -13535,7 +13583,9 @@ ${pluginAppend}`;
|
|
|
13535
13583
|
return { state: { ...currentState, ctx: ctx2 }, rawMessages: currentRawMessages, compressed: false };
|
|
13536
13584
|
}
|
|
13537
13585
|
}
|
|
13538
|
-
const
|
|
13586
|
+
const nodeState = { ...currentState, ctx: { ...currentState.ctx || {}, [SUMMARIZATION_TRIGGER_KEY]: trigger } };
|
|
13587
|
+
const delta = await summarizer(nodeState);
|
|
13588
|
+
if (nodeState.usage !== currentState.usage) currentState.usage = nodeState.usage;
|
|
13539
13589
|
if (!delta || Object.keys(delta).length === 0) {
|
|
13540
13590
|
const ctx2 = {
|
|
13541
13591
|
...currentState.ctx || {},
|
|
@@ -13547,6 +13597,7 @@ ${pluginAppend}`;
|
|
|
13547
13597
|
const ctx = { ...currentState.ctx || {}, ...delta.ctx || {} };
|
|
13548
13598
|
const summarizationCall = ctx[LAST_SUMMARIZATION_CALL_KEY];
|
|
13549
13599
|
delete ctx[LAST_SUMMARIZATION_CALL_KEY];
|
|
13600
|
+
delete ctx[SUMMARIZATION_TRIGGER_KEY];
|
|
13550
13601
|
delete ctx.__summarizationExhausted;
|
|
13551
13602
|
delete ctx.__summarizationExhaustedAtToolCount;
|
|
13552
13603
|
const updated = await persistLatestSummary(syncPlanStateWith(ref, { ...currentState, ...delta, ctx }));
|
|
@@ -13770,7 +13821,7 @@ ${pluginAppend}`;
|
|
|
13770
13821
|
state = syncRuntimeTools({ ...state, messages: rawMessages }, rawMessages, toolSet);
|
|
13771
13822
|
const next = summarizationEnabled ? decideBefore(state) : "agent";
|
|
13772
13823
|
if (next === "contextSummarize" && summarizer) {
|
|
13773
|
-
const result = await trySummarize(state, rawMessages, stateRef);
|
|
13824
|
+
const result = await trySummarize(state, rawMessages, stateRef, "pre_leg");
|
|
13774
13825
|
state = result.state;
|
|
13775
13826
|
rawMessages = result.rawMessages;
|
|
13776
13827
|
noteTraceHandoff(state);
|
|
@@ -13805,7 +13856,7 @@ ${pluginAppend}`;
|
|
|
13805
13856
|
const ctx = { ...state.ctx || {} };
|
|
13806
13857
|
delete ctx.__needsSummarization;
|
|
13807
13858
|
state = { ...state, ctx };
|
|
13808
|
-
const result = await trySummarize(state, rawMessages, stateRef);
|
|
13859
|
+
const result = await trySummarize(state, rawMessages, stateRef, "mid_leg");
|
|
13809
13860
|
state = result.state;
|
|
13810
13861
|
rawMessages = result.rawMessages;
|
|
13811
13862
|
noteTraceHandoff(state);
|
|
@@ -13817,7 +13868,7 @@ ${pluginAppend}`;
|
|
|
13817
13868
|
if (summarizationEnabled) {
|
|
13818
13869
|
const after = decideAfter(state);
|
|
13819
13870
|
if (after === "contextSummarize" && summarizer) {
|
|
13820
|
-
const result = await trySummarize(state, rawMessages, stateRef);
|
|
13871
|
+
const result = await trySummarize(state, rawMessages, stateRef, "post_tools");
|
|
13821
13872
|
state = result.state;
|
|
13822
13873
|
rawMessages = result.rawMessages;
|
|
13823
13874
|
noteTraceHandoff(state);
|
|
@@ -22034,6 +22085,6 @@ function createProvider(config) {
|
|
|
22034
22085
|
}
|
|
22035
22086
|
}
|
|
22036
22087
|
|
|
22037
|
-
export { ASK_USER_TOOL_NAME, AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONSOLE_HOOK_MAP, 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, GENAI_SEMCONV_COMMIT, GuardrailPhase, HOOK_CONTRACT_VERSION, HOOK_NAMES, HookTimeoutError, InMemoryMemoryStore, JevProvider, LAST_SUMMARIZATION_CALL_KEY, MAX_ADJUSTMENTS, MODEL_RULES, ModelRequestError, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, PREOPEN_TOOL_CALL_PREFIX, ProviderError, SMALL_TIER_SKILL_POLICY, StructuredOutputManager, TOOL_INPUT_DIGEST_KEY, ToolBasedStrategy, VertexProvider, agentVerdictRule, allowsSampling, appendBoundTools, applyDropParams, asModelRequestError, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, clearLearnedModelRules, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, effortBudget, emptyUsage, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getLearnedModelRulePatch, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, listLearnedModelRules, loadSkillsFromDisk, mapConsoleHookVerdict, mapReasoningEffort, mapTextParts, mcp, mediaKindOf, mediaPolicy, mergeRulePatch, modelIdCandidates, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseModelError, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, rememberModelRulePatch, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveModelRule, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, runWithModelAdjustments, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
22088
|
+
export { ASK_USER_TOOL_NAME, AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONSOLE_HOOK_MAP, 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, GENAI_SEMCONV_COMMIT, GuardrailPhase, HOOK_CONTRACT_VERSION, HOOK_NAMES, HookTimeoutError, InMemoryMemoryStore, JevProvider, LAST_SUMMARIZATION_CALL_KEY, MAX_ADJUSTMENTS, MODEL_RULES, ModelRequestError, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, PREOPEN_TOOL_CALL_PREFIX, ProviderError, SMALL_TIER_SKILL_POLICY, SUMMARIZATION_TRIGGER_KEY, StructuredOutputManager, TOOL_INPUT_DIGEST_KEY, ToolBasedStrategy, VertexProvider, agentVerdictRule, allowsSampling, appendBoundTools, applyDropParams, asModelRequestError, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, clearLearnedModelRules, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, effortBudget, emptyUsage, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getLearnedModelRulePatch, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, listLearnedModelRules, loadSkillsFromDisk, mapConsoleHookVerdict, mapReasoningEffort, mapTextParts, mcp, mediaKindOf, mediaPolicy, mergeRulePatch, modelIdCandidates, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseModelError, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, rememberModelRulePatch, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveModelRule, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, runWithModelAdjustments, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
22038
22089
|
//# sourceMappingURL=index.mjs.map
|
|
22039
22090
|
//# sourceMappingURL=index.mjs.map
|