Your own agent
The author package gives an agent you build the tools vDesign’s own agents use, and the skill written for them. Your model reads a design a part at a time and changes it with patch statements, instead of reading and rewriting whole files. The documents stay in your store: you write two methods, and the package does the rest. It comes for TypeScript and for Python, with the same tools and the same engine.
TypeScript
npm install @getv.design/author
Install the agent library you use beside it: ai, @langchain/core or @openai/agents.
Python
getv-design-author, imported as getv_design.author, is served from vDesign’s package
index at https://getv-design.github.io/python/simple/ while it is not on PyPI. Wheels
cover Python 3.10 and later on Linux, macOS and Windows. With uv, name the index for this
package alone:
# pyproject.toml
[[tool.uv.index]]
name = "getv-design"
url = "https://getv-design.github.io/python/simple/"
explicit = true
[tool.uv.sources]
getv-design-author = { index = "getv-design" }
uv add "getv-design-author[langchain]" langchain
With pip, pin the version: --extra-index-url looks on PyPI too, and takes the highest
version it finds anywhere.
pip install --extra-index-url https://getv-design.github.io/python/simple/ "getv-design-author[langchain]==0.2.2" langchain
The extra installs the agent library’s tool layer beside it: [langchain] (langchain-core),
[openai-agents] or [pydantic-ai]. LangChain’s create_agent, used below, is in the
langchain package, so install that too, as the commands above do. Pydantic AI needs
Python 3.11 or later; the other two work from 3.10.
Two methods over your store
TypeScript
import { createAgent } from 'langchain';
import { Tools } from '@getv.design/author/langchain';
class DocumentTools extends Tools {
async getDocument(name) {
const row = await db.documents.find(name);
return row && { text: row.body, rev: String(row.version) }; // null: no such document
}
async saveDocument(name, text, rev) {
// Save only if still at `rev` (null: only if new). The new rev, or null when refused.
return db.documents.update(name, text, { ifVersion: rev });
}
}
const agent = createAgent({
model,
tools: DocumentTools.load({ userId }), // reaches your methods as this.options
systemPrompt: DocumentTools.skill(),
});
Python
from langchain.agents import create_agent
from getv_design.author.langchain import Tools
class DocumentTools(Tools):
async def get_document(self, name): # sync methods work too
row = await db.documents.find(name)
return row and {"text": row.body, "rev": str(row.version)} # None: no such document
async def save_document(self, name, text, rev):
# Save only if still at `rev` (None: only if new). The new rev, or None when refused.
return await db.documents.update(name, text, if_version=rev)
agent = create_agent(
model=model,
tools=DocumentTools.load(user_id=user_id), # reaches your methods as self.options
system_prompt=DocumentTools.skill(),
)
The get method returns the whole .vd file as you saved it, pictures included; the tools
carry them through every change untouched and never hand them to the model.
With another agent library
TypeScript
With the Vercel AI SDK or the OpenAI Agents SDK, only the import changes:
import { ToolLoopAgent } from 'ai';
import { Tools } from '@getv.design/author/ai-sdk'; // also for Mastra agents
const agent = new ToolLoopAgent({
model,
instructions: DocumentTools.skill(),
tools: DocumentTools.load(),
});
import { Agent } from '@openai/agents';
import { Tools } from '@getv.design/author/openai-agents';
const agent = new Agent({
name: 'designer',
instructions: DocumentTools.skill(),
tools: DocumentTools.load(),
});
For a folder of .vd files, FileTools.load({ dir: './designs' }) is ready-made. For any
other library, DocumentTools.schemas() gives the tools as { name, description, parameters }
and new DocumentTools(options).call(name, args) runs one.
Python
With the OpenAI Agents SDK or Pydantic AI, only the import changes:
from agents import Agent
from getv_design.author.openai_agents import Tools
agent = Agent(
name="designer",
instructions=DocumentTools.skill(),
tools=DocumentTools.load(),
)
from pydantic_ai import Agent
from getv_design.author.pydantic_ai import Tools
agent = Agent(model, instructions=DocumentTools.skill(), tools=DocumentTools.load())
For a folder of .vd files, FileTools.load(dir="./designs") is ready-made, from the
module of the library you use. For any other library, getv_design.author.Tools.load()
gives plain tools (a name, a description, parameters and an async execute),
DocumentTools.schemas() gives them as {name, description, parameters}, and
await DocumentTools(**options).call(name, args) runs one (call_sync from synchronous
code). There is no Vercel AI SDK in Python.
The tools
| Tool | Answers |
|---|---|
vd_create | makes a new document from complete DSL |
vd_outline | every id with its type and box, for one page or all |
vd_read | some nodes as DSL, by id |
vd_find | which ids match an id, a type or some words |
vd_text | the words, page by page |
vd_patch | applies patch statements, all or nothing |
vd_check | what would not parse or draw |
vd_image | a page as it renders, or one picture with its crop |
vd_reference | one part of the format reference, or an example |
A refused patch, a document that changed since it was read, or a problem comes back as the tool’s answer, with the problem’s code, never as an error your library would hide.
TypeScript
vd_image shows a page (src a page’s id, or null for the first) or one picture (an
image’s id or an asset’s name). It answers with a picture: execute (and call()) resolves to
{ text, image }, image being { mediaType: 'image/jpeg', base64, width, height }, where
every other tool answers a string. Each adapter hands it to its library in that library’s
form: the AI SDK through toModelOutput (text and a file part), LangChain as a text block
and an image block, the OpenAI Agents SDK as text and image output items. With
LangChain on OpenAI, leave it out: @langchain/openai cannot put a picture in a tool
result today. Chat Completions takes only text in a tool message, and the Responses API is
sent the blocks as JSON text, picture and all. Under LangChain with Gemini, check that
the picture reaches the model before relying on it. The drawing code, its WebAssembly and its fonts load the first time it is
called, in a runtime that can compile WebAssembly from bytes (Node, Deno, Bun, a browser);
elsewhere they answer that they could not draw.
A page draws its text with Inter, which the package carries, the document’s own fonts, and the
fonts installed where it runs. For the same picture on every server, pass
systemFonts: false to load(): then a family the document neither carries nor is Inter
draws in Inter, and the problems say which text no longer fits.
vd_png, which showed a page until it became vd_image with a page’s id, is no longer
offered; call('vd_png', { document, page, size }) still answers, as vd_image, until the
next release.
Python
vd_image shows a page (src a page’s id, or None for the first) or one picture (an
image’s id or an asset’s name). It answers with a picture: execute (and call()) returns a
PictureAnswer, with text and image (media_type "image/jpeg", base64, width,
height, and data for the bytes), where every other tool answers a string. Each adapter
hands it to its library in that library’s form: LangChain as a text block and an image
block, the OpenAI Agents SDK as a ToolOutputText and a ToolOutputImage, Pydantic AI as a
ToolReturn with the picture as BinaryContent. With LangChain on OpenAI, leave it out, as
in TypeScript.
The pictures are drawn by the same Rust as the export’s, inside the wheel: Inter is built in, with the document’s own fonts. The fonts installed where it runs are never read, so a page is the same picture on every machine.
From code: Design
The tools are for a model. For a step with no model in it (a digest of a deck, a check of
every image’s hash, a patch someone approved), Design is one .vd file with the same verbs
and data for answers: nodes as objects, problems with their code, bytes as bytes. It reads
the file once, and it never changes: patch returns a new Design.
TypeScript
import { Design } from '@getv.design/author';
const doc = new Design(await readFile('deck.vd', 'utf8'));
doc.pages; // [{ id: 's1' }, …]
doc.assets; // [{ name: 'house', type: 'image/jpeg', hash: 'sha256-…', size: 31700, present: true }]
doc.asset('house')?.data; // Uint8Array
doc.read(['s1.photo'], { assets: true }); // { dsl, assets: [{ …, data }] }
doc.find({ type: 'image' }); // [{ id: 's1.photo', type: 'image', page: 's1' }]
doc.check(); // [{ severity, code, message, nodeId }]
const next = doc.patch('set s1.photo x=900'); // throws PatchRefused, with its problems
await writeFile('deck.vd', next.source);
const page = await doc.image('s1'); // { data, width, height, mediaType, problems }
Over your store, open and save keep the revision, so an edit made on an old copy is
refused rather than written over a newer one:
const tools = new DocumentTools({ userId });
const doc = await tools.open('deck'); // at the store's rev
await tools.save('deck', doc.patch('set s1.photo x=900')); // throws StaleDocument if it moved on
Python
from getv_design.author import Design
doc = Design.open("deck.vd") # or Design(text)
doc.pages # [Page(id="s1"), …]
doc.assets # [Asset(name="house", type="image/jpeg", hash="sha256-…", size=31700, present=True)]
doc.asset("house").data # bytes
doc.read(["s1.photo"], assets=True) # Read(dsl, assets=[AssetData(…, data=b"…")])
doc.find(type="image") # [FoundNode(id="s1.photo", type="image", page="s1")]
doc.check() # [Problem(severity, code, message, node_id)]
new = doc.patch("set s1.photo x=900") # raises PatchRefused, with its problems
Path("deck.vd").write_text(new.source)
page = doc.image("s1") # DesignImage(data, width, height, media_type, problems)
Over your store, open and save keep the revision (open_sync and save_sync from
synchronous code):
tools = DocumentTools(user_id=uid)
doc = await tools.open("deck")
await tools.save("deck", doc.patch("set s1.photo x=900")) # raises StaleDocument if it moved on
The model’s tools return no asset bytes: a picture as base64 costs a model a token for every
three bytes and shows it nothing, so a model looks with vd_image. The bytes are for code.
Choosing what the agent knows
skill() is the system prompt; the reference is fetched with vd_reference when a task
needs it. Give both calls the same options:
TypeScript
const options = { topics: ['motion'], inline: ['edits'] };
DocumentTools.load(options); // no video or brand for this agent
DocumentTools.skill(options); // so the skill leaves them out; the edits reference inlined
Python
options = {"topics": ["motion"], "inline": ["edits"]}
DocumentTools.load(**options) # no video or brand for this agent
DocumentTools.skill(**options) # so the skill leaves them out; the edits reference inlined
topics is any of motion, video and brand, references limits what vd_reference
serves, and inline adds references to the prompt. Pictures are slots: the model writes an
image with a name saying what goes there, and your app fills it.
The package is free to use under its own licence; the skill’s text is CC BY 4.0, like the format.