mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 08:02:21 +00:00
* feat(chat): support structured clear and compact commands * fix(chat): authorize mobile commands and bound clear-chain projection * fix(chat): localize conversation command send errors * fix(chat): retain clear pane identity with reopened history * test: account for combined structured session RPC additions --------- Co-authored-by: Merge Sim <sim@local>
28 lines
1007 B
TypeScript
28 lines
1007 B
TypeScript
import type { AgentSessionStoreState } from './agent-session-record-store-file'
|
|
import type { AgentSessionConversationCommandRecord } from '../../shared/agent-session-conversation-command'
|
|
|
|
export function commitConversationCommandRecord(
|
|
state: AgentSessionStoreState,
|
|
sessionId: string,
|
|
fence: number,
|
|
command: AgentSessionConversationCommandRecord
|
|
): void {
|
|
const record = state.records.get(sessionId)
|
|
if (!record || record.lease.runtimeFence !== fence) {
|
|
throw new Error('agent_session_checkpoint_stale')
|
|
}
|
|
state.records.set(sessionId, { ...record, conversationCommand: command })
|
|
if (
|
|
command.command === 'clear' &&
|
|
command.phase === 'committed' &&
|
|
command.replacementSessionId
|
|
) {
|
|
if (!state.records.has(command.replacementSessionId)) {
|
|
throw new Error('agent_session_identity_required')
|
|
}
|
|
state.visibleSessionIds.delete(sessionId)
|
|
state.visibleSessionIds.add(command.replacementSessionId)
|
|
state.visibleSessionIdsIndexPresent = true
|
|
}
|
|
}
|