bpmax-cli 0.1.33 → 0.1.34

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 CHANGED
@@ -29,10 +29,13 @@ bpmax-cli init \
29
29
  --agent openclaw \
30
30
  --channel feishu \
31
31
  --url https://example.com/w:store_mgr \
32
- --name retail \
32
+ --name local \
33
+ --profile-scope "<TRUSTED_RUNTIME_SCOPE>" \
33
34
  --format json
34
35
  ```
35
36
 
37
+ For OpenClaw multi-user deployments, `TRUSTED_RUNTIME_SCOPE` must come from trusted runtime metadata such as channel + peer/user, or at least a stable user id. The LLM should not invent it, and follow-up commands must use the returned `profile`.
38
+
36
39
  The command saves the profile, syncs bundled skills for the selected agent adapter, and returns a `message_card` with:
37
40
 
38
41
  - `authorization_url`
@@ -242,9 +245,11 @@ After installation, the script prints an agent-oriented guide. The recommended a
242
245
  2. Initialize bpmax-cli for the current agent:
243
246
 
244
247
  ```bash
245
- bpmax-cli init --agent <agent> --channel feishu --url "<USER_URL>" --name local --format json
248
+ bpmax-cli init --agent <agent> --channel feishu --url "<USER_URL>" --name local --profile-scope "<TRUSTED_RUNTIME_SCOPE>" --format json
246
249
  ```
247
250
 
251
+ For OpenClaw multi-user deployments, `TRUSTED_RUNTIME_SCOPE` must come from trusted runtime metadata such as channel + peer/user, or at least a stable user id. Do not ask the LLM to invent this value. The final profile name is the `profile` returned by `init`; do not reuse `local` for follow-up commands.
252
+
248
253
  3. Show `message_card.authorization_url` and `message_card.user_code` to the user, then run `message_card.next_command` exactly after the user confirms the code.
249
254
 
250
255
  For local terminal/browser setup, `bpmax-cli setup "<USER_URL>" --name local` remains available.
package/dist/bin.js CHANGED
@@ -6,6 +6,7 @@ import { Command } from "commander";
6
6
  // src/core/config.ts
7
7
  import { homedir } from "os";
8
8
  import { mkdir, readFile, writeFile } from "fs/promises";
9
+ import { createHash } from "crypto";
9
10
  import path from "path";
10
11
 
11
12
  // src/core/setup-guide.ts
@@ -84,6 +85,14 @@ function getConfigDir() {
84
85
  function getProfileDataDir(profileName) {
85
86
  return path.join(CONFIG_DIR, "profiles", profileName);
86
87
  }
88
+ function hashProfileScope(scope) {
89
+ return createHash("sha256").update(scope.trim()).digest("hex").slice(0, 12);
90
+ }
91
+ function scopedProfileName(baseProfile, agent, scope) {
92
+ const safeBase = baseProfile.trim().replace(/[^a-zA-Z0-9._-]+/g, "_") || "default";
93
+ const safeAgent = agent.trim().replace(/[^a-zA-Z0-9._-]+/g, "_") || "generic";
94
+ return `${safeBase}__${safeAgent}__${hashProfileScope(scope)}`;
95
+ }
87
96
  function maskApiKey(apiKey) {
88
97
  if (!apiKey) {
89
98
  return "(unset)";
@@ -665,7 +674,7 @@ async function parseJsonInput(input, label = "JSON input") {
665
674
  // package.json
666
675
  var package_default = {
667
676
  name: "bpmax-cli",
668
- version: "0.1.33",
677
+ version: "0.1.34",
669
678
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
670
679
  type: "module",
671
680
  bin: {
@@ -827,7 +836,7 @@ function attachProjectDetailUrl(profile, value) {
827
836
 
828
837
  // src/core/business-skills.ts
829
838
  import { cp, mkdir as mkdir2, readFile as readFile3, rm, stat, writeFile as writeFile2 } from "fs/promises";
830
- import { createHash } from "crypto";
839
+ import { createHash as createHash2 } from "crypto";
831
840
  import { homedir as homedir2, tmpdir } from "os";
832
841
  import path2 from "path";
833
842
  import { setTimeout as delay } from "timers/promises";
@@ -1304,7 +1313,7 @@ async function downloadBusinessSkillPackage(profile, download) {
1304
1313
  responseType: "arraybuffer"
1305
1314
  })).data
1306
1315
  );
1307
- const checksum = createHash("sha256").update(buffer).digest("hex");
1316
+ const checksum = createHash2("sha256").update(buffer).digest("hex");
1308
1317
  if (download.checksum && checksum !== download.checksum) {
1309
1318
  throw new Error(`BBS checksum mismatch. expected ${download.checksum}, got ${checksum}`);
1310
1319
  }
@@ -1363,7 +1372,7 @@ async function buildCatalogSkill(skills) {
1363
1372
  await writeFile2(path2.join(dir, "SKILL.md"), body, "utf8");
1364
1373
  return {
1365
1374
  dir,
1366
- checksum: createHash("sha256").update(body).digest("hex")
1375
+ checksum: createHash2("sha256").update(body).digest("hex")
1367
1376
  };
1368
1377
  }
1369
1378
 
@@ -1913,14 +1922,39 @@ function parseSkillsDetail(stdout) {
1913
1922
  return void 0;
1914
1923
  }
1915
1924
  }
1925
+ var SHARED_OPENCLAW_PROFILES = /* @__PURE__ */ new Set(["default", "local"]);
1926
+ var OPENCLAW_SCOPE_REQUIRED_MESSAGE = 'OpenClaw multi-user initialization with shared profile names "local" or "default" requires --profile-scope from trusted runtime metadata.';
1927
+ function isSharedOpenClawProfile(agent, profileName) {
1928
+ return agent === "openclaw" && SHARED_OPENCLAW_PROFILES.has(profileName);
1929
+ }
1916
1930
  function registerInitCommand(program2, deps = {}) {
1917
1931
  const loadConfig2 = deps.loadConfig || loadConfig;
1918
1932
  const saveConfig2 = deps.saveConfig || saveConfig;
1919
1933
  const syncSkills2 = deps.syncSkills || syncSkills;
1920
1934
  const startDeviceLogin2 = deps.startDeviceLogin || startDeviceLogin;
1921
- program2.command("init").description("Initialize bpmax-cli for browserless agent environments").requiredOption("--url <url>", "Full BPMAX workspace URL, for example https://example.com/w:store_mgr").option("--name <name>", "Profile name", "default").option("--agent <agent>", "Agent adapter: openclaw | aily | codex | claude | gemini | generic", "generic").option("--channel <channel>", "Interaction channel: feishu | terminal | json", "json").option("--key-name <keyName>", "Target API key name", "bpmax-cli").option("--language <language>", "Default language", DEFAULT_LANGUAGE).option("--force-skills", "Force skills reinstall").option("--format <format>", "Output format", "pretty").action(async (options) => {
1935
+ program2.command("init").description("Initialize bpmax-cli for browserless agent environments").requiredOption("--url <url>", "Full BPMAX workspace URL, for example https://example.com/w:store_mgr").option("--name <name>", "Profile name", "default").option("--profile-scope <scope>", "Trusted runtime scope for agent-user profile isolation").option("--agent <agent>", "Agent adapter: openclaw | aily | codex | claude | gemini | generic", "generic").option("--channel <channel>", "Interaction channel: feishu | terminal | json", "json").option("--key-name <keyName>", "Target API key name", "bpmax-cli").option("--language <language>", "Default language", DEFAULT_LANGUAGE).option("--force-skills", "Force skills reinstall").option("--format <format>", "Output format", "pretty").action(async (options) => {
1922
1936
  const parsed = parseBpmUrl(options.url);
1923
- const profileName = options.name || "default";
1937
+ const baseProfileName = options.name || "default";
1938
+ if (isSharedOpenClawProfile(options.agent, baseProfileName) && !options.profileScope?.trim()) {
1939
+ if (options.format === "json") {
1940
+ printResult("json", {
1941
+ ok: false,
1942
+ error: {
1943
+ code: "profile_scope_required",
1944
+ message: OPENCLAW_SCOPE_REQUIRED_MESSAGE,
1945
+ agent: options.agent,
1946
+ base_profile: baseProfileName,
1947
+ requires: "--profile-scope"
1948
+ }
1949
+ });
1950
+ process.exitCode = 1;
1951
+ return;
1952
+ }
1953
+ throw new Error(OPENCLAW_SCOPE_REQUIRED_MESSAGE);
1954
+ }
1955
+ const profileScope = options.profileScope?.trim();
1956
+ const profileName = profileScope ? scopedProfileName(baseProfileName, options.agent, profileScope) : baseProfileName;
1957
+ const profileScopeHash = profileScope ? hashProfileScope(profileScope) : void 0;
1924
1958
  const config = await loadConfig2();
1925
1959
  const nextConfig = applySetupProfile(config, profileName, {
1926
1960
  origin: parsed.origin,
@@ -1943,6 +1977,11 @@ function registerInitCommand(program2, deps = {}) {
1943
1977
  printResult(options.format, {
1944
1978
  ok: true,
1945
1979
  profile: profileName,
1980
+ ...profileScope ? {
1981
+ base_profile: baseProfileName,
1982
+ profile_isolated: true,
1983
+ profile_scope_hash: profileScopeHash
1984
+ } : {},
1946
1985
  origin: parsed.origin,
1947
1986
  workspace: parsed.workspace,
1948
1987
  agent: options.agent,