@pmate/cli 0.44.6 → 0.44.7
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 +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +30 -8
- package/dist/templates/electron/agent-runtime.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -418,3 +418,9 @@ For platform actions use `--scope platform`. Platform roles can grant namespace
|
|
|
418
418
|
Root-only migration: `pmate role migration preview --json`, then `pmate role migration apply --json`. It preserves old records, migrates bindings to canonical role IDs, and records completion so revoked grants are not restored by rerunning migration.
|
|
419
419
|
|
|
420
420
|
Permission risk: H requires an admin-level role, M requires maintainer or admin, L allows dev or higher. The same role must carry the explicit scoped grant. New roles default to dev and new permissions default to H. Use `role definition update <role> --level ...` and `role permission update <permission> --risk ...`; omitted values are preserved. Root may preview/apply the one-time risk migration using `role migration preview|apply --risk-model --json`.
|
|
421
|
+
|
|
422
|
+
### Bot Profile identity
|
|
423
|
+
|
|
424
|
+
A Bot Account may own multiple application Profiles. Normal registration ensures one initial Profile; explicit `account bot profile create` adds another Profile for testing or another role. Agent execution metadata uses the selected Profile ID, not the account name.
|
|
425
|
+
|
|
426
|
+
Bot login and nickname updates accept `--profile-id 0x…`. With multiple Profiles, select the intended Profile explicitly. Login does not create a Profile or silently choose the first. The desktop Runtime editor also requires an existing canonical Bot Profile ID; plugin IDs retain their own namespace.
|
package/dist/index.d.ts
CHANGED
|
@@ -459,6 +459,7 @@ type AccountCommandArgs = {
|
|
|
459
459
|
} | {
|
|
460
460
|
type: Command.Account;
|
|
461
461
|
action: "bot-login";
|
|
462
|
+
profileId?: string;
|
|
462
463
|
app: string;
|
|
463
464
|
name: string;
|
|
464
465
|
keyFile?: string;
|
|
@@ -477,6 +478,7 @@ type AccountCommandArgs = {
|
|
|
477
478
|
} | {
|
|
478
479
|
type: Command.Account;
|
|
479
480
|
action: "bot-profile-update";
|
|
481
|
+
profileId?: string;
|
|
480
482
|
app: string;
|
|
481
483
|
name: string;
|
|
482
484
|
nickName: string;
|
package/dist/index.js
CHANGED
|
@@ -9395,6 +9395,19 @@ async function fetchProfiles(options) {
|
|
|
9395
9395
|
function resolveAuthApiBaseUrl(value) {
|
|
9396
9396
|
return (value || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || DEFAULT_AUTH_API_BASE_URL).replace(/\/+$/, "");
|
|
9397
9397
|
}
|
|
9398
|
+
function selectBotProfileId(profiles, selectedProfileId) {
|
|
9399
|
+
if (selectedProfileId) {
|
|
9400
|
+
if (!/^0x[a-f0-9]{64}$/.test(selectedProfileId) || !profiles.some((profile) => profile.id === selectedProfileId)) {
|
|
9401
|
+
throw new Error("Selected Profile does not belong to this Bot Account/application.");
|
|
9402
|
+
}
|
|
9403
|
+
return selectedProfileId;
|
|
9404
|
+
}
|
|
9405
|
+
if (profiles.length !== 1) throw new Error("Bot login requires one existing Profile or explicit --profile-id; no Profile was created.");
|
|
9406
|
+
return profiles[0].id;
|
|
9407
|
+
}
|
|
9408
|
+
async function fetchBotProfileId(options) {
|
|
9409
|
+
return selectBotProfileId(await fetchProfiles(options), options.selectedProfileId);
|
|
9410
|
+
}
|
|
9398
9411
|
|
|
9399
9412
|
// src/commands/LoginCommandHandler.ts
|
|
9400
9413
|
var AUTH_UI_BASE_URL = "https://auth.pmate.chat";
|
|
@@ -22997,11 +23010,12 @@ var AccountCommandHandler = class {
|
|
|
22997
23010
|
signature: this.signBotChallenge(challenge, privateKey)
|
|
22998
23011
|
}
|
|
22999
23012
|
);
|
|
23000
|
-
const profileId = await
|
|
23013
|
+
const profileId = await fetchBotProfileId({
|
|
23001
23014
|
token: login.token,
|
|
23002
23015
|
app: args.app,
|
|
23003
23016
|
accountId: login.session.identity.accountId,
|
|
23004
|
-
authApiBaseUrl: baseUrl2
|
|
23017
|
+
authApiBaseUrl: baseUrl2,
|
|
23018
|
+
selectedProfileId: args.profileId
|
|
23005
23019
|
});
|
|
23006
23020
|
const saved = saveLoginSession({ ...login, profileId }, args.app);
|
|
23007
23021
|
if (!args.json) {
|
|
@@ -23025,10 +23039,10 @@ var AccountCommandHandler = class {
|
|
|
23025
23039
|
return profiles2.filter((profile2) => profile2.app === args.app && profile2.account === bot.account.id);
|
|
23026
23040
|
};
|
|
23027
23041
|
const profiles = await loadProfiles();
|
|
23028
|
-
if (profiles.length !== 1) {
|
|
23042
|
+
if (args.profileId ? !profiles.some((profile2) => profile2.id === args.profileId) : profiles.length !== 1) {
|
|
23029
23043
|
throw new Error(`Expected exactly one profile for bot ${args.app}/${args.name}; found ${profiles.length}. No nickname was changed.`);
|
|
23030
23044
|
}
|
|
23031
|
-
const profile = profiles[0];
|
|
23045
|
+
const profile = args.profileId ? profiles.find((profile2) => profile2.id === args.profileId) : profiles[0];
|
|
23032
23046
|
if (!profile.id?.trim()) throw new Error("Bot profile has no valid ID. No nickname was changed.");
|
|
23033
23047
|
if (profile.nickName === args.nickName) {
|
|
23034
23048
|
this.renderJson(profile, args.json);
|
|
@@ -25688,6 +25702,7 @@ function parseAccountArgs(tokens) {
|
|
|
25688
25702
|
if (action === "list") {
|
|
25689
25703
|
let mobile;
|
|
25690
25704
|
let nickName;
|
|
25705
|
+
let profileId;
|
|
25691
25706
|
let page;
|
|
25692
25707
|
let pageSize;
|
|
25693
25708
|
let baseUrl3;
|
|
@@ -25775,6 +25790,7 @@ function parseAccountArgs(tokens) {
|
|
|
25775
25790
|
let account2;
|
|
25776
25791
|
let mobile;
|
|
25777
25792
|
let nickName;
|
|
25793
|
+
let profileId;
|
|
25778
25794
|
let baseUrl3;
|
|
25779
25795
|
let json2 = false;
|
|
25780
25796
|
while (rest.length > 0) {
|
|
@@ -25932,6 +25948,7 @@ function parseAccountArgs(tokens) {
|
|
|
25932
25948
|
let privateKey;
|
|
25933
25949
|
let newName;
|
|
25934
25950
|
let nickName;
|
|
25951
|
+
let profileId;
|
|
25935
25952
|
let role2;
|
|
25936
25953
|
let baseUrl3;
|
|
25937
25954
|
let json2 = false;
|
|
@@ -25955,6 +25972,10 @@ function parseAccountArgs(tokens) {
|
|
|
25955
25972
|
case "--public-key":
|
|
25956
25973
|
publicKey = requireValue5(rest, token);
|
|
25957
25974
|
break;
|
|
25975
|
+
case "--profile-id":
|
|
25976
|
+
profileId = requireValue5(rest, token);
|
|
25977
|
+
if (!/^0x[a-f0-9]{64}$/.test(profileId)) throw new Error("--profile-id requires a canonical PMate Profile ID");
|
|
25978
|
+
break;
|
|
25958
25979
|
case "--private-key":
|
|
25959
25980
|
privateKey = requireValue5(rest, token);
|
|
25960
25981
|
break;
|
|
@@ -25984,6 +26005,7 @@ function parseAccountArgs(tokens) {
|
|
|
25984
26005
|
throw new Error(`Unknown account bot option: ${token}`);
|
|
25985
26006
|
}
|
|
25986
26007
|
}
|
|
26008
|
+
if (profileId && botAction !== "login" && botAction !== "nickname" && !(botAction === "profile" && botProfileAction === "update")) throw new Error("--profile-id is only supported for Bot login or profile update");
|
|
25987
26009
|
if (botAction === "keygen") {
|
|
25988
26010
|
if (!app || !name) {
|
|
25989
26011
|
throw new Error("Usage: account bot keygen --app <ns:app> --name <name> [--out <path>] [--json]");
|
|
@@ -26018,7 +26040,7 @@ function parseAccountArgs(tokens) {
|
|
|
26018
26040
|
if (!app || !name || !keyFile && !privateKey) {
|
|
26019
26041
|
throw new Error("Usage: account bot login --app <ns:app> --name <name> (--key-file <path> | --private-key <key>) [--base-url <url>] [--json]");
|
|
26020
26042
|
}
|
|
26021
|
-
return { type: "account" /* Account */, action: "bot-login", app, name, keyFile, privateKey, baseUrl: baseUrl3, json: json2 };
|
|
26043
|
+
return { type: "account" /* Account */, action: "bot-login", app, name, keyFile, privateKey, baseUrl: baseUrl3, json: json2, ...profileId ? { profileId } : {} };
|
|
26022
26044
|
}
|
|
26023
26045
|
if (botAction === "nickname" || botAction === "profile" && botProfileAction === "update") {
|
|
26024
26046
|
if (!app || !name?.trim() || !nickName?.trim()) {
|
|
@@ -26027,7 +26049,7 @@ function parseAccountArgs(tokens) {
|
|
|
26027
26049
|
if (role2 || newName || keyFile || publicKey || privateKey || out) {
|
|
26028
26050
|
throw new Error("Bot profile update only accepts --app, --name, --nickname, --base-url, and --json");
|
|
26029
26051
|
}
|
|
26030
|
-
return { type: "account" /* Account */, action: "bot-profile-update", app, name, nickName: nickName.trim(), baseUrl: baseUrl3, json: json2 };
|
|
26052
|
+
return { type: "account" /* Account */, action: "bot-profile-update", app, name, nickName: nickName.trim(), baseUrl: baseUrl3, json: json2, ...profileId ? { profileId } : {} };
|
|
26031
26053
|
}
|
|
26032
26054
|
if (botAction === "profile") {
|
|
26033
26055
|
if (botProfileAction !== "create") {
|
|
@@ -27116,9 +27138,9 @@ var HELP_TEXT = [
|
|
|
27116
27138
|
` ${import_chalk4.default.gray(" bot create --app <ns:app> --name <name> (--key-file <path> | --public-key <key>) [--base-url <url>] [--json]")}`,
|
|
27117
27139
|
` ${import_chalk4.default.gray(" bot view --app <ns:app> --name <name> [--base-url <url>] [--json]")}`,
|
|
27118
27140
|
` ${import_chalk4.default.gray(" bot list --app <ns:app> [--base-url <url>] [--json]")}`,
|
|
27119
|
-
` ${import_chalk4.default.gray(" bot login --app <ns:app> --name <name> (--key-file <path> | --private-key <key>) [--base-url <url>] [--json]")}`,
|
|
27141
|
+
` ${import_chalk4.default.gray(" bot login --app <ns:app> --name <name> (--key-file <path> | --private-key <key>) [--profile-id <id>] [--base-url <url>] [--json]")}`,
|
|
27120
27142
|
` ${import_chalk4.default.gray(" bot profile create --app <ns:app> --name <name> --nickname <nickname> [--role <role>] [--base-url <url>] [--json]")}`,
|
|
27121
|
-
` ${import_chalk4.default.gray(" bot profile update --app <ns:app> --name <name> --nickname <nickname> [--base-url <url>] [--json]")}`,
|
|
27143
|
+
` ${import_chalk4.default.gray(" bot profile update --app <ns:app> --name <name> --nickname <nickname> [--profile-id <id>] [--base-url <url>] [--json]")}`,
|
|
27122
27144
|
` ${import_chalk4.default.gray(" bot nickname --app <ns:app> --name <name> --nickname <nickname> [--base-url <url>] [--json] (alias for profile update)")}`,
|
|
27123
27145
|
` ${import_chalk4.default.gray(" access-key create --app <ns:app> --name <name> [--expires-at <iso> | --expires-in <duration>] [--namespace <ns>] [--out <path>] [--base-url <url>] [--json]")}`,
|
|
27124
27146
|
` ${import_chalk4.default.gray(" access-key list [--app <ns:app>] [--namespace <ns>] [--base-url <url>] [--json]")}`,
|
|
@@ -60,7 +60,7 @@ function createAgentRuntime({ platform = process.platform, home = homedir(), exe
|
|
|
60
60
|
const base=`/v2/topics/${encodeURIComponent(scope.namespace)}/${encodeURIComponent(scope.topic)}`
|
|
61
61
|
if(method==='agents.list')return api(base+'/vega-agents')
|
|
62
62
|
if(method==='plugins.list')return api(base+'/runtime-plugins')
|
|
63
|
-
if(typeof id!=='string'
|
|
63
|
+
if(typeof id!=='string'||!(method==='plugins.configure'?/^(?:[a-z][a-z0-9-]*:)?[a-z][a-z0-9-]*$/:/^0x[a-f0-9]{64}$/).test(id)||!config||typeof config!=='object'||Array.isArray(config))throw new Error('无效配置')
|
|
64
64
|
if(Object.hasOwn(config,'expectedRevision'))throw new Error('revision 必须单独指定')
|
|
65
65
|
if(method!=='agents.create'&&(!Number.isSafeInteger(expectedRevision)||expectedRevision<1))throw new Error('更新需要 revision')
|
|
66
66
|
if(method==='agents.create'&&expectedRevision!==undefined)throw new Error('创建不能指定 revision')
|