@zhushanwen/session-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/dist/index.d.ts +9 -2
- package/dist/index.js +11 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,8 +14,15 @@
|
|
|
14
14
|
* 冻结接口未列的 per-type 附加字段不在此暴露;消费方需要时先扩展本接口——解析层
|
|
15
15
|
* 不私自保留未知字段,保证「读到的就是模型声明的」。
|
|
16
16
|
*/
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* pi message entry 的 role 域(窄联合:解析时值守卫收窄,非法 role 计坏行)。
|
|
19
|
+
*
|
|
20
|
+
* 四值闭集与 pi 1.0 AgentMessage 的 role 全集对齐(pi-ai dist/types.d.ts SystemMessage/
|
|
21
|
+
* UserMessage/AssistantMessage/ToolResultMessage)。1.0 起 system 消息落盘
|
|
22
|
+
* (工具集变更高频追加),三值时代 role=system 的行在守卫处丢弃 message 字段
|
|
23
|
+
* (内容静默丢失);四值放行后 expand/详情可读。
|
|
24
|
+
*/
|
|
25
|
+
type SessionMessageRole = 'user' | 'assistant' | 'toolResult' | 'system';
|
|
19
26
|
interface Entry {
|
|
20
27
|
type: string;
|
|
21
28
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// src/parse.ts
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
|
+
|
|
4
|
+
// src/types.ts
|
|
5
|
+
var SESSION_MESSAGE_ROLES = [
|
|
6
|
+
"user",
|
|
7
|
+
"assistant",
|
|
8
|
+
"toolResult",
|
|
9
|
+
"system"
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
// src/parse.ts
|
|
3
13
|
function isMessageRole(v) {
|
|
4
|
-
return v
|
|
14
|
+
return SESSION_MESSAGE_ROLES.includes(v);
|
|
5
15
|
}
|
|
6
16
|
function parseEntryMessage(raw) {
|
|
7
17
|
if (raw === null || typeof raw !== "object") return void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/session-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Canonical session model and pure JSONL primitives shared by session readers and importers: Entry/ParseResult/SessionHeader/NormalizedSession, parse/serialize, first-line byte primitive, session id invariants. Zero runtime dependencies.",
|
|
6
6
|
"main": "dist/index.mjs",
|