@amaster.ai/runtime-cli 1.1.37 → 1.1.38-beta.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/dist/cli.cjs +31 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +31 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +32 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +32 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -71,6 +71,7 @@ interface RuntimeConfig {
|
|
|
71
71
|
registries?: Record<string, RegistryConfig>;
|
|
72
72
|
currentRegistry?: string;
|
|
73
73
|
}
|
|
74
|
+
declare function getAmasterConfigDir(): string;
|
|
74
75
|
declare function getConfig(): RuntimeConfig;
|
|
75
76
|
declare function saveConfig(config: RuntimeConfig): void;
|
|
76
77
|
declare function getAppConfig(appCode: string): AppConfig | null;
|
|
@@ -96,4 +97,4 @@ declare function isAuthenticated(appCode: string): boolean;
|
|
|
96
97
|
declare function getAccessToken(appCode: string): string | null;
|
|
97
98
|
declare function shouldRefreshToken(appCode: string): boolean;
|
|
98
99
|
|
|
99
|
-
export { type AmasterConfig, type AppConfig, type AuthSession, type McpServerConfig, type OpenClawConfig, type RegistryConfig, type ResolvedRegistry, type RuntimeConfig, type SkillManifest, addApp, clearAuthSession, ensureRegistry, getAccessToken, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, getCurrentRegistry, getRegistryConfig, inferRegistryBaseURLFromAppBaseURL, isAuthenticated, listApps, listRegistries, normalizeRegistryBaseURL, removeApp, resolveAppBaseURL, resolveRegistry, saveAuthSession, saveConfig, setCurrentApp, setCurrentRegistry, shouldRefreshToken };
|
|
100
|
+
export { type AmasterConfig, type AppConfig, type AuthSession, type McpServerConfig, type OpenClawConfig, type RegistryConfig, type ResolvedRegistry, type RuntimeConfig, type SkillManifest, addApp, clearAuthSession, ensureRegistry, getAccessToken, getAmasterConfigDir, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, getCurrentRegistry, getRegistryConfig, inferRegistryBaseURLFromAppBaseURL, isAuthenticated, listApps, listRegistries, normalizeRegistryBaseURL, removeApp, resolveAppBaseURL, resolveRegistry, saveAuthSession, saveConfig, setCurrentApp, setCurrentRegistry, shouldRefreshToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ interface RuntimeConfig {
|
|
|
71
71
|
registries?: Record<string, RegistryConfig>;
|
|
72
72
|
currentRegistry?: string;
|
|
73
73
|
}
|
|
74
|
+
declare function getAmasterConfigDir(): string;
|
|
74
75
|
declare function getConfig(): RuntimeConfig;
|
|
75
76
|
declare function saveConfig(config: RuntimeConfig): void;
|
|
76
77
|
declare function getAppConfig(appCode: string): AppConfig | null;
|
|
@@ -96,4 +97,4 @@ declare function isAuthenticated(appCode: string): boolean;
|
|
|
96
97
|
declare function getAccessToken(appCode: string): string | null;
|
|
97
98
|
declare function shouldRefreshToken(appCode: string): boolean;
|
|
98
99
|
|
|
99
|
-
export { type AmasterConfig, type AppConfig, type AuthSession, type McpServerConfig, type OpenClawConfig, type RegistryConfig, type ResolvedRegistry, type RuntimeConfig, type SkillManifest, addApp, clearAuthSession, ensureRegistry, getAccessToken, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, getCurrentRegistry, getRegistryConfig, inferRegistryBaseURLFromAppBaseURL, isAuthenticated, listApps, listRegistries, normalizeRegistryBaseURL, removeApp, resolveAppBaseURL, resolveRegistry, saveAuthSession, saveConfig, setCurrentApp, setCurrentRegistry, shouldRefreshToken };
|
|
100
|
+
export { type AmasterConfig, type AppConfig, type AuthSession, type McpServerConfig, type OpenClawConfig, type RegistryConfig, type ResolvedRegistry, type RuntimeConfig, type SkillManifest, addApp, clearAuthSession, ensureRegistry, getAccessToken, getAmasterConfigDir, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, getCurrentRegistry, getRegistryConfig, inferRegistryBaseURLFromAppBaseURL, isAuthenticated, listApps, listRegistries, normalizeRegistryBaseURL, removeApp, resolveAppBaseURL, resolveRegistry, saveAuthSession, saveConfig, setCurrentApp, setCurrentRegistry, shouldRefreshToken };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(config_exports, {
|
|
|
26
26
|
clearAuthSession: () => clearAuthSession,
|
|
27
27
|
ensureRegistry: () => ensureRegistry,
|
|
28
28
|
getAccessToken: () => getAccessToken,
|
|
29
|
+
getAmasterConfigDir: () => getAmasterConfigDir,
|
|
29
30
|
getAppConfig: () => getAppConfig,
|
|
30
31
|
getAuthSession: () => getAuthSession,
|
|
31
32
|
getBaseURL: () => getBaseURL,
|
|
@@ -47,21 +48,32 @@ __export(config_exports, {
|
|
|
47
48
|
setCurrentRegistry: () => setCurrentRegistry,
|
|
48
49
|
shouldRefreshToken: () => shouldRefreshToken
|
|
49
50
|
});
|
|
51
|
+
function getAmasterConfigDir() {
|
|
52
|
+
return process.env.AMASTER_CONFIG_DIR?.trim() || join(homedir(), ".amaster");
|
|
53
|
+
}
|
|
54
|
+
function configFile() {
|
|
55
|
+
return join(getAmasterConfigDir(), "config.json");
|
|
56
|
+
}
|
|
57
|
+
function authFile(appCode) {
|
|
58
|
+
return join(getAmasterConfigDir(), `auth-${appCode}.json`);
|
|
59
|
+
}
|
|
50
60
|
function getConfig() {
|
|
51
|
-
|
|
61
|
+
const file = configFile();
|
|
62
|
+
if (!existsSync(file)) {
|
|
52
63
|
return { apps: {} };
|
|
53
64
|
}
|
|
54
65
|
try {
|
|
55
|
-
return JSON.parse(readFileSync(
|
|
66
|
+
return JSON.parse(readFileSync(file, "utf-8"));
|
|
56
67
|
} catch {
|
|
57
68
|
return { apps: {} };
|
|
58
69
|
}
|
|
59
70
|
}
|
|
60
71
|
function saveConfig(config) {
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
const configDir = getAmasterConfigDir();
|
|
73
|
+
if (!existsSync(configDir)) {
|
|
74
|
+
mkdirSync(configDir, { recursive: true });
|
|
63
75
|
}
|
|
64
|
-
writeFileSync(
|
|
76
|
+
writeFileSync(configFile(), JSON.stringify(config, null, 2));
|
|
65
77
|
}
|
|
66
78
|
function getAppConfig(appCode) {
|
|
67
79
|
const config = getConfig();
|
|
@@ -79,9 +91,9 @@ function removeApp(appCode) {
|
|
|
79
91
|
const config = getConfig();
|
|
80
92
|
if (config.apps[appCode]) {
|
|
81
93
|
delete config.apps[appCode];
|
|
82
|
-
const
|
|
83
|
-
if (existsSync(
|
|
84
|
-
rmSync(
|
|
94
|
+
const file = authFile(appCode);
|
|
95
|
+
if (existsSync(file)) {
|
|
96
|
+
rmSync(file, { force: true });
|
|
85
97
|
}
|
|
86
98
|
if (config.currentApp === appCode) {
|
|
87
99
|
const remainingApps = Object.keys(config.apps);
|
|
@@ -245,28 +257,28 @@ function getBaseURL(appCode) {
|
|
|
245
257
|
return appConfig?.baseURL || null;
|
|
246
258
|
}
|
|
247
259
|
function getAuthSession(appCode) {
|
|
248
|
-
const
|
|
249
|
-
if (!existsSync(
|
|
260
|
+
const file = authFile(appCode);
|
|
261
|
+
if (!existsSync(file)) {
|
|
250
262
|
return null;
|
|
251
263
|
}
|
|
252
264
|
try {
|
|
253
|
-
const content = readFileSync(
|
|
265
|
+
const content = readFileSync(file, "utf-8");
|
|
254
266
|
return JSON.parse(content);
|
|
255
267
|
} catch {
|
|
256
268
|
return null;
|
|
257
269
|
}
|
|
258
270
|
}
|
|
259
271
|
function saveAuthSession(appCode, session) {
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
const configDir = getAmasterConfigDir();
|
|
273
|
+
if (!existsSync(configDir)) {
|
|
274
|
+
mkdirSync(configDir, { recursive: true });
|
|
262
275
|
}
|
|
263
|
-
|
|
264
|
-
writeFileSync(authFile, JSON.stringify(session, null, 2), { mode: 384 });
|
|
276
|
+
writeFileSync(authFile(appCode), JSON.stringify(session, null, 2), { mode: 384 });
|
|
265
277
|
}
|
|
266
278
|
function clearAuthSession(appCode) {
|
|
267
|
-
const
|
|
268
|
-
if (existsSync(
|
|
269
|
-
rmSync(
|
|
279
|
+
const file = authFile(appCode);
|
|
280
|
+
if (existsSync(file)) {
|
|
281
|
+
rmSync(file, { force: true });
|
|
270
282
|
}
|
|
271
283
|
}
|
|
272
284
|
function isAuthenticated(appCode) {
|
|
@@ -305,11 +317,9 @@ function isLocalLikeHost(hostname) {
|
|
|
305
317
|
}
|
|
306
318
|
return false;
|
|
307
319
|
}
|
|
308
|
-
var
|
|
320
|
+
var DEFAULT_REGISTRY_NAME, BUILTIN_REGISTRY_DEFINITIONS;
|
|
309
321
|
var init_config = __esm({
|
|
310
322
|
"src/config.ts"() {
|
|
311
|
-
AMASTER_CONFIG_DIR = join(homedir(), ".amaster");
|
|
312
|
-
CONFIG_FILE = join(AMASTER_CONFIG_DIR, "config.json");
|
|
313
323
|
DEFAULT_REGISTRY_NAME = "helige";
|
|
314
324
|
BUILTIN_REGISTRY_DEFINITIONS = {
|
|
315
325
|
helige: "https://helige.cn",
|
|
@@ -3909,6 +3919,6 @@ if (isDirectCliExecution()) {
|
|
|
3909
3919
|
);
|
|
3910
3920
|
}
|
|
3911
3921
|
|
|
3912
|
-
export { addApp, clearAuthSession, createAmasterClient, ensureRegistry, getAccessToken, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, getCurrentRegistry, getRegistryConfig, inferRegistryBaseURLFromAppBaseURL, isAuthenticated, listApps, listRegistries, normalizeRegistryBaseURL, removeApp, resolveAppBaseURL, resolveAppCode, resolveInitBaseURL, resolveRegistry, saveAuthSession, saveConfig, setCurrentApp, setCurrentRegistry, shouldRefreshToken };
|
|
3922
|
+
export { addApp, clearAuthSession, createAmasterClient, ensureRegistry, getAccessToken, getAmasterConfigDir, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, getCurrentRegistry, getRegistryConfig, inferRegistryBaseURLFromAppBaseURL, isAuthenticated, listApps, listRegistries, normalizeRegistryBaseURL, removeApp, resolveAppBaseURL, resolveAppCode, resolveInitBaseURL, resolveRegistry, saveAuthSession, saveConfig, setCurrentApp, setCurrentRegistry, shouldRefreshToken };
|
|
3913
3923
|
//# sourceMappingURL=index.js.map
|
|
3914
3924
|
//# sourceMappingURL=index.js.map
|