@minasoft/mina-ai-router 0.2.0 → 0.2.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 CHANGED
@@ -46,6 +46,8 @@ While this server is running, it owns the live router state for that state file.
46
46
 
47
47
  `mair server start` reports success only after the local Mina health endpoint is ready. If startup fails because the port is occupied, or a stale pid file points at a non-Mina process, Mina reports an actionable diagnostic instead of a healthy-looking server.
48
48
 
49
+ By default, Mina stores local runtime files under `~/.mair`, so `mair server status`, `mair health`, and agent commands point at the same local server no matter which project directory you run them from. Set `MINA_RUNTIME_DIR`, `MINA_ROUTER_STATE`, or `MINA_SERVER_PID` only when you intentionally want an isolated test or custom runtime.
50
+
49
51
  ## Connect Codex or Claude
50
52
 
51
53
  Run setup from the project you want an agent to work in. It discovers the matching running router URL, configures MCP, installs the registration skill, and verifies the client profile.
@@ -6,9 +6,9 @@ const node_fs_1 = require("node:fs");
6
6
  const node_child_process_1 = require("node:child_process");
7
7
  const src_1 = require("../../../packages/core/src");
8
8
  const src_2 = require("../../../packages/transports/src");
9
- const statePath = process.env.MINA_ROUTER_STATE ?? (0, node_path_1.join)(process.cwd(), "data", "router-state.json");
9
+ const statePath = process.env.MINA_ROUTER_STATE ?? (0, src_1.defaultRouterStatePath)();
10
10
  const version = (0, src_1.packageVersion)();
11
- const serverPidPath = process.env.MINA_SERVER_PID ?? (0, node_path_1.join)(process.cwd(), "data", "mair-server.json");
11
+ const serverPidPath = process.env.MINA_SERVER_PID ?? (0, src_1.defaultServerPidPath)();
12
12
  const agentStaleAfterMs = Number(process.env.MINA_AGENT_STALE_AFTER_MS ?? 15 * 60 * 1000);
