Files
factory/lib/interns-mcp/interns_mcp/interns/transcript_distill.py
vitya ca669d96e1 feat(lib): bundle MCP servers from .common/lib into factory/lib/
Copies source (no node_modules, dist, .tasks, .wiki, __pycache__) for:
- projects-meta-mcp v2.25.0 (TypeScript/Node)
- wiki-graph v0.3.1 (TypeScript/Node)
- interns-mcp v0.3.3 (Python/FastMCP)

.gitignore: exclude lib build artefacts (node_modules, dist, .venv, __pycache__, *.pyc)
bootstrap.ps1: add MCP build step — npm install+build for TS servers, venv+pip for Python

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 13:17:29 +03:00

46 lines
1.7 KiB
Python

"""Transcript distill intern — compress session transcript into structured action-list."""
from __future__ import annotations
from pathlib import Path
from typing import Any
from .base import BlockedByPolicy, Intern, InternResponse
class TranscriptDistill(Intern):
id = "transcript_distill"
description = "Compress a session transcript/log into a structured action-list."
def run(self, paths: list[str], question: str = "Extract action items, decisions, and unresolved questions.", **kwargs: Any) -> InternResponse | BlockedByPolicy:
contents: list[str] = []
for p in paths:
text = Path(p).read_text(encoding="utf-8", errors="replace")
contents.append(f"--- {p} ---\n{text}")
combined = "\n\n".join(contents)
prompt = f"Transcript:\n{combined}\n\nTask: {question}"
if self.client is None:
return InternResponse(text="No client configured", usage={})
extra_body = kwargs.get("extra_body", {})
resp = self.client.chat.completions.create(
model=self.model or "deepseek-v4-flash",
messages=[
{"role": "system", "content": self.system_prompt},
{"role": "user", "content": prompt},
],
max_tokens=kwargs.get("max_tokens", self.max_tokens),
temperature=self.temperature,
extra_body=extra_body if extra_body else None,
)
choice = resp.choices[0]
return InternResponse(
text=choice.message.content or "",
usage={
"tokens_in": resp.usage.prompt_tokens if resp.usage else 0,
"tokens_out": resp.usage.completion_tokens if resp.usage else 0,
},
)