Create Library Item
library_create · Tools · Documents
Create a Library document from blocks in an existing folder
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
blocks | object[] | No | The document's blocks, in order. Omit for an empty document. |
color | string | No | Color of the item's icon in the Library tree. Stored exactly as given, without validation, and applied as the icon's CSS color. Use a hex code `#rrggbb`: the color picker offers #b15d5c (red), #94751b (ochre), #54894a (green), #2a8e67 (sea green), #008c93 (teal), #517aba (blue), #846ab0 (purple) or a custom hex. Omit for the default color. |
icon | string | No | Icon drawn for the item in the Library tree, in place of the default document, folder or file icon. Stored exactly as given, without validation. Use a Phosphor icon as an Iconify id, `ph:` plus the icon's kebab-case name from phosphoricons.com, e.g. ph:file-text, ph:notebook, ph:calendar-dots, ph:rocket-launch: that is what the icon picker writes. Any other `prefix:name` is passed to Iconify as is; a value without a colon is read as a Phosphor name. An emoji, or a name the icon set does not have, draws no icon. Omit for the default icon. |
name | string | Yes | The item's name. A document's name is its title: the name shown in the Library tree and the heading its page renders above the blocks, so the blocks must not repeat it as a heading. Example: 'Q1 Research Notes'. |
path | string[] | Yes | Folder path as an array of folder slugs or ids from the root, as library_list and every returned item give them, e.g. ['projects-ab12cd', 'q1-x9y8z7']; [] is the root. A folder's name is not a path segment. The folder the document is created in. Required. |
Create Library Item Tool#
library_create creates a document from blocks in an existing Library folder. Folders are created with library_create_folder.
When to Use#
The agent uses it to save new content. Before creating, it lists the folders with library_list and searches with library_search, then puts the document in the folder it belongs to. A new folder is made first with library_create_folder. Existing documents are edited with the block tools; names and icons are changed with library_update.
load_skill("keeping-a-library") says how to choose where a document goes and how to grow and link documents.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | The item's name. A document's name is its title, shown in the Library tree and as the heading above its blocks, so the blocks must not repeat it as a heading |
path |
string[] | Yes | Required. Folder path as folder slugs or ids from the root; [] is the root. Every folder must already exist |
blocks |
array | No | The document's blocks, in order. Omit for an empty document |
icon |
string | No | Icon drawn in the Library tree, stored as given: a Phosphor icon as an Iconify id such as ph:notebook. Omit for the default icon |
color |
string | No | Icon color, stored as given: a hex code #rrggbb. Omit for the default color |
A block is BlockNode JSON: an object whose type names the block, with an optional id (10 letters and digits). A block keeps the id it states; a missing or malformed id gets a fresh one, and an id repeated within the document is replaced after its first holder. library_get returns the ids stored.
load_skill("library-documents") gives every block type with its fields, and get_docs("documents") says what a document can contain, including pages drawn from HTML or SVG. The agent reads get_docs("documents") before writing to a document the first time. A malformed block is refused with a message naming what is wrong.
Returns#
| Field | Type | Description |
|---|---|---|
item |
object | The item: id, slug, name, kind (document, folder or file), path (folder slugs; null when unfiled), path_names, icon, color, ai_access_policy, revision, created_at, updated_at, url; a file adds object_id, media_kind, content_type, filename, size_bytes |
The blocks, with the ids they were stored under, are read back with library_get.
url is the item's link. The agent gives it to the user when it reports the change, labelled with the item's name rather than its folder path.
Example Scenario#
{
"name": "Q1 Research Notes",
"path": ["projects-ab12cd"],
"blocks": [
{ "type": "heading", "level": 2, "content": [{ "type": "text", "text": "Findings" }] },
{ "type": "paragraph", "content": [{ "type": "text", "text": "Churn fell 4%." }] }
]
}
Notes#
- A call without
path, or withpath: null, is refused:A document needs a place: give `path`, with [] for the root. - A folder on
paththat does not exist is refused, and nothing is created:Folder 'nilo' not found. List the folders with library_list to find the path.A folder's name is not a path segment - Markdown
contentis not accepted; write blocks - The new document's blocks are its first version
- Risk: write