13
13
  async function main(argv) {
14
14
  const command = argv[2];
@@ -1673,7 +1673,8 @@ Example:
1673
1673
  mair ask payment "현재 payment flow를 요약해줘."
1674
1674
 
1675
1675
  State:
1676
- Set MINA_ROUTER_STATE=/path/to/router-state.json to share state between CLI and MCP.
1676
+ By default, Mina uses ~/.mair for router state, pid, and logs across directories.
1677
+ Set MINA_RUNTIME_DIR, MINA_ROUTER_STATE, or MINA_SERVER_PID only for an isolated runtime.
1677
1678
  `);
1678
1679
  }
1679
1680
  function printCommandHelp(command) {
@@ -13,7 +13,7 @@ const importEsm = new Function("specifier", "return import(specifier)");
13
13
  const runtimeModuleUrl = (0, node_url_1.pathToFileURL)((0, node_path_1.join)(__dirname, "../../../../node_modules/@minasoft/mcp-runtime/dist/index.js")).href;
14
14
  const port = Number(process.env.PORT ?? process.env.MINA_HTTP_PORT ?? 3333);
15
15
  const host = process.env.HOST ?? process.env.MINA_HTTP_HOST ?? "127.0.0.1";
16
- const statePath = process.env.MINA_ROUTER_STATE ?? (0, node_path_1.join)(process.cwd(), "data", "router-state.json");
16
+ const statePath = process.env.MINA_ROUTER_STATE ?? (0, src_1.defaultRouterStatePath)();
17
17
  const agentStaleAfterMs = Number(process.env.MINA_AGENT_STALE_AFTER_MS ?? 15 * 60 * 1000);
18
18
  const context = createContext();
19
19
  let mcpHandlerPromise;
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const node_path_1 = require("node:path");
5
4
  const node_url_1 = require("node:url");
6
5
  const node_fs_1 = require("node:fs");
7
6
  const src_1 = require("../../../packages/core/src");
8
7
  const src_2 = require("../../../packages/transports/src");
9
8
  const importEsm = new Function("specifier", "return import(specifier)");
10
9
  const runtimeModuleUrl = (0, node_url_1.pathToFileURL)(require.resolve("@minasoft/mcp-runtime")).href;
11
- const statePath = process.env.MINA_ROUTER_STATE ?? (0, node_path_1.join)(process.cwd(), "data", "router-state.json");
10
+ const statePath = process.env.MINA_ROUTER_STATE ?? (0, src_1.defaultRouterStatePath)();
12
11
  const logPath = process.env.MINA_MCP_LOG;
13
12
  const context = createContext();
14
13
  let inputBuffer = Buffer.alloc(0);
@@ -23,5 +23,6 @@ __exportStar(require("./registry"), exports);
23
23
  __exportStar(require("./request-store"), exports);
24
24
  __exportStar(require("./response-parser"), exports);
25
25
  __exportStar(require("./router"), exports);
26
+ __exportStar(require("./runtime-paths"), exports);
26
27
  __exportStar(require("./types"), exports);
27
28
  __exportStar(require("./version"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultRuntimeDir = defaultRuntimeDir;
4
+ exports.defaultRouterStatePath = defaultRouterStatePath;
5
+ exports.defaultServerPidPath = defaultServerPidPath;
6
+ const node_os_1 = require("node:os");
7
+ const node_path_1 = require("node:path");
8
+ function defaultRuntimeDir() {
9
+ return process.env.MINA_RUNTIME_DIR ?? (0, node_path_1.join)((0, node_os_1.homedir)(), ".mair");
10
+ }
11
+ function defaultRouterStatePath() {
12
+ return (0, node_path_1.join)(defaultRuntimeDir(), "router-state.json");
13
+ }
14
+ function defaultServerPidPath() {
15
+ return (0, node_path_1.join)(defaultRuntimeDir(), "mair-server.json");
16
+ }
@@ -11,7 +11,9 @@ export MINA_TMUX_BIN=/opt/homebrew/bin/tmux
11
11
 
12
12
  ## MCP and CLI See Different Agents
13
13
 
14
- They are probably using different state files.
14
+ By default, Mina uses `~/.mair/router-state.json` and `~/.mair/mair-server.json` so commands run from different directories share one local server.
15
+
16
+ If MCP and CLI still see different agents, they are probably using explicit custom state files.
15
17
 
16
18
  Set the same `MINA_ROUTER_STATE` for both processes:
17
19
 
@@ -39,7 +41,7 @@ Useful checks:
39
41
  ```sh
40
42
  mair server status
41
43
  lsof -nP -iTCP:3333 -sTCP:LISTEN
42
- cat data/mair-server.log
44
+ cat ~/.mair/mair-server.log
43
45
  ```
44
46
 
45
47
  Stop the process that owns the port, or start Mina on another port:
@@ -56,7 +58,7 @@ Safe recovery:
56
58
 
57
59
  ```sh
58
60
  mair server status
59
- rm data/mair-server.json
61
+ rm ~/.mair/mair-server.json
60
62
  mair server start --port 3333
61
63
  ```
62
64
 
@@ -116,7 +118,7 @@ mair register payment --agent gemini --transport tmux --session payment --target
116
118
  Runtime JSON state is ignored by git.
117
119
 
118
120
  ```sh
119
- rm data/router-state.json
121
+ rm ~/.mair/router-state.json
120
122
  ```
121
123
 
122
124
  Use this carefully; it deletes local registrations and request history.
@@ -82,6 +82,8 @@ The center node is the local MCP router. The surrounding nodes are visible Codex
82
82
 
83
83
  While the router server is running, it owns the live state for that `MINA_ROUTER_STATE` file. Normal CLI reads and writes talk to the matching server when possible, so `mair health`, `mair agents`, `mair agent <id>`, the Web UI, and MCP calls stay aligned during active routes.
84
84
 
85
+ By default, those runtime files live in `~/.mair`. You can run `mair server status` from your home directory or any project directory and it will check the same local server. Use `MINA_RUNTIME_DIR`, `MINA_ROUTER_STATE`, or `MINA_SERVER_PID` only when you intentionally want an isolated test/runtime.
86
+
85
87
  ## 3. Connect Your AI CLI to MCP
86
88
 
87
89
  Run setup from the project directory you want the agent to work in:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minasoft/mina-ai-router",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Local MCP router and Web UI for visible tmux-backed AI agents.",
5
5
  "homepage": "https://github.com/stevennana/mina-ai-router#readme",
6
6
  "repository": {