Mark b467123578 feat(01-14): monitorTypeSurfaces:'include' — narrow picker to monitor surfaces only
[per Plan 01-14; closes B-01-14-01 via Step 1b lockstep]

- src/offscreen/recorder.ts: add monitorTypeSurfaces:'include' as top-level
  DisplayMediaStreamOptions sibling of video: (W3C Screen Capture spec §6.1;
  Chrome >= 119; removes tab/window panes from the operator's picker per
  Plan 01-10 RESEARCH §5 + §Pitfall-5 recommendation). Typed widening cast
  extended in lockstep to keep the explicit-typing contract (no `as any`).
  D-15 post-grant validation block at recorder.ts:294 UNCHANGED — belt
  (picker narrowing) + suspenders (post-grant tear-down) chain preserved.

- tests/offscreen/display-surface-constraint.test.ts: lockstep update of
  the strict-deep-equality assertion at lines 223-226 with the same key
  ordering as the source change (video -> monitorTypeSurfaces -> audio).
  toHaveBeenCalledWith contract preserved (NO expect.objectContaining —
  the test author's "catches future drops of ANY field" discipline is
  honored). This edit + the source change land in the SAME commit so the
  98/98 baseline never crosses a commit boundary in RED state.

- src/test-hooks/offscreen-hooks.ts: capture last constraints object in
  module-scoped `lastGetDisplayMediaConstraints` cell (was `_constraints`
  received-but-unused; renamed to `constraints`); add `get-last-getDisplayMedia-constraints`
  bridge op to the __mokoshOffscreenQuery dispatcher between
  get-display-surface and get-segment-count. Defensive try/catch mirrors
  the existing dispatcher pattern; the cell is module-internal so the
  MokoshTestSurface cross-cast in types.ts requires NO change (decision
  documented inline in offscreen-hooks.ts).

- tests/uat/extension-page-harness.ts: add `assertA23` mirroring `assertA3`
  (bridge query → 2-check AssertionResult: non-null constraints + value).
  Extend the `Window.__mokoshHarness` declaration + runtime export + status
  bar text + console.log to reference A23.

- tests/uat/lib/harness-page-driver.ts: export `driveA23(page)` mirroring
  the `driveA14` page.evaluate wrapper shape. Standard read-only driver.

- tests/uat/harness.test.ts: extend FORBIDDEN_HOOK_STRINGS (line 85) with
  `lastGetDisplayMediaConstraints` and `get-last-getDisplayMedia-constraints`.
  Import driveA23. Append `{ name: 'A23', drive: driveA23 }` to the drivers
  array after the A14 entry. Update header comment + orchestrator stdout
  to reflect A14 + A23 chain. The `Total = drivers.length + 1` arithmetic
  adapts automatically: 14 + 1 = 15 → 15 + 1 = 16.

- tests/background/no-test-hooks-in-prod-bundle.test.ts: lockstep
  extension of FORBIDDEN_HOOK_STRINGS (line 105) with the same 2 strings.
  Header comment updated to "Total: 12 surface strings." (was 10).
  Confirms production `dist/` has ZERO occurrences after `npm run build`
  via the `__MOKOSH_UAT__` dead-branch tree-shake (T-01-14-04 mitigation).

D-01 (whole-desktop only via getDisplayMedia; reject window/tab surfaces) is
the design intent that monitorTypeSurfaces:'include' realizes at the picker-
UI level. D-15 post-grant validation (recorder.ts:294-307) remains the
actual enforcement against managed-policy/DevTools/older-Chrome overrides.

Verification chain (per Plan 01-14 §verify; clean post-commit):
- `npx tsc --noEmit` exit 0
- `npm run build` exit 0; dist/ produced, monitorTypeSurfaces ships in
  the offscreen chunk as the operator-facing picker hint
- `npm run build:test` exit 0; dist-test/ produced with the harness
  hooks intact (gated)
- `npm test` 100/100 GREEN (was 98/98; +2 via the 2 new FORBIDDEN_HOOK_STRINGS
  parametrized tests — both PASS, production bundle hook-free)
- `npm run test:uat` 16/16 GREEN (15 → 16 via A23). A23 reads constraints
  `{video: {...}, monitorTypeSurfaces: 'include', audio: false}` from the
  fakeGetDisplayMedia capture cell — round-trips through the full call site.
- Production bundle spot-check:
    `grep -rc 'lastGetDisplayMediaConstraints\|get-last-getDisplayMedia-constraints' dist/ | grep -v ':0$'`
    → empty (all `:0` filtered) → ZERO leakage.

References:
- W3C Screen Capture §6.1 DisplayMediaStreamOptions:
  https://www.w3.org/TR/screen-capture/#dom-displaymediastreamoptions-monitortypesurfaces
- Chrome screen-sharing-controls (Chrome 119+):
  https://developer.chrome.com/docs/web-platform/screen-sharing-controls
- Plan 01-10 RESEARCH §5 + §Pitfall-5 (recommendation provenance):
  .planning/phases/01-stabilize-video-pipeline/01-10-RESEARCH.md
