Restructure chat service, web routes, and add test suite
Split monolithic chat service into modular structure with Matrix client support, extract web server into per-resource route modules, introduce bootstrap/main-loop separation, and add comprehensive vitest coverage across services, repositories, and utilities. Adds project docs and CLAUDE.md agent instructions.
This commit is contained in:
1 parent
dfa0580859
commit
633bb0ec04
84 files changed
+19278
-3888
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import type { Logger } from '../utils/logger.js';
|
||||
import type { Config } from '../config/index.js';
|
||||
import type {
|
||||
PostsRepository,
|
||||
MessagesRepository,
|
||||
SuccessfulMessagesRepository,
|
||||
} from '../database/repositories.js';
|
||||
import type { ChatService } from '../services/chat.js';
|
||||
import type { MediaService } from '../services/media.js';
|
||||
import type { MediaSyncService } from '../services/media-sync.js';
|
||||
import type { ResponseCheckerService } from '../services/response-checker.js';
|
||||
import type { RateLimiter } from '../utils/rate-limiter.js';
|
||||
import type { OpenRouterClient } from '../ai/openrouter.js';
|
||||
import type { StrategySelector } from '../services/strategy-selector.js';
|
||||
import type { BrowserClient } from '../browser/client.js';
|
||||
import type { ActivityLog } from './activity-log.js';
|
||||
import type { LogBroadcaster } from './log-broadcaster.js';
|
||||
import type { RuntimeConfig } from './types.js';
|
||||
|
||||
/** Bag of everything the route modules might need. */
|
||||
export interface WebContext {
|
||||
logger: Logger;
|
||||
config: Config;
|
||||
runtimeConfig: RuntimeConfig;
|
||||
activity: ActivityLog;
|
||||
broadcaster: LogBroadcaster;
|
||||
|
||||
repos: {
|
||||
posts: PostsRepository;
|
||||
messages: MessagesRepository;
|
||||
successful: SuccessfulMessagesRepository;
|
||||
};
|
||||
|
||||
services: {
|
||||
chat?: ChatService;
|
||||
media?: MediaService;
|
||||
mediaSync?: MediaSyncService;
|
||||
responseChecker?: ResponseCheckerService;
|
||||
rateLimiter?: RateLimiter;
|
||||
ai?: OpenRouterClient;
|
||||
strategySelector?: StrategySelector;
|
||||
browser?: BrowserClient;
|
||||
};
|
||||
|
||||
/** Bot pause/resume toggle read by the main loop. */
|
||||
getBotRunning(): boolean;
|
||||
setBotRunning(running: boolean): void;
|
||||
|
||||
/** Mirrored count for the dashboard's `messagesThisHour` widget. */
|
||||
getMessagesThisHour(): number;
|
||||
|
||||
/**
|
||||
* Callback invoked when the dashboard mutates `runtimeConfig`.
|
||||
* Wrapped in a getter so callers see the latest value — it can be installed
|
||||
* after the WebContext is constructed.
|
||||
*/
|
||||
getOnConfigChange(): ((config: RuntimeConfig) => void) | null;
|
||||
}
|
||||
Reference in new issue
Block a user