@linnlabs/linnkit 0.8.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/CHANGELOG.md +84 -0
- package/LICENSE +21 -0
- package/README.md +178 -0
- package/README.zh-CN.md +182 -0
- package/dist/agent-invocation-BHcNfrBV.d.cts +30 -0
- package/dist/agent-invocation-BznDaXDs.d.ts +30 -0
- package/dist/agentEvents-DEB7Fy_J.d.cts +81 -0
- package/dist/agentEvents-DEB7Fy_J.d.ts +81 -0
- package/dist/agentSpec-EkmviZjy.d.cts +2621 -0
- package/dist/agentSpec-EkmviZjy.d.ts +2621 -0
- package/dist/ai-engine.types-BpeU_XQG.d.cts +158 -0
- package/dist/ai-engine.types-vZRnQcJa.d.ts +158 -0
- package/dist/audit-BaRUGaqv.d.cts +307 -0
- package/dist/audit-BaRUGaqv.d.ts +307 -0
- package/dist/audit-CtcfART1.d.ts +33 -0
- package/dist/audit-LeOrm2hX.d.cts +33 -0
- package/dist/checkpointMarker-DAI3wUQu.d.cts +8 -0
- package/dist/checkpointMarker-DAI3wUQu.d.ts +8 -0
- package/dist/cli.cjs +8028 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +4 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +8025 -0
- package/dist/cli.js.map +1 -0
- package/dist/context-manager.cjs +8704 -0
- package/dist/context-manager.cjs.map +1 -0
- package/dist/context-manager.d.cts +2190 -0
- package/dist/context-manager.d.ts +2190 -0
- package/dist/context-manager.js +8650 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/context-trace-DRi5M4lX.d.ts +239 -0
- package/dist/context-trace-HE2qY5Q-.d.cts +239 -0
- package/dist/contracts.cjs +1333 -0
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.cts +8 -0
- package/dist/contracts.d.ts +8 -0
- package/dist/contracts.js +1214 -0
- package/dist/contracts.js.map +1 -0
- package/dist/defaultGraphExecutor-BBswR8wn.d.ts +624 -0
- package/dist/defaultGraphExecutor-BIjJj7WF.d.cts +624 -0
- package/dist/execution-CAIypb41.d.cts +129 -0
- package/dist/execution-CAIypb41.d.ts +129 -0
- package/dist/index-CHqwkvGp.d.ts +149 -0
- package/dist/index-CJeWHopy.d.ts +584 -0
- package/dist/index-Cm-JbzTH.d.cts +1450 -0
- package/dist/index-Cvr23YCl.d.cts +23 -0
- package/dist/index-DDzuSb0n.d.ts +23 -0
- package/dist/index-DO4dQgf2.d.cts +584 -0
- package/dist/index-DRBWi1fy.d.ts +1450 -0
- package/dist/index-Dl5PLgAv.d.cts +149 -0
- package/dist/index.cjs +9577 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +9563 -0
- package/dist/index.js.map +1 -0
- package/dist/messages-XthmnHZ3.d.cts +8007 -0
- package/dist/messages-XthmnHZ3.d.ts +8007 -0
- package/dist/ports-DaatKJXp.d.cts +90 -0
- package/dist/ports-DnLuKfpE.d.ts +90 -0
- package/dist/ports.cjs +4 -0
- package/dist/ports.cjs.map +1 -0
- package/dist/ports.d.cts +7 -0
- package/dist/ports.d.ts +7 -0
- package/dist/ports.js +3 -0
- package/dist/ports.js.map +1 -0
- package/dist/quickstart.cjs +7697 -0
- package/dist/quickstart.cjs.map +1 -0
- package/dist/quickstart.d.cts +24 -0
- package/dist/quickstart.d.ts +24 -0
- package/dist/quickstart.js +7691 -0
- package/dist/quickstart.js.map +1 -0
- package/dist/runAgent-CPj_9e58.d.ts +88 -0
- package/dist/runAgent-HYKlXbVr.d.cts +88 -0
- package/dist/runHandle-CyXvzgzk.d.ts +239 -0
- package/dist/runHandle-D3gPsD7B.d.cts +239 -0
- package/dist/runtime-kernel/events.cjs +1485 -0
- package/dist/runtime-kernel/events.cjs.map +1 -0
- package/dist/runtime-kernel/events.d.cts +8 -0
- package/dist/runtime-kernel/events.d.ts +8 -0
- package/dist/runtime-kernel/events.js +1475 -0
- package/dist/runtime-kernel/events.js.map +1 -0
- package/dist/runtime-kernel.cjs +8656 -0
- package/dist/runtime-kernel.cjs.map +1 -0
- package/dist/runtime-kernel.d.cts +19 -0
- package/dist/runtime-kernel.d.ts +19 -0
- package/dist/runtime-kernel.js +8568 -0
- package/dist/runtime-kernel.js.map +1 -0
- package/dist/sse-vPyrOPa0.d.cts +1687 -0
- package/dist/sse-vPyrOPa0.d.ts +1687 -0
- package/dist/testkit.cjs +10613 -0
- package/dist/testkit.cjs.map +1 -0
- package/dist/testkit.d.cts +284 -0
- package/dist/testkit.d.ts +284 -0
- package/dist/testkit.js +10593 -0
- package/dist/testkit.js.map +1 -0
- package/dist/todo-B1PmDlp3.d.cts +2253 -0
- package/dist/todo-B1PmDlp3.d.ts +2253 -0
- package/dist/tokenizer-DFL4I7-I.d.ts +28 -0
- package/dist/tokenizer-DH_JXv-H.d.cts +28 -0
- package/dist/toolContracts-Blll0241.d.ts +463 -0
- package/dist/toolContracts-CLkQmhTG.d.cts +463 -0
- package/docs/README.md +76 -0
- package/docs/integration/01-installation.md +94 -0
- package/docs/integration/02-quickstart.md +104 -0
- package/docs/integration/README.md +223 -0
- package/docs/integration/agent-registration-guide.md +330 -0
- package/docs/integration/audit.md +64 -0
- package/docs/integration/child-runs.md +87 -0
- package/docs/integration/constraints-and-pitfalls.md +87 -0
- package/docs/integration/context-engineering.md +650 -0
- package/docs/integration/context-fences.md +289 -0
- package/docs/integration/glossary.md +69 -0
- package/docs/integration/llm-provider.md +76 -0
- package/docs/integration/persistence.md +44 -0
- package/docs/integration/realtime.md +76 -0
- package/docs/integration/run-supervisor.md +69 -0
- package/docs/integration/telemetry.md +48 -0
- package/docs/integration/testing.md +95 -0
- package/docs/integration/tool-development-guide.md +362 -0
- package/docs/integration/tool-history.md +202 -0
- package/docs/integration/tools.md +188 -0
- package/package.json +115 -0
|
@@ -0,0 +1,1450 @@
|
|
|
1
|
+
import { a as LLMPolicy, b as LLMPolicyRequestContext, c as LLMPolicyResponseContext, d as LLMPolicyMatchContext, e as LLMPolicyErrorDecision, f as LlmCaller, M as ModelCatalogEntry, g as ModelCatalogLike, h as ModelResolver, E as ExecutorLocalState, S as StandardToolCall, i as ModelResolverLike, T as TelemetryPort, G as GraphNode, j as EngineState, N as NodeResult, C as Checkpointer, k as CheckpointMeta, l as CheckpointListFilter, m as CheckpointSummary, n as ENGINE_STATE_SCHEMA_VERSION, o as GraphExecutor, p as MemoryEventStore, s as summarizeCheckpoint, q as ToolContextPatch, D as DefaultRunSupervisor, r as DefaultRunSupervisorOptions, F as FindActiveByConversationOptions, t as MemoryRunRegistryStore, R as RunExecutionContext, u as RunExecutorPort, v as RunOutcome, x as RunRegistrationSpec, y as RunSnapshot, z as RunSupervisor, A as RunTerminalError, B as RunTerminalEvent, H as RunTerminalStatus, I as RunWaitForTerminalOptions, J as TELEMETRY_EVENT_KINDS, K as TelemetryEvent, O as TelemetryScope, P as DefaultGraphExecutorOptions, Q as GraphLoopHarness, U as GraphLoopHarnessOptions, V as GraphLoopHarnessRunResult, W as GraphLoopLlmNodeFactoryParams, X as createDefaultGraphExecutor, Y as createGraphLoopHarness } from './defaultGraphExecutor-BIjJj7WF.cjs';
|
|
2
|
+
import { b as AuditPort } from './audit-LeOrm2hX.cjs';
|
|
3
|
+
import { T as ToolCatalogPort, a as ToolPresentationPort, b as ToolExecutionPort, O as ObservationPreviewPort, C as ConversationArtifactContext, c as ObservationPreviewContext, d as ObservationPreviewMeta, e as ObservationPreviewResult, f as ToolExecutionResult, g as ToolRuntimeDefinition, h as ToolRuntimePort, i as ToolSchemaContext } from './ports-DaatKJXp.cjs';
|
|
4
|
+
import { A as AgentInvocationRequest } from './agent-invocation-BHcNfrBV.cjs';
|
|
5
|
+
import { a as LlmRequestMessage, L as LlmCallOptions, b as LlmResponseContent, c as LlmRetryConfig, P as ProviderReasoningDetails, T as ToolCall, d as ToolCallChunk, e as ToolCallExtraContent } from './ai-engine.types-BpeU_XQG.cjs';
|
|
6
|
+
import { e as RuntimeEvent, E as ErrorEvent } from './todo-B1PmDlp3.cjs';
|
|
7
|
+
import { A as AnyAgentEvent } from './agentEvents-DEB7Fy_J.cjs';
|
|
8
|
+
import { T as ToolExecutionContext, B as BaseTool, a as ToolArgs, b as ToolParameterSchema, c as ToolParameterProperty, d as ToolContextConversationView, A as AgentTool, C as CommonParameterTypes, J as JsonObjectSchema, O as OpenAIToolSchema, S as StructuredToolResult, e as ToolCallResult, f as ToolContextCompatibilityFields, g as ToolControlInfo, h as ToolDisplayOptions, i as ToolLayoutOptions, j as ToolRegistryEntry, k as ToolResult, U as UnifiedToolResult, l as computeToolIdempotencyKey, m as findCachedToolOutputByIdempotencyKey, r as readToolContextModelId, n as readToolContextRunContext, o as readToolContextUserQuery, R as RunContext, p as createDefaultRunContext, q as ChildRunParentContext, s as SubRunTracePublisher, t as ChildRunHistoryPolicy, u as ChildRunInvokerPort, v as ChildRunRequest, w as ChildRunResult, x as SubRunTraceEnvelope } from './toolContracts-CLkQmhTG.cjs';
|
|
9
|
+
import { E as EventRangeOptions, a as EventStore, P as PersistedEvent, c as createMonotonicEventIdFactory, b as EventBus, C as CancelOpts, D as DefaultRunHandle, d as DefaultRunHandleOptions, L as ListRunsFilter, R as RunAwaitingUserPatch, e as RunCost, f as RunCostCollector, g as RunFailureInfo, h as RunHandle, i as RunLifecyclePatch, j as RunMeta, k as RunObserveFilter, l as RunRecord, m as RunRegistryStore, n as RunRequestSnapshot, o as RunStatus, r as runMetaFromRecord } from './runHandle-D3gPsD7B.cjs';
|
|
10
|
+
import { C as CHECKPOINT_MARKER_TYPE, D as DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME } from './checkpointMarker-DAI3wUQu.cjs';
|
|
11
|
+
import { a as ExecutionTraceContext, E as EventEnvelope } from './execution-CAIypb41.cjs';
|
|
12
|
+
import { i as index$d } from './index-DO4dQgf2.cjs';
|
|
13
|
+
import { T as TokenizerPort } from './tokenizer-DH_JXv-H.cjs';
|
|
14
|
+
import { e as AgentSpecContextPolicy, p as AgentSpecSystemReminderPolicy, q as AgentSpecSystemReminderTrigger, o as AgentSpecSystemReminderExtraRule } from './agentSpec-EkmviZjy.cjs';
|
|
15
|
+
import { e as AuditEnvelope, b as AuditActor, d as AuditDecision, f as AuditEvidence, c as AuditCostDelta, g as AuditScope } from './audit-BaRUGaqv.cjs';
|
|
16
|
+
|
|
17
|
+
interface DefaultTokenizerPortConfig {
|
|
18
|
+
/** tiktoken encoding 名,默认沿用 TokenCalculator 的 cl100k_base 近似路径。 */
|
|
19
|
+
encoding?: string;
|
|
20
|
+
/** tiktoken 不可用或不指定 encoding 时的字符/token 兜底比。 */
|
|
21
|
+
avgCharsPerToken?: number;
|
|
22
|
+
/** 单个 tool_call 的额外 token 开销估算。 */
|
|
23
|
+
toolCallOverhead?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* linnkit 默认 tokenizer。
|
|
27
|
+
*
|
|
28
|
+
* 中文备注:
|
|
29
|
+
* - 这是 TokenCalculator 的薄包装,保持 0.7.x 默认行为;
|
|
30
|
+
* - host 不注入 TokenizerPort 时,context-manager 自动使用该实现;
|
|
31
|
+
* - 只用于上下文 budget 估算,不用于计费。
|
|
32
|
+
*/
|
|
33
|
+
declare class DefaultTokenizerPort implements TokenizerPort {
|
|
34
|
+
private readonly config;
|
|
35
|
+
constructor(config?: DefaultTokenizerPortConfig);
|
|
36
|
+
estimateText(text: string, _modelId?: string): number;
|
|
37
|
+
estimateMessage(message: LlmRequestMessage, _modelId?: string): number;
|
|
38
|
+
}
|
|
39
|
+
declare function createDefaultTokenizerPort(config?: DefaultTokenizerPortConfig): TokenizerPort;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @file src/agent/runtime-kernel/llm/policies/policyEngine.ts
|
|
43
|
+
*
|
|
44
|
+
* @description
|
|
45
|
+
* 统一的 LLM Policy Engine:
|
|
46
|
+
* - 按 match 条件筛选 policies
|
|
47
|
+
* - 固定调用点:beforeRequest / afterResponse / onError
|
|
48
|
+
*
|
|
49
|
+
* 主链路通过调用 PolicyEngine 达到“可扩展但不膨胀”的效果。
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
declare class LLMPolicyEngine {
|
|
53
|
+
private readonly policies;
|
|
54
|
+
constructor(policies: LLMPolicy[]);
|
|
55
|
+
private matched;
|
|
56
|
+
applyBeforeRequest(ctx: LLMPolicyRequestContext): {
|
|
57
|
+
requestData: unknown;
|
|
58
|
+
headers?: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
applyAfterResponse(ctx: LLMPolicyResponseContext): {
|
|
61
|
+
responseData: unknown;
|
|
62
|
+
};
|
|
63
|
+
decideOnError(error: Error, ctx: LLMPolicyMatchContext): LLMPolicyErrorDecision;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @file src/agent/runtime-kernel/llm/policies/defaultPolicyEngine.ts
|
|
68
|
+
*
|
|
69
|
+
* @description
|
|
70
|
+
* linnkit 的默认 PolicyEngine 不注册任何 provider/model 策略。
|
|
71
|
+
*
|
|
72
|
+
* provider 适配属于宿主集成层职责。宿主可以复用 `LLMPolicyEngine`
|
|
73
|
+
* 并显式注入自己的 policies。
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
declare const defaultPolicyEngine: LLMPolicyEngine;
|
|
77
|
+
|
|
78
|
+
type index$c_DefaultTokenizerPort = DefaultTokenizerPort;
|
|
79
|
+
declare const index$c_DefaultTokenizerPort: typeof DefaultTokenizerPort;
|
|
80
|
+
type index$c_DefaultTokenizerPortConfig = DefaultTokenizerPortConfig;
|
|
81
|
+
declare const index$c_LLMPolicy: typeof LLMPolicy;
|
|
82
|
+
type index$c_LLMPolicyEngine = LLMPolicyEngine;
|
|
83
|
+
declare const index$c_LLMPolicyEngine: typeof LLMPolicyEngine;
|
|
84
|
+
declare const index$c_LLMPolicyErrorDecision: typeof LLMPolicyErrorDecision;
|
|
85
|
+
declare const index$c_LLMPolicyMatchContext: typeof LLMPolicyMatchContext;
|
|
86
|
+
declare const index$c_LLMPolicyRequestContext: typeof LLMPolicyRequestContext;
|
|
87
|
+
declare const index$c_LLMPolicyResponseContext: typeof LLMPolicyResponseContext;
|
|
88
|
+
declare const index$c_LlmCallOptions: typeof LlmCallOptions;
|
|
89
|
+
declare const index$c_LlmCaller: typeof LlmCaller;
|
|
90
|
+
declare const index$c_LlmRequestMessage: typeof LlmRequestMessage;
|
|
91
|
+
declare const index$c_LlmResponseContent: typeof LlmResponseContent;
|
|
92
|
+
declare const index$c_LlmRetryConfig: typeof LlmRetryConfig;
|
|
93
|
+
declare const index$c_ModelCatalogEntry: typeof ModelCatalogEntry;
|
|
94
|
+
declare const index$c_ModelCatalogLike: typeof ModelCatalogLike;
|
|
95
|
+
declare const index$c_ModelResolver: typeof ModelResolver;
|
|
96
|
+
declare const index$c_ProviderReasoningDetails: typeof ProviderReasoningDetails;
|
|
97
|
+
declare const index$c_ToolCall: typeof ToolCall;
|
|
98
|
+
declare const index$c_ToolCallChunk: typeof ToolCallChunk;
|
|
99
|
+
declare const index$c_ToolCallExtraContent: typeof ToolCallExtraContent;
|
|
100
|
+
declare const index$c_createDefaultTokenizerPort: typeof createDefaultTokenizerPort;
|
|
101
|
+
declare const index$c_defaultPolicyEngine: typeof defaultPolicyEngine;
|
|
102
|
+
declare namespace index$c {
|
|
103
|
+
export { index$c_DefaultTokenizerPort as DefaultTokenizerPort, type index$c_DefaultTokenizerPortConfig as DefaultTokenizerPortConfig, index$c_LLMPolicy as LLMPolicy, index$c_LLMPolicyEngine as LLMPolicyEngine, index$c_LLMPolicyErrorDecision as LLMPolicyErrorDecision, index$c_LLMPolicyMatchContext as LLMPolicyMatchContext, index$c_LLMPolicyRequestContext as LLMPolicyRequestContext, index$c_LLMPolicyResponseContext as LLMPolicyResponseContext, index$c_LlmCallOptions as LlmCallOptions, index$c_LlmCaller as LlmCaller, index$c_LlmRequestMessage as LlmRequestMessage, index$c_LlmResponseContent as LlmResponseContent, index$c_LlmRetryConfig as LlmRetryConfig, index$c_ModelCatalogEntry as ModelCatalogEntry, index$c_ModelCatalogLike as ModelCatalogLike, index$c_ModelResolver as ModelResolver, index$c_ProviderReasoningDetails as ProviderReasoningDetails, index$c_ToolCall as ToolCall, index$c_ToolCallChunk as ToolCallChunk, index$c_ToolCallExtraContent as ToolCallExtraContent, index$c_createDefaultTokenizerPort as createDefaultTokenizerPort, index$c_defaultPolicyEngine as defaultPolicyEngine };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface GraphExecutorSummarizationCallbacks {
|
|
107
|
+
onSummarizationStart?: () => void;
|
|
108
|
+
onSummarizationEnd?: (summaryInfo: unknown) => void;
|
|
109
|
+
}
|
|
110
|
+
interface PendingContextRuntimeEvent extends Record<string, unknown> {
|
|
111
|
+
id: string;
|
|
112
|
+
type: string;
|
|
113
|
+
}
|
|
114
|
+
interface GraphExecutorContextBuildInput {
|
|
115
|
+
request: AgentInvocationRequest;
|
|
116
|
+
history: RuntimeEvent[];
|
|
117
|
+
summarizationCallbacks?: GraphExecutorSummarizationCallbacks;
|
|
118
|
+
modelId: string;
|
|
119
|
+
signal?: AbortSignal;
|
|
120
|
+
}
|
|
121
|
+
interface GraphExecutorContextBuildOutput {
|
|
122
|
+
mode: 'agent' | 'chat';
|
|
123
|
+
llmMessages: LlmRequestMessage[];
|
|
124
|
+
summaryEvents: PendingContextRuntimeEvent[];
|
|
125
|
+
/**
|
|
126
|
+
* 上下文构建旁路 trace。
|
|
127
|
+
*
|
|
128
|
+
* 中文备注:runtime-kernel 只负责透传,不理解 context-manager 的具体 trace 类型,
|
|
129
|
+
* 避免 graph-engine 反向依赖 context-manager。
|
|
130
|
+
*/
|
|
131
|
+
contextTrace?: unknown;
|
|
132
|
+
}
|
|
133
|
+
interface GraphExecutorContextBuilder {
|
|
134
|
+
build(input: GraphExecutorContextBuildInput): Promise<GraphExecutorContextBuildOutput>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type TickEvent$1 = AnyAgentEvent | RuntimeEvent;
|
|
138
|
+
type AgentStepDecision = {
|
|
139
|
+
kind: 'tool_calls';
|
|
140
|
+
toolCalls: StandardToolCall[];
|
|
141
|
+
} | {
|
|
142
|
+
kind: 'final_answer';
|
|
143
|
+
answer: string;
|
|
144
|
+
} | {
|
|
145
|
+
kind: 'wait_user';
|
|
146
|
+
pendingInteractionSpec: Record<string, unknown>;
|
|
147
|
+
lastToolResult: Record<string, unknown>;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'yield';
|
|
150
|
+
} | {
|
|
151
|
+
kind: 'error';
|
|
152
|
+
error: Error;
|
|
153
|
+
};
|
|
154
|
+
interface TickInput {
|
|
155
|
+
request: AgentInvocationRequest;
|
|
156
|
+
toolContext?: ToolExecutionContext;
|
|
157
|
+
stream?: boolean;
|
|
158
|
+
history: RuntimeEvent[];
|
|
159
|
+
signal?: AbortSignal;
|
|
160
|
+
/**
|
|
161
|
+
* 🔥 达到最大步数时的强制收尾开关:
|
|
162
|
+
* - true 时:禁用工具(不下发 tools schema,tool_choice=none)
|
|
163
|
+
* - 并注入 system 指令,要求模型必须直接输出最终答案
|
|
164
|
+
*/
|
|
165
|
+
forceFinalAnswer?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* 执行阶段信号(由 GraphExecutor 注入到 local.executorLocal)
|
|
168
|
+
*
|
|
169
|
+
* 中文备注:
|
|
170
|
+
* - SystemReminder 引擎会基于它生成 <system-reminder> 并追加到最后一条消息末尾
|
|
171
|
+
* - 该字段仅用于“本次 tick 的 LLM 输入”,不得写入历史事件或持久化
|
|
172
|
+
*/
|
|
173
|
+
executorLocal?: ExecutorLocalState;
|
|
174
|
+
summarizationCallbacks?: GraphExecutorSummarizationCallbacks;
|
|
175
|
+
}
|
|
176
|
+
interface TickOutput {
|
|
177
|
+
decision: AgentStepDecision;
|
|
178
|
+
newEvents: RuntimeEvent[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @file src/agent/runtime-kernel/graph-engine/executor.ts
|
|
183
|
+
*
|
|
184
|
+
* @brief 图执行引擎的单步推理执行器
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
interface GraphAgentExecutorOptions {
|
|
188
|
+
cloudQuotaFallbackModelId?: string;
|
|
189
|
+
modelCatalog?: ModelCatalogLike;
|
|
190
|
+
modelResolver?: Pick<ModelResolverLike, 'resolveModelId'>;
|
|
191
|
+
}
|
|
192
|
+
interface GraphAgentExecutorToolRuntime extends Pick<ToolCatalogPort, 'getToolSchemas'>, Pick<ToolPresentationPort, 'getDisplayOptions'> {
|
|
193
|
+
}
|
|
194
|
+
interface GraphAgentExecutorLlmCaller extends Pick<LlmCaller, 'callWithRetries'> {
|
|
195
|
+
}
|
|
196
|
+
interface GraphAgentExecutorDependencies extends GraphAgentExecutorOptions {
|
|
197
|
+
llmCaller: GraphAgentExecutorLlmCaller;
|
|
198
|
+
toolRuntime: GraphAgentExecutorToolRuntime;
|
|
199
|
+
contextBuilder: GraphExecutorContextBuilder;
|
|
200
|
+
/**
|
|
201
|
+
* 可选:宿主提供的 TelemetryPort 实现。
|
|
202
|
+
* 不传时使用 noopTelemetry(保持当前行为:observability 默认关闭,零业务影响)。
|
|
203
|
+
*/
|
|
204
|
+
telemetryPort?: TelemetryPort;
|
|
205
|
+
auditPort?: AuditPort;
|
|
206
|
+
}
|
|
207
|
+
declare class GraphAgentExecutor {
|
|
208
|
+
private readonly llmCaller;
|
|
209
|
+
private readonly toolRuntime;
|
|
210
|
+
private readonly contextBuilder;
|
|
211
|
+
private readonly cloudQuotaFallbackModelId?;
|
|
212
|
+
private readonly modelResolver;
|
|
213
|
+
private readonly modelCatalog;
|
|
214
|
+
private readonly telemetryPort;
|
|
215
|
+
private readonly auditPort;
|
|
216
|
+
private readonly stages;
|
|
217
|
+
private readonly middlewares;
|
|
218
|
+
constructor(dependencies: GraphAgentExecutorDependencies);
|
|
219
|
+
tick(input: TickInput, eventHandler?: (event: TickEvent$1) => void): Promise<TickOutput>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @file src/core/graph-engine/nodes/llmNode.eventBridge.ts
|
|
224
|
+
*
|
|
225
|
+
* @description
|
|
226
|
+
* LlmNode 事件桥接对象 —— Phase 1.5-2b 的核心产物。
|
|
227
|
+
*
|
|
228
|
+
* 动机:
|
|
229
|
+
* - Phase 1.5-2a 把状态变更收口为 reducer,但 SSE 分发、事件映射、
|
|
230
|
+
* stream_chunk 增强、final_answer 去重等副作用逻辑仍以闭包形式
|
|
231
|
+
* 留在 LlmNode.run() 中,占据约一半的方法体。
|
|
232
|
+
* - 本模块把这些"事件分发职责"抽为独立的 LlmNodeEventBridge 对象,
|
|
233
|
+
* 使 LlmNode.run() 精简为:状态初始化 → 阶段/请求解析 → 创建 bridge
|
|
234
|
+
* → tick → 决策 dispatch → 状态回写 → 路由。
|
|
235
|
+
*
|
|
236
|
+
* 约束:
|
|
237
|
+
* - bridge 不持有可变状态,所有状态读写通过 deps.getState / deps.dispatch 完成。
|
|
238
|
+
* - bridge 不知晓 EngineState / NodeResult 等图执行概念,只负责单事件处理。
|
|
239
|
+
* - 不依赖 features 层任何类型。
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
/** reasoner.tick 的事件类型(AnyAgentEvent 或 RuntimeEvent) */
|
|
243
|
+
type TickEvent = AnyAgentEvent | RuntimeEvent;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* LlmNode 只依赖"单步推理"能力,不直接依赖具体执行器实现。
|
|
247
|
+
*
|
|
248
|
+
* 中文备注:
|
|
249
|
+
* - 这样节点本身只关注图节点职责,不负责组装 `LlmCaller` / `ToolRegistry`;
|
|
250
|
+
* - 默认依赖装配放到工厂里,方便测试替换,也降低构造函数耦合。
|
|
251
|
+
*/
|
|
252
|
+
interface LlmNodeReasoner {
|
|
253
|
+
tick(input: TickInput, eventHandler?: (event: TickEvent) => void): Promise<TickOutput>;
|
|
254
|
+
}
|
|
255
|
+
interface LlmNodeDependencies {
|
|
256
|
+
reasoner: LlmNodeReasoner;
|
|
257
|
+
}
|
|
258
|
+
declare class LlmNode implements GraphNode {
|
|
259
|
+
id: string;
|
|
260
|
+
private readonly reasoner;
|
|
261
|
+
constructor(dependencies: LlmNodeDependencies);
|
|
262
|
+
run(state: EngineState): Promise<NodeResult>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
interface ToolNodeDependencies {
|
|
266
|
+
toolRuntime: Pick<ToolCatalogPort, 'getToolDefinition'> & Pick<ToolExecutionPort, 'executeTool'>;
|
|
267
|
+
observationPreview: ObservationPreviewPort;
|
|
268
|
+
/**
|
|
269
|
+
* 可选:宿主提供的 TelemetryPort 实现。
|
|
270
|
+
* 不传时使用 noopTelemetry(observability 默认关闭,业务零影响)。
|
|
271
|
+
*/
|
|
272
|
+
telemetryPort?: TelemetryPort;
|
|
273
|
+
auditPort?: AuditPort;
|
|
274
|
+
}
|
|
275
|
+
declare class ToolNode implements GraphNode {
|
|
276
|
+
id: string;
|
|
277
|
+
private readonly toolRuntime;
|
|
278
|
+
private readonly observationPreview;
|
|
279
|
+
private readonly telemetryPort;
|
|
280
|
+
private readonly auditPort;
|
|
281
|
+
constructor(dependencies: ToolNodeDependencies);
|
|
282
|
+
/**
|
|
283
|
+
* B2-engine Batch 2: 上报 tool_call 事件到宿主侧 TelemetryPort。
|
|
284
|
+
* 在 handleSuccess / handleError 入口处调用。
|
|
285
|
+
*/
|
|
286
|
+
private emitToolCallTelemetry;
|
|
287
|
+
private emitToolDecisionAudit;
|
|
288
|
+
run(state: EngineState): Promise<NodeResult>;
|
|
289
|
+
private handleSuccess;
|
|
290
|
+
private handleRequireUserSuccess;
|
|
291
|
+
private handleError;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
declare class UserNode implements GraphNode {
|
|
295
|
+
id: string;
|
|
296
|
+
run(state: EngineState): Promise<NodeResult>;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
interface WaitUserNodeDependencies {
|
|
300
|
+
auditPort?: AuditPort;
|
|
301
|
+
}
|
|
302
|
+
declare class WaitUserNode implements GraphNode {
|
|
303
|
+
id: string;
|
|
304
|
+
private readonly auditPort;
|
|
305
|
+
constructor(dependencies?: WaitUserNodeDependencies);
|
|
306
|
+
run(state: EngineState): Promise<NodeResult>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
declare class AnswerNode implements GraphNode {
|
|
310
|
+
id: string;
|
|
311
|
+
run(state: EngineState): Promise<NodeResult>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare class MemoryCheckpointer implements Checkpointer {
|
|
315
|
+
private store;
|
|
316
|
+
private cloneState;
|
|
317
|
+
load(conversationId: string): Promise<EngineState | null>;
|
|
318
|
+
save(conversationId: string, state: EngineState): Promise<void>;
|
|
319
|
+
clear(conversationId: string): Promise<void>;
|
|
320
|
+
peekMeta(conversationId: string): Promise<CheckpointMeta | null>;
|
|
321
|
+
list(filter?: CheckpointListFilter): Promise<CheckpointSummary[]>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
type index$b_AnswerNode = AnswerNode;
|
|
325
|
+
declare const index$b_AnswerNode: typeof AnswerNode;
|
|
326
|
+
declare const index$b_CheckpointListFilter: typeof CheckpointListFilter;
|
|
327
|
+
declare const index$b_CheckpointMeta: typeof CheckpointMeta;
|
|
328
|
+
declare const index$b_CheckpointSummary: typeof CheckpointSummary;
|
|
329
|
+
declare const index$b_Checkpointer: typeof Checkpointer;
|
|
330
|
+
declare const index$b_ENGINE_STATE_SCHEMA_VERSION: typeof ENGINE_STATE_SCHEMA_VERSION;
|
|
331
|
+
declare const index$b_EngineState: typeof EngineState;
|
|
332
|
+
declare const index$b_EventRangeOptions: typeof EventRangeOptions;
|
|
333
|
+
declare const index$b_EventStore: typeof EventStore;
|
|
334
|
+
declare const index$b_ExecutorLocalState: typeof ExecutorLocalState;
|
|
335
|
+
type index$b_GraphAgentExecutor = GraphAgentExecutor;
|
|
336
|
+
declare const index$b_GraphAgentExecutor: typeof GraphAgentExecutor;
|
|
337
|
+
type index$b_GraphAgentExecutorDependencies = GraphAgentExecutorDependencies;
|
|
338
|
+
declare const index$b_GraphExecutor: typeof GraphExecutor;
|
|
339
|
+
type index$b_GraphExecutorContextBuildInput = GraphExecutorContextBuildInput;
|
|
340
|
+
type index$b_GraphExecutorContextBuildOutput = GraphExecutorContextBuildOutput;
|
|
341
|
+
type index$b_GraphExecutorContextBuilder = GraphExecutorContextBuilder;
|
|
342
|
+
declare const index$b_GraphNode: typeof GraphNode;
|
|
343
|
+
type index$b_LlmNode = LlmNode;
|
|
344
|
+
declare const index$b_LlmNode: typeof LlmNode;
|
|
345
|
+
type index$b_MemoryCheckpointer = MemoryCheckpointer;
|
|
346
|
+
declare const index$b_MemoryCheckpointer: typeof MemoryCheckpointer;
|
|
347
|
+
declare const index$b_MemoryEventStore: typeof MemoryEventStore;
|
|
348
|
+
type index$b_PendingContextRuntimeEvent = PendingContextRuntimeEvent;
|
|
349
|
+
declare const index$b_PersistedEvent: typeof PersistedEvent;
|
|
350
|
+
type index$b_ToolNode = ToolNode;
|
|
351
|
+
declare const index$b_ToolNode: typeof ToolNode;
|
|
352
|
+
type index$b_UserNode = UserNode;
|
|
353
|
+
declare const index$b_UserNode: typeof UserNode;
|
|
354
|
+
type index$b_WaitUserNode = WaitUserNode;
|
|
355
|
+
declare const index$b_WaitUserNode: typeof WaitUserNode;
|
|
356
|
+
declare const index$b_createMonotonicEventIdFactory: typeof createMonotonicEventIdFactory;
|
|
357
|
+
declare const index$b_summarizeCheckpoint: typeof summarizeCheckpoint;
|
|
358
|
+
declare namespace index$b {
|
|
359
|
+
export { index$b_AnswerNode as AnswerNode, index$b_CheckpointListFilter as CheckpointListFilter, index$b_CheckpointMeta as CheckpointMeta, index$b_CheckpointSummary as CheckpointSummary, index$b_Checkpointer as Checkpointer, index$b_ENGINE_STATE_SCHEMA_VERSION as ENGINE_STATE_SCHEMA_VERSION, index$b_EngineState as EngineState, index$b_EventRangeOptions as EventRangeOptions, index$b_EventStore as EventStore, index$b_ExecutorLocalState as ExecutorLocalState, index$b_GraphAgentExecutor as GraphAgentExecutor, type index$b_GraphAgentExecutorDependencies as GraphAgentExecutorDependencies, index$b_GraphExecutor as GraphExecutor, type index$b_GraphExecutorContextBuildInput as GraphExecutorContextBuildInput, type index$b_GraphExecutorContextBuildOutput as GraphExecutorContextBuildOutput, type index$b_GraphExecutorContextBuilder as GraphExecutorContextBuilder, index$b_GraphNode as GraphNode, index$b_LlmNode as LlmNode, index$b_MemoryCheckpointer as MemoryCheckpointer, index$b_MemoryEventStore as MemoryEventStore, type index$b_PendingContextRuntimeEvent as PendingContextRuntimeEvent, index$b_PersistedEvent as PersistedEvent, index$b_ToolNode as ToolNode, index$b_UserNode as UserNode, index$b_WaitUserNode as WaitUserNode, index$b_createMonotonicEventIdFactory as createMonotonicEventIdFactory, index$b_summarizeCheckpoint as summarizeCheckpoint };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
interface ContextCheckpointToolArgs extends ToolArgs {
|
|
363
|
+
summary?: unknown;
|
|
364
|
+
}
|
|
365
|
+
interface ContextCheckpointPayload extends Record<string, unknown> {
|
|
366
|
+
_type: typeof CHECKPOINT_MARKER_TYPE;
|
|
367
|
+
summary: string;
|
|
368
|
+
}
|
|
369
|
+
interface ContextCheckpointToolHookParams {
|
|
370
|
+
args: ContextCheckpointToolArgs;
|
|
371
|
+
context: ToolExecutionContext;
|
|
372
|
+
summary: string;
|
|
373
|
+
}
|
|
374
|
+
type ContextCheckpointPayloadExtension = Record<string, unknown> | void | undefined;
|
|
375
|
+
interface ContextCheckpointToolOptions {
|
|
376
|
+
/**
|
|
377
|
+
* 工具名。必须与 `AgentSpec.contextPolicy.checkpoint.triggerToolName` 保持一致。
|
|
378
|
+
*/
|
|
379
|
+
name?: string;
|
|
380
|
+
/**
|
|
381
|
+
* 工具描述。host 可以替换成更贴合自己状态系统的文案。
|
|
382
|
+
*/
|
|
383
|
+
description?: string;
|
|
384
|
+
/**
|
|
385
|
+
* summary 最大字符数。
|
|
386
|
+
*/
|
|
387
|
+
summaryMaxLength?: number;
|
|
388
|
+
/**
|
|
389
|
+
* host 额外参数 schema,例如 taskstate / references。
|
|
390
|
+
*/
|
|
391
|
+
extraParameters?: Record<string, ToolParameterProperty>;
|
|
392
|
+
/**
|
|
393
|
+
* host 额外 required 字段。`summary` 永远必填。
|
|
394
|
+
*/
|
|
395
|
+
requiredExtraParameters?: string[];
|
|
396
|
+
/**
|
|
397
|
+
* 扩展 checkpoint payload。返回值会被合并到 data 中,但 `_type` 与 `summary`
|
|
398
|
+
* 由 framework 最后写入,host 不能覆盖协议核心字段。
|
|
399
|
+
*/
|
|
400
|
+
buildPayloadExtension?: (params: ContextCheckpointToolHookParams) => Promise<ContextCheckpointPayloadExtension> | ContextCheckpointPayloadExtension;
|
|
401
|
+
/**
|
|
402
|
+
* 自定义给模型看的 observation 文本。不影响 provider 识别;provider 只读 raw output marker。
|
|
403
|
+
*/
|
|
404
|
+
buildObservation?: (params: ContextCheckpointToolHookParams & {
|
|
405
|
+
payload: ContextCheckpointPayload;
|
|
406
|
+
}) => Promise<string> | string;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* host-neutral 的最小 checkpoint 工具。
|
|
410
|
+
*
|
|
411
|
+
* 中文备注:
|
|
412
|
+
* - 它只负责输出 linnkit 能识别的 checkpoint marker;
|
|
413
|
+
* - TaskState / SharedMemory / 外部文档写入属于 host 能力,可通过 hook 扩展;
|
|
414
|
+
* - host 不注册这个工具时,主动 checkpoint 行为不会启用。
|
|
415
|
+
*/
|
|
416
|
+
declare class ContextCheckpointTool extends BaseTool<ContextCheckpointToolArgs, string> {
|
|
417
|
+
readonly name: string;
|
|
418
|
+
readonly description: string;
|
|
419
|
+
readonly parameters: ToolParameterSchema;
|
|
420
|
+
private readonly summaryMaxLength;
|
|
421
|
+
private readonly buildPayloadExtension?;
|
|
422
|
+
private readonly buildObservation?;
|
|
423
|
+
constructor(options?: ContextCheckpointToolOptions);
|
|
424
|
+
run(args: ContextCheckpointToolArgs, context: ToolExecutionContext): Promise<string>;
|
|
425
|
+
}
|
|
426
|
+
declare function createContextCheckpointTool(options?: ContextCheckpointToolOptions): ContextCheckpointTool;
|
|
427
|
+
|
|
428
|
+
type UnknownRecord = Record<string, unknown>;
|
|
429
|
+
type NormalizeToolArgsOptions = {
|
|
430
|
+
toolName?: string;
|
|
431
|
+
path?: string;
|
|
432
|
+
};
|
|
433
|
+
declare function normalizeToolArgs(schema: ToolParameterSchema, args: UnknownRecord, options?: NormalizeToolArgsOptions): UnknownRecord;
|
|
434
|
+
|
|
435
|
+
type RuntimeEventSource = () => ReadonlyArray<RuntimeEvent>;
|
|
436
|
+
interface ToolContextExecutionMeta {
|
|
437
|
+
conversationId?: string;
|
|
438
|
+
turnId?: string;
|
|
439
|
+
runId?: string;
|
|
440
|
+
parentRunId?: string;
|
|
441
|
+
parentToolCallId?: string;
|
|
442
|
+
citationOffset?: number;
|
|
443
|
+
}
|
|
444
|
+
interface ToolContextRuntimeBinding {
|
|
445
|
+
readonly conversationView: ToolContextConversationView;
|
|
446
|
+
getWorkingHistoryEvents(): ReadonlyArray<RuntimeEvent>;
|
|
447
|
+
getPersistedHistoryEvents(): ReadonlyArray<RuntimeEvent>;
|
|
448
|
+
setWorkingHistorySource(source: ReadonlyArray<RuntimeEvent> | RuntimeEventSource): void;
|
|
449
|
+
setPersistedHistorySource(source: ReadonlyArray<RuntimeEvent> | RuntimeEventSource): void;
|
|
450
|
+
bindExecutionMeta(meta: ToolContextExecutionMeta): void;
|
|
451
|
+
readExecutionMeta(): Readonly<ToolContextExecutionMeta>;
|
|
452
|
+
}
|
|
453
|
+
declare function ensureToolContextRuntimeCapability(params: {
|
|
454
|
+
context: ToolExecutionContext;
|
|
455
|
+
persistedHistory?: ReadonlyArray<RuntimeEvent> | RuntimeEventSource;
|
|
456
|
+
workingHistory?: ReadonlyArray<RuntimeEvent> | RuntimeEventSource;
|
|
457
|
+
executionMeta?: ToolContextExecutionMeta;
|
|
458
|
+
}): ToolContextRuntimeBinding;
|
|
459
|
+
declare function getToolContextRuntimeBinding(context: ToolExecutionContext): ToolContextRuntimeBinding | undefined;
|
|
460
|
+
declare function readToolContextWorkingHistory(context: ToolExecutionContext): ReadonlyArray<RuntimeEvent>;
|
|
461
|
+
declare function readToolContextPersistedHistory(context: ToolExecutionContext): ReadonlyArray<RuntimeEvent>;
|
|
462
|
+
declare function stripRuntimeReservedToolContextPatch(patch: Partial<ToolExecutionContext> | Record<string, unknown> | undefined): Record<string, unknown>;
|
|
463
|
+
|
|
464
|
+
declare const index$a_AgentTool: typeof AgentTool;
|
|
465
|
+
declare const index$a_BaseTool: typeof BaseTool;
|
|
466
|
+
declare const index$a_CommonParameterTypes: typeof CommonParameterTypes;
|
|
467
|
+
type index$a_ContextCheckpointPayload = ContextCheckpointPayload;
|
|
468
|
+
type index$a_ContextCheckpointPayloadExtension = ContextCheckpointPayloadExtension;
|
|
469
|
+
type index$a_ContextCheckpointTool = ContextCheckpointTool;
|
|
470
|
+
declare const index$a_ContextCheckpointTool: typeof ContextCheckpointTool;
|
|
471
|
+
type index$a_ContextCheckpointToolArgs = ContextCheckpointToolArgs;
|
|
472
|
+
type index$a_ContextCheckpointToolHookParams = ContextCheckpointToolHookParams;
|
|
473
|
+
type index$a_ContextCheckpointToolOptions = ContextCheckpointToolOptions;
|
|
474
|
+
declare const index$a_ConversationArtifactContext: typeof ConversationArtifactContext;
|
|
475
|
+
declare const index$a_JsonObjectSchema: typeof JsonObjectSchema;
|
|
476
|
+
declare const index$a_ObservationPreviewContext: typeof ObservationPreviewContext;
|
|
477
|
+
declare const index$a_ObservationPreviewMeta: typeof ObservationPreviewMeta;
|
|
478
|
+
declare const index$a_ObservationPreviewPort: typeof ObservationPreviewPort;
|
|
479
|
+
declare const index$a_ObservationPreviewResult: typeof ObservationPreviewResult;
|
|
480
|
+
declare const index$a_OpenAIToolSchema: typeof OpenAIToolSchema;
|
|
481
|
+
declare const index$a_StructuredToolResult: typeof StructuredToolResult;
|
|
482
|
+
declare const index$a_ToolArgs: typeof ToolArgs;
|
|
483
|
+
declare const index$a_ToolCallResult: typeof ToolCallResult;
|
|
484
|
+
declare const index$a_ToolCatalogPort: typeof ToolCatalogPort;
|
|
485
|
+
declare const index$a_ToolContextCompatibilityFields: typeof ToolContextCompatibilityFields;
|
|
486
|
+
declare const index$a_ToolContextConversationView: typeof ToolContextConversationView;
|
|
487
|
+
declare const index$a_ToolContextPatch: typeof ToolContextPatch;
|
|
488
|
+
declare const index$a_ToolControlInfo: typeof ToolControlInfo;
|
|
489
|
+
declare const index$a_ToolDisplayOptions: typeof ToolDisplayOptions;
|
|
490
|
+
declare const index$a_ToolExecutionContext: typeof ToolExecutionContext;
|
|
491
|
+
declare const index$a_ToolExecutionPort: typeof ToolExecutionPort;
|
|
492
|
+
declare const index$a_ToolExecutionResult: typeof ToolExecutionResult;
|
|
493
|
+
declare const index$a_ToolLayoutOptions: typeof ToolLayoutOptions;
|
|
494
|
+
declare const index$a_ToolParameterProperty: typeof ToolParameterProperty;
|
|
495
|
+
declare const index$a_ToolParameterSchema: typeof ToolParameterSchema;
|
|
496
|
+
declare const index$a_ToolPresentationPort: typeof ToolPresentationPort;
|
|
497
|
+
declare const index$a_ToolRegistryEntry: typeof ToolRegistryEntry;
|
|
498
|
+
declare const index$a_ToolResult: typeof ToolResult;
|
|
499
|
+
declare const index$a_ToolRuntimeDefinition: typeof ToolRuntimeDefinition;
|
|
500
|
+
declare const index$a_ToolRuntimePort: typeof ToolRuntimePort;
|
|
501
|
+
declare const index$a_ToolSchemaContext: typeof ToolSchemaContext;
|
|
502
|
+
declare const index$a_UnifiedToolResult: typeof UnifiedToolResult;
|
|
503
|
+
declare const index$a_computeToolIdempotencyKey: typeof computeToolIdempotencyKey;
|
|
504
|
+
declare const index$a_createContextCheckpointTool: typeof createContextCheckpointTool;
|
|
505
|
+
declare const index$a_ensureToolContextRuntimeCapability: typeof ensureToolContextRuntimeCapability;
|
|
506
|
+
declare const index$a_findCachedToolOutputByIdempotencyKey: typeof findCachedToolOutputByIdempotencyKey;
|
|
507
|
+
declare const index$a_getToolContextRuntimeBinding: typeof getToolContextRuntimeBinding;
|
|
508
|
+
declare const index$a_normalizeToolArgs: typeof normalizeToolArgs;
|
|
509
|
+
declare const index$a_readToolContextModelId: typeof readToolContextModelId;
|
|
510
|
+
declare const index$a_readToolContextPersistedHistory: typeof readToolContextPersistedHistory;
|
|
511
|
+
declare const index$a_readToolContextRunContext: typeof readToolContextRunContext;
|
|
512
|
+
declare const index$a_readToolContextUserQuery: typeof readToolContextUserQuery;
|
|
513
|
+
declare const index$a_readToolContextWorkingHistory: typeof readToolContextWorkingHistory;
|
|
514
|
+
declare const index$a_stripRuntimeReservedToolContextPatch: typeof stripRuntimeReservedToolContextPatch;
|
|
515
|
+
declare namespace index$a {
|
|
516
|
+
export { index$a_AgentTool as AgentTool, index$a_BaseTool as BaseTool, index$a_CommonParameterTypes as CommonParameterTypes, type index$a_ContextCheckpointPayload as ContextCheckpointPayload, type index$a_ContextCheckpointPayloadExtension as ContextCheckpointPayloadExtension, index$a_ContextCheckpointTool as ContextCheckpointTool, type index$a_ContextCheckpointToolArgs as ContextCheckpointToolArgs, type index$a_ContextCheckpointToolHookParams as ContextCheckpointToolHookParams, type index$a_ContextCheckpointToolOptions as ContextCheckpointToolOptions, index$a_ConversationArtifactContext as ConversationArtifactContext, index$a_JsonObjectSchema as JsonObjectSchema, index$a_ObservationPreviewContext as ObservationPreviewContext, index$a_ObservationPreviewMeta as ObservationPreviewMeta, index$a_ObservationPreviewPort as ObservationPreviewPort, index$a_ObservationPreviewResult as ObservationPreviewResult, index$a_OpenAIToolSchema as OpenAIToolSchema, index$a_StructuredToolResult as StructuredToolResult, index$a_ToolArgs as ToolArgs, index$a_ToolCallResult as ToolCallResult, index$a_ToolCatalogPort as ToolCatalogPort, index$a_ToolContextCompatibilityFields as ToolContextCompatibilityFields, index$a_ToolContextConversationView as ToolContextConversationView, index$a_ToolContextPatch as ToolContextPatch, index$a_ToolControlInfo as ToolControlInfo, index$a_ToolDisplayOptions as ToolDisplayOptions, index$a_ToolExecutionContext as ToolExecutionContext, index$a_ToolExecutionPort as ToolExecutionPort, index$a_ToolExecutionResult as ToolExecutionResult, index$a_ToolLayoutOptions as ToolLayoutOptions, index$a_ToolParameterProperty as ToolParameterProperty, index$a_ToolParameterSchema as ToolParameterSchema, index$a_ToolPresentationPort as ToolPresentationPort, index$a_ToolRegistryEntry as ToolRegistryEntry, index$a_ToolResult as ToolResult, index$a_ToolRuntimeDefinition as ToolRuntimeDefinition, index$a_ToolRuntimePort as ToolRuntimePort, index$a_ToolSchemaContext as ToolSchemaContext, index$a_UnifiedToolResult as UnifiedToolResult, index$a_computeToolIdempotencyKey as computeToolIdempotencyKey, index$a_createContextCheckpointTool as createContextCheckpointTool, index$a_ensureToolContextRuntimeCapability as ensureToolContextRuntimeCapability, index$a_findCachedToolOutputByIdempotencyKey as findCachedToolOutputByIdempotencyKey, index$a_getToolContextRuntimeBinding as getToolContextRuntimeBinding, index$a_normalizeToolArgs as normalizeToolArgs, index$a_readToolContextModelId as readToolContextModelId, index$a_readToolContextPersistedHistory as readToolContextPersistedHistory, index$a_readToolContextRunContext as readToolContextRunContext, index$a_readToolContextUserQuery as readToolContextUserQuery, index$a_readToolContextWorkingHistory as readToolContextWorkingHistory, index$a_stripRuntimeReservedToolContextPatch as stripRuntimeReservedToolContextPatch };
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @file src/agent/runtime-kernel/execution/sequencer.ts
|
|
521
|
+
* @description 事件序列器 - 为事件分配序号和执行上下文
|
|
522
|
+
*
|
|
523
|
+
* 功能 (What):
|
|
524
|
+
* - 为每个执行流程生成唯一的 execution_id
|
|
525
|
+
* - 为事件分配单调递增的序号 (seq)
|
|
526
|
+
* - 将 RuntimeEvent 包装为 EventEnvelope,提供追踪和渲染元数据
|
|
527
|
+
*
|
|
528
|
+
* 输入 (Input):
|
|
529
|
+
* - RuntimeEvent 或原始事件数据
|
|
530
|
+
* - source 信息(事件来源)
|
|
531
|
+
*
|
|
532
|
+
* 输出 (Output):
|
|
533
|
+
* - EventEnvelope 包装的事件
|
|
534
|
+
*
|
|
535
|
+
* 副作用 (Side-effects):
|
|
536
|
+
* - 维护内存中的序号状态
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* 事件序列器类
|
|
541
|
+
*
|
|
542
|
+
* 职责:
|
|
543
|
+
* - 管理执行上下文(execution_id, trace_id)
|
|
544
|
+
* - 为事件分配严格递增的序号
|
|
545
|
+
* - 提供事件包装功能
|
|
546
|
+
*/
|
|
547
|
+
declare class EventSequencer {
|
|
548
|
+
private readonly executionId;
|
|
549
|
+
private readonly traceId;
|
|
550
|
+
private currentSeq;
|
|
551
|
+
constructor(conversationId: string, traceId?: string);
|
|
552
|
+
/**
|
|
553
|
+
* 获取执行上下文
|
|
554
|
+
*/
|
|
555
|
+
getExecutionContext(): ExecutionTraceContext;
|
|
556
|
+
/**
|
|
557
|
+
* 获取下一个序号
|
|
558
|
+
* 这个方法是线程安全的,因为 Node.js 是单线程的
|
|
559
|
+
*/
|
|
560
|
+
private getNextSeq;
|
|
561
|
+
/**
|
|
562
|
+
* 将 RuntimeEvent 包装为 EventEnvelope
|
|
563
|
+
*
|
|
564
|
+
* @param runtimeEvent - 需要包装的运行时事件
|
|
565
|
+
* @param source - 事件来源标识
|
|
566
|
+
* @param renderHint - 可选的渲染建议
|
|
567
|
+
* @param runLocation - 可选的执行位置
|
|
568
|
+
* @returns 包装后的事件信封
|
|
569
|
+
*/
|
|
570
|
+
wrapEvent(runtimeEvent: RuntimeEvent, source: string, options?: {
|
|
571
|
+
renderHint?: EventEnvelope<RuntimeEvent>['render_hint'];
|
|
572
|
+
runLocation?: EventEnvelope<RuntimeEvent>['run_location'];
|
|
573
|
+
}): EventEnvelope<RuntimeEvent>;
|
|
574
|
+
/**
|
|
575
|
+
* 获取当前序号(调试用)
|
|
576
|
+
*/
|
|
577
|
+
getCurrentSeq(): number;
|
|
578
|
+
/**
|
|
579
|
+
* 获取执行ID(调试用)
|
|
580
|
+
*/
|
|
581
|
+
getExecutionId(): string;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
interface CreateRuntimeErrorEventInput {
|
|
585
|
+
/**
|
|
586
|
+
* 可选:由调用方提供稳定 id(例如 generateMessageId())。
|
|
587
|
+
* 若不提供,工厂会生成一个临时 id。
|
|
588
|
+
*/
|
|
589
|
+
id?: string;
|
|
590
|
+
conversationId: string;
|
|
591
|
+
turnId: string;
|
|
592
|
+
error: unknown;
|
|
593
|
+
/**
|
|
594
|
+
* 事件来源,用于排查(不会直接展示给用户)。
|
|
595
|
+
*/
|
|
596
|
+
source?: string;
|
|
597
|
+
/**
|
|
598
|
+
* 可选:覆盖 error_code(例如 SUMMARIZATION_FAILED)。
|
|
599
|
+
*/
|
|
600
|
+
errorCode?: string;
|
|
601
|
+
/**
|
|
602
|
+
* 可选:覆盖 retryable。
|
|
603
|
+
*/
|
|
604
|
+
retryable?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* 可选:覆盖 error 文本(默认使用原始 error.message)。
|
|
607
|
+
* 注意:这不是“用户友好化文案”,只是允许在系统级错误里加上更明确的上下文前缀。
|
|
608
|
+
*/
|
|
609
|
+
errorText?: string;
|
|
610
|
+
/**
|
|
611
|
+
* 可选:合并到 details 的附加字段(便于调用方补充上下文信息)。
|
|
612
|
+
*/
|
|
613
|
+
detailsPatch?: Record<string, unknown>;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* 统一创建 RuntimeEvent(type='error')。
|
|
617
|
+
*
|
|
618
|
+
* 中文备注:
|
|
619
|
+
* - `error` 字段保留原始 message(前端负责友好化);
|
|
620
|
+
* - `error_code` 尽量稳定:优先上游结构化 type,否则 fallback 到分类结果;
|
|
621
|
+
* - `retryable` 与 `details.classification` 使用同一份 classifier 输出,避免重复判断。
|
|
622
|
+
*/
|
|
623
|
+
declare function createRuntimeErrorEvent(input: CreateRuntimeErrorEventInput): ErrorEvent;
|
|
624
|
+
|
|
625
|
+
declare const index$9_EventBus: typeof EventBus;
|
|
626
|
+
type index$9_EventSequencer = EventSequencer;
|
|
627
|
+
declare const index$9_EventSequencer: typeof EventSequencer;
|
|
628
|
+
declare const index$9_createRuntimeErrorEvent: typeof createRuntimeErrorEvent;
|
|
629
|
+
declare namespace index$9 {
|
|
630
|
+
export { index$9_EventBus as EventBus, index$9_EventSequencer as EventSequencer, index$9_createRuntimeErrorEvent as createRuntimeErrorEvent };
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
declare const index$8_RunContext: typeof RunContext;
|
|
634
|
+
declare const index$8_createDefaultRunContext: typeof createDefaultRunContext;
|
|
635
|
+
declare namespace index$8 {
|
|
636
|
+
export { index$8_RunContext as RunContext, index$8_createDefaultRunContext as createDefaultRunContext };
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* @file src/agent/runtime-kernel/child-runs/childRunInvoker.ts
|
|
641
|
+
* @description child-run 调用器
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
interface ChildRunAgentConfig {
|
|
645
|
+
id: string;
|
|
646
|
+
promptKey: string;
|
|
647
|
+
availableTools?: readonly string[];
|
|
648
|
+
modelPolicy?: {
|
|
649
|
+
kind: 'fixed';
|
|
650
|
+
modelId: string;
|
|
651
|
+
};
|
|
652
|
+
stepPolicy?: {
|
|
653
|
+
kind: 'final_answer' | 'force_tools';
|
|
654
|
+
lastStepsHintThreshold?: number;
|
|
655
|
+
forcedTools?: readonly string[];
|
|
656
|
+
};
|
|
657
|
+
contextPolicy?: AgentSpecContextPolicy;
|
|
658
|
+
systemReminderPolicy?: AgentSpecSystemReminderPolicy;
|
|
659
|
+
systemPromptBuilder?: (request: AgentInvocationRequest) => string;
|
|
660
|
+
judgeToolName?: string;
|
|
661
|
+
}
|
|
662
|
+
interface ChildRunInvokeConfig {
|
|
663
|
+
agentConfig: ChildRunAgentConfig;
|
|
664
|
+
userMessage: string;
|
|
665
|
+
parentToolContext: ChildRunParentContext;
|
|
666
|
+
runId?: string;
|
|
667
|
+
parentRunId?: string;
|
|
668
|
+
abortSignal?: AbortSignal;
|
|
669
|
+
subrunTracePublisher?: SubRunTracePublisher;
|
|
670
|
+
seedHistoryEvents?: RuntimeEvent[];
|
|
671
|
+
maxSteps?: number;
|
|
672
|
+
modelId?: string;
|
|
673
|
+
}
|
|
674
|
+
interface ChildRunInvokeResult {
|
|
675
|
+
runId?: string;
|
|
676
|
+
parentRunId?: string;
|
|
677
|
+
success: boolean;
|
|
678
|
+
judgeToolOutput?: string;
|
|
679
|
+
finalAnswer?: string;
|
|
680
|
+
events: RuntimeEvent[];
|
|
681
|
+
stepCount: number;
|
|
682
|
+
error?: string;
|
|
683
|
+
}
|
|
684
|
+
declare class ChildRunInvoker {
|
|
685
|
+
private readonly modelResolver;
|
|
686
|
+
private readonly createLlmNode;
|
|
687
|
+
private readonly toolRuntime;
|
|
688
|
+
private readonly observationPreview;
|
|
689
|
+
private readonly eventToMessageConverter;
|
|
690
|
+
private readonly defaultJudgeToolName?;
|
|
691
|
+
private readonly telemetryPort;
|
|
692
|
+
private readonly auditPort;
|
|
693
|
+
constructor(dependencies: {
|
|
694
|
+
modelResolver: Pick<ModelResolverLike, 'resolveModelId'>;
|
|
695
|
+
createLlmNode: () => GraphNode;
|
|
696
|
+
toolRuntime: Pick<ToolRuntimePort, 'getToolDefinition' | 'executeTool'>;
|
|
697
|
+
observationPreview: ObservationPreviewPort;
|
|
698
|
+
eventToMessageConverter: (events: RuntimeEvent[]) => unknown[];
|
|
699
|
+
defaultJudgeToolName?: string;
|
|
700
|
+
telemetryPort?: TelemetryPort;
|
|
701
|
+
auditPort?: AuditPort;
|
|
702
|
+
});
|
|
703
|
+
invoke(config: ChildRunInvokeConfig): Promise<ChildRunInvokeResult>;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
declare function pickChildRunSeedHistory(params: {
|
|
707
|
+
parentHistory: ReadonlyArray<RuntimeEvent>;
|
|
708
|
+
historyPolicy?: ChildRunHistoryPolicy;
|
|
709
|
+
}): RuntimeEvent[];
|
|
710
|
+
|
|
711
|
+
type index$7_ChildRunAgentConfig = ChildRunAgentConfig;
|
|
712
|
+
type index$7_ChildRunInvokeConfig = ChildRunInvokeConfig;
|
|
713
|
+
type index$7_ChildRunInvokeResult = ChildRunInvokeResult;
|
|
714
|
+
type index$7_ChildRunInvoker = ChildRunInvoker;
|
|
715
|
+
declare const index$7_ChildRunInvoker: typeof ChildRunInvoker;
|
|
716
|
+
declare const index$7_ChildRunInvokerPort: typeof ChildRunInvokerPort;
|
|
717
|
+
declare const index$7_ChildRunRequest: typeof ChildRunRequest;
|
|
718
|
+
declare const index$7_ChildRunResult: typeof ChildRunResult;
|
|
719
|
+
declare const index$7_pickChildRunSeedHistory: typeof pickChildRunSeedHistory;
|
|
720
|
+
declare namespace index$7 {
|
|
721
|
+
export { type index$7_ChildRunAgentConfig as ChildRunAgentConfig, type index$7_ChildRunInvokeConfig as ChildRunInvokeConfig, type index$7_ChildRunInvokeResult as ChildRunInvokeResult, index$7_ChildRunInvoker as ChildRunInvoker, index$7_ChildRunInvokerPort as ChildRunInvokerPort, index$7_ChildRunRequest as ChildRunRequest, index$7_ChildRunResult as ChildRunResult, index$7_pickChildRunSeedHistory as pickChildRunSeedHistory };
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
interface EventBusSubRunTracePublisherOptions {
|
|
725
|
+
eventBus: EventBus;
|
|
726
|
+
sequencer: EventSequencer;
|
|
727
|
+
/** 父会话上下文:用于填充 RuntimeEvent 基础字段 */
|
|
728
|
+
conversationId: string;
|
|
729
|
+
turnId: string;
|
|
730
|
+
/** 绑定关系:用于 UI 精确归属与并发分桶 */
|
|
731
|
+
parentToolCallId: string;
|
|
732
|
+
subrunId: string;
|
|
733
|
+
subrunParentId?: string;
|
|
734
|
+
/**
|
|
735
|
+
* 事件来源(用于调试与过滤)
|
|
736
|
+
* 建议格式:`subrun:<tool_name>` 或 `tool:<tool_name>:subrun`
|
|
737
|
+
*/
|
|
738
|
+
source?: string;
|
|
739
|
+
/**
|
|
740
|
+
* 透传到 RuntimeEvent.metadata 的扩展字段(可选)
|
|
741
|
+
* 注意:subrun_trace 默认不持久化,但 metadata 仍会随 SSE 推送给前端用于调试/归类。
|
|
742
|
+
*/
|
|
743
|
+
metadata?: Record<string, unknown>;
|
|
744
|
+
/**
|
|
745
|
+
* 是否持久化 subrun_trace(用于历史回放)。
|
|
746
|
+
*
|
|
747
|
+
* 默认 false:
|
|
748
|
+
* - subrun_trace 为高频增量过程事件,写入事实事件表会造成体积膨胀;
|
|
749
|
+
* - 因此默认只走实时 SSE(ephemeral=true),不落库。
|
|
750
|
+
*
|
|
751
|
+
* 仅当业务明确需要“回放时可重建子过程”才应开启(例如 task 通用子 Agent)。
|
|
752
|
+
*
|
|
753
|
+
* ⚠️ 注意:
|
|
754
|
+
* - 即使开启持久化,该事件仍属于 UI-only 数据;
|
|
755
|
+
* - ContextManager 构建 LLM 上下文时必须过滤该类事件,避免污染父会话上下文。
|
|
756
|
+
*/
|
|
757
|
+
persistForReplay?: boolean;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* EventBusSubRunTracePublisher
|
|
761
|
+
*
|
|
762
|
+
* 说明:
|
|
763
|
+
* - 该发布器在构造时绑定 parent_tool_call_id 与 subrun_id;
|
|
764
|
+
* - 每次 publish 只需要提供“分片载荷”(kind/delta/...)即可。
|
|
765
|
+
*/
|
|
766
|
+
declare class EventBusSubRunTracePublisher implements SubRunTracePublisher {
|
|
767
|
+
private readonly eventBus;
|
|
768
|
+
private readonly sequencer;
|
|
769
|
+
private readonly conversationId;
|
|
770
|
+
private readonly turnId;
|
|
771
|
+
private readonly parentToolCallId;
|
|
772
|
+
private readonly subrunId;
|
|
773
|
+
private readonly subrunParentId?;
|
|
774
|
+
private readonly source;
|
|
775
|
+
private readonly metadata?;
|
|
776
|
+
private readonly persistForReplay;
|
|
777
|
+
constructor(options: EventBusSubRunTracePublisherOptions);
|
|
778
|
+
publish(envelope: SubRunTraceEnvelope): void;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
type index$6_EventBusSubRunTracePublisher = EventBusSubRunTracePublisher;
|
|
782
|
+
declare const index$6_EventBusSubRunTracePublisher: typeof EventBusSubRunTracePublisher;
|
|
783
|
+
declare const index$6_SubRunTracePublisher: typeof SubRunTracePublisher;
|
|
784
|
+
declare namespace index$6 {
|
|
785
|
+
export { index$6_EventBusSubRunTracePublisher as EventBusSubRunTracePublisher, index$6_SubRunTracePublisher as SubRunTracePublisher };
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* @file src/agent/runtime-kernel/enrichment/types.ts
|
|
790
|
+
* @description 请求增强器(Request Enricher)接口定义
|
|
791
|
+
*
|
|
792
|
+
* 核心目标:
|
|
793
|
+
* - 将业务特定的上下文组装逻辑(如 Review 的角色解析等)从主循环剥离
|
|
794
|
+
* - 提供统一的扩展点,主循环只负责调度,不感知具体业务
|
|
795
|
+
*/
|
|
796
|
+
|
|
797
|
+
interface EnrichmentContext {
|
|
798
|
+
/**
|
|
799
|
+
* 当前会话 ID
|
|
800
|
+
*
|
|
801
|
+
* 中文备注:
|
|
802
|
+
* - RequestEnricher 的目标是"把业务特定逻辑从主循环剥离",但它仍然是"针对某个会话的增强";
|
|
803
|
+
* - Deep Research / Review 等业务常需要读取/写入会话级状态(例如 conversations.metadata),
|
|
804
|
+
* 因此把 conversationId 纳入 enrichment 上下文是结构性必需条件;
|
|
805
|
+
* - 该字段是运行期上下文,不属于模型输入。
|
|
806
|
+
*/
|
|
807
|
+
conversationId: string;
|
|
808
|
+
/** 原始请求(运行时为 AgentInvokeRequest,runtime 只依赖 AgentInvocationRequest 协议面) */
|
|
809
|
+
request: AgentInvocationRequest;
|
|
810
|
+
/** 当前运行上下文 */
|
|
811
|
+
runContext: RunContext;
|
|
812
|
+
}
|
|
813
|
+
interface EnrichmentResult {
|
|
814
|
+
/**
|
|
815
|
+
* 增强后的请求对象(例如:补全了 system_prompt / knowledge 变量)
|
|
816
|
+
* - 如果不需要修改,可返回原对象
|
|
817
|
+
*/
|
|
818
|
+
request: AgentInvocationRequest;
|
|
819
|
+
/**
|
|
820
|
+
* 需要注入到 ToolContext 的额外数据
|
|
821
|
+
* - 例如:Review 场景下的 block_map (已废弃) 或 review_run_id 等元信息
|
|
822
|
+
* - 这些数据仅工具可见,模型不可见
|
|
823
|
+
*/
|
|
824
|
+
toolContextPatch?: ToolContextPatch;
|
|
825
|
+
/**
|
|
826
|
+
* 对 RunContext 的更新(可选)
|
|
827
|
+
* - 例如:业务层解析出了更准确的 traceId 或 tags
|
|
828
|
+
*/
|
|
829
|
+
runContextPatch?: Partial<RunContext>;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Registry 输出的最终增强结果
|
|
833
|
+
*
|
|
834
|
+
* 说明:
|
|
835
|
+
* - `RequestEnricher.enrich()` 返回 patch(增量)
|
|
836
|
+
* - Registry 会把所有 patch 串行合并,并返回最终的 `runContext`
|
|
837
|
+
*/
|
|
838
|
+
interface RegistryEnrichmentResult {
|
|
839
|
+
request: AgentInvocationRequest;
|
|
840
|
+
toolContextPatch?: ToolContextPatch;
|
|
841
|
+
runContext: RunContext;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* 请求增强器接口
|
|
845
|
+
*
|
|
846
|
+
* 中文备注:
|
|
847
|
+
* - runtime 层只依赖 AgentInvocationRequest 协议面;
|
|
848
|
+
* - 产品层 enricher 实现中,运行时收到的实际值是 AgentInvokeRequest(结构上满足 AgentInvocationRequest);
|
|
849
|
+
* - 需要访问产品级字段时,features 实现可在边界做安全窄化。
|
|
850
|
+
*/
|
|
851
|
+
interface RequestEnricher {
|
|
852
|
+
/** 增强器名称(用于调试/日志) */
|
|
853
|
+
name: string;
|
|
854
|
+
/**
|
|
855
|
+
* 判断该增强器是否适用于当前请求
|
|
856
|
+
* - 通常基于 promptKey 或 mode 判断
|
|
857
|
+
*/
|
|
858
|
+
isApplicable(request: AgentInvocationRequest): boolean;
|
|
859
|
+
/**
|
|
860
|
+
* 执行增强逻辑
|
|
861
|
+
* - 可以包含异步操作(查库、调 RPC 等)
|
|
862
|
+
*/
|
|
863
|
+
enrich(context: EnrichmentContext): Promise<EnrichmentResult>;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* @file src/agent/runtime-kernel/enrichment/registry.ts
|
|
868
|
+
* @description 请求增强器注册表
|
|
869
|
+
*/
|
|
870
|
+
|
|
871
|
+
declare class RequestEnricherRegistry {
|
|
872
|
+
private enrichers;
|
|
873
|
+
/**
|
|
874
|
+
* 注册增强器
|
|
875
|
+
*/
|
|
876
|
+
register(enricher: RequestEnricher): void;
|
|
877
|
+
/**
|
|
878
|
+
* 执行所有适用的增强器
|
|
879
|
+
* - 按注册顺序串行执行(后续增强器基于前序结果继续增强)
|
|
880
|
+
*/
|
|
881
|
+
enrich(context: EnrichmentContext): Promise<RegistryEnrichmentResult>;
|
|
882
|
+
}
|
|
883
|
+
declare const requestEnricherRegistry: RequestEnricherRegistry;
|
|
884
|
+
|
|
885
|
+
type index$5_EnrichmentContext = EnrichmentContext;
|
|
886
|
+
type index$5_EnrichmentResult = EnrichmentResult;
|
|
887
|
+
type index$5_RegistryEnrichmentResult = RegistryEnrichmentResult;
|
|
888
|
+
type index$5_RequestEnricher = RequestEnricher;
|
|
889
|
+
declare const index$5_requestEnricherRegistry: typeof requestEnricherRegistry;
|
|
890
|
+
declare namespace index$5 {
|
|
891
|
+
export { type index$5_EnrichmentContext as EnrichmentContext, type index$5_EnrichmentResult as EnrichmentResult, type index$5_RegistryEnrichmentResult as RegistryEnrichmentResult, type index$5_RequestEnricher as RequestEnricher, index$5_requestEnricherRegistry as requestEnricherRegistry };
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
declare class NotImplementedError extends Error {
|
|
895
|
+
constructor(message: string);
|
|
896
|
+
}
|
|
897
|
+
declare class RunNotFoundError extends Error {
|
|
898
|
+
constructor(runId: string);
|
|
899
|
+
}
|
|
900
|
+
declare class RunAlreadyRegisteredError extends Error {
|
|
901
|
+
readonly runId: string;
|
|
902
|
+
constructor(runId: string);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
declare const index$4_CancelOpts: typeof CancelOpts;
|
|
906
|
+
declare const index$4_DefaultRunHandle: typeof DefaultRunHandle;
|
|
907
|
+
declare const index$4_DefaultRunHandleOptions: typeof DefaultRunHandleOptions;
|
|
908
|
+
declare const index$4_DefaultRunSupervisor: typeof DefaultRunSupervisor;
|
|
909
|
+
declare const index$4_DefaultRunSupervisorOptions: typeof DefaultRunSupervisorOptions;
|
|
910
|
+
declare const index$4_FindActiveByConversationOptions: typeof FindActiveByConversationOptions;
|
|
911
|
+
declare const index$4_ListRunsFilter: typeof ListRunsFilter;
|
|
912
|
+
declare const index$4_MemoryRunRegistryStore: typeof MemoryRunRegistryStore;
|
|
913
|
+
type index$4_NotImplementedError = NotImplementedError;
|
|
914
|
+
declare const index$4_NotImplementedError: typeof NotImplementedError;
|
|
915
|
+
type index$4_RunAlreadyRegisteredError = RunAlreadyRegisteredError;
|
|
916
|
+
declare const index$4_RunAlreadyRegisteredError: typeof RunAlreadyRegisteredError;
|
|
917
|
+
declare const index$4_RunAwaitingUserPatch: typeof RunAwaitingUserPatch;
|
|
918
|
+
declare const index$4_RunCost: typeof RunCost;
|
|
919
|
+
declare const index$4_RunCostCollector: typeof RunCostCollector;
|
|
920
|
+
declare const index$4_RunExecutionContext: typeof RunExecutionContext;
|
|
921
|
+
declare const index$4_RunExecutorPort: typeof RunExecutorPort;
|
|
922
|
+
declare const index$4_RunFailureInfo: typeof RunFailureInfo;
|
|
923
|
+
declare const index$4_RunHandle: typeof RunHandle;
|
|
924
|
+
declare const index$4_RunLifecyclePatch: typeof RunLifecyclePatch;
|
|
925
|
+
declare const index$4_RunMeta: typeof RunMeta;
|
|
926
|
+
type index$4_RunNotFoundError = RunNotFoundError;
|
|
927
|
+
declare const index$4_RunNotFoundError: typeof RunNotFoundError;
|
|
928
|
+
declare const index$4_RunObserveFilter: typeof RunObserveFilter;
|
|
929
|
+
declare const index$4_RunOutcome: typeof RunOutcome;
|
|
930
|
+
declare const index$4_RunRecord: typeof RunRecord;
|
|
931
|
+
declare const index$4_RunRegistrationSpec: typeof RunRegistrationSpec;
|
|
932
|
+
declare const index$4_RunRegistryStore: typeof RunRegistryStore;
|
|
933
|
+
declare const index$4_RunRequestSnapshot: typeof RunRequestSnapshot;
|
|
934
|
+
declare const index$4_RunSnapshot: typeof RunSnapshot;
|
|
935
|
+
declare const index$4_RunStatus: typeof RunStatus;
|
|
936
|
+
declare const index$4_RunSupervisor: typeof RunSupervisor;
|
|
937
|
+
declare const index$4_RunTerminalError: typeof RunTerminalError;
|
|
938
|
+
declare const index$4_RunTerminalEvent: typeof RunTerminalEvent;
|
|
939
|
+
declare const index$4_RunTerminalStatus: typeof RunTerminalStatus;
|
|
940
|
+
declare const index$4_RunWaitForTerminalOptions: typeof RunWaitForTerminalOptions;
|
|
941
|
+
declare const index$4_runMetaFromRecord: typeof runMetaFromRecord;
|
|
942
|
+
declare namespace index$4 {
|
|
943
|
+
export { index$4_CancelOpts as CancelOpts, index$4_DefaultRunHandle as DefaultRunHandle, index$4_DefaultRunHandleOptions as DefaultRunHandleOptions, index$4_DefaultRunSupervisor as DefaultRunSupervisor, index$4_DefaultRunSupervisorOptions as DefaultRunSupervisorOptions, index$4_FindActiveByConversationOptions as FindActiveByConversationOptions, index$4_ListRunsFilter as ListRunsFilter, index$4_MemoryRunRegistryStore as MemoryRunRegistryStore, index$4_NotImplementedError as NotImplementedError, index$4_RunAlreadyRegisteredError as RunAlreadyRegisteredError, index$4_RunAwaitingUserPatch as RunAwaitingUserPatch, index$4_RunCost as RunCost, index$4_RunCostCollector as RunCostCollector, index$4_RunExecutionContext as RunExecutionContext, index$4_RunExecutorPort as RunExecutorPort, index$4_RunFailureInfo as RunFailureInfo, index$4_RunHandle as RunHandle, index$4_RunLifecyclePatch as RunLifecyclePatch, index$4_RunMeta as RunMeta, index$4_RunNotFoundError as RunNotFoundError, index$4_RunObserveFilter as RunObserveFilter, index$4_RunOutcome as RunOutcome, index$4_RunRecord as RunRecord, index$4_RunRegistrationSpec as RunRegistrationSpec, index$4_RunRegistryStore as RunRegistryStore, index$4_RunRequestSnapshot as RunRequestSnapshot, index$4_RunSnapshot as RunSnapshot, index$4_RunStatus as RunStatus, index$4_RunSupervisor as RunSupervisor, index$4_RunTerminalError as RunTerminalError, index$4_RunTerminalEvent as RunTerminalEvent, index$4_RunTerminalStatus as RunTerminalStatus, index$4_RunWaitForTerminalOptions as RunWaitForTerminalOptions, index$4_runMetaFromRecord as runMetaFromRecord };
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
declare const noopTelemetry: TelemetryPort;
|
|
947
|
+
|
|
948
|
+
declare const index$3_TELEMETRY_EVENT_KINDS: typeof TELEMETRY_EVENT_KINDS;
|
|
949
|
+
declare const index$3_TelemetryEvent: typeof TelemetryEvent;
|
|
950
|
+
declare const index$3_TelemetryPort: typeof TelemetryPort;
|
|
951
|
+
declare const index$3_TelemetryScope: typeof TelemetryScope;
|
|
952
|
+
declare const index$3_noopTelemetry: typeof noopTelemetry;
|
|
953
|
+
declare namespace index$3 {
|
|
954
|
+
export { index$3_TELEMETRY_EVENT_KINDS as TELEMETRY_EVENT_KINDS, index$3_TelemetryEvent as TelemetryEvent, index$3_TelemetryPort as TelemetryPort, index$3_TelemetryScope as TelemetryScope, index$3_noopTelemetry as noopTelemetry };
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
interface ConsoleAuditOptions {
|
|
958
|
+
sink?: Pick<Console, 'info'>;
|
|
959
|
+
}
|
|
960
|
+
declare function createConsoleAudit(options?: ConsoleAuditOptions): AuditPort;
|
|
961
|
+
declare const consoleAudit: AuditPort;
|
|
962
|
+
|
|
963
|
+
interface CompositeAuditOptions {
|
|
964
|
+
ports: readonly AuditPort[];
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* 组合多个审计 sink。
|
|
968
|
+
*
|
|
969
|
+
* 中文备注:
|
|
970
|
+
* - 按顺序 await,确保 EventStore 这类主审计落点先完成;
|
|
971
|
+
* - 不吞异常,审计失败应该暴露给调用方,由 host 决定是否降级。
|
|
972
|
+
*/
|
|
973
|
+
declare class CompositeAuditPort implements AuditPort {
|
|
974
|
+
private readonly ports;
|
|
975
|
+
constructor(options: CompositeAuditOptions);
|
|
976
|
+
emit(envelope: AuditEnvelope): Promise<void>;
|
|
977
|
+
flush(): Promise<void>;
|
|
978
|
+
}
|
|
979
|
+
declare function createCompositeAudit(options: CompositeAuditOptions): AuditPort;
|
|
980
|
+
|
|
981
|
+
interface EmitAuditEnvelopeParams {
|
|
982
|
+
runId?: string;
|
|
983
|
+
parentRunId?: string;
|
|
984
|
+
actor?: AuditActor;
|
|
985
|
+
action: string;
|
|
986
|
+
decision?: AuditDecision;
|
|
987
|
+
evidence?: AuditEvidence[];
|
|
988
|
+
costDelta?: AuditCostDelta;
|
|
989
|
+
scope: AuditScope;
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* 统一发出 AuditEnvelope。
|
|
993
|
+
*
|
|
994
|
+
* 中文备注:
|
|
995
|
+
* - 调用点只描述“谁做了什么决策”,这里统一补 envelopeId / ts / runId;
|
|
996
|
+
* - 不吞 emit 异常,审计链路异常应由上层测试或 host 策略显式处理。
|
|
997
|
+
*/
|
|
998
|
+
declare function emitAuditEnvelope(auditPort: AuditPort, params: EmitAuditEnvelopeParams): Promise<void>;
|
|
999
|
+
declare function emitSandboxDecisionAudit(auditPort: AuditPort, params: {
|
|
1000
|
+
scope: AuditScope;
|
|
1001
|
+
allowed: boolean;
|
|
1002
|
+
reason?: string;
|
|
1003
|
+
policy?: string;
|
|
1004
|
+
evidence?: AuditEvidence[];
|
|
1005
|
+
}): Promise<void>;
|
|
1006
|
+
|
|
1007
|
+
interface EventStoreAuditOptions {
|
|
1008
|
+
eventStore: EventStore;
|
|
1009
|
+
}
|
|
1010
|
+
declare class AuditEnvelopePersistenceError extends Error {
|
|
1011
|
+
constructor(message: string);
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* 默认 EventStore 审计 sink。
|
|
1015
|
+
*
|
|
1016
|
+
* 中文备注:
|
|
1017
|
+
* - 写入隐藏 RuntimeEvent:type=audit_envelope;
|
|
1018
|
+
* - 事件不进 UI、不进 agent context,只作为追加只读审计事实保留;
|
|
1019
|
+
* - conversationId 必须来自 envelope.scope,避免把跨会话审计混进同一条流。
|
|
1020
|
+
*/
|
|
1021
|
+
declare class EventStoreAuditPort implements AuditPort {
|
|
1022
|
+
private readonly eventStore;
|
|
1023
|
+
constructor(options: EventStoreAuditOptions);
|
|
1024
|
+
emit(envelope: AuditEnvelope): Promise<void>;
|
|
1025
|
+
}
|
|
1026
|
+
declare function createEventStoreAudit(options: EventStoreAuditOptions): AuditPort;
|
|
1027
|
+
|
|
1028
|
+
interface FileAuditOptions {
|
|
1029
|
+
filePath: string;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* JSONL 文件审计 sink。
|
|
1033
|
+
*
|
|
1034
|
+
* 中文备注:
|
|
1035
|
+
* - 每个 envelope 一行,便于 tail / grep / 后续导入 SIEM;
|
|
1036
|
+
* - 不做轮转与脱敏,轮转/脱敏属于 host 策略,后续由 G-4 RedactionPort 处理。
|
|
1037
|
+
*/
|
|
1038
|
+
declare class FileAuditPort implements AuditPort {
|
|
1039
|
+
private readonly filePath;
|
|
1040
|
+
constructor(options: FileAuditOptions);
|
|
1041
|
+
emit(envelope: AuditEnvelope): Promise<void>;
|
|
1042
|
+
}
|
|
1043
|
+
declare function createFileAudit(options: FileAuditOptions): AuditPort;
|
|
1044
|
+
|
|
1045
|
+
declare const noopAudit: AuditPort;
|
|
1046
|
+
|
|
1047
|
+
type index$2_AuditEnvelopePersistenceError = AuditEnvelopePersistenceError;
|
|
1048
|
+
declare const index$2_AuditEnvelopePersistenceError: typeof AuditEnvelopePersistenceError;
|
|
1049
|
+
type index$2_CompositeAuditOptions = CompositeAuditOptions;
|
|
1050
|
+
type index$2_CompositeAuditPort = CompositeAuditPort;
|
|
1051
|
+
declare const index$2_CompositeAuditPort: typeof CompositeAuditPort;
|
|
1052
|
+
type index$2_ConsoleAuditOptions = ConsoleAuditOptions;
|
|
1053
|
+
type index$2_EmitAuditEnvelopeParams = EmitAuditEnvelopeParams;
|
|
1054
|
+
type index$2_EventStoreAuditOptions = EventStoreAuditOptions;
|
|
1055
|
+
type index$2_EventStoreAuditPort = EventStoreAuditPort;
|
|
1056
|
+
declare const index$2_EventStoreAuditPort: typeof EventStoreAuditPort;
|
|
1057
|
+
type index$2_FileAuditOptions = FileAuditOptions;
|
|
1058
|
+
type index$2_FileAuditPort = FileAuditPort;
|
|
1059
|
+
declare const index$2_FileAuditPort: typeof FileAuditPort;
|
|
1060
|
+
declare const index$2_consoleAudit: typeof consoleAudit;
|
|
1061
|
+
declare const index$2_createCompositeAudit: typeof createCompositeAudit;
|
|
1062
|
+
declare const index$2_createConsoleAudit: typeof createConsoleAudit;
|
|
1063
|
+
declare const index$2_createEventStoreAudit: typeof createEventStoreAudit;
|
|
1064
|
+
declare const index$2_createFileAudit: typeof createFileAudit;
|
|
1065
|
+
declare const index$2_emitAuditEnvelope: typeof emitAuditEnvelope;
|
|
1066
|
+
declare const index$2_emitSandboxDecisionAudit: typeof emitSandboxDecisionAudit;
|
|
1067
|
+
declare const index$2_noopAudit: typeof noopAudit;
|
|
1068
|
+
declare namespace index$2 {
|
|
1069
|
+
export { index$2_AuditEnvelopePersistenceError as AuditEnvelopePersistenceError, type index$2_CompositeAuditOptions as CompositeAuditOptions, index$2_CompositeAuditPort as CompositeAuditPort, type index$2_ConsoleAuditOptions as ConsoleAuditOptions, type index$2_EmitAuditEnvelopeParams as EmitAuditEnvelopeParams, type index$2_EventStoreAuditOptions as EventStoreAuditOptions, index$2_EventStoreAuditPort as EventStoreAuditPort, type index$2_FileAuditOptions as FileAuditOptions, index$2_FileAuditPort as FileAuditPort, index$2_consoleAudit as consoleAudit, index$2_createCompositeAudit as createCompositeAudit, index$2_createConsoleAudit as createConsoleAudit, index$2_createEventStoreAudit as createEventStoreAudit, index$2_createFileAudit as createFileAudit, index$2_emitAuditEnvelope as emitAuditEnvelope, index$2_emitSandboxDecisionAudit as emitSandboxDecisionAudit, index$2_noopAudit as noopAudit };
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* @file src/agent/runtime-kernel/system-reminder/types.ts
|
|
1074
|
+
* @description SystemReminder(系统提醒)类型定义
|
|
1075
|
+
*
|
|
1076
|
+
* 设计目标(必须遵守):
|
|
1077
|
+
* - ✅ 只对“当前 tick / 当前 request”生效:不写入 history,不转换成 RuntimeEvent,不进入持久化
|
|
1078
|
+
* - ✅ 配置驱动:新增/调整提醒只改 rules 配置文件
|
|
1079
|
+
* - ✅ 注入形态:追加到“最后一条将发给 LLM 的 message.content”末尾,包裹在 <system-reminder> 标签中
|
|
1080
|
+
*/
|
|
1081
|
+
|
|
1082
|
+
interface SystemReminderContext {
|
|
1083
|
+
request: AgentInvocationRequest;
|
|
1084
|
+
history: ReadonlyArray<RuntimeEvent>;
|
|
1085
|
+
/**
|
|
1086
|
+
* 执行阶段信号(由 GraphExecutor 注入)
|
|
1087
|
+
* - stepCount/maxSteps/remainingSteps/phase/finalStepPolicy...
|
|
1088
|
+
*/
|
|
1089
|
+
executorLocal?: ExecutorLocalState;
|
|
1090
|
+
}
|
|
1091
|
+
interface SystemReminderRule {
|
|
1092
|
+
/**
|
|
1093
|
+
* 规则唯一 ID(用于本 tick 内去重与调试定位)
|
|
1094
|
+
*/
|
|
1095
|
+
id: string;
|
|
1096
|
+
/**
|
|
1097
|
+
* 是否触发
|
|
1098
|
+
*/
|
|
1099
|
+
when: (ctx: SystemReminderContext) => boolean;
|
|
1100
|
+
/**
|
|
1101
|
+
* 构建提醒正文(不包含外层 <system-reminder> 标签)
|
|
1102
|
+
*/
|
|
1103
|
+
build: (ctx: SystemReminderContext) => string;
|
|
1104
|
+
}
|
|
1105
|
+
type SystemReminderTriggerEvaluator = (ctx: SystemReminderContext, trigger: AgentSpecSystemReminderTrigger) => boolean;
|
|
1106
|
+
type SystemReminderContentTemplate = (ctx: SystemReminderContext, args: Record<string, unknown> | undefined) => string;
|
|
1107
|
+
interface SystemReminderRuleDefinition extends AgentSpecSystemReminderExtraRule {
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
declare class SystemReminderRegistry {
|
|
1111
|
+
private readonly triggers;
|
|
1112
|
+
private readonly templates;
|
|
1113
|
+
constructor(seed?: {
|
|
1114
|
+
triggers?: Record<string, SystemReminderTriggerEvaluator>;
|
|
1115
|
+
templates?: Record<string, SystemReminderContentTemplate>;
|
|
1116
|
+
});
|
|
1117
|
+
registerTriggerKind(kind: string, evaluator: SystemReminderTriggerEvaluator): void;
|
|
1118
|
+
registerContentTemplate(name: string, template: SystemReminderContentTemplate): void;
|
|
1119
|
+
buildRule(definition: SystemReminderRuleDefinition): SystemReminderRule | undefined;
|
|
1120
|
+
}
|
|
1121
|
+
declare function createDefaultSystemReminderRegistry(): SystemReminderRegistry;
|
|
1122
|
+
declare const defaultSystemReminderRegistry: SystemReminderRegistry;
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* @file src/agent/runtime-kernel/system-reminder/apply.ts
|
|
1126
|
+
* @description SystemReminder 注入引擎:把提醒追加到“最后一条将发送给 LLM 的 message.content”末尾
|
|
1127
|
+
*
|
|
1128
|
+
* 关键约束(根因级):
|
|
1129
|
+
* - 这里的注入只发生在“即将发给 LLM 的 messages”数组上
|
|
1130
|
+
* - 不生成 RuntimeEvent,不写入 history,不进入数据库(下一次 request 不可回放)
|
|
1131
|
+
* - 允许出现在 LLMRunAudit(after_context_manager)里:因为它属于“本次真实发给模型的输入”
|
|
1132
|
+
*/
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* 将 system-reminder 追加到最后一条消息末尾(原地返回新数组,但不修改原数组引用)
|
|
1136
|
+
*/
|
|
1137
|
+
declare function applySystemReminders(params: {
|
|
1138
|
+
llmMessages: unknown[];
|
|
1139
|
+
ctx: SystemReminderContext;
|
|
1140
|
+
rules?: ReadonlyArray<SystemReminderRule>;
|
|
1141
|
+
policy?: AgentSpecSystemReminderPolicy;
|
|
1142
|
+
registry?: SystemReminderRegistry;
|
|
1143
|
+
/**
|
|
1144
|
+
* 🔔 命中回调:仅当本次确实发生注入时触发
|
|
1145
|
+
*
|
|
1146
|
+
* 中文备注:
|
|
1147
|
+
* - 用于“审计增强”:在 after_context_manager 覆盖写语义下,仍能保留命中时刻的快照;
|
|
1148
|
+
* - 回调只传递最小信息(ruleIds),避免额外依赖和体积膨胀。
|
|
1149
|
+
*/
|
|
1150
|
+
onInjected?: (info: {
|
|
1151
|
+
ruleIds: string[];
|
|
1152
|
+
}) => void;
|
|
1153
|
+
}): unknown[];
|
|
1154
|
+
|
|
1155
|
+
declare function readNonEmptyStrings(value: unknown): string[];
|
|
1156
|
+
declare function toDisplayStep(nodeSwitches: number): number;
|
|
1157
|
+
declare function readContextCheckpointToolName(ctx: SystemReminderContext): string;
|
|
1158
|
+
/**
|
|
1159
|
+
* 统计“本轮请求内”的工具调用次数(LLM 决策层)。
|
|
1160
|
+
*
|
|
1161
|
+
* 中文备注:只统计最后一个 user_input 之后的 tool_call_decision,避免旧事件或 ToolNode
|
|
1162
|
+
* 复用 action 语义时把同一轮工具调用重复计数。
|
|
1163
|
+
*/
|
|
1164
|
+
declare function countToolCallsInCurrentRequest(history: ReadonlyArray<unknown>): number;
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* @file src/agent/runtime-kernel/system-reminder/rules.ts
|
|
1168
|
+
* @description SystemReminder 规则集合(注册式配置入口)
|
|
1169
|
+
*
|
|
1170
|
+
* 中文备注:
|
|
1171
|
+
* - 内置规则也走 trigger + template,和 host extraRules 使用同一套解释链路;
|
|
1172
|
+
* - spec 只引用 rule/template/trigger ID,不塞函数,保证可序列化、可回放、可审计。
|
|
1173
|
+
*/
|
|
1174
|
+
|
|
1175
|
+
declare const SYSTEM_REMINDER_RULES: ReadonlyArray<SystemReminderRuleDefinition>;
|
|
1176
|
+
declare function createSystemReminderRules(params?: {
|
|
1177
|
+
policy?: AgentSpecSystemReminderPolicy;
|
|
1178
|
+
registry?: SystemReminderRegistry;
|
|
1179
|
+
}): ReadonlyArray<SystemReminderRule>;
|
|
1180
|
+
|
|
1181
|
+
declare const maxStepsForceFinalAnswerTemplate: SystemReminderContentTemplate;
|
|
1182
|
+
declare const lastStepsHintTemplate: SystemReminderContentTemplate;
|
|
1183
|
+
declare const toolCallStreakTemplate: SystemReminderContentTemplate;
|
|
1184
|
+
declare const periodicTaskstateReflectionTemplate: SystemReminderContentTemplate;
|
|
1185
|
+
declare const contextBudgetWarningTemplate: SystemReminderContentTemplate;
|
|
1186
|
+
declare const BUILTIN_SYSTEM_REMINDER_TEMPLATES: Record<string, SystemReminderContentTemplate>;
|
|
1187
|
+
|
|
1188
|
+
declare const phaseEqualsTrigger: SystemReminderTriggerEvaluator;
|
|
1189
|
+
declare const remainingStepsLeqTrigger: SystemReminderTriggerEvaluator;
|
|
1190
|
+
declare const stepCountModuloTrigger: SystemReminderTriggerEvaluator;
|
|
1191
|
+
declare const toolCallStreakTrigger: SystemReminderTriggerEvaluator;
|
|
1192
|
+
declare const budgetWarningTrigger: SystemReminderTriggerEvaluator;
|
|
1193
|
+
declare const agentHasToolTrigger: SystemReminderTriggerEvaluator;
|
|
1194
|
+
declare const BUILTIN_SYSTEM_REMINDER_TRIGGERS: Record<string, SystemReminderTriggerEvaluator>;
|
|
1195
|
+
|
|
1196
|
+
declare const index$1_BUILTIN_SYSTEM_REMINDER_TEMPLATES: typeof BUILTIN_SYSTEM_REMINDER_TEMPLATES;
|
|
1197
|
+
declare const index$1_BUILTIN_SYSTEM_REMINDER_TRIGGERS: typeof BUILTIN_SYSTEM_REMINDER_TRIGGERS;
|
|
1198
|
+
declare const index$1_DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME: typeof DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME;
|
|
1199
|
+
declare const index$1_SYSTEM_REMINDER_RULES: typeof SYSTEM_REMINDER_RULES;
|
|
1200
|
+
type index$1_SystemReminderContentTemplate = SystemReminderContentTemplate;
|
|
1201
|
+
type index$1_SystemReminderContext = SystemReminderContext;
|
|
1202
|
+
type index$1_SystemReminderRegistry = SystemReminderRegistry;
|
|
1203
|
+
declare const index$1_SystemReminderRegistry: typeof SystemReminderRegistry;
|
|
1204
|
+
type index$1_SystemReminderRule = SystemReminderRule;
|
|
1205
|
+
type index$1_SystemReminderRuleDefinition = SystemReminderRuleDefinition;
|
|
1206
|
+
type index$1_SystemReminderTriggerEvaluator = SystemReminderTriggerEvaluator;
|
|
1207
|
+
declare const index$1_agentHasToolTrigger: typeof agentHasToolTrigger;
|
|
1208
|
+
declare const index$1_applySystemReminders: typeof applySystemReminders;
|
|
1209
|
+
declare const index$1_budgetWarningTrigger: typeof budgetWarningTrigger;
|
|
1210
|
+
declare const index$1_contextBudgetWarningTemplate: typeof contextBudgetWarningTemplate;
|
|
1211
|
+
declare const index$1_countToolCallsInCurrentRequest: typeof countToolCallsInCurrentRequest;
|
|
1212
|
+
declare const index$1_createDefaultSystemReminderRegistry: typeof createDefaultSystemReminderRegistry;
|
|
1213
|
+
declare const index$1_createSystemReminderRules: typeof createSystemReminderRules;
|
|
1214
|
+
declare const index$1_defaultSystemReminderRegistry: typeof defaultSystemReminderRegistry;
|
|
1215
|
+
declare const index$1_lastStepsHintTemplate: typeof lastStepsHintTemplate;
|
|
1216
|
+
declare const index$1_maxStepsForceFinalAnswerTemplate: typeof maxStepsForceFinalAnswerTemplate;
|
|
1217
|
+
declare const index$1_periodicTaskstateReflectionTemplate: typeof periodicTaskstateReflectionTemplate;
|
|
1218
|
+
declare const index$1_phaseEqualsTrigger: typeof phaseEqualsTrigger;
|
|
1219
|
+
declare const index$1_readContextCheckpointToolName: typeof readContextCheckpointToolName;
|
|
1220
|
+
declare const index$1_readNonEmptyStrings: typeof readNonEmptyStrings;
|
|
1221
|
+
declare const index$1_remainingStepsLeqTrigger: typeof remainingStepsLeqTrigger;
|
|
1222
|
+
declare const index$1_stepCountModuloTrigger: typeof stepCountModuloTrigger;
|
|
1223
|
+
declare const index$1_toDisplayStep: typeof toDisplayStep;
|
|
1224
|
+
declare const index$1_toolCallStreakTemplate: typeof toolCallStreakTemplate;
|
|
1225
|
+
declare const index$1_toolCallStreakTrigger: typeof toolCallStreakTrigger;
|
|
1226
|
+
declare namespace index$1 {
|
|
1227
|
+
export { index$1_BUILTIN_SYSTEM_REMINDER_TEMPLATES as BUILTIN_SYSTEM_REMINDER_TEMPLATES, index$1_BUILTIN_SYSTEM_REMINDER_TRIGGERS as BUILTIN_SYSTEM_REMINDER_TRIGGERS, index$1_DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME as DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME, index$1_SYSTEM_REMINDER_RULES as SYSTEM_REMINDER_RULES, type index$1_SystemReminderContentTemplate as SystemReminderContentTemplate, type index$1_SystemReminderContext as SystemReminderContext, index$1_SystemReminderRegistry as SystemReminderRegistry, type index$1_SystemReminderRule as SystemReminderRule, type index$1_SystemReminderRuleDefinition as SystemReminderRuleDefinition, type index$1_SystemReminderTriggerEvaluator as SystemReminderTriggerEvaluator, index$1_agentHasToolTrigger as agentHasToolTrigger, index$1_applySystemReminders as applySystemReminders, index$1_budgetWarningTrigger as budgetWarningTrigger, index$1_contextBudgetWarningTemplate as contextBudgetWarningTemplate, index$1_countToolCallsInCurrentRequest as countToolCallsInCurrentRequest, index$1_createDefaultSystemReminderRegistry as createDefaultSystemReminderRegistry, index$1_createSystemReminderRules as createSystemReminderRules, index$1_defaultSystemReminderRegistry as defaultSystemReminderRegistry, index$1_lastStepsHintTemplate as lastStepsHintTemplate, index$1_maxStepsForceFinalAnswerTemplate as maxStepsForceFinalAnswerTemplate, index$1_periodicTaskstateReflectionTemplate as periodicTaskstateReflectionTemplate, index$1_phaseEqualsTrigger as phaseEqualsTrigger, index$1_readContextCheckpointToolName as readContextCheckpointToolName, index$1_readNonEmptyStrings as readNonEmptyStrings, index$1_remainingStepsLeqTrigger as remainingStepsLeqTrigger, index$1_stepCountModuloTrigger as stepCountModuloTrigger, index$1_toDisplayStep as toDisplayStep, index$1_toolCallStreakTemplate as toolCallStreakTemplate, index$1_toolCallStreakTrigger as toolCallStreakTrigger };
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* @file src/agent/shared/errorClassifier.ts
|
|
1232
|
+
*
|
|
1233
|
+
* @brief Agent runtime 自己拥有的错误分类器
|
|
1234
|
+
*
|
|
1235
|
+
* @description
|
|
1236
|
+
* 错误分类与重试策略属于 Agent runtime 的执行协议,不应该继续由 app shared owner 持有。
|
|
1237
|
+
*/
|
|
1238
|
+
declare enum ErrorCategory {
|
|
1239
|
+
RETRYABLE = "retryable",
|
|
1240
|
+
NON_RETRYABLE = "non_retryable",
|
|
1241
|
+
RATE_LIMIT = "rate_limit"
|
|
1242
|
+
}
|
|
1243
|
+
declare const ENGINE_ERROR_CODES: {
|
|
1244
|
+
readonly LLM_RATE_LIMIT: "llm.rate_limit";
|
|
1245
|
+
readonly LLM_INVALID_TOOL_ARGS: "llm.invalid_tool_args";
|
|
1246
|
+
readonly LLM_PROVIDER_DOWN: "llm.provider_down";
|
|
1247
|
+
readonly LLM_UNSUPPORTED_CAPABILITY: "llm.unsupported_capability";
|
|
1248
|
+
readonly LLM_AUTH_FAILED: "llm.auth_failed";
|
|
1249
|
+
readonly LLM_INVALID_REQUEST: "llm.invalid_request";
|
|
1250
|
+
readonly LLM_RESOURCE_NOT_FOUND: "llm.resource_not_found";
|
|
1251
|
+
readonly TOOL_TIMEOUT: "tool.timeout";
|
|
1252
|
+
readonly TOOL_PROTOCOL_FUSE: "tool.protocol_fuse";
|
|
1253
|
+
readonly ENGINE_DELEGATE_DEPTH: "engine.delegate_depth_exceeded";
|
|
1254
|
+
readonly ENGINE_BUDGET_EXHAUSTED: "engine.budget_exhausted";
|
|
1255
|
+
readonly USER_CANCELLED: "user.cancelled";
|
|
1256
|
+
readonly ENGINE_UNKNOWN: "engine.unknown";
|
|
1257
|
+
};
|
|
1258
|
+
interface ErrorClassification {
|
|
1259
|
+
category: ErrorCategory;
|
|
1260
|
+
reason: string;
|
|
1261
|
+
suggestedDelay: number | null;
|
|
1262
|
+
errorCode: string;
|
|
1263
|
+
recoverable: boolean;
|
|
1264
|
+
retryAfterMs?: number;
|
|
1265
|
+
hint?: string;
|
|
1266
|
+
metadata?: Record<string, unknown>;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
declare const index_AgentTool: typeof AgentTool;
|
|
1270
|
+
type index_AnswerNode = AnswerNode;
|
|
1271
|
+
declare const index_AnswerNode: typeof AnswerNode;
|
|
1272
|
+
type index_AuditEnvelopePersistenceError = AuditEnvelopePersistenceError;
|
|
1273
|
+
declare const index_AuditEnvelopePersistenceError: typeof AuditEnvelopePersistenceError;
|
|
1274
|
+
declare const index_BUILTIN_SYSTEM_REMINDER_TEMPLATES: typeof BUILTIN_SYSTEM_REMINDER_TEMPLATES;
|
|
1275
|
+
declare const index_BUILTIN_SYSTEM_REMINDER_TRIGGERS: typeof BUILTIN_SYSTEM_REMINDER_TRIGGERS;
|
|
1276
|
+
declare const index_BaseTool: typeof BaseTool;
|
|
1277
|
+
declare const index_CheckpointListFilter: typeof CheckpointListFilter;
|
|
1278
|
+
declare const index_CheckpointMeta: typeof CheckpointMeta;
|
|
1279
|
+
declare const index_CheckpointSummary: typeof CheckpointSummary;
|
|
1280
|
+
declare const index_Checkpointer: typeof Checkpointer;
|
|
1281
|
+
declare const index_CommonParameterTypes: typeof CommonParameterTypes;
|
|
1282
|
+
type index_CompositeAuditOptions = CompositeAuditOptions;
|
|
1283
|
+
type index_CompositeAuditPort = CompositeAuditPort;
|
|
1284
|
+
declare const index_CompositeAuditPort: typeof CompositeAuditPort;
|
|
1285
|
+
type index_ConsoleAuditOptions = ConsoleAuditOptions;
|
|
1286
|
+
type index_ContextCheckpointPayload = ContextCheckpointPayload;
|
|
1287
|
+
type index_ContextCheckpointPayloadExtension = ContextCheckpointPayloadExtension;
|
|
1288
|
+
type index_ContextCheckpointTool = ContextCheckpointTool;
|
|
1289
|
+
declare const index_ContextCheckpointTool: typeof ContextCheckpointTool;
|
|
1290
|
+
type index_ContextCheckpointToolArgs = ContextCheckpointToolArgs;
|
|
1291
|
+
type index_ContextCheckpointToolHookParams = ContextCheckpointToolHookParams;
|
|
1292
|
+
type index_ContextCheckpointToolOptions = ContextCheckpointToolOptions;
|
|
1293
|
+
declare const index_ConversationArtifactContext: typeof ConversationArtifactContext;
|
|
1294
|
+
declare const index_DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME: typeof DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME;
|
|
1295
|
+
declare const index_DefaultGraphExecutorOptions: typeof DefaultGraphExecutorOptions;
|
|
1296
|
+
type index_DefaultTokenizerPort = DefaultTokenizerPort;
|
|
1297
|
+
declare const index_DefaultTokenizerPort: typeof DefaultTokenizerPort;
|
|
1298
|
+
type index_DefaultTokenizerPortConfig = DefaultTokenizerPortConfig;
|
|
1299
|
+
declare const index_ENGINE_ERROR_CODES: typeof ENGINE_ERROR_CODES;
|
|
1300
|
+
declare const index_ENGINE_STATE_SCHEMA_VERSION: typeof ENGINE_STATE_SCHEMA_VERSION;
|
|
1301
|
+
type index_EmitAuditEnvelopeParams = EmitAuditEnvelopeParams;
|
|
1302
|
+
declare const index_EngineState: typeof EngineState;
|
|
1303
|
+
type index_EnrichmentContext = EnrichmentContext;
|
|
1304
|
+
type index_EnrichmentResult = EnrichmentResult;
|
|
1305
|
+
type index_ErrorClassification = ErrorClassification;
|
|
1306
|
+
type index_EventBusSubRunTracePublisher = EventBusSubRunTracePublisher;
|
|
1307
|
+
declare const index_EventBusSubRunTracePublisher: typeof EventBusSubRunTracePublisher;
|
|
1308
|
+
declare const index_EventRangeOptions: typeof EventRangeOptions;
|
|
1309
|
+
declare const index_EventStore: typeof EventStore;
|
|
1310
|
+
type index_EventStoreAuditOptions = EventStoreAuditOptions;
|
|
1311
|
+
type index_EventStoreAuditPort = EventStoreAuditPort;
|
|
1312
|
+
declare const index_EventStoreAuditPort: typeof EventStoreAuditPort;
|
|
1313
|
+
declare const index_ExecutorLocalState: typeof ExecutorLocalState;
|
|
1314
|
+
type index_FileAuditOptions = FileAuditOptions;
|
|
1315
|
+
type index_FileAuditPort = FileAuditPort;
|
|
1316
|
+
declare const index_FileAuditPort: typeof FileAuditPort;
|
|
1317
|
+
type index_GraphAgentExecutor = GraphAgentExecutor;
|
|
1318
|
+
declare const index_GraphAgentExecutor: typeof GraphAgentExecutor;
|
|
1319
|
+
type index_GraphAgentExecutorDependencies = GraphAgentExecutorDependencies;
|
|
1320
|
+
declare const index_GraphExecutor: typeof GraphExecutor;
|
|
1321
|
+
type index_GraphExecutorContextBuildInput = GraphExecutorContextBuildInput;
|
|
1322
|
+
type index_GraphExecutorContextBuildOutput = GraphExecutorContextBuildOutput;
|
|
1323
|
+
type index_GraphExecutorContextBuilder = GraphExecutorContextBuilder;
|
|
1324
|
+
declare const index_GraphLoopHarness: typeof GraphLoopHarness;
|
|
1325
|
+
declare const index_GraphLoopHarnessOptions: typeof GraphLoopHarnessOptions;
|
|
1326
|
+
declare const index_GraphLoopHarnessRunResult: typeof GraphLoopHarnessRunResult;
|
|
1327
|
+
declare const index_GraphLoopLlmNodeFactoryParams: typeof GraphLoopLlmNodeFactoryParams;
|
|
1328
|
+
declare const index_GraphNode: typeof GraphNode;
|
|
1329
|
+
declare const index_JsonObjectSchema: typeof JsonObjectSchema;
|
|
1330
|
+
declare const index_LLMPolicy: typeof LLMPolicy;
|
|
1331
|
+
type index_LLMPolicyEngine = LLMPolicyEngine;
|
|
1332
|
+
declare const index_LLMPolicyEngine: typeof LLMPolicyEngine;
|
|
1333
|
+
declare const index_LLMPolicyErrorDecision: typeof LLMPolicyErrorDecision;
|
|
1334
|
+
declare const index_LLMPolicyMatchContext: typeof LLMPolicyMatchContext;
|
|
1335
|
+
declare const index_LLMPolicyRequestContext: typeof LLMPolicyRequestContext;
|
|
1336
|
+
declare const index_LLMPolicyResponseContext: typeof LLMPolicyResponseContext;
|
|
1337
|
+
declare const index_LlmCallOptions: typeof LlmCallOptions;
|
|
1338
|
+
declare const index_LlmCaller: typeof LlmCaller;
|
|
1339
|
+
type index_LlmNode = LlmNode;
|
|
1340
|
+
declare const index_LlmNode: typeof LlmNode;
|
|
1341
|
+
declare const index_LlmRequestMessage: typeof LlmRequestMessage;
|
|
1342
|
+
declare const index_LlmResponseContent: typeof LlmResponseContent;
|
|
1343
|
+
declare const index_LlmRetryConfig: typeof LlmRetryConfig;
|
|
1344
|
+
type index_MemoryCheckpointer = MemoryCheckpointer;
|
|
1345
|
+
declare const index_MemoryCheckpointer: typeof MemoryCheckpointer;
|
|
1346
|
+
declare const index_MemoryEventStore: typeof MemoryEventStore;
|
|
1347
|
+
declare const index_ModelCatalogEntry: typeof ModelCatalogEntry;
|
|
1348
|
+
declare const index_ModelCatalogLike: typeof ModelCatalogLike;
|
|
1349
|
+
declare const index_ModelResolver: typeof ModelResolver;
|
|
1350
|
+
declare const index_ObservationPreviewContext: typeof ObservationPreviewContext;
|
|
1351
|
+
declare const index_ObservationPreviewMeta: typeof ObservationPreviewMeta;
|
|
1352
|
+
declare const index_ObservationPreviewPort: typeof ObservationPreviewPort;
|
|
1353
|
+
declare const index_ObservationPreviewResult: typeof ObservationPreviewResult;
|
|
1354
|
+
declare const index_OpenAIToolSchema: typeof OpenAIToolSchema;
|
|
1355
|
+
type index_PendingContextRuntimeEvent = PendingContextRuntimeEvent;
|
|
1356
|
+
declare const index_PersistedEvent: typeof PersistedEvent;
|
|
1357
|
+
declare const index_ProviderReasoningDetails: typeof ProviderReasoningDetails;
|
|
1358
|
+
type index_RegistryEnrichmentResult = RegistryEnrichmentResult;
|
|
1359
|
+
type index_RequestEnricher = RequestEnricher;
|
|
1360
|
+
declare const index_SYSTEM_REMINDER_RULES: typeof SYSTEM_REMINDER_RULES;
|
|
1361
|
+
declare const index_StructuredToolResult: typeof StructuredToolResult;
|
|
1362
|
+
declare const index_SubRunTracePublisher: typeof SubRunTracePublisher;
|
|
1363
|
+
type index_SystemReminderContentTemplate = SystemReminderContentTemplate;
|
|
1364
|
+
type index_SystemReminderContext = SystemReminderContext;
|
|
1365
|
+
type index_SystemReminderRegistry = SystemReminderRegistry;
|
|
1366
|
+
declare const index_SystemReminderRegistry: typeof SystemReminderRegistry;
|
|
1367
|
+
type index_SystemReminderRule = SystemReminderRule;
|
|
1368
|
+
type index_SystemReminderRuleDefinition = SystemReminderRuleDefinition;
|
|
1369
|
+
type index_SystemReminderTriggerEvaluator = SystemReminderTriggerEvaluator;
|
|
1370
|
+
declare const index_ToolArgs: typeof ToolArgs;
|
|
1371
|
+
declare const index_ToolCall: typeof ToolCall;
|
|
1372
|
+
declare const index_ToolCallChunk: typeof ToolCallChunk;
|
|
1373
|
+
declare const index_ToolCallExtraContent: typeof ToolCallExtraContent;
|
|
1374
|
+
declare const index_ToolCallResult: typeof ToolCallResult;
|
|
1375
|
+
declare const index_ToolCatalogPort: typeof ToolCatalogPort;
|
|
1376
|
+
declare const index_ToolContextCompatibilityFields: typeof ToolContextCompatibilityFields;
|
|
1377
|
+
declare const index_ToolContextConversationView: typeof ToolContextConversationView;
|
|
1378
|
+
declare const index_ToolContextPatch: typeof ToolContextPatch;
|
|
1379
|
+
declare const index_ToolControlInfo: typeof ToolControlInfo;
|
|
1380
|
+
declare const index_ToolDisplayOptions: typeof ToolDisplayOptions;
|
|
1381
|
+
declare const index_ToolExecutionContext: typeof ToolExecutionContext;
|
|
1382
|
+
declare const index_ToolExecutionPort: typeof ToolExecutionPort;
|
|
1383
|
+
declare const index_ToolExecutionResult: typeof ToolExecutionResult;
|
|
1384
|
+
declare const index_ToolLayoutOptions: typeof ToolLayoutOptions;
|
|
1385
|
+
type index_ToolNode = ToolNode;
|
|
1386
|
+
declare const index_ToolNode: typeof ToolNode;
|
|
1387
|
+
declare const index_ToolParameterProperty: typeof ToolParameterProperty;
|
|
1388
|
+
declare const index_ToolParameterSchema: typeof ToolParameterSchema;
|
|
1389
|
+
declare const index_ToolPresentationPort: typeof ToolPresentationPort;
|
|
1390
|
+
declare const index_ToolRegistryEntry: typeof ToolRegistryEntry;
|
|
1391
|
+
declare const index_ToolResult: typeof ToolResult;
|
|
1392
|
+
declare const index_ToolRuntimeDefinition: typeof ToolRuntimeDefinition;
|
|
1393
|
+
declare const index_ToolRuntimePort: typeof ToolRuntimePort;
|
|
1394
|
+
declare const index_ToolSchemaContext: typeof ToolSchemaContext;
|
|
1395
|
+
declare const index_UnifiedToolResult: typeof UnifiedToolResult;
|
|
1396
|
+
type index_UserNode = UserNode;
|
|
1397
|
+
declare const index_UserNode: typeof UserNode;
|
|
1398
|
+
type index_WaitUserNode = WaitUserNode;
|
|
1399
|
+
declare const index_WaitUserNode: typeof WaitUserNode;
|
|
1400
|
+
declare const index_agentHasToolTrigger: typeof agentHasToolTrigger;
|
|
1401
|
+
declare const index_applySystemReminders: typeof applySystemReminders;
|
|
1402
|
+
declare const index_budgetWarningTrigger: typeof budgetWarningTrigger;
|
|
1403
|
+
declare const index_computeToolIdempotencyKey: typeof computeToolIdempotencyKey;
|
|
1404
|
+
declare const index_consoleAudit: typeof consoleAudit;
|
|
1405
|
+
declare const index_contextBudgetWarningTemplate: typeof contextBudgetWarningTemplate;
|
|
1406
|
+
declare const index_countToolCallsInCurrentRequest: typeof countToolCallsInCurrentRequest;
|
|
1407
|
+
declare const index_createCompositeAudit: typeof createCompositeAudit;
|
|
1408
|
+
declare const index_createConsoleAudit: typeof createConsoleAudit;
|
|
1409
|
+
declare const index_createContextCheckpointTool: typeof createContextCheckpointTool;
|
|
1410
|
+
declare const index_createDefaultGraphExecutor: typeof createDefaultGraphExecutor;
|
|
1411
|
+
declare const index_createDefaultSystemReminderRegistry: typeof createDefaultSystemReminderRegistry;
|
|
1412
|
+
declare const index_createDefaultTokenizerPort: typeof createDefaultTokenizerPort;
|
|
1413
|
+
declare const index_createEventStoreAudit: typeof createEventStoreAudit;
|
|
1414
|
+
declare const index_createFileAudit: typeof createFileAudit;
|
|
1415
|
+
declare const index_createGraphLoopHarness: typeof createGraphLoopHarness;
|
|
1416
|
+
declare const index_createMonotonicEventIdFactory: typeof createMonotonicEventIdFactory;
|
|
1417
|
+
declare const index_createSystemReminderRules: typeof createSystemReminderRules;
|
|
1418
|
+
declare const index_defaultPolicyEngine: typeof defaultPolicyEngine;
|
|
1419
|
+
declare const index_defaultSystemReminderRegistry: typeof defaultSystemReminderRegistry;
|
|
1420
|
+
declare const index_emitAuditEnvelope: typeof emitAuditEnvelope;
|
|
1421
|
+
declare const index_emitSandboxDecisionAudit: typeof emitSandboxDecisionAudit;
|
|
1422
|
+
declare const index_ensureToolContextRuntimeCapability: typeof ensureToolContextRuntimeCapability;
|
|
1423
|
+
declare const index_findCachedToolOutputByIdempotencyKey: typeof findCachedToolOutputByIdempotencyKey;
|
|
1424
|
+
declare const index_getToolContextRuntimeBinding: typeof getToolContextRuntimeBinding;
|
|
1425
|
+
declare const index_lastStepsHintTemplate: typeof lastStepsHintTemplate;
|
|
1426
|
+
declare const index_maxStepsForceFinalAnswerTemplate: typeof maxStepsForceFinalAnswerTemplate;
|
|
1427
|
+
declare const index_noopAudit: typeof noopAudit;
|
|
1428
|
+
declare const index_normalizeToolArgs: typeof normalizeToolArgs;
|
|
1429
|
+
declare const index_periodicTaskstateReflectionTemplate: typeof periodicTaskstateReflectionTemplate;
|
|
1430
|
+
declare const index_phaseEqualsTrigger: typeof phaseEqualsTrigger;
|
|
1431
|
+
declare const index_readContextCheckpointToolName: typeof readContextCheckpointToolName;
|
|
1432
|
+
declare const index_readNonEmptyStrings: typeof readNonEmptyStrings;
|
|
1433
|
+
declare const index_readToolContextModelId: typeof readToolContextModelId;
|
|
1434
|
+
declare const index_readToolContextPersistedHistory: typeof readToolContextPersistedHistory;
|
|
1435
|
+
declare const index_readToolContextRunContext: typeof readToolContextRunContext;
|
|
1436
|
+
declare const index_readToolContextUserQuery: typeof readToolContextUserQuery;
|
|
1437
|
+
declare const index_readToolContextWorkingHistory: typeof readToolContextWorkingHistory;
|
|
1438
|
+
declare const index_remainingStepsLeqTrigger: typeof remainingStepsLeqTrigger;
|
|
1439
|
+
declare const index_requestEnricherRegistry: typeof requestEnricherRegistry;
|
|
1440
|
+
declare const index_stepCountModuloTrigger: typeof stepCountModuloTrigger;
|
|
1441
|
+
declare const index_stripRuntimeReservedToolContextPatch: typeof stripRuntimeReservedToolContextPatch;
|
|
1442
|
+
declare const index_summarizeCheckpoint: typeof summarizeCheckpoint;
|
|
1443
|
+
declare const index_toDisplayStep: typeof toDisplayStep;
|
|
1444
|
+
declare const index_toolCallStreakTemplate: typeof toolCallStreakTemplate;
|
|
1445
|
+
declare const index_toolCallStreakTrigger: typeof toolCallStreakTrigger;
|
|
1446
|
+
declare namespace index {
|
|
1447
|
+
export { index_AgentTool as AgentTool, index_AnswerNode as AnswerNode, index_AuditEnvelopePersistenceError as AuditEnvelopePersistenceError, index_BUILTIN_SYSTEM_REMINDER_TEMPLATES as BUILTIN_SYSTEM_REMINDER_TEMPLATES, index_BUILTIN_SYSTEM_REMINDER_TRIGGERS as BUILTIN_SYSTEM_REMINDER_TRIGGERS, index_BaseTool as BaseTool, index_CheckpointListFilter as CheckpointListFilter, index_CheckpointMeta as CheckpointMeta, index_CheckpointSummary as CheckpointSummary, index_Checkpointer as Checkpointer, index_CommonParameterTypes as CommonParameterTypes, type index_CompositeAuditOptions as CompositeAuditOptions, index_CompositeAuditPort as CompositeAuditPort, type index_ConsoleAuditOptions as ConsoleAuditOptions, type index_ContextCheckpointPayload as ContextCheckpointPayload, type index_ContextCheckpointPayloadExtension as ContextCheckpointPayloadExtension, index_ContextCheckpointTool as ContextCheckpointTool, type index_ContextCheckpointToolArgs as ContextCheckpointToolArgs, type index_ContextCheckpointToolHookParams as ContextCheckpointToolHookParams, type index_ContextCheckpointToolOptions as ContextCheckpointToolOptions, index_ConversationArtifactContext as ConversationArtifactContext, index_DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME as DEFAULT_CONTEXT_CHECKPOINT_TOOL_NAME, index_DefaultGraphExecutorOptions as DefaultGraphExecutorOptions, index_DefaultTokenizerPort as DefaultTokenizerPort, type index_DefaultTokenizerPortConfig as DefaultTokenizerPortConfig, index_ENGINE_ERROR_CODES as ENGINE_ERROR_CODES, index_ENGINE_STATE_SCHEMA_VERSION as ENGINE_STATE_SCHEMA_VERSION, type index_EmitAuditEnvelopeParams as EmitAuditEnvelopeParams, index_EngineState as EngineState, type index_EnrichmentContext as EnrichmentContext, type index_EnrichmentResult as EnrichmentResult, type index_ErrorClassification as ErrorClassification, index_EventBusSubRunTracePublisher as EventBusSubRunTracePublisher, index_EventRangeOptions as EventRangeOptions, index_EventStore as EventStore, type index_EventStoreAuditOptions as EventStoreAuditOptions, index_EventStoreAuditPort as EventStoreAuditPort, index_ExecutorLocalState as ExecutorLocalState, type index_FileAuditOptions as FileAuditOptions, index_FileAuditPort as FileAuditPort, index_GraphAgentExecutor as GraphAgentExecutor, type index_GraphAgentExecutorDependencies as GraphAgentExecutorDependencies, index_GraphExecutor as GraphExecutor, type index_GraphExecutorContextBuildInput as GraphExecutorContextBuildInput, type index_GraphExecutorContextBuildOutput as GraphExecutorContextBuildOutput, type index_GraphExecutorContextBuilder as GraphExecutorContextBuilder, index_GraphLoopHarness as GraphLoopHarness, index_GraphLoopHarnessOptions as GraphLoopHarnessOptions, index_GraphLoopHarnessRunResult as GraphLoopHarnessRunResult, index_GraphLoopLlmNodeFactoryParams as GraphLoopLlmNodeFactoryParams, index_GraphNode as GraphNode, index_JsonObjectSchema as JsonObjectSchema, index_LLMPolicy as LLMPolicy, index_LLMPolicyEngine as LLMPolicyEngine, index_LLMPolicyErrorDecision as LLMPolicyErrorDecision, index_LLMPolicyMatchContext as LLMPolicyMatchContext, index_LLMPolicyRequestContext as LLMPolicyRequestContext, index_LLMPolicyResponseContext as LLMPolicyResponseContext, index_LlmCallOptions as LlmCallOptions, index_LlmCaller as LlmCaller, index_LlmNode as LlmNode, index_LlmRequestMessage as LlmRequestMessage, index_LlmResponseContent as LlmResponseContent, index_LlmRetryConfig as LlmRetryConfig, index_MemoryCheckpointer as MemoryCheckpointer, index_MemoryEventStore as MemoryEventStore, index_ModelCatalogEntry as ModelCatalogEntry, index_ModelCatalogLike as ModelCatalogLike, index_ModelResolver as ModelResolver, index_ObservationPreviewContext as ObservationPreviewContext, index_ObservationPreviewMeta as ObservationPreviewMeta, index_ObservationPreviewPort as ObservationPreviewPort, index_ObservationPreviewResult as ObservationPreviewResult, index_OpenAIToolSchema as OpenAIToolSchema, type index_PendingContextRuntimeEvent as PendingContextRuntimeEvent, index_PersistedEvent as PersistedEvent, index_ProviderReasoningDetails as ProviderReasoningDetails, type index_RegistryEnrichmentResult as RegistryEnrichmentResult, type index_RequestEnricher as RequestEnricher, index_SYSTEM_REMINDER_RULES as SYSTEM_REMINDER_RULES, index_StructuredToolResult as StructuredToolResult, index_SubRunTracePublisher as SubRunTracePublisher, type index_SystemReminderContentTemplate as SystemReminderContentTemplate, type index_SystemReminderContext as SystemReminderContext, index_SystemReminderRegistry as SystemReminderRegistry, type index_SystemReminderRule as SystemReminderRule, type index_SystemReminderRuleDefinition as SystemReminderRuleDefinition, type index_SystemReminderTriggerEvaluator as SystemReminderTriggerEvaluator, index_ToolArgs as ToolArgs, index_ToolCall as ToolCall, index_ToolCallChunk as ToolCallChunk, index_ToolCallExtraContent as ToolCallExtraContent, index_ToolCallResult as ToolCallResult, index_ToolCatalogPort as ToolCatalogPort, index_ToolContextCompatibilityFields as ToolContextCompatibilityFields, index_ToolContextConversationView as ToolContextConversationView, index_ToolContextPatch as ToolContextPatch, index_ToolControlInfo as ToolControlInfo, index_ToolDisplayOptions as ToolDisplayOptions, index_ToolExecutionContext as ToolExecutionContext, index_ToolExecutionPort as ToolExecutionPort, index_ToolExecutionResult as ToolExecutionResult, index_ToolLayoutOptions as ToolLayoutOptions, index_ToolNode as ToolNode, index_ToolParameterProperty as ToolParameterProperty, index_ToolParameterSchema as ToolParameterSchema, index_ToolPresentationPort as ToolPresentationPort, index_ToolRegistryEntry as ToolRegistryEntry, index_ToolResult as ToolResult, index_ToolRuntimeDefinition as ToolRuntimeDefinition, index_ToolRuntimePort as ToolRuntimePort, index_ToolSchemaContext as ToolSchemaContext, index_UnifiedToolResult as UnifiedToolResult, index_UserNode as UserNode, index_WaitUserNode as WaitUserNode, index_agentHasToolTrigger as agentHasToolTrigger, index_applySystemReminders as applySystemReminders, index$2 as audit, index_budgetWarningTrigger as budgetWarningTrigger, index$6 as childRunTrace, index$7 as childRuns, index_computeToolIdempotencyKey as computeToolIdempotencyKey, index_consoleAudit as consoleAudit, index_contextBudgetWarningTemplate as contextBudgetWarningTemplate, index_countToolCallsInCurrentRequest as countToolCallsInCurrentRequest, index_createCompositeAudit as createCompositeAudit, index_createConsoleAudit as createConsoleAudit, index_createContextCheckpointTool as createContextCheckpointTool, index_createDefaultGraphExecutor as createDefaultGraphExecutor, index_createDefaultSystemReminderRegistry as createDefaultSystemReminderRegistry, index_createDefaultTokenizerPort as createDefaultTokenizerPort, index_createEventStoreAudit as createEventStoreAudit, index_createFileAudit as createFileAudit, index_createGraphLoopHarness as createGraphLoopHarness, index_createMonotonicEventIdFactory as createMonotonicEventIdFactory, index_createSystemReminderRules as createSystemReminderRules, index_defaultPolicyEngine as defaultPolicyEngine, index_defaultSystemReminderRegistry as defaultSystemReminderRegistry, index_emitAuditEnvelope as emitAuditEnvelope, index_emitSandboxDecisionAudit as emitSandboxDecisionAudit, index$5 as enrichment, index_ensureToolContextRuntimeCapability as ensureToolContextRuntimeCapability, index$d as events, index$9 as execution, index_findCachedToolOutputByIdempotencyKey as findCachedToolOutputByIdempotencyKey, index_getToolContextRuntimeBinding as getToolContextRuntimeBinding, index$b as graph, index_lastStepsHintTemplate as lastStepsHintTemplate, index$c as llm, index_maxStepsForceFinalAnswerTemplate as maxStepsForceFinalAnswerTemplate, index_noopAudit as noopAudit, index_normalizeToolArgs as normalizeToolArgs, index_periodicTaskstateReflectionTemplate as periodicTaskstateReflectionTemplate, index_phaseEqualsTrigger as phaseEqualsTrigger, index_readContextCheckpointToolName as readContextCheckpointToolName, index_readNonEmptyStrings as readNonEmptyStrings, index_readToolContextModelId as readToolContextModelId, index_readToolContextPersistedHistory as readToolContextPersistedHistory, index_readToolContextRunContext as readToolContextRunContext, index_readToolContextUserQuery as readToolContextUserQuery, index_readToolContextWorkingHistory as readToolContextWorkingHistory, index_remainingStepsLeqTrigger as remainingStepsLeqTrigger, index_requestEnricherRegistry as requestEnricherRegistry, index$8 as runContext, index$4 as runSupervisor, index_stepCountModuloTrigger as stepCountModuloTrigger, index_stripRuntimeReservedToolContextPatch as stripRuntimeReservedToolContextPatch, index_summarizeCheckpoint as summarizeCheckpoint, index$1 as systemReminder, index$3 as telemetry, index_toDisplayStep as toDisplayStep, index_toolCallStreakTemplate as toolCallStreakTemplate, index_toolCallStreakTrigger as toolCallStreakTrigger, index$a as tools };
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
export { consoleAudit as $, AnswerNode as A, BUILTIN_SYSTEM_REMINDER_TEMPLATES as B, type CompositeAuditOptions as C, DefaultTokenizerPort as D, ENGINE_ERROR_CODES as E, type FileAuditOptions as F, GraphAgentExecutor as G, type SystemReminderContentTemplate as H, type SystemReminderContext as I, SystemReminderRegistry as J, type SystemReminderRule as K, LLMPolicyEngine as L, MemoryCheckpointer as M, type SystemReminderRuleDefinition as N, type SystemReminderTriggerEvaluator as O, type PendingContextRuntimeEvent as P, agentHasToolTrigger as Q, type RegistryEnrichmentResult as R, SYSTEM_REMINDER_RULES as S, ToolNode as T, UserNode as U, applySystemReminders as V, WaitUserNode as W, index$2 as X, budgetWarningTrigger as Y, index$6 as Z, index$7 as _, AuditEnvelopePersistenceError as a, contextBudgetWarningTemplate as a0, countToolCallsInCurrentRequest as a1, createCompositeAudit as a2, createConsoleAudit as a3, createContextCheckpointTool as a4, createDefaultSystemReminderRegistry as a5, createDefaultTokenizerPort as a6, createEventStoreAudit as a7, createFileAudit as a8, createSystemReminderRules as a9, index$1 as aA, index$3 as aB, toDisplayStep as aC, toolCallStreakTemplate as aD, toolCallStreakTrigger as aE, index$a as aF, defaultPolicyEngine as aa, defaultSystemReminderRegistry as ab, emitAuditEnvelope as ac, emitSandboxDecisionAudit as ad, index$5 as ae, ensureToolContextRuntimeCapability as af, index$9 as ag, getToolContextRuntimeBinding as ah, index$b as ai, lastStepsHintTemplate as aj, index$c as ak, maxStepsForceFinalAnswerTemplate as al, noopAudit as am, normalizeToolArgs as an, periodicTaskstateReflectionTemplate as ao, phaseEqualsTrigger as ap, readContextCheckpointToolName as aq, readNonEmptyStrings as ar, readToolContextPersistedHistory as as, readToolContextWorkingHistory as at, remainingStepsLeqTrigger as au, requestEnricherRegistry as av, index$8 as aw, index$4 as ax, stepCountModuloTrigger as ay, stripRuntimeReservedToolContextPatch as az, BUILTIN_SYSTEM_REMINDER_TRIGGERS as b, CompositeAuditPort as c, type ConsoleAuditOptions as d, type ContextCheckpointPayload as e, type ContextCheckpointPayloadExtension as f, ContextCheckpointTool as g, type ContextCheckpointToolArgs as h, index as i, type ContextCheckpointToolHookParams as j, type ContextCheckpointToolOptions as k, type DefaultTokenizerPortConfig as l, type EmitAuditEnvelopeParams as m, type EnrichmentContext as n, type EnrichmentResult as o, type ErrorClassification as p, EventBusSubRunTracePublisher as q, type EventStoreAuditOptions as r, EventStoreAuditPort as s, FileAuditPort as t, type GraphAgentExecutorDependencies as u, type GraphExecutorContextBuildInput as v, type GraphExecutorContextBuildOutput as w, type GraphExecutorContextBuilder as x, LlmNode as y, type RequestEnricher as z };
|