Document & Table Nodes

Applies to: ChengOS v0.2.0+ | Last verified: 2026-09-25 | Source: crates/cheng-nodes/src/nodes/builtin/document, crates/cheng-nodes/src/nodes/builtin/table

Structured content, in two shapes. Documents are block-based: document/ops_hub dispatches by operation the way the file hub does, while the individual nodes create, query, and update blocks explicitly. Tables are record-based, with a query node, a node that applies record operations, and a node that renders a table into LLM context. The format_for_llm and build_llm_context nodes exist because raw document or table JSON is a poor prompt — they produce the bounded, readable form a model should actually see. Shadow-session internals are hidden and driven by the hub.

Document Operations Hub — document/ops_hub

Document operations hub node: control Agent document capabilities with toggle switches

Inputs

FieldTypeRequiredDefaultDescription
operationstring—""Operation type
document_idstring——Document ID (common to most operations)
configobject (port)——Unified config object (can input JSON text directly). Connection port, not a form field. Control: text
workspace_idstring——Workspace ID (used by create operation, set by user on canvas)
allow_queryboolean✅trueWhether to allow querying documents (read-only). Control: switch
allow_formatboolean✅trueWhether to allow formatting documents (read-only). Control: switch
allow_discoveryboolean✅trueWhether to allow document discovery (list/search) (read-only). Control: switch
allow_diffboolean✅trueWhether to allow diff preview of proposed edits (read-only). Control: switch
allow_updateboolean✅falseWhether to allow updating document blocks (medium side-effect). Control: switch
allow_batchboolean✅falseWhether to allow batch document operations (mixed side-effect). Control: switch
allow_createboolean✅falseWhether to allow creating new documents (medium side-effect). Control: switch
allow_duplicateboolean✅falseWhether to allow duplicating documents (medium side-effect). Control: switch
allow_importboolean✅falseWhether to allow importing documents from text (medium side-effect). Control: switch
allow_delete_documentboolean✅falseWhether to allow hard-deleting documents (high risk). Control: switch
allow_rollbackboolean✅falseWhether to allow restoring/rolling back a document from a snapshot (high risk). Control: switch

Outputs

FieldTypeDescription
operationstringActual operation type executed
requires_reviewbooleanWhether this operation staged a shadow that must be reviewed.
shadow_idstringShadow session ID, when a write operation is staged for review.
document_idstringDocument ID associated with the staged review.
change_summarystringSummary lifted from shadow apply output for Agent final/review handling.
errorstringError message (operation prohibited or execution failed)
resultanyOperation result (JSON-serialized sub-node output)
preview_contextstringPreview lifted from shadow apply output for Agent final/review handling.

Create Document — document/create

Create a new document in workspace, supports AgentContext pass-through

Inputs

FieldTypeRequiredDefaultDescription
contextobject (port)—nullAgentContext port. Connection port, not a form field.
titlestring—nullOptional title for the document.
initial_contentstring—nullInitial content for the first block (optional).
block_typestring—paragraphBlock type for initial content (default: paragraph).
priorityenum—normalInitial block priority. Control: select. Options: low, normal, medium, high, critical
tagsstring—nullInitial block tags (comma-separated)

Outputs

FieldTypeDescription
contextobject (port)AgentContext port. Connection port, not a form field.
stringstringFormatted success message with title and document_id
document_idstringID of the created document.
titlestringTitle of the created document.
root_block_idstringID of the root block.
successbooleanWhether creation was successful.
errorstringError message if creation failed.

Query Document — document/query

Get document content, optionally return as block structure or Markdown format

Inputs

FieldTypeRequiredDefaultDescription
document_idstring✅—Select document to query (from current workspace). Control: dynamic-select
include_contentboolean—trueWhether to include full block content (default: true).
as_markdownboolean—falseOptional: return content as markdown instead of blocks.

Outputs

