Skip to content

The sona command-line tool

sona does on the command line what the SDK Studio does in its panes: search the item catalogue, make and edit avatars, check that a console will take them, make and check custom items, draw pictures and write 3D files. Every command prints plain text for people or, with --json, one JSON object for scripts and agents. Exit codes are the same for every command.

sona avatar random --seed 42 --catalogue sona-catalogue.bin -o me.txt
sona avatar dress me.txt "Blue full-zip hoodie" --catalogue \
    sona-catalogue.bin -o me.txt
sona avatar ready me.txt -o me.txt
sona render me.txt -o me.png --camera bust --size 256 --gate
sona export glb me.txt -o me.glb --gate

The tool comes with the tools installer. It links the core statically. The installed sona is the same for every developer, so it opens no licence of its own: set SONA_SDK (or --sdk) to the SDK made for your app (sona app download <platform> --unpack <folder>), and every command that opens the SDK runs in that download's bin/sona, with its licence and catalogue. For agents with no person present, see Unattended agents. render and item preview load Vulkan at run time, so every other command runs on a machine with no GPU or Vulkan loader at all. On Windows the binary also links d3d11.dll and dxgi.dll, which every Windows has, for the D3D11 device.

Avatars on the command line

An <avatar> argument is any of:

Form Example
a file of the 1000 raw manifest bytes me.bin
a file of base64 text me.txt
a JSON file: the manifest form (sona manifest unpack) or any object with "b64" (also "avatar": {"b64"}, so a command's --json output works) me.json
-, standard input, in any of the forms above sona avatar new | sona avatar show -
seed:<name>, a built-in starter: atlas (man), vega, juno, cutout (women) seed:vega
the base64 text itself AAAAAD9MzM0...

Commands that make or change an avatar print it as one line of base64, so they chain through pipes, or write it to -o <file>: .bin raw bytes, .json the manifest form, anything else base64 and a newline. The output file may be the input file.

Output

Without --json, results are text on stdout and notes (sona: wrote me.png ...) on stderr; --quiet drops the notes. With --json, stdout holds exactly one object:

{
  "ok": true,
  "command": "render",
  "exit": 0,
  "backend": "vulkan",
  "device": "Intel(R) Arc(tm) Graphics (MTL)",
  "camera": "bust",
  ...
}

ok, command and exit are always there; a failure adds error (what went wrong, in a sentence). That holds for errors in the arguments too (an unknown command or option, an option that does not apply, a bad value): command is then the command when it was recognised, else "". Help with --json (sona render --help --json, or no command at all) is the same object with the page as help. Notes the command makes on the way, such as the SDK's error log lines or "made a creator key", are a notes array of strings, present only when there are any. Nothing goes to stderr with --json unless --verbose is also given, which copies the error and the notes there as well. A command whose answer is a verdict (item check, avatar validate) keeps its own ok and fields. Item ids are lowercase dashed text; colours are #aarrggbb strings.

Exit status

Code Meaning
0 done
1 the command ran and the answer is no: invalid, refused, not console-ready, not in the catalogue, a picture or model written without worn items the sources lack
2 bad arguments (an unknown option, an option that does not apply to the command, a bad value)
3 a file could not be read or written; --gate with a server that gave no answer (it is asked once, at once, so the command never waits --timeout for it)
4 an input did not decode: a manifest, an item file, a PNG, JSON
5 not available here: no GPU device (the message names the packages: on Debian or Ubuntu apt-get install libvulkan1 mesa-vulkan-drivers, then --cpu where there is no GPU; Headless rendering and video)
6 the SDK refused: the licence (the message names the setting that mends it, usually SONA_SDK), the sources, an avatar that did not build in time
7 out of memory or a bug

Global options

Option What
--json one JSON object on stdout
-o, --out <file> where a command writes its file (- is stdout for pictures and models)
--dir <folder> an asset folder the avatar's items are read from (up to 4; default $SONA_DIR)
--sdk <folder> the SDK made for your app, unpacked (default $SONA_SDK): its bin/sona runs the command, with its sona-licence.json and data/sona-catalogue.bin
--gate, --gate-url <url> read items through the 360sona gate (needs your app's licence and the network). --dir sources make no network call; a gate source also sends the licence check to --server (default https://test.360sona.com, the library's config.check_host)
--server <url> the 360sona server (default $SONA_SERVER, then https://test.360sona.com): the app commands, and the licence check of --gate (https only in a release build)
--licence <file> sona-licence.json (default $SONA_LICENCE, then <sdk>/sona-licence.json, then ./sona-licence.json). A licence opens only in the sona of the same download: the installed tool takes it through --sdk. Testing builds fall back to the test licence
--app <id> the app id (default: the licence's)
--catalogue <file> sona-catalogue.bin (default $SONA_CATALOGUE, then <sdk>/data/sona-catalogue.bin)
--filter <list> a content filter: presets family, no-logos, no-licensed and rules files, comma-separated. catalogue search, avatar random and avatar dress-like leave out what it denies, render and export draw avatars through it; needs --catalogue
--timeout <s> how long an avatar may take to build (default 120)
--threads <n> the ctx's worker threads: 0 (default) works on the calling thread, -1 uses cores - 1
--backend vulkan|d3d11, --cpu the device for pictures; --cpu takes a software rasteriser (lavapipe, WARP)
--ctx-seed <n> the ctx's seed for idle choices (default 1, so runs repeat)
--quiet, --verbose fewer notes; the SDK's warnings too
-h, --help the overview, or a command's page (sona render --help, sona help render)

Every option takes its value as the next word or after = (--size=256). -- ends the options.

Commands

version

sona version prints the SDK version, the binary platform id and the ABI; JSON adds testing (a testing build, which accepts the test licence), made_for_app (the app this copy is stamped for; null for the installed tool) and sdk (the folder SONA_SDK names).

update

sona update [--server url] asks 360sona whether a newer SDK is out. When one is, it prints the new version, the changelog and the two steps: new tools from your app's page (or sona app tools <system>), then your SDK again with sona app download <platform> --force. JSON: current, latest, newer, system, notes, download. Other commands print a one-line reminder on stderr once a day when one is out, on a terminal only (never --json, --quiet, pipes, sona mcp, CI, or SONA_NO_UPDATE_CHECK=1). See versions.

catalogue

sona catalogue search [words...] [--section s] [--game g] [--body man|woman]
    [--slots mask]
                      [--require flags] [--exclude flags] [--all]
                          [--on-disk] [--offset n] [--limit n]
sona catalogue show <item id>
sona catalogue games
sona catalogue sections

search reads the offline catalogue. Every word must appear in the name, game or type; "in quotes" matches a whole name. By default it lists what the editor offers (offered, not hidden); --all lists everything. Flags for --require and --exclude are comma-separated: offered, named, stock, award, marketplace, hidden, notPickable, hasModel, glb, colourable, colourways, multiSlot. --on-disk keeps only items the --dir folders hold, the ones a render can draw. JSON: total (every match), offset, count, and items, each with id, name, section, body, game, type, family, description, mask, kind, route, flags, and colour_set and colourways where they apply. show prints one item (exit 1 when it is not in the catalogue), games the games with their item counts, sections the names --section takes.

avatar

sona avatar new [--body man|woman] [--from atlas|vega|juno|cutout] [-o file]
sona avatar random [--seed n] [--body man|woman] [--style s] [--palette p]
    [--game g] [--tag words]
                   [--set] [--props] [--plain] [--on-disk] [--no-costume]
                       [-o file]
sona avatar dress-like <avatar> <like> [--parts list] [--match
    same|similar|any] [--layer] [--on-disk] [-o file]
sona avatar show <avatar>
sona avatar validate <avatar> [--console] [--build]
sona avatar dress <avatar> <item>... [--colours c1,c2,c3] [--stack-props]
    [--no-required] [-o file]
sona avatar undress <avatar> [<slot or item id>...] [--all] [--no-required]
    [-o file]
sona avatar colour <avatar> <slot> <colour> [-o file]          (also: color)
sona avatar shape <avatar> [--weight w] [--height h] [-o file]
sona avatar body <avatar> man|woman [--no-dress] [-o file]
sona avatar ready <avatar> [-o file]
sona avatar filter <avatar> --filter <list> [-o file]
  • filter runs the avatar through --filter: denied clothes become the slot's default, denied face parts the first allowed stock part, anything else denied comes off. With --json, filter.changes lists each change: from and to (with from_name and to_name), action (replaced, hidden), section, reason (id, source, section, slot, game, tag, not-allowed) and tag.

filter

sona filter tags [--filter list]
sona filter check <item id>... --filter <list>

tags lists every tag with how many catalogue items carry it, and how many items the filter allows. check gives the verdict on items (allowed or denied, why, section, source, tags); exit 1 when one is denied.

  • new makes the editor's own new avatar: the atlas starter in the default shoes. --from starts from another starter as it is; --body woman changes the body and its clothes the way the editor does.
  • random is the core's sona_make_random (Making avatars in code): a whole avatar from the catalogue, seeded: hair, eyes, eyebrows, mouth, nose, chin, ears (facial hair on men at a chance of 35%), skin, hair and eye colours, a body shape, and an outfit with no clashes by the chances sona-bench --outfits random uses (a costume at a chance of 12%, else shirt, trousers and shoes, with a hat, glasses, gloves, a watch, earrings or a ring by chance). --style (any, casual, smart, sporty, costume) and --palette (natural, vivid, pastel, mono, fantasy) shape the look; --game and --tag keep the clothes to a franchise or to items holding the words; --set dresses it in one matched set, --props adds a prop sometimes, --plain leaves accessories out. The same seed, options and library give the same bytes, and a newer catalogue changes only the picks whose item left or was outscored. --on-disk draws only items the --dir folders hold. JSON random.picked lists each item drawn (section, id, name), with random.style, random.palette and random.set. The picks are rendezvous hashes, so a newer catalogue changes only the picks it must.
  • dress-like dresses <avatar> like <like> (sona_make_dress_like): --parts (clothes, props, hair, face, colours, shape or all; default clothes,props), --match (same, similar, any; default similar), --layer keeps its own clothes where nothing copied covers them. Each item made for the other body becomes its variant; JSON like.items says what each became (kept, variant, similar, substitute, dropped, covered) and like.counts counts them. Without --catalogue only items both bodies wear come across.
  • show prints the body, the two sliders, every worn item by slot (with its name when --catalogue is given), the face records, chin, nose and ears, the nine colours, and whether a console takes it as it is.
  • validate runs the checks and prints each: parse, valid (the manifest's own IsValid), body, clothed (shirt, trousers and shoes or a costume; reported, not required), console_ready (required with --console). --build also builds it through the sources: build fails when it does not get ready, custom_items when it wears custom ids no one registered, and items_found when a worn item is in no --dir folder (listed in missing_items). items_drawn reports worn items that were found but drew nothing because another item covers their slot (hair under a hat); it is information and never fails the avatar. Exit 1 when a required check fails. A file that is not a manifest gets a verdict too (parse fails).
  • dress wears items with the editor's rules: what each slot replaces, the props, the required clothes. An item is an id, or with --catalogue an item's exact name (the match the editor offers this body first). --colours sets the item's three colours. A shape or anything else that cannot be worn: exit 1.
  • undress takes off what a slot holds (shirt, trousers, shoes, hat, gloves, glasses, wristwear, earrings, ring, prop, costume, hair, the face parts, or a mask such as 0x40) or one item by id; --all takes off everything but the hair. The required clothes refill unless --no-required.
  • colour sets one of skin, hair, mouth, eyes, eyebrows, eyeShadow, facialHair, facialFeature, facialFeature2 (any case, dashes allowed) to #rgb, #rrggbb or #aarrggbb.
  • shape sets the weight and height sliders, -1 to 1; beyond that is stored and saturates when drawn (JSON saturates).
  • body changes the body: the four required slots get that body's defaults and anything made for the other body comes off (--no-dress skips the defaults).
  • ready makes the avatar console-ready (sona_manifest_ready_for_xbox): one prop, the required clothes, the body's defaults for awards in the required cache. It writes the result either way; exit 1 when it still is not ready, which only a custom item causes (no console has those).

outfit

sona outfit check <avatar>
sona outfit fix <avatar> [-o file]
sona outfit sets [words] [--game g] [--body man|woman] [--offset n] [--limit
    n]
sona outfit set <index or item id> [--body man|woman]
sona outfit clash <item> <item>

The outfit rules of Making avatars in code. check lists every issue of an avatar (clash, wrong_body, duplicate, wrong_place, missing, bad_shape, too_many_props as errors; shape_range, stale_cache, bad_mask, unknown as warnings; props, not_offered, custom as infos), errors first, with the field and the items; exit 1 when there is an error. Without --catalogue the catalogue's checks are left out. fix mends every error with the editor's rules and prints the avatar (JSON check is the check after, with errors_before). sets lists the catalogue's matched sets (index, name, items, bodies, game), set one set and its items, clash whether two items go together and why not (a slot in common, or no body that wears both).

render

sona render <avatar> -o file.png [--camera full|upper|bust|face] [--size
    WxH] [--clip key] [--time s]
            [--yaw deg] [--pitch deg] [--background colour] [--shadow]
                [--no-credit] [--allow-missing]

Draws the avatar on a headless GPU device with sona_snapshot and writes a PNG, transparent unless --background is given (the background is laid under the straight-alpha picture, so it comes out exactly as given). The camera is one of the console's framings (sona_camera_preset), turned by --yaw and --pitch about its target. Any size up to 8192 x 8192; one number is square; default 512 x 512. The clip is a key from sona clips, idle or still (default), held at --time seconds. The badge is drawn in the bottom-right corner and the PNG carries the credit's three tEXt chunks, as sona_png_encode writes them; the pixels are deflated. --no-credit leaves the badge out of the pixels; the licence still requires the credit wherever the picture is shown. JSON: backend, device, camera, clip, time, width, height, bytes, opaque_pixels, clear_pixels, file, complete, missing_items. Needs --dir or --gate. When a worn item is in no --dir folder the picture is still written, but complete is false, missing_items lists them and the exit is 1; --allow-missing accepts it (exit 0, with a note). export does the same.

clips

sona clips lists the clip keys (with their captions) that render --clip and export --clip take.

export

sona export glb <avatar> -o file.glb [--clip key] [--time s]
sona export glb <avatar> -o file.glb --rigged [--clips k,...] [--bones
    unity|vrm|vrm0|ue4|ue5]
sona export fbx <avatar> -o file.fbx [--clips k,...] [--bones ...]
sona export roblox <avatar> -o file.fbx

glb writes a glTF 2.0 binary of the avatar as posed (still by default) from the data API: every part it draws, skinned on the CPU (sona_pose_vertices), in metres, +Y up, facing +Z. The avatar space is left-handed, so z is negated and every triangle's winding reversed (the editor's export does the same). Each part's albedo is baked into one PNG sheet: the shader's chain, colour times the intensity texture's alpha plus its colour, then the decal for non-reflective parts, in linear light, and for reflective parts the matcap times the reflectivity as a camera in front sees it (a lens keeps the colour its reflection gives it), with the baked edges grown 4 texels so filtering at a seam reads baked colour. The sheet is in the part's uv0 space, unless uv0 cannot hold it: when uv0 is one flat colour with the pattern in uv1 (leggings whose print is all in the intensity texture), or tiles so its texels overlap (a cap's fabric under one logo), the part is baked into the uv1 or uv2 layout that covers the surface once, at up to 1024 texels a side so the colour texture keeps its detail, and that layout becomes the mesh's TEXCOORD_0. Each texture names the sampler of the set it was baked in (repeat or clamp, as the part's textures are addressed). Vertex colours (the baked occlusion) are COLOR_0; transparent parts are BLEND at 1 - transparency, parts with cut-out alpha MASK at 0.5. The asset's extras carry the credit. Without --rigged it has no rig and no clips; --rigged, fbx and roblox are the rigged exports (below, "Rigged exports"). JSON: meshes, vertices, triangles, materials, textures, bytes.

manifest

sona manifest unpack <avatar> [-o form.json]
sona manifest pack <form.json> [-o file]

The manifest form is every field of sona_manifest as JSON: version, weight, height, chin, nose, ears, six face records (part, id, words), the nine colours by name, figure (the body), head, thirteen worn and four required references (id, mask, pad, colours), and blob5, pad_xuid, xuid, padding as hex. Non-finite sliders are kept as weight_bits and height_bits. Packing a form gives back the very bytes it was unpacked from, and any field can be edited in between; a field left out is zero, and a reference may be just an id string.

item

sona item templates
sona item new <dir> --template <id or name> --name <text> [--body
    man|woman|both] [--pair]
              [--description t] [--creator t] [--licence t] [--layout
                  split|template] [--sha256 hex] [--force]
sona item id --template <id or name> [--body man|woman|both]
sona item check <file.sonaitem> [--deep]
sona item pack <dir> [-o file] [--no-sign] [--key file] [--dry-run]
sona item unpack <file.sonaitem> <dir> [--force]
sona item preview <item id or file.sonaitem> -o file.png [--size WxH]
    [--body man|woman] [--background c]

The custom items guide walks through them.

  • templates lists the 28 templates (id, body, slot, colour size, default layout).
  • new writes a source folder (here --licence <text> is the item's licence, written to item.json, not the SDK licence file the global option names; item new opens no SDK context): item.json as node writes it (a fresh custom id, today's date, the template's id and SHA-256 from the built-in table, so no asset folder is needed) and blank.png, a white sheet of the template's size in its layout (twice as wide for split) to paint color.png from. --pair also writes the other body's folder (<dir>-man or <dir>-woman) with the paired id. The guide kit (sona-item kit) stays in the node tool.
  • id prints a fresh custom id for a template.
  • check gives the loader's verdict, rules 1 to 11 (sona_item_parse, the same checker the core loads with). JSON has node's shape: ok, rule, why, code (corrupt, limit, unsupported), info (id, slot, mask, body, name, creator, version, sha256, template, surfaces, colourways, signed, bytes, warnings), warnings, and buildable. --deep reads the template through the sources too: a hash that does not match is a warning, rule 12 (the surface count, a decal on a reflective surface) fails it, and colour sheets smaller than the template's are warned about. Exit 1 when refused or not buildable.
  • pack turns a folder into a .sonaitem: the canonical JSON chunk (known keys in order, unknown keys kept and sorted), each PNG encoded (colour BC1 on white, regions and decals BC3), a PNG over 512 halved to fit, and an untouched unpacked PNG's own texture record reused. The version rises when the content changed since the last pack (.sonaitem-pack.json in the folder). The file is signed with your creator key: --key, else $SONA_CREATOR_KEY, else ~/.sona/creator.key, made on first use. The key file is an ed25519 PKCS#8 PEM; ed25519 is deterministic, so the same folder and key always give the same bytes.
  • unpack writes the folder form back: item.json naming color.png, regions.png, decal.png (-2, -3 for more surfaces), each PNG carrying its texture record in a soBC chunk, so packing it untouched gives the same blocks.
  • preview draws one item worn alone on the grey stand-in body (sona_item_preview_snapshot), framed by its slot. A .sonaitem file is registered first (sona_custom_item_add) and previewed by its id; its template must be in the sources.

The Studio's other verbs

app, console, project, scene, docs, mcp and item mesh, so the CLI does everything SDK Studio does: The CLI and SDK Studio.

For scripts and agents

The MCP server and the CLI share one internal library, sona_tool. It is not part of the SDK's public API. Each operation writes the same JSON object the CLI prints into a cJSON and returns an exit code; a session keeps the ctx, the catalogue and the GPU device open, so a long-lived server opens them once:

Area Functions
session sona_tool_open, _close, _message, _fail, _ctx, _catalogue, _wait_ready, _renderer; sona_tool_options.note takes the notes and SDK log lines (stderr when NULL), one call at a time
avatars sona_tool_avatar_read, _write, _new, _random, _dress, _undress, _colour, _shape, _body, _make_ready, _show, _validate; sona_tool_seed_count, _seed_name, _seed_b64
manifest form sona_tool_manifest_form, sona_tool_manifest_from_form
catalogue sona_tool_catalogue_search, _catalogue_show, _catalogue_games, sona_tool_item_json, sona_tool_item_on_disk
pictures, models sona_tool_render_avatar, sona_tool_render_item, sona_tool_export_glb
custom items sona_tool_item_check, _item_pack, _item_unpack, _item_new, _item_id, _item_templates
names sona_tool_colour_slot, _colour_slot_name, sona_tool_slot_mask, sona_tool_body, sona_tool_parse_colour, sona_tool_section, sona_tool_flag
the whole CLI sona_cli_run(argc, argv, out, err): any command in process, output in buffers

Third-party code

The CLI, not the core, uses three small libraries, fetched by CMake as pinned files checked against their SHA-256: stb_image and stb_image_write 2.30 / 1.16 (MIT or public domain) for PNG in and out, cJSON 1.7.18 (MIT) for JSON, and Monocypher 4.0.2's ed25519 (BSD-2-Clause or CC0) for creator signatures. With no network and no copy in SONA_CLI_DEPS, configure skips the CLI with a warning and builds everything else.

Rigged exports

export glb --rigged, export fbx and export roblox use the core's export (sona_export_avatar, FBX, Roblox and clips): the avatar on its skeleton in the T-pose with its body shape, bones named by --bones (unity, vrm, vrm0, ue4, ue5; default unity). --clips wave,clap,... puts those clips on the skeleton as animations (glb and fbx): the first plays on the avatar, the others on layers at weight 0, so all of them load; stock library names and clip keys both work. roblox is an FBX for Roblox Studio's avatar import: R15 part names (LowerTorso, UpperTorso, LeftUpperArm ...) under HumanoidRootPart, no props, no clips, and hair, hats, glasses, earrings, wristwear and rings left off (export those as accessories). With --json the answer adds rigged, clips and clip_keys.

sona export glb seed:vega --rigged --clips wave,walk_forward -o vega.glb \
    --gate
sona export fbx seed:vega --clips wave -o vega.fbx --gate
sona export roblox seed:vega -o vega-roblox.fbx --gate

Blender 4.5 imports all three: 9 skinned meshes on 71 bones with both actions, and 6 meshes on 72 bones with the R15 names for Roblox.

Limits

  • export glb (not --rigged) is the posed figure with no rig. Where two surfaces of one part share texels in every uv set (mirrored halves with different prints), the bake keeps the last one drawn; the editor's export makes a chart atlas there.
  • render draws one picture per call; video, turntables and sprite sheets are library calls (Headless rendering and video, 2D outputs), not commands.
  • The D3D11 device path (Windows without Vulkan) is written but has not been run.

This page as Markdown · All the docs as one file (llms-full.txt)