managarten/packages/bot-services/src/index.ts
Till-JS c2c80efc50 feat(matrix-bots): add i18n system and direct message fallback
- Add I18nService with per-user language preferences (de/en)
- Add !language/!sprache command to all 4 bots (todo, calendar, contacts, clock)
- Add fallback behavior: messages without commands create tasks/events/contacts/timers
- Improve clock bot duration parsing to accept bare numbers as minutes (e.g. "25" = 25min)
- Add support for more duration formats: "25 minuten", "1 stunde", etc.

Language preferences stored in SessionService, default configurable via BOT_DEFAULT_LANGUAGE env var.
2026-02-02 16:07:27 +01:00

195 lines
4.3 KiB
TypeScript

/**
* @manacore/bot-services
*
* Shared business logic services for Matrix bots and the Gateway.
* These services are transport-agnostic and can be used by:
* - Individual Matrix bots (standalone)
* - The Gateway bot (all-in-one)
* - REST APIs
* - CLI tools
*
* @example
* ```typescript
* import { TodoModule, TodoService } from '@manacore/bot-services/todo';
* import { AiModule, AiService } from '@manacore/bot-services/ai';
*
* // In NestJS module
* @Module({
* imports: [
* TodoModule.register({ storagePath: './data/todos.json' }),
* AiModule.register({ baseUrl: 'http://ollama:11434' }),
* ],
* })
* export class AppModule {}
* ```
*/
// ===== Core Services =====
// Todo
export {
TodoModule,
TodoModuleOptions,
TodoService,
TODO_STORAGE_PROVIDER,
TodoApiService,
} from './todo/index.js';
export type {
Task,
Project,
TodoData,
CreateTaskInput,
UpdateTaskInput,
TaskFilter,
TodoStats,
ParsedTaskInput,
} from './todo/index.js';
// Calendar
export {
CalendarModule,
CalendarModuleOptions,
CalendarService,
CalendarApiService,
CALENDAR_STORAGE_PROVIDER,
} from './calendar/index.js';
export type {
CalendarEvent,
Calendar,
CalendarData,
CreateEventInput,
UpdateEventInput,
EventFilter,
ParsedEventInput,
} from './calendar/index.js';
// AI (Ollama)
export { AiModule, AiModuleOptions, AiService } from './ai/index.js';
export type {
OllamaModel,
ChatMessage,
ChatOptions,
ChatResult,
ChatResponseMeta,
AiServiceConfig,
UserAiSession,
SystemPromptPreset,
} from './ai/index.js';
export { SYSTEM_PROMPTS, VISION_MODELS, NON_CHAT_MODELS } from './ai/index.js';
// Clock
export { ClockModule, ClockModuleOptions, ClockService } from './clock/index.js';
export type {
Timer,
Alarm,
WorldClock,
TimezoneResult,
CreateTimerInput,
CreateAlarmInput,
CreateWorldClockInput,
ClockServiceConfig,
TimeTrackingSummary,
} from './clock/index.js';
// Session (User authentication via mana-core-auth)
export {
SessionModule,
SessionService,
RedisSessionProvider,
REDIS_SESSION_PROVIDER,
REDIS_CLIENT,
SESSION_MODULE_OPTIONS,
DEFAULT_SESSION_EXPIRY_MS,
} from './session/index.js';
export type {
UserSession,
LoginResult,
SessionStats,
SessionModuleOptions,
SessionStorageMode,
} from './session/index.js';
// Transcription (Speech-to-Text via mana-stt)
export {
TranscriptionModule,
TranscriptionService,
STT_MODULE_OPTIONS,
} from './transcription/index.js';
export type {
SttResponse,
TranscriptionOptions,
TranscriptionModuleOptions,
} from './transcription/index.js';
// Credit (Credit balance and formatting for Matrix bots)
export {
CreditModule,
CreditService,
CREDIT_MODULE_OPTIONS,
CreditErrorCode,
} from './credit/index.js';
export type {
CreditBalance,
CreditValidationResult,
CreditConsumeResult,
CreditModuleOptions,
CreditStatusMessage,
} from './credit/index.js';
// I18n (Multi-language support for Matrix bots)
export { I18nModule, I18nService, I18N_OPTIONS, LANGUAGE_NAMES } from './i18n/index.js';
export type {
Language,
I18nOptions,
BotTranslations,
CommonTranslations,
TodoTranslations,
CalendarTranslations,
ContactsTranslations,
ClockTranslations,
} from './i18n/index.js';
export { de as deTranslations, en as enTranslations } from './i18n/index.js';
// ===== Placeholder Services (to be implemented) =====
export { NutritionModule } from './nutrition/index.js';
export type { NutritionServiceConfig, Meal, NutritionSummary } from './nutrition/index.js';
export { QuotesModule } from './quotes/index.js';
export type { QuotesServiceConfig, Quote } from './quotes/index.js';
export { StatsModule } from './stats/index.js';
export type { StatsServiceConfig, AnalyticsReport } from './stats/index.js';
export { DocsModule } from './docs/index.js';
export type { DocsServiceConfig, ProjectDoc } from './docs/index.js';
// ===== Shared Utilities =====
export { FileStorageProvider, MemoryStorageProvider } from './shared/index.js';
export type {
StorageProvider,
BaseEntity,
UserEntity,
ServiceConfig,
Result,
PaginationOptions,
PaginatedResult,
DateRange,
Priority,
ServiceStats,
} from './shared/index.js';
export {
generateId,
getTodayISO,
startOfDay,
endOfDay,
addDays,
formatDateDE,
formatTimeDE,
isToday,
isTomorrow,
parseGermanDateKeyword,
getRelativeDateLabel,
} from './shared/index.js';
export { PRIORITY_VALUES } from './shared/index.js';