feat: session goals - server-driven goal loop with independent small-model audit (#2148)

Arm the target button in the composer and the next prompt becomes a goal:
the server keeps the session working toward it (idle tick -> small-model
audit -> continuation) until the objective is verifiably complete, blocked,
or out of budget — even with the UI closed.

Server (packages/web/server/lib/session-goal):
- event-driven loop on the global SSE hub; goal state lives in
  session.metadata.openchamber.goal (merge-safe patches, stale-write guard
  by goal id), so it survives restarts and syncs to every client for free
- the small-model audit (objective + last assistant turn only, language
  pinned to the objective) is the sole termination authority; blocked needs
  3 consecutive verdicts, audit outages tolerate one unaudited continuation
  then stop the goal as resumable-blocked
- hard stops: optional token budget, auto-continuation cap (Resume grants a
  fresh allowance), turn errors; user abort pauses the goal instead of
  blocking it, and resuming over an aborted tail nudges immediately
- token accounting as a snapshot of the latest turn (input + cache.read +
  output), goal-relative via a creation baseline and segmented across
  compactions; a compaction summary skips the audit and continues
- continuations reuse the session's own provider/model/agent/variant

UI:
- three-mode target button (arm / disarm / manage dialog), informational
  goal strip with inline pause/resume and an Evaluating indicator, sidebar
  state glyph, objective length counter (2000-char server clamp),
  read-only completed goals
- goal entry points: composer (sessions and drafts), start-new-session-
  from-answer dialog, plan implement dialog (plan content becomes the
  objective), scheduled tasks (Run as goal + budget)
- Settings -> Chat -> Goal: feature toggle + default token budget with
  three-layer parity (web server, client persistence, VS Code bridge);
  VS Code renders goal state but hides the entry points (the loop runs in
  the web server only)

Notifications: per-turn "ready" notifications are suppressed while a goal
is active; settling sends one final notification (desktop, web-push, APNs
generic titles with the session name as body) honoring the completion
toggle. Error/question/permission notifications are untouched.

Docs: user guide (session-goals) in all 9 locales + sidebar entry,
scheduled-tasks cross-reference, server module DOCUMENTATION.md.
This commit is contained in:
Bohdan Triapitsyn
2026-07-12 01:23:22 +03:00
committed by GitHub
parent 82c039117a
commit bb45164ae8
73 changed files with 3330 additions and 29 deletions
+37
View File
@@ -381,6 +381,10 @@ export const dict: Record<I18nKey, string> = {
'sessions.scheduledTasks.editor.prompt.placeholder': 'Podsumuj otwarte zadania i zaproponuj następne działania',
'sessions.scheduledTasks.editor.enabled.aria': 'Włącz zadanie',
'sessions.scheduledTasks.editor.enabled.label': 'Włączone',
'sessions.scheduledTasks.editor.goal.label': 'Uruchom jako cel',
'sessions.scheduledTasks.editor.goal.aria': 'Uruchom to zadanie jako cel, do którego agent dąży aż do ukończenia',
'sessions.scheduledTasks.editor.goal.budgetLabel': 'Budżet tokenów',
'sessions.scheduledTasks.editor.goal.budgetAria': 'Ogranicz cel budżetem tokenów',
'sessions.scheduledTasks.editor.actions.closeAria': 'Zamknij',
'sessions.scheduledTasks.editor.actions.cancel': 'Anuluj',
'sessions.scheduledTasks.editor.actions.save': 'Zapisz',
@@ -2093,6 +2097,39 @@ export const dict: Record<I18nKey, string> = {
'header.actions.terminalPanelWithShortcut': 'Panel terminala ({shortcut})',
'chat.recap.aria': 'Podsumowanie sesji',
'chat.recap.label': 'Podsumowanie:',
'chat.goal.dialog.titleCreate': 'Ustaw cel sesji',
'chat.goal.dialog.titleManage': 'Cel sesji',
'chat.goal.dialog.objectiveLabel': 'Cel',
'chat.goal.dialog.objectivePlaceholder': 'Opisz stan końcowy, który agent ma osiągnąć i zweryfikować…',
'chat.goal.dialog.budgetLabel': 'Budżet tokenów',
'chat.goal.status.active': 'Aktywny',
'chat.goal.status.evaluating': 'Ocenianie…',
'chat.goal.status.paused': 'Wstrzymany',
'chat.goal.status.blocked': 'Zablokowany',
'chat.goal.status.budgetLimited': 'Budżet wyczerpany',
'chat.goal.status.complete': 'Ukończony',
'chat.goal.usage.tokens': '{used} tokenów',
'chat.goal.usage.tokensWithBudget': '{used}/{budget} tokenów',
'chat.goal.usage.turns': 'kontynuacje: {turns}',
'chat.goal.action.pause': 'Wstrzymaj',
'chat.goal.action.resume': 'Wznów',
'chat.goal.action.markComplete': 'Oznacz jako ukończony',
'chat.goal.action.clear': 'Usuń cel',
'chat.goal.action.cancel': 'Anuluj',
'chat.goal.action.save': 'Zapisz cel',
'chat.goal.action.start': 'Rozpocznij cel',
'chat.goal.toast.actionFailed': 'Nie udało się zaktualizować celu',
'chat.goal.row.aria': 'Cel sesji — otwórz szczegóły',
'chat.goal.button.createAria': 'Ustaw cel sesji',
'chat.goal.button.manageAria': 'Zarządzaj celem sesji',
'chat.goal.button.armAria': 'Rozpocznij cel następną wiadomością',
'chat.goal.counter.aria': 'Limit długości celu',
'chat.goal.button.disarmAria': 'Cel uzbrojony — dotknij, aby rozbroić',
'chat.goal.button.cancelAria': 'Cel w toku — dotknij, aby anulować',
'chat.goal.cancelDialog.title': 'Anulować ten cel?',
'chat.goal.cancelDialog.description': 'Agent przestanie automatycznie pracować nad tym celem.',
'chat.goal.cancelDialog.keep': 'Zachowaj cel',
'chat.goal.cancelDialog.confirm': 'Anuluj cel',
'chat.suggestion.applyAria': 'Użyj sugerowanej wiadomości',
'chat.suggestion.dismissAria': 'Odrzuć sugestię',
'header.actions.toggleRightSidebarAria': 'Przełącz prawy panel boczny',