Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/bopoadz-del_cerebrum-blocks.json
T
OpenCode 68a9071cf1 feat: reconcile local master with origin (exa/hot-platform hunters, leaks ledger, latest results)
Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
2026-08-07 12:53:47 +08:00

1 line
15 KiB
JSON

{"repo": "bopoadz-del/cerebrum-blocks", "files": {"block_registry/knowledge/block.json": {"d5a7469921c803a779a1d100c72fdcdab847ceeb": {"t": 1786068229.2092915, "n": 5164, "h": "f3391040f53ea600", "c": "{\n \"author\": \"Cerebrum Team\",\n \"description\": \"Ask questions across stored captures and swarm runs using RAG\",\n \"digests\": {\n \"Dockerfile\": \"905bd5e509638c2df98d8f1039fba18adde147d0d7ffbf70778ca87888cd0da1\",\n \"block.json\": \"b3c2795999fa2e6e9aa3f872aa9e092a2f19819dd7864c456ed7def5390a597a\",\n \"block.py\": \"d1dea88780e5c8a02184b6d4c55fa88fb63fed4d3656466bb76e31b66bc7192c\"\n },\n \"execution\": {\n \"image\": \"ghcr.io/cerebrum-blocks/knowledge:latest\",\n \"type\": \"docker\"\n },\n \"id\": \"knowledge\",\n \"inputs\": [\n {\n \"description\": \"Ask a question about your knowledge base...\",\n \"name\": \"input\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"ask\",\n \"description\": \"Action\",\n \"name\": \"action\",\n \"options\": [\n \"ask\",\n \"search\",\n \"summarize\"\n ],\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": 5,\n \"description\": \"Top K\",\n \"name\": \"top_k\",\n \"required\": false,\n \"type\": \"number\"\n },\n {\n \"default\": \"deepseek\",\n \"description\": \"Configuration parameter: llm_provider\",\n \"name\": \"llm_provider\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"http://localhost:11434\",\n \"description\": \"Configuration parameter: ollama_base_url\",\n \"name\": \"ollama_base_url\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"llama3.2:3b\",\n \"description\": \"Configuration parameter: ollama_model\",\n \"name\": \"ollama_model\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"\",\n \"description\": \"Configuration parameter: deepseek_api_key\",\n \"name\": \"deepseek_api_key\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"deepseek-chat\",\n \"description\": \"Configuration parameter: deepseek_model\",\n \"name\": \"deepseek_model\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"\",\n \"description\": \"Configuration parameter: openrouter_api_key\",\n \"name\": \"openrouter_api_key\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"anthropic/claude-3.5-sonnet\",\n \"description\": \"Configuration parameter: openrouter_model\",\n \"name\": \"openrouter_model\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": \"http://localhost:8001\",\n \"description\": \"Configuration parameter: vector_db_url\",\n \"name\": \"vector_db_url\",\n \"required\": false,\n \"type\": \"string\"\n },\n {\n \"default\": 5,\n \"description\": \"Configuration parameter: default_top_k\",\n \"name\": \"default_top_k\",\n \"required\": false,\n \"type\": \"number\"\n },\n {\n \"default\": [\n \"cerebrum_captures\",\n \"cerebrum_swarm\"\n ],\n \"description\": \"Configuration parameter: default_collections\",\n \"name\": \"default_collections\",\n \"required\": false,\n \"type\": \"array\"\n }\n ],\n \"layer\": 3,\n \"name\": \"Knowledge\",\n \"outputs\": [\n {\n \"description\": \"Answer\",\n \"name\": \"answer\",\n \"type\": \"text\"\n },\n {\n \"description\": \"Sources\",\n \"name\": \"sources\",\n \"type\": \"json\"\n },\n {\n \"description\": \"Confidence\",\n \"name\": \"confidence\",\n \"type\": \"percentage\"\n }\n ],\n \"permissions\": {\n \"blocks\": [],\n \"filesystem\": false,\n \"imports\": [],\n \"network\": false\n },\n \"publisher_id\": \"cerebrum_platform\",\n \"requires\": [\n \"vector_search\"\n ],\n \"signature\": \"HutT8m1UTqOXYY+2GtY0hEJlCqyoOwqrlqalNmnjpPDY+zO1nCn5/lSkMK1uU84lQrlJTHMjctx0FJjVECY+Ag==\",\n \"tags\": [\n \"knowledge\",\n \"rag\",\n \"retrieval\",\n \"qa\",\n \"memory\",\n \"ai\"\n ],\n \"ui_schema\": [\n {\n \"label\": \"Ask a question about your knowledge base...\",\n \"name\": \"input\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Action\",\n \"name\": \"action\",\n \"options\": [\n \"ask\",\n \"search\",\n \"summarize\"\n ],\n \"widget\": \"select\"\n },\n {\n \"label\": \"Top K\",\n \"name\": \"top_k\",\n \"widget\": \"number\"\n },\n {\n \"label\": \"Llm Provider\",\n \"name\": \"llm_provider\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Ollama Base Url\",\n \"name\": \"ollama_base_url\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Ollama Model\",\n \"name\": \"ollama_model\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Deepseek Api Key\",\n \"name\": \"deepseek_api_key\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Deepseek Model\",\n \"name\": \"deepseek_model\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Openrouter Api Key\",\n \"name\": \"openrouter_api_key\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Openrouter Model\",\n \"name\": \"openrouter_model\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Vector Db Url\",\n \"name\": \"vector_db_url\",\n \"widget\": \"text\"\n },\n {\n \"label\": \"Default Top K\",\n \"name\": \"default_top_k\",\n \"widget\": \"number\"\n },\n {\n \"label\": \"Default Collections\",\n \"name\": \"default_collections\",\n \"widget\": \"json\"\n }\n ],\n \"version\": \"2.0.0\"\n}"}}, "block_store/kits/construction/bundle/app/blocks/project_reasoner.py": {"d5a7469921c803a779a1d100c72fdcdab847ceeb": {"t": 1786068460.4369626, "n": 8114, "h": "6d76dbf50dedde75", "c": "\"\"\"Project Reasoner — Reasoning Engine Plan 5.\n\nThe LLM agent. One turn: UNDERSTAND + PLAN (one LLM call returning plan JSON)\n-> EXECUTE (PlanExecutor runs the steps) -> DELIVER (one LLM call writing the\nanswer from the executed results).\n\"\"\"\n\nimport json\nimport os\nfrom typing import Any, Dict\n\nimport httpx\n\nfrom app.core.universal_base import UniversalBlock\nfrom app.core.plan_executor import PlanExecutor\nfrom app.prompts.reasoner_system import build_reasoner_prompt\nfrom app.schemas.execution_plan import ExecutionPlan\nfrom app.schemas.project_session import ProjectSession\n\n\ndef _extract_json(text: str) -> dict:\n \"\"\"Pull a JSON object out of an LLM reply (it may add prose or fences).\n Tries the whole string first, then decodes the first object starting at\n the first '{' — trailing prose (even prose containing a '}') is ignored.\n Raises ValueError when there is no parsable object.\"\"\"\n if not isinstance(text, str):\n raise ValueError(\"no JSON object in LLM reply\")\n try:\n return json.loads(text)\n except ValueError:\n pass\n start = text.find(\"{\")\n if start == -1:\n raise ValueError(\"no JSON object in LLM reply\")\n try:\n obj, _ = json.JSONDecoder().raw_decode(text, start)\n except ValueError:\n raise ValueError(\"no JSON object in LLM reply\")\n return obj\n\n\n# Per-step bound for the DELIVER prompt: every step's result is included, but\n# no single step may exceed this, so nothing is silently dropped.\n_DELIVER_STEP_LIMIT = 2500\n\n\ndef _render_step_results(run) -> str:\n \"\"\"Format this turn's step results (step + computed output) for the\n DELIVER prompt. Each output is bounded individually.\"\"\"\n lines = []\n for i, sr in enumerate(run.step_results, 1):\n if sr.status == \"success\":\n rendered = json.dumps(sr.output, default=str)\n if len(rendered) > _DELIVER_STEP_LIMIT:\n rendered = rendered[:_DELIVER_STEP_LIMIT] + \"… (truncated)\"\n lines.append(\n f\"{i}. {sr.type} (-> {sr.output_key or 'default'}): \"\n f\"OK\\n output: {rendered}\"\n )\n else:\n lines.append(\n f\"{i}. {sr.type} (-> {sr.output_key or 'default'}): \"\n f\"ERROR — {sr.error}\"\n )\n return \"\\n\".join(lines) if lines else \"(no steps executed)\"\n\n\nclass ProjectReasonerBlock(UniversalBlock):\n name = \"project_reasoner\"\n version = \"1.0.0\"\n description = (\n \"Reasoning agent: UNDERSTAND -> PLAN -> EXECUTE -> DELIVER over a \"\n \"project session.\"\n )\n layer = 3\n tags = [\"domain\", \"construction\", \"reasoning\", \"agent\", \"llm\"]\n requires = []\n\n default_config = {\"model\": \"deepseek-chat\"}\n\n ui_schema = {\n \"input\": {\n \"type\": \"text\",\n \"placeholder\": \"Ask anything about your project...\",\n \"multiline\": True,\n },\n \"output\": {\n \"type\": \"json\",\n \"fields\": [\n {\"name\": \"answer\", \"type\": \"markdown\", \"label\": \"Answer\"},\n {\"name\": \"understanding\", \"type\": \"text\", \"label\": \"Understood as\"},\n ],\n },\n \"quick_actions\": [\n {\"icon\": \"\", \"label\": \"Critical path\", \"prompt\": \"What is the critical path?\"},\n {\"icon\": \"⏱️\", \"label\": \"Compress\", \"prompt\": \"How can I finish 2 weeks sooner?\"},\n ],\n }\n\n async def _call_llm(self, prompt: str) -> str:\n \"\"\"Active-LLM-provider call. Overridden by test doubles.\n\n Routes via app.agents.runtime._llm_config — auto-uses Groq when\n GROQ_API_KEY is set, otherwise DeepSeek.\n \"\"\"\n from app.agents.runtime import _llm_config # local import: avoid cycle at module load\n cfg = _llm_config()\n api_key = os.getenv(cfg[\"env_key\"])\n if not api_key:\n raise RuntimeError(f\"{cfg['env_key']} not configured\")\n model = self.config.get(\"model\", cfg[\"default_model\"])\n if cfg[\"provider\"] != \"deepseek\" and isinstance(model, str) and model.startswith(\"deepseek-\"):\n model = cfg[\"default_model\"]\n async with httpx.AsyncClient(timeout=60.0) as client:\n resp = await client.post(\n cfg[\"url\"],\n headers={\"Authorization\": f\"Bearer {api_key}\",\n \"Content-Type\": \"application/json\"},\n json={\"model\": model,\n \"messages\": [{\"role\": \"user\", \"content\": prompt}],\n \"temperature\": 0.2},\n )\n if resp.status_code != 200:\n raise RuntimeError(\n f\"{cfg['provider']} API error (HTTP {resp.status_code})\"\n )\n return resp.json()[\"choices\"][0][\"message\"][\"content\"]\n\n async def process(self, input_data: Any, params: Dict = None) -> Dict:\n params = params or {}\n data = input_data if isinstance(input_data, dict) else {}\n request = data.get(\"request\") or data.get(\"text\") \\\n or params.get(\"request\") \\\n or (str(input_data) if not isinstance(input_data, dict) else \"\")\n session: ProjectSession = data.get(\"session\") or params.get(\"session\")\n project_id = data.get(\"project_id\") or params.get(\"project_id\")\n\n request = request or \"\"\n if not request.strip():\n return {\"status\": \"error\", \"error\": \"No request provided\"}\n if session is None:\n return {\"status\": \"error\", \"error\": \"No session provided\"}\n\n session.add_message(\"user\", request)\n\n # Look up top-k relevant snippets from this project's indexed\n # documents so the planner can ground its steps in the actual\n # uploaded files. Silent no-op when no project_id is given or the\n # project has nothing indexed yet — the reasoner falls back to\n # session-state-only planning, matching the old behavior.\n excerpts: list = []\n if project_id:\n try:\n from app.core.doc_index import search_project_documents\n excerpts = await search_project_documents(\n project_id, request, top_k=5\n )\n except Exception:\n excerpts = []\n\n # ── UNDERSTAND + PLAN ────────────────────────────────────────────\n try:\n plan_reply = await self._call_llm(\n build_reasoner_prompt(session, request, excerpts)\n )\n plan = ExecutionPlan.model_validate(_extract_json(plan_reply))\n except Exception as e: # noqa: BLE001\n return {\"status\": \"error\",\n \"error\": f\"Could not build a plan: {e}\"}\n\n # ── EXECUTE ──────────────────────────────────────────────────────\n run = await PlanExecutor().run(plan, session)\n\n # ── DELIVER ──────────────────────────────────────────────────────\n # Build the prompt from THIS turn's step results, not the whole\n # accumulated session blob — so the answer sees exactly what was just\n # computed and no step's output is silently truncated away.\n deliver_prompt = (\n f\"You planned and executed steps for this request:\\n{request}\\n\\n\"\n f\"UNDERSTANDING: {plan.understanding}\\n\"\n f\"EXECUTION STATUS: {run.status}\\n\"\n f\"STEP RESULTS (from this turn):\\n\"\n f\"{_render_step_results(run)}\\n\\n\"\n f\"Write a clear, concise answer for the user from these results. \"\n f\"If the status is error or partial, explain what is missing.\"\n )\n try:\n answer = await self._call_llm(deliver_prompt)\n except Exception as e: # noqa: BLE001\n answer = f\"(Could not generate the written answer: {e})\"\n\n session.add_message(\"assistant\", answer)\n\n status = run.status\n return {\n \"status\": status,\n \"answer\": answer,\n \"understanding\": plan.understanding,\n \"plan\": plan.model_dump(mode=\"json\"),\n \"execution\": run.model_dump(mode=\"json\"),\n }\n"}}}}