sandbox-ocr
Read the text in an image from a Code node or CodeAct action, with tesseract.js running on the host
- License 许可
- AGPL-3.0
- 最近更新
- 2026-08-18
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- sandbox-ocr
- description
- Read the text in an image from a Code node or CodeAct action, with tesseract.js running on the host
02 资源文件 1
- 参考文档package.json862 B
03 SKILL.md 正文
OCR in the sandbox
Specifier: @nodetool-ai/sandbox-ocr. Declare it in the node's packages
property and import it at the top of the body.
tesseract.js runs a WASM engine, spawns workers, and downloads its language data on first use — none of which the guest can do. This pack is a host module: the import resolves to a generated facade over NodeTool's own implementation.
recognize — image bytes to text
import { recognize } from "@nodetool-ai/sandbox-ocr";
const { text, confidence, words } = await recognize(
await workspace.readBytes("receipt.png")
);
const total = words.find((w) => /^\d+[.,]\d{2}$/.test(w.text));
return { text, confidence, total: total?.text ?? null };
One call gives you all three readings:
text— the whole page as one string.confidence— the page mean, 0–100.words—{text, confidence, bbox: {x, y, width, height}}per word, in reading order, with the box in image pixels.
Pass { language: "eng+deu" } for anything other than English; the codes are
Tesseract's, +-joined. The data file for a language it has not seen before is
downloaded the first time you ask for it, so that call is slower.
Get the bytes from workspace.readBytes, from await response.bytes(), or
from an asset with assetToSandbox.
Gotchas
recognizeis async, and the first call to it pays for engine startup.- 10 MB per image. Larger input is refused by name.
- 20 000 words per page.
- Straight, sharp scans read best. Use
image.rotateandimage.adjustto deskew and raise contrast before you hand the bytes over.
04 同仓库更多 Skills
sandbox-zip
Read and write zip archives in a Code node or CodeAct action, with fflate running on the host under a 50 MB inflation cap
sandbox-yaml
Read and write YAML inside a Code node or CodeAct action, with js-yaml running in the guest
sandbox-xml
Parse XML feeds and sitemaps in a Code node or CodeAct action, with fast-xml-parser running on the host
sandbox-xlsx
Read and write Excel workbooks in a Code node or CodeAct action, with exceljs running on the host
sandbox-twilio
Send SMS and WhatsApp messages and look up numbers from a Code node or CodeAct action, with NodeTool's Twilio request builder running on the host
sandbox-tfjs
Classify and embed images, detect objects, and answer from a passage in a Code node or CodeAct action, with TensorFlow.js running on the host