Files
orca/src/shared/structured-agent-session-status-block.ts
T
Brennan Benson f16212a29c feat(acp): compact Grok, OpenCode and OMP chats (#26502)
* feat(acp): compact Grok, OpenCode and OMP chats

* test(acp): expect Grok compaction capability

* fix(chat): keep skipped compaction outcomes visible across history pages

* fix(acp): a signed-out /compact reports not signed in, as a send does

A /compact the agent refused for sign-in now records the same notSignedIn
fact as an ordinary send, so the chat shows sign-in guidance and the next
send starts a new agent that reads the new login.

* refactor(acp): keep the timeline translator under its line limit after main's growth

Main's OMP per-channel message identity grew acp-timeline-translator.ts past
max-lines with this PR's compaction handling. The running compaction's frame
folding moves beside its ending in acp-compaction-turn.ts, and the
compacting-prompt lookup into AcpPromptTurns; behaviour is unchanged.
2026-10-09 02:05:31 -07:00

41 lines
1.6 KiB
TypeScript

import { readWholeAgentSessionFailureFact } from './agent-session-failure'
import type { AgentJournalStatusItem, AgentJournalTurnScope } from './agent-session-journal-types'
import { readAgentSessionOrcaStop } from './agent-session-orca-stop'
import type { NativeChatTextBlock } from './native-chat-types'
import {
AGENT_SESSION_COMPACTION_SKIPPED_PRESENTATION,
isAgentSessionLegacyCompactionResult
} from './agent-session-compaction'
/** A status row as the line a chat paints: named fields only, so a host-only key never leaks. */
export function structuredAgentSessionStatusBlock(
body: AgentJournalStatusItem,
turnScope?: AgentJournalTurnScope,
itemId?: string
): NativeChatTextBlock {
const failure = readWholeAgentSessionFailureFact(body.failure)
const orcaStop = readAgentSessionOrcaStop(body.orcaStop)
const presentation =
body.presentation ??
(body.tone === 'warning' && itemId !== undefined && isAgentSessionLegacyCompactionResult(itemId)
? AGENT_SESSION_COMPACTION_SKIPPED_PRESENTATION
: undefined)
return {
type: 'text',
text: body.text,
...(presentation !== undefined ? { presentation } : {}),
...(body.contextClear !== undefined ? { contextClear: body.contextClear } : {}),
...(body.tone !== undefined ? { tone: body.tone } : {}),
...(body.providerFrame ? { providerFrame: body.providerFrame } : {}),
...(failure ? { failure } : {}),
...(orcaStop
? {
orcaStop: {
...orcaStop,
...(turnScope?.kind === 'turn' ? { turnItemId: turnScope.turnItemId } : {})
}
}
: {})
}
}