Commit Graph

4 Commits

Author SHA1 Message Date
Adam Weidman 1dc55b278b fix(core): harden injection safety and listener resilience
Wrap background completion output in <background_output> XML tags with
inline instructions to treat as data, consistent with <user_input> tags
used for user steering hints.

Guard listener iteration in InjectionService.addInjection and
ExecutionLifecycleService.settleExecution with try/catch so a throwing
listener doesn't block subsequent listeners or crash the caller.
2026-03-16 11:00:52 -04:00
Adam Weidman 2727a871c3 fix(core): source-aware injection getters, fix unshift ordering, remove dead code
Rename getUserHints/getUserHintsAfter/getLatestHintIndex to
getInjections/getInjectionsAfter/getLatestInjectionIndex with optional
source filter so bg completions don't get formatted as user hints.

Swap unshift ordering so bg completions appear before user hints in the
message — the model sees context before the user's reaction to it.

Remove unused getLastUserHintAt().
2026-03-15 22:16:38 -04:00
Adam Weidman 8fcb18996a refactor(core): unify InjectionService API to single onInjection interface
Remove legacy onUserHint/offUserHint/addUserHint methods. All callers
now use addInjection(text, source) and onInjection/offInjection with
source-based filtering where needed.
2026-03-15 21:38:11 -04:00
Adam Weidman 931b80206b refactor(core): rename UserHintService to InjectionService and add background completion support
Rename UserHintService to InjectionService as a generic, source-agnostic
injection mechanism. InjectionService supports typed sources ('user_steering'
and 'background_completion') with source-specific gating — user_steering
respects the model steering toggle while background_completion always fires.

Add background completion lifecycle to ExecutionLifecycleService: tracks
backgrounded executions, fires onBackgroundComplete listeners when they
settle, and supports FormatInjectionFn callbacks so execution creators
control how their output is formatted for reinjection.

Wire AppContainer to route background completions through InjectionService
and submit them to the model when idle, independent of model steering.
2026-03-12 13:23:52 -04:00