Skip to main content

Crate k2f_sdk

Crate k2f_sdk 

Source
Expand description

Agent-facing K2F SDK: edit by node id, Markdown bridge, PDF export.

§Example

use k2f_sdk::Editor;
use std::path::Path;

let mut editor = Editor::open_dir(Path::new("./source")).unwrap();
editor.insert_node(
    "root",
    0,
    r#"{"id":"doc.title","role":"h1","content":{"type":"text","value":"Hello"}}"#,
)
.unwrap();
let bytes = editor.save_bytes().unwrap();
assert!(!bytes.is_empty());

Structs§

AgentError
Change
ChangelogEntry
ChangelogFile
ConversionReport
Editor
Surgical editor: mutate the semantic tree, then relock. Does not edit lock x/y.
GeneratedKey
MarkdownOptions
MarkdownResult
OutlineNode
PdfExportOptions
PDF export settings. By default exports only the lock pages (no captions or verify page).

Enums§

ChangeOp
PageSize
PdfScale

Constants§

CONTENT_HASH_MISMATCH
DOCX_IS_NOT_A_SOURCE
DUPLICATE_ID
FONT_MISSING
IDML_IS_NOT_A_SOURCE
IMAGE_SIZE
INVALID_ARGUMENT
INVALID_ID
INVALID_MODIFIER
PDF_IS_NOT_A_SOURCE
PPTX_IS_NOT_A_SOURCE
SCHEMA_INVALID
SVG_TEXT
SYSTEM_PROMPT
TABLE_ROW_MISMATCH
UNKNOWN_ID
UNKNOWN_ROLE
WRONG_CONTENT

Functions§

export_docx
export_idml
export_idml_only
export_pdf
export_pdf_at
export_pdf_with
export_pptx
format_schemas
Pack-path keys (e.g. schema/nodes.schema.json) → embedded format schema JSON text.
generate_key
k2f_to_markdown
markdown_to_k2f
parse_pdf_scale
sign
Sign a compiled package. Agents save unsigned; a human/org key signs the lock bytes. signed_at is UTC unix seconds. None uses the current UTC time.
validate_agent_json