Убраны таймауты. Вместо этого:
- Polling ctx.session.get() каждые 500ms
- Ожидаем outcome: succeeded/failed/interrupted
- Собираем текст assistant сообщений из session.get()
- Event subscription логирует события для отладки
- Session.get() error — retry, без abort
session.prompt() non-blocking — возвращает объект-приём, а не текст.
Текст ответа приходит через ctx.event.subscribe() как live-only events.
Подход:
- pendingResponses Map: sessionID -> {resolve, reject, timer}
- Event subscription: парсит события, извлекает текст из assistant сообщений
- Message handler: создаёт Promise, ждёт события (timeout 30s)
- Парсим несколько структур событий на всякий случай
При создании сессии не передаём id — OpenCode сам генерирует ses_*.
Ключ мапы (roomId:threadRootId) используется только для поиска,
не передаётся в OpenCode.
Используем ctx.session.get({ sessionID }) для проверки существования
сессии в OpenCode ДО отправки prompt. Если сессия удалена/невалидна —
создаём новую. Убрана реактивная обработка Session.NotFoundError.
Плагин теперь пытается использовать OpenCode API логирования
(ctx.app.log) для записи в ~/.local/share/opencode/log/.
При ошибке — fallback на файловый лог ~/.opencode-matrix-plugin/plugin.log.
- logger.ts теперь использует console.log/console.error с префиксом [matrix-plugin]
- Удалена запись в ~/.opencode-matrix-plugin/plugin.log
- Удалены setup-started.log и setup-error.log
- Ошибки пишутся через logError() в stderr
Server holds the lock even after cleanup. Client always sees the lock
and skips bot startup. On crash, stale PID is detected and lock is
cleaned up automatically.
All plugin files (lock, logs) now live under the configured storage
path (default ~/.local/share/opencode-matrix-bot/plugin-data),
matching matrix-client.ts behavior. No extra directories created.
OpenCode V2 loads plugins in both the background server and the client.
Add a file-based mutex (/tmp/opencode-matrix-plugin.lock) so only the
first instance (server) starts the Matrix bot. The second instance
(client) detects the lock and returns a no-op cleanup.
- Add plugins/matrix-plugin/ directory with symlinks to root files
(OpenCode V2 resolver appends path suffix after symlink resolution)
- Rename plugin id from 'opencode-matrix' to 'matrix-plugin'