mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
- Rename platform/ to svc/ to avoid shadowing stdlib platform. - Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths. - tests/conftest: prepend repo root to sys.path (no parent-folder package name). - CI: paths and offline_eval script under repo root. - Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup). - Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from runtime.tools.base import ToolSpec
|
|
|
|
|
|
def index_workspace_tool() -> ToolSpec:
|
|
def handler(args: dict[str, Any]) -> dict[str, Any]:
|
|
max_files = int(args.get("max_files") or 120)
|
|
try:
|
|
from svc.persistence.sqlite_store import SqliteStore
|
|
from svc.config.paths import db_path
|
|
from runtime.tools.workspace_indexer import index_workspace
|
|
|
|
store = SqliteStore(db_path())
|
|
st = index_workspace(store, max_files=max(1, min(max_files, 800)))
|
|
return {"ok": True, "files_seen": st.files_seen, "chunks_upserted": st.chunks_upserted, "embeddings_upserted": st.embeddings_upserted}
|
|
except Exception as e:
|
|
return {"ok": False, "error": f"{type(e).__name__}: {e}"}
|
|
|
|
return ToolSpec(
|
|
name="index_workspace",
|
|
description="Index workspace files into vector knowledge base for RAG.",
|
|
parameters={
|
|
"type": "object",
|
|
"properties": {"max_files": {"type": "integer", "default": 120, "description": "Max files to index."}},
|
|
"required": [],
|
|
"additionalProperties": False,
|
|
},
|
|
handler=handler,
|
|
tags=frozenset({"public", "rag"}),
|
|
risk_level="high",
|
|
read_only=False,
|
|
)
|
|
|
|
|
|
__all__ = ["index_workspace_tool"]
|