fix(session-persistence-jsonl): require delegation depth
This commit is contained in:
@@ -25,7 +25,7 @@ export interface HeaderLine {
|
||||
cwd?: string
|
||||
parentSession?: SessionId
|
||||
seedLength?: number
|
||||
delegationDepth?: number
|
||||
delegationDepth: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ export function toHeaderLine(header: SessionHeader): HeaderLine {
|
||||
...header.cwd !== undefined ? { cwd: header.cwd } : {},
|
||||
...header.parentSession !== undefined ? { parentSession: header.parentSession } : {},
|
||||
...header.seedLength !== undefined ? { seedLength: header.seedLength } : {},
|
||||
...header.delegationDepth !== undefined ? { delegationDepth: header.delegationDepth } : {},
|
||||
delegationDepth: header.delegationDepth ?? 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export function fromHeaderLine(line: HeaderLine): SessionHeader {
|
||||
...line.cwd !== undefined ? { cwd: line.cwd } : {},
|
||||
...line.parentSession !== undefined ? { parentSession: line.parentSession } : {},
|
||||
...line.seedLength !== undefined ? { seedLength: line.seedLength } : {},
|
||||
...line.delegationDepth !== undefined ? { delegationDepth: line.delegationDepth } : {},
|
||||
delegationDepth: line.delegationDepth,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,10 @@ function isHeaderLine(value: unknown): value is HeaderLine {
|
||||
&& typeof (value as { version?: unknown }).version === 'number'
|
||||
&& typeof (value as { id?: unknown }).id === 'string'
|
||||
&& typeof (value as { createdAt?: unknown }).createdAt === 'number'
|
||||
&& typeof (value as { delegationDepth?: unknown }).delegationDepth === 'number'
|
||||
&& Number.isSafeInteger((value as { delegationDepth: number }).delegationDepth)
|
||||
&& (value as { delegationDepth: number }).delegationDepth >= 0
|
||||
&& !Object.is((value as { delegationDepth: number }).delegationDepth, -0)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user