feat(distill,conversations,scheduler,api,ui): close deep chats with a distiller fork, digest and index, idle and weekly state jobs

This commit is contained in:
hh
2026-08-29 03:15:39 +02:00
parent ab9ce50b82
commit 23cfb16228
11 changed files with 1103 additions and 19 deletions
@@ -441,6 +441,36 @@ def build_app(runtime: GatewayRuntime, *, memory_root: Path | None = None) -> Fa
"text": result.text,
}
@app.post("/conversations/{public_id}/close")
async def post_close(public_id: str, request: Request) -> dict[str, Any]:
token = await require_token(request, runtime, scope=SCOPE)
conv = await conv_of(public_id)
if conv.kind != "deep":
closed = await conversations.close(conv)
return {"id": closed.external_id, "status": closed.status}
try:
result = await conversations.distill(conv, reason="api")
except (ValueError, LookupError) as exc:
raise HTTPException(status.HTTP_400_BAD_REQUEST, str(exc)) from exc
except RuntimeError as exc:
raise HTTPException(status.HTTP_409_CONFLICT, str(exc)) from exc
await audit.log(
runtime,
actor=f"token:{token}",
kind="api_close",
agent_name=conv.agent_name,
conversation=conv.external_id,
digest=str(result.digest.path) if result.digest else None,
)
return {
"id": conv.external_id,
"status": "closed",
"fork": result.fork.external_id,
"text": result.text,
"digest": str(result.digest.path) if result.digest else None,
"error": result.error,
}
@app.post("/conversations/{public_id}/fork")
async def post_fork(public_id: str, request: Request) -> dict[str, Any]:
await require_token(request, runtime, scope=SCOPE)