@reinsjs/core 0.7.0 → 0.9.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 +24 -0
- package/README.md +9 -1
- package/dist/{chunk-63AJKR7J.js → chunk-GWU2JSFA.js} +1 -1
- package/dist/chunk-GWU2JSFA.js.map +1 -0
- package/dist/index.d.ts +111 -58
- package/dist/index.js +305 -215
- package/dist/index.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{types-DrzC9Mfc.d.ts → types-BlyGZlJp.d.ts} +150 -118
- package/package.json +1 -1
- package/dist/chunk-63AJKR7J.js.map +0 -1
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BlobStore,
|
|
1
|
+
import { B as BlobStore, b as EventLog, E as Event, M as MemoryStore, r as RunLease, f as LoweringCapabilities, o as CoreEventDraft, V as LoweringOutcome, a6 as ToRequestInput, L as Lowering, e as ModelRef, k as LoweredRequest, W as LoweringStreamContext, c as EventDraft } from '../types-BlyGZlJp.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 一致性套件对测试框架的最小要求:只要 describe / it 两个函数。
|
package/dist/testing/index.js
CHANGED
|
@@ -50,9 +50,12 @@ type Event<T extends string = string, P = unknown> = EventBase & {
|
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* 内容片段。用户消息、工具结果都由它组成;投影/降级时再翻译成各家 API 的 content block。
|
|
53
|
-
*
|
|
53
|
+
* 文本、图片、视频、音频,以及"工具定义引用"(L1);大结果不塞进片段,走 tool_result.spilled 外溢到 BlobStore。
|
|
54
|
+
*
|
|
55
|
+
* 消费片段的地方一律逐类型显式分支、末尾 `const _exhaustive: never = p` 收口——
|
|
56
|
+
* "不是文本就当图片"的 else 兜底会让新加的片段类型悄悄落进图片分支(2026-11-05 视频 / 音频方案)。
|
|
54
57
|
*/
|
|
55
|
-
type ContentPart = TextPart | ImagePart | ToolReferencePart;
|
|
58
|
+
type ContentPart = TextPart | ImagePart | VideoPart | AudioPart | ToolReferencePart;
|
|
56
59
|
interface TextPart {
|
|
57
60
|
type: "text";
|
|
58
61
|
text: string;
|
|
@@ -63,6 +66,29 @@ interface ImagePart {
|
|
|
63
66
|
/** base64 编码的图片字节 */
|
|
64
67
|
data: string;
|
|
65
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* 视频片段(2026-11-05,OnSet 建议 12)。音轨算视频的一部分,不另要 `audio` 能力位;纯音频文件用 AudioPart。
|
|
71
|
+
* 模型收不收看 `LoweringCapabilities.video`,不收时降级层落文字占位并记 lossy。
|
|
72
|
+
*/
|
|
73
|
+
interface VideoPart {
|
|
74
|
+
type: "video";
|
|
75
|
+
/** 必须以 "video/" 开头 */
|
|
76
|
+
mime: string;
|
|
77
|
+
/** base64 编码的文件字节 */
|
|
78
|
+
data: string;
|
|
79
|
+
/** 时长(秒,有限正数);只用于 token 估算,没有时按字节折算(偏高)。宿主拿得到就该给 */
|
|
80
|
+
durationSec?: number;
|
|
81
|
+
}
|
|
82
|
+
/** 音频片段(2026-11-05)。模型收不收看 `LoweringCapabilities.audio` */
|
|
83
|
+
interface AudioPart {
|
|
84
|
+
type: "audio";
|
|
85
|
+
/** 必须以 "audio/" 开头 */
|
|
86
|
+
mime: string;
|
|
87
|
+
/** base64 编码的文件字节 */
|
|
88
|
+
data: string;
|
|
89
|
+
/** 时长(秒,有限正数);只用于 token 估算,没有时按字节折算(偏高) */
|
|
90
|
+
durationSec?: number;
|
|
91
|
+
}
|
|
66
92
|
/**
|
|
67
93
|
* 工具定义引用(L1,2026-09-15):`tool_find` 这类"取回工具"的结果用它表达"这几件工具从现在起可用"。
|
|
68
94
|
* 带完整定义快照,日志自足(宪法二:模型可见的一切都在日志里);翻译时按能力分两路——
|
|
@@ -394,121 +420,6 @@ declare function createEvent<T extends string, P>(registry: EventSchemaRegistry,
|
|
|
394
420
|
/** 内置事件的强类型版本:type 与 payload 联动校验。 */
|
|
395
421
|
declare function createCoreEvent<T extends CoreEventType>(registry: EventSchemaRegistry, input: CreateEventInput<T, CoreEventPayloads[T]>): CoreEventOf<T>;
|
|
396
422
|
|
|
397
|
-
/**
|
|
398
|
-
* 存储接口(技术方案 §5)。四者相互独立,允许部分实现:
|
|
399
|
-
* - 只有 EventLog 就能跑
|
|
400
|
-
* - 缺 BlobStore → spill 模块自动关闭并告警
|
|
401
|
-
* - 缺 MemoryStore → memory 工具不注册
|
|
402
|
-
* - 缺 RunLease → run 登记只在进程内(多实例部署要它,见 D4)
|
|
403
|
-
*
|
|
404
|
-
* 每个接口的行为契约由 ../testing 下的一致性套件定义,第三方后端跑同一套件即可自证合规。
|
|
405
|
-
*/
|
|
406
|
-
|
|
407
|
-
interface ReadOptions {
|
|
408
|
-
/** 起始 seq,含;缺省从 1 */
|
|
409
|
-
fromSeq?: number;
|
|
410
|
-
/** 结束 seq,含;缺省到末尾 */
|
|
411
|
-
toSeq?: number;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* 事件日志:只 append,永不 update / delete(宪法二)。
|
|
415
|
-
*
|
|
416
|
-
* seq 由调用方分配(通常是 runLoop),日志只校验:同一批必须同会话、seq 从当前末尾 +1 起连续。
|
|
417
|
-
* 这样并发写入者会在 append 时收到 seq_conflict,而不是静默交错 —— 乐观并发控制就这么简单。
|
|
418
|
-
*/
|
|
419
|
-
interface EventLog {
|
|
420
|
-
/** 同会话原子:整批要么全部写入,要么一个都不写 */
|
|
421
|
-
append(events: readonly Event[]): Promise<void>;
|
|
422
|
-
/** 按 seq 升序流式读取;不存在的会话得到空流 */
|
|
423
|
-
read(sessionId: string, opts?: ReadOptions): AsyncIterable<Event>;
|
|
424
|
-
/** 最后 n 条,按 seq 升序;不够 n 条就返回全部 */
|
|
425
|
-
tail(sessionId: string, n: number): Promise<Event[]>;
|
|
426
|
-
/**
|
|
427
|
-
* 从 fromSessionId 的 [1, atSeq] 分叉出新会话 toSessionId。
|
|
428
|
-
* 事件原样复制(保留 id 与 seq,只换 sessionId),以维持 parentId / pinsKept 等会话内引用。
|
|
429
|
-
* 目标会话必须为空;atSeq 超出范围报错。
|
|
430
|
-
*/
|
|
431
|
-
fork(fromSessionId: string, atSeq: number, toSessionId: string): Promise<void>;
|
|
432
|
-
}
|
|
433
|
-
interface BlobMeta {
|
|
434
|
-
mime: string;
|
|
435
|
-
sessionId: string;
|
|
436
|
-
/** 字节数 */
|
|
437
|
-
size: number;
|
|
438
|
-
/** Unix 毫秒 */
|
|
439
|
-
createdAt: number;
|
|
440
|
-
}
|
|
441
|
-
/** 大对象:外溢的工具结果、附件、代码执行产物。字符串按 UTF-8 编码存储。 */
|
|
442
|
-
interface BlobStore {
|
|
443
|
-
put(bytes: Uint8Array | string, meta: {
|
|
444
|
-
mime: string;
|
|
445
|
-
sessionId: string;
|
|
446
|
-
}): Promise<{
|
|
447
|
-
id: string;
|
|
448
|
-
}>;
|
|
449
|
-
/** 不存在抛 StoreError("not_found") */
|
|
450
|
-
get(id: string): Promise<{
|
|
451
|
-
bytes: Uint8Array;
|
|
452
|
-
meta: BlobMeta;
|
|
453
|
-
}>;
|
|
454
|
-
/** 可选:分段取回 [start, end),供模型分页读大结果;越界部分截断 */
|
|
455
|
-
slice?(id: string, range: {
|
|
456
|
-
start: number;
|
|
457
|
-
end: number;
|
|
458
|
-
}): Promise<Uint8Array>;
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* 记忆后端:一个极简的文本 KV,键是路径。
|
|
462
|
-
* 路径限定(必须在 /memories 下、禁止 ..)由 memory 工具层负责(B6),存储层只管存取。
|
|
463
|
-
*/
|
|
464
|
-
interface MemoryStore {
|
|
465
|
-
/** 所有以 prefix 开头的路径,按字典序 */
|
|
466
|
-
list(prefix: string): Promise<string[]>;
|
|
467
|
-
/** 不存在返回 null */
|
|
468
|
-
read(path: string): Promise<string | null>;
|
|
469
|
-
/** 覆盖写 */
|
|
470
|
-
write(path: string, content: string): Promise<void>;
|
|
471
|
-
/** 幂等:不存在也不报错 */
|
|
472
|
-
delete(path: string): Promise<void>;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* 技能载体(技术方案 §9.9,S1):MemoryStore 的只读子集。任何 MemoryStore(内存 / sqlite / pg)天然满足,
|
|
476
|
-
* 数据库载体零新代码;文件系统载体 `fsSkillSource(dir)` 在 `@reinsjs/brain/node`。刻意不新造接口——"存哪"由宿主定。
|
|
477
|
-
*/
|
|
478
|
-
type SkillSource = Pick<MemoryStore, "list" | "read">;
|
|
479
|
-
/**
|
|
480
|
-
* run 租约(D4,2026-09-14):多实例部署下"同一会话同时只允许一个 run"的跨进程登记表。
|
|
481
|
-
*
|
|
482
|
-
* 语义是**带过期时间的独占锁**:`acquire` 在无人持有、持有者已过期、或持有者就是自己时成功;
|
|
483
|
-
* 持有者每隔一段时间 `renew` 续期,进程崩了不续期,到期后别的实例就能接手;`release` 只删自己持有的。
|
|
484
|
-
* 过期判定用**存储层自己的时钟**(数据库时间),不用各实例本机时钟——租约的意义是各实例对"谁持有"达成一致,
|
|
485
|
-
* 判定时钟必须唯一。三个方法都不抛"冲突"类错误,用返回值说话;存储不可用时照常抛。
|
|
486
|
-
*
|
|
487
|
-
* 心跳、丢租约中止、失败告警这些行为放在 `@reinsjs/server` 的 `leasedRunRegistry` 一份,store 只做三条语句。
|
|
488
|
-
* 单进程部署不需要它(进程内登记表已够),`memoryStore()` 刻意不带;`InMemoryRunLease` 是参考实现与测试用。
|
|
489
|
-
*/
|
|
490
|
-
interface RunLease {
|
|
491
|
-
/**
|
|
492
|
-
* 为会话占租约 ttlMs 毫秒。无人持有、持有者已过期、或持有者就是 owner(幂等,等于续期)→ true;
|
|
493
|
-
* 别人仍持有且未过期 → false。
|
|
494
|
-
*/
|
|
495
|
-
acquire(sessionId: string, owner: string, ttlMs: number): Promise<boolean>;
|
|
496
|
-
/** 续期:owner 仍持有且未过期 → true 并延长到 now + ttlMs;已过期、被别人接手、或从未持有 → false */
|
|
497
|
-
renew(sessionId: string, owner: string, ttlMs: number): Promise<boolean>;
|
|
498
|
-
/** 释放:只删 owner 自己持有的那条;不是自己的、或不存在,静默返回 */
|
|
499
|
-
release(sessionId: string, owner: string): Promise<void>;
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* 一套存储:只有 log 是必需的(§5 允许部分实现),`createAgent({ store })` 接收的就是它。
|
|
503
|
-
* 带 `runLease` 时 `createAgent` 自动把 handler 的 run 登记表换成跨进程的租约登记(D4)。
|
|
504
|
-
*/
|
|
505
|
-
interface Stores {
|
|
506
|
-
log: EventLog;
|
|
507
|
-
blobs?: BlobStore;
|
|
508
|
-
memory?: MemoryStore;
|
|
509
|
-
runLease?: RunLease;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
423
|
/**
|
|
513
424
|
* 降级层接口(技术方案 §11;宪法二:角色只是翻译)。
|
|
514
425
|
*
|
|
@@ -554,6 +465,12 @@ interface LoweringCapabilities {
|
|
|
554
465
|
*/
|
|
555
466
|
deferredTools: boolean;
|
|
556
467
|
images: boolean;
|
|
468
|
+
/**
|
|
469
|
+
* 模型收不收视频 / 音频片段(2026-11-05)。没写 = 不收(fail-closed),降级层落文字占位并记 lossy。
|
|
470
|
+
* 可选是为了宿主自写的 Lowering 不改也能编译;视频里的音轨不要求 `audio`
|
|
471
|
+
*/
|
|
472
|
+
video?: boolean;
|
|
473
|
+
audio?: boolean;
|
|
557
474
|
contextWindow: number;
|
|
558
475
|
maxOutputTokens: number;
|
|
559
476
|
}
|
|
@@ -637,4 +554,119 @@ interface Lowering<TPayload = unknown> {
|
|
|
637
554
|
stream(req: LoweredRequest<TPayload>, ctx?: LoweringStreamContext): AsyncGenerator<EventDraft, LoweringOutcome>;
|
|
638
555
|
}
|
|
639
556
|
|
|
640
|
-
|
|
557
|
+
/**
|
|
558
|
+
* 存储接口(技术方案 §5)。四者相互独立,允许部分实现:
|
|
559
|
+
* - 只有 EventLog 就能跑
|
|
560
|
+
* - 缺 BlobStore → spill 模块自动关闭并告警
|
|
561
|
+
* - 缺 MemoryStore → memory 工具不注册
|
|
562
|
+
* - 缺 RunLease → run 登记只在进程内(多实例部署要它,见 D4)
|
|
563
|
+
*
|
|
564
|
+
* 每个接口的行为契约由 ../testing 下的一致性套件定义,第三方后端跑同一套件即可自证合规。
|
|
565
|
+
*/
|
|
566
|
+
|
|
567
|
+
interface ReadOptions {
|
|
568
|
+
/** 起始 seq,含;缺省从 1 */
|
|
569
|
+
fromSeq?: number;
|
|
570
|
+
/** 结束 seq,含;缺省到末尾 */
|
|
571
|
+
toSeq?: number;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* 事件日志:只 append,永不 update / delete(宪法二)。
|
|
575
|
+
*
|
|
576
|
+
* seq 由调用方分配(通常是 runLoop),日志只校验:同一批必须同会话、seq 从当前末尾 +1 起连续。
|
|
577
|
+
* 这样并发写入者会在 append 时收到 seq_conflict,而不是静默交错 —— 乐观并发控制就这么简单。
|
|
578
|
+
*/
|
|
579
|
+
interface EventLog {
|
|
580
|
+
/** 同会话原子:整批要么全部写入,要么一个都不写 */
|
|
581
|
+
append(events: readonly Event[]): Promise<void>;
|
|
582
|
+
/** 按 seq 升序流式读取;不存在的会话得到空流 */
|
|
583
|
+
read(sessionId: string, opts?: ReadOptions): AsyncIterable<Event>;
|
|
584
|
+
/** 最后 n 条,按 seq 升序;不够 n 条就返回全部 */
|
|
585
|
+
tail(sessionId: string, n: number): Promise<Event[]>;
|
|
586
|
+
/**
|
|
587
|
+
* 从 fromSessionId 的 [1, atSeq] 分叉出新会话 toSessionId。
|
|
588
|
+
* 事件原样复制(保留 id 与 seq,只换 sessionId),以维持 parentId / pinsKept 等会话内引用。
|
|
589
|
+
* 目标会话必须为空;atSeq 超出范围报错。
|
|
590
|
+
*/
|
|
591
|
+
fork(fromSessionId: string, atSeq: number, toSessionId: string): Promise<void>;
|
|
592
|
+
}
|
|
593
|
+
interface BlobMeta {
|
|
594
|
+
mime: string;
|
|
595
|
+
sessionId: string;
|
|
596
|
+
/** 字节数 */
|
|
597
|
+
size: number;
|
|
598
|
+
/** Unix 毫秒 */
|
|
599
|
+
createdAt: number;
|
|
600
|
+
}
|
|
601
|
+
/** 大对象:外溢的工具结果、附件、代码执行产物。字符串按 UTF-8 编码存储。 */
|
|
602
|
+
interface BlobStore {
|
|
603
|
+
put(bytes: Uint8Array | string, meta: {
|
|
604
|
+
mime: string;
|
|
605
|
+
sessionId: string;
|
|
606
|
+
}): Promise<{
|
|
607
|
+
id: string;
|
|
608
|
+
}>;
|
|
609
|
+
/** 不存在抛 StoreError("not_found") */
|
|
610
|
+
get(id: string): Promise<{
|
|
611
|
+
bytes: Uint8Array;
|
|
612
|
+
meta: BlobMeta;
|
|
613
|
+
}>;
|
|
614
|
+
/** 可选:分段取回 [start, end),供模型分页读大结果;越界部分截断 */
|
|
615
|
+
slice?(id: string, range: {
|
|
616
|
+
start: number;
|
|
617
|
+
end: number;
|
|
618
|
+
}): Promise<Uint8Array>;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* 记忆后端:一个极简的文本 KV,键是路径。
|
|
622
|
+
* 路径限定(必须在 /memories 下、禁止 ..)由 memory 工具层负责(B6),存储层只管存取。
|
|
623
|
+
*/
|
|
624
|
+
interface MemoryStore {
|
|
625
|
+
/** 所有以 prefix 开头的路径,按字典序 */
|
|
626
|
+
list(prefix: string): Promise<string[]>;
|
|
627
|
+
/** 不存在返回 null */
|
|
628
|
+
read(path: string): Promise<string | null>;
|
|
629
|
+
/** 覆盖写 */
|
|
630
|
+
write(path: string, content: string): Promise<void>;
|
|
631
|
+
/** 幂等:不存在也不报错 */
|
|
632
|
+
delete(path: string): Promise<void>;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* 技能载体(技术方案 §9.9,S1):MemoryStore 的只读子集。任何 MemoryStore(内存 / sqlite / pg)天然满足,
|
|
636
|
+
* 数据库载体零新代码;文件系统载体 `fsSkillSource(dir)` 在 `@reinsjs/brain/node`。刻意不新造接口——"存哪"由宿主定。
|
|
637
|
+
*/
|
|
638
|
+
type SkillSource = Pick<MemoryStore, "list" | "read">;
|
|
639
|
+
/**
|
|
640
|
+
* run 租约(D4,2026-09-14):多实例部署下"同一会话同时只允许一个 run"的跨进程登记表。
|
|
641
|
+
*
|
|
642
|
+
* 语义是**带过期时间的独占锁**:`acquire` 在无人持有、持有者已过期、或持有者就是自己时成功;
|
|
643
|
+
* 持有者每隔一段时间 `renew` 续期,进程崩了不续期,到期后别的实例就能接手;`release` 只删自己持有的。
|
|
644
|
+
* 过期判定用**存储层自己的时钟**(数据库时间),不用各实例本机时钟——租约的意义是各实例对"谁持有"达成一致,
|
|
645
|
+
* 判定时钟必须唯一。三个方法都不抛"冲突"类错误,用返回值说话;存储不可用时照常抛。
|
|
646
|
+
*
|
|
647
|
+
* 心跳、丢租约中止、失败告警这些行为放在 `@reinsjs/server` 的 `leasedRunRegistry` 一份,store 只做三条语句。
|
|
648
|
+
* 单进程部署不需要它(进程内登记表已够),`memoryStore()` 刻意不带;`InMemoryRunLease` 是参考实现与测试用。
|
|
649
|
+
*/
|
|
650
|
+
interface RunLease {
|
|
651
|
+
/**
|
|
652
|
+
* 为会话占租约 ttlMs 毫秒。无人持有、持有者已过期、或持有者就是 owner(幂等,等于续期)→ true;
|
|
653
|
+
* 别人仍持有且未过期 → false。
|
|
654
|
+
*/
|
|
655
|
+
acquire(sessionId: string, owner: string, ttlMs: number): Promise<boolean>;
|
|
656
|
+
/** 续期:owner 仍持有且未过期 → true 并延长到 now + ttlMs;已过期、被别人接手、或从未持有 → false */
|
|
657
|
+
renew(sessionId: string, owner: string, ttlMs: number): Promise<boolean>;
|
|
658
|
+
/** 释放:只删 owner 自己持有的那条;不是自己的、或不存在,静默返回 */
|
|
659
|
+
release(sessionId: string, owner: string): Promise<void>;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* 一套存储:只有 log 是必需的(§5 允许部分实现),`createAgent({ store })` 接收的就是它。
|
|
663
|
+
* 带 `runLease` 时 `createAgent` 自动把 handler 的 run 登记表换成跨进程的租约登记(D4)。
|
|
664
|
+
*/
|
|
665
|
+
interface Stores {
|
|
666
|
+
log: EventLog;
|
|
667
|
+
blobs?: BlobStore;
|
|
668
|
+
memory?: MemoryStore;
|
|
669
|
+
runLease?: RunLease;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export { type RunPausedPayload as $, type ApprovalRequestPayload as A, type BlobStore as B, type ContentPart as C, type CoreEventPayloads as D, type Event as E, type CoreEventType as F, type CreateEventInput as G, DEFAULT_TRUST as H, type EventBase as I, type EventSchema as J, type ExtEvent as K, type Lowering as L, type MemoryStore as M, type HandoffPayload as N, type ImagePart as O, type LandingSpec as P, type LossKind as Q, type ReadOptions as R, type Stores as S, type TokenUsage as T, type LossMatrix as U, type LoweringOutcome as V, type LoweringStreamContext as W, type MemoryOpPayload as X, type ModelTextPayload as Y, type ModelThinkingPayload as Z, type Provenance as _, EventSchemaRegistry as a, type RunResumedPayload as a0, SchemaError as a1, type SchemaErrorCode as a2, type SkillSource as a3, type SystemNotePayload as a4, type TextPart as a5, type ToRequestInput as a6, type ToolReferencePart as a7, type ToolsBoundPayload as a8, type Upcaster as a9, type UserMessagePayload as aa, type VideoPart as ab, contextOverheadOf as ac, contextTokensOf as ad, createCoreEvent as ae, createCoreRegistry as af, createEvent as ag, lossesOf as ah, renderToolReference as ai, type EventLog 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 AudioPart as v, type BoundModel as w, CORE_SCHEMAS as x, type CompactionPayload as y, type CoreEvent as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reinsjs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/events/base.ts","../src/events/id.ts","../src/events/create.ts","../src/events/registry.ts"],"sourcesContent":["/**\n * 事件基础类型(技术方案 §4)。\n *\n * 宪法二:时间线是唯一真源,角色只是翻译。内部只有一种数据 —— 带发起者的事件。\n * 本文件只定义\"所有事件共有的壳\",具体载荷见 ./core.ts(内置 core.*)与宿主自定义的 ext.*。\n */\n\n/** 事件发起者。用户打断、脑子注入、宿主插话都只是不同 actor 的一次 append。 */\nexport type Actor = \"user\" | \"model\" | \"tool\" | \"system\" | \"host\"\n\n/**\n * 信任等级,供投影层与安全网判断\"这段内容能不能当指令\"。\n * - principal:主事人(用户)说的\n * - system:库或宿主注入的\n * - model:模型自己产出的\n * - untrusted:工具输出、外部抓取内容(默认值,防提示注入)\n */\nexport type Trust = \"principal\" | \"system\" | \"model\" | \"untrusted\"\n\n/** 来源:哪个工具、哪个 URL、哪个用户。用于审计与信任判断。 */\nexport interface Provenance {\n source: string\n ref?: string\n}\n\n/**\n * 所有事件的公共字段。\n * 载荷放在 payload 下(而不是平铺),这样 schema 升级函数只碰 payload,壳永远稳定。\n */\nexport interface EventBase {\n /** uuidv7,时间有序;会话内唯一。fork 复制的事件保留原 id,以维持 parentId / pinsKept 等引用 */\n id: string\n sessionId: string\n /** 会话内单调递增,从 1 起;是会话内排序的唯一依据 */\n seq: number\n /** Unix 毫秒 */\n at: number\n /** 命名空间化:内置 \"core.*\",宿主扩展 \"ext.*\" */\n type: string\n /** 该 type 自己的 schema 版本,从 1 起;读时按注册表升级(P9) */\n schemaVersion: number\n actor: Actor\n /** 因果链或分叉点:回答哪条消息、由哪次 tool_call 产生 */\n parentId?: string\n trust: Trust\n provenance?: Provenance\n /** 厂商专有回放数据(thinking signature、encrypted reasoning),不进通用字段 */\n replay?: Record<string, unknown>\n}\n\n/** 带类型载荷的事件。T 为 type 字面量,P 为 payload 形状。 */\nexport type Event<T extends string = string, P = unknown> = EventBase & {\n type: T\n payload: P\n}\n\n/**\n * 内容片段。用户消息、工具结果都由它组成;投影/降级时再翻译成各家 API 的 content block。\n * 文本、图片,以及\"工具定义引用\"(L1);大结果不塞进片段,走 tool_result.spilled 外溢到 BlobStore。\n */\nexport type ContentPart = TextPart | ImagePart | ToolReferencePart\n\nexport interface TextPart {\n type: \"text\"\n text: string\n}\n\nexport interface ImagePart {\n type: \"image\"\n mime: string\n /** base64 编码的图片字节 */\n data: string\n}\n\n/**\n * 工具定义引用(L1,2026-09-15):`tool_find` 这类\"取回工具\"的结果用它表达\"这几件工具从现在起可用\"。\n * 带完整定义快照,日志自足(宪法二:模型可见的一切都在日志里);翻译时按能力分两路——\n * 支持原生延迟加载的线(Anthropic `defer_loading`)只发 `tool_reference` 块、由厂商就地展开、工具表整段不变;\n * 其余线用 `renderToolReference` 展开成文本,信息等价。宿主经 HTTP 送来的用户消息不接受这种段(server 白名单)。\n */\nexport interface ToolReferencePart {\n type: \"tool_reference\"\n name: string\n description: string\n /** JSON Schema 对象,与 Tool.inputSchema 同形 */\n inputSchema: Record<string, unknown>\n}\n\n/** 引用段展开成文本的唯一写法:非原生线的降级层、UI、投影估算都调它,别各自拼 */\nexport function renderToolReference(part: ToolReferencePart): string {\n return `### ${part.name}\\n${part.description.trim()}\\nInput schema: ${JSON.stringify(part.inputSchema)}`\n}\n\n/** 各 actor 的默认信任等级;工厂函数在未显式给出 trust 时使用。 */\nexport const DEFAULT_TRUST: Readonly<Record<Actor, Trust>> = {\n user: \"principal\",\n system: \"system\",\n host: \"system\",\n model: \"model\",\n tool: \"untrusted\",\n}\n","/**\n * UUID v7 生成(RFC 9562):前 48 位为 Unix 毫秒时间戳,字典序即时间序。\n * 只用 Web 标准 crypto.getRandomValues,不引依赖(P5)。\n *\n * 同一毫秒内的多个 id 之间顺序随机 —— 会话内排序以 seq 为准,id 只需全局唯一且大致有序。\n */\nexport function uuidv7(now: number = Date.now()): string {\n const bytes = new Uint8Array(16)\n crypto.getRandomValues(bytes)\n\n // 48 位时间戳,大端写入 bytes[0..5]\n let ts = now\n for (let i = 5; i >= 0; i--) {\n bytes[i] = ts & 0xff\n ts = Math.floor(ts / 256)\n }\n // 版本位:byte6 高 4 位 = 0111\n bytes[6] = ((bytes[6] as number) & 0x0f) | 0x70\n // 变体位:byte8 高 2 位 = 10\n bytes[8] = ((bytes[8] as number) & 0x3f) | 0x80\n\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\")\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`\n}\n","/**\n * 事件工厂:补齐 id / at / schemaVersion / trust,调用方只关心\"谁、在哪个会话、第几条、说了什么\"。\n * seq 由 EventLog 的 append 方决定(T4),这里要求显式传入,不替存储层做主。\n */\nimport { type Actor, DEFAULT_TRUST, type Event, type EventBase, type Provenance, type Trust } from \"./base.js\"\nimport type { CoreEventOf, CoreEventPayloads, CoreEventType } from \"./core.js\"\nimport { uuidv7 } from \"./id.js\"\nimport type { EventSchemaRegistry } from \"./registry.js\"\n\n/**\n * 事件草稿:还没进日志的事件,缺 id / seq / at / sessionId / schemaVersion。\n * 降级层(模型输出)与脑子模块(注入的 system_note)都只产出草稿,由循环补齐后 append ——\n * 谁分配 seq 只有循环知道,草稿不替它做主。\n */\nexport interface EventDraft<T extends string = string, P = unknown> {\n type: T\n payload: P\n actor: Actor\n /** 缺省按 DEFAULT_TRUST[actor] */\n trust?: Trust\n parentId?: string\n provenance?: Provenance\n replay?: Record<string, unknown>\n}\n\n/** 内置事件的草稿联合,type 与 payload 联动 */\nexport type CoreEventDraft = { [T in CoreEventType]: EventDraft<T, CoreEventPayloads[T]> }[CoreEventType]\n\nexport interface CreateEventInput<T extends string, P> extends EventDraft<T, P> {\n sessionId: string\n seq: number\n /** 测试注入用;缺省 Date.now() */\n at?: number\n id?: string\n}\n\n/**\n * 通用工厂。schemaVersion 从注册表取当前版本,所以未登记的 type 会在这里就被拒绝,\n * 而不是写进日志后读不出来。\n */\nexport function createEvent<T extends string, P>(\n registry: EventSchemaRegistry,\n input: CreateEventInput<T, P>,\n): Event<T, P> {\n const at = input.at ?? Date.now()\n const base: EventBase = {\n id: input.id ?? uuidv7(at),\n sessionId: input.sessionId,\n seq: input.seq,\n at,\n type: input.type,\n schemaVersion: registry.currentVersion(input.type),\n actor: input.actor,\n trust: input.trust ?? DEFAULT_TRUST[input.actor],\n }\n // 可选字段只在有值时写入,避免日志里出现一堆 undefined(exactOptionalPropertyTypes 也不允许)\n if (input.parentId !== undefined) base.parentId = input.parentId\n if (input.provenance !== undefined) base.provenance = input.provenance\n if (input.replay !== undefined) base.replay = input.replay\n return { ...base, type: input.type, payload: input.payload }\n}\n\n/** 内置事件的强类型版本:type 与 payload 联动校验。 */\nexport function createCoreEvent<T extends CoreEventType>(\n registry: EventSchemaRegistry,\n input: CreateEventInput<T, CoreEventPayloads[T]>,\n): CoreEventOf<T> {\n return createEvent(registry, input) as CoreEventOf<T>\n}\n","/**\n * 事件 schema 注册表(P9:schema 有版本,读时升级,查不到即拒绝)。\n *\n * 职责:\n * 1. 登记每个 type 的当前版本与逐级升级函数 upcast(v → v+1)\n * 2. read(raw):校验壳字段 → 查 type → 逐级升级到当前版本 → 返回类型化事件\n * 3. 任何一步查不到都抛 SchemaError(fail-closed),绝不静默返回半个事件\n *\n * 日志文件不做原地迁移:存的永远是写入时的版本,读时升级。\n */\nimport type { Actor, Event, EventBase, Trust } from \"./base.js\"\nimport type { CoreEventType } from \"./core.js\"\n\n/** 把 payload 从版本 from 升到 from+1。只碰 payload,壳字段由注册表保证不变。 */\nexport type Upcaster = (payload: unknown) => unknown\n\nexport interface EventSchema {\n type: string\n /** 当前版本;新写入的事件一律打这个版本号 */\n version: number\n /**\n * 升级函数表,键为\"起点版本\":upcasters[1] 把 v1 升到 v2。\n * version 为 n 时必须覆盖 1..n-1 全部键,缺一个即注册失败 —— 宁可启动时报错,不要读到一半才发现。\n */\n upcasters?: Readonly<Record<number, Upcaster>>\n}\n\nexport type SchemaErrorCode =\n | \"malformed_base\" // 壳字段缺失或类型不对\n | \"unknown_type\" // 没登记的 type\n | \"future_version\" // 版本比注册表还新(旧代码读新日志)\n | \"missing_upcaster\" // 升级链断了\n | \"upcaster_failed\" // 升级函数自己抛了\n | \"invalid_schema\" // 登记时的定义不合法\n\nexport class SchemaError extends Error {\n constructor(\n readonly code: SchemaErrorCode,\n message: string,\n readonly context: { type?: string; version?: number } = {},\n ) {\n super(`[${code}] ${message}`)\n this.name = \"SchemaError\"\n }\n}\n\nconst ACTORS: ReadonlySet<string> = new Set<Actor>([\"user\", \"model\", \"tool\", \"system\", \"host\"])\nconst TRUSTS: ReadonlySet<string> = new Set<Trust>([\"principal\", \"system\", \"model\", \"untrusted\"])\n\nexport class EventSchemaRegistry {\n private readonly schemas = new Map<string, EventSchema>()\n\n constructor(schemas: Iterable<EventSchema> = []) {\n for (const s of schemas) this.register(s)\n }\n\n /** 登记一个 type。重复登记同一 type 视为错误,避免两处定义互相覆盖。 */\n register(schema: EventSchema): this {\n if (!schema.type || !/^(core|ext)\\.[a-z][a-z0-9_]*$/.test(schema.type)) {\n throw new SchemaError(\n \"invalid_schema\",\n `type must look like \"core.xxx\" or \"ext.xxx\", got ${schema.type}`,\n {\n type: schema.type,\n },\n )\n }\n if (!Number.isInteger(schema.version) || schema.version < 1) {\n throw new SchemaError(\"invalid_schema\", `version must be an integer >= 1, got ${schema.version}`, {\n type: schema.type,\n version: schema.version,\n })\n }\n if (this.schemas.has(schema.type)) {\n throw new SchemaError(\"invalid_schema\", `type already registered: ${schema.type}`, {\n type: schema.type,\n })\n }\n for (let v = 1; v < schema.version; v++) {\n if (typeof schema.upcasters?.[v] !== \"function\") {\n throw new SchemaError(\n \"invalid_schema\",\n `${schema.type} is at version ${schema.version} but has no v${v} -> v${v + 1} upgrade function`,\n { type: schema.type, version: v },\n )\n }\n }\n this.schemas.set(schema.type, schema)\n return this\n }\n\n has(type: string): boolean {\n return this.schemas.has(type)\n }\n\n /** 该 type 当前应写入的版本号;未登记则抛 unknown_type。 */\n currentVersion(type: string): number {\n const s = this.schemas.get(type)\n if (!s) throw new SchemaError(\"unknown_type\", `unregistered event type: ${type}`, { type })\n return s.version\n }\n\n /**\n * 从存储读出的原始对象 → 当前版本的事件。\n * 泛型只是给调用方的类型提示(如 read<CoreEvent>),运行时校验的是壳与版本,不校验 payload 形状 ——\n * payload 的正确性由写入方与升级函数负责。\n */\n read<E extends Event = Event>(raw: unknown): E {\n const base = assertBase(raw)\n const schema = this.schemas.get(base.type)\n if (!schema) {\n throw new SchemaError(\"unknown_type\", `unregistered event type: ${base.type}`, { type: base.type })\n }\n if (base.schemaVersion > schema.version) {\n throw new SchemaError(\n \"future_version\",\n `${base.type} v${base.schemaVersion} is newer than the locally known v${schema.version}; upgrade the code`,\n { type: base.type, version: base.schemaVersion },\n )\n }\n\n let payload = (raw as { payload?: unknown }).payload\n for (let v = base.schemaVersion; v < schema.version; v++) {\n const up = schema.upcasters?.[v]\n if (!up) {\n // register() 已保证不会走到这里,留作防御\n throw new SchemaError(\"missing_upcaster\", `${base.type} has no v${v} -> v${v + 1} upgrade function`, {\n type: base.type,\n version: v,\n })\n }\n try {\n payload = up(payload)\n } catch (cause) {\n throw new SchemaError(\n \"upcaster_failed\",\n `${base.type} v${v} -> v${v + 1} upgrade failed: ${cause instanceof Error ? cause.message : String(cause)}`,\n { type: base.type, version: v },\n )\n }\n }\n\n return { ...base, schemaVersion: schema.version, payload } as E\n }\n}\n\n/** 校验壳字段。只看公共字段,payload 不管。 */\nfunction assertBase(raw: unknown): EventBase {\n if (typeof raw !== \"object\" || raw === null) {\n throw new SchemaError(\"malformed_base\", \"event must be an object\")\n }\n const r = raw as Record<string, unknown>\n const fail = (field: string, expect: string): never => {\n throw new SchemaError(\n \"malformed_base\",\n `field ${field} must be ${expect}`,\n typeof r.type === \"string\" ? { type: r.type } : {},\n )\n }\n if (typeof r.id !== \"string\" || r.id === \"\") fail(\"id\", \"a non-empty string\")\n if (typeof r.sessionId !== \"string\" || r.sessionId === \"\") fail(\"sessionId\", \"a non-empty string\")\n if (!Number.isInteger(r.seq) || (r.seq as number) < 1) fail(\"seq\", \"an integer >= 1\")\n if (typeof r.at !== \"number\" || !Number.isFinite(r.at)) fail(\"at\", \"a finite number\")\n if (typeof r.type !== \"string\" || r.type === \"\") fail(\"type\", \"a non-empty string\")\n if (!Number.isInteger(r.schemaVersion) || (r.schemaVersion as number) < 1)\n fail(\"schemaVersion\", \"an integer >= 1\")\n if (typeof r.actor !== \"string\" || !ACTORS.has(r.actor)) fail(\"actor\", \"user|model|tool|system|host\")\n if (typeof r.trust !== \"string\" || !TRUSTS.has(r.trust)) fail(\"trust\", \"principal|system|model|untrusted\")\n if (r.parentId !== undefined && typeof r.parentId !== \"string\") fail(\"parentId\", \"a string or undefined\")\n if (r.provenance !== undefined) {\n const p = r.provenance as Record<string, unknown> | null\n if (typeof p !== \"object\" || p === null || typeof p.source !== \"string\")\n fail(\"provenance\", \"{ source: string }\")\n }\n if (r.replay !== undefined && (typeof r.replay !== \"object\" || r.replay === null))\n fail(\"replay\", \"an object or undefined\")\n return r as unknown as EventBase\n}\n\n/** 全部内置事件当前都是 v1。升版本时在此加 upcasters,并在 core.ts 改载荷类型。 */\nexport const CORE_SCHEMAS: readonly EventSchema[] = (\n [\n \"core.user_message\",\n \"core.model_text\",\n \"core.model_thinking\",\n \"core.tool_call\",\n \"core.tool_result\",\n \"core.system_note\",\n \"core.approval_request\",\n \"core.approval_decision\",\n \"core.compaction\",\n \"core.handoff\",\n \"core.memory_op\",\n \"core.budget_usage\",\n \"core.run_paused\",\n \"core.run_resumed\",\n \"core.tools_bound\",\n \"core.error\",\n ] satisfies CoreEventType[]\n).map((type) => ({ type, version: 1 }))\n\n/** 预装了全部 core.* 的注册表。宿主要加 ext.* 时 new 一个并传入 [...CORE_SCHEMAS, ...自己的]。 */\nexport function createCoreRegistry(extra: Iterable<EventSchema> = []): EventSchemaRegistry {\n return new EventSchemaRegistry([...CORE_SCHEMAS, ...extra])\n}\n"],"mappings":";AAyFO,SAAS,oBAAoB,MAAiC;AACnE,SAAO,OAAO,KAAK,IAAI;AAAA,EAAK,KAAK,YAAY,KAAK,CAAC;AAAA,gBAAmB,KAAK,UAAU,KAAK,WAAW,CAAC;AACxG;AAGO,IAAM,gBAAgD;AAAA,EAC3D,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACR;;;AC9FO,SAAS,OAAO,MAAc,KAAK,IAAI,GAAW;AACvD,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,SAAO,gBAAgB,KAAK;AAG5B,MAAI,KAAK;AACT,WAAS,IAAI,GAAG,KAAK,GAAG,KAAK;AAC3B,UAAM,CAAC,IAAI,KAAK;AAChB,SAAK,KAAK,MAAM,KAAK,GAAG;AAAA,EAC1B;AAEA,QAAM,CAAC,IAAM,MAAM,CAAC,IAAe,KAAQ;AAE3C,QAAM,CAAC,IAAM,MAAM,CAAC,IAAe,KAAQ;AAE3C,QAAM,MAAM,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAC7E,SAAO,GAAG,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM,GAAG,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC,IAAI,IAAI,MAAM,IAAI,EAAE,CAAC,IAAI,IAAI,MAAM,EAAE,CAAC;AAC1G;;;ACiBO,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