feat: auth surface exposée + ChatService partagé (v0.19.0)

Auth login fort : mot de passe scrypt + TOTP 2FA (otplib) + JWT HS256
(jose), login tout-ou-rien sans indice. ChatService factorise le tour
d'agent pour toutes les surfaces (Telegram refactoré). 60 tests, 0 vuln.

Palier de risque : reversible (logique d'auth ; surface API câblée en v0.20).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kantin-Petit
2026-06-23 02:06:32 +02:00
parent b617487d0d
commit e322ed1167
7 changed files with 299 additions and 13 deletions
+35
View File
@@ -0,0 +1,35 @@
import type { Logger } from "pino";
import { OllamaClient } from "../llm/ollama.js";
import { runAgentTurn } from "./loop.js";
import type { Guard, ToolHandle } from "./types.js";
/**
* Service de conversation : un tour d'agent par message. Partagé par toutes les
* surfaces (Telegram, API/UI) pour garantir le MÊME comportement et le même
* contrôle (Guard, audit) quelle que soit l'entrée.
*/
export interface ChatServiceDeps {
client: OllamaClient;
tools: ToolHandle[];
guard: Guard;
systemPrompt: string;
logger: Logger;
}
export class ChatService {
constructor(private readonly deps: ChatServiceDeps) {}
async handle(actor: string, text: string): Promise<string> {
const { reply, steps } = await runAgentTurn({
client: this.deps.client,
system: this.deps.systemPrompt,
userText: text,
tools: this.deps.tools,
actor,
guard: this.deps.guard,
logger: this.deps.logger,
});
this.deps.logger.info({ actor, steps }, "tour d'agent terminé");
return reply;
}
}