@qilin-agent/session-snapshot 3.1.5 → 3.1.6
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/lib/index.js +36 -3
- package/package.json +21 -21
package/lib/index.js
CHANGED
|
@@ -20,6 +20,8 @@ import { isSurfaceEligibleType } from "@qilin-agent/session/surface";
|
|
|
20
20
|
//#region lib/types/identity.js
|
|
21
21
|
/** Relationship-preserving identity redaction for committed session snapshots. */
|
|
22
22
|
const UUID_FRAGMENT_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
23
|
+
/** The visible job id suffix the jobs registry generates: `-` + 16 UUID hex characters. */
|
|
24
|
+
const SHORT_JOB_ID_RE$1 = /-[0-9a-f]{16}$/i;
|
|
23
25
|
const LEGACY_TOKEN_RE = /^\{\{(?:sessionId|messageId)\}\}$/;
|
|
24
26
|
const CANONICAL_TOKEN_RE = /^\{\{(session|message|approval|workflow|command|rpc|retry|id):([1-9]\d*)\}\}$/;
|
|
25
27
|
const ID_KEY_RE = /(?:^id$|Id$|Ids$)/;
|
|
@@ -37,7 +39,7 @@ function messageId(value) {
|
|
|
37
39
|
return value.id;
|
|
38
40
|
}
|
|
39
41
|
function redactedCandidate(value) {
|
|
40
|
-
return UUID_FRAGMENT_RE.test(value) || LEGACY_TOKEN_RE.test(value) || CANONICAL_TOKEN_RE.test(value);
|
|
42
|
+
return UUID_FRAGMENT_RE.test(value) || SHORT_JOB_ID_RE$1.test(value) || LEGACY_TOKEN_RE.test(value) || CANONICAL_TOKEN_RE.test(value);
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* Replace volatile opaque ids while preserving equality relationships across a parent and its child logs.
|
|
@@ -1188,6 +1190,8 @@ const PATH_TEXT_BOUNDARY_RE = /[\s<>'"`()\[\]{},;:!?=]/;
|
|
|
1188
1190
|
const FILE_URI_PATH_PREFIX_RE = /(?:^|[^a-z0-9+.-])file:\/\/\/?$/i;
|
|
1189
1191
|
/** A UUID v4 string, the shape `randomUUID()` produces for session ids. */
|
|
1190
1192
|
const UUID_RE$1 = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
1193
|
+
/** The visible job id suffix the jobs registry generates: `-` + 16 UUID hex characters. */
|
|
1194
|
+
const SHORT_JOB_ID_RE = /-[0-9a-f]{16}$/i;
|
|
1191
1195
|
const LOCAL_SPILL_PATH_RE = new RegExp(String.raw`\{\{cwd\}\}[\\/]+\.spill[\\/]+session-[0-9a-f]{12}[\\/]+[0-9a-f]{12}-([A-Za-z0-9._~-]+?)` + String.raw`(?=\. Use read with offset/limit|[\s)"]|\\+"|$)`, "g");
|
|
1192
1196
|
const SNAPSHOT_SPILL_PATH_RE = new RegExp(String.raw`(?:[A-Za-z]:)?[\\/]+(?:tmp|t)[\\/]+(?:qilin-acp-snap-[0-9a-f]{9}|qilin-acp-snapshot-spill)[\\/]+session-[0-9a-f]{12}[\\/]+[0-9a-f]{12}-([A-Za-z0-9._~-]+?)` + String.raw`(?=\. Use read with offset/limit|[\s)"]|\\+"|$)`, "g");
|
|
1193
1197
|
/**
|
|
@@ -1378,8 +1382,32 @@ function normalizeStdout(rawStdout, ctx, options = {}) {
|
|
|
1378
1382
|
function normalizeSessionLog(rawLog, ctx, options = {}) {
|
|
1379
1383
|
const cwdPathMode = options.cwdPathMode ?? "canonical";
|
|
1380
1384
|
const identityMode = options.identityMode ?? "legacy";
|
|
1381
|
-
|
|
1382
|
-
|
|
1385
|
+
const parsed = rawLog.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
1386
|
+
const jobTokens = /* @__PURE__ */ new Map();
|
|
1387
|
+
const reservedTokens = new Set(rawLog.match(/\{\{id:[1-9]\d*\}\}/g) ?? []);
|
|
1388
|
+
let nextJobToken = 1;
|
|
1389
|
+
if (identityMode === "legacy") for (const record of parsed) {
|
|
1390
|
+
if (record.type !== "job/registered" && record.type !== "job/settled" || record.data === null || typeof record.data !== "object") continue;
|
|
1391
|
+
const id = record.data.jobId;
|
|
1392
|
+
if (typeof id !== "string" || id.search(UUID_RE$1) < 0 && !SHORT_JOB_ID_RE.test(id) || jobTokens.has(id)) continue;
|
|
1393
|
+
let token;
|
|
1394
|
+
do
|
|
1395
|
+
token = `{{id:${nextJobToken++}}}`;
|
|
1396
|
+
while (reservedTokens.has(token));
|
|
1397
|
+
jobTokens.set(id, token);
|
|
1398
|
+
}
|
|
1399
|
+
const replaceJobs = (value) => {
|
|
1400
|
+
if (typeof value === "string") {
|
|
1401
|
+
let output = value;
|
|
1402
|
+
for (const [id, token] of jobTokens) output = output.split(id).join(token);
|
|
1403
|
+
return output;
|
|
1404
|
+
}
|
|
1405
|
+
if (Array.isArray(value)) return value.map(replaceJobs);
|
|
1406
|
+
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, replaceJobs(item)]));
|
|
1407
|
+
return value;
|
|
1408
|
+
};
|
|
1409
|
+
return parsed.map((raw) => {
|
|
1410
|
+
const record = jobTokens.size === 0 ? raw : replaceJobs(raw);
|
|
1383
1411
|
if (record.type === "session") {
|
|
1384
1412
|
if ("createdAt" in record) record.createdAt = 0;
|
|
1385
1413
|
} else if (isPackedFixtureRow(record)) {
|
|
@@ -1402,6 +1430,11 @@ function normalizeSessionLog(rawLog, ctx, options = {}) {
|
|
|
1402
1430
|
if ("durationMs" in data) data.durationMs = 0;
|
|
1403
1431
|
}
|
|
1404
1432
|
normalizeFeedbackClocks(record);
|
|
1433
|
+
if ((record.type === "job/registered" || record.type === "job/settled") && record.data !== null && typeof record.data === "object") {
|
|
1434
|
+
const data = record.data;
|
|
1435
|
+
if ("startedAt" in data) data.startedAt = 0;
|
|
1436
|
+
if ("finishedAt" in data) data.finishedAt = 0;
|
|
1437
|
+
}
|
|
1405
1438
|
if (record.type === "goal/change" && record.data !== null && typeof record.data === "object") {
|
|
1406
1439
|
const data = record.data;
|
|
1407
1440
|
if ("createdAt" in data) data.createdAt = 0;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qilin-agent/session-snapshot",
|
|
3
3
|
"description": "Session-log snapshot core with an ACP protocol adapter, expected-output normalization, and fixture invariants",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.6",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,31 +31,31 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
34
|
-
"js-yaml": "^4.2
|
|
34
|
+
"js-yaml": "^4.3.2",
|
|
35
35
|
"vitest": "^4.1.8",
|
|
36
|
-
"@qilin-agent/llm-replay": "3.1.
|
|
37
|
-
"@qilin-agent/
|
|
38
|
-
"@qilin-agent/
|
|
39
|
-
"@qilin-agent/
|
|
36
|
+
"@qilin-agent/llm-replay": "3.1.6",
|
|
37
|
+
"@qilin-agent/loader-smoke": "3.1.6",
|
|
38
|
+
"@qilin-agent/kylin-plugin-include": "~1.0.10",
|
|
39
|
+
"@qilin-agent/session-format": "3.1.6"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@qilin-agent/session": "3.1.
|
|
43
|
-
"@qilin-agent/kylin": "~4.0.
|
|
44
|
-
"@qilin-agent/http-proxy": "3.1.
|
|
42
|
+
"@qilin-agent/session": "3.1.6",
|
|
43
|
+
"@qilin-agent/kylin": "~4.0.5",
|
|
44
|
+
"@qilin-agent/http-proxy": "3.1.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/js-yaml": "^4.0.9",
|
|
48
|
-
"@qilin-agent/kylin": "~4.0.
|
|
49
|
-
"@qilin-agent/agent": "3.1.
|
|
50
|
-
"@qilin-agent/agent-loop": "3.1.
|
|
51
|
-
"@qilin-agent/llm": "3.1.
|
|
52
|
-
"@qilin-agent/compaction": "3.1.
|
|
53
|
-
"@qilin-agent/
|
|
54
|
-
"@qilin-agent/
|
|
55
|
-
"@qilin-agent/subagent": "3.1.
|
|
56
|
-
"@qilin-agent/tools": "3.1.
|
|
57
|
-
"@qilin-agent/
|
|
58
|
-
"@qilin-agent/
|
|
59
|
-
"@qilin-agent/http-proxy": "3.1.
|
|
48
|
+
"@qilin-agent/kylin": "~4.0.5",
|
|
49
|
+
"@qilin-agent/agent": "3.1.6",
|
|
50
|
+
"@qilin-agent/agent-loop": "3.1.6",
|
|
51
|
+
"@qilin-agent/llm": "3.1.6",
|
|
52
|
+
"@qilin-agent/compaction": "3.1.6",
|
|
53
|
+
"@qilin-agent/session": "3.1.6",
|
|
54
|
+
"@qilin-agent/sandbox": "3.1.6",
|
|
55
|
+
"@qilin-agent/subagent": "3.1.6",
|
|
56
|
+
"@qilin-agent/tools": "3.1.6",
|
|
57
|
+
"@qilin-agent/user-questions": "3.1.6",
|
|
58
|
+
"@qilin-agent/sandbox-policy": "3.1.6",
|
|
59
|
+
"@qilin-agent/http-proxy": "3.1.6"
|
|
60
60
|
}
|
|
61
61
|
}
|