@morlay/session-rdb 0.0.21-alpha.3 → 0.0.21-alpha.4
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/README.md +1 -1
- package/dist/artifact.d.mts +1 -1
- package/dist/artifact.mjs +1 -1
- package/dist/{backend-DpdtxYpz.d.mts → backend-a0xDrUFG.d.mts} +58 -9
- package/dist/{branch-5JzX9rUq.mjs → branch-Dlmbkfjj.mjs} +4 -12
- package/dist/deletion.d.mts +1 -1
- package/dist/deletion.mjs +1 -1
- package/dist/import.d.mts +1 -1
- package/dist/import.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{log-CnYct2Dv.mjs → log-C-rbdFwK.mjs} +32 -4
- package/dist/{sqlite-fpvm5Dzs.mjs → sqlite-C3LHLzYW.mjs} +282 -23
- package/dist/{src-CWTWV7vx.mjs → src-Bn0038Sp.mjs} +269 -165
- package/dist/storage.d.mts +11 -2
- package/dist/storage.mjs +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +11 -11
- package/drizzle/postgres/20260918120000_v3_event_usage/migration.sql +1 -1
- package/drizzle/sqlite/20260918120000_v3_event_usage/migration.sql +1 -1
- package/package.json +2 -2
- package/src/backend.ts +26 -1
- package/src/branch.ts +5 -13
- package/src/entities/v3/event-usage.ts +2 -1
- package/src/index.ts +132 -33
- package/src/log.ts +36 -19
- package/src/postgres.ts +232 -38
- package/src/sqlite.ts +204 -25
- package/src/usage.ts +96 -32
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ type Config =
|
|
|
60
60
|
除 `ctx.sessionPersistence` 外,本包还实现 `@morlay/session-branch` 的 provider
|
|
61
61
|
抽象并**随插件自动注册 `ctx.sessionBranch`**(`SessionBranchRdb`),在不修改上游
|
|
62
62
|
代码的前提下提供 `rewind / retry / fork` 的持久化闭环(原语:`forkFrom` 纯 append
|
|
63
|
-
派生、`rewind`
|
|
63
|
+
派生、`rewind` 后端事务截断)——语义、坐标论证与已知限制见
|
|
64
64
|
[分支能力](.agents/designs/20260917-分支能力.md)。
|
|
65
65
|
|
|
66
66
|
上层编排(edit / reroll / retry / rewind / fork 完整功能)由
|
package/dist/artifact.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SessionRow, i as EventRow } from "./backend-a0xDrUFG.mjs";
|
|
2
2
|
import { SESSION_IMPORT_PATH, SESSION_LOG_ARTIFACT_FILENAME, parseImportZip, parseJsonlArtifact, persistImport, registerSessionImport } from "./import.mjs";
|
|
3
3
|
import { SessionStorageMetadata } from "@deepseek-ai/dsh-session-persistence";
|
|
4
4
|
import { SessionEvent, SessionHeader } from "@deepseek-ai/dsh-session";
|
package/dist/artifact.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as toJsonlArtifact, a as repairAssistantSettlement, c as repairRequestHeaders, d as rowToMeta, f as scanRows, g as titleOfEventData, h as syncMeteringRanges, i as renameLegacyPtcEvents, l as repairSurfaceOps, m as sessionInsertRow, n as orphanInboxSpliceSeqs, o as repairOrphanInboxSplices, p as sessionConflictRow, r as recomputeReplaceProvenance, s as repairReadView, t as findSurfaceRepairs, u as rowToEvent, v as usageRowOf } from "./log-
|
|
1
|
+
import { _ as toJsonlArtifact, a as repairAssistantSettlement, c as repairRequestHeaders, d as rowToMeta, f as scanRows, g as titleOfEventData, h as syncMeteringRanges, i as renameLegacyPtcEvents, l as repairSurfaceOps, m as sessionInsertRow, n as orphanInboxSpliceSeqs, o as repairOrphanInboxSplices, p as sessionConflictRow, r as recomputeReplaceProvenance, s as repairReadView, t as findSurfaceRepairs, u as rowToEvent, v as usageRowOf } from "./log-C-rbdFwK.mjs";
|
|
2
2
|
import { SESSION_IMPORT_PATH, SESSION_LOG_ARTIFACT_FILENAME, parseImportZip, parseJsonlArtifact, persistImport, registerSessionImport } from "./import.mjs";
|
|
3
3
|
export { SESSION_IMPORT_PATH, SESSION_LOG_ARTIFACT_FILENAME, findSurfaceRepairs, orphanInboxSpliceSeqs, parseImportZip, parseJsonlArtifact, persistImport, recomputeReplaceProvenance, registerSessionImport, renameLegacyPtcEvents, repairAssistantSettlement, repairOrphanInboxSplices, repairReadView, repairRequestHeaders, repairSurfaceOps, rowToEvent, rowToMeta, scanRows, sessionConflictRow, sessionInsertRow, syncMeteringRanges, titleOfEventData, toJsonlArtifact, usageRowOf };
|
|
@@ -3416,7 +3416,6 @@ declare class SessionBranchRdb extends SessionBranch {
|
|
|
3416
3416
|
}>;
|
|
3417
3417
|
forkFrom(sourceId: SessionId, options?: ForkFromOptions, signal?: AbortSignal): Promise<SessionId>;
|
|
3418
3418
|
rewind(id: SessionId, toBoundary: number, signal?: AbortSignal): Promise<SessionPersistenceSnapshot>;
|
|
3419
|
-
timeline(sessionId: SessionId, signal?: AbortSignal): Promise<import("@morlay/session-branch").BranchTimeline>;
|
|
3420
3419
|
}
|
|
3421
3420
|
//#endregion
|
|
3422
3421
|
//#region src/index.d.ts
|
|
@@ -3575,6 +3574,15 @@ declare class SessionPersistenceRdb extends SessionPersistence {
|
|
|
3575
3574
|
storedCount: number;
|
|
3576
3575
|
migrated: boolean;
|
|
3577
3576
|
} | undefined>;
|
|
3577
|
+
/**
|
|
3578
|
+
* 活动计数**旁路累加**:不在写事务里、失败只 warn——`t_event_counts` 是可销毁重建的派生表,
|
|
3579
|
+
* 丢几次累加不影响可用性(需要时用 `rebuildEventCounts` 重算)。
|
|
3580
|
+
*/
|
|
3581
|
+
private recordEventCounts;
|
|
3582
|
+
/** 重算一个会话的活动计数(rewind / fork 之后;best-effort,同 `recordEventCounts`)。 */
|
|
3583
|
+
rebuildEventCounts(id: SessionId): Promise<void>;
|
|
3584
|
+
/** 会话删除时清掉它的活动计数行(best-effort)。 */
|
|
3585
|
+
private deleteEventCounts;
|
|
3578
3586
|
private rewriteMigratedLog;
|
|
3579
3587
|
listSnapshots(signal?: AbortSignal): Promise<Array<SessionPersistenceSnapshot & {
|
|
3580
3588
|
inheritedEventCount: number;
|
|
@@ -3592,22 +3600,39 @@ declare class SessionPersistenceRdb extends SessionPersistence {
|
|
|
3592
3600
|
registerReuseEventIds(childId: SessionId, map: ReadonlyMap<number, string>): void;
|
|
3593
3601
|
internals(): SessionPersistenceRdbInternals;
|
|
3594
3602
|
private rowRevision;
|
|
3603
|
+
private readonly liveFailures;
|
|
3604
|
+
private readonly liveDropWarned;
|
|
3605
|
+
private watchLiveReady;
|
|
3595
3606
|
private installLiveRouting;
|
|
3596
3607
|
private ensureLiveHandle;
|
|
3597
3608
|
}
|
|
3598
3609
|
//#endregion
|
|
3599
3610
|
//#region src/usage.d.ts
|
|
3600
|
-
/**
|
|
3601
|
-
interface
|
|
3602
|
-
events: number;
|
|
3611
|
+
/** 一段 token 用量(字段直接取事件里模型报的 usage)。 */
|
|
3612
|
+
interface UsageTokenTotals {
|
|
3603
3613
|
inputTokens: number;
|
|
3604
3614
|
outputTokens: number;
|
|
3605
3615
|
cacheReadTokens: number;
|
|
3606
3616
|
reasoningTokens: number;
|
|
3607
3617
|
totalTokens: number;
|
|
3608
3618
|
}
|
|
3609
|
-
/**
|
|
3610
|
-
|
|
3619
|
+
/**
|
|
3620
|
+
* 活动计数:与 token 用量同一时间范围、同一去重口径(只算被会话引用的事件行),
|
|
3621
|
+
* 按事件类型数出来——「轮次 / 步骤 / 用户输入 / 工具调用」比「事件行数」有信息量。
|
|
3622
|
+
*/
|
|
3623
|
+
interface UsageActivityTotals {
|
|
3624
|
+
turns: number;
|
|
3625
|
+
steps: number;
|
|
3626
|
+
userInputs: number;
|
|
3627
|
+
toolCalls: number;
|
|
3628
|
+
}
|
|
3629
|
+
/** 总量与按会话行用的一整套指标(token + 活动)。 */
|
|
3630
|
+
interface UsageTotals extends UsageTokenTotals, UsageActivityTotals {}
|
|
3631
|
+
/**
|
|
3632
|
+
* 一天 × 一个模型 × 是否子代理 的用量桶:总览、按天、按模型都由它折叠。
|
|
3633
|
+
* 只有 token 用量——活动计数没有模型归属(一个轮次可能跨模型),挂在总量与按会话行上。
|
|
3634
|
+
*/
|
|
3635
|
+
interface UsageBucket extends UsageTokenTotals {
|
|
3611
3636
|
day: string;
|
|
3612
3637
|
provider: string | null;
|
|
3613
3638
|
model: string | null;
|
|
@@ -3620,8 +3645,11 @@ interface UsageSessionRow extends UsageTotals {
|
|
|
3620
3645
|
subagent: boolean;
|
|
3621
3646
|
archived: boolean;
|
|
3622
3647
|
}
|
|
3623
|
-
/**
|
|
3648
|
+
/** 后端的原始聚合结果(总量 / 其中子代理 / 人类、按天×模型的桶、按会话的行)。 */
|
|
3624
3649
|
interface UsageAggregate {
|
|
3650
|
+
totals: UsageTotals;
|
|
3651
|
+
subagent: UsageTotals;
|
|
3652
|
+
human: UsageTotals;
|
|
3625
3653
|
buckets: UsageBucket[];
|
|
3626
3654
|
sessions: UsageSessionRow[];
|
|
3627
3655
|
}
|
|
@@ -3690,6 +3718,12 @@ interface BackendTx {
|
|
|
3690
3718
|
/** 批量删除整条会话:桥接行、workspace 归属行、投影行与会话行。 */
|
|
3691
3719
|
deleteSessions(ids: SessionId[]): Promise<number>;
|
|
3692
3720
|
}
|
|
3721
|
+
/** 活动计数的一个桶:本地日 + 事件类型 + 计数。 */
|
|
3722
|
+
interface EventCountBucket {
|
|
3723
|
+
day: string;
|
|
3724
|
+
type: string;
|
|
3725
|
+
count: number;
|
|
3726
|
+
}
|
|
3693
3727
|
interface Backend {
|
|
3694
3728
|
readonly kind: "sqlite" | "postgres";
|
|
3695
3729
|
readonly storeIdentity: string;
|
|
@@ -3706,13 +3740,28 @@ interface Backend {
|
|
|
3706
3740
|
/** 父会话已不存在(或没有父)的 subagent 会话:父被删后它们成了孤儿。 */
|
|
3707
3741
|
listOrphanSubagentSessions(): Promise<SessionId[]>;
|
|
3708
3742
|
/**
|
|
3709
|
-
*
|
|
3743
|
+
* 用量统计的原始聚合:token 用量读 `t_event_usage`、活动计数读派生表 `t_event_counts`,
|
|
3744
|
+
* 加按天×模型的桶与按会话的行(事件行去重、排除孤儿)。
|
|
3710
3745
|
* @param sinceMs - 只算该时刻(含)之后的事件行;省略即全量。
|
|
3711
3746
|
*/
|
|
3712
3747
|
usageReport(sinceMs?: number): Promise<UsageAggregate>;
|
|
3748
|
+
/**
|
|
3749
|
+
* 活动计数**旁路累加**(派生表 `t_event_counts`,不参与写事务、失败可丢——表可销毁重建):
|
|
3750
|
+
* 每个 (会话, 本地日, 事件类型) 记一行计数。
|
|
3751
|
+
* @param id - 会话 id。
|
|
3752
|
+
* @param buckets - 本批要累加的 (day, type, count)。
|
|
3753
|
+
*/
|
|
3754
|
+
incrementEventCounts(id: SessionId, buckets: readonly EventCountBucket[]): Promise<void>;
|
|
3755
|
+
/**
|
|
3756
|
+
* 按会话从事件表重算活动计数(rewind / fork 之后调用):先删该会话的行再重算。
|
|
3757
|
+
* @param id - 会话 id。
|
|
3758
|
+
*/
|
|
3759
|
+
rebuildEventCounts(id: SessionId): Promise<void>;
|
|
3760
|
+
/** 删掉一个会话的活动计数行(会话删除时)。 */
|
|
3761
|
+
deleteEventCounts(id: SessionId): Promise<void>;
|
|
3713
3762
|
/** 回收空间与统计(含 VACUUM);不得在事务内执行。 */
|
|
3714
3763
|
vacuum(): Promise<void>;
|
|
3715
3764
|
close(): Promise<void>;
|
|
3716
3765
|
}
|
|
3717
3766
|
//#endregion
|
|
3718
|
-
export {
|
|
3767
|
+
export { tSessionEvents as A, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID as C, tEvents as D, tEventUsage as E, tWorkspaceState as F, tWorkspaces as I, WriteGuard as L, tSessions as M, tStorageUnits as N, tPersistenceState as O, tWorkspaceSessions as P, StorageRepository as R, SCHEMA_VERSION as S, eventKind as T, DEFAULT_BUSY_TIMEOUT_MS as _, SessionRow as a, EventRole as b, ProjectionCacheOptions as c, SessionPersistenceRdb as d, SessionPersistenceRdbInternals as f, truncateLiveSession as g, locateTurnEnd as h, EventRow as i, tSessionProjcacheRows as j, tSchemaMeta as k, SessionDeletionError as l, SessionBranchRdbProvider as m, BackendTx as n, UsageAggregate as o, SessionBranchRdb as p, EventCountBucket as r, Config$1 as s, Backend as t, SessionDeletionErrorCode as u, EVENT_ENCODING as v, eventDimensions as w, JournalMode as x, EventKind as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as repairRequestHeaders, d as rowToMeta, f as scanRows } from "./log-
|
|
1
|
+
import { c as repairRequestHeaders, d as rowToMeta, f as scanRows } from "./log-C-rbdFwK.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { SESSION_FORMAT_VERSION, SessionLogOffset } from "@deepseek-ai/dsh-session";
|
|
4
4
|
import { sessionFormatCatalog } from "@deepseek-ai/dsh-session-format-catalog";
|
|
5
|
-
import { SessionBranch, SessionBranchError, balanceRewindPrefix,
|
|
5
|
+
import { SessionBranch, SessionBranchError, balanceRewindPrefix, rewindKeepLength } from "@morlay/session-branch";
|
|
6
6
|
//#region src/legacy.ts
|
|
7
7
|
function physicalHeader(row) {
|
|
8
8
|
const common = {
|
|
@@ -201,6 +201,7 @@ var SessionBranchRdbProvider = class {
|
|
|
201
201
|
} finally {
|
|
202
202
|
await handle.close();
|
|
203
203
|
}
|
|
204
|
+
await this.persistence.rebuildEventCounts(childId);
|
|
204
205
|
return childId;
|
|
205
206
|
}
|
|
206
207
|
async rewind(id, toBoundary, signal) {
|
|
@@ -273,6 +274,7 @@ var SessionBranchRdbProvider = class {
|
|
|
273
274
|
headSeq: keepLength - 1,
|
|
274
275
|
snapshotEvents: () => []
|
|
275
276
|
});
|
|
277
|
+
await this.persistence.rebuildEventCounts(id);
|
|
276
278
|
return {
|
|
277
279
|
header: rowToMeta(row),
|
|
278
280
|
revision: await internals.readStoredRevision(id)
|
|
@@ -375,16 +377,6 @@ var SessionBranchRdb = class extends SessionBranch {
|
|
|
375
377
|
rewind(id, toBoundary, signal) {
|
|
376
378
|
return this.provider.rewind(id, toBoundary, signal);
|
|
377
379
|
}
|
|
378
|
-
async timeline(sessionId, signal) {
|
|
379
|
-
const persistence = this.ctx.sessionPersistence;
|
|
380
|
-
const snapshots = await persistence.listSnapshots(signal);
|
|
381
|
-
const readOwnEvents = async (id, fromSeq, s) => {
|
|
382
|
-
const live = this.ctx.sessions.get(id);
|
|
383
|
-
if (live !== void 0) return live.snapshotEvents().slice(fromSeq);
|
|
384
|
-
return (await persistence.internals().readFrom(id, fromSeq, s)).events;
|
|
385
|
-
};
|
|
386
|
-
return buildTimeline(snapshots, readOwnEvents, sessionId, signal);
|
|
387
|
-
}
|
|
388
380
|
};
|
|
389
381
|
//#endregion
|
|
390
382
|
export { truncateLiveSession as a, isLegacyVersion as c, replaceLiveSessionLog as i, SessionBranchRdbProvider as n, adoptLegacyRows as o, locateTurnEnd as r, convertLegacyRows as s, SessionBranchRdb as t };
|
package/dist/deletion.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as SessionPersistenceRdb } from "./backend-a0xDrUFG.mjs";
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
//#region src/deletion.d.ts
|
|
4
4
|
declare const SESSION_DELETE_PATH = "/api/session.delete";
|
package/dist/deletion.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as registerSessionDeletion, r as SESSION_DELETE_PATH } from "./src-
|
|
1
|
+
import { i as registerSessionDeletion, r as SESSION_DELETE_PATH } from "./src-Bn0038Sp.mjs";
|
|
2
2
|
export { SESSION_DELETE_PATH, registerSessionDeletion };
|
package/dist/import.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as SessionPersistenceRdb } from "./backend-a0xDrUFG.mjs";
|
|
2
2
|
import { SessionStorageMetadata } from "@deepseek-ai/dsh-session-persistence";
|
|
3
3
|
import { Session, SessionEvent, SessionId } from "@deepseek-ai/dsh-session";
|
|
4
4
|
import { Context } from "@deepseek-ai/cordis";
|
package/dist/import.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as replaceLiveSessionLog } from "./branch-
|
|
1
|
+
import { i as replaceLiveSessionLog } from "./branch-Dlmbkfjj.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { SESSION_FORMAT_VERSION, SessionLogOffset } from "@deepseek-ai/dsh-session";
|
|
4
4
|
import { parseSessionFormatLogFilename } from "@deepseek-ai/dsh-session-format";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as SCHEMA_VERSION, c as ProjectionCacheOptions, d as SessionPersistenceRdb, f as SessionPersistenceRdbInternals, h as locateTurnEnd, l as SessionDeletionError, m as SessionBranchRdbProvider, p as SessionBranchRdb, s as Config, u as SessionDeletionErrorCode } from "./backend-a0xDrUFG.mjs";
|
|
2
2
|
export { Config, ProjectionCacheOptions, SCHEMA_VERSION, SessionBranchRdb, SessionBranchRdbProvider, SessionDeletionError, SessionDeletionErrorCode, SessionPersistenceRdb, SessionPersistenceRdb as default, SessionPersistenceRdbInternals, locateTurnEnd };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as SessionPersistenceRdb, t as SessionDeletionError } from "./src-
|
|
3
|
-
import { n as SessionBranchRdbProvider, r as locateTurnEnd, t as SessionBranchRdb } from "./branch-
|
|
1
|
+
import { p as SCHEMA_VERSION } from "./sqlite-C3LHLzYW.mjs";
|
|
2
|
+
import { n as SessionPersistenceRdb, t as SessionDeletionError } from "./src-Bn0038Sp.mjs";
|
|
3
|
+
import { n as SessionBranchRdbProvider, r as locateTurnEnd, t as SessionBranchRdb } from "./branch-Dlmbkfjj.mjs";
|
|
4
4
|
export { SCHEMA_VERSION, SessionBranchRdb, SessionBranchRdbProvider, SessionDeletionError, SessionPersistenceRdb, SessionPersistenceRdb as default, locateTurnEnd };
|
|
@@ -80,7 +80,36 @@ const SURFACE_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
80
80
|
"tool/result"
|
|
81
81
|
]);
|
|
82
82
|
const METERING_EVENT_TYPES = /* @__PURE__ */ new Set(["compaction/summary", "compaction/prune"]);
|
|
83
|
+
/**
|
|
84
|
+
* 升序的 surface 事件 seq 索引:读视图修复里的溯源(replace 的 `sourceEventSeqs` 与
|
|
85
|
+
* metering 的 `shadowedSeqs`)共用这一份,避免每个 replace 各扫一遍全量事件。
|
|
86
|
+
* 前提是输入按 seq 有序(`readLog` 与 live snapshot 都如此)。
|
|
87
|
+
*/
|
|
88
|
+
function surfaceSeqIndex(events) {
|
|
89
|
+
const seqs = [];
|
|
90
|
+
for (const event of events) if (SURFACE_EVENT_TYPES.has(event.type)) seqs.push(event.seq);
|
|
91
|
+
return seqs;
|
|
92
|
+
}
|
|
93
|
+
/** `[startSeq, endSeq]` 内的 surface seq(含端点),二分定位后切片。 */
|
|
94
|
+
function surfaceSeqsInRange(seqs, startSeq, endSeq) {
|
|
95
|
+
let low = 0;
|
|
96
|
+
let high = seqs.length;
|
|
97
|
+
while (low < high) {
|
|
98
|
+
const mid = low + high >> 1;
|
|
99
|
+
if (seqs[mid] < startSeq) low = mid + 1;
|
|
100
|
+
else high = mid;
|
|
101
|
+
}
|
|
102
|
+
const from = low;
|
|
103
|
+
high = seqs.length;
|
|
104
|
+
while (low < high) {
|
|
105
|
+
const mid = low + high >> 1;
|
|
106
|
+
if (seqs[mid] <= endSeq) low = mid + 1;
|
|
107
|
+
else high = mid;
|
|
108
|
+
}
|
|
109
|
+
return seqs.slice(from, low);
|
|
110
|
+
}
|
|
83
111
|
function recomputeReplaceProvenance(events) {
|
|
112
|
+
const seqs = surfaceSeqIndex(events);
|
|
84
113
|
for (let i = 0; i < events.length; i++) {
|
|
85
114
|
const raw = events[i];
|
|
86
115
|
const op = raw.surfaceOp;
|
|
@@ -92,9 +121,7 @@ function recomputeReplaceProvenance(events) {
|
|
|
92
121
|
raw.sourceEventSeqs = meteringData.shadowedSeqs;
|
|
93
122
|
continue;
|
|
94
123
|
}
|
|
95
|
-
|
|
96
|
-
for (const candidate of events) if (candidate.seq >= startSeq && candidate.seq <= endSeq && SURFACE_EVENT_TYPES.has(candidate.type)) refs.push(candidate.seq);
|
|
97
|
-
raw.sourceEventSeqs = refs;
|
|
124
|
+
raw.sourceEventSeqs = surfaceSeqsInRange(seqs, startSeq, endSeq);
|
|
98
125
|
}
|
|
99
126
|
}
|
|
100
127
|
function isEventSeqLike(value) {
|
|
@@ -247,6 +274,7 @@ function repairRequestHeaders(events) {
|
|
|
247
274
|
}
|
|
248
275
|
}
|
|
249
276
|
function syncMeteringRanges(events) {
|
|
277
|
+
const seqs = surfaceSeqIndex(events);
|
|
250
278
|
for (let i = 1; i < events.length; i++) {
|
|
251
279
|
const metering = events[i - 1];
|
|
252
280
|
if (!METERING_EVENT_TYPES.has(metering.type)) continue;
|
|
@@ -259,7 +287,7 @@ function syncMeteringRanges(events) {
|
|
|
259
287
|
start: startSeq,
|
|
260
288
|
end: endSeq
|
|
261
289
|
};
|
|
262
|
-
data.shadowedSeqs =
|
|
290
|
+
data.shadowedSeqs = surfaceSeqsInRange(seqs, startSeq, endSeq);
|
|
263
291
|
}
|
|
264
292
|
}
|
|
265
293
|
const PTC_EVENT_RENAMES = {
|