dsh-official-file-parse: DeepSeek Harness Document Parsing Plugin

Introduction

DeepSeek Harness (DSH) embraces a “everything is a plugin” philosophy, allowing developers to extend model capabilities as needed. When processing local documents directly within a conversation, existing solutions either rely on local OCR or require additional service infrastructure. Fireqtian’s dsh-official-file-parse plugin leverages the official DeepSeek document parsing API (Files API + Anthropic-compatible Messages) to parse and answer questions about PDF, Word, PowerPoint, and other files within Harness. The parsing method is consistent with the DeepSeek official Chat Demo.

What It Is

dsh-official-file-parse is a standard Bundle plugin for DeepSeek Harness, developed by maintainer Fireqtian. It uploads local documents via the official DeepSeek document parsing API, and after parsing is complete, the server generates a context containing text, charts, and layout. It then calls a large model to answer questions. The plugin depends only on Node built-in modules and introduces no @deepseek-ai/* dependencies, avoiding coupling with the host version.

Core Features

Two Parsing Modes

The plugin provides two parsing modes, selectable via the purpose parameter:

  • rich_layout_recognition (default): Preserves text along with charts, photos, and diagrams cropped at their original positions. Ideal for papers, financial reports, and slide decks.
  • text_recognition: Extracts text only, discarding images to save tokens. Suitable for contracts and purely text-based materials.

No image cropping, re-encoding, or full-page rendering is required. Both parsing and Q&A are completed on the server side.

Tool Calls

After installation, the model gains two additional tools that can be invoked directly in conversation:

  • document_qa(path, question?, purpose?, model?): Ask questions about a specified document.
  • document_files(action, fileId?): View or delete parsed files stored under the account.

File Support

Supported formats include PDF / DOC / DOCX / PPT / PPTX, images (PNG / JPEG / WebP / GIF / BMP / TIFF), as well as TXT / MD / CSV / JSON / XLSX / XLS / EPUB / MOBI.

Caching & Re-upload

The file_id for the same file is cached based on sha256(file content) + purpose + API host, so the same file will not be parsed and charged repeatedly. If the cached ID becomes invalid, it is automatically re-uploaded once.

Installation & Activation

DeepSeek Harness (dsh) must be installed first. This plugin is a standard Bundle that declares a Host plugin via dsh.bundle.patch and registers two tools in apply.

Method 1: Local directory installation

git clone https://github.com/Fireqtian/dsh-official-file-parse.git

In Harness, open Plugins → Add Plugin → Select Local Directory (or “Install from local directory” on the plugins page) and point it to the cloned dsh-official-file-parse directory. After installation, the plugin row dsh-official-file-parse appears and takes effect automatically.

You can also publish this package to npm and install it by package name; both the plugin manager and dsh plugin --profile <name> add will install the package into the profile.

After installation, new sessions can use it immediately. After modifying code, you need to disable/enable the plugin once on the plugins page (or restart Harness) to load the updated JS.

Configuration

Plugin row configuration (can also be modified on the Plugins page):

Key Default Description
baseURL https://api.deepseek.com Official API endpoint
apiKeyEnv DEEPSEEK_API_KEY Credential reference name
model deepseek-flash Response model
reasoningEffort low Reasoning effort: default/none/low/high/max. default means the field is not sent (server default is high)
maxTokens 32768 Single output limit, including reasoning tokens; too small will cause long-document questions to only reason without answering
timeoutMs 300000 Timeout for a single upload/Q&A (parsing can be slow)
defaultPurpose rich_layout_recognition Parsing mode when none is specified

Usage Examples

document_qa(path="C:\docs\report.pdf", question="What is the revenue in 2025 in this table?")
document_qa(path="paper.pdf", purpose="text_recognition", question="Summarize the contributions of this paper")
document_qa(path="slides.pptx")            # Performs a general summary when no question is provided
document_files(action="list")              # View parsed files stored under the account
document_files(action="delete", fileId="file-api-...")

Parameter descriptions:

  • path: Absolute path, or a path relative to the session working directory.
  • question: The question to ask; omitted for a general summary.
  • purpose: rich_layout_recognition (default) or text_recognition; plain text, tables, and e-books always use user_data.
  • model: The model to answer document questions, default deepseek-flash.

Implementation Details

  • POST /anthropic/v1/files: Multipart upload; purpose must be placed before file; the server returns file_id only after parsing is complete.
  • POST /anthropic/v1/messages: Content block {type:'document', source:{type:'file', file_id}} + question text, with anthropic-beta: files-api-2025-04-14.
  • Request body includes reasoning: {effort}: Reasoning is enabled by default with effort high, sharing max_tokens with the response. The default is lowered to low, and the budget is raised to 32768.
  • Parsing response stop_reason: When it is max_tokens, the result is annotated with “response was truncated” instead of presenting a half-sentence as a complete answer; if reasoning exhausts the budget and produces no text at all, reasoning is automatically disabled and retried once. If still empty, an error is raised explaining that this is an output budget issue, not an unreadable document.
  • Files are read via Harness’s ctx.fs (respecting sandbox and observation policies), falling back to Node fs only when the service is unavailable.

Why “call the model a second time”: The Harness DeepSeek adapter currently only accepts text / image content blocks and cannot include a file_id in the current session request. Additionally, the official policy states that parsing results cannot be downloaded. Therefore, the plugin uses a separate Messages call to read the document and returns the answer as a tool result.

Limitations

  • Single file ≤ 100 MiB, ≤ 1000 pages (plain text/tables/e-books use user_data, original ≤ 32 MiB, text ≤ 8 MiB, no parsing fee).
  • Upload is billed per page; subsequent questions are billed per token.
  • Official note: Images in documents are auto-cropped by layout analysis; it is not guaranteed that every image is recognized; images that are not cropped are invisible to the model.
  • The official API does not provide download of parsing results: cropped images exist only in the model’s context; the plugin cannot access pixel data and can only pass back the text the model extracted.
  • Uploaded documents are stored under the DeepSeek account; use document_files to delete them.

Development & Structure

  • index.js: Plugin entry point: two tools, Files/Messages client, upload cache.
  • cordis.patch.yml: Bundle’s Host plugin row and default configuration.
  • locale/{en,zh}.json: Title, description, and detail page path in the plugin manager.
  • icon.svg: Plugin icon (36×36, self-contained SVG).
  • docs/DETAIL.md: Plugin detail page content.
  • test/mock-test.mjs: Offline integration test.

Local testing:

node --check index.js
node test/mock-test.mjs      # Local mock service, validates multipart order, document block, SSE parsing, list/delete

test/mock-test.mjs requires no network or API Key.

Use Cases

Suitable for developers and users who need to process local documents directly within Harness conversations, for example:

  • Quick Q&A on papers, financial reports, and technical documents
  • Structured information extraction from PPT slide decks
  • Text retrieval from contracts and plain-text materials

Before use, review the source code and license (MIT) to ensure compatibility with the current dsh process permissions.

Conclusion

dsh-official-file-parse enables native document parsing and Q&A in Harness through the official Files API, allowing developers to process PDF, Word, PowerPoint, and other formats in conversation without setting up their own services. The plugin’s caching mechanism avoids redundant parsing, and the two parsing modes adapt to different scenarios. Everything is completed server-side, making it ideal for agent development that requires deep document reading.

Plugin Directory | GitHub

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye