@minasoft/mina-ai-router 0.1.0
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 +53 -0
- package/dist/apps/cli/src/index.js +574 -0
- package/dist/apps/http-server/src/index.js +755 -0
- package/dist/apps/mcp-server/src/index.js +308 -0
- package/dist/packages/core/src/file-state.js +35 -0
- package/dist/packages/core/src/ids.js +8 -0
- package/dist/packages/core/src/index.js +24 -0
- package/dist/packages/core/src/prompt-envelope.js +27 -0
- package/dist/packages/core/src/registry.js +34 -0
- package/dist/packages/core/src/request-store.js +50 -0
- package/dist/packages/core/src/response-parser.js +33 -0
- package/dist/packages/core/src/router.js +100 -0
- package/dist/packages/core/src/types.js +2 -0
- package/dist/packages/mcp/src/provider.js +177 -0
- package/dist/packages/transports/src/headless/headless-transport.js +31 -0
- package/dist/packages/transports/src/index.js +22 -0
- package/dist/packages/transports/src/tmux/tmux-client.js +126 -0
- package/dist/packages/transports/src/tmux/tmux-transport.js +54 -0
- package/dist/packages/transports/src/transport-registry.js +20 -0
- package/dist/packages/transports/src/zmux/zmux-client.js +18 -0
- package/dist/packages/transports/src/zmux/zmux-transport.js +36 -0
- package/docs/DEVELOPER-START-GUIDE.md +111 -0
- package/docs/GETTING-STARTED.md +32 -0
- package/docs/HTTP-UI-MCP.md +142 -0
- package/docs/MCP-CLIENT-SETUP.md +71 -0
- package/docs/SKILL-INSTALL-GUIDE.md +96 -0
- package/docs/TROUBLESHOOTING.md +75 -0
- package/docs/USER-START-GUIDE.md +187 -0
- package/docs/assets/mair-agent-details.jpg +0 -0
- package/docs/assets/mair-live-flow.jpg +0 -0
- package/docs/assets/mair-terminal-preview.jpg +0 -0
- package/package.json +47 -0
- package/skills/mina-ai-router-agent/SKILL.md +64 -0
- package/skills/mina-ai-router-agent/agents/openai.yaml +4 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# HTTP UI and MCP Server
|
|
2
|
+
|
|
3
|
+
Mina AI Router now runs as a local HTTP server.
|
|
4
|
+
|
|
5
|
+
It serves both:
|
|
6
|
+
|
|
7
|
+
- management UI: `http://127.0.0.1:3333/`
|
|
8
|
+
- streamable HTTP MCP endpoint: `http://127.0.0.1:3333/mcp`
|
|
9
|
+
|
|
10
|
+
## MCP Tools
|
|
11
|
+
|
|
12
|
+
The HTTP MCP endpoint exposes:
|
|
13
|
+
|
|
14
|
+
- `list_agents`
|
|
15
|
+
- `register_agent`
|
|
16
|
+
- `call_agent`
|
|
17
|
+
- `get_request_status`
|
|
18
|
+
|
|
19
|
+
## Start
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
cd mina-ai-router
|
|
23
|
+
npm run build
|
|
24
|
+
node dist/apps/cli/src/index.js server start --port 3333
|
|
25
|
+
node dist/apps/cli/src/index.js server status
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or, after `npm link`:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
mair server start --port 3333
|
|
32
|
+
mair server status
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Stop:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
mair server stop
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Connect Codex CLI
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
codex mcp remove mina-ai-router
|
|
45
|
+
codex mcp add mina-ai-router --url http://127.0.0.1:3333/mcp
|
|
46
|
+
codex mcp get mina-ai-router
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Expected transport:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
transport: streamable_http
|
|
53
|
+
url: http://127.0.0.1:3333/mcp
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Use the UI
|
|
57
|
+
|
|
58
|
+
Open:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
http://127.0.0.1:3333/
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The page shows:
|
|
65
|
+
|
|
66
|
+
- a router-centered agent flow diagram
|
|
67
|
+
- registered agents as clickable nodes around the router
|
|
68
|
+
- each agent's short capability notice on the node
|
|
69
|
+
- agent status, project root, capability details, and tmux metadata in a modal
|
|
70
|
+
- per-agent request history in a modal opened from the agent context menu
|
|
71
|
+
- agent controls in the context menu: details, history, ask, attach commands, copy attach command, restart session, delete agent
|
|
72
|
+
- right-click flow background menu for creating a tmux-backed Codex or Claude agent from a project directory
|
|
73
|
+
- a `Connect Agent` guide instead of manual UI registration
|
|
74
|
+
- hidden `Developer Tools` for diagnostics such as the two-Codex demo and stale request cleanup
|
|
75
|
+
|
|
76
|
+
## Health
|
|
77
|
+
|
|
78
|
+
The server exposes a local health endpoint:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
http://127.0.0.1:3333/api/health
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The CLI exposes the same operator view:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
mair health
|
|
88
|
+
mair version
|
|
89
|
+
mair verify
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Visible Agent Commands
|
|
93
|
+
|
|
94
|
+
Start a visible Codex agent in the current directory:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
mair codex
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This derives the agent id and tmux session from the current directory. For example, from `/Users/stevenna/WebstormProjects/minasoftai`, it uses:
|
|
101
|
+
|
|
102
|
+
- agent id: `minasoftai`
|
|
103
|
+
- tmux session: `codex-minasoftai`
|
|
104
|
+
- project root: current directory
|
|
105
|
+
|
|
106
|
+
The started agent also receives a self-registration prompt. During registration it should inspect `CLAUDE.md`, `claude.md`, `AGENTS.md`, `agents.md`, `agent.md`, `README.md`, or project metadata and send `capabilitySummary` and `capabilitySources` to MCP `register_agent`.
|
|
107
|
+
|
|
108
|
+
Start a visible Claude agent:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
mair claude
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Override values when needed:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
mair codex --id ralph --session mina-ralph-codex --root /Users/stevenna/PycharmProjects/mina-ralph-loop-bootstrap-nextjs
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Verify
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
npm run smoke:http
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Current Test Flow
|
|
127
|
+
|
|
128
|
+
1. Start HTTP server with `mair server start --port 3333`.
|
|
129
|
+
2. Open the UI.
|
|
130
|
+
3. Click `Connect Agent` for the registration command guide.
|
|
131
|
+
4. Start an agent from its project directory with `mair codex` or `mair claude`.
|
|
132
|
+
5. Confirm the agent appears in the flow diagram.
|
|
133
|
+
6. Click the agent node and use the context menu to inspect details, view history, or delete it.
|
|
134
|
+
|
|
135
|
+
Alternative UI-created agent flow:
|
|
136
|
+
|
|
137
|
+
1. Right-click the `Live Agent Flow` background.
|
|
138
|
+
2. Choose `Create tmux Agent`.
|
|
139
|
+
3. Select `codex` or `claude`.
|
|
140
|
+
4. Enter the target project directory or use `Browse Directory` to select it.
|
|
141
|
+
5. Create the agent.
|
|
142
|
+
6. Use the agent context menu `Attach Commands` when direct terminal control is needed.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# MCP Client Setup
|
|
2
|
+
|
|
3
|
+
Mina AI Router exposes a local HTTP MCP endpoint:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
http://127.0.0.1:3333/mcp
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Start the router first:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
mair server start --port 3333
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Codex
|
|
16
|
+
|
|
17
|
+
Register the MAIR MCP server with Codex:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
codex mcp remove mina-ai-router
|
|
21
|
+
codex mcp add mina-ai-router --url http://127.0.0.1:3333/mcp
|
|
22
|
+
codex mcp get mina-ai-router
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Expected result:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
transport: streamable_http
|
|
29
|
+
url: http://127.0.0.1:3333/mcp
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then start Codex inside a project with MAIR:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
cd /path/to/project
|
|
36
|
+
mair codex
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Claude
|
|
40
|
+
|
|
41
|
+
Register the MAIR MCP server with Claude Code:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
claude mcp remove mina-ai-router
|
|
45
|
+
claude mcp add --transport http mina-ai-router http://127.0.0.1:3333/mcp
|
|
46
|
+
claude mcp get mina-ai-router
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then start Claude inside a project with MAIR:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
cd /path/to/project
|
|
53
|
+
mair claude
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Verify From the AI CLI
|
|
57
|
+
|
|
58
|
+
In Codex or Claude, ask:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
Use Mina AI Router MCP list_agents and summarize the registered agents.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If the MCP setup is working, the agent should call `list_agents`.
|
|
65
|
+
|
|
66
|
+
## Available MCP Tools
|
|
67
|
+
|
|
68
|
+
- `list_agents`: list known agents and their statuses
|
|
69
|
+
- `register_agent`: register or update the current visible agent
|
|
70
|
+
- `call_agent`: send a task to another registered agent
|
|
71
|
+
- `get_request_status`: check a routed request
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Skill Install Guide
|
|
2
|
+
|
|
3
|
+
Mina AI Router includes a local skill:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
skills/mina-ai-router-agent/SKILL.md
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The skill lets Codex or Claude register the current visible tmux-backed CLI session with MAIR without requiring the user to write a full registration payload.
|
|
10
|
+
|
|
11
|
+
## Codex
|
|
12
|
+
|
|
13
|
+
Install the skill into your Codex skills directory:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
mkdir -p ~/.codex/skills
|
|
17
|
+
ln -sfn "$(npm root -g)/@minasoft/mina-ai-router/skills/mina-ai-router-agent" \
|
|
18
|
+
~/.codex/skills/mina-ai-router-agent
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Restart Codex or open a new Codex session.
|
|
22
|
+
|
|
23
|
+
Use it from a MAIR-started session:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
cd /path/to/project
|
|
27
|
+
mair codex
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then tell Codex:
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
Register this CLI session with Mina AI Router.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Expected behavior:
|
|
37
|
+
|
|
38
|
+
1. Codex reads the skill.
|
|
39
|
+
2. Codex infers `pwd`, tmux session id, agent id, and agent type.
|
|
40
|
+
3. Codex reads project docs or metadata for capabilities.
|
|
41
|
+
4. Codex calls MCP `register_agent`.
|
|
42
|
+
5. Codex calls MCP `list_agents` and confirms registration.
|
|
43
|
+
|
|
44
|
+
## Claude
|
|
45
|
+
|
|
46
|
+
Claude Code project skills live under `.claude/skills/*/SKILL.md`.
|
|
47
|
+
|
|
48
|
+
For a single project, copy or link the MAIR skill into that project:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
cd /path/to/project
|
|
52
|
+
mkdir -p .claude/skills
|
|
53
|
+
ln -sfn "$(npm root -g)/@minasoft/mina-ai-router/skills/mina-ai-router-agent" \
|
|
54
|
+
.claude/skills/mina-ai-router-agent
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Restart Claude or open a new Claude session.
|
|
58
|
+
|
|
59
|
+
Use it from a MAIR-started session:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
cd /path/to/project
|
|
63
|
+
mair claude
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then tell Claude:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
Register this CLI session with Mina AI Router.
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Expected behavior:
|
|
73
|
+
|
|
74
|
+
1. Claude invokes the `mina-ai-router-agent` skill.
|
|
75
|
+
2. Claude infers `pwd`, tmux session id, agent id, and agent type.
|
|
76
|
+
3. Claude reads project docs or metadata for capabilities.
|
|
77
|
+
4. Claude calls MCP `register_agent`.
|
|
78
|
+
5. Claude calls MCP `list_agents` and confirms registration.
|
|
79
|
+
|
|
80
|
+
## Web UI Created Agents
|
|
81
|
+
|
|
82
|
+
If you create an agent from the Web UI, installing the skill is still useful but not mandatory for the first node to appear.
|
|
83
|
+
|
|
84
|
+
The Web UI already creates an initial registration so the agent is visible immediately. The skill improves that registration by letting the agent inspect its own project and update `capabilitySummary` and `capabilitySources`.
|
|
85
|
+
|
|
86
|
+
## Verify
|
|
87
|
+
|
|
88
|
+
Open the MAIR UI:
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
http://127.0.0.1:3333/
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Click the agent node and choose `Status & Details`.
|
|
95
|
+
|
|
96
|
+
The capability summary should describe the target project, and the capability sources should mention files such as `CLAUDE.md`, `AGENTS.md`, `README.md`, or package metadata.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
## `tmux binary is not available`
|
|
4
|
+
|
|
5
|
+
Install tmux or set `MINA_TMUX_BIN` to the tmux binary path.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
command -v tmux
|
|
9
|
+
export MINA_TMUX_BIN=/opt/homebrew/bin/tmux
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## MCP and CLI See Different Agents
|
|
13
|
+
|
|
14
|
+
They are probably using different state files.
|
|
15
|
+
|
|
16
|
+
Set the same `MINA_ROUTER_STATE` for both processes:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
export MINA_ROUTER_STATE=/absolute/path/to/router-state.json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## `call_agent` Times Out
|
|
23
|
+
|
|
24
|
+
Common causes:
|
|
25
|
+
|
|
26
|
+
- the helper agent is not running inside the tmux session
|
|
27
|
+
- the helper agent did not follow the response marker instruction
|
|
28
|
+
- the tmux session target is wrong
|
|
29
|
+
- the response markers wrapped across terminal lines in an unusual way
|
|
30
|
+
|
|
31
|
+
Useful checks:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
tmux ls
|
|
35
|
+
tmux capture-pane -t payment -p -J -S -200
|
|
36
|
+
mair request <request-id>
|
|
37
|
+
mair attach payment
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Answer Is `...` or `[your answer]`
|
|
41
|
+
|
|
42
|
+
This should be rejected by the parser. If it appears again, the parser is likely reading the prompt example instead of the helper answer.
|
|
43
|
+
|
|
44
|
+
Run:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm test
|
|
48
|
+
npm run smoke:tmux
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Wrong Agent Receives the Prompt
|
|
52
|
+
|
|
53
|
+
Check the registered session ids:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
mair agents
|
|
57
|
+
mair agent payment
|
|
58
|
+
mair agent delivery
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
If needed, register with an explicit tmux pane target:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
mair register payment --agent gemini --transport tmux --session payment --target payment:0.0 --root ~/work/payment
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Reset Local State
|
|
68
|
+
|
|
69
|
+
Runtime JSON state is ignored by git.
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
rm data/router-state.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Use this carefully; it deletes local registrations and request history.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# User Start Guide
|
|
2
|
+
|
|
3
|
+
This guide is for someone who wants to use Mina AI Router, not develop it.
|
|
4
|
+
|
|
5
|
+
## What You Will Set Up
|
|
6
|
+
|
|
7
|
+
You will:
|
|
8
|
+
|
|
9
|
+
1. Install the `mair` command.
|
|
10
|
+
2. Start the local router and Web UI.
|
|
11
|
+
3. Connect Codex or Claude to the local MCP server.
|
|
12
|
+
4. Install the agent registration skill.
|
|
13
|
+
5. Create visible tmux-backed agents.
|
|
14
|
+
6. Inspect and control agents from the browser.
|
|
15
|
+
|
|
16
|
+
## 1. Install the `mair` Command
|
|
17
|
+
|
|
18
|
+
Install the published package:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install -g @minasoft/mina-ai-router
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Verify:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
mair version
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Expected output:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"name": "@minasoft/mina-ai-router",
|
|
35
|
+
"version": "0.1.0"
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 2. Start the Router
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
mair server start --port 3333
|
|
43
|
+
mair server status
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Open:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
http://127.0.0.1:3333/
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The center node is the local MCP router. The surrounding nodes are registered agents.
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
|
|
56
|
+
## 3. Connect Your AI CLI to MCP
|
|
57
|
+
|
|
58
|
+
Pick the guide for the CLI you use:
|
|
59
|
+
|
|
60
|
+
- Codex: [Codex MCP Setup](./MCP-CLIENT-SETUP.md#codex)
|
|
61
|
+
- Claude: [Claude MCP Setup](./MCP-CLIENT-SETUP.md#claude)
|
|
62
|
+
|
|
63
|
+
This gives the AI CLI access to these MAIR MCP tools:
|
|
64
|
+
|
|
65
|
+
- `list_agents`
|
|
66
|
+
- `register_agent`
|
|
67
|
+
- `call_agent`
|
|
68
|
+
- `get_request_status`
|
|
69
|
+
|
|
70
|
+
## 4. Install the Registration Skill
|
|
71
|
+
|
|
72
|
+
Pick the guide for the CLI you use:
|
|
73
|
+
|
|
74
|
+
- Codex: [Codex Skill Install](./SKILL-INSTALL-GUIDE.md#codex)
|
|
75
|
+
- Claude: [Claude Skill Install](./SKILL-INSTALL-GUIDE.md#claude)
|
|
76
|
+
|
|
77
|
+
The skill lets the agent register itself without asking you to type a long JSON payload.
|
|
78
|
+
|
|
79
|
+
It automatically infers:
|
|
80
|
+
|
|
81
|
+
- project root
|
|
82
|
+
- tmux session id
|
|
83
|
+
- agent id
|
|
84
|
+
- agent type
|
|
85
|
+
- capability summary
|
|
86
|
+
- capability sources
|
|
87
|
+
|
|
88
|
+
## 5. Create an Agent From the Web UI
|
|
89
|
+
|
|
90
|
+
This is the easiest path for most users.
|
|
91
|
+
|
|
92
|
+
1. Right-click the empty area in `Live Agent Flow`.
|
|
93
|
+
2. Click `Create tmux Agent`.
|
|
94
|
+
3. Choose `codex` or `claude`.
|
|
95
|
+
4. Select a project directory.
|
|
96
|
+
5. Click `Create Agent`.
|
|
97
|
+
|
|
98
|
+
Mina creates or reuses a tmux session and registers the agent in the router.
|
|
99
|
+
|
|
100
|
+
If Codex or Claude needs trust approval, the Web UI shows the terminal so you can respond.
|
|
101
|
+
|
|
102
|
+
## 6. Alternative: Create an Agent From a Terminal
|
|
103
|
+
|
|
104
|
+
From the project you want to expose as an agent:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
cd /path/to/project
|
|
108
|
+
mair codex
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For Claude:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
cd /path/to/project
|
|
115
|
+
mair claude
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Mina derives the agent id and tmux session name from the current directory.
|
|
119
|
+
|
|
120
|
+
## 7. Self-Register With the Skill
|
|
121
|
+
|
|
122
|
+
If the agent did not fully self-register, open the agent terminal and send:
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
Register this CLI session with Mina AI Router.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
If you created the agent from the Web UI, this step is still useful but not always required:
|
|
129
|
+
|
|
130
|
+
- the Web UI creates an initial registration immediately
|
|
131
|
+
- the skill can update that registration with a better project-aware capability summary
|
|
132
|
+
|
|
133
|
+
## 8. Inspect or Edit Capabilities
|
|
134
|
+
|
|
135
|
+
Click an agent node and choose `Status & Details`.
|
|
136
|
+
|
|
137
|
+
You can view and edit:
|
|
138
|
+
|
|
139
|
+
- capability summary
|
|
140
|
+
- capability sources
|
|
141
|
+
- project root
|
|
142
|
+
- tmux session
|
|
143
|
+
- attach commands
|
|
144
|
+
|
|
145
|
+

|
|
146
|
+
|
|
147
|
+
## 9. Open the Agent Terminal
|
|
148
|
+
|
|
149
|
+
Click an agent node and choose `Open Terminal`.
|
|
150
|
+
|
|
151
|
+
The browser shows the current tmux screen. Type into the input field and press `Enter`, or click `Send`.
|
|
152
|
+
|
|
153
|
+
Use this when:
|
|
154
|
+
|
|
155
|
+
- the agent is waiting for trust approval
|
|
156
|
+
- the agent is stuck at a prompt
|
|
157
|
+
- you want to see what the CLI is doing
|
|
158
|
+
- you need to manually type into the session
|
|
159
|
+
|
|
160
|
+

|
|
161
|
+
|
|
162
|
+
## 10. Ask One Agent to Use Another
|
|
163
|
+
|
|
164
|
+
In a registered Codex or Claude session, ask it to use Mina AI Router.
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
Use Mina AI Router to ask api_server:
|
|
170
|
+
Which REST API should aiagent call first for user lookup?
|
|
171
|
+
Summarize method, endpoint, parameters, and source files.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Expected flow:
|
|
175
|
+
|
|
176
|
+
1. The source agent calls `list_agents`.
|
|
177
|
+
2. It chooses the target agent.
|
|
178
|
+
3. It calls `call_agent`.
|
|
179
|
+
4. MAIR sends the task into the target tmux session.
|
|
180
|
+
5. The target agent answers with Mina response markers.
|
|
181
|
+
6. MAIR returns the parsed answer to the source agent.
|
|
182
|
+
|
|
183
|
+
## 11. Stop the Router
|
|
184
|
+
|
|
185
|
+
```sh
|
|
186
|
+
mair server stop
|
|
187
|
+
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@minasoft/mina-ai-router",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local MCP router and Web UI for visible tmux-backed AI agents.",
|
|
5
|
+
"main": "dist/apps/cli/src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mair": "dist/apps/cli/src/index.js",
|
|
8
|
+
"mair-mcp": "dist/apps/mcp-server/src/index.js",
|
|
9
|
+
"mair-http": "dist/apps/http-server/src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"docs/assets",
|
|
14
|
+
"docs/GETTING-STARTED.md",
|
|
15
|
+
"docs/USER-START-GUIDE.md",
|
|
16
|
+
"docs/DEVELOPER-START-GUIDE.md",
|
|
17
|
+
"docs/MCP-CLIENT-SETUP.md",
|
|
18
|
+
"docs/SKILL-INSTALL-GUIDE.md",
|
|
19
|
+
"docs/HTTP-UI-MCP.md",
|
|
20
|
+
"docs/TROUBLESHOOTING.md",
|
|
21
|
+
"skills",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"test": "npm run build && node scripts/core-tests.js",
|
|
27
|
+
"mair": "node dist/apps/cli/src/index.js",
|
|
28
|
+
"mcp": "node dist/apps/mcp-server/src/index.js",
|
|
29
|
+
"http": "node dist/apps/http-server/src/index.js",
|
|
30
|
+
"smoke": "npm run build && node dist/apps/cli/src/index.js register payment --agent gemini --transport headless --session payment --root ./payment && node dist/apps/cli/src/index.js ask payment \"현재 payment flow를 요약해줘.\"",
|
|
31
|
+
"smoke:http": "npm run build && node scripts/smoke-http.js",
|
|
32
|
+
"smoke:cli-controls": "npm run build && node scripts/smoke-cli-controls.js",
|
|
33
|
+
"smoke:tmux": "npm run build && node scripts/smoke-tmux.js",
|
|
34
|
+
"smoke:mcp": "npm run build && node scripts/smoke-mcp.js",
|
|
35
|
+
"smoke:multi": "npm run build && node scripts/smoke-multi-agent.js",
|
|
36
|
+
"verify": "npm run test && npm run smoke:http && npm run smoke:cli-controls && npm run smoke:tmux && npm run smoke:mcp && npm run smoke:multi"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@minasoft/mcp-runtime": "^0.1.6"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"typescript": "^5.5.3"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mina-ai-router-agent
|
|
3
|
+
description: Register the current visible Codex or Claude CLI session with Mina AI Router through MCP. Use when the user says to connect, register, join, attach, or make the current CLI agent available in Mina/MAIR, especially from inside a tmux-backed project session.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Mina AI Router Agent
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Register the current visible CLI agent session with Mina AI Router using the MCP tool `register_agent`.
|
|
11
|
+
|
|
12
|
+
Use this skill when the user asks for a short instruction such as:
|
|
13
|
+
|
|
14
|
+
- "register this session with Mina"
|
|
15
|
+
- "connect this agent to MAIR"
|
|
16
|
+
- "join the router"
|
|
17
|
+
- "make this Codex/Claude visible in Mina"
|
|
18
|
+
|
|
19
|
+
## Workflow
|
|
20
|
+
|
|
21
|
+
1. Collect local context with shell commands when available:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pwd
|
|
25
|
+
tmux display-message -p '#S' 2>/dev/null || true
|
|
26
|
+
tmux display-message -p '#{pane_id}' 2>/dev/null || true
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. Infer fields:
|
|
30
|
+
|
|
31
|
+
- `projectRoot`: output of `pwd`
|
|
32
|
+
- `sessionId`: tmux session name from `tmux display-message -p '#S'`
|
|
33
|
+
- `id`: project directory basename, lowercased and normalized to letters, digits, `_`, and `-`
|
|
34
|
+
- `name`: same as `id` unless the user gave a name
|
|
35
|
+
- `agentType`: `codex` when running in Codex; `claude` when running in Claude
|
|
36
|
+
- `transport`: `tmux`
|
|
37
|
+
- `startupCommand`: `codex --no-alt-screen` for Codex, `claude` for Claude
|
|
38
|
+
|
|
39
|
+
3. Build a capability notice for this session.
|
|
40
|
+
|
|
41
|
+
Prefer these project files when present:
|
|
42
|
+
|
|
43
|
+
- `CLAUDE.md` or `claude.md`
|
|
44
|
+
- `AGENTS.md` or `agents.md`
|
|
45
|
+
- `agent.md`
|
|
46
|
+
- `README.md`
|
|
47
|
+
|
|
48
|
+
If none of those files exist, inspect project metadata and structure, such as `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, source directories, and test directories.
|
|
49
|
+
|
|
50
|
+
Set:
|
|
51
|
+
|
|
52
|
+
- `capabilitySummary`: 2-5 short bullets or one short paragraph under 800 characters that explains what this agent can help with.
|
|
53
|
+
- `capabilitySources`: comma-separated file paths or project signals used for the summary.
|
|
54
|
+
|
|
55
|
+
4. Call Mina MCP `register_agent` with the inferred values and capability notice.
|
|
56
|
+
|
|
57
|
+
5. Call Mina MCP `list_agents` and confirm the registered agent is present with its capability notice.
|
|
58
|
+
|
|
59
|
+
## Rules
|
|
60
|
+
|
|
61
|
+
- Do not ask the user to manually provide the full registration payload unless inference fails.
|
|
62
|
+
- If not running inside tmux, explain that Mina visible-session routing expects a tmux session and ask the user to start through `mair codex` or `mair claude`.
|
|
63
|
+
- If `register_agent` is not available, ask the user to update Mina AI Router or restart the MCP server.
|
|
64
|
+
- Keep the user-facing response short: say the agent id, session id, project root, capability source, and registration status.
|