FieldTypeDescription
successbooleanWhether the query was successful.
foundbooleanWhether the document was found.
document_idstringDocument ID (if found).
titlestringDocument title.
blocksarray<object>All blocks in the document.
markdownstringFull document content as markdown (if as_markdown=true).
plain_textstringPlain text content.
block_countintegerNumber of blocks.
character_countintegerTotal character count.
errorstringError message if query failed.
content_typestringContent type (richtext/markdown).
root_block_idstringRoot block ID.

Update Document Block — document/update_block

Update content or type of a specific block in document, supports AgentContext pass-through

Inputs

FieldTypeRequiredDefaultDescription
contextobject (port)—nullAgentContext port. Connection port, not a form field.
document_idstring✅—Select document to update. Control: dynamic-select
block_idstring✅—ID of the block to update.
contentstring✅—New content for the block.
block_typestring—nullNew block type (optional, keeps existing if not provided).
languagestring—nullLanguage for code blocks (optional).
priorityenum—nullBlock priority. Control: select. Options: low, normal, medium, high, critical
tagsstring—nullBlock tags (comma-separated)

Outputs

FieldTypeDescription
contextobject (port)AgentContext port. Connection port, not a form field.
stringstringFormatted success message with document_id and block_id
successbooleanWhether the update was successful.
block_idstringUpdated block ID.
block_typestringUpdated block type.
contentstringUpdated content.
document_versionintegerNew document version after update.
errorstringError message if update failed.

Extract Document Items — document/extract_items

Extract document block tags + lines into Loop-ready items

Inputs

FieldTypeRequiredDefaultDescription
document_idstring✅—Select a document, searchable by name. Control: dynamic-select
extract_targetenum—tagsWhich payload to emit: tags, lines, pairs, objects, groups. Control: select. Options: tags (Just the tag list.), lines (Just the line list.), pairs ({ tag, line } pairs.), objects (Structured object whose keys are tags, values are selected lines.), groups (Full { tag, lines } candidate pool.)
combine_modeenum—listCombination mode: list, sequential, random, selected, zip, cartesian. Control: select. Options: list (Simple flat list.), sequential (Iterate in document order (tags × lines, document-order interleaved).), random (One random pick per tag.), selected (Use selection_map to pick one line per tag.), zip (Align lines across tags by index.), cartesian (Cartesian product across tags.)
tag_filterstring—nullFilter tags (comma-separated, case-insensitive substring match)
tag_policyenum—first_tagHow to handle blocks with multiple tags. Control: select. Options: first_tag (Use only the first tag of a block as its group label.), all_tags (The same block belongs to every tag it carries.)
untagged_policyenum—skipHow to handle blocks without tags. Control: select. Options: skip (Skip blocks without tags (default).), group (Group untagged blocks under the synthetic tag _untagged.)
selection_mapobject—nullUser selection per tag (populated by popup widget). Control: document-extract-selector. Shown when document_id
random_seedstring—nullOptional seed for reproducible random selection
max_itemsinteger—0Maximum number of items to emit (0 = unlimited). Control: number
delimiterstring—, Delimiter used to join item texts into formatted_text
strictboolean—falseError out when selection_map references missing lines. Control: switch

Outputs

FieldTypeDescription
itemsanyStandard Loop items array
formatted_textstringItems joined into a single string
groupsarray<object>Tag → candidate lines pool
countintegerItems count.
document_titlestringDocument title (if any).
successbooleanWhether the node executed successfully.
errorstringFatal error message (if any).
warningsarray<string>Non-fatal warnings.

Format Document (LLM) — document/format_for_llm

Read and format document for LLM use, supports priority and tag filtering

Inputs

