@reinsjs/core 0.3.0 → 0.5.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 +14 -0
- package/README.md +1 -1
- package/dist/index.d.ts +40 -9
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/{types-DJB-13o3.d.ts → types-BOSGqMVX.d.ts} +26 -3
- package/package.json +1 -1
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BlobStore, E as EventLog, a as Event, M as MemoryStore, r as RunLease, f as LoweringCapabilities, o as CoreEventDraft, U as LoweringOutcome, a5 as ToRequestInput, L as Lowering, e as ModelRef, k as LoweredRequest, V as LoweringStreamContext, c as EventDraft } from '../types-
|
|
1
|
+
import { B as BlobStore, E as EventLog, a as Event, M as MemoryStore, r as RunLease, f as LoweringCapabilities, o as CoreEventDraft, U as LoweringOutcome, a5 as ToRequestInput, L as Lowering, e as ModelRef, k as LoweredRequest, V as LoweringStreamContext, c as EventDraft } from '../types-BOSGqMVX.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 一致性套件对测试框架的最小要求:只要 describe / it 两个函数。
|
|
@@ -139,6 +139,12 @@ interface SystemNotePayload {
|
|
|
139
139
|
* 折叠之前它照常可见(未折叠的历史原样展示)。可选字段,不升版本。
|
|
140
140
|
*/
|
|
141
141
|
supersedes?: string[];
|
|
142
|
+
/**
|
|
143
|
+
* 注入者声明这是要模型**去做**的指令(如 compact 的整理请求,OPT-261031-1),不是陈述。降级层据此选送达方式:
|
|
144
|
+
* 有的上游收下中途 system 却不执行其中的指令(踩坑 42),指令类说明一律以带标签的 user 文本送达,陈述类(感知、钉住)不受影响。
|
|
145
|
+
* 角色仍只由降级层决定(宪法二),这里只写语义。写进日志即定格:历史说明的送达方式不随升级变化,缓存前缀稳定。可选字段,不升版本。
|
|
146
|
+
*/
|
|
147
|
+
directive?: true;
|
|
142
148
|
}
|
|
143
149
|
interface ApprovalRequestPayload {
|
|
144
150
|
toolCallId: string;
|
|
@@ -155,13 +161,17 @@ interface ApprovalDecisionPayload {
|
|
|
155
161
|
}
|
|
156
162
|
/**
|
|
157
163
|
* 压缩不删原事件,只追加这一条:投影层看到它就用 summary 替代 coversSeq 范围内的事件。
|
|
158
|
-
* decidedBy
|
|
164
|
+
* decidedBy 记"谁定的时机":
|
|
165
|
+
* - `model`:模型自己挑的时机(默认路径,P1);
|
|
166
|
+
* - `forced`:用量过了软线、框架请它整理后模型照做的——时机是框架定的,摘要仍是模型写的(OPT-261030-3);
|
|
167
|
+
* - `threshold`:模型没整理、过了触发线,投影链机械裁剪。
|
|
168
|
+
* 新增取值不升 schemaVersion:注册表不校验载荷,旧日志照读。
|
|
159
169
|
*/
|
|
160
170
|
interface CompactionPayload {
|
|
161
171
|
/** 闭区间 [from, to],按 seq */
|
|
162
172
|
coversSeq: [number, number];
|
|
163
173
|
summary: string;
|
|
164
|
-
decidedBy: "model" | "threshold";
|
|
174
|
+
decidedBy: "model" | "forced" | "threshold";
|
|
165
175
|
/** 折叠后仍需重注入的钉住事件 id */
|
|
166
176
|
pinsKept: string[];
|
|
167
177
|
}
|
|
@@ -197,6 +207,19 @@ interface TokenUsage {
|
|
|
197
207
|
}
|
|
198
208
|
/** 该请求实际送进模型的上下文大小:未命中 + 缓存读 + 缓存写 */
|
|
199
209
|
declare function contextTokensOf(usage: TokenUsage): number;
|
|
210
|
+
/**
|
|
211
|
+
* 估算与真实之间的固定开销(B8):上一次请求的真实上下文 − 当时的投影估算。
|
|
212
|
+
*
|
|
213
|
+
* 投影只数模型可见事件的正文,系统提示、工具表、thinking 签名块等都不在内,真实 input 可高出一倍。
|
|
214
|
+
* 这些多出来的部分在一个 run 里基本是常量(系统提示与工具表整轮不变),所以用**加法**校准而不是比例:
|
|
215
|
+
* 比例会随历史变长把误差放大,加法只补那块固定的开销。
|
|
216
|
+
* 数据来自日志最后一条同时带 tokens 与 contextEstimate 的 budget_usage;没有可对照的请求时为 0,不为负。
|
|
217
|
+
* 那条记录算出非有限值(宿主 / 适配器写进 NaN、Infinity)也回 0:日志里一条坏用量不该让 project() 的开销校验
|
|
218
|
+
* 在 run 起步就抛错,退化成"不校准"即可。
|
|
219
|
+
*
|
|
220
|
+
* 阈值兜底(投影)与感知读数**必须**都调这一个函数:两处口径一分叉,模型被告知"到 85% 自动折叠"就不成立。
|
|
221
|
+
*/
|
|
222
|
+
declare function contextOverheadOf(timeline: readonly Event[]): number;
|
|
200
223
|
/**
|
|
201
224
|
* 用量是事件,宿主可按会话或用户聚合出配额(库不做配额)。
|
|
202
225
|
* `contextEstimate`(B8):这次请求投影的估算 token(= 当轮 TurnContext.budget.used),与真实用量放在同一条事件里,
|
|
@@ -609,4 +632,4 @@ interface Lowering<TPayload = unknown> {
|
|
|
609
632
|
stream(req: LoweredRequest<TPayload>, ctx?: LoweringStreamContext): AsyncGenerator<EventDraft, LoweringOutcome>;
|
|
610
633
|
}
|
|
611
634
|
|
|
612
|
-
export { type RunResumedPayload as $, type ApprovalRequestPayload as A, type BlobStore as B, type ContentPart as C, type CoreEventType as D, type EventLog as E, type CreateEventInput as F, DEFAULT_TRUST as G, type EventBase as H, type EventSchema as I, type ExtEvent as J, type HandoffPayload as K, type Lowering as L, type MemoryStore as M, type ImagePart as N, type LandingSpec as O, type LossKind as P, type LossMatrix as Q, type ReadOptions as R, type Stores as S, type TokenUsage as T, type LoweringOutcome as U, type LoweringStreamContext as V, type MemoryOpPayload as W, type ModelTextPayload as X, type ModelThinkingPayload as Y, type Provenance as Z, type RunPausedPayload as _, type Event as a, SchemaError as a0, type SchemaErrorCode as a1, type SkillSource as a2, type SystemNotePayload as a3, type TextPart as a4, type ToRequestInput as a5, type ToolReferencePart as a6, type ToolsBoundPayload as a7, type Upcaster as a8, type UserMessagePayload as a9,
|
|
635
|
+
export { type RunResumedPayload as $, type ApprovalRequestPayload as A, type BlobStore as B, type ContentPart as C, type CoreEventType as D, type EventLog as E, type CreateEventInput as F, DEFAULT_TRUST as G, type EventBase as H, type EventSchema as I, type ExtEvent as J, type HandoffPayload as K, type Lowering as L, type MemoryStore as M, type ImagePart as N, type LandingSpec as O, type LossKind as P, type LossMatrix as Q, type ReadOptions as R, type Stores as S, type TokenUsage as T, type LoweringOutcome as U, type LoweringStreamContext as V, type MemoryOpPayload as W, type ModelTextPayload as X, type ModelThinkingPayload as Y, type Provenance as Z, type RunPausedPayload as _, type Event as a, SchemaError as a0, type SchemaErrorCode as a1, type SkillSource as a2, type SystemNotePayload as a3, type TextPart as a4, type ToRequestInput as a5, type ToolReferencePart as a6, type ToolsBoundPayload as a7, type Upcaster as a8, type UserMessagePayload as a9, contextOverheadOf as aa, contextTokensOf as ab, createCoreEvent as ac, createCoreRegistry as ad, createEvent as ae, lossesOf as af, renderToolReference as ag, EventSchemaRegistry as b, type EventDraft as c, type Trust as d, type ModelRef as e, type LoweringCapabilities as f, type CoreEventOf as g, type ToolResultPayload as h, type LoweringDelta as i, type LandingRecord as j, type LoweredRequest as k, type ErrorPayload as l, type ToolCallPayload as m, type ToolSpec as n, type CoreEventDraft as o, type BudgetUsagePayload as p, type BlobMeta as q, type RunLease as r, type Actor as s, type AnyEvent as t, type ApprovalDecisionPayload as u, type BoundModel as v, CORE_SCHEMAS as w, type CompactionPayload as x, type CoreEvent as y, type CoreEventPayloads as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reinsjs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "reins — core: append-only event timeline, projection, the copyable runLoop, serializable run state and the Socket seam. Zero dependencies, zero node:*",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|