diff --git a/agent/tools/read/read.py b/agent/tools/read/read.py index 09cd1f9c..69f5676c 100644 --- a/agent/tools/read/read.py +++ b/agent/tools/read/read.py @@ -16,7 +16,7 @@ class Read(BaseTool): """Tool for reading file contents""" name: str = "read" - description: str = f"Read or inspect file contents. For text/PDF files, returns content (truncated to {DEFAULT_MAX_LINES} lines or {DEFAULT_MAX_BYTES // 1024}KB). For images/videos/audio, returns metadata only (file info, size, type). Use offset/limit for large text files." + description: str = f"Read or inspect file contents. For text/PDF/Word/Excel/PPT files, returns content (truncated to {DEFAULT_MAX_LINES} lines or {DEFAULT_MAX_BYTES // 1024}KB). For images/videos/audio, returns metadata only (file info, size, type). Use offset/limit for large text files." params: dict = { "type": "object", diff --git a/desktop/build/cowagent-backend.spec b/desktop/build/cowagent-backend.spec index b6886a03..123656e3 100644 --- a/desktop/build/cowagent-backend.spec +++ b/desktop/build/cowagent-backend.spec @@ -73,6 +73,21 @@ hiddenimports += [ 'tiktoken_ext.openai_public', ] +# Document parsing libs. The read / web_fetch tools import these lazily inside +# functions (e.g. `from pypdf import PdfReader`), so PyInstaller's static +# analysis misses them and they'd be dropped from the bundle — leaving the +# desktop client unable to read PDF/Word/Excel/PPT. List them explicitly. +hiddenimports += [ + 'pypdf', + 'docx', # python-docx + 'pptx', # python-pptx + 'openpyxl', +] +hiddenimports += collect_submodules('pypdf') +hiddenimports += collect_submodules('docx') +hiddenimports += collect_submodules('pptx') +hiddenimports += collect_submodules('openpyxl') + # --- Data files ----------------------------------------------------------- # Runtime-read files/dirs that must travel with the executable. Paths are # (source, dest_dir_in_bundle). @@ -92,6 +107,12 @@ datas = [ # Some libraries (tiktoken encodings, etc.) ship data files. datas += collect_data_files('tiktoken_ext', include_py_files=False) +# python-docx / python-pptx bundle template files (default.docx / default.pptx, +# content-type XML) inside their packages; they're loaded at import/parse time, +# so ship them or document parsing fails in the frozen build. +datas += collect_data_files('docx') +datas += collect_data_files('pptx') + # --- Excludes ------------------------------------------------------------- # Keep the bundle lean: drop Feishu's heavy SDK, plugins (disabled in desktop # mode), tests/docs, and dev-only packages.