Himansh Raj

maya code: A Provider-Agnostic Coding Agent

· 3 min read

maya code: A Provider-Agnostic Coding Agent

maya code (mayac) is the coding agent inside Maya OS, and the thing I cared about most while building it was making the provider a detail, not a decision. It's a provider-agnostic coding-agent harness built fresh on the official Anthropic and OpenAI SDKs, with a full-screen Ink TUI. It ships on npm as @maya-os/code.

One interface, two providers

The whole design rests on a single contract: Provider.stream(req) → AsyncIterable<StreamEvent>. The Anthropic Messages API and the OpenAI Responses API both translate into the same internal ModelMessage and tool format. That has one very practical consequence:

  • Adding a third provider is a single new file — an adapter, a catalog entry, and an auth resolver.

Auth is auto-detected per provider, and it works with either an API key or a subscription:

  • AnthropicANTHROPIC_API_KEY, or a Claude Code OAuth login.
  • OpenAIOPENAI_API_KEY, or a ChatGPT/Codex login that targets the Codex backend.

So you can run it on the plan you already pay for, without pasting keys around.

The agent loop

Underneath the UI is a real streaming turn loop, not a single request/response:

  • Streaming tool-use turns — the model calls tools, results feed back, and it repeats until it ends its turn.
  • Context auto-compaction near the token limit so long sessions don't fall over.
  • Retry/backoff and token + cost accounting built in.
  • A tool set of read, write, edit (exact-string replace), bash, glob, grep, ls, each behind a permission gate — reads auto-allow, writes and bash are gated unless you pass --yolo.

The TUI is the part I obsessed over

A coding agent lives or dies by how it feels to use, so the full-screen Ink TUI got a lot of attention. A few pieces I'm happy with:

  • A managed scroll viewport — PageUp/PageDown, auto-stick to the bottom, and a ▼ N new below hint when you've scrolled up.
  • Collapsible tool calls — the latest call shows full detail, older ones collapse to a line; Ctrl+P/Ctrl+N focus one, arrows expand and collapse.
  • Mid-turn steering — the input stays live while the agent works. Type to queue the next message; Esc interrupts the running turn, aborting the stream and any running tool.
  • Autocomplete for slash commands, @-paths, and command history.
  • Background tasks/bg <cmd> runs a detached shell command, /tasks lists and kills them.
  • Sessions persist to ~/.maya-harness, so /resume (or --resume/--continue) reloads a past transcript.

It also has a dynamic /model picker fetched live from the provider's /v1/models, cached, with a built-in fallback list when you're offline.

What I took away from it

  • Design the internal format first. Once ModelMessage and the tool schema were fixed, both provider adapters became mechanical translations.
  • Make auth invisible. Auto-detecting API-key vs subscription per provider removed the single most annoying step of getting started.
  • TUI details compound. Scrollback, collapsible calls, and mid-turn queueing each seem small, but together they're the difference between a demo and something I actually want to code in.

If you want to look at the code, here it is: maya code on GitHub. Docs are at maya.himansh.in/docs.