Init commit

This commit is contained in:
pporcheret
2026-10-24 17:55:05 +02:00
parent 7152b10695
commit c9c3d5f223
122 changed files with 7154 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
python3 -m venv "$ROOT/venv"
"$ROOT/venv/bin/pip" install -U pip
"$ROOT/venv/bin/pip" install -r "$ROOT/requirements.txt"
for d in "$ROOT"/hermes/MCP_*; do
echo "Installation $(basename "$d")"
rm -rf "$d/venv"
python3 -m venv "$d/venv"
"$d/venv/bin/pip" install -U pip
"$d/venv/bin/pip" install -r "$d/requirements.txt"
[ -f "$d/.env" ] || cp "$d/.env.example" "$d/.env"
done
[ -f "$ROOT/.env" ] || cp "$ROOT/.env.example" "$ROOT/.env"
mkdir -p "$HOME/.hermes/skills" "$HOME/alfred-data"
echo "Venv créés. Copie ensuite hermes/skills/* vers $HOME/.hermes/skills/ et renseigne les .env."
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
mkdir -p "$HOME/.hermes/skills"
cp -a "$ROOT/hermes/skills/." "$HOME/.hermes/skills/"
echo "Skills installées dans $HOME/.hermes/skills"
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT/app"
exec "$ROOT/venv/bin/python" app.py
+97
View File
@@ -0,0 +1,97 @@
import asyncio
import time
from acp import Client, connect_to_agent
from acp.schema import (
InitializeResponse,
NewSessionResponse,
PromptResponse,
RequestPermissionResponse,
)
class AlfredClient(Client):
async def session_update(self, session_id, update):
print(f"[ACP] {update}", flush=True)
async def request_permission(self, options, session_id, tool_call):
raise RuntimeError(
"Une autorisation est demandée pendant le test ACP"
)
async def main():
print("[ALFRED] Démarrage Hermes ACP...", flush=True)
start = time.perf_counter()
process = await asyncio.create_subprocess_exec(
"/root/.local/bin/hermes",
"acp",
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.DEVNULL,
)
try:
client = AlfredClient()
async with connect_to_agent(
client,
process.stdin,
process.stdout,
) as agent:
init = await agent.initialize(
protocol_version=1,
client_capabilities={},
client_info={
"name": "alfred",
"version": "1.0",
},
)
print(f"[ACP] Initialisation : {init}", flush=True)
session = await agent.new_session(
cwd="/opt/alfred/app",
mcp_servers=[],
)
print(f"[ACP] Session : {session.session_id}", flush=True)
for question in (
"Combien font deux plus deux ? Réponds en français.",
"Quelle est la capitale de la France ? Réponds en français.",
):
start_question = time.perf_counter()
result = await agent.prompt(
session_id=session.session_id,
prompt=[
{
"type": "text",
"text": question,
}
],
)
elapsed = time.perf_counter() - start_question
print(f"\nQuestion : {question}")
print(f"Résultat : {result}")
print(f"Temps : {elapsed:.2f} secondes\n")
print(
f"[ALFRED] Temps total : "
f"{time.perf_counter() - start:.2f}s"
)
finally:
if process.returncode is None:
process.terminate()
await process.wait()
if __name__ == "__main__":
asyncio.run(main())