mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* Keep clear in the same chat and reset its provider context * Derive clear pauses only from journal membership and cover older rewind clients * Point queued command rewind test at the structured hook * Group queue consume errors and rewind replay assertions
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import type { AgentSessionRecord } from './agent-session-record'
|
|
|
|
export type AgentSessionProviderContextBoundary = {
|
|
operationId: string
|
|
afterFence: number
|
|
clearedAt: number
|
|
}
|
|
|
|
export function isAgentSessionProviderContextBoundary(
|
|
value: unknown
|
|
): value is AgentSessionProviderContextBoundary {
|
|
return (
|
|
typeof value === 'object' &&
|
|
value !== null &&
|
|
'operationId' in value &&
|
|
typeof value.operationId === 'string' &&
|
|
value.operationId.length > 0 &&
|
|
value.operationId.length <= 512 &&
|
|
'afterFence' in value &&
|
|
typeof value.afterFence === 'number' &&
|
|
Number.isSafeInteger(value.afterFence) &&
|
|
value.afterFence >= 0 &&
|
|
'clearedAt' in value &&
|
|
typeof value.clearedAt === 'number' &&
|
|
Number.isSafeInteger(value.clearedAt) &&
|
|
value.clearedAt >= 0
|
|
)
|
|
}
|
|
|
|
/** Clear resets the chain; the boundary identifies a fresh launch before its first proof. */
|
|
export function activeProviderContext(
|
|
record: Pick<AgentSessionRecord, 'providerHandleChain' | 'providerContextBoundary'>
|
|
) {
|
|
const handleChain = record.providerHandleChain
|
|
const head = handleChain.at(-1) ?? null
|
|
return {
|
|
handleChain,
|
|
head,
|
|
pendingClear: record.providerContextBoundary !== undefined && head === null
|
|
}
|
|
}
|