@agentscope-ai/platform-cli 1.0.2 → 1.0.4
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 +89 -31
- package/dist/{chunk-YN3EQLE2.js → chunk-IHANUO75.js} +22 -15
- package/dist/chunk-IHANUO75.js.map +1 -0
- package/dist/{chunk-GWGNF3I7.js → chunk-OKVCMNGY.js} +22 -17
- package/dist/chunk-OKVCMNGY.js.map +1 -0
- package/dist/cli.js +111 -81
- package/dist/cli.js.map +1 -1
- package/dist/{credentials-YBXW6FP6.js → credentials-J4V4LBC5.js} +2 -2
- package/dist/{credentials-YM6GIGYX.js → credentials-KIOZKCTT.js} +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-GWGNF3I7.js.map +0 -1
- package/dist/chunk-YN3EQLE2.js.map +0 -1
- /package/dist/{credentials-YBXW6FP6.js.map → credentials-J4V4LBC5.js.map} +0 -0
- /package/dist/{credentials-YM6GIGYX.js.map → credentials-KIOZKCTT.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
CLI_VERSION,
|
|
6
6
|
DEFAULT_SCOPE,
|
|
7
7
|
PLATFORM_URL,
|
|
8
|
+
PRE_PLATFORM_URL,
|
|
8
9
|
clearCredentials,
|
|
9
10
|
credentialsFromTokenResponse,
|
|
10
11
|
getAspConfigDir,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
loadCredentials,
|
|
13
14
|
resolveConfig,
|
|
14
15
|
saveCredentials
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IHANUO75.js";
|
|
16
17
|
|
|
17
18
|
// src/cli.ts
|
|
18
19
|
import { Command } from "commander";
|
|
@@ -68,6 +69,64 @@ function maskSecrets(text) {
|
|
|
68
69
|
return text.replace(/Bearer\s+[A-Za-z0-9._-]+/gi, "Bearer [REDACTED]").replace(/"access_token"\s*:\s*"[^"]+"/gi, '"access_token":"[REDACTED]"').replace(/"refresh_token"\s*:\s*"[^"]+"/gi, '"refresh_token":"[REDACTED]"').replace(/"token"\s*:\s*"[^"]+"/gi, '"token":"[REDACTED]"');
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
// src/utils/platform.ts
|
|
73
|
+
function detectPlatformEnv(url) {
|
|
74
|
+
const normalized = url.replace(/\/$/, "");
|
|
75
|
+
if (normalized === PLATFORM_URL) return "default";
|
|
76
|
+
if (normalized === PRE_PLATFORM_URL) return "pre";
|
|
77
|
+
return "custom";
|
|
78
|
+
}
|
|
79
|
+
function formatPlatformLabel(url) {
|
|
80
|
+
const env = detectPlatformEnv(url);
|
|
81
|
+
if (env === "default") return `platform (${PLATFORM_URL})`;
|
|
82
|
+
if (env === "pre") return `pre (${PRE_PLATFORM_URL})`;
|
|
83
|
+
return url;
|
|
84
|
+
}
|
|
85
|
+
function envCommandSuffix(platformUrl) {
|
|
86
|
+
return detectPlatformEnv(platformUrl) === "pre" ? " pre" : "";
|
|
87
|
+
}
|
|
88
|
+
function loginCommandHint(platformUrl) {
|
|
89
|
+
return `Run \`asp auth login${envCommandSuffix(platformUrl)}\`.`;
|
|
90
|
+
}
|
|
91
|
+
function withPlatformUrl(config, platformUrl) {
|
|
92
|
+
return { ...config, platformUrl: platformUrl.replace(/\/$/, "") };
|
|
93
|
+
}
|
|
94
|
+
async function requireCredentials(config, targetPlatformUrl) {
|
|
95
|
+
if (config.token) {
|
|
96
|
+
return {
|
|
97
|
+
config: withPlatformUrl(config, targetPlatformUrl),
|
|
98
|
+
creds: {
|
|
99
|
+
access_token: config.token,
|
|
100
|
+
token_type: "Bearer",
|
|
101
|
+
platform_url: targetPlatformUrl
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const creds = await loadCredentials(targetPlatformUrl);
|
|
106
|
+
if (!creds?.access_token) {
|
|
107
|
+
throw new AspError("Not logged in.", {
|
|
108
|
+
code: "UNAUTHORIZED",
|
|
109
|
+
hint: loginCommandHint(targetPlatformUrl),
|
|
110
|
+
exitCode: 3
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const credsUrl = creds.platform_url.replace(/\/$/, "");
|
|
114
|
+
const targetUrl = targetPlatformUrl.replace(/\/$/, "");
|
|
115
|
+
if (credsUrl !== targetUrl) {
|
|
116
|
+
const loggedIn = formatPlatformLabel(credsUrl);
|
|
117
|
+
const target = formatPlatformLabel(targetUrl);
|
|
118
|
+
throw new AspError(`Credential environment mismatch: logged in to ${loggedIn}, command targets ${target}.`, {
|
|
119
|
+
code: "ENV_MISMATCH",
|
|
120
|
+
hint: loginCommandHint(targetUrl),
|
|
121
|
+
exitCode: 1
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
config: withPlatformUrl(config, targetUrl),
|
|
126
|
+
creds
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
71
130
|
// src/auth/session.ts
|
|
72
131
|
function isSessionInvalidError(err) {
|
|
73
132
|
if (!(err instanceof AspError)) return false;
|
|
@@ -114,7 +173,7 @@ var HttpClient = class {
|
|
|
114
173
|
return await this.doRequest(opts);
|
|
115
174
|
} catch (err) {
|
|
116
175
|
if (opts.auth !== false && !opts._retried && isSessionInvalidError(err) && !this.config.token) {
|
|
117
|
-
const creds = await loadCredentials();
|
|
176
|
+
const creds = await loadCredentials(this.config.platformUrl);
|
|
118
177
|
if (creds?.refresh_token) {
|
|
119
178
|
await refreshStoredSession(configWithPlatform(this.config, creds), creds.refresh_token, creds.platform_url);
|
|
120
179
|
return this.doRequest({ ...opts, _retried: true });
|
|
@@ -124,7 +183,7 @@ var HttpClient = class {
|
|
|
124
183
|
}
|
|
125
184
|
}
|
|
126
185
|
async doRequest(opts) {
|
|
127
|
-
const creds = opts.auth !== false && !this.config.token ? await loadCredentials() : null;
|
|
186
|
+
const creds = opts.auth !== false && !this.config.token ? await loadCredentials(this.config.platformUrl) : null;
|
|
128
187
|
const platformUrl = creds?.platform_url ?? this.config.platformUrl;
|
|
129
188
|
const prefix = opts.prefix ?? "";
|
|
130
189
|
const url = `${platformUrl}${prefix}${opts.path}`;
|
|
@@ -169,7 +228,7 @@ var HttpClient = class {
|
|
|
169
228
|
}
|
|
170
229
|
async resolveAccessToken(existing) {
|
|
171
230
|
if (this.config.token) return this.config.token;
|
|
172
|
-
const creds = existing ?? await loadCredentials();
|
|
231
|
+
const creds = existing ?? await loadCredentials(this.config.platformUrl);
|
|
173
232
|
if (!creds) return void 0;
|
|
174
233
|
if (isTokenExpired(creds) && creds.refresh_token) {
|
|
175
234
|
const refreshed = await refreshStoredSession(
|
|
@@ -351,56 +410,6 @@ function generatePkce() {
|
|
|
351
410
|
return { codeVerifier, codeChallenge, state, nonce };
|
|
352
411
|
}
|
|
353
412
|
|
|
354
|
-
// src/utils/platform.ts
|
|
355
|
-
function detectPlatformEnv(url) {
|
|
356
|
-
const normalized = url.replace(/\/$/, "");
|
|
357
|
-
if (normalized === PLATFORM_URL) return "default";
|
|
358
|
-
return "custom";
|
|
359
|
-
}
|
|
360
|
-
function formatPlatformLabel(url) {
|
|
361
|
-
const env = detectPlatformEnv(url);
|
|
362
|
-
if (env === "default") return `platform (${PLATFORM_URL})`;
|
|
363
|
-
return url;
|
|
364
|
-
}
|
|
365
|
-
function withPlatformUrl(config, platformUrl) {
|
|
366
|
-
return { ...config, platformUrl: platformUrl.replace(/\/$/, "") };
|
|
367
|
-
}
|
|
368
|
-
async function requireCredentials(config, targetPlatformUrl) {
|
|
369
|
-
if (config.token) {
|
|
370
|
-
return {
|
|
371
|
-
config: withPlatformUrl(config, targetPlatformUrl),
|
|
372
|
-
creds: {
|
|
373
|
-
access_token: config.token,
|
|
374
|
-
token_type: "Bearer",
|
|
375
|
-
platform_url: targetPlatformUrl
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
const creds = await loadCredentials();
|
|
380
|
-
if (!creds?.access_token) {
|
|
381
|
-
throw new AspError("Not logged in.", {
|
|
382
|
-
code: "UNAUTHORIZED",
|
|
383
|
-
hint: "Run `asp auth login`.",
|
|
384
|
-
exitCode: 3
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
const credsUrl = creds.platform_url.replace(/\/$/, "");
|
|
388
|
-
const targetUrl = targetPlatformUrl.replace(/\/$/, "");
|
|
389
|
-
if (credsUrl !== targetUrl) {
|
|
390
|
-
const loggedIn = formatPlatformLabel(credsUrl);
|
|
391
|
-
const target = formatPlatformLabel(targetUrl);
|
|
392
|
-
throw new AspError(`Credential environment mismatch: logged in to ${loggedIn}, command targets ${target}.`, {
|
|
393
|
-
code: "ENV_MISMATCH",
|
|
394
|
-
hint: "Run `asp auth login` for the current target platform.",
|
|
395
|
-
exitCode: 1
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
return {
|
|
399
|
-
config: withPlatformUrl(config, targetUrl),
|
|
400
|
-
creds
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
|
|
404
413
|
// src/utils/output.ts
|
|
405
414
|
import chalk from "chalk";
|
|
406
415
|
function printJson(data) {
|
|
@@ -647,9 +656,10 @@ function wantsPasswordLogin(opts) {
|
|
|
647
656
|
async function ensureBrowserLoginEnabled(config) {
|
|
648
657
|
const meta = await new CliApiClient(config).getMeta().catch(() => null);
|
|
649
658
|
if (meta?.features?.browser_pkce_login === false) {
|
|
659
|
+
const suffix = envCommandSuffix(config.platformUrl);
|
|
650
660
|
throw new AspError("Browser authorization login is not enabled on this platform.", {
|
|
651
661
|
code: "FEATURE_DISABLED",
|
|
652
|
-
hint:
|
|
662
|
+
hint: `Use \`asp auth login --password${suffix}\` instead.`
|
|
653
663
|
});
|
|
654
664
|
}
|
|
655
665
|
}
|
|
@@ -688,9 +698,10 @@ async function runLogin(config, opts) {
|
|
|
688
698
|
return;
|
|
689
699
|
}
|
|
690
700
|
if (!process.stdin.isTTY) {
|
|
701
|
+
const suffix = envCommandSuffix(config.platformUrl);
|
|
691
702
|
throw new AspError("Non-interactive login requires a login method flag.", {
|
|
692
703
|
code: "INVALID_REQUEST",
|
|
693
|
-
hint:
|
|
704
|
+
hint: `Use \`asp auth login --browser${suffix}\` or \`asp auth login --password --account <email> --pass <password>${suffix}\`.`
|
|
694
705
|
});
|
|
695
706
|
}
|
|
696
707
|
const method = await promptLoginMethod();
|
|
@@ -712,16 +723,16 @@ async function saveTokenLogin(config, token) {
|
|
|
712
723
|
}
|
|
713
724
|
async function runStatus(getConfig2) {
|
|
714
725
|
const base = getConfig2();
|
|
715
|
-
const creds = await loadCredentials();
|
|
726
|
+
const creds = await loadCredentials(base.platformUrl);
|
|
716
727
|
if (!base.token && !creds) {
|
|
717
728
|
printInfo("Not logged in.");
|
|
718
|
-
printInfo(
|
|
729
|
+
printInfo(loginCommandHint(base.platformUrl));
|
|
719
730
|
return;
|
|
720
731
|
}
|
|
721
732
|
const { config: apiConfig } = await requireCredentials(base, base.platformUrl);
|
|
722
733
|
const client = new CliApiClient(apiConfig);
|
|
723
734
|
const me = await client.getMe();
|
|
724
|
-
const latestCreds = await loadCredentials() ?? creds;
|
|
735
|
+
const latestCreds = await loadCredentials(base.platformUrl) ?? creds;
|
|
725
736
|
if (base.json) {
|
|
726
737
|
printJson({
|
|
727
738
|
logged_in: true,
|
|
@@ -756,7 +767,7 @@ async function runRefresh(getConfig2) {
|
|
|
756
767
|
if (!creds.refresh_token) {
|
|
757
768
|
throw new AspError("No refresh token available.", {
|
|
758
769
|
code: "UNAUTHORIZED",
|
|
759
|
-
hint:
|
|
770
|
+
hint: loginCommandHint(config.platformUrl),
|
|
760
771
|
exitCode: 3
|
|
761
772
|
});
|
|
762
773
|
}
|
|
@@ -766,7 +777,7 @@ async function runRefresh(getConfig2) {
|
|
|
766
777
|
async function runLogout(getConfig2) {
|
|
767
778
|
const base = getConfig2();
|
|
768
779
|
const platformUrl = base.platformUrl;
|
|
769
|
-
const creds = await loadCredentials();
|
|
780
|
+
const creds = await loadCredentials(platformUrl);
|
|
770
781
|
if (!creds) {
|
|
771
782
|
printInfo(`Not logged in to ${formatPlatformLabel(platformUrl)}.`);
|
|
772
783
|
return;
|
|
@@ -776,7 +787,7 @@ async function runLogout(getConfig2) {
|
|
|
776
787
|
await client.logout().catch(() => {
|
|
777
788
|
});
|
|
778
789
|
}
|
|
779
|
-
await clearCredentials();
|
|
790
|
+
await clearCredentials(creds.platform_url);
|
|
780
791
|
printSuccess(`Logged out from ${formatPlatformLabel(creds.platform_url)}.`);
|
|
781
792
|
}
|
|
782
793
|
async function runLogs(getConfig2, opts) {
|
|
@@ -808,7 +819,7 @@ async function runLogs(getConfig2, opts) {
|
|
|
808
819
|
}
|
|
809
820
|
function registerAuthCommands(program2, getConfig2) {
|
|
810
821
|
const auth = program2.command("auth").description("Authentication commands");
|
|
811
|
-
let login = auth.command("login").description("Log in (
|
|
822
|
+
let login = auth.command("login").description("Log in (append `pre` for pre-production, e.g. asp auth login pre)");
|
|
812
823
|
for (const [flags, desc] of LOGIN_OPTIONS) {
|
|
813
824
|
login = login.option(flags, desc);
|
|
814
825
|
}
|
|
@@ -1549,15 +1560,17 @@ async function runPublish(getConfig2, zipPath, opts) {
|
|
|
1549
1560
|
publishOpts = { ...opts, category };
|
|
1550
1561
|
}
|
|
1551
1562
|
if (useUrlMode && zipPath) {
|
|
1563
|
+
const suffix = envCommandSuffix(config.platformUrl);
|
|
1552
1564
|
throw new AspError("Do not pass zip path when using --url.", {
|
|
1553
1565
|
code: "INVALID_REQUEST",
|
|
1554
|
-
hint:
|
|
1566
|
+
hint: `Use either \`asp plugin publish ./plugin.zip${suffix}\` or \`asp plugin publish --url <url>${suffix}\`.`
|
|
1555
1567
|
});
|
|
1556
1568
|
}
|
|
1557
1569
|
if (!useUrlMode && !zipPath) {
|
|
1570
|
+
const suffix = envCommandSuffix(config.platformUrl);
|
|
1558
1571
|
throw new AspError("Zip path is required unless --url is provided.", {
|
|
1559
1572
|
code: "INVALID_REQUEST",
|
|
1560
|
-
hint:
|
|
1573
|
+
hint: `Use \`asp plugin publish ./plugin.zip${suffix}\`.`
|
|
1561
1574
|
});
|
|
1562
1575
|
}
|
|
1563
1576
|
let submission;
|
|
@@ -1575,7 +1588,6 @@ async function runPublish(getConfig2, zipPath, opts) {
|
|
|
1575
1588
|
code: "UPLOAD_URL_MISSING"
|
|
1576
1589
|
});
|
|
1577
1590
|
}
|
|
1578
|
-
printInfo("Uploading plugin zip to object storage...");
|
|
1579
1591
|
await uploadZipToSignedUrl(localSubmission.upload, fileBuffer);
|
|
1580
1592
|
localSubmission = await client.completeArtifactSubmission(localSubmission.submission_id, {
|
|
1581
1593
|
sha512,
|
|
@@ -1609,14 +1621,16 @@ async function runPublish(getConfig2, zipPath, opts) {
|
|
|
1609
1621
|
printInfo(`Initial status: ${submission.status}`);
|
|
1610
1622
|
const trackRef = publishOpts.artifactId ?? manifest?.id ?? urlPluginId ?? submission.submission_id;
|
|
1611
1623
|
if (opts.noWait) {
|
|
1612
|
-
|
|
1613
|
-
printInfo(`
|
|
1624
|
+
const envSuffix2 = envCommandSuffix(config.platformUrl);
|
|
1625
|
+
printInfo(`Track progress: asp plugin publish status ${trackRef}${envSuffix2}`);
|
|
1626
|
+
printInfo(`Show logs: asp plugin publish logs ${trackRef}${envSuffix2}`);
|
|
1614
1627
|
return;
|
|
1615
1628
|
}
|
|
1616
1629
|
if (!submission.terminal) {
|
|
1617
1630
|
printSuccess("Upload submitted successfully. Scanning continues asynchronously.");
|
|
1618
|
-
|
|
1619
|
-
printInfo(`
|
|
1631
|
+
const envSuffix2 = envCommandSuffix(config.platformUrl);
|
|
1632
|
+
printInfo(`Track progress: asp plugin publish status ${trackRef} --watch${envSuffix2}`);
|
|
1633
|
+
printInfo(`Show logs: asp plugin publish logs ${trackRef}${envSuffix2}`);
|
|
1620
1634
|
return;
|
|
1621
1635
|
}
|
|
1622
1636
|
if (submission.status === "published") {
|
|
@@ -1630,7 +1644,8 @@ async function runPublish(getConfig2, zipPath, opts) {
|
|
|
1630
1644
|
if (submission.failure?.message) {
|
|
1631
1645
|
printWarn(`Failure: ${submission.failure.message}`);
|
|
1632
1646
|
}
|
|
1633
|
-
|
|
1647
|
+
const envSuffix = envCommandSuffix(config.platformUrl);
|
|
1648
|
+
printInfo(`Inspect logs: asp plugin publish logs ${trackRef}${envSuffix}`);
|
|
1634
1649
|
}
|
|
1635
1650
|
async function runPublishStatus(getConfig2, pluginRef, opts) {
|
|
1636
1651
|
const base = getConfig2();
|
|
@@ -2147,15 +2162,17 @@ async function runPublish2(getConfig2, zipPath, opts) {
|
|
|
2147
2162
|
}
|
|
2148
2163
|
const useUrlMode = Boolean(opts.url);
|
|
2149
2164
|
if (useUrlMode && zipPath) {
|
|
2165
|
+
const suffix = envCommandSuffix(config.platformUrl);
|
|
2150
2166
|
throw new AspError("Do not pass zip path when using --url.", {
|
|
2151
2167
|
code: "INVALID_REQUEST",
|
|
2152
|
-
hint:
|
|
2168
|
+
hint: `Use either \`asp skill publish ./skill.zip${suffix}\` or \`asp skill publish --url <url>${suffix}\`.`
|
|
2153
2169
|
});
|
|
2154
2170
|
}
|
|
2155
2171
|
if (!useUrlMode && !zipPath) {
|
|
2172
|
+
const suffix = envCommandSuffix(config.platformUrl);
|
|
2156
2173
|
throw new AspError("Zip path is required unless --url is provided.", {
|
|
2157
2174
|
code: "INVALID_REQUEST",
|
|
2158
|
-
hint:
|
|
2175
|
+
hint: `Use \`asp skill publish ./skill.zip${suffix}\`.`
|
|
2159
2176
|
});
|
|
2160
2177
|
}
|
|
2161
2178
|
const manifest = useUrlMode ? void 0 : await readSkillManifestFromZip(zipPath);
|
|
@@ -2180,7 +2197,6 @@ async function runPublish2(getConfig2, zipPath, opts) {
|
|
|
2180
2197
|
code: "UPLOAD_URL_MISSING"
|
|
2181
2198
|
});
|
|
2182
2199
|
}
|
|
2183
|
-
printInfo("Uploading skill zip to object storage...");
|
|
2184
2200
|
await uploadZipToSignedUrl2(localSubmission.upload, fileBuffer);
|
|
2185
2201
|
localSubmission = await client.completeArtifactSubmission(localSubmission.submission_id, {
|
|
2186
2202
|
sha512,
|
|
@@ -2225,14 +2241,16 @@ async function runPublish2(getConfig2, zipPath, opts) {
|
|
|
2225
2241
|
printInfo(`Initial status: ${submission.status}`);
|
|
2226
2242
|
const trackRef = publishOpts.artifactId ?? urlSkillId ?? submission.submission_id;
|
|
2227
2243
|
if (opts.noWait) {
|
|
2228
|
-
|
|
2229
|
-
printInfo(`
|
|
2244
|
+
const envSuffix2 = envCommandSuffix(config.platformUrl);
|
|
2245
|
+
printInfo(`Track progress: asp skill publish status ${trackRef}${envSuffix2}`);
|
|
2246
|
+
printInfo(`Show logs: asp skill publish logs ${trackRef}${envSuffix2}`);
|
|
2230
2247
|
return;
|
|
2231
2248
|
}
|
|
2232
2249
|
if (!submission.terminal) {
|
|
2233
2250
|
printSuccess("Upload submitted successfully. Scanning continues asynchronously.");
|
|
2234
|
-
|
|
2235
|
-
printInfo(`
|
|
2251
|
+
const envSuffix2 = envCommandSuffix(config.platformUrl);
|
|
2252
|
+
printInfo(`Track progress: asp skill publish status ${trackRef} --watch${envSuffix2}`);
|
|
2253
|
+
printInfo(`Show logs: asp skill publish logs ${trackRef}${envSuffix2}`);
|
|
2236
2254
|
return;
|
|
2237
2255
|
}
|
|
2238
2256
|
if (submission.status === "published") {
|
|
@@ -2246,7 +2264,8 @@ async function runPublish2(getConfig2, zipPath, opts) {
|
|
|
2246
2264
|
if (submission.failure?.message) {
|
|
2247
2265
|
printWarn(`Failure: ${submission.failure.message}`);
|
|
2248
2266
|
}
|
|
2249
|
-
|
|
2267
|
+
const envSuffix = envCommandSuffix(config.platformUrl);
|
|
2268
|
+
printInfo(`Inspect logs: asp skill publish logs ${trackRef}${envSuffix}`);
|
|
2250
2269
|
}
|
|
2251
2270
|
async function runPublishStatus2(getConfig2, skillRef, opts) {
|
|
2252
2271
|
const base = getConfig2();
|
|
@@ -2347,9 +2366,20 @@ function registerSkillCommands(program2, getConfig2) {
|
|
|
2347
2366
|
|
|
2348
2367
|
// src/cli.ts
|
|
2349
2368
|
var globalOpts = {};
|
|
2350
|
-
|
|
2369
|
+
function preprocessArgv(argv) {
|
|
2370
|
+
const args = [...argv];
|
|
2371
|
+
let pre = false;
|
|
2372
|
+
if (args.length >= 4 && args[args.length - 1] === "pre") {
|
|
2373
|
+
pre = true;
|
|
2374
|
+
args.pop();
|
|
2375
|
+
}
|
|
2376
|
+
return { argv: args, pre };
|
|
2377
|
+
}
|
|
2378
|
+
var { argv: cliArgv, pre: trailingPre } = preprocessArgv(process.argv);
|
|
2379
|
+
var program = new Command().name("asp").description("AgentScope Platform CLI").version(CLI_VERSION).option("--platform-url <url>", "Custom Platform base URL (advanced)").option("--pre", "Target pre-production environment (https://platform-pre.agentscope.io)").option("--token <token>", "Access token (overrides stored credentials)").option("-v, --verbose", "Verbose logging").option("--json", "Output JSON").hook("preAction", (thisCommand) => {
|
|
2351
2380
|
const opts = thisCommand.opts();
|
|
2352
2381
|
globalOpts.platformUrl = opts.platformUrl;
|
|
2382
|
+
globalOpts.pre = opts.pre || trailingPre;
|
|
2353
2383
|
globalOpts.token = opts.token;
|
|
2354
2384
|
globalOpts.verbose = opts.verbose;
|
|
2355
2385
|
globalOpts.json = opts.json;
|
|
@@ -2360,7 +2390,7 @@ registerPluginCommands(program, getConfig);
|
|
|
2360
2390
|
registerSkillCommands(program, getConfig);
|
|
2361
2391
|
async function main() {
|
|
2362
2392
|
try {
|
|
2363
|
-
await program.parseAsync(
|
|
2393
|
+
await program.parseAsync(cliArgv);
|
|
2364
2394
|
} catch (err) {
|
|
2365
2395
|
if (err instanceof AspError) {
|
|
2366
2396
|
printError(`${err.message} [${err.code}]`);
|