mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
* refactor(shared): organize session contracts and projections * chore: tighten dropped-path flaky pattern allowance * docs: preserve current agent instructions with valid formatting
19 lines
722 B
TypeScript
19 lines
722 B
TypeScript
import { isLoneStructuredAgentSessionConversationCommand } from './agent-session/view/structured-agent-session-composer'
|
|
|
|
/** Append returned text without replacing typed drafts or duplicating an existing suffix.
|
|
* Replace lone /compact or /clear commands: they were unsent and cannot accept trailing text. */
|
|
export function appendReturnedDraftText(draft: string, text: string): string {
|
|
const returned = text.trimEnd()
|
|
if (returned.trim() === '') {
|
|
return draft
|
|
}
|
|
const kept = draft.trimEnd()
|
|
if (kept === '' || isLoneStructuredAgentSessionConversationCommand(kept)) {
|
|
return text
|
|
}
|
|
if (kept === returned || kept.endsWith(`\n\n${returned}`)) {
|
|
return draft
|
|
}
|
|
return `${kept}\n\n${text}`
|
|
}
|