- Architectural-note (replaces retired AMENDMENT-A.md improvisation per
  01-11-SUMMARY): canonical GSD ceremony — plan → checker (B-01-14-01)
  → executor → SUMMARY (this commit).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 21:37:59 +02:00

AI Call Recorder - Браузерное расширение для записи сессий операторов

Фаза 1 — Локальная запись + экспорт архива

Установка и запуск

Разработка

# Установка зависимостей
npm install

# Сборка для разработки с HMR
npm run dev

# Сборка для продакшена
npm run build

Установка расширения в Chrome

  1. Соберите проект:

    npm run build
    
  2. Откройте Chrome и перейдите по адресу: chrome://extensions/

  3. Включите "Режим разработчика" (Developer mode) в правом верхнем углу

  4. Нажмите кнопку "Загрузить распакованное расширение" (Load unpacked)

  5. Выберите папку dist в корне проекта

  6. Расширение установлено!

Использование

  1. При первом открытии popup расширение запросит разрешение на запись экрана

  2. Разрешение обязательно для работы расширения

  3. Расширение автоматически начнет запись:

    • Видео: последние 30 секунд (кольцевой буфер)
    • DOM-события через rrweb: последние 10 минут
    • Лог действий пользователя: последние 10 минут
  4. Для сохранения отчета об ошибке:

    • Нажмите на иконку расширения
    • Нажмите кнопку "Сохранить отчёт об ошибке"
    • Архив автоматически загрузится в папку "Загрузки"

Структура архива

Архив session_report_YYYY-MM-DD_HH-MM-SS.zip содержит:

session_report_2025-05-15_14-32-10.zip
├── video/
│   └── last_30sec.webm         # склеенные чанки видеобуфера
├── rrweb/
│   └── session.json            # массив DOM-событий rrweb
├── logs/
│   └── events.json             # лог действий пользователя
├── screenshot.png              # скриншот в момент сохранения
└── meta.json                   # метаданные сессии

Технический стек

  • Тип расширения: Chrome Extension, Manifest V3
  • Service Worker: Background script (Manifest V3)
  • Захват экрана: chrome.tabCapture API
  • Захват DOM: rrweb (npm: rrweb)
  • Лог событий: Content Script
  • Упаковка архива: JSZip (npm: jszip)
  • Сохранение файла: chrome.downloads API
  • Хранение буфера: In-memory (Service Worker + Content Script)
  • Build: Vite + crxjs + TypeScript

Особенности

Маскирование чувствительных данных

  • Пароли (input[type=password]) маскируются автоматически в rrweb и логах
  • Поля с атрибутом data-sensitive="true" также маскируются в rrweb

Записываемые события

Пользовательские события

  • click — клик по любому элементу
  • input — изменение значения поля (без паролей)
  • navigation — переходы по страницам (popstate, hashchange, History API)
  • js_error — JavaScript ошибки (window.onerror, unhandledrejection)
  • network_error — сетевые ошибки (fetch/XHR с кодом ответа >= 400)

Кольцевой буфер

  • Видео: 30 секунд, первый чанк (WebM заголовок) хранится всегда
  • rrweb события: 10 минут, максимум 5000 событий
  • Пользовательские события: 10 минут

Память

  • Ожидаемое потребление: ~5-10 МБ в фоновом режиме

Критерии приёмки Фазы 1

  • Расширение устанавливается в Chrome без ошибок
  • Видеобуфер непрерывно работает на любой вкладке
  • В буфере всегда есть не более 30 секунд видео
  • rrweb пишет DOM-события без ошибок на типовых страницах
  • Лог событий фиксирует клики, навигацию и сетевые ошибки
  • При нажатии кнопки архив скачивается в "Загрузки" за < 5 секунд
  • Архив открывается, last_30sec.webm воспроизводится в браузере
  • Пароли не попадают в лог и rrweb-снимки
  • RAM-потребление расширения не превышает 50 МБ в фоне

Отладка

Console Logs

Расширение пишет подробные логи в консоль:

  • Service Worker: Chrome DevTools → Extensions → Service Worker → Console
  • Content Script: Chrome DevTools на любой странице → Console
  • Popup: Правый клик по popup → Проверить

Структура проекта

ai-call-extension/
├── src/
│   ├── background/          # Service Worker
│   │   └── index.ts
│   ├── content/            # Content Script
│   │   └── index.ts
│   ├── popup/              # Popup UI
│   │   ├── index.html
│   │   ├── index.ts
│   │   └── style.css
│   └── shared/             # Общие типы и утилиты
│       ├── types.ts
│       └── logger.ts
├── icons/                  # Иконки расширения
├── dist/                   # Собранные файлы
├── manifest.json           # Manifest расширения
├── vite.config.ts          # Конфигурация Vite
├── tsconfig.json           # Конфигурация TypeScript
└── package.json

Лицензия

MIT

Контакты

Для вопросов и предложений обращайтесь в support.

Description
No description provided
Readme 8 MiB
Languages
TypeScript 91%
HTML 3.4%
CSS 2.8%
Shell 2%
JavaScript 0.8%