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
@@ -293,6 +293,10 @@ export const dict: Record<I18nKey, string> = {
"sessions.scheduledTasks.editor.prompt.placeholder": "Підсумуйте відкриті завдання й запропонуйте наступні дії",
"sessions.scheduledTasks.editor.enabled.aria": "Увімкнути завдання",
"sessions.scheduledTasks.editor.enabled.label": "Увімкнено",
"sessions.scheduledTasks.editor.goal.label": "Виконати як ціль",
"sessions.scheduledTasks.editor.goal.aria": "Виконати це завдання як ціль, яку агент веде до завершення",
"sessions.scheduledTasks.editor.goal.budgetLabel": "Бюджет токенів",
"sessions.scheduledTasks.editor.goal.budgetAria": "Обмежити ціль бюджетом токенів",
"sessions.scheduledTasks.editor.actions.closeAria": "Закрити",
"sessions.scheduledTasks.editor.actions.cancel": "Скасувати",
"sessions.scheduledTasks.editor.actions.save": "Зберегти",
@@ -1389,6 +1393,39 @@ export const dict: Record<I18nKey, string> = {
"header.actions.terminalPanelWithShortcut": "Термінальна панель ({shortcut})",
"chat.recap.aria": "Підсумок сесії",
"chat.recap.label": "Підсумок:",
"chat.goal.dialog.titleCreate": "Встановити ціль сесії",
"chat.goal.dialog.titleManage": "Ціль сесії",
"chat.goal.dialog.objectiveLabel": "Ціль",
"chat.goal.dialog.objectivePlaceholder": "Опишіть кінцевий стан, якого агент має досягти та перевірити…",
"chat.goal.dialog.budgetLabel": "Бюджет токенів",
"chat.goal.status.active": "Активна",
"chat.goal.status.evaluating": "Оцінювання…",
"chat.goal.status.paused": "Призупинена",
"chat.goal.status.blocked": "Заблокована",
"chat.goal.status.budgetLimited": "Бюджет вичерпано",
"chat.goal.status.complete": "Завершена",
"chat.goal.usage.tokens": "{used} токенів",
"chat.goal.usage.tokensWithBudget": "{used}/{budget} токенів",
"chat.goal.usage.turns": "продовжень: {turns}",
"chat.goal.action.pause": "Призупинити",
"chat.goal.action.resume": "Відновити",
"chat.goal.action.markComplete": "Позначити завершеною",
"chat.goal.action.clear": "Видалити ціль",
"chat.goal.action.cancel": "Скасувати",
"chat.goal.action.save": "Зберегти ціль",
"chat.goal.action.start": "Розпочати ціль",
"chat.goal.toast.actionFailed": "Не вдалося оновити ціль",
"chat.goal.row.aria": "Ціль сесії — відкрити деталі",
"chat.goal.button.createAria": "Встановити ціль сесії",
"chat.goal.button.manageAria": "Керувати ціллю сесії",
"chat.goal.button.armAria": "Розпочати ціль наступним повідомленням",
"chat.goal.counter.aria": "Ліміт довжини цілі",
"chat.goal.button.disarmAria": "Ціль увімкнена — торкніться, щоб вимкнути",
"chat.goal.button.cancelAria": "Ціль виконується — торкніться, щоб скасувати",
"chat.goal.cancelDialog.title": "Скасувати цю ціль?",
"chat.goal.cancelDialog.description": "Агент припинить автоматично працювати над цією ціллю.",
"chat.goal.cancelDialog.keep": "Залишити ціль",
"chat.goal.cancelDialog.confirm": "Скасувати ціль",
"chat.suggestion.applyAria": "Використати запропоноване повідомлення",
"chat.suggestion.dismissAria": "Прибрати пропозицію",
"header.actions.toggleTerminalPanelAria": "Перемкнути панель терміналу",