agent-resource-management 2.1.9 → 2.1.10

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/dist/main.js CHANGED
@@ -330,6 +330,7 @@ import { writeFileSync, readFileSync, existsSync, mkdirSync, chmodSync } from "f
330
330
  import { join } from "path";
331
331
  var CONFIG_DIR = join(process.env.HOME || "/root", ".arm");
332
332
  var CONFIG_FILE = join(CONFIG_DIR, "config.json");
333
+ var DEFAULT_SERVER_URL = "http://arm.agent-platform.dev.aimstek.cn";
333
334
  function ensureConfigDir() {
334
335
  if (!existsSync(CONFIG_DIR)) {
335
336
  mkdirSync(CONFIG_DIR, { recursive: true });
@@ -354,7 +355,7 @@ function loadConfig() {
354
355
  }
355
356
  function getServerUrl() {
356
357
  const config = loadConfig();
357
- return config?.serverUrl || "http://localhost:3000";
358
+ return config?.serverUrl || DEFAULT_SERVER_URL;
358
359
  }
359
360
  function setServerUrl(url) {
360
361
  const config = loadConfig() || {};
@@ -491,7 +492,7 @@ function formatKnowledgeDetail(knowledge) {
491
492
 
492
493
  // src/cmd/auth.ts
493
494
  async function register(name, email, password) {
494
- const { readline } = await import("readline");
495
+ const readline = await import("readline");
495
496
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
496
497
  const ask = (question) => new Promise((resolve) => rl.question(question, resolve));
497
498
  let finalEmail = email;
@@ -516,7 +517,7 @@ async function register(name, email, password) {
516
517
  process.exit(1);
517
518
  }
518
519
  const config = loadConfig();
519
- const serverUrl = config?.serverUrl || "http://localhost:3000";
520
+ const serverUrl = config?.serverUrl || DEFAULT_SERVER_URL;
520
521
  const client = new ApiClient(serverUrl);
521
522
  try {
522
523
  const result = await client.register(finalEmail, finalPassword, finalName);
@@ -532,9 +533,9 @@ async function register(name, email, password) {
532
533
  }
533
534
  }
534
535
  async function login() {
535
- console.log("请在浏览器打开:" + (loadConfig()?.serverUrl || "http://localhost:3000") + "/settings/tokens");
536
+ console.log("请在浏览器打开:" + (loadConfig()?.serverUrl || DEFAULT_SERVER_URL) + "/settings/tokens");
536
537
  console.log("生成一个 PAT(建议命名包含机器名),复制粘贴到此处:");
537
- const { readline } = await import("readline");
538
+ const readline = await import("readline");
538
539
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
539
540
  const token = await new Promise((resolve) => rl.question("PAT> ", (a) => {
540
541
  rl.close();
@@ -545,8 +546,8 @@ async function login() {
545
546
  error("格式错误:应以 arm_pat_ 开头");
546
547
  process.exit(1);
547
548
  }
548
- const config = loadConfig() || { serverUrl: "http://localhost:3000" };
549
- config.serverUrl = config.serverUrl || "http://localhost:3000";
549
+ const config = loadConfig() || { serverUrl: DEFAULT_SERVER_URL };
550
+ config.serverUrl = config.serverUrl || DEFAULT_SERVER_URL;
550
551
  config.token = trimmed;
551
552
  saveConfig(config);
552
553
  const client = new ApiClient(config.serverUrl, trimmed);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-resource-management",
3
- "version": "2.1.9",
3
+ "version": "2.1.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "arm": "./dist/main.js"
package/src/cmd/auth.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { ApiClient } from '../lib/client';
2
- import { loadConfig, saveConfig } from '../lib/storage';
2
+ import { loadConfig, saveConfig, DEFAULT_SERVER_URL } from '../lib/storage';
3
3
  import { success, error, info } from '../lib/formatter';
4
4
 
5
5
  export async function register(name?: string, email?: string, password?: string): Promise<void> {
6
- const { readline } = await import('readline');
6
+ const readline = await import('readline');
7
7
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
8
8
 
9
9
  const ask = (question: string): Promise<string> =>
@@ -35,7 +35,7 @@ export async function register(name?: string, email?: string, password?: string)
35
35
  }
36
36
 
37
37
  const config = loadConfig();
38
- const serverUrl = config?.serverUrl || 'http://localhost:3000';
38
+ const serverUrl = config?.serverUrl || DEFAULT_SERVER_URL;
39
39
  const client = new ApiClient(serverUrl);
40
40
 
41
41
  try {
@@ -53,9 +53,9 @@ export async function register(name?: string, email?: string, password?: string)
53
53
  }
54
54
 
55
55
  export async function login(): Promise<void> {
56
- console.log('请在浏览器打开:' + (loadConfig()?.serverUrl || 'http://localhost:3000') + '/settings/tokens');
56
+ console.log('请在浏览器打开:' + (loadConfig()?.serverUrl || DEFAULT_SERVER_URL) + '/settings/tokens');
57
57
  console.log('生成一个 PAT(建议命名包含机器名),复制粘贴到此处:');
58
- const { readline } = await import('readline');
58
+ const readline = await import('readline');
59
59
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
60
60
  const token = await new Promise<string>((resolve) => rl.question('PAT> ', (a) => { rl.close(); resolve(a); }));
61
61
  const trimmed = token.trim();
@@ -64,8 +64,8 @@ export async function login(): Promise<void> {
64
64
  process.exit(1);
65
65
  }
66
66
 
67
- const config = loadConfig() || { serverUrl: 'http://localhost:3000' };
68
- config.serverUrl = config.serverUrl || 'http://localhost:3000';
67
+ const config = loadConfig() || { serverUrl: DEFAULT_SERVER_URL };
68
+ config.serverUrl = config.serverUrl || DEFAULT_SERVER_URL;
69
69
  config.token = trimmed;
70
70
  saveConfig(config);
71
71
 
@@ -4,6 +4,8 @@ import { join } from 'path';
4
4
  const CONFIG_DIR = join(process.env.HOME || '/root', '.arm');
5
5
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
6
6
 
7
+ export const DEFAULT_SERVER_URL = 'http://arm.agent-platform.dev.aimstek.cn';
8
+
7
9
  interface Config {
8
10
  serverUrl: string;
9
11
  token?: string;
@@ -55,7 +57,7 @@ export function clearConfig(): void {
55
57
 
56
58
  export function getServerUrl(): string {
57
59
  const config = loadConfig();
58
- return config?.serverUrl || 'http://localhost:3000';
60
+ return config?.serverUrl || DEFAULT_SERVER_URL;
59
61
  }
60
62
 
61
63
  export function setServerUrl(url: string): void {