@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,284 @@
|
|
|
1
|
+
import { L as LlmCallOptions$1, a as LlmRequestMessage } from './ai-engine.types-BpeU_XQG.cjs';
|
|
2
|
+
import { f as LlmCaller$1, K as TelemetryEvent$2, D as DefaultRunSupervisor, t as MemoryRunRegistryStore, p as MemoryEventStore, u as RunExecutorPort$1, v as RunOutcome$1, q as ToolContextPatch$1 } from './defaultGraphExecutor-BIjJj7WF.cjs';
|
|
3
|
+
export { 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';
|
|
4
|
+
import { e as RuntimeEvent } from './todo-B1PmDlp3.cjs';
|
|
5
|
+
import { A as AiMessage } from './messages-XthmnHZ3.cjs';
|
|
6
|
+
import { e as AgentSpecContextPolicy, a as AgentSpec } from './agentSpec-EkmviZjy.cjs';
|
|
7
|
+
import { d as ContextTrace } from './context-trace-HE2qY5Q-.cjs';
|
|
8
|
+
import { T as TokenizerPort } from './tokenizer-DH_JXv-H.cjs';
|
|
9
|
+
import { e as AuditEnvelope } from './audit-BaRUGaqv.cjs';
|
|
10
|
+
import { b as AuditPort } from './audit-LeOrm2hX.cjs';
|
|
11
|
+
import { f as RunCostCollector$1, n as RunRequestSnapshot$1, b as EventBus, h as RunHandle$1, l as RunRecord$2, P as PersistedEvent$1, e as RunCost$1 } from './runHandle-D3gPsD7B.cjs';
|
|
12
|
+
import { T as ToolExecutionContext$1, f as ToolContextCompatibilityFields$1 } from './toolContracts-CLkQmhTG.cjs';
|
|
13
|
+
import './agent-invocation-BHcNfrBV.cjs';
|
|
14
|
+
import './agentEvents-DEB7Fy_J.cjs';
|
|
15
|
+
import './ports-DaatKJXp.cjs';
|
|
16
|
+
import 'zod';
|
|
17
|
+
import './execution-CAIypb41.cjs';
|
|
18
|
+
|
|
19
|
+
type LlmCaller = LlmCaller$1;
|
|
20
|
+
type LlmCallOptions = LlmCallOptions$1;
|
|
21
|
+
interface ScriptedLlmCall {
|
|
22
|
+
modelId: string;
|
|
23
|
+
messages: unknown[];
|
|
24
|
+
options: LlmCallOptions & {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
stream_options?: {
|
|
27
|
+
include_usage?: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface ScriptedToolCall {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
argumentsJson: string;
|
|
35
|
+
index?: number;
|
|
36
|
+
}
|
|
37
|
+
interface ScriptedLlmTurn {
|
|
38
|
+
thoughtDeltas?: string[];
|
|
39
|
+
contentChunks?: string[];
|
|
40
|
+
toolCalls?: ScriptedToolCall[];
|
|
41
|
+
reasoningDetails?: unknown[];
|
|
42
|
+
usage?: unknown;
|
|
43
|
+
finishReason?: string;
|
|
44
|
+
error?: string | Error;
|
|
45
|
+
throwAfterCallbacks?: string | Error;
|
|
46
|
+
assertCall?: (call: ScriptedLlmCall) => void;
|
|
47
|
+
}
|
|
48
|
+
interface ScriptedAiEngineHarness {
|
|
49
|
+
getCalls(): ScriptedLlmCall[];
|
|
50
|
+
getConsumedTurnCount(): number;
|
|
51
|
+
getLlmCaller(): LlmCaller;
|
|
52
|
+
assertAllTurnsConsumed(): void;
|
|
53
|
+
restore(): void;
|
|
54
|
+
}
|
|
55
|
+
interface ScriptedAiEngineHarnessOptions {
|
|
56
|
+
/**
|
|
57
|
+
* 迁移期兼容开关:历史上可把 scripted engine patch 到模块级 `aiEngine`。
|
|
58
|
+
*
|
|
59
|
+
* 中文备注:
|
|
60
|
+
* - `src/agent/testkit/*` 现在不再依赖 `src/core/aiEngine`;
|
|
61
|
+
* - 新旧测试都应显式注入 `getLlmCaller()`;
|
|
62
|
+
* - 若仍传入 `true`,直接抛错,避免 package boundary 悄悄回退。
|
|
63
|
+
*/
|
|
64
|
+
patchModuleAiEngine?: boolean;
|
|
65
|
+
}
|
|
66
|
+
declare function createScriptedAiEngineHarness(turns: ScriptedLlmTurn[], options?: ScriptedAiEngineHarnessOptions): ScriptedAiEngineHarness;
|
|
67
|
+
|
|
68
|
+
declare function expectMessagesContainToolResult(call: ScriptedLlmCall, expectedText: string): void;
|
|
69
|
+
declare function expectToolOutputFedBackToHistory(call: ScriptedLlmCall, expectedText: string): void;
|
|
70
|
+
declare function expectFinalStepForcedTools(call: ScriptedLlmCall, forcedToolName: string): void;
|
|
71
|
+
declare function expectRunEndedWithFinalAnswer(events: RuntimeEvent[], expectedText: string): void;
|
|
72
|
+
declare function expectMessagesContainText(call: ScriptedLlmCall, expectedText: string): void;
|
|
73
|
+
|
|
74
|
+
declare const assertions_expectFinalStepForcedTools: typeof expectFinalStepForcedTools;
|
|
75
|
+
declare const assertions_expectMessagesContainText: typeof expectMessagesContainText;
|
|
76
|
+
declare const assertions_expectMessagesContainToolResult: typeof expectMessagesContainToolResult;
|
|
77
|
+
declare const assertions_expectRunEndedWithFinalAnswer: typeof expectRunEndedWithFinalAnswer;
|
|
78
|
+
declare const assertions_expectToolOutputFedBackToHistory: typeof expectToolOutputFedBackToHistory;
|
|
79
|
+
declare namespace assertions {
|
|
80
|
+
export { assertions_expectFinalStepForcedTools as expectFinalStepForcedTools, assertions_expectMessagesContainText as expectMessagesContainText, assertions_expectMessagesContainToolResult as expectMessagesContainToolResult, assertions_expectRunEndedWithFinalAnswer as expectRunEndedWithFinalAnswer, assertions_expectToolOutputFedBackToHistory as expectToolOutputFedBackToHistory };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 中文备注:
|
|
85
|
+
* - ReplayHarness 负责把“持久化事实事件 -> LLM 回放消息”这个协议边界显式化;
|
|
86
|
+
* - 测试不再直接散落调用 eventConverter,而是通过统一夹具观察回放结果;
|
|
87
|
+
* - 这样后续如果回放语义升级,测试入口可以保持稳定。
|
|
88
|
+
*/
|
|
89
|
+
interface ReplayHarness {
|
|
90
|
+
replay(): AiMessage[];
|
|
91
|
+
getAssistantToolCallMessages(): AiMessage[];
|
|
92
|
+
getToolOutputMessages(): AiMessage[];
|
|
93
|
+
}
|
|
94
|
+
declare function createReplayHarness(events: RuntimeEvent[]): ReplayHarness;
|
|
95
|
+
|
|
96
|
+
type ContextPolicyInvariantId = 'C1_TRACE_ENABLED_MATCHES_POLICY' | 'C2_EFFECTIVE_POLICY_MATCHES_EXPECTED' | 'C3_TRACE_OPTIONS_MATCH_POLICY' | 'C4_TRACE_EVENT_LIMIT' | 'C5_FINAL_COUNTS_MATCH_MESSAGES' | 'C6_FINAL_TOKENS_WITHIN_BUDGET' | 'C7_PROVIDER_TOKEN_DELTA' | 'C8_TRACE_DETAIL_OPTIONS' | 'C9_MESSAGE_DECISION_REASON' | 'C10_TOOL_PAIR_DECISIONS_STAY_TOGETHER' | 'C11_MUST_KEEP_TYPES_KEPT' | 'C12_HOST_TOKENIZER_DRIVES_BUDGET';
|
|
97
|
+
interface ContextPolicyInvariantFailure {
|
|
98
|
+
id: ContextPolicyInvariantId;
|
|
99
|
+
title: string;
|
|
100
|
+
message: string;
|
|
101
|
+
details?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
interface ContextPolicyInvariantReport {
|
|
104
|
+
ok: boolean;
|
|
105
|
+
failures: ContextPolicyInvariantFailure[];
|
|
106
|
+
}
|
|
107
|
+
interface ContextPolicyInvariantContext {
|
|
108
|
+
expectedPolicy?: AgentSpecContextPolicy;
|
|
109
|
+
trace?: ContextTrace;
|
|
110
|
+
originalMessages?: readonly AiMessage[];
|
|
111
|
+
finalMessages?: readonly AiMessage[];
|
|
112
|
+
tokenizer?: TokenizerPort;
|
|
113
|
+
tokenizerModelId?: string;
|
|
114
|
+
}
|
|
115
|
+
type ContextPolicyInvariantValidator = (context: ContextPolicyInvariantContext) => ContextPolicyInvariantFailure[];
|
|
116
|
+
interface ValidateContextPolicyInvariantsOptions {
|
|
117
|
+
enabled?: readonly ContextPolicyInvariantId[];
|
|
118
|
+
disabled?: readonly ContextPolicyInvariantId[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare function validateContextPolicyInvariants(context: ContextPolicyInvariantContext, options?: ValidateContextPolicyInvariantsOptions): ContextPolicyInvariantReport;
|
|
122
|
+
declare function assertContextPolicyInvariants(report: ContextPolicyInvariantReport): void;
|
|
123
|
+
|
|
124
|
+
interface CollectingAuditPortHarness {
|
|
125
|
+
port: AuditPort;
|
|
126
|
+
getEnvelopes(action?: string): AuditEnvelope[];
|
|
127
|
+
assertEmitted(action: string): AuditEnvelope;
|
|
128
|
+
assertEmittedInOrder(actions: readonly string[]): AuditEnvelope[];
|
|
129
|
+
reset(): void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 收集型 AuditPort。
|
|
133
|
+
*
|
|
134
|
+
* 中文备注:
|
|
135
|
+
* - 用于测试“某次 run 做过哪些决策”,不写文件、不进 EventStore;
|
|
136
|
+
* - 断言方法故意抛普通 Error,让 Vitest/Jest 能直接显示友好的失败原因。
|
|
137
|
+
*/
|
|
138
|
+
declare function createCollectingAuditPort(): CollectingAuditPortHarness;
|
|
139
|
+
|
|
140
|
+
type TelemetryEvent$1 = TelemetryEvent$2;
|
|
141
|
+
type RunCostCollector = RunCostCollector$1;
|
|
142
|
+
interface TelemetryUsageTotal {
|
|
143
|
+
tokensInput: number;
|
|
144
|
+
tokensOutput: number;
|
|
145
|
+
latencyMs: number;
|
|
146
|
+
llmCallCount: number;
|
|
147
|
+
toolCallCount: number;
|
|
148
|
+
}
|
|
149
|
+
interface MockTelemetryPortHarness {
|
|
150
|
+
port: {
|
|
151
|
+
emit(event: TelemetryEvent$1): void;
|
|
152
|
+
flush(): Promise<void>;
|
|
153
|
+
};
|
|
154
|
+
costCollector: RunCostCollector;
|
|
155
|
+
emit(event: TelemetryEvent$1): void;
|
|
156
|
+
getEvents(runId?: string): TelemetryEvent$1[];
|
|
157
|
+
getTotalUsageByRun(runId: string): TelemetryUsageTotal;
|
|
158
|
+
getKnownRunIds(): string[];
|
|
159
|
+
reset(): void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* TelemetryPort 测试夹具。
|
|
163
|
+
*
|
|
164
|
+
* 中文备注:
|
|
165
|
+
* - 它同时保留 ground truth 事件列表和一个 RunCostCollector;
|
|
166
|
+
* - 父子 run 通过 scope.parentRunId 关联,方便验证 B.3 的 childrenTotal。
|
|
167
|
+
*/
|
|
168
|
+
declare function createMockTelemetryPort(): MockTelemetryPortHarness;
|
|
169
|
+
|
|
170
|
+
type RunHandle<TRequest extends RunRequestSnapshot$1> = RunHandle$1<TRequest>;
|
|
171
|
+
type RunRecord$1 = RunRecord$2;
|
|
172
|
+
type RunRequestSnapshot = RunRequestSnapshot$1;
|
|
173
|
+
type RunExecutorPort<TRequest extends RunRequestSnapshot> = RunExecutorPort$1<TRequest>;
|
|
174
|
+
interface RunSupervisorHarness<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
175
|
+
supervisor: DefaultRunSupervisor<TRequest>;
|
|
176
|
+
registry: MemoryRunRegistryStore;
|
|
177
|
+
eventStore: MemoryEventStore;
|
|
178
|
+
eventBus: EventBus;
|
|
179
|
+
audit: CollectingAuditPortHarness;
|
|
180
|
+
telemetry: MockTelemetryPortHarness;
|
|
181
|
+
registerRun(params?: Partial<{
|
|
182
|
+
runId: string;
|
|
183
|
+
parentRunId: string;
|
|
184
|
+
conversationId: string;
|
|
185
|
+
agentSpec: AgentSpec;
|
|
186
|
+
request: TRequest;
|
|
187
|
+
metadata: Record<string, unknown>;
|
|
188
|
+
}>): Promise<RunHandle<TRequest>>;
|
|
189
|
+
spawnDetached(params?: Partial<{
|
|
190
|
+
runId: string;
|
|
191
|
+
parentRunId: string;
|
|
192
|
+
conversationId: string;
|
|
193
|
+
agentSpec: AgentSpec;
|
|
194
|
+
request: TRequest;
|
|
195
|
+
metadata: Record<string, unknown>;
|
|
196
|
+
}>): Promise<RunHandle<TRequest>>;
|
|
197
|
+
publish(event: RuntimeEvent, seq?: number): void;
|
|
198
|
+
persist(event: RuntimeEvent, eventId?: string): Promise<void>;
|
|
199
|
+
getRegisteredRuns(): Promise<RunRecord$1[]>;
|
|
200
|
+
restore(): void;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* RunSupervisor 一站式测试夹具。
|
|
204
|
+
*
|
|
205
|
+
* 中文备注:
|
|
206
|
+
* - 只使用 linnkit package 内部 port,不依赖具体 host;
|
|
207
|
+
* - 适合协议测试、外部接入方测试、Quickstart/CLI 的最小 run 验证。
|
|
208
|
+
*/
|
|
209
|
+
declare function createRunSupervisorHarness<TRequest extends RunRequestSnapshot = RunRequestSnapshot>(options?: Partial<{
|
|
210
|
+
executionId: string;
|
|
211
|
+
now: () => number;
|
|
212
|
+
runIdFactory: () => string;
|
|
213
|
+
executor: RunExecutorPort<TRequest>;
|
|
214
|
+
}>): RunSupervisorHarness<TRequest>;
|
|
215
|
+
|
|
216
|
+
type PersistedEvent = PersistedEvent$1;
|
|
217
|
+
type RunCost = RunCost$1;
|
|
218
|
+
type RunRecord = RunRecord$2;
|
|
219
|
+
type RunOutcome = RunOutcome$1;
|
|
220
|
+
type TelemetryEvent = TelemetryEvent$2;
|
|
221
|
+
type RunInvariantId = 'I1_FINAL_STATUS' | 'I2_CHILDREN_COST_TOTAL' | 'I3_TOOL_CALL_OUTPUT_PAIR' | 'I4_LLM_MODEL_SELECT_AUDIT' | 'I5_CANCEL_AUDIT' | 'I6_EVENT_RUN_CONTEXT' | 'I7_PERSISTED_EVENT_ORDER' | 'I8_NO_ACTION_EVENT' | 'I9_CANCEL_SIGNAL_STATUS' | 'I10_TELEMETRY_RUN_REGISTERED' | 'I11_COST_NON_NEGATIVE' | 'I12_AUDIT_RUN_REGISTERED' | 'I13_WAIT_USER_STATUS' | 'I14_DETACHED_TERMINAL_OUTCOME' | 'I15_DRAIN_NO_INFLIGHT';
|
|
222
|
+
interface RunInvariantFailure {
|
|
223
|
+
id: RunInvariantId;
|
|
224
|
+
title: string;
|
|
225
|
+
message: string;
|
|
226
|
+
details?: Record<string, unknown>;
|
|
227
|
+
}
|
|
228
|
+
interface RunInvariantReport {
|
|
229
|
+
ok: boolean;
|
|
230
|
+
failures: RunInvariantFailure[];
|
|
231
|
+
}
|
|
232
|
+
interface RunInvariantContext {
|
|
233
|
+
rootRunId: string;
|
|
234
|
+
runRecords: readonly RunRecord[];
|
|
235
|
+
events?: readonly RuntimeEvent[];
|
|
236
|
+
persistedEvents?: readonly PersistedEvent[];
|
|
237
|
+
telemetryEvents?: readonly TelemetryEvent[];
|
|
238
|
+
auditEnvelopes?: readonly AuditEnvelope[];
|
|
239
|
+
terminalOutcomes?: readonly RunOutcome[];
|
|
240
|
+
inFlightRunIds?: readonly string[];
|
|
241
|
+
signal?: AbortSignal;
|
|
242
|
+
getCost?: (runId: string) => RunCost | Promise<RunCost>;
|
|
243
|
+
}
|
|
244
|
+
interface ValidateRunInvariantsOptions {
|
|
245
|
+
enabled?: readonly RunInvariantId[];
|
|
246
|
+
disabled?: readonly RunInvariantId[];
|
|
247
|
+
/**
|
|
248
|
+
* 中文备注:
|
|
249
|
+
* N-3.B.0 只给同步 child-run 透传 runId,并未正式注册 child RunRecord。
|
|
250
|
+
* 默认严格校验会暴露这个缺口;过渡测试可显式允许 parentRunId 场景下的未注册 child telemetry。
|
|
251
|
+
*/
|
|
252
|
+
allowUnregisteredChildTelemetry?: boolean;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare function validateRunInvariants(context: RunInvariantContext, options?: ValidateRunInvariantsOptions): Promise<RunInvariantReport>;
|
|
256
|
+
declare function assertRunInvariants(report: RunInvariantReport): void;
|
|
257
|
+
|
|
258
|
+
interface MockTokenizerPortOptions {
|
|
259
|
+
/** 每段 text 固定返回的 token 数,默认 10。 */
|
|
260
|
+
tokensPerText?: number;
|
|
261
|
+
/** 每条 message 固定返回的 token 数,默认 50。 */
|
|
262
|
+
tokensPerMessage?: number;
|
|
263
|
+
/** 自定义 text 估算逻辑,优先级高于 tokensPerText。 */
|
|
264
|
+
estimateText?: (text: string, modelId?: string) => number;
|
|
265
|
+
/** 自定义 message 估算逻辑,优先级高于 tokensPerMessage。 */
|
|
266
|
+
estimateMessage?: (message: LlmRequestMessage, modelId?: string) => number;
|
|
267
|
+
}
|
|
268
|
+
declare function createMockTokenizerPort(options?: MockTokenizerPortOptions): TokenizerPort;
|
|
269
|
+
|
|
270
|
+
type ToolContextCompatibilityFields = ToolContextCompatibilityFields$1;
|
|
271
|
+
type ToolExecutionContext = ToolExecutionContext$1;
|
|
272
|
+
type ToolContextPatch = ToolContextPatch$1;
|
|
273
|
+
type ToolContextFixture = ToolExecutionContext & ToolContextCompatibilityFields & Record<string, unknown>;
|
|
274
|
+
interface ToolContextFixtureOptions {
|
|
275
|
+
conversationId?: string;
|
|
276
|
+
turnId?: string;
|
|
277
|
+
historyEvents?: RuntimeEvent[];
|
|
278
|
+
workingHistoryEvents?: RuntimeEvent[];
|
|
279
|
+
persistedHistoryEvents?: RuntimeEvent[];
|
|
280
|
+
patch?: ToolContextPatch;
|
|
281
|
+
}
|
|
282
|
+
declare function createToolContextFixture(options?: ToolContextFixtureOptions): ToolContextFixture;
|
|
283
|
+
|
|
284
|
+
export { type CollectingAuditPortHarness, type ContextPolicyInvariantContext, type ContextPolicyInvariantFailure, type ContextPolicyInvariantId, type ContextPolicyInvariantReport, type ContextPolicyInvariantValidator, type MockTelemetryPortHarness, type MockTokenizerPortOptions, type ReplayHarness, type RunInvariantContext, type RunInvariantFailure, type RunInvariantId, type RunInvariantReport, type RunSupervisorHarness, type ScriptedAiEngineHarness, type ScriptedAiEngineHarnessOptions, type ScriptedLlmCall, type ScriptedLlmTurn, type ScriptedToolCall, type TelemetryUsageTotal, type ToolContextFixture, type ToolContextFixtureOptions, type ValidateContextPolicyInvariantsOptions, type ValidateRunInvariantsOptions, assertContextPolicyInvariants, assertRunInvariants, assertions, createCollectingAuditPort, createMockTelemetryPort, createMockTokenizerPort, createReplayHarness, createRunSupervisorHarness, createScriptedAiEngineHarness, createToolContextFixture, expectFinalStepForcedTools, expectMessagesContainText, expectMessagesContainToolResult, expectRunEndedWithFinalAnswer, expectToolOutputFedBackToHistory, validateContextPolicyInvariants, validateRunInvariants };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { L as LlmCallOptions$1, a as LlmRequestMessage } from './ai-engine.types-vZRnQcJa.js';
|
|
2
|
+
import { f as LlmCaller$1, K as TelemetryEvent$2, D as DefaultRunSupervisor, t as MemoryRunRegistryStore, p as MemoryEventStore, u as RunExecutorPort$1, v as RunOutcome$1, q as ToolContextPatch$1 } from './defaultGraphExecutor-BBswR8wn.js';
|
|
3
|
+
export { P as DefaultGraphExecutorOptions, Q as GraphLoopHarness, U as GraphLoopHarnessOptions, V as GraphLoopHarnessRunResult, W as GraphLoopLlmNodeFactoryParams, X as createDefaultGraphExecutor, Y as createGraphLoopHarness } from './defaultGraphExecutor-BBswR8wn.js';
|
|
4
|
+
import { e as RuntimeEvent } from './todo-B1PmDlp3.js';
|
|
5
|
+
import { A as AiMessage } from './messages-XthmnHZ3.js';
|
|
6
|
+
import { e as AgentSpecContextPolicy, a as AgentSpec } from './agentSpec-EkmviZjy.js';
|
|
7
|
+
import { d as ContextTrace } from './context-trace-DRi5M4lX.js';
|
|
8
|
+
import { T as TokenizerPort } from './tokenizer-DFL4I7-I.js';
|
|
9
|
+
import { e as AuditEnvelope } from './audit-BaRUGaqv.js';
|
|
10
|
+
import { b as AuditPort } from './audit-CtcfART1.js';
|
|
11
|
+
import { f as RunCostCollector$1, n as RunRequestSnapshot$1, b as EventBus, h as RunHandle$1, l as RunRecord$2, P as PersistedEvent$1, e as RunCost$1 } from './runHandle-CyXvzgzk.js';
|
|
12
|
+
import { T as ToolExecutionContext$1, f as ToolContextCompatibilityFields$1 } from './toolContracts-Blll0241.js';
|
|
13
|
+
import './agent-invocation-BznDaXDs.js';
|
|
14
|
+
import './agentEvents-DEB7Fy_J.js';
|
|
15
|
+
import './ports-DnLuKfpE.js';
|
|
16
|
+
import 'zod';
|
|
17
|
+
import './execution-CAIypb41.js';
|
|
18
|
+
|
|
19
|
+
type LlmCaller = LlmCaller$1;
|
|
20
|
+
type LlmCallOptions = LlmCallOptions$1;
|
|
21
|
+
interface ScriptedLlmCall {
|
|
22
|
+
modelId: string;
|
|
23
|
+
messages: unknown[];
|
|
24
|
+
options: LlmCallOptions & {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
stream_options?: {
|
|
27
|
+
include_usage?: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface ScriptedToolCall {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
argumentsJson: string;
|
|
35
|
+
index?: number;
|
|
36
|
+
}
|
|
37
|
+
interface ScriptedLlmTurn {
|
|
38
|
+
thoughtDeltas?: string[];
|
|
39
|
+
contentChunks?: string[];
|
|
40
|
+
toolCalls?: ScriptedToolCall[];
|
|
41
|
+
reasoningDetails?: unknown[];
|
|
42
|
+
usage?: unknown;
|
|
43
|
+
finishReason?: string;
|
|
44
|
+
error?: string | Error;
|
|
45
|
+
throwAfterCallbacks?: string | Error;
|
|
46
|
+
assertCall?: (call: ScriptedLlmCall) => void;
|
|
47
|
+
}
|
|
48
|
+
interface ScriptedAiEngineHarness {
|
|
49
|
+
getCalls(): ScriptedLlmCall[];
|
|
50
|
+
getConsumedTurnCount(): number;
|
|
51
|
+
getLlmCaller(): LlmCaller;
|
|
52
|
+
assertAllTurnsConsumed(): void;
|
|
53
|
+
restore(): void;
|
|
54
|
+
}
|
|
55
|
+
interface ScriptedAiEngineHarnessOptions {
|
|
56
|
+
/**
|
|
57
|
+
* 迁移期兼容开关:历史上可把 scripted engine patch 到模块级 `aiEngine`。
|
|
58
|
+
*
|
|
59
|
+
* 中文备注:
|
|
60
|
+
* - `src/agent/testkit/*` 现在不再依赖 `src/core/aiEngine`;
|
|
61
|
+
* - 新旧测试都应显式注入 `getLlmCaller()`;
|
|
62
|
+
* - 若仍传入 `true`,直接抛错,避免 package boundary 悄悄回退。
|
|
63
|
+
*/
|
|
64
|
+
patchModuleAiEngine?: boolean;
|
|
65
|
+
}
|
|
66
|
+
declare function createScriptedAiEngineHarness(turns: ScriptedLlmTurn[], options?: ScriptedAiEngineHarnessOptions): ScriptedAiEngineHarness;
|
|
67
|
+
|
|
68
|
+
declare function expectMessagesContainToolResult(call: ScriptedLlmCall, expectedText: string): void;
|
|
69
|
+
declare function expectToolOutputFedBackToHistory(call: ScriptedLlmCall, expectedText: string): void;
|
|
70
|
+
declare function expectFinalStepForcedTools(call: ScriptedLlmCall, forcedToolName: string): void;
|
|
71
|
+
declare function expectRunEndedWithFinalAnswer(events: RuntimeEvent[], expectedText: string): void;
|
|
72
|
+
declare function expectMessagesContainText(call: ScriptedLlmCall, expectedText: string): void;
|
|
73
|
+
|
|
74
|
+
declare const assertions_expectFinalStepForcedTools: typeof expectFinalStepForcedTools;
|
|
75
|
+
declare const assertions_expectMessagesContainText: typeof expectMessagesContainText;
|
|
76
|
+
declare const assertions_expectMessagesContainToolResult: typeof expectMessagesContainToolResult;
|
|
77
|
+
declare const assertions_expectRunEndedWithFinalAnswer: typeof expectRunEndedWithFinalAnswer;
|
|
78
|
+
declare const assertions_expectToolOutputFedBackToHistory: typeof expectToolOutputFedBackToHistory;
|
|
79
|
+
declare namespace assertions {
|
|
80
|
+
export { assertions_expectFinalStepForcedTools as expectFinalStepForcedTools, assertions_expectMessagesContainText as expectMessagesContainText, assertions_expectMessagesContainToolResult as expectMessagesContainToolResult, assertions_expectRunEndedWithFinalAnswer as expectRunEndedWithFinalAnswer, assertions_expectToolOutputFedBackToHistory as expectToolOutputFedBackToHistory };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 中文备注:
|
|
85
|
+
* - ReplayHarness 负责把“持久化事实事件 -> LLM 回放消息”这个协议边界显式化;
|
|
86
|
+
* - 测试不再直接散落调用 eventConverter,而是通过统一夹具观察回放结果;
|
|
87
|
+
* - 这样后续如果回放语义升级,测试入口可以保持稳定。
|
|
88
|
+
*/
|
|
89
|
+
interface ReplayHarness {
|
|
90
|
+
replay(): AiMessage[];
|
|
91
|
+
getAssistantToolCallMessages(): AiMessage[];
|
|
92
|
+
getToolOutputMessages(): AiMessage[];
|
|
93
|
+
}
|
|
94
|
+
declare function createReplayHarness(events: RuntimeEvent[]): ReplayHarness;
|
|
95
|
+
|
|
96
|
+
type ContextPolicyInvariantId = 'C1_TRACE_ENABLED_MATCHES_POLICY' | 'C2_EFFECTIVE_POLICY_MATCHES_EXPECTED' | 'C3_TRACE_OPTIONS_MATCH_POLICY' | 'C4_TRACE_EVENT_LIMIT' | 'C5_FINAL_COUNTS_MATCH_MESSAGES' | 'C6_FINAL_TOKENS_WITHIN_BUDGET' | 'C7_PROVIDER_TOKEN_DELTA' | 'C8_TRACE_DETAIL_OPTIONS' | 'C9_MESSAGE_DECISION_REASON' | 'C10_TOOL_PAIR_DECISIONS_STAY_TOGETHER' | 'C11_MUST_KEEP_TYPES_KEPT' | 'C12_HOST_TOKENIZER_DRIVES_BUDGET';
|
|
97
|
+
interface ContextPolicyInvariantFailure {
|
|
98
|
+
id: ContextPolicyInvariantId;
|
|
99
|
+
title: string;
|
|
100
|
+
message: string;
|
|
101
|
+
details?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
interface ContextPolicyInvariantReport {
|
|
104
|
+
ok: boolean;
|
|
105
|
+
failures: ContextPolicyInvariantFailure[];
|
|
106
|
+
}
|
|
107
|
+
interface ContextPolicyInvariantContext {
|
|
108
|
+
expectedPolicy?: AgentSpecContextPolicy;
|
|
109
|
+
trace?: ContextTrace;
|
|
110
|
+
originalMessages?: readonly AiMessage[];
|
|
111
|
+
finalMessages?: readonly AiMessage[];
|
|
112
|
+
tokenizer?: TokenizerPort;
|
|
113
|
+
tokenizerModelId?: string;
|
|
114
|
+
}
|
|
115
|
+
type ContextPolicyInvariantValidator = (context: ContextPolicyInvariantContext) => ContextPolicyInvariantFailure[];
|
|
116
|
+
interface ValidateContextPolicyInvariantsOptions {
|
|
117
|
+
enabled?: readonly ContextPolicyInvariantId[];
|
|
118
|
+
disabled?: readonly ContextPolicyInvariantId[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare function validateContextPolicyInvariants(context: ContextPolicyInvariantContext, options?: ValidateContextPolicyInvariantsOptions): ContextPolicyInvariantReport;
|
|
122
|
+
declare function assertContextPolicyInvariants(report: ContextPolicyInvariantReport): void;
|
|
123
|
+
|
|
124
|
+
interface CollectingAuditPortHarness {
|
|
125
|
+
port: AuditPort;
|
|
126
|
+
getEnvelopes(action?: string): AuditEnvelope[];
|
|
127
|
+
assertEmitted(action: string): AuditEnvelope;
|
|
128
|
+
assertEmittedInOrder(actions: readonly string[]): AuditEnvelope[];
|
|
129
|
+
reset(): void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 收集型 AuditPort。
|
|
133
|
+
*
|
|
134
|
+
* 中文备注:
|
|
135
|
+
* - 用于测试“某次 run 做过哪些决策”,不写文件、不进 EventStore;
|
|
136
|
+
* - 断言方法故意抛普通 Error,让 Vitest/Jest 能直接显示友好的失败原因。
|
|
137
|
+
*/
|
|
138
|
+
declare function createCollectingAuditPort(): CollectingAuditPortHarness;
|
|
139
|
+
|
|
140
|
+
type TelemetryEvent$1 = TelemetryEvent$2;
|
|
141
|
+
type RunCostCollector = RunCostCollector$1;
|
|
142
|
+
interface TelemetryUsageTotal {
|
|
143
|
+
tokensInput: number;
|
|
144
|
+
tokensOutput: number;
|
|
145
|
+
latencyMs: number;
|
|
146
|
+
llmCallCount: number;
|
|
147
|
+
toolCallCount: number;
|
|
148
|
+
}
|
|
149
|
+
interface MockTelemetryPortHarness {
|
|
150
|
+
port: {
|
|
151
|
+
emit(event: TelemetryEvent$1): void;
|
|
152
|
+
flush(): Promise<void>;
|
|
153
|
+
};
|
|
154
|
+
costCollector: RunCostCollector;
|
|
155
|
+
emit(event: TelemetryEvent$1): void;
|
|
156
|
+
getEvents(runId?: string): TelemetryEvent$1[];
|
|
157
|
+
getTotalUsageByRun(runId: string): TelemetryUsageTotal;
|
|
158
|
+
getKnownRunIds(): string[];
|
|
159
|
+
reset(): void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* TelemetryPort 测试夹具。
|
|
163
|
+
*
|
|
164
|
+
* 中文备注:
|
|
165
|
+
* - 它同时保留 ground truth 事件列表和一个 RunCostCollector;
|
|
166
|
+
* - 父子 run 通过 scope.parentRunId 关联,方便验证 B.3 的 childrenTotal。
|
|
167
|
+
*/
|
|
168
|
+
declare function createMockTelemetryPort(): MockTelemetryPortHarness;
|
|
169
|
+
|
|
170
|
+
type RunHandle<TRequest extends RunRequestSnapshot$1> = RunHandle$1<TRequest>;
|
|
171
|
+
type RunRecord$1 = RunRecord$2;
|
|
172
|
+
type RunRequestSnapshot = RunRequestSnapshot$1;
|
|
173
|
+
type RunExecutorPort<TRequest extends RunRequestSnapshot> = RunExecutorPort$1<TRequest>;
|
|
174
|
+
interface RunSupervisorHarness<TRequest extends RunRequestSnapshot = RunRequestSnapshot> {
|
|
175
|
+
supervisor: DefaultRunSupervisor<TRequest>;
|
|
176
|
+
registry: MemoryRunRegistryStore;
|
|
177
|
+
eventStore: MemoryEventStore;
|
|
178
|
+
eventBus: EventBus;
|
|
179
|
+
audit: CollectingAuditPortHarness;
|
|
180
|
+
telemetry: MockTelemetryPortHarness;
|
|
181
|
+
registerRun(params?: Partial<{
|
|
182
|
+
runId: string;
|
|
183
|
+
parentRunId: string;
|
|
184
|
+
conversationId: string;
|
|
185
|
+
agentSpec: AgentSpec;
|
|
186
|
+
request: TRequest;
|
|
187
|
+
metadata: Record<string, unknown>;
|
|
188
|
+
}>): Promise<RunHandle<TRequest>>;
|
|
189
|
+
spawnDetached(params?: Partial<{
|
|
190
|
+
runId: string;
|
|
191
|
+
parentRunId: string;
|
|
192
|
+
conversationId: string;
|
|
193
|
+
agentSpec: AgentSpec;
|
|
194
|
+
request: TRequest;
|
|
195
|
+
metadata: Record<string, unknown>;
|
|
196
|
+
}>): Promise<RunHandle<TRequest>>;
|
|
197
|
+
publish(event: RuntimeEvent, seq?: number): void;
|
|
198
|
+
persist(event: RuntimeEvent, eventId?: string): Promise<void>;
|
|
199
|
+
getRegisteredRuns(): Promise<RunRecord$1[]>;
|
|
200
|
+
restore(): void;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* RunSupervisor 一站式测试夹具。
|
|
204
|
+
*
|
|
205
|
+
* 中文备注:
|
|
206
|
+
* - 只使用 linnkit package 内部 port,不依赖具体 host;
|
|
207
|
+
* - 适合协议测试、外部接入方测试、Quickstart/CLI 的最小 run 验证。
|
|
208
|
+
*/
|
|
209
|
+
declare function createRunSupervisorHarness<TRequest extends RunRequestSnapshot = RunRequestSnapshot>(options?: Partial<{
|
|
210
|
+
executionId: string;
|
|
211
|
+
now: () => number;
|
|
212
|
+
runIdFactory: () => string;
|
|
213
|
+
executor: RunExecutorPort<TRequest>;
|
|
214
|
+
}>): RunSupervisorHarness<TRequest>;
|
|
215
|
+
|
|
216
|
+
type PersistedEvent = PersistedEvent$1;
|
|
217
|
+
type RunCost = RunCost$1;
|
|
218
|
+
type RunRecord = RunRecord$2;
|
|
219
|
+
type RunOutcome = RunOutcome$1;
|
|
220
|
+
type TelemetryEvent = TelemetryEvent$2;
|
|
221
|
+
type RunInvariantId = 'I1_FINAL_STATUS' | 'I2_CHILDREN_COST_TOTAL' | 'I3_TOOL_CALL_OUTPUT_PAIR' | 'I4_LLM_MODEL_SELECT_AUDIT' | 'I5_CANCEL_AUDIT' | 'I6_EVENT_RUN_CONTEXT' | 'I7_PERSISTED_EVENT_ORDER' | 'I8_NO_ACTION_EVENT' | 'I9_CANCEL_SIGNAL_STATUS' | 'I10_TELEMETRY_RUN_REGISTERED' | 'I11_COST_NON_NEGATIVE' | 'I12_AUDIT_RUN_REGISTERED' | 'I13_WAIT_USER_STATUS' | 'I14_DETACHED_TERMINAL_OUTCOME' | 'I15_DRAIN_NO_INFLIGHT';
|
|
222
|
+
interface RunInvariantFailure {
|
|
223
|
+
id: RunInvariantId;
|
|
224
|
+
title: string;
|
|
225
|
+
message: string;
|
|
226
|
+
details?: Record<string, unknown>;
|
|
227
|
+
}
|
|
228
|
+
interface RunInvariantReport {
|
|
229
|
+
ok: boolean;
|
|
230
|
+
failures: RunInvariantFailure[];
|
|
231
|
+
}
|
|
232
|
+
interface RunInvariantContext {
|
|
233
|
+
rootRunId: string;
|
|
234
|
+
runRecords: readonly RunRecord[];
|
|
235
|
+
events?: readonly RuntimeEvent[];
|
|
236
|
+
persistedEvents?: readonly PersistedEvent[];
|
|
237
|
+
telemetryEvents?: readonly TelemetryEvent[];
|
|
238
|
+
auditEnvelopes?: readonly AuditEnvelope[];
|
|
239
|
+
terminalOutcomes?: readonly RunOutcome[];
|
|
240
|
+
inFlightRunIds?: readonly string[];
|
|
241
|
+
signal?: AbortSignal;
|
|
242
|
+
getCost?: (runId: string) => RunCost | Promise<RunCost>;
|
|
243
|
+
}
|
|
244
|
+
interface ValidateRunInvariantsOptions {
|
|
245
|
+
enabled?: readonly RunInvariantId[];
|
|
246
|
+
disabled?: readonly RunInvariantId[];
|
|
247
|
+
/**
|
|
248
|
+
* 中文备注:
|
|
249
|
+
* N-3.B.0 只给同步 child-run 透传 runId,并未正式注册 child RunRecord。
|
|
250
|
+
* 默认严格校验会暴露这个缺口;过渡测试可显式允许 parentRunId 场景下的未注册 child telemetry。
|
|
251
|
+
*/
|
|
252
|
+
allowUnregisteredChildTelemetry?: boolean;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare function validateRunInvariants(context: RunInvariantContext, options?: ValidateRunInvariantsOptions): Promise<RunInvariantReport>;
|
|
256
|
+
declare function assertRunInvariants(report: RunInvariantReport): void;
|
|
257
|
+
|
|
258
|
+
interface MockTokenizerPortOptions {
|
|
259
|
+
/** 每段 text 固定返回的 token 数,默认 10。 */
|
|
260
|
+
tokensPerText?: number;
|
|
261
|
+
/** 每条 message 固定返回的 token 数,默认 50。 */
|
|
262
|
+
tokensPerMessage?: number;
|
|
263
|
+
/** 自定义 text 估算逻辑,优先级高于 tokensPerText。 */
|
|
264
|
+
estimateText?: (text: string, modelId?: string) => number;
|
|
265
|
+
/** 自定义 message 估算逻辑,优先级高于 tokensPerMessage。 */
|
|
266
|
+
estimateMessage?: (message: LlmRequestMessage, modelId?: string) => number;
|
|
267
|
+
}
|
|
268
|
+
declare function createMockTokenizerPort(options?: MockTokenizerPortOptions): TokenizerPort;
|
|
269
|
+
|
|
270
|
+
type ToolContextCompatibilityFields = ToolContextCompatibilityFields$1;
|
|
271
|
+
type ToolExecutionContext = ToolExecutionContext$1;
|
|
272
|
+
type ToolContextPatch = ToolContextPatch$1;
|
|
273
|
+
type ToolContextFixture = ToolExecutionContext & ToolContextCompatibilityFields & Record<string, unknown>;
|
|
274
|
+
interface ToolContextFixtureOptions {
|
|
275
|
+
conversationId?: string;
|
|
276
|
+
turnId?: string;
|
|
277
|
+
historyEvents?: RuntimeEvent[];
|
|
278
|
+
workingHistoryEvents?: RuntimeEvent[];
|
|
279
|
+
persistedHistoryEvents?: RuntimeEvent[];
|
|
280
|
+
patch?: ToolContextPatch;
|
|
281
|
+
}
|
|
282
|
+
declare function createToolContextFixture(options?: ToolContextFixtureOptions): ToolContextFixture;
|
|
283
|
+
|
|
284
|
+
export { type CollectingAuditPortHarness, type ContextPolicyInvariantContext, type ContextPolicyInvariantFailure, type ContextPolicyInvariantId, type ContextPolicyInvariantReport, type ContextPolicyInvariantValidator, type MockTelemetryPortHarness, type MockTokenizerPortOptions, type ReplayHarness, type RunInvariantContext, type RunInvariantFailure, type RunInvariantId, type RunInvariantReport, type RunSupervisorHarness, type ScriptedAiEngineHarness, type ScriptedAiEngineHarnessOptions, type ScriptedLlmCall, type ScriptedLlmTurn, type ScriptedToolCall, type TelemetryUsageTotal, type ToolContextFixture, type ToolContextFixtureOptions, type ValidateContextPolicyInvariantsOptions, type ValidateRunInvariantsOptions, assertContextPolicyInvariants, assertRunInvariants, assertions, createCollectingAuditPort, createMockTelemetryPort, createMockTokenizerPort, createReplayHarness, createRunSupervisorHarness, createScriptedAiEngineHarness, createToolContextFixture, expectFinalStepForcedTools, expectMessagesContainText, expectMessagesContainToolResult, expectRunEndedWithFinalAnswer, expectToolOutputFedBackToHistory, validateContextPolicyInvariants, validateRunInvariants };
|