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': '저장',
@@ -1413,6 +1417,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': '토글 터미널 패널',