@reinsjs/core 0.11.0 → 0.12.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 +6 -0
- package/README.md +1 -1
- package/dist/core-h3S4jFh-.d.ts +1256 -0
- package/dist/index.d.ts +10 -572
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types-CFO8uTd0.d.ts +0 -682
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as Event,
|
|
2
|
-
export {
|
|
1
|
+
import { E as Event, T as ToolCallEvent, a as ToolResultEvent, b as EventLog, L as LoopConfig, c as EventDraft, R as RunResult, S as SerializedRunState, M as ModelRef, d as Tool, e as SubagentInterruption, f as ToolSpec, C as ContentPart, g as ToolResult, h as Trust, i as CoreEventOf, j as CoreEventDraft, P as ProjectionBudget, k as ProjectionStrategy, l as ProjectionContext, m as TokenEstimator, n as EventSchemaRegistry, o as ProjectionResult, p as ProjectionStats, B as BudgetUsagePayload, q as BlobStore, r as BlobMeta, s as ReadOptions, t as MemoryStore, u as RunLease, v as Stores } from './core-h3S4jFh-.js';
|
|
2
|
+
export { A as Actor, w as AnyEvent, x as ApprovalDecisionInput, y as ApprovalDecisionPayload, z as ApprovalRequestPayload, D as ApprovalRequestSpec, F as AudioPart, G as BeforeModelPatch, H as BeforeToolDecision, I as BoundModel, J as CORE_SCHEMAS, K as CompactionPayload, N as CoreEvent, O as CoreEventPayloads, Q as CoreEventType, U as CreateEventInput, V as DEFAULT_RETRY_BASE_DELAY_MS, W as DEFAULT_RETRY_MAX_ATTEMPTS, X as DEFAULT_RETRY_MAX_DELAY_MS, Y as DEFAULT_TRUST, Z as ErrorEventPayload, _ as ErrorPayload, $ as EventBase, a0 as EventSchema, a1 as ExtEvent, a2 as HandoffIntent, a3 as HandoffPayload, a4 as ImagePart, a5 as Interruption, a6 as LandingRecord, a7 as LandingSpec, a8 as LossKind, a9 as LossMatrix, aa as LoweredRequest, ab as Lowering, ac as LoweringCapabilities, ad as LoweringDelta, ae as LoweringOutcome, af as LoweringStreamContext, ag as MaybePromise, ah as MemoryOpPayload, ai as ModelCallFailure, aj as ModelTextPayload, ak as ModelThinkingPayload, al as PauseReason, am as Principal, an as ProjectionStep, ao as ProjectionStepStats, ap as Provenance, aq as PullInputContext, ar as ResolvedRetry, as as RetryOptions, at as RunPausedPayload, au as RunResumedPayload, av as SchemaError, aw as SchemaErrorCode, ax as SessionInfo, ay as SkillSource, az as Socket, aA as SocketSetup, aB as StaticContribution, aC as SystemNotePayload, aD as TextPart, aE as ToRequestInput, aF as TokenUsage, aG as ToolBatch, aH as ToolCallPayload, aI as ToolContext, aJ as ToolReferencePart, aK as ToolResultDraft, aL as ToolResultPayload, aM as ToolSide, aN as ToolStartedPayload, aO as ToolsBoundPayload, aP as TurnContext, aQ as TurnDecision, aR as Upcaster, aS as UserMessagePayload, aT as VideoPart, aU as backoffDelayMs, aV as contextOverheadOf, aW as contextTokensOf, aX as createCoreEvent, aY as createCoreRegistry, aZ as createEvent, a_ as defaultSleep, a$ as isTransientFailure, b0 as lossesOf, b1 as renderToolReference, b2 as resolveRetry, b3 as statusFromMessage } from './core-h3S4jFh-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* UUID v7 生成(RFC 9562):前 48 位为 Unix 毫秒时间戳,字典序即时间序。
|
|
@@ -9,574 +9,6 @@ export { s as Actor, t as AnyEvent, u as ApprovalDecisionPayload, v as AudioPart
|
|
|
9
9
|
*/
|
|
10
10
|
declare function uuidv7(now?: number): string;
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* 投影(技术方案 §8):输入完整时间线,输出模型本轮应看到的事件。
|
|
14
|
-
*
|
|
15
|
-
* 投影是纯函数:同一份时间线快照、同样的参数,输出必须逐字相同。这让它可单测、可回放、
|
|
16
|
-
* 可在 eval 里对比不同策略。任何"随机"(事件 id)与"时间"(at)都从 ctx 注入,不在策略里 Date.now()。
|
|
17
|
-
*
|
|
18
|
-
* 策略链按顺序执行,每个策略拿到上一步的结果与不变的上下文,输出新的事件序列。
|
|
19
|
-
* 策略可以新造事件(如阈值兜底的 compaction),但必须通过 `emitted` 交出去由循环 append 进日志,
|
|
20
|
-
* 否则违反"模型可见 ⟺ 已记录"。
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
interface ProjectionBudget {
|
|
24
|
-
/** 模型上下文窗口上限(token) */
|
|
25
|
-
contextLimit: number;
|
|
26
|
-
/** 为模型输出预留的 token;裁剪目标 = contextLimit - reserveTokens,按真实上下文(估算 + overheadTokens)比 */
|
|
27
|
-
reserveTokens: number;
|
|
28
|
-
/**
|
|
29
|
-
* 估算不含的固定开销(系统提示、工具表、thinking 等),见 contextOverheadOf。project() 总会填;
|
|
30
|
-
* 自己拼上下文直接调策略时缺省按 0
|
|
31
|
-
*/
|
|
32
|
-
overheadTokens?: number;
|
|
33
|
-
}
|
|
34
|
-
/** 估算一条事件降级后大约占多少 token。核心包不带 tokenizer,默认是粗估,宿主可注入精确实现。 */
|
|
35
|
-
type TokenEstimator = (event: Event) => number;
|
|
36
|
-
/** 策略执行时能看到的一切。全部只读;策略之间不共享可变状态。 */
|
|
37
|
-
interface ProjectionContext {
|
|
38
|
-
readonly sessionId: string;
|
|
39
|
-
/** 完整时间线快照,按 seq 升序。策略要回看被前序策略移除的事件时用 */
|
|
40
|
-
readonly timeline: readonly Event[];
|
|
41
|
-
readonly budget: ProjectionBudget;
|
|
42
|
-
readonly estimate: TokenEstimator;
|
|
43
|
-
/** 新造事件取 schemaVersion 用 */
|
|
44
|
-
readonly registry: EventSchemaRegistry;
|
|
45
|
-
/** 本次投影的时间戳;新造事件的 at 一律取它 */
|
|
46
|
-
readonly now: number;
|
|
47
|
-
/** 新造事件的 id 工厂;测试可注入确定值 */
|
|
48
|
-
readonly newId: (at: number) => string;
|
|
49
|
-
/** 前序策略已新造、待 append 的事件 */
|
|
50
|
-
readonly emitted: readonly Event[];
|
|
51
|
-
/** 下一条新造事件应使用的 seq:时间线末尾 + 已新造数 + 1 */
|
|
52
|
-
nextSeq(): number;
|
|
53
|
-
}
|
|
54
|
-
interface ProjectionStep {
|
|
55
|
-
/** 本策略之后模型应看到的事件序列。顺序即模型看到的顺序,不必与 seq 一致 */
|
|
56
|
-
events: Event[];
|
|
57
|
-
/**
|
|
58
|
-
* 本策略新造、需要由循环 append 进日志的事件。
|
|
59
|
-
* 必须同时出现在 events 里 —— 模型看到的每一条都要落日志。
|
|
60
|
-
*/
|
|
61
|
-
emitted?: Event[];
|
|
62
|
-
}
|
|
63
|
-
interface ProjectionStrategy {
|
|
64
|
-
readonly name: string;
|
|
65
|
-
apply(events: readonly Event[], ctx: ProjectionContext): ProjectionStep;
|
|
66
|
-
}
|
|
67
|
-
interface ProjectionStepStats {
|
|
68
|
-
name: string;
|
|
69
|
-
/** 进入该策略前 / 后的事件数 */
|
|
70
|
-
before: number;
|
|
71
|
-
after: number;
|
|
72
|
-
}
|
|
73
|
-
interface ProjectionStats {
|
|
74
|
-
/** 最终可见事件的估算 token 总量 */
|
|
75
|
-
estimatedTokens: number;
|
|
76
|
-
/** contextLimit - reserveTokens,真实上下文口径:estimatedTokens + overheadTokens 超过它就兜底裁剪 */
|
|
77
|
-
targetTokens: number;
|
|
78
|
-
/** 本次投影用的固定开销(缺省从时间线校准,见 contextOverheadOf) */
|
|
79
|
-
overheadTokens: number;
|
|
80
|
-
/** 裁到不能再裁仍超目标(估算 + 开销):只剩最后一轮也放不下,需要 spill 或更大的窗口。循环层据此告警 */
|
|
81
|
-
overBudget: boolean;
|
|
82
|
-
steps: ProjectionStepStats[];
|
|
83
|
-
}
|
|
84
|
-
interface ProjectionResult {
|
|
85
|
-
/** 模型本轮看到的事件 */
|
|
86
|
-
events: Event[];
|
|
87
|
-
/**
|
|
88
|
-
* 投影新造、循环必须 append 进日志的事件,seq 已按时间线末尾预分配。
|
|
89
|
-
* append 时 seq 冲突**不重跑投影**,`StoreError("seq_conflict")` 原样抛给宿主(R4,DECISIONS 2026-09-10):
|
|
90
|
-
* run 进行中还有人往同一会话追加,是会话级并发违规(server 用 409 一会话一 run 挡它),静默重跑只会把并发写入藏起来
|
|
91
|
-
*/
|
|
92
|
-
emitted: Event[];
|
|
93
|
-
stats: ProjectionStats;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
interface RetryOptions {
|
|
97
|
-
/** 最多尝试几次(含第一次)。缺省 3;1 = 不重试 */
|
|
98
|
-
maxAttempts?: number;
|
|
99
|
-
/** 首次重试前等多久(毫秒),之后每次翻倍。缺省 1000 */
|
|
100
|
-
baseDelayMs?: number;
|
|
101
|
-
/** 单次等待上限(毫秒)。缺省 8000 */
|
|
102
|
-
maxDelayMs?: number;
|
|
103
|
-
/** 覆盖瞬断判定:返回 true 表示值得重试。缺省见 isTransientFailure */
|
|
104
|
-
isTransient?: (failure: ModelCallFailure) => boolean;
|
|
105
|
-
/** 测试注入:等待实现。缺省 setTimeout,且被 signal 中止时提前结束 */
|
|
106
|
-
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
107
|
-
}
|
|
108
|
-
/** 一次模型调用失败的两种形态:降级层抛了异常,或流正常收尾但 stopReason = error */
|
|
109
|
-
type ModelCallFailure = {
|
|
110
|
-
kind: "thrown";
|
|
111
|
-
error: unknown;
|
|
112
|
-
} | {
|
|
113
|
-
kind: "outcome";
|
|
114
|
-
message: string;
|
|
115
|
-
};
|
|
116
|
-
declare const DEFAULT_RETRY_MAX_ATTEMPTS = 3;
|
|
117
|
-
declare const DEFAULT_RETRY_BASE_DELAY_MS = 1000;
|
|
118
|
-
declare const DEFAULT_RETRY_MAX_DELAY_MS = 8000;
|
|
119
|
-
/**
|
|
120
|
-
* 从错误文案里提取 HTTP 状态码:开头的三位数字(SDK 格式 "<status> <body>"),或 "status (code) 503" / "HTTP 503" 写法。
|
|
121
|
-
* 只认 100~599,不在这两个位置上的数字不算(正文里提到 "429" 不是状态码)
|
|
122
|
-
*/
|
|
123
|
-
declare function statusFromMessage(message: string): number | undefined;
|
|
124
|
-
declare function isTransientFailure(failure: ModelCallFailure): boolean;
|
|
125
|
-
/** 第 attempt 次失败后等多久:base × 2^(attempt−1),封顶 maxDelay。不加抖动,保证可测、可回放 */
|
|
126
|
-
declare function backoffDelayMs(attempt: number, opts?: Pick<RetryOptions, "baseDelayMs" | "maxDelayMs">): number;
|
|
127
|
-
/** 缺省等待:setTimeout;signal 中止就立刻返回(由调用方检查 aborted 再决定怎么收尾) */
|
|
128
|
-
declare function defaultSleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
129
|
-
interface ResolvedRetry {
|
|
130
|
-
maxAttempts: number;
|
|
131
|
-
delayFor: (attempt: number) => number;
|
|
132
|
-
isTransient: (failure: ModelCallFailure) => boolean;
|
|
133
|
-
sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
134
|
-
}
|
|
135
|
-
declare function resolveRetry(opts?: RetryOptions): ResolvedRetry;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 循环与插座的类型(技术方案 §6、§7、§10)。
|
|
139
|
-
*
|
|
140
|
-
* 三组契约:
|
|
141
|
-
* - Tool:宿主给模型的能力(§10 四个正交维度);循环只用 name / inputSchema / execute / needsApproval 等少数字段,
|
|
142
|
-
* 其余维度(lazy、resultPolicy、ui…)留给脑子模块与后续期次消费,先把形状定下来。
|
|
143
|
-
* - Socket:脑子与底盘之间唯一的契约,五个钩子。脑子只依赖它,不依赖 runLoop 的实现(P3、P4)。
|
|
144
|
-
* - RunResult / SerializedRunState:暂停是显式返回值,状态小到能放 URL 参数(P6)。
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
/** 主事人:本次 run 代表谁。库只透传给钩子与工具,不解释其字段 */
|
|
148
|
-
interface Principal {
|
|
149
|
-
id: string;
|
|
150
|
-
[key: string]: unknown;
|
|
151
|
-
}
|
|
152
|
-
interface SessionInfo {
|
|
153
|
-
id: string;
|
|
154
|
-
/** 本次 run 内的第几轮(从 1 起) */
|
|
155
|
-
turn: number;
|
|
156
|
-
}
|
|
157
|
-
type ToolSide = "server" | "client" | "sandbox" | "provider";
|
|
158
|
-
/** 工具执行结果的规范形态;execute 可以返回任何值,循环用 normalizeToolOutput 归一 */
|
|
159
|
-
interface ToolResult {
|
|
160
|
-
content: ContentPart[];
|
|
161
|
-
isError?: boolean;
|
|
162
|
-
}
|
|
163
|
-
interface ToolContext {
|
|
164
|
-
sessionId: string;
|
|
165
|
-
toolCallId: string;
|
|
166
|
-
principal?: Principal;
|
|
167
|
-
log: EventLog;
|
|
168
|
-
blobs?: BlobStore;
|
|
169
|
-
memory?: MemoryStore;
|
|
170
|
-
signal?: AbortSignal;
|
|
171
|
-
/** 工具想留痕(如 memory_op):草稿由循环补齐后、在 tool_result 之前 append */
|
|
172
|
-
emit(draft: EventDraft): void;
|
|
173
|
-
/**
|
|
174
|
-
* 宿主本次续跑给**别的会话**(子代理)的审批结论(`ApprovalDecisionInput.sessionId` 指向非本会话的那些),循环不校验、不记事件,
|
|
175
|
-
* 原样转发;`asTool` 把它们交给子 run,多层嵌套逐层下传。没有就缺省(§10.1)
|
|
176
|
-
*/
|
|
177
|
-
decisions?: readonly ApprovalDecisionInput[];
|
|
178
|
-
/**
|
|
179
|
-
* 把工具代跑的模型用量(子代理的 run)计入本 run 的预算:只加 `TurnContext.budget.tokensSpent`,父的 budget 模块按总账拦。
|
|
180
|
-
* 不追加父的 budget_usage 事件(那条是感知校准上下文大小的依据)。宿主循环提供;没提供的环境里工具只把用量写进结果
|
|
181
|
-
*/
|
|
182
|
-
spend?(usage: TokenUsage): void;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* 工具。execute / validate 用"方法签名"而非属性函数:TS 对方法参数做双变检查,
|
|
186
|
-
* 这样 Tool<{ path: string }> 才能放进 Tool[](即 Tool<unknown>[])里。
|
|
187
|
-
* needsApproval 是 boolean | 函数 的联合,无法写成方法,带类型入参的工具请用 defineTool() 定义。
|
|
188
|
-
*/
|
|
189
|
-
interface Tool<TInput = unknown> {
|
|
190
|
-
name: string;
|
|
191
|
-
description: string;
|
|
192
|
-
/** JSON Schema 对象,原样交给模型;不绑任何校验库 */
|
|
193
|
-
inputSchema: Record<string, unknown>;
|
|
194
|
-
/** 可选的入参校验/转换:返回规范化入参,抛错即视为入参不合法(结果以 isError 告知模型) */
|
|
195
|
-
validate?(input: unknown): TInput;
|
|
196
|
-
/** 执行位置;缺省 server。client 表示由宿主前端执行,循环遇到即暂停等结果 */
|
|
197
|
-
side?: ToolSide;
|
|
198
|
-
/** 缺省表示本循环不执行(转客户端) */
|
|
199
|
-
execute?(input: TInput, ctx: ToolContext): Promise<unknown> | unknown;
|
|
200
|
-
/** 把 execute 的返回值翻译成模型看到的内容片段;缺省规则见 normalizeToolOutput */
|
|
201
|
-
toModelOutput?(output: unknown): ContentPart[];
|
|
202
|
-
/** 结果处置:超限截断或外溢(B4 消费) */
|
|
203
|
-
resultPolicy?: {
|
|
204
|
-
maxTokens?: number;
|
|
205
|
-
overflow: "truncate" | "spill";
|
|
206
|
-
};
|
|
207
|
-
/** 执行前是否要人审批。循环内置兜底:为真且没有任何 Socket 做主时,直接转审批暂停(安全默认值) */
|
|
208
|
-
needsApproval?: boolean | ((input: TInput, ctx: ToolContext) => Promise<boolean> | boolean);
|
|
209
|
-
risk?: "low" | "medium" | "high";
|
|
210
|
-
/**
|
|
211
|
-
* 开始动手后中断(进程死亡、执行中被掐断)、没留下结果时,续跑能不能再执行一遍。缺省按 risk:只有 `"low"` 可重放(`isReplayable`)。
|
|
212
|
-
* 不可重放的调用在 execute 之前落一条 `core.tool_started`,续跑时见到它就落"结果未知"让模型先查再定,不再执行——写工具重复执行
|
|
213
|
-
* 就是重复改用户的东西。幂等的写工具可以显式 `true`;asTool 子代理显式 `true`(子会话自己能续跑)
|
|
214
|
-
*/
|
|
215
|
-
replayable?: boolean;
|
|
216
|
-
/**
|
|
217
|
-
* 这个工具**成功**结果事件(tool_result)的 trust;缺省 `DEFAULT_TRUST.tool`(untrusted:翻译给模型时包 `<untrusted>` 标记)。
|
|
218
|
-
* 只有输出等同宿主配置的工具才声明 `"system"`——如 brain 的 `skill_read`(技能是宿主写的说明书,视同系统提示)。
|
|
219
|
-
* 刻意只开 system / untrusted 两档:principal 是用户本人的权威、model 是模型自己的话,工具输出冒充哪一个都不对。
|
|
220
|
-
* 落法只有一份纯函数 `toolResultTrust(tool, isError)`:循环(执行结果、宿主回填的客户端工具结果)与 TanStack 适配器
|
|
221
|
-
* (afterToolCall、toolPhaseComplete)都调它;isError 结果、未知工具、入参不合法、执行抛错一律缺省。
|
|
222
|
-
*/
|
|
223
|
-
resultTrust?: Extract<Trust, "system" | "untrusted">;
|
|
224
|
-
/** 暴露策略:延迟加载/发现(后续期次) */
|
|
225
|
-
lazy?: boolean;
|
|
226
|
-
allowedCallers?: ("direct" | "code")[];
|
|
227
|
-
/** MCP Apps 形态(第三期) */
|
|
228
|
-
ui?: {
|
|
229
|
-
resourceUri: string;
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
type ToolCallEvent = CoreEventOf<"core.tool_call">;
|
|
233
|
-
type ToolResultEvent = CoreEventOf<"core.tool_result">;
|
|
234
|
-
type ToolResultDraft = EventDraft<"core.tool_result", ToolResultPayload>;
|
|
235
|
-
/** beforeModel 的返回:改投影、增删工具、换系统提示;缺省字段表示不改 */
|
|
236
|
-
interface BeforeModelPatch {
|
|
237
|
-
events?: Event[];
|
|
238
|
-
tools?: Tool[];
|
|
239
|
-
systemPrompt?: string;
|
|
240
|
-
/**
|
|
241
|
-
* 本轮工具表里哪些只"向厂商声明、不载入上下文"(按名字;L1)。循环把它翻成 `ToolSpec.deferLoading`,
|
|
242
|
-
* 名字不在最终工具表里的忽略。只在 `ctx.capabilities.deferredTools` 为真时有意义——没有原生落点的降级层会直接不发这些工具。
|
|
243
|
-
* 后一个 Socket 给了就整体替换前一个的;没给就沿用
|
|
244
|
-
*/
|
|
245
|
-
deferredTools?: readonly string[];
|
|
246
|
-
}
|
|
247
|
-
/** 审批请求的规格;toolCallId 由循环填 */
|
|
248
|
-
interface ApprovalRequestSpec {
|
|
249
|
-
policyId: string;
|
|
250
|
-
summary: string;
|
|
251
|
-
}
|
|
252
|
-
type BeforeToolDecision = "proceed" | {
|
|
253
|
-
block: string;
|
|
254
|
-
} | {
|
|
255
|
-
defer: ApprovalRequestSpec;
|
|
256
|
-
} | {
|
|
257
|
-
rewrite: unknown;
|
|
258
|
-
};
|
|
259
|
-
interface HandoffIntent {
|
|
260
|
-
/** 缺省由循环生成 */
|
|
261
|
-
toSessionId?: string;
|
|
262
|
-
summary: string;
|
|
263
|
-
/** 触发交接的那条用户消息,新会话据此续做 */
|
|
264
|
-
triggerMessage?: string;
|
|
265
|
-
reason: string;
|
|
266
|
-
/** 谁决定交接:模型(默认,经 handoff 工具)或宿主 */
|
|
267
|
-
by?: "model" | "host";
|
|
268
|
-
/**
|
|
269
|
-
* 新会话开头额外追加的事件草稿(B5):排在摘要说明(seq 1)之后、触发消息之前,如带过去的 pin。
|
|
270
|
-
* 循环只补齐 id / seq / at / sessionId,不解释内容。
|
|
271
|
-
*/
|
|
272
|
-
opening?: EventDraft[];
|
|
273
|
-
}
|
|
274
|
-
type TurnDecision = "continue" | "stop" | {
|
|
275
|
-
handoff: HandoffIntent;
|
|
276
|
-
} | {
|
|
277
|
-
pause: {
|
|
278
|
-
reason: "budget" | "host";
|
|
279
|
-
note?: string;
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
283
|
-
interface TurnContext {
|
|
284
|
-
session: SessionInfo;
|
|
285
|
-
principal?: Principal;
|
|
286
|
-
/** 当前投影结果,即模型本轮将看到的事件(可读) */
|
|
287
|
-
events: Event[];
|
|
288
|
-
/** 完整时间线快照(脑子模块回看被折叠的事件时用) */
|
|
289
|
-
timeline: readonly Event[];
|
|
290
|
-
log: EventLog;
|
|
291
|
-
blobs?: BlobStore;
|
|
292
|
-
memory?: MemoryStore;
|
|
293
|
-
/** 本轮可用工具 */
|
|
294
|
-
tools: readonly Tool[];
|
|
295
|
-
model: ModelRef;
|
|
296
|
-
/** 本模型支持什么(中途 system、thinking 回放、并行工具…) */
|
|
297
|
-
capabilities: LoweringCapabilities;
|
|
298
|
-
budget: {
|
|
299
|
-
contextLimit: number;
|
|
300
|
-
/**
|
|
301
|
-
* 投影的裁剪目标 = contextLimit - reserveTokens,真实上下文口径:本轮估算 + 固定开销(contextOverheadOf(timeline))
|
|
302
|
-
* 超过它库就按阈值自动折叠最旧的轮次(感知用同一函数校准、据此提醒模型)
|
|
303
|
-
*/
|
|
304
|
-
targetTokens: number;
|
|
305
|
-
/** 本轮投影的估算 token */
|
|
306
|
-
used: number;
|
|
307
|
-
/** 本次 run 累计消耗(输入 + 输出) */
|
|
308
|
-
tokensSpent: number;
|
|
309
|
-
turns: number;
|
|
310
|
-
toolCalls: number;
|
|
311
|
-
/** 距 run 开始的毫秒数;beforeModel 时是本轮开始的读数,模型调用后更新 */
|
|
312
|
-
wallMs: number;
|
|
313
|
-
/**
|
|
314
|
-
* 最近一次模型请求的真实用量(B8):beforeModel 时是上一次请求的(含上次 run,从日志最后一条 budget_usage 读),
|
|
315
|
-
* 模型调用后即本轮的。上下文大小用 contextTokensOf(lastUsage) 算,不是 input
|
|
316
|
-
*/
|
|
317
|
-
lastUsage?: TokenUsage;
|
|
318
|
-
};
|
|
319
|
-
signal?: AbortSignal;
|
|
320
|
-
/**
|
|
321
|
-
* 本批工具调用的活动(2026-11-02,OnSet 建议 9 / 10):模型这次发了哪些调用、已落了哪些结果、哪些被挂起、是不是补跑。
|
|
322
|
-
* 同一个对象在本轮内由循环随落随更——beforeTool 处理第 k 个调用时只看得见它之前落下的结果;不要拿快照比较
|
|
323
|
-
*/
|
|
324
|
-
batch: ToolBatch;
|
|
325
|
-
/** 草稿:无 id / seq / at / sessionId,循环补齐后 append。beforeModel 期间 emit 的本轮即可见 */
|
|
326
|
-
emit(draft: EventDraft): void;
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* "一批" = 一段连续模型输出里的 tool_call(与 replay 切轮 `isModelOutput` 同口径,模型不可见的运维事件不切段),
|
|
330
|
-
* 定位规则只有一份:`toolBatchOf`。Socket 只读;循环(runLoop、TanStack 适配器)负责填。
|
|
331
|
-
*/
|
|
332
|
-
interface ToolBatch {
|
|
333
|
-
/** 本批调用,按执行顺序。模型输出前(beforeModel)为空;补跑时是遗留调用所在那批的全部 tool_call */
|
|
334
|
-
readonly calls: readonly ToolCallEvent[];
|
|
335
|
-
/**
|
|
336
|
-
* 本批已落日志的 tool_result(afterTool 替换之后、真正落日志的那条),按落下顺序。
|
|
337
|
-
* 补跑时预置上次已落的(含宿主经 input 回填的客户端工具结果)
|
|
338
|
-
*/
|
|
339
|
-
readonly results: readonly ToolResultEvent[];
|
|
340
|
-
/** 本批已处理但被挂起、没落结果的 toolCallId(等审批 / 等客户端回填 / 子代理暂停)。TanStack 路径恒为空(defer 让整批暂停) */
|
|
341
|
-
readonly held: readonly string[];
|
|
342
|
-
/** 本批是续跑补齐上次遗留的调用(没有新的模型输出) */
|
|
343
|
-
readonly resumed: boolean;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* 静态贡献的运行环境(B6):run 起步时给每个 Socket 看一次,让它按"有哪些存储、给谁跑"决定带不带工具与规则。
|
|
347
|
-
* 只暴露跨请求不变或整个 run 不变的东西;每轮变化的信息(视图、预算)走 TurnContext。
|
|
348
|
-
*/
|
|
349
|
-
interface SocketSetup {
|
|
350
|
-
log: EventLog;
|
|
351
|
-
blobs?: BlobStore;
|
|
352
|
-
memory?: MemoryStore;
|
|
353
|
-
model: ModelRef;
|
|
354
|
-
principal?: Principal;
|
|
355
|
-
/** 宿主自己的工具(尚未并入任何 Socket 的贡献) */
|
|
356
|
-
hostTools: readonly Tool[];
|
|
357
|
-
/**
|
|
358
|
-
* 到本 Socket 为止已并入的工具表(2026-09-22):宿主工具 + 注册在本 Socket **之前**的各 Socket 贡献,按同名先到者为准去重后。
|
|
359
|
-
* 各 Socket 按注册顺序依次解析,所以排在后面的能看见前面的,反过来不行——lazy-tools 靠它把 MCP 等 Socket 贡献的
|
|
360
|
-
* `lazy: true` 工具也收进菜单,前提是 `lazyTools()` 注册在 `mcpTools()` 之后。本 Socket 自己的贡献不在其中
|
|
361
|
-
*/
|
|
362
|
-
tools: readonly Tool[];
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* 静态贡献:常量,或按运行环境算一次的函数(返回 undefined 表示这次不贡献)。
|
|
366
|
-
* 函数可以是异步的(P1):MCP 模块的工具表要在 run 起步时向服务器 `tools/list` 一次,同步解析不可能成立;
|
|
367
|
-
* 代价只是 `resolveSocketContributions` 变成 async,调用它的三处(循环起步、server 预校验、TanStack 适配器)本就在异步上下文里。
|
|
368
|
-
*/
|
|
369
|
-
type StaticContribution<T> = T | ((setup: SocketSetup) => T | undefined | Promise<T | undefined>);
|
|
370
|
-
/**
|
|
371
|
-
* 脑子与底盘之间唯一的契约。多个 Socket 按注册顺序执行。
|
|
372
|
-
* 钩子可以不返回(无意见),返回值的合并规则见 runLoop 各处注释。
|
|
373
|
-
*
|
|
374
|
-
* 静态贡献与动态补丁分两条路:
|
|
375
|
-
* - `tools` / `systemPrompt` 是模块给整个 run 的**静态**贡献(如 compact 工具与它的规则提示)。循环起步时并进
|
|
376
|
-
* 工具表与系统提示,整个 run 不变 —— 满足 prompt cache 约束(系统提示与工具表每轮稳定,§9.1),
|
|
377
|
-
* 续跑补齐 pending 调用时也在场,并计入 configHash(恢复时能察觉模块被拆装)。
|
|
378
|
-
* - `beforeModel` 的补丁是**动态**改动(宿主换场景、按 principal 增删工具),每改一次缓存前缀重算,别拿它做每轮的事。
|
|
379
|
-
*/
|
|
380
|
-
interface Socket {
|
|
381
|
-
/** 便于日志与排错 */
|
|
382
|
-
name?: string;
|
|
383
|
-
/**
|
|
384
|
-
* 模块带给模型的工具,整个 run 不变;与 LoopConfig.tools 同名时以后者为准。
|
|
385
|
-
* 可以是函数:run 起步时按运行环境算一次(如 memory 模块在没有 MemoryStore 时不注册工具,§5"缺则不注册")。
|
|
386
|
-
*/
|
|
387
|
-
tools?: StaticContribution<readonly Tool[]>;
|
|
388
|
-
/** 模块的规则提示片段,追加在宿主系统提示之后(空行分隔),整个 run 不变;同样可以是按环境算一次的函数 */
|
|
389
|
-
systemPrompt?: StaticContribution<string>;
|
|
390
|
-
beforeModel?(ctx: TurnContext): MaybePromise<BeforeModelPatch | undefined>;
|
|
391
|
-
afterModel?(ctx: TurnContext, events: Event[]): MaybePromise<void>;
|
|
392
|
-
/**
|
|
393
|
-
* 任一 block / defer 即中止该调用;rewrite 替换入参后继续问下一个 Socket(后面的在 call.payload.args 里看到改写后的入参)。
|
|
394
|
-
* 宿主已批准(approval_decision.approved)的调用再遇到 defer 只是略过、继续问后面的 Socket:批准解决的是"要不要问人",
|
|
395
|
-
* 排在后面的审批策略仍可 block —— deny 不可被覆盖(§9.7)。
|
|
396
|
-
*/
|
|
397
|
-
beforeTool?(ctx: TurnContext, call: ToolCallEvent, tool: Tool | undefined): MaybePromise<BeforeToolDecision | undefined>;
|
|
398
|
-
/** 返回新草稿即替换(如外溢后的指引),结果此时尚未 append */
|
|
399
|
-
afterTool?(ctx: TurnContext, call: ToolCallEvent, result: ToolResultDraft): MaybePromise<ToolResultDraft | undefined>;
|
|
400
|
-
/** 第一个给出意见的 Socket 决定;都无意见时:本轮有工具调用则继续,否则结束 */
|
|
401
|
-
onTurnEnd?(ctx: TurnContext): MaybePromise<TurnDecision | undefined>;
|
|
402
|
-
}
|
|
403
|
-
type PauseReason = "approval" | "budget" | "host";
|
|
404
|
-
type Interruption = {
|
|
405
|
-
kind: "approval";
|
|
406
|
-
toolCallId: string;
|
|
407
|
-
request: ApprovalRequestPayload;
|
|
408
|
-
call: ToolCallPayload;
|
|
409
|
-
} | {
|
|
410
|
-
kind: "client_tool";
|
|
411
|
-
toolCallId: string;
|
|
412
|
-
call: ToolCallPayload;
|
|
413
|
-
} | {
|
|
414
|
-
kind: "budget";
|
|
415
|
-
note: string;
|
|
416
|
-
} | {
|
|
417
|
-
kind: "host";
|
|
418
|
-
note: string;
|
|
419
|
-
} | SubagentInterruption;
|
|
420
|
-
/**
|
|
421
|
-
* 子代理即工具(§10.1,`asTool`)的暂停冒泡:工具里跑的子 run 暂停了,父 run 不落这条 tool_result(调用留作 pending),
|
|
422
|
-
* 而是整体暂停并把子的中断带给宿主。宿主处理子的审批时,结论带 `sessionId: childSessionId` 放进父的 `decisions` 续跑父 run,
|
|
423
|
-
* 父续跑补齐这条 pending 时工具再续跑子 run。子 run 任何原因的暂停(approval / budget / host)都冒泡,父的 reason 综合取最需要人的那个
|
|
424
|
-
*/
|
|
425
|
-
interface SubagentInterruption {
|
|
426
|
-
kind: "subagent";
|
|
427
|
-
toolCallId: string;
|
|
428
|
-
call: ToolCallPayload;
|
|
429
|
-
childSessionId: string;
|
|
430
|
-
/** 子 run 的暂停原因 */
|
|
431
|
-
reason: PauseReason;
|
|
432
|
-
/** 子 run 自己的中断(可能再嵌 subagent) */
|
|
433
|
-
interruptions: Interruption[];
|
|
434
|
-
/** 子 run 的可序列化状态,给宿主看(续跑子 run 由工具凭 childSessionId 完成,不需要宿主传回) */
|
|
435
|
-
state: SerializedRunState;
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* 可序列化的 run 状态。只含引用,内容全部从 EventLog 重读,小到能放 URL 参数或 KV。
|
|
439
|
-
* 配置了密钥时 sig 为 HMAC-SHA256;恢复时先验签,再与日志对账(pending 调用的 ID 与入参摘要)。
|
|
440
|
-
*/
|
|
441
|
-
interface SerializedRunState {
|
|
442
|
-
v: 1;
|
|
443
|
-
sessionId: string;
|
|
444
|
-
lastSeq: number;
|
|
445
|
-
pendingToolCallIds: string[];
|
|
446
|
-
/** 模型、工具集、系统提示的摘要;恢复时配置变了要能察觉 */
|
|
447
|
-
configHash: string;
|
|
448
|
-
/** pending 调用(id、名、入参)的 SHA-256;批下去的必须是当时看到的那次调用 */
|
|
449
|
-
pendingDigest: string;
|
|
450
|
-
/**
|
|
451
|
-
* 模型引用的摘要(D4,可选、不升 v)。与 `pendingToolsDigest` 同时在场时,续跑只比对模型与 pending 工具定义,
|
|
452
|
-
* 不再整体比 configHash(加减别的工具不再拒续跑);在场即进签名材料
|
|
453
|
-
*/
|
|
454
|
-
modelDigest?: string;
|
|
455
|
-
/** pending 调用涉及的工具定义(名、描述、入参 schema)摘要,取基础工具表(D4) */
|
|
456
|
-
pendingToolsDigest?: string;
|
|
457
|
-
sig?: string;
|
|
458
|
-
}
|
|
459
|
-
/** 宿主对某次 pending 调用的审批结论;循环记成 approval_decision 事件后按它办 */
|
|
460
|
-
interface ApprovalDecisionInput {
|
|
461
|
-
toolCallId: string;
|
|
462
|
-
approved: boolean;
|
|
463
|
-
/** 谁批的:用户标识或策略 ID */
|
|
464
|
-
by: string;
|
|
465
|
-
reason?: string;
|
|
466
|
-
/**
|
|
467
|
-
* 结论针对哪个会话,缺省本会话。指向别的会话(子代理,见 `SubagentInterruption.childSessionId`)的结论本循环不校验、不记事件,
|
|
468
|
-
* 经 `ToolContext.decisions` 原样转发给工具
|
|
469
|
-
*/
|
|
470
|
-
sessionId?: string;
|
|
471
|
-
}
|
|
472
|
-
type RunResult = {
|
|
473
|
-
status: "done";
|
|
474
|
-
sessionId: string;
|
|
475
|
-
lastSeq: number;
|
|
476
|
-
} | {
|
|
477
|
-
status: "paused";
|
|
478
|
-
sessionId: string;
|
|
479
|
-
lastSeq: number;
|
|
480
|
-
reason: PauseReason;
|
|
481
|
-
interruptions: Interruption[];
|
|
482
|
-
state: SerializedRunState;
|
|
483
|
-
} | {
|
|
484
|
-
status: "handoff";
|
|
485
|
-
sessionId: string;
|
|
486
|
-
lastSeq: number;
|
|
487
|
-
toSessionId: string;
|
|
488
|
-
} | {
|
|
489
|
-
status: "error";
|
|
490
|
-
sessionId: string;
|
|
491
|
-
lastSeq: number;
|
|
492
|
-
error: CoreEventOf<"core.error">;
|
|
493
|
-
};
|
|
494
|
-
type ErrorEventPayload = ErrorPayload;
|
|
495
|
-
/** `LoopConfig.pullInput` 的参数 */
|
|
496
|
-
interface PullInputContext {
|
|
497
|
-
sessionId: string;
|
|
498
|
-
/** 将要进行的轮次(本 run 内从 1 起):拉到的输入就给这一轮的模型看 */
|
|
499
|
-
turn: number;
|
|
500
|
-
}
|
|
501
|
-
interface LoopConfig {
|
|
502
|
-
sessionId: string;
|
|
503
|
-
log: EventLog;
|
|
504
|
-
blobs?: BlobStore;
|
|
505
|
-
memory?: MemoryStore;
|
|
506
|
-
lowering: Lowering;
|
|
507
|
-
model: ModelRef;
|
|
508
|
-
tools?: readonly Tool[];
|
|
509
|
-
sockets?: readonly Socket[];
|
|
510
|
-
systemPrompt?: string;
|
|
511
|
-
/**
|
|
512
|
-
* 本次 run 要追加的新输入:字符串 / 内容片段 → user_message;也可直接给草稿(如宿主注入 system_note),
|
|
513
|
-
* 或草稿数组——一次 append、按给定顺序写入,适合"背景 + 任务":`[system_note(kind: "host"), user_message]`,
|
|
514
|
-
* 每批只放一条 user_message(compact 只保最后一条)。片段与草稿不能混排;任一草稿不合规整批拒绝、日志不写。
|
|
515
|
-
* 草稿数组只给进程内宿主,HTTP 入口只收文本 / 内容片段与两种重建过的草稿(刻意不对称)。
|
|
516
|
-
* 缺省不追加(续跑:日志里有未完成的工具调用就先补齐,再问模型)。
|
|
517
|
-
*/
|
|
518
|
-
input?: string | ContentPart[] | EventDraft | readonly EventDraft[];
|
|
519
|
-
/**
|
|
520
|
-
* run 进行中的新输入(拉,OnSet 建议 13)。循环在每次调模型前调一次——补跑 pending 的那轮与已触顶 `maxTurns` 时不调;
|
|
521
|
-
* 返回非空即一次 append 写入时间线,排在本轮 beforeModel 说明之前,空数组表示没有。
|
|
522
|
-
* 只收 `core.user_message` / `core.system_note` / `ext.*`(比 `input` 窄:拉取点上没有可回答的 pending 调用,不收 tool_result)。
|
|
523
|
-
* - 返回值不合规(非数组、白名单外类型、未登记的 ext.*):run 以 error 结束(`core.error` category "input"),这一批一条不写。
|
|
524
|
-
* - 回调抛错:记一条模型不可见的 `core.error`(category "host"),当这次没有、run 照跑(fail-open:消息还在宿主队列里)。
|
|
525
|
-
* - 拉完发现已中止:拉到的不写,按"本轮开始前中止"暂停。
|
|
526
|
-
* 宿主须在处理到写入事件时(await 完)完成认领再继续迭代,否则下一次会再拉到同一批;推荐草稿带 `provenance.ref` 记投递 id。
|
|
527
|
-
* 最后一次拉取到 run 结束之间来的消息不会进本 run:run 结束后宿主仍须查一次队列。回调挂住不返回 run 就挂住,超时由宿主自带。
|
|
528
|
-
* 每次 run 的字段:不进 `AgentDefinition`(HTTP run、asTool 子 run 不拉)。
|
|
529
|
-
*/
|
|
530
|
-
pullInput?: (ctx: PullInputContext) => MaybePromise<readonly EventDraft[]>;
|
|
531
|
-
principal?: Principal;
|
|
532
|
-
projection?: {
|
|
533
|
-
strategies?: readonly ProjectionStrategy[];
|
|
534
|
-
estimate?: TokenEstimator;
|
|
535
|
-
reserveTokens?: number;
|
|
536
|
-
};
|
|
537
|
-
/** 缺省内置 core 注册表;有 ext.* 事件时传自己的 */
|
|
538
|
-
registry?: EventSchemaRegistry;
|
|
539
|
-
/**
|
|
540
|
-
* 单次 run 的轮数上限,触顶以 paused(budget) 返回。这是循环层的兜底,不是预算模块(B8 才做细粒度预算)。
|
|
541
|
-
* 缺省 100。
|
|
542
|
-
*/
|
|
543
|
-
maxTurns?: number;
|
|
544
|
-
/** 宿主中止:当前请求停止后以 paused(host) 返回,已产出的内容仍入日志 */
|
|
545
|
-
signal?: AbortSignal;
|
|
546
|
-
/**
|
|
547
|
-
* 模型调用遇到瞬断(连接被掐、超时、过载 / 限流 / 5xx)时的有限重试,缺省最多 3 次尝试、1s 起翻倍退避。
|
|
548
|
-
* 只在本次尝试尚未写进任何模型输出时重试;宿主中止与配置错不重试。每次将要重试的失败记一条 core.error(模型不可见)。
|
|
549
|
-
* 传 { maxAttempts: 1 } 关闭。见 retry.ts。
|
|
550
|
-
*/
|
|
551
|
-
retry?: RetryOptions;
|
|
552
|
-
/** 流式增量,只给 UI 用;日志里只有完整内容块 */
|
|
553
|
-
onDelta?: (delta: LoweringDelta) => void;
|
|
554
|
-
/** 每次请求的落点记录(有损与丢弃在此可见),供宿主告警或统计 */
|
|
555
|
-
onLandings?: (records: LandingRecord[], request: LoweredRequest) => void;
|
|
556
|
-
/** 交接后宿主重绑对话锚点(聊天窗口、频道等) */
|
|
557
|
-
onHandoff?: (fromSessionId: string, toSessionId: string) => MaybePromise<void>;
|
|
558
|
-
/**
|
|
559
|
-
* 恢复:上一次 paused 返回的状态(可来自 URL 参数 / KV)。循环先校验(形状、会话、签名、配置、与日志对账),
|
|
560
|
-
* 不通过抛 RunStateError 且不写日志;通过则 append run_resumed,再从"补齐 pending 调用"接上。
|
|
561
|
-
* 不传也能续跑(同一 sessionId 再跑一次),只是少了这层校验。
|
|
562
|
-
*/
|
|
563
|
-
resume?: SerializedRunState;
|
|
564
|
-
/** 宿主给 pending 调用的审批结论,先记成 approval_decision 再执行;指向非 pending 调用即拒绝 */
|
|
565
|
-
decisions?: readonly ApprovalDecisionInput[];
|
|
566
|
-
/** 状态签名密钥。给了就签发与校验;没给则状态不签名、恢复不验签(只适合可信环境) */
|
|
567
|
-
secret?: string;
|
|
568
|
-
/** 允许在模型 / 工具集 / 系统提示变了之后恢复;缺省拒绝 */
|
|
569
|
-
allowConfigDrift?: boolean;
|
|
570
|
-
/**
|
|
571
|
-
* 工具表与上一次 run 相比有增删时,是否追加一条模型可见的 `system_note(kind=host)` 列出增删的工具名(P1,缺省开)。
|
|
572
|
-
* 关掉只是不出说明;每次 run 起步那条模型不可见的 `core.tools_bound` 快照照样记,回放与 eval 靠它知道当时有哪些工具。
|
|
573
|
-
*/
|
|
574
|
-
announceToolChanges?: boolean;
|
|
575
|
-
/** 测试注入:时间与 id 工厂 */
|
|
576
|
-
now?: () => number;
|
|
577
|
-
newId?: (at: number) => string;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
12
|
/**
|
|
581
13
|
* 工具批的定位(2026-11-02,OnSet 建议 9 / 10)。
|
|
582
14
|
*
|
|
@@ -693,6 +125,12 @@ declare class RunStateError extends Error {
|
|
|
693
125
|
constructor(code: RunStateErrorCode, message: string, context?: Record<string, unknown>);
|
|
694
126
|
}
|
|
695
127
|
declare function assertRunStateShape(raw: unknown): asserts raw is SerializedRunState;
|
|
128
|
+
/**
|
|
129
|
+
* 一条事件里可续跑的暂停状态(AdRate 建议 8):是 `core.run_paused` 且带合规形状的 `state` 才返回,否则 undefined(不抛)。
|
|
130
|
+
* 调用方传的必须是**会话末尾**那条事件——末尾之后有任何事件(续跑、停止收尾、新 run)这份状态就已过时。
|
|
131
|
+
* server 补发判"end 帧带不带 state"只走这里(真源)。返回的状态续跑时照常过 `validateResume`,这里不验签
|
|
132
|
+
*/
|
|
133
|
+
declare function pausedStateOf(event: Event | undefined): SerializedRunState | undefined;
|
|
696
134
|
/**
|
|
697
135
|
* 恢复前的全部校验。顺序有讲究:先看形状与会话,再验签名(防伪造),最后与日志对账(防篡改与错连)。
|
|
698
136
|
* 通过后返回日志里的 pending 调用,供循环继续处理。
|
|
@@ -1363,6 +801,6 @@ declare function readTimeline(log: EventLog, sessionId: string, opts: ReadTimeli
|
|
|
1363
801
|
*/
|
|
1364
802
|
|
|
1365
803
|
/** 库版本,与 packages/core/package.json 的 version 同步(发布前 `pnpm check:dist` 会核对) */
|
|
1366
|
-
declare const REINS_VERSION = "0.
|
|
804
|
+
declare const REINS_VERSION = "0.12.0";
|
|
1367
805
|
|
|
1368
|
-
export {
|
|
806
|
+
export { BUILTIN_APPROVAL_POLICY, BlobMeta, BlobStore, type BudgetTruncateOptions, BudgetUsagePayload, type CompactionEvent, ContentPart, type ContributionConfig, CoreEventDraft, CoreEventOf, DEFAULT_CUT_TO_RATIO, DEFAULT_MAX_TURNS, DEFAULT_MODEL_INVISIBLE_TYPES, DEFAULT_RESERVE_RATIO, type DecodedToolArguments, type DefaultChainOptions, Event, EventDraft, EventLog, EventSchemaRegistry, type FoldOptions, type FoldedToolResult, type FoldedToolResultOptions, type ForkOptions, INPUT_DRAFT_TYPES, INTERRUPTED_IN_PROGRESS_TEXT, INTERRUPTED_NOT_EXECUTED_TEXT, InMemoryBlobStore, InMemoryEventLog, InMemoryMemoryStore, InMemoryRunLease, LoopConfig, LoweringError, type LoweringErrorCode, type MarkedContent, MemoryStore, ModelRef, OUTCOME_UNKNOWN_TEXT, type ProjectOptions, ProjectionBudget, ProjectionContext, ProjectionResult, ProjectionStats, ProjectionStrategy, REINS_VERSION, ReadOptions, type ReadTimelineOptions, type RenderManifestOptions, type ReplayOptions, type ReplayResult, type ReplayedTurn, type ResolvedContributions, RunLease, RunResult, RunStateError, type RunStateErrorCode, RunStop, STOPPED_IN_PROGRESS_TEXT, STOPPED_NOTE, STOPPED_NOT_EXECUTED_TEXT, SerializedRunState, type StopTexts, StoreError, type StoreErrorCode, Stores, SubagentInterruption, type SubagentPause, type SubagentPauseDetail, type ThresholdSummarizer, TokenEstimator, Tool, ToolCallEvent, type ToolNamesDiff, ToolResult, ToolResultEvent, ToolSpec, type ToolsBoundEvent, Trust, UNTRUSTED_CLOSE_TAG, UNTRUSTED_TAG, type VisibilityFilterOptions, assertRunStateShape, budgetTruncate, computeConfigHash, computeModelDigest, computePendingDigest, computePendingToolsDigest, covers, decodeToolArgumentsText, defaultProjectionChain, defaultThresholdSummary, deferredToolSpecOf, defineTool, diffToolNames, digestArgs, errorMessageOf, escapeUntrustedText, estimateBudgetOf, estimateTextTokens, estimateTotal, foldCompactions, foldedToolResults, forkSession, inputDrafts, isCompaction, isContentPart, isModelOutput, isPinNote, isReplayable, isStopReason, isStopped, isSubagentPause, keptBy, lastToolsBound, markUntrusted, markUntrustedText, memoryStore, needsUntrustedMark, normalizeToolOutput, pausedStateOf, pendingToolCalls, project, readEvents, readTimeline, reinjectPins, renderFoldedToolResults, renderToolChangeNote, replayTurns, resolveSocketContributions, roughTokenEstimate, runLoop, serializeRunState, signRunState, splitTurns, startedToolCallIds, stopTextsOf, subagentPause, supersededIds, toolBatchOf, toolCallArgumentsMeta, toolResultTrust, toolSpecOf, toolsBoundDrafts, untrustedOpenTag, untrustedSourceOf, unwrapToolArguments, uuidv7, validateResume, verifyRunState, visibilityFilter };
|