@linnlabs/linnkit 0.32.0 → 0.32.1
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/CHANGELOG.md +14 -0
- package/dist/context-manager/features/context-compaction/definitions/contextCheckpointFormat.d.cts +3 -0
- package/dist/context-manager/features/context-compaction/definitions/contextCheckpointFormat.d.ts +3 -0
- package/dist/context-manager/features/context-compaction/definitions/historySummaryDraft.d.cts +22 -0
- package/dist/context-manager/features/context-compaction/definitions/historySummaryDraft.d.ts +22 -0
- package/dist/context-manager/profiles/agent/config.d.cts +33 -0
- package/dist/context-manager/profiles/agent/config.d.ts +33 -0
- package/dist/context-manager/profiles/agent/context/AgentContextManager.d.cts +132 -0
- package/dist/context-manager/profiles/agent/context/AgentContextManager.d.ts +132 -0
- package/dist/context-manager/profiles/agent/context/ConversationSession.d.cts +131 -0
- package/dist/context-manager/profiles/agent/context/ConversationSession.d.ts +131 -0
- package/dist/context-manager/profiles/agent/context/config.d.cts +191 -0
- package/dist/context-manager/profiles/agent/context/config.d.ts +191 -0
- package/dist/context-manager/profiles/agent/context/index.d.cts +8 -0
- package/dist/context-manager/profiles/agent/context/index.d.ts +8 -0
- package/dist/context-manager/profiles/agent/context/providers/AgentCoreContextProvider.d.cts +52 -0
- package/dist/context-manager/profiles/agent/context/providers/AgentCoreContextProvider.d.ts +52 -0
- package/dist/context-manager/profiles/agent/context/providers/AgentWorkingMemoryProvider.d.cts +50 -0
- package/dist/context-manager/profiles/agent/context/providers/AgentWorkingMemoryProvider.d.ts +50 -0
- package/dist/context-manager/profiles/agent/context/providers/base.d.cts +11 -0
- package/dist/context-manager/profiles/agent/context/providers/base.d.ts +11 -0
- package/dist/context-manager/profiles/agent/context/providers/index.d.cts +12 -0
- package/dist/context-manager/profiles/agent/context/providers/index.d.ts +12 -0
- package/dist/context-manager/profiles/agent/contracts.d.cts +27 -0
- package/dist/context-manager/profiles/agent/contracts.d.ts +27 -0
- package/dist/context-manager/profiles/agent/orchestration/AgentMessageOrchestrator.d.cts +140 -0
- package/dist/context-manager/profiles/agent/orchestration/AgentMessageOrchestrator.d.ts +140 -0
- package/dist/context-manager/profiles/agent/orchestration/index.d.cts +1 -0
- package/dist/context-manager/profiles/agent/orchestration/index.d.ts +1 -0
- package/dist/context-manager/profiles/agent/preprocessors/base.d.cts +17 -0
- package/dist/context-manager/profiles/agent/preprocessors/base.d.ts +17 -0
- package/dist/context-manager/profiles/agent/preprocessors/index.d.cts +117 -0
- package/dist/context-manager/profiles/agent/preprocessors/index.d.ts +117 -0
- package/dist/context-manager/profiles/agent/preprocessors/toolHistoryCompressor.d.cts +47 -0
- package/dist/context-manager/profiles/agent/preprocessors/toolHistoryCompressor.d.ts +47 -0
- package/dist/context-manager/profiles/agent/preprocessors/toolReplayProtocolGuard.d.cts +27 -0
- package/dist/context-manager/profiles/agent/preprocessors/toolReplayProtocolGuard.d.ts +27 -0
- package/dist/context-manager/profiles/agent/tasks/BaseAgentTask.d.cts +43 -0
- package/dist/context-manager/profiles/agent/tasks/BaseAgentTask.d.ts +43 -0
- package/dist/context-manager/profiles/agent/tasks/base.d.cts +18 -0
- package/dist/context-manager/profiles/agent/tasks/base.d.ts +18 -0
- package/dist/context-manager/profiles/agent/tasks/index.d.cts +2 -0
- package/dist/context-manager/profiles/agent/tasks/index.d.ts +2 -0
- package/dist/context-manager/profiles/agent/tools/ToolManager.d.cts +27 -0
- package/dist/context-manager/profiles/agent/tools/ToolManager.d.ts +27 -0
- package/dist/context-manager/profiles/agent/tools/index.d.cts +1 -0
- package/dist/context-manager/profiles/agent/tools/index.d.ts +1 -0
- package/dist/context-manager/profiles/agent/utils/eventConverter.d.cts +15 -0
- package/dist/context-manager/profiles/agent/utils/eventConverter.d.ts +15 -0
- package/dist/context-manager/profiles/agent/utils/index.d.cts +2 -0
- package/dist/context-manager/profiles/agent/utils/index.d.ts +2 -0
- package/dist/context-manager/profiles/agent/utils/toolOutputSummarizer.d.cts +26 -0
- package/dist/context-manager/profiles/agent/utils/toolOutputSummarizer.d.ts +26 -0
- package/dist/context-manager/shared/MessageFormatter.d.cts +55 -0
- package/dist/context-manager/shared/MessageFormatter.d.ts +55 -0
- package/dist/context-manager/shared/agentSpecAdapter.d.cts +63 -0
- package/dist/context-manager/shared/agentSpecAdapter.d.ts +63 -0
- package/dist/context-manager/shared/context-manager-base.d.cts +102 -0
- package/dist/context-manager/shared/context-manager-base.d.ts +102 -0
- package/dist/context-manager/shared/context-pipeline.d.cts +42 -0
- package/dist/context-manager/shared/context-pipeline.d.ts +42 -0
- package/dist/context-manager/shared/context-trace.d.cts +102 -0
- package/dist/context-manager/shared/context-trace.d.ts +102 -0
- package/dist/context-manager/shared/contextPolicyMerge.d.cts +19 -0
- package/dist/context-manager/shared/contextPolicyMerge.d.ts +19 -0
- package/dist/context-manager/shared/contracts/chatLineMessage.d.cts +15 -0
- package/dist/context-manager/shared/contracts/chatLineMessage.d.ts +15 -0
- package/dist/context-manager/shared/fences/FenceRegistry.d.cts +24 -0
- package/dist/context-manager/shared/fences/FenceRegistry.d.ts +24 -0
- package/dist/context-manager/shared/image-input-estimation.d.cts +16 -0
- package/dist/context-manager/shared/image-input-estimation.d.ts +16 -0
- package/dist/context-manager/shared/policies/MustKeepPolicy.d.cts +19 -0
- package/dist/context-manager/shared/policies/MustKeepPolicy.d.ts +19 -0
- package/dist/context-manager/shared/preprocessors/base.d.cts +43 -0
- package/dist/context-manager/shared/preprocessors/base.d.ts +43 -0
- package/dist/context-manager/shared/preprocessors/currentTurnMessageAssembler.d.cts +26 -0
- package/dist/context-manager/shared/preprocessors/currentTurnMessageAssembler.d.ts +26 -0
- package/dist/context-manager/shared/preprocessors/fenceLifetimeManager.d.cts +18 -0
- package/dist/context-manager/shared/preprocessors/fenceLifetimeManager.d.ts +18 -0
- package/dist/context-manager/shared/preprocessors/historyPurification.d.cts +19 -0
- package/dist/context-manager/shared/preprocessors/historyPurification.d.ts +19 -0
- package/dist/context-manager/shared/preprocessors/priority.d.cts +17 -0
- package/dist/context-manager/shared/preprocessors/priority.d.ts +17 -0
- package/dist/context-manager/shared/providers/base.d.cts +106 -0
- package/dist/context-manager/shared/providers/base.d.ts +106 -0
- package/dist/context-manager/shared/providers/registry.d.cts +11 -0
- package/dist/context-manager/shared/providers/registry.d.ts +11 -0
- package/dist/context-manager/shared/token-calibration.d.cts +25 -0
- package/dist/context-manager/shared/token-calibration.d.ts +25 -0
- package/dist/context-manager.d.cts +34 -1559
- package/dist/context-manager.d.ts +34 -1559
- package/dist/contracts/agentSpec.d.cts +869 -0
- package/dist/contracts/agentSpec.d.ts +869 -0
- package/dist/{audit-XsNMTt0-.d.cts → contracts/audit.d.cts} +33 -33
- package/dist/{audit-XsNMTt0-.d.ts → contracts/audit.d.ts} +33 -33
- package/dist/contracts/constants.d.cts +3 -0
- package/dist/contracts/constants.d.ts +3 -0
- package/dist/contracts/contextCompaction.d.cts +43 -0
- package/dist/contracts/contextCompaction.d.ts +43 -0
- package/dist/contracts/contextPolicy.d.cts +1121 -0
- package/dist/contracts/contextPolicy.d.ts +1121 -0
- package/dist/{final-answer-oOQ_7nPt.d.ts → contracts/events.d.cts} +1219 -1222
- package/dist/{final-answer-B0_kx5_U.d.cts → contracts/events.d.ts} +1219 -1222
- package/dist/{execution-B7e01ZjW.d.cts → contracts/execution.d.cts} +21 -21
- package/dist/{execution-B7e01ZjW.d.ts → contracts/execution.d.ts} +21 -21
- package/dist/contracts/final-answer.d.cts +7 -0
- package/dist/contracts/final-answer.d.ts +7 -0
- package/dist/contracts/identity/definitions.d.cts +70 -0
- package/dist/contracts/identity/definitions.d.ts +70 -0
- package/dist/contracts/identity/generators.d.cts +33 -0
- package/dist/contracts/identity/generators.d.ts +33 -0
- package/dist/contracts/identity/invariants.d.cts +24 -0
- package/dist/contracts/identity/invariants.d.ts +24 -0
- package/dist/contracts/json.d.cts +12 -0
- package/dist/contracts/json.d.ts +12 -0
- package/dist/{provider-continuation-CTZdCB--.d.cts → contracts/messages.d.cts} +210 -957
- package/dist/{provider-continuation-CTZdCB--.d.ts → contracts/messages.d.ts} +210 -957
- package/dist/contracts/provider-continuation.d.cts +609 -0
- package/dist/contracts/provider-continuation.d.ts +609 -0
- package/dist/contracts/reasoning.d.cts +77 -0
- package/dist/contracts/reasoning.d.ts +77 -0
- package/dist/contracts/resource-ref.d.cts +73 -0
- package/dist/contracts/resource-ref.d.ts +73 -0
- package/dist/contracts/runtime-status.d.cts +8 -0
- package/dist/contracts/runtime-status.d.ts +8 -0
- package/dist/contracts/sse-framing.d.cts +28 -0
- package/dist/contracts/sse-framing.d.ts +28 -0
- package/dist/{index-Cp1_oUj0.d.ts → contracts/sse.d.cts} +1218 -1574
- package/dist/{index-JYf6n2Ik.d.cts → contracts/sse.d.ts} +1218 -1574
- package/dist/contracts/sub-run-trace-payload.d.cts +187 -0
- package/dist/contracts/sub-run-trace-payload.d.ts +187 -0
- package/dist/{summarization-CMMLhaCe.d.ts → contracts/summarization.d.cts} +2 -2
- package/dist/{summarization-kLeweZ5-.d.cts → contracts/summarization.d.ts} +2 -2
- package/dist/contracts/token-accounting.d.cts +1177 -0
- package/dist/contracts/token-accounting.d.ts +1177 -0
- package/dist/{token-calibration-GtFyMJtM.d.cts → contracts/token-calibration.d.cts} +1 -42
- package/dist/{token-calibration-GtFyMJtM.d.ts → contracts/token-calibration.d.ts} +1 -42
- package/dist/{reasoning-bffu9R2B.d.cts → contracts/token-usage.d.cts} +9 -84
- package/dist/{reasoning-bffu9R2B.d.ts → contracts/token-usage.d.ts} +9 -84
- package/dist/contracts.d.cts +24 -10
- package/dist/contracts.d.ts +24 -10
- package/dist/index.d.cts +14 -77
- package/dist/index.d.ts +14 -77
- package/dist/ports/agent-invocation.d.cts +42 -0
- package/dist/ports/agent-invocation.d.ts +42 -0
- package/dist/{audit-DnuOSwWE.d.ts → ports/audit.d.cts} +2 -2
- package/dist/{audit-C9LPbPib.d.cts → ports/audit.d.ts} +2 -2
- package/dist/ports/canonical-inference.d.cts +135 -0
- package/dist/ports/canonical-inference.d.ts +135 -0
- package/dist/ports/llm-call.d.cts +109 -0
- package/dist/ports/llm-call.d.ts +109 -0
- package/dist/ports/llm-input-materialization.d.cts +69 -0
- package/dist/ports/llm-input-materialization.d.ts +69 -0
- package/dist/{token-counter-BjiHQEJ-.d.ts → ports/token-counter.d.cts} +3 -3
- package/dist/{token-counter-DiGIoaq2.d.cts → ports/token-counter.d.ts} +3 -3
- package/dist/{tokenizer-yIFTTc-W.d.ts → ports/tokenizer.d.cts} +2 -2
- package/dist/{tokenizer-Dz5Y3KT0.d.cts → ports/tokenizer.d.ts} +2 -2
- package/dist/ports/tool-schema.d.cts +30 -0
- package/dist/ports/tool-schema.d.ts +30 -0
- package/dist/ports/usage-normalizer.d.cts +16 -0
- package/dist/ports/usage-normalizer.d.ts +16 -0
- package/dist/ports.d.cts +10 -9
- package/dist/ports.d.ts +10 -9
- package/dist/quickstart/defineAgent.d.cts +12 -0
- package/dist/quickstart/defineAgent.d.ts +12 -0
- package/dist/quickstart/defineConfig.d.cts +7 -0
- package/dist/quickstart/defineConfig.d.ts +7 -0
- package/dist/quickstart/runAgent.d.cts +12 -0
- package/dist/quickstart/runAgent.d.ts +12 -0
- package/dist/quickstart/toolRuntime.d.cts +14 -0
- package/dist/quickstart/toolRuntime.d.ts +14 -0
- package/dist/{runAgent-jxZ0uNto.d.ts → quickstart/types.d.cts} +10 -28
- package/dist/{runAgent-QiBiFXHR.d.cts → quickstart/types.d.ts} +10 -28
- package/dist/quickstart.d.cts +5 -23
- package/dist/quickstart.d.ts +5 -23
- package/dist/runtime-kernel/audit/compositeAudit.d.cts +23 -0
- package/dist/runtime-kernel/audit/compositeAudit.d.ts +23 -0
- package/dist/runtime-kernel/audit/consoleAudit.d.cts +10 -0
- package/dist/runtime-kernel/audit/consoleAudit.d.ts +10 -0
- package/dist/runtime-kernel/audit/emitAudit.d.cts +31 -0
- package/dist/runtime-kernel/audit/emitAudit.d.ts +31 -0
- package/dist/runtime-kernel/audit/eventStoreAudit.d.cts +27 -0
- package/dist/runtime-kernel/audit/eventStoreAudit.d.ts +27 -0
- package/dist/runtime-kernel/audit/fileAudit.d.cts +22 -0
- package/dist/runtime-kernel/audit/fileAudit.d.ts +22 -0
- package/dist/runtime-kernel/audit/index.d.cts +6 -0
- package/dist/runtime-kernel/audit/index.d.ts +6 -0
- package/dist/runtime-kernel/audit/noopAudit.d.cts +5 -0
- package/dist/runtime-kernel/audit/noopAudit.d.ts +5 -0
- package/dist/runtime-kernel/child-run-trace/childRunParentTraceProjection.d.cts +26 -0
- package/dist/runtime-kernel/child-run-trace/childRunParentTraceProjection.d.ts +26 -0
- package/dist/runtime-kernel/child-run-trace/index.d.cts +4 -0
- package/dist/runtime-kernel/child-run-trace/index.d.ts +4 -0
- package/dist/runtime-kernel/child-run-trace/projectChildRuntimeEventToSubRunTrace.d.cts +10 -0
- package/dist/runtime-kernel/child-run-trace/projectChildRuntimeEventToSubRunTrace.d.ts +10 -0
- package/dist/runtime-kernel/child-run-trace/runtimeEventSubRunTracePublisher.d.cts +47 -0
- package/dist/runtime-kernel/child-run-trace/runtimeEventSubRunTracePublisher.d.ts +47 -0
- package/dist/runtime-kernel/child-run-trace/subrunTrace.types.d.cts +81 -0
- package/dist/runtime-kernel/child-run-trace/subrunTrace.types.d.ts +81 -0
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +101 -0
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +101 -0
- package/dist/runtime-kernel/child-runs/historyPolicy.d.cts +9 -0
- package/dist/runtime-kernel/child-runs/historyPolicy.d.ts +9 -0
- package/dist/runtime-kernel/child-runs/index.d.cts +3 -0
- package/dist/runtime-kernel/child-runs/index.d.ts +3 -0
- package/dist/runtime-kernel/child-runs/types.d.cts +82 -0
- package/dist/runtime-kernel/child-runs/types.d.ts +82 -0
- package/dist/runtime-kernel/enrichment/index.d.cts +2 -0
- package/dist/runtime-kernel/enrichment/index.d.ts +2 -0
- package/dist/runtime-kernel/enrichment/registry.d.cts +25 -0
- package/dist/runtime-kernel/enrichment/registry.d.ts +25 -0
- package/dist/runtime-kernel/enrichment/types.d.cts +83 -0
- package/dist/runtime-kernel/enrichment/types.d.ts +83 -0
- package/dist/runtime-kernel/events/agent-to-runtime.d.cts +6 -0
- package/dist/runtime-kernel/events/agent-to-runtime.d.ts +6 -0
- package/dist/{agentEvents-yvamy9xt.d.cts → runtime-kernel/events/agentEvents.d.cts} +127 -126
- package/dist/{agentEvents-DhXdKeXD.d.ts → runtime-kernel/events/agentEvents.d.ts} +127 -126
- package/dist/runtime-kernel/events/eventGovernance.d.cts +47 -0
- package/dist/runtime-kernel/events/eventGovernance.d.ts +47 -0
- package/dist/runtime-kernel/events/eventMappers.d.cts +41 -0
- package/dist/runtime-kernel/events/eventMappers.d.ts +41 -0
- package/dist/runtime-kernel/events/finalAnswerAssembler.d.cts +27 -0
- package/dist/runtime-kernel/events/finalAnswerAssembler.d.ts +27 -0
- package/dist/runtime-kernel/events/finalAnswerCompletion.d.cts +6 -0
- package/dist/runtime-kernel/events/finalAnswerCompletion.d.ts +6 -0
- package/dist/runtime-kernel/events/provider-sidecar.d.cts +33 -0
- package/dist/runtime-kernel/events/provider-sidecar.d.ts +33 -0
- package/dist/runtime-kernel/events/runtime-to-ai-message.d.cts +14 -0
- package/dist/runtime-kernel/events/runtime-to-ai-message.d.ts +14 -0
- package/dist/runtime-kernel/events.d.cts +7 -5
- package/dist/runtime-kernel/events.d.ts +7 -5
- package/dist/runtime-kernel/execution/event-bus.d.cts +52 -0
- package/dist/runtime-kernel/execution/event-bus.d.ts +52 -0
- package/dist/runtime-kernel/execution/eventBusEventPersistence.d.cts +40 -0
- package/dist/runtime-kernel/execution/eventBusEventPersistence.d.ts +40 -0
- package/dist/runtime-kernel/execution/index.d.cts +5 -0
- package/dist/runtime-kernel/execution/index.d.ts +5 -0
- package/dist/runtime-kernel/execution/runtimeErrorEventFactory.d.cts +46 -0
- package/dist/runtime-kernel/execution/runtimeErrorEventFactory.d.ts +46 -0
- package/dist/runtime-kernel/execution/runtimeEventPublisher.d.cts +34 -0
- package/dist/runtime-kernel/execution/runtimeEventPublisher.d.ts +34 -0
- package/dist/runtime-kernel/execution/sequencer.d.cts +69 -0
- package/dist/runtime-kernel/execution/sequencer.d.ts +69 -0
- package/dist/runtime-kernel/graph-engine/checkpointer/base.d.cts +59 -0
- package/dist/runtime-kernel/graph-engine/checkpointer/base.d.ts +59 -0
- package/dist/runtime-kernel/graph-engine/checkpointer/memoryCheckpointer.d.cts +14 -0
- package/dist/runtime-kernel/graph-engine/checkpointer/memoryCheckpointer.d.ts +14 -0
- package/dist/runtime-kernel/graph-engine/definitions/primaryPromptCapacityError.d.cts +22 -0
- package/dist/runtime-kernel/graph-engine/definitions/primaryPromptCapacityError.d.ts +22 -0
- package/dist/runtime-kernel/graph-engine/engine.d.cts +64 -0
- package/dist/runtime-kernel/graph-engine/engine.d.ts +64 -0
- package/dist/runtime-kernel/graph-engine/event-store/base.d.cts +26 -0
- package/dist/runtime-kernel/graph-engine/event-store/base.d.ts +26 -0
- package/dist/runtime-kernel/graph-engine/event-store/memoryEventStore.d.cts +14 -0
- package/dist/runtime-kernel/graph-engine/event-store/memoryEventStore.d.ts +14 -0
- package/dist/runtime-kernel/graph-engine/executor.d.cts +59 -0
- package/dist/runtime-kernel/graph-engine/executor.d.ts +59 -0
- package/dist/runtime-kernel/graph-engine/executorContextBuilder.d.cts +104 -0
- package/dist/runtime-kernel/graph-engine/executorContextBuilder.d.ts +104 -0
- package/dist/runtime-kernel/graph-engine/functions/createHostToolCallBootstrap.d.cts +41 -0
- package/dist/runtime-kernel/graph-engine/functions/createHostToolCallBootstrap.d.ts +41 -0
- package/dist/runtime-kernel/graph-engine/functions/engineStateSnapshot.d.cts +23 -0
- package/dist/runtime-kernel/graph-engine/functions/engineStateSnapshot.d.ts +23 -0
- package/dist/runtime-kernel/graph-engine/functions/evaluatePrimaryPromptCapacity.d.cts +15 -0
- package/dist/runtime-kernel/graph-engine/functions/evaluatePrimaryPromptCapacity.d.ts +15 -0
- package/dist/runtime-kernel/graph-engine/functions/runtimeFailureFact.d.cts +7 -0
- package/dist/runtime-kernel/graph-engine/functions/runtimeFailureFact.d.ts +7 -0
- package/dist/runtime-kernel/graph-engine/index.d.cts +18 -0
- package/dist/runtime-kernel/graph-engine/index.d.ts +18 -0
- package/dist/runtime-kernel/graph-engine/nodes/llmNode.d.cts +26 -0
- package/dist/runtime-kernel/graph-engine/nodes/llmNode.d.ts +26 -0
- package/dist/runtime-kernel/graph-engine/nodes/llmNode.eventBridge.d.cts +6 -0
- package/dist/runtime-kernel/graph-engine/nodes/llmNode.eventBridge.d.ts +6 -0
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +44 -0
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +44 -0
- package/dist/runtime-kernel/graph-engine/nodes/userNode.d.cts +8 -0
- package/dist/runtime-kernel/graph-engine/nodes/userNode.d.ts +8 -0
- package/dist/runtime-kernel/graph-engine/nodes/waitUserNode.d.cts +15 -0
- package/dist/runtime-kernel/graph-engine/nodes/waitUserNode.d.ts +15 -0
- package/dist/runtime-kernel/graph-engine/tick-pipeline/types.d.cts +57 -0
- package/dist/runtime-kernel/graph-engine/tick-pipeline/types.d.ts +57 -0
- package/dist/runtime-kernel/graph-engine/types.d.cts +143 -0
- package/dist/runtime-kernel/graph-engine/types.d.ts +143 -0
- package/dist/runtime-kernel/llm/caller.d.cts +50 -0
- package/dist/runtime-kernel/llm/caller.d.ts +50 -0
- package/dist/runtime-kernel/llm/canonical-inference/definitions/canonicalInferenceStreamState.d.cts +28 -0
- package/dist/runtime-kernel/llm/canonical-inference/definitions/canonicalInferenceStreamState.d.ts +28 -0
- package/dist/runtime-kernel/llm/canonical-inference/functions/advanceCanonicalInferenceStreamState.d.cts +6 -0
- package/dist/runtime-kernel/llm/canonical-inference/functions/advanceCanonicalInferenceStreamState.d.ts +6 -0
- package/dist/runtime-kernel/llm/canonical-inference/orchestration/consumeCanonicalInferenceStream.d.cts +6 -0
- package/dist/runtime-kernel/llm/canonical-inference/orchestration/consumeCanonicalInferenceStream.d.ts +6 -0
- package/dist/runtime-kernel/llm/definitions/llmCallInvocationContext.d.cts +29 -0
- package/dist/runtime-kernel/llm/definitions/llmCallInvocationContext.d.ts +29 -0
- package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.cts +26 -0
- package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.ts +26 -0
- package/dist/runtime-kernel/llm/functions/evaluateFallbackPromptCapacity.d.cts +9 -0
- package/dist/runtime-kernel/llm/functions/evaluateFallbackPromptCapacity.d.ts +9 -0
- package/dist/runtime-kernel/llm/index.d.cts +22 -0
- package/dist/runtime-kernel/llm/index.d.ts +22 -0
- package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapability.d.cts +24 -0
- package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapability.d.ts +24 -0
- package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapabilityError.d.cts +31 -0
- package/dist/runtime-kernel/llm/input-capabilities/definitions/modelInputCapabilityError.d.ts +31 -0
- package/dist/runtime-kernel/llm/input-capabilities/functions/createModelInputCompatibilityError.d.cts +13 -0
- package/dist/runtime-kernel/llm/input-capabilities/functions/createModelInputCompatibilityError.d.ts +13 -0
- package/dist/runtime-kernel/llm/input-capabilities/functions/deriveModelInputRequirement.d.cts +6 -0
- package/dist/runtime-kernel/llm/input-capabilities/functions/deriveModelInputRequirement.d.ts +6 -0
- package/dist/runtime-kernel/llm/input-capabilities/functions/evaluateModelInputCompatibility.d.cts +7 -0
- package/dist/runtime-kernel/llm/input-capabilities/functions/evaluateModelInputCompatibility.d.ts +7 -0
- package/dist/runtime-kernel/llm/input-capabilities/orchestration/assertModelInputCompatibility.d.cts +10 -0
- package/dist/runtime-kernel/llm/input-capabilities/orchestration/assertModelInputCompatibility.d.ts +10 -0
- package/dist/runtime-kernel/llm/modelCatalog.d.cts +62 -0
- package/dist/runtime-kernel/llm/modelCatalog.d.ts +62 -0
- package/dist/runtime-kernel/llm/modelResolver.d.cts +40 -0
- package/dist/runtime-kernel/llm/modelResolver.d.ts +40 -0
- package/dist/runtime-kernel/llm/policies/defaultPolicyEngine.d.cts +15 -0
- package/dist/runtime-kernel/llm/policies/defaultPolicyEngine.d.ts +15 -0
- package/dist/runtime-kernel/llm/policies/policyEngine.d.cts +18 -0
- package/dist/runtime-kernel/llm/policies/policyEngine.d.ts +18 -0
- package/dist/runtime-kernel/llm/policies/types.d.cts +27 -0
- package/dist/runtime-kernel/llm/policies/types.d.ts +27 -0
- package/dist/runtime-kernel/llm/request-builder.d.cts +22 -0
- package/dist/runtime-kernel/llm/request-builder.d.ts +22 -0
- package/dist/runtime-kernel/llm/usage-telemetry.d.cts +17 -0
- package/dist/runtime-kernel/llm/usage-telemetry.d.ts +17 -0
- package/dist/runtime-kernel/run-context/index.d.cts +1 -0
- package/dist/runtime-kernel/run-context/index.d.ts +1 -0
- package/dist/runtime-kernel/run-context/types.d.cts +44 -0
- package/dist/runtime-kernel/run-context/types.d.ts +44 -0
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +131 -0
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +131 -0
- package/dist/runtime-kernel/run-supervisor/index.d.cts +6 -0
- package/dist/runtime-kernel/run-supervisor/index.d.ts +6 -0
- package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.cts +15 -0
- package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.ts +15 -0
- package/dist/runtime-kernel/run-supervisor/runErrors.d.cts +24 -0
- package/dist/runtime-kernel/run-supervisor/runErrors.d.ts +24 -0
- package/dist/runtime-kernel/run-supervisor/runHandle.d.cts +155 -0
- package/dist/runtime-kernel/run-supervisor/runHandle.d.ts +155 -0
- package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.cts +47 -0
- package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.ts +47 -0
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +57 -0
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +57 -0
- package/dist/runtime-kernel/system-reminder/apply.d.cts +38 -0
- package/dist/runtime-kernel/system-reminder/apply.d.ts +38 -0
- package/dist/runtime-kernel/system-reminder/helpers.d.cts +11 -0
- package/dist/runtime-kernel/system-reminder/helpers.d.ts +11 -0
- package/dist/runtime-kernel/system-reminder/index.d.cts +7 -0
- package/dist/runtime-kernel/system-reminder/index.d.ts +7 -0
- package/dist/runtime-kernel/system-reminder/registry.d.cts +17 -0
- package/dist/runtime-kernel/system-reminder/registry.d.ts +17 -0
- package/dist/runtime-kernel/system-reminder/rules.d.cts +20 -0
- package/dist/runtime-kernel/system-reminder/rules.d.ts +20 -0
- package/dist/runtime-kernel/system-reminder/templates.d.cts +10 -0
- package/dist/runtime-kernel/system-reminder/templates.d.ts +10 -0
- package/dist/runtime-kernel/system-reminder/triggers.d.cts +10 -0
- package/dist/runtime-kernel/system-reminder/triggers.d.ts +10 -0
- package/dist/runtime-kernel/system-reminder/types.d.cts +46 -0
- package/dist/runtime-kernel/system-reminder/types.d.ts +46 -0
- package/dist/runtime-kernel/telemetry/index.d.cts +3 -0
- package/dist/runtime-kernel/telemetry/index.d.ts +3 -0
- package/dist/runtime-kernel/telemetry/noopTelemetry.d.cts +5 -0
- package/dist/runtime-kernel/telemetry/noopTelemetry.d.ts +5 -0
- package/dist/runtime-kernel/telemetry/telemetryEvents.d.cts +5 -0
- package/dist/runtime-kernel/telemetry/telemetryEvents.d.ts +5 -0
- package/dist/runtime-kernel/telemetry/telemetryPort.d.cts +95 -0
- package/dist/runtime-kernel/telemetry/telemetryPort.d.ts +95 -0
- package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.cts +23 -0
- package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.ts +23 -0
- package/dist/runtime-kernel/testkit/graphLoopHarness.d.cts +49 -0
- package/dist/runtime-kernel/testkit/graphLoopHarness.d.ts +49 -0
- package/dist/runtime-kernel/token-accounting/functions.d.cts +27 -0
- package/dist/runtime-kernel/token-accounting/functions.d.ts +27 -0
- package/dist/runtime-kernel/token-accounting/index.d.cts +1 -0
- package/dist/runtime-kernel/token-accounting/index.d.ts +1 -0
- package/dist/runtime-kernel/tools/argNormalizer.d.cts +10 -0
- package/dist/runtime-kernel/tools/argNormalizer.d.ts +10 -0
- package/dist/runtime-kernel/tools/conversationView.d.cts +22 -0
- package/dist/runtime-kernel/tools/conversationView.d.ts +22 -0
- package/dist/runtime-kernel/tools/idempotency/toolIdempotency.d.cts +25 -0
- package/dist/runtime-kernel/tools/idempotency/toolIdempotency.d.ts +25 -0
- package/dist/runtime-kernel/tools/index.d.cts +15 -0
- package/dist/runtime-kernel/tools/index.d.ts +15 -0
- package/dist/runtime-kernel/tools/model-input/definitions/toolModelInput.d.cts +51 -0
- package/dist/runtime-kernel/tools/model-input/definitions/toolModelInput.d.ts +51 -0
- package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.cts +17 -0
- package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.ts +17 -0
- package/dist/runtime-kernel/tools/model-input/functions/parseToolModelInputDeclaration.d.cts +17 -0
- package/dist/runtime-kernel/tools/model-input/functions/parseToolModelInputDeclaration.d.ts +17 -0
- package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.cts +16 -0
- package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.ts +16 -0
- package/dist/runtime-kernel/tools/ports.d.cts +119 -0
- package/dist/runtime-kernel/tools/ports.d.ts +119 -0
- package/dist/runtime-kernel/tools/schema/functions/assertToolParameterSchema.d.cts +15 -0
- package/dist/runtime-kernel/tools/schema/functions/assertToolParameterSchema.d.ts +15 -0
- package/dist/runtime-kernel/tools/toolContextPatch.d.cts +14 -0
- package/dist/runtime-kernel/tools/toolContextPatch.d.ts +14 -0
- package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +37 -0
- package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +37 -0
- package/dist/runtime-kernel/tools/toolContracts.d.cts +109 -0
- package/dist/runtime-kernel/tools/toolContracts.d.ts +109 -0
- package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +104 -0
- package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +104 -0
- package/dist/runtime-kernel/tools/ui-types.d.cts +72 -0
- package/dist/runtime-kernel/tools/ui-types.d.ts +72 -0
- package/dist/runtime-kernel.d.cts +106 -20
- package/dist/runtime-kernel.d.ts +106 -20
- package/dist/shared/defaultTokenizerPort.d.cts +29 -0
- package/dist/shared/defaultTokenizerPort.d.ts +29 -0
- package/dist/shared/errorClassifier.d.cts +42 -0
- package/dist/shared/errorClassifier.d.ts +42 -0
- package/dist/shared/llmAuditProjection.d.cts +11 -0
- package/dist/shared/llmAuditProjection.d.ts +11 -0
- package/dist/shared/llmAuditRecorder.d.cts +44 -0
- package/dist/shared/llmAuditRecorder.d.ts +44 -0
- package/dist/shared/llmImageInputError.d.cts +34 -0
- package/dist/shared/llmImageInputError.d.ts +34 -0
- package/dist/shared/llmTelemetryContext.d.cts +52 -0
- package/dist/shared/llmTelemetryContext.d.ts +52 -0
- package/dist/shared/logger.d.cts +12 -0
- package/dist/shared/logger.d.ts +12 -0
- package/dist/{prompt-budget-yciFkC9U.d.cts → shared/prompt-budget.d.cts} +2 -1
- package/dist/{prompt-budget-yciFkC9U.d.ts → shared/prompt-budget.d.ts} +2 -1
- package/dist/testkit/agent-harness/assertions.d.cts +10 -0
- package/dist/testkit/agent-harness/assertions.d.ts +10 -0
- package/dist/testkit/agent-harness/scriptedInferenceHarness.d.cts +52 -0
- package/dist/testkit/agent-harness/scriptedInferenceHarness.d.ts +52 -0
- package/dist/testkit/context-harness/invariants/index.d.cts +7 -0
- package/dist/testkit/context-harness/invariants/index.d.ts +7 -0
- package/dist/testkit/context-harness/invariants/types.d.cts +32 -0
- package/dist/testkit/context-harness/invariants/types.d.ts +32 -0
- package/dist/testkit/context-harness/replayHarness.d.cts +18 -0
- package/dist/testkit/context-harness/replayHarness.d.ts +18 -0
- package/dist/testkit/mocks/tokenizerPort.d.cts +17 -0
- package/dist/testkit/mocks/tokenizerPort.d.ts +17 -0
- package/dist/testkit/run-harness/collectingAuditPort.d.cts +21 -0
- package/dist/testkit/run-harness/collectingAuditPort.d.ts +21 -0
- package/dist/testkit/run-harness/invariants/index.d.cts +7 -0
- package/dist/testkit/run-harness/invariants/index.d.ts +7 -0
- package/dist/testkit/run-harness/invariants/types.d.cts +48 -0
- package/dist/testkit/run-harness/invariants/types.d.ts +48 -0
- package/dist/testkit/run-harness/mockTelemetryPort.d.cts +35 -0
- package/dist/testkit/run-harness/mockTelemetryPort.d.ts +35 -0
- package/dist/testkit/run-harness/runSupervisorHarness.d.cts +60 -0
- package/dist/testkit/run-harness/runSupervisorHarness.d.ts +60 -0
- package/dist/testkit/tool-fixtures/toolContext.d.cts +19 -0
- package/dist/testkit/tool-fixtures/toolContext.d.ts +19 -0
- package/dist/testkit.d.cts +17 -277
- package/dist/testkit.d.ts +17 -277
- package/package.json +6 -4
- package/dist/base-DRRrRhxS.d.cts +0 -216
- package/dist/base-DVyQIl_d.d.ts +0 -216
- package/dist/defaultGraphExecutor-Chr16eYO.d.cts +0 -914
- package/dist/defaultGraphExecutor-hT7dchpC.d.ts +0 -914
- package/dist/index-1pE6gSpV.d.cts +0 -172
- package/dist/index-C2PSqU1I.d.cts +0 -1971
- package/dist/index-CZMXtw4h.d.ts +0 -1971
- package/dist/index-D_csW7Zl.d.ts +0 -172
- package/dist/index-DpSWZ1L6.d.ts +0 -67
- package/dist/index-oCM3XEu2.d.cts +0 -67
- package/dist/llm-input-materialization-Vce5Swvc.d.ts +0 -366
- package/dist/llm-input-materialization-r-V3n9U-.d.cts +0 -366
- package/dist/runHandle--l0kE205.d.cts +0 -490
- package/dist/runHandle-ouLd6Tgp.d.ts +0 -490
- package/dist/token-accounting-19cXG7hM.d.cts +0 -3342
- package/dist/token-accounting-CVW37Uri.d.ts +0 -3342
- package/dist/toolContracts--KrHHNCY.d.cts +0 -424
- package/dist/toolContracts-BQ4kIso_.d.ts +0 -424
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
14
14
|
|
|
15
15
|
## [Unreleased]
|
|
16
16
|
|
|
17
|
+
## [0.32.1] - 2026-09-05
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Preserve type and value exports inside published namespaces, including nested
|
|
22
|
+
`runtimeKernel.graph`, generic child-run contracts and Host ports. The previous
|
|
23
|
+
declaration bundler emitted some imported types as value-only aliases, causing
|
|
24
|
+
downstream TypeScript errors despite valid source contracts.
|
|
25
|
+
- Preserve one declaration module graph with pinned `rollup-plugin-dts`, independently
|
|
26
|
+
of tsup's JavaScript bundles; avoid cross-chunk namespace flattening and duplicate
|
|
27
|
+
class identities. Public entrypoints and runtime behavior are unchanged.
|
|
28
|
+
- Verify all public declaration entrypoints with strict Bundler and NodeNext consumers,
|
|
29
|
+
without source aliases or `skipLibCheck`, in CI and the release gate.
|
|
30
|
+
|
|
17
31
|
## [0.32.0] - 2026-09-04
|
|
18
32
|
|
|
19
33
|
### Added
|
package/dist/context-manager/features/context-compaction/definitions/historySummaryDraft.d.cts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AiMessage } from '../../../../contracts/messages.cjs';
|
|
2
|
+
import { HistorySummaryEvent } from '../../../../contracts/events.cjs';
|
|
3
|
+
import { ContextCheckpointValidationFailure } from './contextCheckpointFormat.cjs';
|
|
4
|
+
|
|
5
|
+
type HistorySummaryDraftResult = {
|
|
6
|
+
readonly kind: 'ready';
|
|
7
|
+
readonly message: AiMessage;
|
|
8
|
+
readonly event: HistorySummaryEvent;
|
|
9
|
+
readonly compressionRatio: number;
|
|
10
|
+
readonly summaryTokenEstimate: number;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'ineffective';
|
|
13
|
+
readonly compressionRatio: number;
|
|
14
|
+
readonly summaryTokenEstimate: number;
|
|
15
|
+
};
|
|
16
|
+
type ContextCompactionDraftPreparationResult = HistorySummaryDraftResult | {
|
|
17
|
+
readonly kind: 'invalid';
|
|
18
|
+
readonly reason: ContextCheckpointValidationFailure;
|
|
19
|
+
readonly tokenEstimate: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { ContextCompactionDraftPreparationResult, HistorySummaryDraftResult };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AiMessage } from '../../../../contracts/messages.js';
|
|
2
|
+
import { HistorySummaryEvent } from '../../../../contracts/events.js';
|
|
3
|
+
import { ContextCheckpointValidationFailure } from './contextCheckpointFormat.js';
|
|
4
|
+
|
|
5
|
+
type HistorySummaryDraftResult = {
|
|
6
|
+
readonly kind: 'ready';
|
|
7
|
+
readonly message: AiMessage;
|
|
8
|
+
readonly event: HistorySummaryEvent;
|
|
9
|
+
readonly compressionRatio: number;
|
|
10
|
+
readonly summaryTokenEstimate: number;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'ineffective';
|
|
13
|
+
readonly compressionRatio: number;
|
|
14
|
+
readonly summaryTokenEstimate: number;
|
|
15
|
+
};
|
|
16
|
+
type ContextCompactionDraftPreparationResult = HistorySummaryDraftResult | {
|
|
17
|
+
readonly kind: 'invalid';
|
|
18
|
+
readonly reason: ContextCheckpointValidationFailure;
|
|
19
|
+
readonly tokenEstimate: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { ContextCompactionDraftPreparationResult, HistorySummaryDraftResult };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const AGENT_CONSTANTS: {
|
|
2
|
+
readonly DEFAULT_MAX_STEPS: 80;
|
|
3
|
+
readonly DEFAULT_TIMEOUT_MS: 300000;
|
|
4
|
+
readonly DEFAULT_MAX_RETRIES: 3;
|
|
5
|
+
readonly DEFAULT_RETRY_DELAY_MS: 1000;
|
|
6
|
+
};
|
|
7
|
+
interface AgentConfig {
|
|
8
|
+
defaultModelId: string;
|
|
9
|
+
maxSteps: number;
|
|
10
|
+
defaultTools: string[];
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
debug: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated 不再参与上下文裁剪。
|
|
15
|
+
* 中文备注:Agent 历史保留现在由 `contextPolicy.budget` 与 `contextPolicy.toolHistory`
|
|
16
|
+
* 共同决定;保留这个字段只是为了兼容可能读取 `DEFAULT_AGENT_CONFIG` 的旧接入方。
|
|
17
|
+
*/
|
|
18
|
+
maxHistoryLength: number;
|
|
19
|
+
tokenBudget: {
|
|
20
|
+
maxTokens: number;
|
|
21
|
+
reservedForResponse: number;
|
|
22
|
+
};
|
|
23
|
+
contextProcessingTimeoutMs: number;
|
|
24
|
+
retry: {
|
|
25
|
+
maxRetries: number;
|
|
26
|
+
enableEmptyResponseRetry: boolean;
|
|
27
|
+
retryDelayMs: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
declare const DEFAULT_AGENT_CONFIG: AgentConfig;
|
|
31
|
+
|
|
32
|
+
export { AGENT_CONSTANTS, DEFAULT_AGENT_CONFIG };
|
|
33
|
+
export type { AgentConfig };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const AGENT_CONSTANTS: {
|
|
2
|
+
readonly DEFAULT_MAX_STEPS: 80;
|
|
3
|
+
readonly DEFAULT_TIMEOUT_MS: 300000;
|
|
4
|
+
readonly DEFAULT_MAX_RETRIES: 3;
|
|
5
|
+
readonly DEFAULT_RETRY_DELAY_MS: 1000;
|
|
6
|
+
};
|
|
7
|
+
interface AgentConfig {
|
|
8
|
+
defaultModelId: string;
|
|
9
|
+
maxSteps: number;
|
|
10
|
+
defaultTools: string[];
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
debug: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated 不再参与上下文裁剪。
|
|
15
|
+
* 中文备注:Agent 历史保留现在由 `contextPolicy.budget` 与 `contextPolicy.toolHistory`
|
|
16
|
+
* 共同决定;保留这个字段只是为了兼容可能读取 `DEFAULT_AGENT_CONFIG` 的旧接入方。
|
|
17
|
+
*/
|
|
18
|
+
maxHistoryLength: number;
|
|
19
|
+
tokenBudget: {
|
|
20
|
+
maxTokens: number;
|
|
21
|
+
reservedForResponse: number;
|
|
22
|
+
};
|
|
23
|
+
contextProcessingTimeoutMs: number;
|
|
24
|
+
retry: {
|
|
25
|
+
maxRetries: number;
|
|
26
|
+
enableEmptyResponseRetry: boolean;
|
|
27
|
+
retryDelayMs: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
declare const DEFAULT_AGENT_CONFIG: AgentConfig;
|
|
31
|
+
|
|
32
|
+
export { AGENT_CONSTANTS, DEFAULT_AGENT_CONFIG };
|
|
33
|
+
export type { AgentConfig };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AgentProfileRequest } from '../contracts.cjs';
|
|
2
|
+
import { AgentContextBuilderConfig, AgentContextBuildStats } from './config.cjs';
|
|
3
|
+
import { ContextProviderRegistry } from './providers/index.cjs';
|
|
4
|
+
import { ContextManagerBase, ContextManagerBaseOptions } from '../../../shared/context-manager-base.cjs';
|
|
5
|
+
import { ContextTrace } from '../../../shared/context-trace.cjs';
|
|
6
|
+
import { AiMessage } from '../../../../contracts/messages.cjs';
|
|
7
|
+
import { AgentSpecContextTracePolicy, AgentSpecContextPolicy } from '../../../../contracts/contextPolicy.cjs';
|
|
8
|
+
import { ContextCompactionCandidate, ResolvedContextCompactionPolicy, ContextCompactionPlan } from '../../../../contracts/contextCompaction.cjs';
|
|
9
|
+
import { TokenRoute, TokenCountSource, TokenCountConfidence, PromptUsageMeasurementPolicy } from '../../../../contracts/token-usage.cjs';
|
|
10
|
+
import { ContextTokenComponent } from '../../../../contracts/token-accounting.cjs';
|
|
11
|
+
import { ContextBuildTokenEstimate } from '../../../../contracts/token-calibration.cjs';
|
|
12
|
+
import { ContextCompactionDraftPreparationResult } from '../../../features/context-compaction/definitions/historySummaryDraft.cjs';
|
|
13
|
+
import { TokenCounterPort } from '../../../../ports/token-counter.cjs';
|
|
14
|
+
import { TokenizerPort } from '../../../../ports/tokenizer.cjs';
|
|
15
|
+
import { LlmImageInputEstimatorPort, ImageInputAdmissionEvidence } from '../../../../ports/llm-input-materialization.cjs';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 上下文构建结果接口
|
|
19
|
+
*/
|
|
20
|
+
interface ContextBuildResult {
|
|
21
|
+
/** 构建后的消息列表 */
|
|
22
|
+
messages: AiMessage[];
|
|
23
|
+
/** Token使用情况 */
|
|
24
|
+
tokenUsage: {
|
|
25
|
+
used: number;
|
|
26
|
+
remaining: number;
|
|
27
|
+
messageBudget: number;
|
|
28
|
+
inputBudget: number;
|
|
29
|
+
toolDefinitionTokens: number;
|
|
30
|
+
source: TokenCountSource;
|
|
31
|
+
confidence: TokenCountConfidence;
|
|
32
|
+
};
|
|
33
|
+
/** Graph 对 reminder 后最终 Prompt 计数时复用的已解析策略。 */
|
|
34
|
+
promptUsageMeasurementPolicy: PromptUsageMeasurementPolicy;
|
|
35
|
+
/** 处理统计信息 */
|
|
36
|
+
processingStats: {
|
|
37
|
+
originalCount: number;
|
|
38
|
+
keptCount: number;
|
|
39
|
+
truncatedCount: number;
|
|
40
|
+
tokenDistribution: Record<string, number>;
|
|
41
|
+
strategiesApplied: string[];
|
|
42
|
+
recommendations: string[];
|
|
43
|
+
buildStats?: AgentContextBuildStats;
|
|
44
|
+
};
|
|
45
|
+
/** 是否进行了截断 */
|
|
46
|
+
truncated: boolean;
|
|
47
|
+
/** 截断的消息数量 */
|
|
48
|
+
truncatedCount?: number;
|
|
49
|
+
/** 应用的策略列表 */
|
|
50
|
+
strategies: {
|
|
51
|
+
applied: string[];
|
|
52
|
+
recommendations: string[];
|
|
53
|
+
};
|
|
54
|
+
/** ContextTrace:解释本次上下文构建如何保留/裁剪消息。 */
|
|
55
|
+
contextTrace?: ContextTrace;
|
|
56
|
+
/** 构建期 token 估算快照,用于 host 把本地估算与响应后 actual usage 配对。 */
|
|
57
|
+
tokenEstimate?: ContextBuildTokenEstimate;
|
|
58
|
+
/** 构建期上下文分项 token 估算,用于 trace、账本与 host 面板后端。 */
|
|
59
|
+
tokenComponents?: ContextTokenComponent[];
|
|
60
|
+
/** provider attempt 用来按 active profile 复核 final context 的短生命周期预算证据。 */
|
|
61
|
+
imageInputAdmissionEvidence?: ImageInputAdmissionEvidence;
|
|
62
|
+
/** Graph 在最终 Prompt 计量后可执行的纯压缩候选。 */
|
|
63
|
+
contextCompactionCandidate?: ContextCompactionCandidate;
|
|
64
|
+
/** 本次 build 已解析的压缩策略;无候选时 Graph 仍需它判定终态。 */
|
|
65
|
+
contextCompactionPolicy: ResolvedContextCompactionPolicy;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Agent专用智能上下文管理器
|
|
69
|
+
*
|
|
70
|
+
* 🎯 核心职责:
|
|
71
|
+
* 1. 编排Provider执行,构建优化的上下文
|
|
72
|
+
* 2. 保证工具调用的完整性和配对保留
|
|
73
|
+
* 3. 使用统一配置,不感知对话阶段
|
|
74
|
+
*
|
|
75
|
+
* 🏗️ 架构特性:
|
|
76
|
+
* - Provider策略模式: 实现高内聚、低耦合
|
|
77
|
+
* - 责任链模式: 按优先级编排Provider
|
|
78
|
+
* - 专注于Provider编排,不负责消息构建
|
|
79
|
+
*/
|
|
80
|
+
declare class AgentContextManager extends ContextManagerBase<AgentContextBuilderConfig, ContextProviderRegistry> {
|
|
81
|
+
constructor(options?: {
|
|
82
|
+
debugMode?: boolean;
|
|
83
|
+
customConfig?: Partial<AgentContextBuilderConfig>;
|
|
84
|
+
providerRegistry?: ContextProviderRegistry;
|
|
85
|
+
tokenizer?: TokenizerPort;
|
|
86
|
+
tokenizerModelId?: string;
|
|
87
|
+
tokenCounter?: TokenCounterPort;
|
|
88
|
+
tokenRoute?: TokenRoute;
|
|
89
|
+
remoteCount?: ContextManagerBaseOptions<AgentContextBuilderConfig, ContextProviderRegistry>['remoteCount'];
|
|
90
|
+
tokenCalibration?: ContextManagerBaseOptions<AgentContextBuilderConfig, ContextProviderRegistry>['tokenCalibration'];
|
|
91
|
+
imageInputEstimator?: LlmImageInputEstimatorPort;
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* 主入口:为Agent构建智能上下文
|
|
95
|
+
* 专门处理预处理过的消息,专注于上下文优化
|
|
96
|
+
*/
|
|
97
|
+
buildContextFromPreprocessedMessages(request: AgentProfileRequest, preprocessedMessages: AiMessage[], totalBudget: number, traceOptions?: {
|
|
98
|
+
policy?: AgentSpecContextTracePolicy;
|
|
99
|
+
effectiveContextPolicy?: AgentSpecContextPolicy;
|
|
100
|
+
budgetDetails?: {
|
|
101
|
+
inputBudgetTokens: number;
|
|
102
|
+
toolDefinitionTokens: number;
|
|
103
|
+
};
|
|
104
|
+
}): Promise<ContextBuildResult>;
|
|
105
|
+
/**
|
|
106
|
+
* 校验模型生成的 checkpoint,并创建尚未发布的 summary draft。
|
|
107
|
+
*
|
|
108
|
+
* 中文备注:该方法只做确定性规则,不调用模型、不发布事件。Graph 只有在重建后的
|
|
109
|
+
* Prompt 通过容量校验后,才允许把这里返回的事实提交到 EventStore。
|
|
110
|
+
*/
|
|
111
|
+
prepareContextCompactionDraft(input: {
|
|
112
|
+
id: string;
|
|
113
|
+
conversationId: string;
|
|
114
|
+
turnId: string;
|
|
115
|
+
timestamp: number;
|
|
116
|
+
checkpointContent: string;
|
|
117
|
+
plan: ContextCompactionPlan;
|
|
118
|
+
maxOutputTokens: number;
|
|
119
|
+
}): ContextCompactionDraftPreparationResult;
|
|
120
|
+
private initializeBuildStats;
|
|
121
|
+
private buildFinalResult;
|
|
122
|
+
private buildImageInputAdmissionEvidence;
|
|
123
|
+
private buildContextTokenEstimate;
|
|
124
|
+
private buildTokenUsageMeasurement;
|
|
125
|
+
/**
|
|
126
|
+
* 生成优化建议
|
|
127
|
+
*/
|
|
128
|
+
private generateRecommendations;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { AgentContextManager };
|
|
132
|
+
export type { ContextBuildResult };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AgentProfileRequest } from '../contracts.js';
|
|
2
|
+
import { AgentContextBuilderConfig, AgentContextBuildStats } from './config.js';
|
|
3
|
+
import { ContextProviderRegistry } from './providers/index.js';
|
|
4
|
+
import { ContextManagerBase, ContextManagerBaseOptions } from '../../../shared/context-manager-base.js';
|
|
5
|
+
import { ContextTrace } from '../../../shared/context-trace.js';
|
|
6
|
+
import { AiMessage } from '../../../../contracts/messages.js';
|
|
7
|
+
import { AgentSpecContextTracePolicy, AgentSpecContextPolicy } from '../../../../contracts/contextPolicy.js';
|
|
8
|
+
import { ContextCompactionCandidate, ResolvedContextCompactionPolicy, ContextCompactionPlan } from '../../../../contracts/contextCompaction.js';
|
|
9
|
+
import { TokenRoute, TokenCountSource, TokenCountConfidence, PromptUsageMeasurementPolicy } from '../../../../contracts/token-usage.js';
|
|
10
|
+
import { ContextTokenComponent } from '../../../../contracts/token-accounting.js';
|
|
11
|
+
import { ContextBuildTokenEstimate } from '../../../../contracts/token-calibration.js';
|
|
12
|
+
import { ContextCompactionDraftPreparationResult } from '../../../features/context-compaction/definitions/historySummaryDraft.js';
|
|
13
|
+
import { TokenCounterPort } from '../../../../ports/token-counter.js';
|
|
14
|
+
import { TokenizerPort } from '../../../../ports/tokenizer.js';
|
|
15
|
+
import { LlmImageInputEstimatorPort, ImageInputAdmissionEvidence } from '../../../../ports/llm-input-materialization.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 上下文构建结果接口
|
|
19
|
+
*/
|
|
20
|
+
interface ContextBuildResult {
|
|
21
|
+
/** 构建后的消息列表 */
|
|
22
|
+
messages: AiMessage[];
|
|
23
|
+
/** Token使用情况 */
|
|
24
|
+
tokenUsage: {
|
|
25
|
+
used: number;
|
|
26
|
+
remaining: number;
|
|
27
|
+
messageBudget: number;
|
|
28
|
+
inputBudget: number;
|
|
29
|
+
toolDefinitionTokens: number;
|
|
30
|
+
source: TokenCountSource;
|
|
31
|
+
confidence: TokenCountConfidence;
|
|
32
|
+
};
|
|
33
|
+
/** Graph 对 reminder 后最终 Prompt 计数时复用的已解析策略。 */
|
|
34
|
+
promptUsageMeasurementPolicy: PromptUsageMeasurementPolicy;
|
|
35
|
+
/** 处理统计信息 */
|
|
36
|
+
processingStats: {
|
|
37
|
+
originalCount: number;
|
|
38
|
+
keptCount: number;
|
|
39
|
+
truncatedCount: number;
|
|
40
|
+
tokenDistribution: Record<string, number>;
|
|
41
|
+
strategiesApplied: string[];
|
|
42
|
+
recommendations: string[];
|
|
43
|
+
buildStats?: AgentContextBuildStats;
|
|
44
|
+
};
|
|
45
|
+
/** 是否进行了截断 */
|
|
46
|
+
truncated: boolean;
|
|
47
|
+
/** 截断的消息数量 */
|
|
48
|
+
truncatedCount?: number;
|
|
49
|
+
/** 应用的策略列表 */
|
|
50
|
+
strategies: {
|
|
51
|
+
applied: string[];
|
|
52
|
+
recommendations: string[];
|
|
53
|
+
};
|
|
54
|
+
/** ContextTrace:解释本次上下文构建如何保留/裁剪消息。 */
|
|
55
|
+
contextTrace?: ContextTrace;
|
|
56
|
+
/** 构建期 token 估算快照,用于 host 把本地估算与响应后 actual usage 配对。 */
|
|
57
|
+
tokenEstimate?: ContextBuildTokenEstimate;
|
|
58
|
+
/** 构建期上下文分项 token 估算,用于 trace、账本与 host 面板后端。 */
|
|
59
|
+
tokenComponents?: ContextTokenComponent[];
|
|
60
|
+
/** provider attempt 用来按 active profile 复核 final context 的短生命周期预算证据。 */
|
|
61
|
+
imageInputAdmissionEvidence?: ImageInputAdmissionEvidence;
|
|
62
|
+
/** Graph 在最终 Prompt 计量后可执行的纯压缩候选。 */
|
|
63
|
+
contextCompactionCandidate?: ContextCompactionCandidate;
|
|
64
|
+
/** 本次 build 已解析的压缩策略;无候选时 Graph 仍需它判定终态。 */
|
|
65
|
+
contextCompactionPolicy: ResolvedContextCompactionPolicy;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Agent专用智能上下文管理器
|
|
69
|
+
*
|
|
70
|
+
* 🎯 核心职责:
|
|
71
|
+
* 1. 编排Provider执行,构建优化的上下文
|
|
72
|
+
* 2. 保证工具调用的完整性和配对保留
|
|
73
|
+
* 3. 使用统一配置,不感知对话阶段
|
|
74
|
+
*
|
|
75
|
+
* 🏗️ 架构特性:
|
|
76
|
+
* - Provider策略模式: 实现高内聚、低耦合
|
|
77
|
+
* - 责任链模式: 按优先级编排Provider
|
|
78
|
+
* - 专注于Provider编排,不负责消息构建
|
|
79
|
+
*/
|
|
80
|
+
declare class AgentContextManager extends ContextManagerBase<AgentContextBuilderConfig, ContextProviderRegistry> {
|
|
81
|
+
constructor(options?: {
|
|
82
|
+
debugMode?: boolean;
|
|
83
|
+
customConfig?: Partial<AgentContextBuilderConfig>;
|
|
84
|
+
providerRegistry?: ContextProviderRegistry;
|
|
85
|
+
tokenizer?: TokenizerPort;
|
|
86
|
+
tokenizerModelId?: string;
|
|
87
|
+
tokenCounter?: TokenCounterPort;
|
|
88
|
+
tokenRoute?: TokenRoute;
|
|
89
|
+
remoteCount?: ContextManagerBaseOptions<AgentContextBuilderConfig, ContextProviderRegistry>['remoteCount'];
|
|
90
|
+
tokenCalibration?: ContextManagerBaseOptions<AgentContextBuilderConfig, ContextProviderRegistry>['tokenCalibration'];
|
|
91
|
+
imageInputEstimator?: LlmImageInputEstimatorPort;
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* 主入口:为Agent构建智能上下文
|
|
95
|
+
* 专门处理预处理过的消息,专注于上下文优化
|
|
96
|
+
*/
|
|
97
|
+
buildContextFromPreprocessedMessages(request: AgentProfileRequest, preprocessedMessages: AiMessage[], totalBudget: number, traceOptions?: {
|
|
98
|
+
policy?: AgentSpecContextTracePolicy;
|
|
99
|
+
effectiveContextPolicy?: AgentSpecContextPolicy;
|
|
100
|
+
budgetDetails?: {
|
|
101
|
+
inputBudgetTokens: number;
|
|
102
|
+
toolDefinitionTokens: number;
|
|
103
|
+
};
|
|
104
|
+
}): Promise<ContextBuildResult>;
|
|
105
|
+
/**
|
|
106
|
+
* 校验模型生成的 checkpoint,并创建尚未发布的 summary draft。
|
|
107
|
+
*
|
|
108
|
+
* 中文备注:该方法只做确定性规则,不调用模型、不发布事件。Graph 只有在重建后的
|
|
109
|
+
* Prompt 通过容量校验后,才允许把这里返回的事实提交到 EventStore。
|
|
110
|
+
*/
|
|
111
|
+
prepareContextCompactionDraft(input: {
|
|
112
|
+
id: string;
|
|
113
|
+
conversationId: string;
|
|
114
|
+
turnId: string;
|
|
115
|
+
timestamp: number;
|
|
116
|
+
checkpointContent: string;
|
|
117
|
+
plan: ContextCompactionPlan;
|
|
118
|
+
maxOutputTokens: number;
|
|
119
|
+
}): ContextCompactionDraftPreparationResult;
|
|
120
|
+
private initializeBuildStats;
|
|
121
|
+
private buildFinalResult;
|
|
122
|
+
private buildImageInputAdmissionEvidence;
|
|
123
|
+
private buildContextTokenEstimate;
|
|
124
|
+
private buildTokenUsageMeasurement;
|
|
125
|
+
/**
|
|
126
|
+
* 生成优化建议
|
|
127
|
+
*/
|
|
128
|
+
private generateRecommendations;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { AgentContextManager };
|
|
132
|
+
export type { ContextBuildResult };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { AssistantMessage, AiMessage } from '../../../../contracts/messages.cjs';
|
|
2
|
+
import { RuntimeResourceRef } from '../../../../contracts/resource-ref.cjs';
|
|
3
|
+
import { ToolCallId } from '../../../../contracts/identity/definitions.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 对话会话管理类
|
|
7
|
+
*
|
|
8
|
+
* 单一职责:管理当前会话的消息存储和基础CRUD操作
|
|
9
|
+
* - 存储和检索消息
|
|
10
|
+
* - 维护对话历史的完整性
|
|
11
|
+
* - 提供基础的消息查询功能
|
|
12
|
+
*
|
|
13
|
+
* 不负责:Token管理、智能截断、优先级分析(这些由WorkingContextManager处理)
|
|
14
|
+
*/
|
|
15
|
+
declare class ConversationSession {
|
|
16
|
+
private messages;
|
|
17
|
+
private systemPrompt;
|
|
18
|
+
/**
|
|
19
|
+
* 构造函数
|
|
20
|
+
* @param systemPrompt 系统提示词
|
|
21
|
+
*/
|
|
22
|
+
constructor(systemPrompt: string);
|
|
23
|
+
/**
|
|
24
|
+
* 添加消息到会话
|
|
25
|
+
* @param role 消息角色
|
|
26
|
+
* @param content 消息内容
|
|
27
|
+
*/
|
|
28
|
+
addMessage(role: 'user' | 'assistant', content: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 添加用户消息
|
|
31
|
+
* @param content 用户消息内容
|
|
32
|
+
* @param id 可选的消息ID,如果不提供则自动生成
|
|
33
|
+
*/
|
|
34
|
+
addUserMessage(content: string, id?: string, attachments?: RuntimeResourceRef[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* 添加助手消息,可能包含工具调用
|
|
37
|
+
* @param content 文本内容(可选)
|
|
38
|
+
* @param type 消息类型
|
|
39
|
+
* @param metadata 消息元数据(可选)
|
|
40
|
+
* @param id 可选的消息ID,如果不提供则自动生成
|
|
41
|
+
*/
|
|
42
|
+
addAssistantMessage(content: string | null, type: AssistantMessage['type'], metadata?: AiMessage['metadata'], id?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* 添加从历史记录加载的工具输出消息
|
|
45
|
+
* @param content 消息内容
|
|
46
|
+
* @param metadata 消息元数据
|
|
47
|
+
*/
|
|
48
|
+
addToolOutputMessage(content: string, metadata: AiMessage['metadata'], attachments?: RuntimeResourceRef[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* 添加工具调用的响应结果
|
|
51
|
+
* @param toolCallId 工具调用的唯一ID
|
|
52
|
+
* @param content 工具执行返回的结果(通常是字符串格式)
|
|
53
|
+
* @param toolName 工具名称(可选)
|
|
54
|
+
* @param id 可选的消息ID,如果不提供则自动生成
|
|
55
|
+
*/
|
|
56
|
+
addToolResponse(toolCallId: ToolCallId, content: string, toolName: string, id?: string, attachments?: RuntimeResourceRef[], metadata?: AiMessage['metadata']): void;
|
|
57
|
+
/**
|
|
58
|
+
* 追加一条已构造完成的消息。
|
|
59
|
+
*
|
|
60
|
+
* 中文备注:
|
|
61
|
+
* - 该方法用于回放阶段写入“已是最终形态”的消息,例如 `history_summary`;
|
|
62
|
+
* - 这样 core 侧只依赖最小写入端口,不需要直接感知 `ConversationSession` 的私有字段结构。
|
|
63
|
+
*/
|
|
64
|
+
appendMessage(message: AiMessage): void;
|
|
65
|
+
/**
|
|
66
|
+
* 获取完整的对话历史记录
|
|
67
|
+
* @returns 消息数组
|
|
68
|
+
*/
|
|
69
|
+
getHistory(): AiMessage[];
|
|
70
|
+
/**
|
|
71
|
+
* 清空对话历史,只保留系统提示词
|
|
72
|
+
*/
|
|
73
|
+
clear(): void;
|
|
74
|
+
/**
|
|
75
|
+
* 更新系统提示词
|
|
76
|
+
* @param newSystemPrompt 新的系统提示词
|
|
77
|
+
*/
|
|
78
|
+
updateSystemPrompt(newSystemPrompt: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* 获取当前系统提示词
|
|
81
|
+
* @returns 系统提示词字符串
|
|
82
|
+
*/
|
|
83
|
+
getSystemPrompt(): string;
|
|
84
|
+
/**
|
|
85
|
+
* 获取消息总数(不包括系统消息)
|
|
86
|
+
* @returns 消息数量
|
|
87
|
+
*/
|
|
88
|
+
getMessageCount(): number;
|
|
89
|
+
/**
|
|
90
|
+
* 获取最近的n条用户消息
|
|
91
|
+
* @param n 消息数量
|
|
92
|
+
* @returns 用户消息数组
|
|
93
|
+
*/
|
|
94
|
+
getRecentUserMessages(n: number): AiMessage[];
|
|
95
|
+
/**
|
|
96
|
+
* 获取最近的n条助手消息
|
|
97
|
+
* @param n 消息数量
|
|
98
|
+
* @returns 助手消息数组
|
|
99
|
+
*/
|
|
100
|
+
getRecentAssistantMessages(n: number): AiMessage[];
|
|
101
|
+
/**
|
|
102
|
+
* 检查是否有待处理的工具调用
|
|
103
|
+
* @returns 是否有未响应的工具调用
|
|
104
|
+
*/
|
|
105
|
+
hasPendingToolCalls(): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* 获取待处理的工具调用
|
|
108
|
+
* @returns 待处理的工具调用数组
|
|
109
|
+
*/
|
|
110
|
+
getPendingToolCalls(): Array<{
|
|
111
|
+
id: string;
|
|
112
|
+
type: 'function';
|
|
113
|
+
function: {
|
|
114
|
+
name: string;
|
|
115
|
+
arguments: string;
|
|
116
|
+
};
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* 将历史记录序列化为JSON
|
|
120
|
+
* @returns JSON字符串
|
|
121
|
+
*/
|
|
122
|
+
serialize(): string;
|
|
123
|
+
/**
|
|
124
|
+
* 从JSON反序列化历史记录
|
|
125
|
+
* @param json JSON字符串
|
|
126
|
+
* @returns ConversationSession实例
|
|
127
|
+
*/
|
|
128
|
+
static deserialize(json: string): ConversationSession;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { ConversationSession };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { AssistantMessage, AiMessage } from '../../../../contracts/messages.js';
|
|
2
|
+
import { RuntimeResourceRef } from '../../../../contracts/resource-ref.js';
|
|
3
|
+
import { ToolCallId } from '../../../../contracts/identity/definitions.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 对话会话管理类
|
|
7
|
+
*
|
|
8
|
+
* 单一职责:管理当前会话的消息存储和基础CRUD操作
|
|
9
|
+
* - 存储和检索消息
|
|
10
|
+
* - 维护对话历史的完整性
|
|
11
|
+
* - 提供基础的消息查询功能
|
|
12
|
+
*
|
|
13
|
+
* 不负责:Token管理、智能截断、优先级分析(这些由WorkingContextManager处理)
|
|
14
|
+
*/
|
|
15
|
+
declare class ConversationSession {
|
|
16
|
+
private messages;
|
|
17
|
+
private systemPrompt;
|
|
18
|
+
/**
|
|
19
|
+
* 构造函数
|
|
20
|
+
* @param systemPrompt 系统提示词
|
|
21
|
+
*/
|
|
22
|
+
constructor(systemPrompt: string);
|
|
23
|
+
/**
|
|
24
|
+
* 添加消息到会话
|
|
25
|
+
* @param role 消息角色
|
|
26
|
+
* @param content 消息内容
|
|
27
|
+
*/
|
|
28
|
+
addMessage(role: 'user' | 'assistant', content: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 添加用户消息
|
|
31
|
+
* @param content 用户消息内容
|
|
32
|
+
* @param id 可选的消息ID,如果不提供则自动生成
|
|
33
|
+
*/
|
|
34
|
+
addUserMessage(content: string, id?: string, attachments?: RuntimeResourceRef[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* 添加助手消息,可能包含工具调用
|
|
37
|
+
* @param content 文本内容(可选)
|
|
38
|
+
* @param type 消息类型
|
|
39
|
+
* @param metadata 消息元数据(可选)
|
|
40
|
+
* @param id 可选的消息ID,如果不提供则自动生成
|
|
41
|
+
*/
|
|
42
|
+
addAssistantMessage(content: string | null, type: AssistantMessage['type'], metadata?: AiMessage['metadata'], id?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* 添加从历史记录加载的工具输出消息
|
|
45
|
+
* @param content 消息内容
|
|
46
|
+
* @param metadata 消息元数据
|
|
47
|
+
*/
|
|
48
|
+
addToolOutputMessage(content: string, metadata: AiMessage['metadata'], attachments?: RuntimeResourceRef[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* 添加工具调用的响应结果
|
|
51
|
+
* @param toolCallId 工具调用的唯一ID
|
|
52
|
+
* @param content 工具执行返回的结果(通常是字符串格式)
|
|
53
|
+
* @param toolName 工具名称(可选)
|
|
54
|
+
* @param id 可选的消息ID,如果不提供则自动生成
|
|
55
|
+
*/
|
|
56
|
+
addToolResponse(toolCallId: ToolCallId, content: string, toolName: string, id?: string, attachments?: RuntimeResourceRef[], metadata?: AiMessage['metadata']): void;
|
|
57
|
+
/**
|
|
58
|
+
* 追加一条已构造完成的消息。
|
|
59
|
+
*
|
|
60
|
+
* 中文备注:
|
|
61
|
+
* - 该方法用于回放阶段写入“已是最终形态”的消息,例如 `history_summary`;
|
|
62
|
+
* - 这样 core 侧只依赖最小写入端口,不需要直接感知 `ConversationSession` 的私有字段结构。
|
|
63
|
+
*/
|
|
64
|
+
appendMessage(message: AiMessage): void;
|
|
65
|
+
/**
|
|
66
|
+
* 获取完整的对话历史记录
|
|
67
|
+
* @returns 消息数组
|
|
68
|
+
*/
|
|
69
|
+
getHistory(): AiMessage[];
|
|
70
|
+
/**
|
|
71
|
+
* 清空对话历史,只保留系统提示词
|
|
72
|
+
*/
|
|
73
|
+
clear(): void;
|
|
74
|
+
/**
|
|
75
|
+
* 更新系统提示词
|
|
76
|
+
* @param newSystemPrompt 新的系统提示词
|
|
77
|
+
*/
|
|
78
|
+
updateSystemPrompt(newSystemPrompt: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* 获取当前系统提示词
|
|
81
|
+
* @returns 系统提示词字符串
|
|
82
|
+
*/
|
|
83
|
+
getSystemPrompt(): string;
|
|
84
|
+
/**
|
|
85
|
+
* 获取消息总数(不包括系统消息)
|
|
86
|
+
* @returns 消息数量
|
|
87
|
+
*/
|
|
88
|
+
getMessageCount(): number;
|
|
89
|
+
/**
|
|
90
|
+
* 获取最近的n条用户消息
|
|
91
|
+
* @param n 消息数量
|
|
92
|
+
* @returns 用户消息数组
|
|
93
|
+
*/
|
|
94
|
+
getRecentUserMessages(n: number): AiMessage[];
|
|
95
|
+
/**
|
|
96
|
+
* 获取最近的n条助手消息
|
|
97
|
+
* @param n 消息数量
|
|
98
|
+
* @returns 助手消息数组
|
|
99
|
+
*/
|
|
100
|
+
getRecentAssistantMessages(n: number): AiMessage[];
|
|
101
|
+
/**
|
|
102
|
+
* 检查是否有待处理的工具调用
|
|
103
|
+
* @returns 是否有未响应的工具调用
|
|
104
|
+
*/
|
|
105
|
+
hasPendingToolCalls(): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* 获取待处理的工具调用
|
|
108
|
+
* @returns 待处理的工具调用数组
|
|
109
|
+
*/
|
|
110
|
+
getPendingToolCalls(): Array<{
|
|
111
|
+
id: string;
|
|
112
|
+
type: 'function';
|
|
113
|
+
function: {
|
|
114
|
+
name: string;
|
|
115
|
+
arguments: string;
|
|
116
|
+
};
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* 将历史记录序列化为JSON
|
|
120
|
+
* @returns JSON字符串
|
|
121
|
+
*/
|
|
122
|
+
serialize(): string;
|
|
123
|
+
/**
|
|
124
|
+
* 从JSON反序列化历史记录
|
|
125
|
+
* @param json JSON字符串
|
|
126
|
+
* @returns ConversationSession实例
|
|
127
|
+
*/
|
|
128
|
+
static deserialize(json: string): ConversationSession;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { ConversationSession };
|