@amaster.ai/runtime-cli 1.1.27 → 1.1.28
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 +33 -1
- package/dist/cli.cjs +243 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +10 -1
- package/dist/cli.d.ts +10 -1
- package/dist/cli.js +243 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +252 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +243 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createAmasterClient, resolveAppCode } from './cli.cjs';
|
|
1
|
+
export { createAmasterClient, resolveAppCode, resolveInitBaseURL } from './cli.cjs';
|
|
2
2
|
import '@amaster.ai/client';
|
|
3
3
|
|
|
4
4
|
interface AmasterConfig {
|
|
@@ -40,9 +40,20 @@ interface SkillManifest {
|
|
|
40
40
|
|
|
41
41
|
interface AppConfig {
|
|
42
42
|
baseURL: string;
|
|
43
|
+
registry?: string;
|
|
44
|
+
registryBaseURL?: string;
|
|
43
45
|
ossEndpoint?: string;
|
|
44
46
|
initializedAt: string;
|
|
45
47
|
}
|
|
48
|
+
interface RegistryConfig {
|
|
49
|
+
baseURL: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
}
|
|
52
|
+
interface ResolvedRegistry {
|
|
53
|
+
name: string;
|
|
54
|
+
baseURL: string;
|
|
55
|
+
builtin: boolean;
|
|
56
|
+
}
|
|
46
57
|
interface AuthSession {
|
|
47
58
|
accessToken: string;
|
|
48
59
|
refreshToken?: string;
|
|
@@ -57,6 +68,8 @@ interface AuthSession {
|
|
|
57
68
|
interface RuntimeConfig {
|
|
58
69
|
apps: Record<string, AppConfig>;
|
|
59
70
|
currentApp?: string;
|
|
71
|
+
registries?: Record<string, RegistryConfig>;
|
|
72
|
+
currentRegistry?: string;
|
|
60
73
|
}
|
|
61
74
|
declare function getConfig(): RuntimeConfig;
|
|
62
75
|
declare function saveConfig(config: RuntimeConfig): void;
|
|
@@ -66,6 +79,15 @@ declare function removeApp(appCode: string): void;
|
|
|
66
79
|
declare function setCurrentApp(appCode: string): boolean;
|
|
67
80
|
declare function getCurrentApp(): string | null;
|
|
68
81
|
declare function listApps(): string[];
|
|
82
|
+
declare function listRegistries(): ResolvedRegistry[];
|
|
83
|
+
declare function getCurrentRegistry(): string;
|
|
84
|
+
declare function setCurrentRegistry(registryRef: string): ResolvedRegistry;
|
|
85
|
+
declare function getRegistryConfig(name: string): RegistryConfig | null;
|
|
86
|
+
declare function ensureRegistry(registryRef: string): ResolvedRegistry;
|
|
87
|
+
declare function resolveRegistry(registryRef?: string): ResolvedRegistry;
|
|
88
|
+
declare function normalizeRegistryBaseURL(value: string): string;
|
|
89
|
+
declare function resolveAppBaseURL(appCode: string, registryRef?: string): string;
|
|
90
|
+
declare function inferRegistryBaseURLFromAppBaseURL(appBaseURL: string, appCode?: string): string;
|
|
69
91
|
declare function getBaseURL(appCode?: string): string | null;
|
|
70
92
|
declare function getAuthSession(appCode: string): AuthSession | null;
|
|
71
93
|
declare function saveAuthSession(appCode: string, session: AuthSession): void;
|
|
@@ -74,4 +96,4 @@ declare function isAuthenticated(appCode: string): boolean;
|
|
|
74
96
|
declare function getAccessToken(appCode: string): string | null;
|
|
75
97
|
declare function shouldRefreshToken(appCode: string): boolean;
|
|
76
98
|
|
|
77
|
-
export { type AmasterConfig, type AppConfig, type AuthSession, type McpServerConfig, type OpenClawConfig, type RuntimeConfig, type SkillManifest, addApp, clearAuthSession, getAccessToken, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, isAuthenticated, listApps, removeApp, saveAuthSession, saveConfig, setCurrentApp, shouldRefreshToken };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createAmasterClient, resolveAppCode } from './cli.js';
|
|
1
|
+
export { createAmasterClient, resolveAppCode, resolveInitBaseURL } from './cli.js';
|
|
2
2
|
import '@amaster.ai/client';
|
|
3
3
|
|
|
4
4
|
interface AmasterConfig {
|
|
@@ -40,9 +40,20 @@ interface SkillManifest {
|
|
|
40
40
|
|
|
41
41
|
interface AppConfig {
|
|
42
42
|
baseURL: string;
|
|
43
|
+
registry?: string;
|
|
44
|
+
registryBaseURL?: string;
|
|
43
45
|
ossEndpoint?: string;
|
|
44
46
|
initializedAt: string;
|
|
45
47
|
}
|
|
48
|
+
interface RegistryConfig {
|
|
49
|
+
baseURL: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
}
|
|
52
|
+
interface ResolvedRegistry {
|
|
53
|
+
name: string;
|
|
54
|
+
baseURL: string;
|
|
55
|
+
builtin: boolean;
|
|
56
|
+
}
|
|
46
57
|
interface AuthSession {
|
|
47
58
|
accessToken: string;
|
|
48
59
|
refreshToken?: string;
|
|
@@ -57,6 +68,8 @@ interface AuthSession {
|
|
|
57
68
|
interface RuntimeConfig {
|
|
58
69
|
apps: Record<string, AppConfig>;
|
|
59
70
|
currentApp?: string;
|
|
71
|
+
registries?: Record<string, RegistryConfig>;
|
|
72
|
+
currentRegistry?: string;
|
|
60
73
|
}
|
|
61
74
|
declare function getConfig(): RuntimeConfig;
|
|
62
75
|
declare function saveConfig(config: RuntimeConfig): void;
|
|
@@ -66,6 +79,15 @@ declare function removeApp(appCode: string): void;
|
|
|
66
79
|
declare function setCurrentApp(appCode: string): boolean;
|
|
67
80
|
declare function getCurrentApp(): string | null;
|
|
68
81
|
declare function listApps(): string[];
|
|
82
|
+
declare function listRegistries(): ResolvedRegistry[];
|
|
83
|
+
declare function getCurrentRegistry(): string;
|
|
84
|
+
declare function setCurrentRegistry(registryRef: string): ResolvedRegistry;
|
|
85
|
+
declare function getRegistryConfig(name: string): RegistryConfig | null;
|
|
86
|
+
declare function ensureRegistry(registryRef: string): ResolvedRegistry;
|
|
87
|
+
declare function resolveRegistry(registryRef?: string): ResolvedRegistry;
|
|
88
|
+
declare function normalizeRegistryBaseURL(value: string): string;
|
|
89
|
+
declare function resolveAppBaseURL(appCode: string, registryRef?: string): string;
|
|
90
|
+
declare function inferRegistryBaseURLFromAppBaseURL(appBaseURL: string, appCode?: string): string;
|
|
69
91
|
declare function getBaseURL(appCode?: string): string | null;
|
|
70
92
|
declare function getAuthSession(appCode: string): AuthSession | null;
|
|
71
93
|
declare function saveAuthSession(appCode: string, session: AuthSession): void;
|
|
@@ -74,4 +96,4 @@ declare function isAuthenticated(appCode: string): boolean;
|
|
|
74
96
|
declare function getAccessToken(appCode: string): string | null;
|
|
75
97
|
declare function shouldRefreshToken(appCode: string): boolean;
|
|
76
98
|
|
|
77
|
-
export { type AmasterConfig, type AppConfig, type AuthSession, type McpServerConfig, type OpenClawConfig, type RuntimeConfig, type SkillManifest, addApp, clearAuthSession, getAccessToken, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, isAuthenticated, listApps, removeApp, saveAuthSession, saveConfig, setCurrentApp, shouldRefreshToken };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -24,18 +24,27 @@ var config_exports = {};
|
|
|
24
24
|
__export(config_exports, {
|
|
25
25
|
addApp: () => addApp,
|
|
26
26
|
clearAuthSession: () => clearAuthSession,
|
|
27
|
+
ensureRegistry: () => ensureRegistry,
|
|
27
28
|
getAccessToken: () => getAccessToken,
|
|
28
29
|
getAppConfig: () => getAppConfig,
|
|
29
30
|
getAuthSession: () => getAuthSession,
|
|
30
31
|
getBaseURL: () => getBaseURL,
|
|
31
32
|
getConfig: () => getConfig,
|
|
32
33
|
getCurrentApp: () => getCurrentApp,
|
|
34
|
+
getCurrentRegistry: () => getCurrentRegistry,
|
|
35
|
+
getRegistryConfig: () => getRegistryConfig,
|
|
36
|
+
inferRegistryBaseURLFromAppBaseURL: () => inferRegistryBaseURLFromAppBaseURL,
|
|
33
37
|
isAuthenticated: () => isAuthenticated,
|
|
34
38
|
listApps: () => listApps,
|
|
39
|
+
listRegistries: () => listRegistries,
|
|
40
|
+
normalizeRegistryBaseURL: () => normalizeRegistryBaseURL,
|
|
35
41
|
removeApp: () => removeApp,
|
|
42
|
+
resolveAppBaseURL: () => resolveAppBaseURL,
|
|
43
|
+
resolveRegistry: () => resolveRegistry,
|
|
36
44
|
saveAuthSession: () => saveAuthSession,
|
|
37
45
|
saveConfig: () => saveConfig,
|
|
38
46
|
setCurrentApp: () => setCurrentApp,
|
|
47
|
+
setCurrentRegistry: () => setCurrentRegistry,
|
|
39
48
|
shouldRefreshToken: () => shouldRefreshToken
|
|
40
49
|
});
|
|
41
50
|
function getConfig() {
|
|
@@ -98,6 +107,137 @@ function listApps() {
|
|
|
98
107
|
const config = getConfig();
|
|
99
108
|
return Object.keys(config.apps);
|
|
100
109
|
}
|
|
110
|
+
function listRegistries() {
|
|
111
|
+
const config = getConfig();
|
|
112
|
+
const currentRegistry = config.currentRegistry || DEFAULT_REGISTRY_NAME;
|
|
113
|
+
const registryMap = /* @__PURE__ */ new Map();
|
|
114
|
+
for (const [name, baseURL] of Object.entries(BUILTIN_REGISTRY_DEFINITIONS)) {
|
|
115
|
+
registryMap.set(name, {
|
|
116
|
+
name,
|
|
117
|
+
baseURL,
|
|
118
|
+
builtin: true
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
for (const [name, registry] of Object.entries(config.registries || {})) {
|
|
122
|
+
registryMap.set(name, {
|
|
123
|
+
name,
|
|
124
|
+
baseURL: registry.baseURL,
|
|
125
|
+
builtin: false
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const registries = Array.from(registryMap.values()).sort((left, right) => left.name.localeCompare(right.name));
|
|
129
|
+
const currentResolved = resolveRegistry(currentRegistry);
|
|
130
|
+
return registries.map((registry) => ({
|
|
131
|
+
...registry,
|
|
132
|
+
name: registry.name === currentResolved.name ? registry.name : registry.name
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
function getCurrentRegistry() {
|
|
136
|
+
const config = getConfig();
|
|
137
|
+
return config.currentRegistry || DEFAULT_REGISTRY_NAME;
|
|
138
|
+
}
|
|
139
|
+
function setCurrentRegistry(registryRef) {
|
|
140
|
+
const resolved = ensureRegistry(registryRef);
|
|
141
|
+
const config = getConfig();
|
|
142
|
+
config.currentRegistry = resolved.name;
|
|
143
|
+
saveConfig(config);
|
|
144
|
+
return resolved;
|
|
145
|
+
}
|
|
146
|
+
function getRegistryConfig(name) {
|
|
147
|
+
const config = getConfig();
|
|
148
|
+
return config.registries?.[name] || null;
|
|
149
|
+
}
|
|
150
|
+
function ensureRegistry(registryRef) {
|
|
151
|
+
const normalizedRef = registryRef.trim();
|
|
152
|
+
if (!normalizedRef) {
|
|
153
|
+
throw new Error("Registry cannot be empty");
|
|
154
|
+
}
|
|
155
|
+
const builtinBaseURL = BUILTIN_REGISTRY_DEFINITIONS[normalizedRef];
|
|
156
|
+
if (builtinBaseURL) {
|
|
157
|
+
return {
|
|
158
|
+
name: normalizedRef,
|
|
159
|
+
baseURL: builtinBaseURL,
|
|
160
|
+
builtin: true
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const config = getConfig();
|
|
164
|
+
const existing = config.registries?.[normalizedRef];
|
|
165
|
+
if (existing) {
|
|
166
|
+
return {
|
|
167
|
+
name: normalizedRef,
|
|
168
|
+
baseURL: existing.baseURL,
|
|
169
|
+
builtin: false
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const normalizedBaseURL = normalizeRegistryBaseURL(normalizedRef);
|
|
173
|
+
for (const [name, baseURL] of Object.entries(BUILTIN_REGISTRY_DEFINITIONS)) {
|
|
174
|
+
if (normalizeRegistryBaseURL(baseURL) === normalizedBaseURL) {
|
|
175
|
+
return {
|
|
176
|
+
name,
|
|
177
|
+
baseURL,
|
|
178
|
+
builtin: true
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const inferredName = inferRegistryName(normalizedBaseURL);
|
|
183
|
+
const current = config.registries?.[inferredName];
|
|
184
|
+
const nextRegistry = {
|
|
185
|
+
baseURL: normalizedBaseURL,
|
|
186
|
+
createdAt: current?.createdAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
187
|
+
};
|
|
188
|
+
config.registries = {
|
|
189
|
+
...config.registries || {},
|
|
190
|
+
[inferredName]: nextRegistry
|
|
191
|
+
};
|
|
192
|
+
saveConfig(config);
|
|
193
|
+
return {
|
|
194
|
+
name: inferredName,
|
|
195
|
+
baseURL: normalizedBaseURL,
|
|
196
|
+
builtin: false
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function resolveRegistry(registryRef) {
|
|
200
|
+
return ensureRegistry(registryRef || getCurrentRegistry());
|
|
201
|
+
}
|
|
202
|
+
function normalizeRegistryBaseURL(value) {
|
|
203
|
+
const trimmed = value.trim();
|
|
204
|
+
if (!trimmed) {
|
|
205
|
+
throw new Error("Registry cannot be empty");
|
|
206
|
+
}
|
|
207
|
+
const withProtocol = /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
208
|
+
const parsed = new URL(withProtocol);
|
|
209
|
+
if (parsed.username || parsed.password || parsed.search || parsed.hash) {
|
|
210
|
+
throw new Error(`Unsupported registry URL: ${value}`);
|
|
211
|
+
}
|
|
212
|
+
if (parsed.pathname && parsed.pathname !== "/") {
|
|
213
|
+
throw new Error(`Registry URL must not include a path: ${value}`);
|
|
214
|
+
}
|
|
215
|
+
parsed.pathname = "";
|
|
216
|
+
return parsed.toString().replace(/\/$/, "");
|
|
217
|
+
}
|
|
218
|
+
function resolveAppBaseURL(appCode, registryRef) {
|
|
219
|
+
const resolved = resolveRegistry(registryRef);
|
|
220
|
+
const registryUrl = new URL(resolved.baseURL);
|
|
221
|
+
if (isLocalLikeHost(registryUrl.hostname)) {
|
|
222
|
+
throw new Error(`Cannot infer app URL from registry ${resolved.baseURL}; please pass --url explicitly`);
|
|
223
|
+
}
|
|
224
|
+
return `${registryUrl.protocol}//${appCode}.${registryUrl.host}`;
|
|
225
|
+
}
|
|
226
|
+
function inferRegistryBaseURLFromAppBaseURL(appBaseURL, appCode) {
|
|
227
|
+
const parsed = new URL(appBaseURL);
|
|
228
|
+
const hostnameParts = parsed.hostname.split(".");
|
|
229
|
+
if (hostnameParts.length <= 2 || isLocalLikeHost(parsed.hostname)) {
|
|
230
|
+
parsed.pathname = "";
|
|
231
|
+
return parsed.toString().replace(/\/$/, "");
|
|
232
|
+
}
|
|
233
|
+
if (appCode && parsed.hostname.startsWith(`${appCode}.`)) {
|
|
234
|
+
parsed.hostname = parsed.hostname.slice(appCode.length + 1);
|
|
235
|
+
} else {
|
|
236
|
+
parsed.hostname = hostnameParts.slice(1).join(".");
|
|
237
|
+
}
|
|
238
|
+
parsed.pathname = "";
|
|
239
|
+
return parsed.toString().replace(/\/$/, "");
|
|
240
|
+
}
|
|
101
241
|
function getBaseURL(appCode) {
|
|
102
242
|
const code = appCode || getCurrentApp();
|
|
103
243
|
if (!code) return null;
|
|
@@ -152,11 +292,29 @@ function shouldRefreshToken(appCode) {
|
|
|
152
292
|
const fiveMinutes = 5 * 60 * 1e3;
|
|
153
293
|
return expiresAt.getTime() - now.getTime() < fiveMinutes;
|
|
154
294
|
}
|
|
155
|
-
|
|
295
|
+
function inferRegistryName(baseURL) {
|
|
296
|
+
const parsed = new URL(baseURL);
|
|
297
|
+
return parsed.hostname.replace(/\./g, "-");
|
|
298
|
+
}
|
|
299
|
+
function isLocalLikeHost(hostname) {
|
|
300
|
+
if (hostname === "localhost") {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(hostname)) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
var AMASTER_CONFIG_DIR, CONFIG_FILE, DEFAULT_REGISTRY_NAME, BUILTIN_REGISTRY_DEFINITIONS;
|
|
156
309
|
var init_config = __esm({
|
|
157
310
|
"src/config.ts"() {
|
|
158
311
|
AMASTER_CONFIG_DIR = join(homedir(), ".amaster");
|
|
159
312
|
CONFIG_FILE = join(AMASTER_CONFIG_DIR, "config.json");
|
|
313
|
+
DEFAULT_REGISTRY_NAME = "helige";
|
|
314
|
+
BUILTIN_REGISTRY_DEFINITIONS = {
|
|
315
|
+
helige: "https://helige.cn",
|
|
316
|
+
"helige-int": "https://helige-int.cn"
|
|
317
|
+
};
|
|
160
318
|
}
|
|
161
319
|
});
|
|
162
320
|
|
|
@@ -2792,6 +2950,8 @@ async function initOpenClaw(options) {
|
|
|
2792
2950
|
}
|
|
2793
2951
|
addApp(options.appCode, {
|
|
2794
2952
|
baseURL: options.baseURL,
|
|
2953
|
+
registry: options.registry,
|
|
2954
|
+
registryBaseURL: options.registryBaseURL,
|
|
2795
2955
|
ossEndpoint,
|
|
2796
2956
|
initializedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2797
2957
|
});
|
|
@@ -2805,6 +2965,8 @@ async function initOpenClaw(options) {
|
|
|
2805
2965
|
{
|
|
2806
2966
|
appCode: options.appCode,
|
|
2807
2967
|
baseURL: options.baseURL,
|
|
2968
|
+
registry: options.registry || null,
|
|
2969
|
+
registryBaseURL: options.registryBaseURL || null,
|
|
2808
2970
|
ossEndpoint,
|
|
2809
2971
|
openClawDetected: false,
|
|
2810
2972
|
installedSkills: 0,
|
|
@@ -2820,6 +2982,9 @@ async function initOpenClaw(options) {
|
|
|
2820
2982
|
console.log(chalk4.blue("\n\u{1F4CB} Configuration:\n"));
|
|
2821
2983
|
console.log(` App Code: ${chalk4.green(options.appCode)}`);
|
|
2822
2984
|
console.log(` Base URL: ${chalk4.gray(options.baseURL)}`);
|
|
2985
|
+
if (options.registryBaseURL) {
|
|
2986
|
+
console.log(` Registry: ${chalk4.gray(`${options.registry || "custom"} -> ${options.registryBaseURL}`)}`);
|
|
2987
|
+
}
|
|
2823
2988
|
console.log();
|
|
2824
2989
|
}
|
|
2825
2990
|
spinner.start("Downloading skills...");
|
|
@@ -2873,12 +3038,16 @@ async function initOpenClaw(options) {
|
|
|
2873
3038
|
const config = getAppConfig(app);
|
|
2874
3039
|
return {
|
|
2875
3040
|
appCode: app,
|
|
2876
|
-
baseURL: config?.baseURL || null
|
|
3041
|
+
baseURL: config?.baseURL || null,
|
|
3042
|
+
registry: config?.registry || null,
|
|
3043
|
+
registryBaseURL: config?.registryBaseURL || null
|
|
2877
3044
|
};
|
|
2878
3045
|
});
|
|
2879
3046
|
const summary = {
|
|
2880
3047
|
appCode: options.appCode,
|
|
2881
3048
|
baseURL: options.baseURL,
|
|
3049
|
+
registry: options.registry || null,
|
|
3050
|
+
registryBaseURL: options.registryBaseURL || null,
|
|
2882
3051
|
ossEndpoint,
|
|
2883
3052
|
openClawDetected: true,
|
|
2884
3053
|
installedSkills,
|
|
@@ -3059,6 +3228,24 @@ function createAmasterClient(appCode) {
|
|
|
3059
3228
|
}
|
|
3060
3229
|
return client;
|
|
3061
3230
|
}
|
|
3231
|
+
function resolveInitBaseURL(options) {
|
|
3232
|
+
if (options.url) {
|
|
3233
|
+
const resolvedRegistry2 = resolveRegistry(
|
|
3234
|
+
options.registry || inferRegistryBaseURLFromAppBaseURL(options.url, options.appCode)
|
|
3235
|
+
);
|
|
3236
|
+
return {
|
|
3237
|
+
baseURL: options.url,
|
|
3238
|
+
registryName: resolvedRegistry2.name,
|
|
3239
|
+
registryBaseURL: resolvedRegistry2.baseURL
|
|
3240
|
+
};
|
|
3241
|
+
}
|
|
3242
|
+
const resolvedRegistry = resolveRegistry(options.registry);
|
|
3243
|
+
return {
|
|
3244
|
+
baseURL: resolveAppBaseURL(options.appCode, resolvedRegistry.name),
|
|
3245
|
+
registryName: resolvedRegistry.name,
|
|
3246
|
+
registryBaseURL: resolvedRegistry.baseURL
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3062
3249
|
var program = new Command();
|
|
3063
3250
|
program.name("amaster").description("CLI for Amaster SDK - Multi-app support for OpenClaw").version(resolveCliVersion());
|
|
3064
3251
|
program.command("apps").description("List all configured apps").addOption(createFormatOption()).action((options) => {
|
|
@@ -3069,6 +3256,8 @@ program.command("apps").description("List all configured apps").addOption(create
|
|
|
3069
3256
|
return {
|
|
3070
3257
|
appCode,
|
|
3071
3258
|
baseURL: config?.baseURL || null,
|
|
3259
|
+
registry: config?.registry || null,
|
|
3260
|
+
registryBaseURL: config?.registryBaseURL || null,
|
|
3072
3261
|
authenticated: isAuthenticated(appCode),
|
|
3073
3262
|
current: appCode === current
|
|
3074
3263
|
};
|
|
@@ -3085,6 +3274,9 @@ program.command("apps").description("List all configured apps").addOption(create
|
|
|
3085
3274
|
const prefix = app.current ? chalk4.green("\u2192 ") : " ";
|
|
3086
3275
|
console.log(`${prefix}${chalk4.bold(app.appCode)}${app.current ? chalk4.green(" (current)") : ""}`);
|
|
3087
3276
|
console.log(` ${chalk4.gray(app.baseURL || "No URL")}`);
|
|
3277
|
+
if (app.registryBaseURL) {
|
|
3278
|
+
console.log(` ${chalk4.gray(`registry: ${app.registry} -> ${app.registryBaseURL}`)}`);
|
|
3279
|
+
}
|
|
3088
3280
|
console.log(
|
|
3089
3281
|
` ${app.authenticated ? chalk4.green("\u25CF Authenticated") : chalk4.yellow("\u25CB Not authenticated")}`
|
|
3090
3282
|
);
|
|
@@ -3095,6 +3287,45 @@ program.command("apps").description("List all configured apps").addOption(create
|
|
|
3095
3287
|
}
|
|
3096
3288
|
});
|
|
3097
3289
|
});
|
|
3290
|
+
var registryCmd = program.command("registry").description("Manage addon and app registries");
|
|
3291
|
+
registryCmd.command("list").alias("ls").description("List available registries").addOption(createFormatOption()).action((options) => {
|
|
3292
|
+
const currentRegistry = getCurrentRegistry();
|
|
3293
|
+
const registries = listRegistries().map((registry) => ({
|
|
3294
|
+
...registry,
|
|
3295
|
+
current: registry.name === currentRegistry
|
|
3296
|
+
}));
|
|
3297
|
+
renderOutput(registries, {
|
|
3298
|
+
format: options.format,
|
|
3299
|
+
pretty: () => {
|
|
3300
|
+
console.log(chalk4.blue("\n\u{1F310} Registries\n"));
|
|
3301
|
+
for (const registry of registries) {
|
|
3302
|
+
const prefix = registry.current ? chalk4.green("\u2192 ") : " ";
|
|
3303
|
+
const builtin = registry.builtin ? chalk4.gray("builtin") : chalk4.gray("custom");
|
|
3304
|
+
console.log(`${prefix}${chalk4.bold(registry.name)}${registry.current ? chalk4.green(" (current)") : ""}`);
|
|
3305
|
+
console.log(` ${chalk4.gray(registry.baseURL)} ${builtin}`);
|
|
3306
|
+
}
|
|
3307
|
+
console.log();
|
|
3308
|
+
}
|
|
3309
|
+
});
|
|
3310
|
+
});
|
|
3311
|
+
registryCmd.command("use <registry>").description("Set the default registry by name or URL").addOption(createFormatOption()).action((registry, options) => {
|
|
3312
|
+
const resolved = setCurrentRegistry(registry);
|
|
3313
|
+
renderOutput(
|
|
3314
|
+
{
|
|
3315
|
+
name: resolved.name,
|
|
3316
|
+
baseURL: resolved.baseURL,
|
|
3317
|
+
builtin: resolved.builtin,
|
|
3318
|
+
current: true
|
|
3319
|
+
},
|
|
3320
|
+
{
|
|
3321
|
+
format: options.format,
|
|
3322
|
+
pretty: () => {
|
|
3323
|
+
console.log(chalk4.green(`\u2705 Now using registry: ${resolved.name}`));
|
|
3324
|
+
console.log(chalk4.gray(resolved.baseURL));
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
);
|
|
3328
|
+
});
|
|
3098
3329
|
program.command("use <app-code>").description("Set the default app for subsequent commands").addOption(createFormatOption()).action((appCode, options) => {
|
|
3099
3330
|
if (setCurrentApp(appCode)) {
|
|
3100
3331
|
renderOutput(
|
|
@@ -3114,10 +3345,17 @@ program.command("use <app-code>").description("Set the default app for subsequen
|
|
|
3114
3345
|
process.exit(1);
|
|
3115
3346
|
}
|
|
3116
3347
|
});
|
|
3117
|
-
program.command("init").description("Initialize an app for OpenClaw integration").requiredOption("--app-code <code>", "Application code (e.g., fhv94bto1)").
|
|
3348
|
+
program.command("init").description("Initialize an app for OpenClaw integration").requiredOption("--app-code <code>", "Application code (e.g., fhv94bto1)").option("--url <url>", "Base URL (e.g., https://fhv94bto1.helige.cn)").option("--registry <registry>", "Registry name or URL (default: current registry)").option("--api-key <key>", "API Key for OSS access").option("--oss-endpoint <endpoint>", "OSS endpoint").option("--force", "Reinitialize an existing app").addOption(createFormatOption()).action(async (options) => {
|
|
3349
|
+
const resolvedInit = resolveInitBaseURL({
|
|
3350
|
+
appCode: options.appCode,
|
|
3351
|
+
url: options.url,
|
|
3352
|
+
registry: options.registry
|
|
3353
|
+
});
|
|
3118
3354
|
await initOpenClaw({
|
|
3119
3355
|
appCode: options.appCode,
|
|
3120
|
-
baseURL:
|
|
3356
|
+
baseURL: resolvedInit.baseURL,
|
|
3357
|
+
registry: resolvedInit.registryName,
|
|
3358
|
+
registryBaseURL: resolvedInit.registryBaseURL,
|
|
3121
3359
|
apiKey: options.apiKey,
|
|
3122
3360
|
ossEndpoint: options.ossEndpoint,
|
|
3123
3361
|
force: options.force,
|
|
@@ -3671,6 +3909,6 @@ if (isDirectCliExecution()) {
|
|
|
3671
3909
|
);
|
|
3672
3910
|
}
|
|
3673
3911
|
|
|
3674
|
-
export { addApp, clearAuthSession, createAmasterClient, getAccessToken, getAppConfig, getAuthSession, getBaseURL, getConfig, getCurrentApp, isAuthenticated, listApps, removeApp, resolveAppCode, saveAuthSession, saveConfig, setCurrentApp, shouldRefreshToken };
|
|
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 };
|
|
3675
3913
|
//# sourceMappingURL=index.js.map
|
|
3676
3914
|
//# sourceMappingURL=index.js.map
|