sandbox-docx
Build a Word document in a Code node or CodeAct action, with docx running on the host
- License 许可
- AGPL-3.0
- 最近更新
- 2026-08-18
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- sandbox-docx
- description
- Build a Word document in a Code node or CodeAct action, with docx running on the host
02 资源文件 1
- 参考文档package.json842 B
03 SKILL.md 正文
Word documents in the sandbox
Specifier: @nodetool-ai/sandbox-docx. Declare it in the node's packages
property and import it at the top of the body.
docx builds a document out of class instances (Paragraph, TextRun,
Table, …) that cannot cross the guest boundary as plain data. This pack is a
host module: you describe the document as a JSON element list and the host
builds the real .docx bytes.
build — element list to .docx bytes
import { build } from "@nodetool-ai/sandbox-docx";
const bytes = await build({
properties: { title: "Q3 Report", author: "NodeTool" },
elements: [
{ type: "heading", text: "Q3 Report", level: 1 },
{ type: "paragraph", text: "Revenue grew 12% quarter over quarter.", bold: true },
{ type: "table", rows: [["Month", "Revenue"], ["Jul", "120k"], ["Aug", "134k"]] },
{ type: "pageBreak" },
{ type: "paragraph", text: "See appendix for methodology.", alignment: "CENTER" }
]
});
await workspace.writeBytes("report.docx", bytes);
Element types:
heading—text,level(1–6, default 1)paragraph—text,alignment(LEFT/CENTER/RIGHT/JUSTIFY, defaultLEFT),bold,italic,fontSize(points, default 12)table—rows, a 2D array; every cell is stringifiedimage—data(aUint8Array),width/heightin inchespageBreak— no fields
properties.title/author/subject/keywords set the document's metadata.
Gotchas
buildis async and returns aUint8Array.- Writing only. To read an existing
.docx, use@nodetool-ai/sandbox-mammothinstead — these are two different libraries on two different sides of the format. - Images are inches, not pixels.
width/heightfollow docx's own convention; omit them and the image renders at a fixed placeholder size. - 10 MB per image. The shared host-module input cap applies to each
datafield.
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