AGENT SKILL

file_hub_tools

暂无简介

License 许可
MIT
最近更新
2026-11-14
Stars
★ 0
Forks
0

02 资源文件 5

03 SKILL.md 正文

File-hub tools — document fetch, fill, render, and upload

You have six tools for working with files via the robotsix-file-hub service:

file_hub_get — download a file from file-hub

Downloads a file by its file-hub UUID to a local working directory and returns the local path plus metadata (filename, size, content-type, category, tags, summary).

Use when: you need to inspect, process, or fill a document that was pushed to file-hub (e.g. a PDF attachment from an email).

Example: file_hub_get(file_id="e0367d94-1895-4756-8730-3867f694fd05")

list_pdf_form_fields — inspect fillable fields in a PDF

Lists all AcroForm form fields in a PDF: field names, types, current values, and available options (for dropdowns/checkboxes). Use this before fill_pdf_document to discover what fields are available.

Use when: you have a PDF and need to know what form fields it contains before filling them.

Example: list_pdf_form_fields(pdf_path="/data/file_hub_work/form.pdf")

render_pdf_page — render a PDF page to a viewable image

Renders page N of a local PDF to a raster image (PNG) so you can visually inspect the page — see field box positions, verify overlay placement, or identify where to draw text. Returns the image as base64 data plus pixel dimensions and PDF-point page size for coordinate conversion.

Use when: you need to see a PDF page visually — to find form field box positions before overlaying text, or to verify that filled overlays are correctly placed.

Coordinate conversion: The response includes page_width_points and page_height_points (the page size in PDF points, 1 pt = 1/72 inch). To convert a pixel position from the rendered image to PDF overlay coordinates:

pdf_x = pixel_x * page_width_points / width
pdf_y = page_height_points - (pixel_y * page_height_points / height)

Note the Y-axis flip: rendered images have Y=0 at the top, but PDF coordinates have Y=0 at the bottom.

Example:

render_pdf_page(pdf_path="/data/file_hub_work/sepa_mandate.pdf", page=0, dpi=120)

fill_pdf_document — fill a PDF form, overlay text, or stamp images

Fills a PDF in one or more of three modes:

  1. Form-field fill — for PDFs with AcroForm fields. Pass field_values as a JSON object mapping field names to values: {"name": "John Doe", "date": "2025-01-15"}

  2. Text overlay — for flat/non-form PDFs. Pass text_overlays as a JSON array: [{"page": 0, "x": 100, "y": 700, "text": "John Doe", "font_size": 12}]

  3. Image overlay — stamp a local image (PNG with transparency) onto the PDF. Pass image_overlays as a JSON array: [{"page": 0, "x": 400, "y": 50, "image_path": "/data/file_hub_work/signature.png", "width": 150}] If only width or height is given, the other is derived from the image's aspect ratio.

Coordinates are in PDF points (72 per inch) from the bottom-left corner of the page. All three modes can be combined in a single call.

Constraints:

  • No signature forging. This tool writes text, field values, and stamps provided images only. It must not generate or synthesize signatures. The human operator provides their own signature image for the agent to stamp.
  • Use list_pdf_form_fields first to discover available field names.

Example (form fill):

fill_pdf_document(
    pdf_path="/data/file_hub_work/sepa_mandate.pdf",
    field_values='{"account_holder": "Jean Dupont", "iban": "FR76...", "bic": "BNPAFRPP"}',
    output_path="/data/file_hub_work/sepa_mandate_filled.pdf"
)

Example (overlay):

fill_pdf_document(
    pdf_path="/data/file_hub_work/flat_form.pdf",
    text_overlays='[{"page": 0, "x": 150, "y": 680, "text": "Jean Dupont"}]',
    output_path="/data/file_hub_work/flat_form_filled.pdf"
)

Example (image stamp):

fill_pdf_document(
    pdf_path="/data/file_hub_work/sepa_mandate.pdf",
    image_overlays='[{"page": 0, "x": 400, "y": 50, "image_path": "/data/file_hub_work/signature.png", "width": 150}]',
    output_path="/data/file_hub_work/sepa_mandate_signed.pdf"
)

transform_image — resize, compress, convert, or strip metadata from an image

Runs a trivial binary-asset transform on an image stored in file-hub. Fetches the source by file-hub id, processes it locally with Pillow, uploads the result back to file-hub, and returns the new file-hub id plus before/after byte sizes and pixel dimensions. It does the whole file-hub round-trip itself — you do not need file_hub_get/file_hub_put around it.

Use when: you need to shrink/compress a large photo before adding it to a website, convert between formats (JPEG/PNG/WebP), or strip EXIF/ICC metadata.

Pass operations as a JSON object; every field is optional:

  • resize — {"max_width": 1600, "max_height": 1200} (either key optional). Preserves aspect ratio and never upscales.
  • quality — JPEG/WebP quality 1–100 (default 75).
  • format — "jpeg", "png", or "webp" (default: keep the source format).
  • strip_metadata — bool (default true); strip EXIF/ICC/other metadata.

Constraints: input images larger than 50 MB are rejected; non-image objects return a clear error. Only the transforms above are available (no arbitrary processing).

Example:

transform_image(
    file_id="e0367d94-1895-4756-8730-3867f694fd05",
    operations='{"resize": {"max_width": 1600}, "quality": 75}',
    output_filename="hero.jpg"
)

file_hub_put — upload a file to file-hub

Uploads a local file to file-hub, preserving the filename and content-type. Returns the new file-hub UUID so the file can be retrieved later or shared.

Use when: you have a filled/processed document that needs to go back into file-hub for the operator to download, sign, or forward.

Example: file_hub_put(file_path="/data/file_hub_work/sepa_mandate_filled.pdf")

Typical workflow

  1. file_hub_get — fetch the document from file-hub
  2. render_pdf_page — view the page to identify field positions
  3. list_pdf_form_fields — inspect what form fields are available
  4. fill_pdf_document — fill the form fields or overlay text
  5. render_pdf_page — verify the filled document looks correct
  6. file_hub_put — upload the filled document back to file-hub

Error handling

  • Unknown file id — file_hub_get returns a clear "File not found" message.
  • File-hub unreachable — all tools return a clear "File-hub unavailable" message with the connection error details.
  • Non-PDF input — fill_pdf_document and list_pdf_form_fields return a clear "Not a valid PDF" message when the file lacks a %PDF header.
  • Non-image / oversize input — transform_image returns a clear "Not a decodable image" message for non-image objects and an "Image too large" message when the source exceeds 50 MB.

04 同仓库更多 Skills