anakin-ops
v0.9.4
Published
Anakin Ops CLI — single command for autonomous agents, lanes, database, and MCP tools.
Readme
@anakin/cli
Frontier developer platform CLI for Anakin. Dual-surface (Agent-first & Human TTY), built-in MCP server, real-time SSE streaming, remote sandbox bridge, and live counterpart lanes. Zero external dependencies (Node 18+).
___ __ _ _____ __ ____
/ _ | ___ ___ _/ /__(_)__ / ___// / / _/
/ __ |/ _ \/ _ `/ '_/ / _ \ / /__ / /___/ /
/_/ |_/_//_/\_,_/_/\_\_/_//_/ \___//_____/___/ Quick Start
cd packages/anakin-cli
npm run build
npm test
# 1. Inspect environment, OpenAPI spec (64 paths / 76 endpoints), and active profile
node dist/index.js doctor
# 2. Login & Profile Management
node dist/index.js login --key "ak_live_..." --profile default
node dist/index.js whoami
# 3. Sub-spec Search (token-AND search over the API contract, no LLM needed)
node dist/index.js search "lanes thread"
node dist/index.js search "files upload"
node dist/index.js search "database introspect"
# 4. Operate the whole company
node dist/index.js agent list --limit 5
node dist/index.js pages list <agentId>
node dist/index.js ledger ping <agentId>
node dist/index.js lanes send <agentId> <laneId> --message "hello"
node dist/index.js limits
# 5. Stream real-time agent turns in the terminal
node dist/index.js agent chat <agentId> --message "Audit quarterly revenue" --stream
# 6. Run Python in the remote sandbox
node dist/index.js sandbox eval "print(40 + 2)"
node dist/index.js sandbox run script.py --pull workspace/output.pdf --out ./output.pdf
# 7. Connect to the live lane terminal
node dist/index.js lanes live <agentId> <laneId>
# 8. Start the MCP server
node dist/index.js mcp
# 9. Multi-Shell Completion (bash, zsh, fish, powershell)
node dist/index.js completion bash >> ~/.bashrc
node dist/index.js completion powershell >> $PROFILEFrontier Architecture & Features
1. Dual-Surface Output
- Agent Mode (
--jsonor pipe/subshell): Emits pure, compact single-line JSON tostdoutwith structured machine-readable errors on failure. - Human TTY Mode (
stdout.isTTY): Automatically renders collection endpoints (agent list,lanes list,files list,database list) as crisp, bordered ASCII tables with ANSI-styled method tags.
2. Full-Company Operator Commands
- Agents:
list | get | chat | create | update | delete— the whole lifecycle from the terminal. - Tables & SQL:
tables list | get | rows | export,sql --query "...",query run | analyze | staging | saved— query workspace tables with automatic JSON column decoding or run arbitrary SQL. - Capabilities:
list | get | invoke | dry-run | test | stats | calls | propose— inspect, dry-run, test, and invoke agent capabilities. - Pages:
list | create | update | delete | submissions | audience— the owner publishing surface (auto-resolves primary agent when[agentId]is omitted). - Lanes:
list | create | send | note | thread | facts | files | digest | read | revoke | live— counterpart delivery (including email) plus the live terminal. - Ledger:
ping | stock | companies | invoices | chart | periods | warehouses | reconcile | ...— ERP reads across 12 views. - Inbox, Workflows & Skills:
inbox list,workflows list | run,skills list— inspect escalations, workflows, and agent skills. - Files:
list | read | details | upload | download | compile | export-pdf | save-artifact | signed-url— the workspace vault end to end. - Limits: plan caps, agent counts, and rate limits from live usage.
3. Native Model Context Protocol (MCP) Server (28 Tools)
Turn @anakin/cli into an MCP server for any modern AI IDE or agent (Claude Code, Cursor, Windsurf, Codex):
{
"mcpServers": {
"anakin": {
"command": "npx",
"args": ["-y", "anakin-ops", "mcp"]
}
}
}Exposes 28 workspace tools with automatic primary-agent resolution:
- Discovery & Runtime:
anakin_search,anakin_execute,anakin_usage_limits,anakin_sandbox_eval - Agents & Inbox:
anakin_agent_list,anakin_agent_get,anakin_agent_chat,anakin_inbox_list,anakin_workflows_list,anakin_skills_list - Workspace Tables & SQL:
anakin_tables_list,anakin_tables_rows,anakin_sql_query,anakin_saved_queries_list,anakin_db_list - Capabilities:
anakin_capabilities_list,anakin_capability_get,anakin_capability_invoke,anakin_capability_dry_run - Counterpart Lanes:
anakin_lanes_list,anakin_lanes_thread,anakin_lanes_send,anakin_lanes_note - Pages & ERP Ledger:
anakin_pages_list,anakin_pages_submissions,anakin_ledger_query - Files & Vault:
anakin_files_list,anakin_files_read
4. Remote Sandbox Execution Bridge
Run Python scripts and calculations inside isolated sandbox containers:
anakin sandbox eval "import pandas; print('ready')"anakin sandbox run analyze.py --pull /workspace/chart.png --out ./chart.png
5. Live Lane Counterpart Terminal
- Connects directly to the lane room over bi-directional WebSockets (
anakin lanes live <agentId> <laneId>). - Supports typewriter incoming streaming chunks, heartbeat ping/pong keepalive, and live interactive prompt input.
6. Real-Time SSE Token Streaming
anakin agent chat <id> --message "..." --stream reads Server-Sent Events natively over fetch streams:
- Human TTY: Streams tokens live to the console with typing cadence.
- Agent mode (
--stream --json): Emits structured NDJSON event objects ({ event: "token", data: "..." }).
7. Multi-Profile Credential Store
anakin login --key <key> [--profile <name>] [--base-url <url>]- Persists credentials securely to
~/.anakin/credentials.json(or%USERPROFILE%\.anakin\credentials.json) with restricted permissions (0600). - Priority cascade:
--api-keyflag $\rightarrow$ANAKIN_API_KEY$\rightarrow$anakin.config.json$\rightarrow$ Active User Profile.
8. Humane Safety Confirmation
Mutating or metered operations (capability invoke, lanes revoke, keys rotate) enforce safety:
- Interactive TTY: Prompts developer with
Warning: ... Proceed? [y/N]. - Non-TTY / Agent: Fails-closed immediately unless explicit
--forceflag is provided.
Test Suite & Invariants
npm run audit-deps # Asserts 0 external dependencies
npm test # Runs 34 unit tests across 14 suites via node:testTAP version 13
1..14
# tests 34
# suites 14
# pass 34
# fail 00.9.0 — Full 8-Sector Workspace Cockpit, Tables, SQL, Capabilities & 28 MCP Tools
- 8-Sector TUI Cockpit (
anakin top/anakin dashboard): Every row across all 8 workspace sectors (1 usage & telemetry,2 fleet agents,3 workspace tables,4 capabilities,5 counterpart lanes,6 pages & artifacts,7 ledger, queries & inbox,8 files & developer keys) is selectable and scrollable from line 0 to the final line (computeMainViewport+clampAnsiLineoverflow protection). - Interactive Inspectors & Inline Prompts: Press
Enteron any row to open its dedicated scrollable inspector (detailScrollwith↑/↓/PgUp/PgDn/g/G,Esc/Backspaceto return). Run inline prompts directly inside the TUI:c(live agent chat),x(custom SQL query),p(Python sandbox eval),i/d(capability invoke/dry-run),m/n(lane message/note),/(global filter). - Shared Workspace Engine (
src/workspace.ts): Automatic primary Copilot resolution (resolveDefaultAgentIdprioritizesgeneral/copilotagents over visitor subagents), automatic decoding of JSON-encodedworkspace_table_rows.datacolumns, and fleet-wide aggregation. - New CLI Command Groups:
tables list|get|rows|export,sql,query run|analyze|staging|saved,capability list|get|invoke|dry-run|test|stats|calls|propose,inbox list,workflows list|run,skills list, andfiles read|details. Optional[agentId]across all workspace commands. - 28 MCP Server Tools: Expanded
anakin mcpfrom 7 to 28 tools covering tables, SQL, capabilities, lanes, pages, ERP ledger views, inbox, workflows, skills, file content reading, and Python sandbox execution. - 34/34 unit tests across 14 suites (
computeMainViewport,clampAnsiLine,resolveDefaultAgentId,MCP_TOOLS,truncASCII width invariants).
0.8.0 — One scroll list + sticky header
- Cockpit is now a single unified scroll list: usage → keys → fleet → lanes → files. One cursor (
↑↓/j/k,PgUp/PgDn) travels all selectable rows (agents, then lanes); per-panel focus and hide/show are gone. tabjumps between fleet and lanes,1-5jumps the viewport to a section,Enteropens the row under the cursor. Footer shows scroll position (1-26/28).- Header is a sticky compact 3-row block (gradient ANAKIN wordmark + status, clock/latency, target/profile/identity) — the 5-row block art that clipped narrow terminals is retired from the header.
- No new tests (30/30 across 11 suites).
- New
src/art.ts: photo-derived ASCII art in 80x27 + 100x34, plain ramp.:-=+*#%@, dark-terminal mapping, zero-dep constants. - New
anakin art [--width 80|100]command (auto-picks by terminal width,--jsonsupported); shell completions updated. - Cockpit
Atoggles a fullscreen art view (ticks pause while viewing,Enter/Escbacks out); help/footer hints updated. - Art unit-tested (30 tests).
- Header drops the blue block for a big 5x40 ANAKIN block wordmark (royal-to-ice gradient,
#ASCII fallback, plain ANAKIN at level 0, single-column stack under 104 cols). - Lanes are fleet-wide now: prefetched across all agents in parallel, tagged per agent, sorted unread-first, filter matches counterpart + agent + id; footer/panel show fleet totals instead of selected-agent-only;
Enteropens the lane's own agent thread. anakinWord()unit-tested (29 tests).- Brand header: white-stick-on-royal-blue
logoMark()(5 rows, level-gated truecolor/256/16 + ASCII fallback) beside title block with target, profile, signed-in identity, and health. - Fixes your three findings: fleet conversation bars are brand-blue fixed (threshold red only for quota API/fleet-cap bars), files title shows
(count · MB)matching its body, usage numbers row no longer fights the identity (ownsigned in asline). - SOTA upgrades: fleet sort
S(activity/name/recent), API-pressure sparkline, display-width-aware truncation (CJK/emoji-safe), 72x20 minimum-size gate, SIGTERM/SIGHUP restore,Sin help/footer. bar()gainsfixedHexfor informational quantities;logoMark()+anakinWord()+ bundled art unit-tested (30 tests).- Numbered panels à la abtop:
¹usage(API window + fleet bars, latency sparkline),²keys(prefix + last-used rel times),³fleet(selectable, conversation bars),⁴lanes(selected agent's lanes, lazy per-agent fetch + cache),⁵files(recent + storage). tabswitches fleet/lanes focus,Enteropens agent detail or lane thread view,1–5toggle panels,ttoggles anakin/mono theme live.bar()+spark()join the theme engine (threshold colors, ASCII fallback) with unit tests.- New
src/theme.tsengine: capability detection per stream (levels 0–3),NO_COLOR/FORCE_COLOR/NO_UNICODEhonored,--color/--theme/--no-colorflags +ANAKIN_THEMEenv,anakin+monothemes. - Trademark system: bold white
▌section markers (Vercel-▲ style brand glyph), royal→ice gradient wordmark inhelp, glyph+word badges (never color alone), dim borders, bold content. - Downgrade ladder: truecolor ramp → 256/16-quantized solid → plain text; unicode → ASCII (
✔→√,▌→|); pipes stay byte-clean.doctorreportstheme/colorLevel/unicode.
0.2.1 — Clean ship (stale build artifacts removed)
0.2.0accidentally shipped deaddist/cf.js+dist/forge*.js(tsc never deletes stale output). Addednpm run cleanand madebuildclean-first so it can't recur.- No behavior change from 0.2.0.
0.2.0 — Pure Anakin: no cf, no forge, no outside names
- Removed command groups:
cf(edge-database bridge) andforge(contract/codegen). Removedforge:*npm scripts and theforgekeyword. - Scrubbed all user-facing outside names (sandbox/bridge/lane copy is now brand-neutral). Completions are fully static (no contract-registry I/O).
- Kept: everything else, including
searchover the bundled API contract and the MCP server.
0.1.11 — Full operator: agent CRUD, pages, lane sends, ledger, file builds, limits
agent create|update|delete,pages list|create|update|delete|submissions|audience,lanes send|note(counterpart delivery incl. email),ledger <12 views>,files compile|export-pdf|save-artifact,limits(plan caps + rates from usage).- Worker: gateway
/api/v2/*accepts PATs on the extended allowlist (lanes/ledger/pages reads, lane sends, page writes, file builds); destructive/credential ops stay JWT-only.adminPatScopes.test.tsextended (7 tests).
0.1.10 — anakin cf Cloudflare bridge
- New group
anakin cf d1 <tables|query|agent> [--db engine|cache] [--local|--remote]: runs CF D1 SQL through wrangler (repo-root aware, pinned[email protected],--jsonparsed into tables). No Anakin API key needed — uses wrangler auth (wrangler loginorCLOUDFLARE_API_TOKEN). - Reads free-form; remote writes require
--force. Agent ids validated before interpolation (no SQL injection from CLI args). cf d1 agent <id>returns the exact agent row (the D1 counterpart ofagent get).
0.1.9 — Probe-then-classify (future-proof for PAT-aware backend)
- Dashboard/smoke attempt all probes (cheap, time-boxed) and classify scope-denials (
browser session|Clerk JWT|Invalid JWT parts) with a PAT asskipped, everything else as failed. Against the current JWT-only backend: same cleanvia webdisplay. After the worker ships PAT reads: sections fill automatically, no CLI change needed. - Worker (
agent-worker, deploy separately):requireAdminAuthacceptsak_live_*PATs on an explicit allowlist — all GETs on data-connections/files/query/unified-tools (data:read), developer/keys (keys:manage), developer/webhooks (webhooks:manage), plus benign POSTs (connection test/introspect, files upload/signed-url, query run/analyze/python, webhook test). Destructive/credential-lifecycle ops stay JWT-only (403 with clear message).keys/webhooksrouter middleware consolidated ontorequireAdminAuth. NewadminPatScopes.test.ts(4 tests); JWT behavior byte-identical (existingauth.test.tsgreen).
0.1.8 — Scope-aware auth (no more phantom degradation)
- Root cause:
data-connections,files/*,developer/keys|webhooks,query/*,unified-tools/*are Clerk-JWT-only (requireAdminAuth);ak_live_*PATs can never pass them — v1 runtime (auth/agents/usage) is the PAT surface. Probing JWT-only routes with a PAT always 401s. client.ts:looksLikeJWT()/isJwtOnlyPath()/patScopeHint(); 401s on JWT-only paths with a PAT now explain scope + web-app path instead ofInvalid JWT parts length: 1.dashboard.ts: JWT-only probes skipped (not fetched) for PATs —skipped[]with reason,patModeflag, counts showweb, bands showvia web app (browser login). Same run: 0 errors, 5 skipped, ~2.3s (was 5 degraded).smoke.ts:database+storageprobesSKIP(notFAIL) for PATs.- Backend note (not in this package): make v2 PAT-aware via
patServicelike v1, or document JWT requirement. Direct CF D1 queries from the CLI are impossible (ENGINE_DB is a server binding;query/*is equally JWT-gated).
0.1.7 — Stable cockpit (no shake, one clock, whole platform)
- No shake: home-cursor redraw (
ESC[H+ clear-below, no full clear), change-gated renders (identical frames skipped), ticks paused while typing filter / in detail view, default interval 10s (was 3s). - One clock: header keeps the single refreshed-at time; footer
ok …duplicate removed (hints + transient status only). - Whole thing: cockpit now shows Metrics band (credits/runs/files + agents/db/keys/hooks counts), Agents (select + detail), Files (recent 3), DB (recent 3), Platform counts (keys/webhooks from live endpoints). New probes:
files/list,developer/keys,developer/webhooks(all degraded gracefully).
0.1.6 — Truly interactive cockpit (keyboard-first rethink)
anakin top/anakin dashboardare now interactive by default in a real terminal (alternate screen, hidden cursor).--oncefor single-shot scripts/CI;--json/pipes/CI auto-fallback to snapshot.- Keys (PowerShell/cmd/bash-safe via
keypressevents):↑/↓orj/kmove,/filter,Enteragent detail,rrefresh,spacepause/resume,oopen web app,ssettings,?help,q/Esc/Ctrl+Cquit. Live auto-refresh (--interval), resize redraw,⟳indicator. ONLINE = auth || fleet || usage— flakyauth/me(8s+ timeouts observed) no longer blanks the fleet whenagentsproves the key. Identity falls back to fleetuser_id. Metrics/databases showunavailableper-section instead of guest mode.
0.1.5 — Resilient cockpit (auth-first, partial degradation)
dashboard.ts: auth fetched first (8s cap), secondaries parallel (8s each).ONLINE = !!auth(latency no longer blanks auth). Per-sectionunavailablestates + namederrors[]({idx, endpoint, error}). Header shows2 section(s) degraded, TTY hints--jsonfor details. Fixes 12s OFFLINE when slow/failingdata-connections/files/usagehung the fullPromise.allSettled.- Known server-side:
/api/v2/data-connections+/api/v2/files/usagereturn401 Invalid JWT parts length: 1forak_live_*keys whileauth/agents/usagesucceed — CLI now degrades instead of going guest. (Resolved: workerrequireAdminAuthnow acceptsak_live_*PATs on the read allowlist —data-connections,files/*,developer/keys|webhooksGETs plus benign data-plane POSTs, same payloads scoped to the key owner; mutations stay JWT-only. Probes fill automatically, no CLI change needed.)
0.1.4 — SOTA identity (doctor/whoami parity)
credentials.ts: typedActiveCredential(email/createdAt/updatedAt), per-profile validation, atomic tmp+rename writes, profile-name validation,updatedAttracking,listProfiles().doctor: showskeySource(flag/env/config/profile), storedemail,profileUpdatedAt.whoami: self-heals stale/missing stored email when file was the key source (best-effort, no behavior change on failure).
0.1.3 — Hardening + Premium TUI
- SSE parser hoists event state, handles split chunks,
\r\n,[DONE], OpenAIchoices[0].deltatokens,onToken/onEventwired. apiRequest/apiStreamRequestshare 30s timeout (--timeout,ANAKIN_TIMEOUT_MS), attach.status/.dataon errors.loginverifies live; offline save requires--force; 401 never persists.files download --outis binary-safe + contained in cwd.- Forge: heuristics-first then exact overlays, sanitized group/action, unique MCP names (96/96), typed schemas,
mkdir -pcodegen. forge checkscans.all(), multiline/backticks, honest spec+code coverage.searchranked, single-char safe, cached. MCPisErrorinsideresult, protocol negotiate, arg validation.dashboardspawn-safe browser open, honest ONLINE, clamped watch interval, responsive cockpit.smoketime-boxed + SKIP-aware.taskRunnerword-boundary intents + injection-safe sandbox prompt.- Parser supports
-h/-v,--no-*,--k=false,--terminator. Version string unified toanakin v0.1.3.
