@mu-agent/mu 0.0.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +212 -73
- package/dist/index.js +207 -121
- package/dist/mu.js +395 -297
- package/dist/types/ai/catalog.d.ts +0 -1
- package/dist/types/ai/providers/openai.d.ts +2 -0
- package/dist/types/ai/types.d.ts +47 -2
- package/dist/types/core/commands.d.ts +1 -0
- package/dist/types/core/compaction.d.ts +9 -2
- package/dist/types/core/events.d.ts +8 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/loop.d.ts +2 -1
- package/dist/types/core/messages.d.ts +4 -1
- package/dist/types/core/microcompaction.d.ts +3 -0
- package/dist/types/core/profile.d.ts +10 -2
- package/dist/types/core/session.d.ts +5 -0
- package/dist/types/core/tools.d.ts +4 -2
- package/dist/types/profile-coding/prompts.d.ts +3 -0
- package/dist/types/sdk/agent.d.ts +27 -3
- package/dist/types/sdk/commands.d.ts +7 -2
- package/dist/types/sdk/file-store.d.ts +1 -0
- package/dist/types/sdk/index.d.ts +7 -3
- package/dist/types/sdk/recall.d.ts +3 -0
- package/dist/types/sdk/side.d.ts +12 -0
- package/dist/types/sdk/subagents.d.ts +46 -0
- package/dist/types/sdk/tool.d.ts +1 -1
- package/dist/types/sdk/web-search.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,93 +1,125 @@
|
|
|
1
1
|
# @mu-agent/mu
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
3
|
+
The CLI and TypeScript SDK distribution of [Mu](https://github.com/Spandan7724/mu), an
|
|
4
|
+
extensible AI agent with a built-in coding profile.
|
|
5
|
+
|
|
6
|
+
The package provides:
|
|
7
|
+
|
|
8
|
+
- the `mu` interactive terminal application;
|
|
9
|
+
- headless and NDJSON RPC modes;
|
|
10
|
+
- the public `Agent` and `createAgent` TypeScript APIs;
|
|
11
|
+
- the coding profile, TUI, extensions, MCP support, and a platform-specific ripgrep
|
|
12
|
+
sidecar.
|
|
13
|
+
|
|
14
|
+
This package requires Bun 1.3 or later at runtime.
|
|
15
|
+
|
|
16
|
+
## Install the CLI
|
|
5
17
|
|
|
6
18
|
```sh
|
|
7
|
-
# npm (requires Bun)
|
|
8
19
|
npm install -g @mu-agent/mu
|
|
9
|
-
|
|
10
|
-
# Bun
|
|
20
|
+
# or
|
|
11
21
|
bun install -g @mu-agent/mu
|
|
22
|
+
|
|
12
23
|
mu
|
|
13
24
|
```
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
Run `/login` to configure a provider account or API key, then `/model` to select a model.
|
|
27
|
+
Environment variables such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and `GEMINI_API_KEY`
|
|
28
|
+
also work.
|
|
16
29
|
|
|
17
30
|
```sh
|
|
18
|
-
mu
|
|
31
|
+
mu # interactive TUI
|
|
32
|
+
mu -p "fix the failing test" # one-shot result
|
|
33
|
+
mu -p "review this patch" --json # JSON event stream
|
|
34
|
+
mu --resume <session-id> # resume a session
|
|
35
|
+
mu --rpc # NDJSON operations in, events out
|
|
36
|
+
mu agents # manage several sessions
|
|
19
37
|
```
|
|
20
38
|
|
|
21
|
-
|
|
39
|
+
Run `mu --help` for all flags. Global npm and Bun installs can update or remove themselves:
|
|
22
40
|
|
|
23
41
|
```sh
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
import { Agent, createAgent } from "@mu-agent/mu";
|
|
30
|
-
|
|
31
|
-
// A domain-neutral agent with a general prompt and no tools.
|
|
32
|
-
const assistant = new Agent();
|
|
33
|
-
console.log((await assistant.run("Explain how an AI agent loop works")).text);
|
|
34
|
-
|
|
35
|
-
// Mu's built-in coding profile: file, search, shell, task, and checkpoint tools.
|
|
36
|
-
const codingAgent = await createAgent({
|
|
37
|
-
profile: "coding",
|
|
38
|
-
profileOptions: { root: process.cwd() },
|
|
39
|
-
});
|
|
40
|
-
console.log((await codingAgent.run("Summarize this directory")).text);
|
|
41
|
-
await codingAgent.shutdown();
|
|
42
|
+
mu self update
|
|
43
|
+
mu self uninstall
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
46
|
+
Native, runtime-free installers and release archives are documented in the
|
|
47
|
+
[project README](https://github.com/Spandan7724/mu#install).
|
|
48
|
+
|
|
49
|
+
## Coding agent
|
|
50
|
+
|
|
51
|
+
The CLI loads the coding profile by default. It includes:
|
|
52
|
+
|
|
53
|
+
- `read`, `ls`, `edit`, and `write` file tools;
|
|
54
|
+
- foreground and PTY-backed background shell commands;
|
|
55
|
+
- repository search with `rg` and `rg --files`;
|
|
56
|
+
- read-before-write checks and diff previews for approvals;
|
|
57
|
+
- shadow-git workspace checkpoints with `/undo`, `/redo`, `/fork`, and `/diff`;
|
|
58
|
+
- durable sessions, automatic context compaction, and Markdown transcript export;
|
|
59
|
+
- managed `task` delegation and coding-specific `search`, `counsel`, and `recall` subagents.
|
|
60
|
+
|
|
61
|
+
Explicitly ask **“Ask Recall why we rejected SQLite”** to investigate retained project
|
|
62
|
+
sessions, including compacted history and alternate branches. Recall has only read-only
|
|
63
|
+
history tools, no workspace or network tools, and cites session/entry references. It uses
|
|
64
|
+
Search's same-provider model routing with the current model as fallback. Explicit-only
|
|
65
|
+
invocation is a parent-model instruction, not a classifier or runtime authorization gate.
|
|
66
|
+
Separate project directories, including other clones/worktrees, are not automatically joined.
|
|
67
|
+
|
|
68
|
+
The default permission mode allows inspection and asks before file changes or commands.
|
|
69
|
+
Use `/permissions` or `--permission-mode` to choose `default`, `accept-edits`,
|
|
70
|
+
`plan-readonly`, or `yolo`. These are permission rules, not an OS sandbox.
|
|
71
|
+
|
|
72
|
+
CLI sessions are scoped to the current project and stored under `~/.mu/sessions`.
|
|
73
|
+
Checkpoints are stored under `~/.mu/checkpoints` and do not add commits or refs to the
|
|
74
|
+
user's repository.
|
|
75
|
+
|
|
76
|
+
### Interactive commands
|
|
77
|
+
|
|
78
|
+
| Command | Purpose |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `/login`, `/logout` | Add or remove credentials stored by Mu |
|
|
81
|
+
| `/model` | Select the active model |
|
|
82
|
+
| `/permissions` | Change the current permission mode |
|
|
83
|
+
| `/resume`, `/new`, `/rename` | Open, create, or name conversations |
|
|
84
|
+
| `/compact [focus]` | Compact the active model context |
|
|
85
|
+
| `/undo`, `/redo`, `/fork`, `/diff` | Navigate the session and workspace history |
|
|
86
|
+
| `/export [path.md]` | Export the complete active branch |
|
|
87
|
+
| `/btw [question]` | Open an ephemeral read-only side conversation |
|
|
88
|
+
| `/instructions [reload]`, `/reload` | Inspect or reload repository instructions |
|
|
89
|
+
| `/subagents` | List subagents, their roles, and how to invoke them |
|
|
90
|
+
| `/cost` | Show session token and cost totals |
|
|
91
|
+
| `/keybindings` | Show Mu-specific keyboard controls |
|
|
92
|
+
|
|
93
|
+
During a run, Enter steers the current turn and Tab queues a follow-up. `Ctrl+O` opens
|
|
94
|
+
transcript review, `Alt+T` collapses expanded tool activity, `Shift+Tab` cycles permission
|
|
95
|
+
modes, and a leading `!` runs a command directly without a model call. Direct shell commands
|
|
96
|
+
are still recorded as session context.
|
|
97
|
+
|
|
98
|
+
## Providers
|
|
99
|
+
|
|
100
|
+
Account sign-in is available for OpenAI Codex/ChatGPT, GitHub Copilot, Kimi Code,
|
|
101
|
+
OpenRouter, and xAI. API-key routes include Anthropic, OpenAI, Google, Z.AI Coding Plan,
|
|
102
|
+
Qwen Token Plan, and providers supported by Mu's shared OpenAI-compatible and
|
|
103
|
+
Gemini-compatible transports. Anthropic subscription OAuth is not supported.
|
|
104
|
+
|
|
105
|
+
OpenAI API-key models use the `openai/*` namespace. ChatGPT-plan models use
|
|
106
|
+
`openai-codex/*`; the credentials are separate and may coexist. Both routes receive
|
|
107
|
+
provider-hosted web search automatically. Other providers currently run without web
|
|
108
|
+
search.
|
|
109
|
+
|
|
110
|
+
A local `llama-server` is discovered at `http://127.0.0.1:8000` and exposed as
|
|
111
|
+
`llama-cpp/<alias>`. Set `LLAMA_CPP_BASE_URL` or `LLAMA_CPP_API_KEY` when needed.
|
|
112
|
+
|
|
113
|
+
## Project instructions and extensions
|
|
114
|
+
|
|
115
|
+
The coding profile loads instructions from `~/.mu/AGENTS.md` and the active project,
|
|
116
|
+
stopping at its configured root marker (`.git` by default). It supports
|
|
117
|
+
`AGENTS.override.md`, `AGENTS.md`, configured fallback names such as `CLAUDE.md`,
|
|
118
|
+
`.mu/rules/`, `.claude/rules/`, conditional `paths` frontmatter, and scoped `@file`
|
|
119
|
+
imports.
|
|
120
|
+
|
|
121
|
+
Instruction settings can be placed in `~/.mu/config.json` or `.mu/config.json`. Project
|
|
122
|
+
values override user values.
|
|
91
123
|
|
|
92
124
|
```json
|
|
93
125
|
{
|
|
@@ -100,3 +132,110 @@ override user values:
|
|
|
100
132
|
}
|
|
101
133
|
}
|
|
102
134
|
```
|
|
135
|
+
|
|
136
|
+
The CLI also discovers:
|
|
137
|
+
|
|
138
|
+
- TypeScript extensions in `~/.mu/extensions` and `.mu/extensions`;
|
|
139
|
+
- Markdown slash commands in `~/.mu/commands` and `.mu/commands`;
|
|
140
|
+
- skills in `~/.mu/skills` and `.mu/skills`;
|
|
141
|
+
- MCP servers from user and project `.mu/config.json`.
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"mcpServers": {
|
|
146
|
+
"docs": {
|
|
147
|
+
"command": "bunx",
|
|
148
|
+
"args": ["-y", "your-mcp-server"],
|
|
149
|
+
"env": { "SERVER_TOKEN": "..." }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
MCP tools are named `mcp_<server>_<tool>` and use the same permission, event, and abort
|
|
156
|
+
paths as local tools.
|
|
157
|
+
|
|
158
|
+
## TypeScript SDK
|
|
159
|
+
|
|
160
|
+
Install the package in a Bun project:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
bun add @mu-agent/mu
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Low-level agent
|
|
167
|
+
|
|
168
|
+
`new Agent()` is domain-neutral. It uses an in-memory session store and has no tools or
|
|
169
|
+
extensions unless they are supplied by the caller.
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import { Agent } from "@mu-agent/mu";
|
|
173
|
+
|
|
174
|
+
const agent = new Agent({
|
|
175
|
+
model: "anthropic/claude-sonnet-5",
|
|
176
|
+
budget: { maxTurns: 8, maxCostUsd: 1 },
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const result = await agent.run("Summarize the design trade-offs");
|
|
180
|
+
console.log(result.text);
|
|
181
|
+
console.log(result.reason, result.usage);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Coding agent
|
|
185
|
+
|
|
186
|
+
`createAgent()` adds managed `task` delegation. With `profile: "coding"`, it also loads
|
|
187
|
+
the shipped coding tools, project instructions, permissions, checkpoints, background
|
|
188
|
+
runtime, and `search`/`counsel`/`recall` specialists. Recall can access only history in the
|
|
189
|
+
configured session store; SDK agents use an in-memory store by default.
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import { createAgent } from "@mu-agent/mu";
|
|
193
|
+
|
|
194
|
+
const agent = await createAgent({
|
|
195
|
+
profile: "coding",
|
|
196
|
+
profileOptions: { root: process.cwd() },
|
|
197
|
+
budget: { maxCostUsd: 2 },
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const result = await agent.run("Find and fix the failing test");
|
|
201
|
+
console.log(result.text);
|
|
202
|
+
await agent.shutdown();
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Custom tools
|
|
206
|
+
|
|
207
|
+
Tools use Zod schemas. Arguments are validated before `execute`, and the schema is
|
|
208
|
+
converted to JSON Schema for providers.
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { Agent, tool } from "@mu-agent/mu";
|
|
212
|
+
import { z } from "zod";
|
|
213
|
+
|
|
214
|
+
const add = tool({
|
|
215
|
+
name: "add",
|
|
216
|
+
description: "Add two numbers",
|
|
217
|
+
inputSchema: z.object({ a: z.number(), b: z.number() }),
|
|
218
|
+
execute: ({ a, b }) => String(a + b),
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const agent = new Agent({ tools: [add] });
|
|
222
|
+
const result = await agent.run("What is 17 + 25?");
|
|
223
|
+
console.log(result.text);
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
`Agent` also supports:
|
|
227
|
+
|
|
228
|
+
- `stream()` for the same serializable event stream used by the TUI and RPC;
|
|
229
|
+
- Zod-validated structured output through `run(prompt, { output: schema })`;
|
|
230
|
+
- permission callbacks and layered permission rules;
|
|
231
|
+
- model, turn, token, and cost budgets;
|
|
232
|
+
- custom providers and models;
|
|
233
|
+
- `MemorySessionStore`, `FileSessionStore`, and caller-defined session stores;
|
|
234
|
+
- extensions, shell hooks, skills, MCP, child agents, and transcript serialization.
|
|
235
|
+
|
|
236
|
+
See the [project README](https://github.com/Spandan7724/mu#typescript-sdk) and
|
|
237
|
+
[source](https://github.com/Spandan7724/mu) for the complete project overview.
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT
|