Sync agents and workflows with the UI
Pull agent and workflow definitions into lunnoa/, edit the JSON, and push them back without overwriting UI changes.
Agent and workflow definitions can live in a lunnoa/ folder and stay in step with the Automate UI. pull copies the UI into those files. push copies the files back. If both sides changed, the CLI stops and shows the difference.
Use JSON files for this loop. Use a TypeScript defineAgent or defineWorkflow file only when the definition needs code. A TypeScript deploy stays locked in the UI. See Synced and generated.
The binary is lunnoa-client. npx lunnoa-client and npx @lunnoa/client run the same command. This page uses npx lunnoa-client.
Auth matches the rest of the CLI: LUNNOA_URL and LUNNOA_API_KEY, or --url and --api-key. The CLI also reads ./.env. A lunnoa.config.ts, .mjs, .js, or .json file can set url, apiKey, and definitionsDir. Real environment variables win. The key is for the CLI only. See Authentication.
Why
Someone can edit an agent or a workflow in the UI after the last push. A later push must not throw that edit away.
pull writes the UI copy into the repo. status shows whether the file, the UI, or both have moved. push sends baseRevision from lunnoa/lunnoa.lock.json. When that revision is stale, Lunnoa answers 409 and the CLI exits 1. Nothing is written on that push.
The lunnoa folder
The default folder is ./lunnoa, next to package.json. Set definitionsDir in lunnoa.config.*, or pass --dir, to use another folder.
lunnoa/
agents/<slug>.json
agents/<slug>.instructions.md
workflows/<slug>.json
lunnoa.lock.json<slug> is the workspace slug (^[a-z0-9]+(?:-[a-z0-9]+)*$). Renaming an agent or workflow in the UI does not change the slug.
Every JSON file starts with $schema. The value is a relative path from that file to node_modules/@lunnoa/client/schemas/agent.schema.json or workflow.schema.json. The CLI adds $schema when it writes a file and removes it before sending. Files are pretty-printed JSON with a trailing newline.
Agent instructions are the markdown file. The JSON points at it:
"instructions": { "file": "triage.instructions.md" }You may hand-write instructions as a string. pull always writes the markdown file and the { "file" } pointer.
lunnoa.lock.json is committed. It records, per deployment, the id, revision, and file hash of each synced agent and workflow. The deployment key is <base url without a trailing slash>#<workspace id>.
{
"version": 1,
"deployments": {
"https://lunnoa.example#workspace-id": {
"agents": {
"triage": { "id": "…", "revision": "…", "fileHash": "…" }
},
"workflows": {
"sync-orders": { "id": "…", "revision": "…", "fileHash": "…" }
}
}
}
}fileHash is the SHA-256 of the JSON bytes. For an agent it also covers a NUL byte and the instructions file. pull and push update the lock. Commit it with the JSON files.
What is in the file
Agent
Write a small file. The first successful push rewrites it to the definition Lunnoa stored: full settings and empty link lists. Commit that rewrite with the lock file. A connection id in that rewrite belongs to this deployment. Do not copy it into another workspace.
{
"$schema": "../../node_modules/@lunnoa/client/schemas/agent.schema.json",
"kind": "agent",
"slug": "greeter",
"name": "Greeter",
"description": "Replies with one short sentence.",
"model": "deepseek-ai/DeepSeek-V4-Pro",
"instructions": {
"file": "greeter.instructions.md"
},
"settings": {
"suggestedPrompts": ["Say hello"]
}
}greeter.instructions.md sits next to the JSON. That file is the prompt:
You are Greeter.
When someone says hello, reply with one short, friendly sentence. Use their name when they give one.| Field | How to set it |
|---|---|
kind | agent. |
slug | Workspace slug. Renaming the agent in the UI does not change it. |
name | The name people see. |
description | Optional. Leaving it out of a later push clears it. |
model | A models[].id from npx lunnoa-client ai-connections list --json. Leaving model out clears it, and the agent cannot chat. |
aiConnection | Optional { "id" } from ai-connections list. Leaving it out stores no connection. Do not copy a connection id into another deployment. |
instructions | { "file": "<slug>.instructions.md" }, or a string. pull always writes the markdown file. |
settings | Optional. Only the keys you include are written. Leaving a key out does not clear it. pull writes every key, including temperature, maxToolRoundtrips, messageLookbackLimit, suggestedPrompts, and longHorizonMode. The schema lists the rest. |
tools | Optional. Each tool has key, id (the catalogue action id from tools get), name, and input. Add connection: { "id" } when the action needs one. Leave tools out to keep the tools already stored. |
workflows, agents | Optional { "slug" } links. A full push sends workflows before agents. |
connections, knowledge, variables, objects, objectTypes, mcpServers, a2aAgents | Optional id lists. Leave a list out to keep the links already stored. objects and objectTypes may include a scope object. |
profileImageUrl, canvas, skills, drive, shares, publicShare | Optional. null clears the image, canvas, drive mount, or public link. An empty skills or shares list removes them. Leave a key out to keep what is stored. |
Field by field: The agent file, Capabilities, and Runtime settings.
Workflow
A workflow file is either steps or graph. See Steps files and graph files.
Connection fields in these files are ids. The secret for a connection stays in Lunnoa.
Left in the UI
These are not in the file, and push does not change them:
| Left in the UI | What that means |
|---|---|
| Credentials | API keys, tokens, passwords, and connection secrets. The file may hold a connection id. A public-link password is not in the file. passwordProtected: false clears one. |
| Workflow canvas layout | Node positions on a workflow. A push keeps the position of a step it matches by key. Agent builder positions are canvas on the agent file. |
| On/off switch | Workflow isActive. A push of an existing workflow leaves the switch as it is. A new workflow starts on. |
| Memory facts | What the agent has remembered. The memory policy is settings.memoryEnabled and the fields next to it. |
| Triggers on an agent | Agents have no trigger. Put the schedule, webhook, or app event on a workflow. |
codeSource and the sync revision | The lock file stores the revision. push sets codeSource to synced. Do not put either in the agent file. The revision is a hash of that file. |
Placeholder nodes the builder uses as scaffolding are dropped on pull and on push.
Pull, edit, push
Check status
npx lunnoa-client statusprints one row per file in the folder and per slug in the lock for this deployment.Pull
npx lunnoa-client pullwrites definitions whose server revision differs from the lock, when the local file is unchanged. If the lock revision already matches, the file is left as it is, including local edits.Edit
Change the JSON, the instructions markdown, or both. Keep secrets out of
inputvalues. See Secrets.Push
npx lunnoa-client pushsends every JSON file, workflows first, then agents. On success it writes the definition Lunnoa stored and updates the lock.
Run pull before push whenever status says the UI has moved. A push uses the revision in the lock. A stale revision is a 409.
| Command | Effect |
|---|---|
pull | Slugs recorded in the lock for this deployment. |
pull <slug> | That agent or workflow. If the slug is both, the CLI stops and asks for a prefix. |
pull agents/<slug> or pull workflows/<slug> | One resource. |
pull --all | Every agent and workflow in the workspace. |
push | Every JSON file in the folder. |
push <path-or-slug> | One file. agents/<slug>.json and workflows/<slug>.json select the kind. |
status | Local and remote state. Add --json for a JSON array. |
--dir <folder> | Definitions folder for that command. |
--force | Pull overwrites a local edit. Push skips the revision check. See Conflicts. |
status columns are KIND, SLUG, LOCAL, REMOTE, CONFLICT.
| Column | Values |
|---|---|
LOCAL | unchanged, modified, new, missing |
REMOTE | unchanged, changed in UI, missing in Lunnoa |
CONFLICT | true when both sides differ from the lock. A new file that Lunnoa does not have yet is not a conflict. |
--json prints { "kind", "slug", "local", "remote", "conflict" } for each row. remote uses the words changed in UI, with spaces.
pull only calls read endpoints. When there is nothing to write it prints Nothing to pull.
Conflicts
Pull refuses the whole run before it writes a file when the server revision differs from the lock and the local file hash also differs. The message is:
Local and server both changed. Run pull --force to overwrite.
agents/triage.json
--- local
+++ serverLines starting with - are the file on disk. Lines starting with + are the server copy. A local file that exists but is not in the lock counts as a local change.
pull --force replaces those files with the server copy and updates the lock.
Push exits 1 on HTTP 409 and prints the server message. The CLI appends the current revision:
Changed in the UI since your last pull. Run pull first. (currentRevision: …)push --force skips that check and overwrites the UI with the file.
First push onto an existing slug
A file that is not in the lock for this deployment is sent without baseRevision. If that slug already exists, Lunnoa answers 409:
A workflow with slug "sync-orders" already exists in Lunnoa. Run pull first, or push with --force.The same sentence is used for an agent, with agent in place of workflow. Run pull for that slug, then edit, then push. pull records the revision. The next push sends it as baseRevision.
A slug Lunnoa does not have yet is created, even when the lock has no row for it.
agents deploy file.json and workflows deploy file.json are a push of that file. agents deploy file.ts and workflows deploy file.ts (also .js and .mjs) still deploy the TypeScript definition. See the next section.
Synced and generated
codeSource is the field on agents and workflows. It replaces managedByCode for those two resources. Tables and entity types still use managedByCode.
codeSource | How it got there | UI |
|---|---|---|
none | Built in the UI, never pushed | Editable. No badge. |
synced | Pushed from a JSON file | Editable, unless Lock code-synced resources is on. |
generated | agents deploy / workflows deploy of a .ts, .js, or .mjs file | Always locked. |
npx lunnoa-client agents list and npx lunnoa-client workflows list print a SOURCE column. That value is codeSource.
JSON is the default. Write lunnoa/agents/<slug>.json or lunnoa/workflows/<slug>.json, then push.
TypeScript is for a definition that needs code: a defineWorkflow you also pass to runs.start, or an agent whose tools are built in code. Deploy sets codeSource to generated. The UI shows Managed by code and rejects edits. Deploy the TypeScript file again to change it. agents deploy file.ts --force does not send --force. The flag applies to pull, push, and a .json deploy.
To turn a generated resource into a synced one, pull that slug (this writes the JSON) and push the JSON file. The push sends codeSource: "synced". After that, UI edits are allowed and come back through pull.
App code can load a definition file and pass it to defineAgent or defineWorkflow. $schema is removed. instructions: { file } is accepted by defineAgent and left as that object. The CLI is what reads the markdown, and only when you push. Do not call the upsert helpers from the app for this loop.
Badges and the workspace lock
Lists and detail pages show a badge from the sync state:
| Badge | When |
|---|---|
| Synced with code | codeSource is synced, and the definition still matches the last push. |
| Changed in UI, not yet in code | codeSource is synced, and someone saved in the UI after that push. |
| Managed by code | codeSource is generated, or synced while the workspace lock below is on. Editing is disabled. |
| No badge | codeSource is none. |
A successful push stores the new revision, and the badge returns to Synced with code. The push job runs when main changes, which keeps the badge on the copy in main. The server stores the revision from the push it received. A push from another branch updates the badge the same way.
The badge tooltip for Changed in UI, not yet in code says to run lunnoa-client pull.
Lock code-synced resources
A workspace switch, Lock code-synced resources, makes every synced agent and workflow read-only in the UI. They show Managed by code. Generated resources stay locked whether the switch is on or off.
Open Admin Panel → User Management → Workspaces, open the workspace, and open Settings. The switch is on the LLM Audit Policy card. Its description says agents and workflows synced with code can only change through a push.
With the switch on, a UI save returns 409: This agent is synced with code. This workspace only allows changes through a push. The workflow sentence uses workflow. A generated resource returns: This agent is managed by code and cannot be changed here.
push still updates a locked resource. Memories, shares, and the profile image are not part of the definition. The lock does not cover them.
Steps files and graph files
pull picks the file shape.
Steps ("format": "steps") is the readable shape: one trigger and a steps list. A step has key, name, use (id, optional appId, optional connection), and input. Optional description, retrySettings, continueOnFailure, and paths are included when set. The trigger key is trigger. Other keys start with a letter and use letters, digits, -, or _. References in input look like ={{step:send,…}} or ={{step:trigger,…}}.
Graph ("format": "graph") is the fallback: nodes and edges, with edges pointing at keys. Pull writes graph when the steps file would not round-trip to the same workflow. That includes paths that join again, and a for-each loop. A straight line, including a branch at the end, stays steps.
Pull chooses the format. Edit that file and push it. Push accepts either format. The first push rewrites the file to the definition Lunnoa stored. Pushing that file again changes nothing, and a pull right after a push writes the same bytes.
Secrets
pull scans tool inputs, trigger inputs, step inputs, and graph node values. If a field name matches authorization, token, secret, password, passwd, api key, apikey, bearer, cookie, or private key, and the value is a non-empty string that is not a ={{…}} reference, it prints a warning on stderr and still writes the file:
Warning: workflows/sync-orders.json field "steps[0].input.apiKey" looks like a secret. Definitions are committed; keep secrets in Lunnoa connections.The warning does not include the secret value. A conflict diff replaces that value with ***. Put the secret on a Lunnoa connection and reference the connection by id.
Schemas
Validate a file against the package schemas before you push:
node_modules/@lunnoa/client/schemas/agent.schema.jsonnode_modules/@lunnoa/client/schemas/workflow.schema.json
Both are JSON Schema draft 2020-12. The $schema key in each file points at them, so an editor can check as you type. On push the CLI checks the file shape: a slug, instructions, step use.id, unique keys, and a graph with exactly one trigger. A file that fails those checks errors before the request is sent.
Continuous integration
Two jobs keep the repo and the workspace aligned. The pull job uses a read-only key (LUNNOA_API_KEY): it only sends GET requests, and it needs permission to read agents and workflows. The push job needs a key that can create agents and workflows (LUNNOA_PUSH_API_KEY). Store both, and LUNNOA_URL, as repository secrets. Do not pass --force.
pull with no slug updates slugs already in the lock. Commit lunnoa.lock.json on main so the push job can send baseRevision. If pull finds a conflict it exits 1 and the pull request is not opened.
The install step should match the repo. This example uses npm.
name: Lunnoa definitions
on:
schedule:
- cron: "0 6 * * *"
push:
branches: [main]
workflow_dispatch:
jobs:
pull:
if: github.event_name != 'push'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx lunnoa-client pull
env:
LUNNOA_URL: ${{ secrets.LUNNOA_URL }}
LUNNOA_API_KEY: ${{ secrets.LUNNOA_API_KEY }}
- uses: peter-evans/create-pull-request@v7
with:
commit-message: "Pull Lunnoa agent and workflow definitions"
title: "Pull Lunnoa definitions"
body: "Brings UI edits into lunnoa/."
branch: chore/lunnoa-pull
add-paths: lunnoa
push:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx lunnoa-client push
env:
LUNNOA_URL: ${{ secrets.LUNNOA_URL }}
LUNNOA_API_KEY: ${{ secrets.LUNNOA_PUSH_API_KEY }}peter-evans/create-pull-request opens a pull request only when lunnoa/ changed. Merging that pull request pushes to main, which runs the push job. That push is what returns the badge to Synced with code.
Related
- CLI: discovery, TypeScript deploy, entity types
- Define locally:
defineAgentanddefineWorkflow - Agents: chat after the agent exists
- Authentication: API keys stay off the browser
- API reference: Public API operation list