FieldTypeRequiredDefaultDescription
contextobject (port)—nullAgentContext port. Connection port, not a form field.
document_idstring✅—Select a document to read, searchable by name. Control: dynamic-select
priority_filterenum—allFilter blocks by priority. Control: select. Options: all (所有优先级), high_only (仅高优先级(High + Critical)), critical_only (仅 Critical), normal_and_above (Normal 及以上(Normal + High + Critical))
tag_filterstring—nullFilter by tags (comma-separated, e.g.: core concepts,API)
sort_orderenum—originalBlock sort order. Control: select. Options: original (按文档原始顺序), priority_desc (按优先级降序(Critical -> High -> Normal -> Low)), priority_asc (按优先级升序(Low -> Normal -> High -> Critical))
output_formatenum—markdownOutput format. Control: select. Options: markdown (Markdown 格式), plain_text (纯文本), structured (结构化(包含块信息))
include_metadataboolean—trueWhether to include block tags and priority info in output
system_promptstring—nullCustom system prompt (optional). Control: textarea
max_charsinteger—0Maximum character limit (0 means unlimited)

Outputs

FieldTypeDescription
contextobject (port)AgentContext port. Connection port, not a form field.
formatted_contentstringFormatted document content
preview_contentstringPreview-friendly document summary with title, character count, and content excerpt
blocksarray<object>Structured block list
titlestring文档标题
block_countinteger处理的块数量
filtered_block_countinteger过滤后的块数量
character_countinteger总字符数
truncatedboolean是否被截断
successboolean是否成功
errorstring错误信息

Query Table — table/query

Get table data, including column definitions and records

Inputs

FieldTypeRequiredDefaultDescription
table_idstring✅—ID of the table to query.
record_idsarray—nullOptional list of specific record IDs to fetch. If not provided, fetches all records (paginated).
include_schemaboolean—trueWhether to include column definitions (default: true).
pageinteger—1Page number for pagination (1-based, default: 1).
page_sizeinteger—100Number of records per page (default: 100, max: 1000).

Outputs

FieldTypeDescription
successbooleanWhether the query was successful.
foundbooleanWhether the table was found.
tableobjectTable metadata (if found).
columnsarray<object>Column definitions (if include_schema=true).
recordsarray<object>Records data.
total_recordsintegerTotal number of records in the table.
pageintegerCurrent page number.
total_pagesintegerTotal number of pages.
errorstringError message if query failed.
markdownstringMarkdown formatted table (columns + records), suitable for preview node.
agent_contextobject (port)AgentContext port (can be directly connected to Agent node's context input). Connection port, not a form field.

Apply Table Operations — table/apply_record_ops

Batch apply table record insert, update, delete operations

Inputs

FieldTypeRequiredDefaultDescription
table_idstring✅—Table ID to apply operations to.
operationsarray<enum>✅—List of operations to apply.
summarystring—nullOptional summary of changes (for logging/audit).

Outputs

FieldTypeDescription
successbooleanWhether all operations were successful.
resultsarray<object>Results for each operation.
summarystringSummary of changes.
table_idstringTable ID.
records_affectedintegerNumber of records affected.
records_insertedintegerNumber of records inserted.
records_updatedintegerNumber of records updated.
records_deletedintegerNumber of records deleted.
errorstringError message if the overall operation failed.

Build Table LLM Context — table/build_llm_context

Build context information for LLM table editing

Inputs

FieldTypeRequiredDefaultDescription
table_idstring✅—Table ID to build context for.
selected_record_idsarray—nullOptional list of selected record IDs. If provided, only these records will be included in the context.
instructionstring✅—User's editing instruction/request.
formatstring—jsonOutput format: "json", "markdown", or "csv".
max_recordsinteger—100Maximum records to include in context (0 = unlimited).

Outputs

FieldTypeDescription
successbooleanWhether context building was successful.
table_idstringTable ID.
table_namestringTable name.
system_promptstringSystem prompt for LLM.
table_contextstringTable context (formatted table data).
user_promptstringUser instruction (formatted).
tools_jsonstringTool definitions JSON for LLM function calling.
llm_contextstringIntegrated LLM context as JSON string. Connect this to ReAct agent's task input.
agent_contextobject (port)AgentContext port (can be directly connected to Agent node's context input). Connection port, not a form field.
records_includedintegerNumber of records included.
column_countintegerNumber of columns.
errorstringError message if building failed.
warningsarray<string>Warnings generated during context building.

Next steps