bpmax-cli 0.1.40 → 0.1.41
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 +19 -6
- package/dist/bin.js +240 -24
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-cli/SKILL.md +2 -0
- package/skills/bpmax-project/SKILL.md +6 -4
- package/skills/bpmax-schema/SKILL.md +6 -2
package/README.md
CHANGED
|
@@ -172,12 +172,12 @@ bpmax-cli project create --profile yuanrong --flow-id 123 --format json
|
|
|
172
172
|
Use `--no-interactive` only for explicit direct-submit automation. If the target form template contains page-only behavior such as auto-init lambda scripts, serial number controls, complex selectors, uploads, rich text, or sub forms, the CLI still refuses direct submit and prints a web form handoff URL with `reason: "form_template_requires_page_handoff"`.
|
|
173
173
|
Direct `project create --body` is blocked by default because it bypasses flow form-template checks and can create an empty project shell. Use `project create --json` with a flow id/type so the CLI can detect page-only controls such as serial numbers, complex selectors, uploads, rich text, and sub forms. Only local experts should use `--unsafe-direct-create --body` for intentional legacy raw creation.
|
|
174
174
|
|
|
175
|
-
##
|
|
175
|
+
## Project search queries
|
|
176
176
|
|
|
177
|
-
Use
|
|
177
|
+
Use typed project search for high-volume reads, candidate lookup, form-field lookup, and reporting-style queries that can be expressed with the huanpingtong project list ES-mode request body. The CLI calls `POST /api/project/list`, so huanpingtong keeps API Key authentication and forwards the authenticated user context to bpmax-server project list logic:
|
|
178
178
|
|
|
179
179
|
```bash
|
|
180
|
-
bpmax-cli
|
|
180
|
+
bpmax-cli project search --profile yuanrong --body @project-search-query.json --page 1 --page-size 20 --format json
|
|
181
181
|
```
|
|
182
182
|
|
|
183
183
|
```json
|
|
@@ -192,9 +192,11 @@ bpmax-cli es project-search --profile yuanrong --body @project-list-query.json -
|
|
|
192
192
|
}
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
`bpmax-cli es project-search` remains as a compatibility alias, but new Agent/BBS scenarios should use `bpmax-cli project search`.
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
Raw Elasticsearch DTOs are intentionally not supported through `bpmax-cli project search` or `bpmax-cli es project-search`. `huanpingtong-server` does not expose `/api/project/raw-es-search` as a public endpoint, and legacy `/api/project/<id>` routing can fall through to project creation. If the payload contains a top-level `body` field, the CLI fails before sending any request.
|
|
198
|
+
|
|
199
|
+
Use a project search body instead:
|
|
198
200
|
|
|
199
201
|
```json
|
|
200
202
|
{
|
|
@@ -208,6 +210,17 @@ Use a project-list body instead:
|
|
|
208
210
|
}
|
|
209
211
|
```
|
|
210
212
|
|
|
213
|
+
## Server capabilities
|
|
214
|
+
|
|
215
|
+
Authenticated CLI API commands are gated by the huanpingtong server capability whitelist. The CLI refreshes `GET /api/cli/capabilities` after device authorization and before API commands when the local cache is missing or expired. If the current user is not granted the required capability, the CLI stops before sending the business request.
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
bpmax-cli capabilities status --profile yuanrong --format json
|
|
219
|
+
bpmax-cli capabilities refresh --profile yuanrong --format json
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Use typed commands instead of raw API calls so the capability gate can map the request to a stable capability such as `project.search`, `project.create`, `step.submit`, or `bbs.ensure`.
|
|
223
|
+
|
|
211
224
|
## Profile recipes
|
|
212
225
|
|
|
213
226
|
Profile recipes are local, profile-scoped playbooks for environment-specific BPMAX operations. They live outside project repositories under the active config directory:
|
|
@@ -305,7 +318,7 @@ bpmax-cli --config-dir <config_dir> bbs ensure <skill-key> --agent <agent> --pro
|
|
|
305
318
|
|
|
306
319
|
Use `bbs sync` when there is no local/catalog match, then check again before falling back to generic flow/project/API commands. `bbs sync` installs only the catalog skill; individual business skills are installed lazily with `bbs ensure`.
|
|
307
320
|
|
|
308
|
-
For mutating raw API calls, `bpmax-cli api` requires `--confirm-mutating` and supports `--data @file.json`. Raw API calls to `POST /project` or `POST /project/<anything>` are blocked even with `--confirm-mutating`; the only project POST allowed in raw mode is the read-style `/project/list`.
|
|
321
|
+
For mutating raw API calls, `bpmax-cli api` requires `--confirm-mutating` and supports `--data @file.json`. Raw API calls to `POST /project` or `POST /project/<anything>` are blocked even with `--confirm-mutating`; the only project POST allowed in raw mode is the read-style `/project/list`. Search projects through `bpmax-cli project search`, and create projects through `bpmax-cli project create --flow-id <id> --json <json>` so the CLI can run form-template checks and choose safe direct submit or handoff. Prefer typed commands such as `step submit` for workflow state changes.
|
|
309
322
|
|
|
310
323
|
If `aily-skillhub` is available in `PATH`, the installer also runs:
|
|
311
324
|
|
package/dist/bin.js
CHANGED
|
@@ -145,7 +145,8 @@ function resolveProfile(config, profileName) {
|
|
|
145
145
|
api_key: profile.api_key,
|
|
146
146
|
workspace: profile.workspace || DEFAULT_WORKSPACE,
|
|
147
147
|
language: profile.language || DEFAULT_LANGUAGE,
|
|
148
|
-
user: profile.user
|
|
148
|
+
user: profile.user,
|
|
149
|
+
capabilities_cache: profile.capabilities_cache
|
|
149
150
|
}
|
|
150
151
|
};
|
|
151
152
|
}
|
|
@@ -167,6 +168,106 @@ async function upsertProfile(name, nextProfile) {
|
|
|
167
168
|
|
|
168
169
|
// src/core/http.ts
|
|
169
170
|
import axios, { AxiosHeaders } from "axios";
|
|
171
|
+
|
|
172
|
+
// src/core/capabilities.ts
|
|
173
|
+
function capabilityForRequest(method, path6) {
|
|
174
|
+
const normalizedMethod = method.toUpperCase();
|
|
175
|
+
const normalizedPath = normalizePath(path6);
|
|
176
|
+
if (normalizedPath === "/cli/capabilities") {
|
|
177
|
+
return void 0;
|
|
178
|
+
}
|
|
179
|
+
if (normalizedMethod === "GET" && normalizedPath === "/user/current") return "user.current";
|
|
180
|
+
if (normalizedMethod === "GET" && normalizedPath === "/workspace/by_key") return "flow.list";
|
|
181
|
+
if (normalizedMethod === "GET" && normalizedPath === "/flow/flow_type") return "flow.list";
|
|
182
|
+
if (normalizedMethod === "GET" && normalizedPath === "/flow/options") return "flow.options";
|
|
183
|
+
if (normalizedMethod === "POST" && normalizedPath === "/flow/batch_get") return "flow.get";
|
|
184
|
+
if (normalizedMethod === "GET" && normalizedPath.startsWith("/form_template/")) return "project.create";
|
|
185
|
+
if (normalizedMethod === "POST" && normalizedPath === "/project_staging/prefill") return "project.create";
|
|
186
|
+
if (normalizedMethod === "POST" && normalizedPath === "/project/search") return "project.search";
|
|
187
|
+
if (normalizedMethod === "POST" && normalizedPath === "/project/list") return "project.list";
|
|
188
|
+
if (normalizedMethod === "POST" && normalizedPath === "/project") return "project.create";
|
|
189
|
+
if (normalizedMethod === "GET" && normalizedPath === "/project/my_step") return "project.my-step";
|
|
190
|
+
if (normalizedMethod === "GET" && /^\/project\/[^/]+$/.test(normalizedPath)) return "project.get";
|
|
191
|
+
if (normalizedMethod === "GET" && /^\/step\/[^/]+$/.test(normalizedPath)) return "step.get";
|
|
192
|
+
if (normalizedMethod === "PUT" && /^\/step\/[^/]+$/.test(normalizedPath)) return "step.submit";
|
|
193
|
+
if (normalizedMethod === "GET" && normalizedPath === "/business_skill") return "bbs.list";
|
|
194
|
+
if (normalizedMethod === "POST" && normalizedPath === "/business_skill") return "bbs.create";
|
|
195
|
+
if (normalizedMethod === "POST" && normalizedPath === "/business_skill/install_record") return "bbs.ensure";
|
|
196
|
+
if (normalizedMethod === "GET" && /^\/business_skill\/[^/]+$/.test(normalizedPath)) return "bbs.show";
|
|
197
|
+
if (normalizedMethod === "POST" && /^\/business_skill\/[^/]+\/versions$/.test(normalizedPath)) return "bbs.upgrade";
|
|
198
|
+
if (normalizedMethod === "GET" && /^\/business_skill\/[^/]+\/download$/.test(normalizedPath)) return "bbs.ensure";
|
|
199
|
+
return "api.raw";
|
|
200
|
+
}
|
|
201
|
+
async function refreshCapabilities(client, profile, now = /* @__PURE__ */ new Date()) {
|
|
202
|
+
const response = await client.request({
|
|
203
|
+
method: "GET",
|
|
204
|
+
url: "/api/cli/capabilities"
|
|
205
|
+
});
|
|
206
|
+
const body = response.data;
|
|
207
|
+
if (typeof body.code === "number" && body.code !== 0) {
|
|
208
|
+
throw new Error(body.msg || `Capabilities probe failed with code ${body.code}`);
|
|
209
|
+
}
|
|
210
|
+
const data = body.data ?? body;
|
|
211
|
+
const ttlSeconds = typeof data.ttl_seconds === "number" ? data.ttl_seconds : 300;
|
|
212
|
+
const cache = {
|
|
213
|
+
version: data.version ?? 1,
|
|
214
|
+
generated_at: data.generated_at,
|
|
215
|
+
ttl_seconds: ttlSeconds,
|
|
216
|
+
fetched_at: now.toISOString(),
|
|
217
|
+
expires_at: new Date(now.getTime() + ttlSeconds * 1e3).toISOString(),
|
|
218
|
+
capabilities: Array.isArray(data.capabilities) ? data.capabilities : []
|
|
219
|
+
};
|
|
220
|
+
await updateProfileCapabilities(profile.name, cache);
|
|
221
|
+
return cache;
|
|
222
|
+
}
|
|
223
|
+
async function ensureCapability(client, profile, capabilityName) {
|
|
224
|
+
if (!capabilityName) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
let cache = profile.config.capabilities_cache;
|
|
228
|
+
if (!capabilityEnabled(cache, capabilityName)) {
|
|
229
|
+
cache = await refreshCapabilities(client, profile);
|
|
230
|
+
profile.config.capabilities_cache = cache;
|
|
231
|
+
}
|
|
232
|
+
if (!capabilityEnabled(cache, capabilityName)) {
|
|
233
|
+
throw new Error(`bpmax-cli capability "${capabilityName}" is not allowed for profile "${profile.name}". Refresh succeeded but the server did not grant this capability.`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function capabilityEnabled(cache, capabilityName, now = /* @__PURE__ */ new Date()) {
|
|
237
|
+
if (!cache || Date.parse(cache.expires_at) <= now.getTime()) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
return cache.capabilities.some((item) => item.name === capabilityName && item.enabled === true);
|
|
241
|
+
}
|
|
242
|
+
async function updateProfileCapabilities(profileName, cache) {
|
|
243
|
+
const config = await loadConfig();
|
|
244
|
+
const profile = config.profiles[profileName];
|
|
245
|
+
if (!profile) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
config.profiles[profileName] = {
|
|
249
|
+
...profile,
|
|
250
|
+
capabilities_cache: cache
|
|
251
|
+
};
|
|
252
|
+
await saveConfig(config);
|
|
253
|
+
}
|
|
254
|
+
function normalizePath(path6) {
|
|
255
|
+
let normalized = path6.split("?")[0] || "/";
|
|
256
|
+
if (!normalized.startsWith("/")) {
|
|
257
|
+
normalized = `/${normalized}`;
|
|
258
|
+
}
|
|
259
|
+
normalized = normalized.replace(/\/+/g, "/");
|
|
260
|
+
if (normalized.startsWith("/api/")) {
|
|
261
|
+
normalized = normalized.slice(4);
|
|
262
|
+
}
|
|
263
|
+
if (normalized.length > 1) {
|
|
264
|
+
normalized = normalized.replace(/\/+$/g, "");
|
|
265
|
+
}
|
|
266
|
+
return normalized;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/core/http.ts
|
|
270
|
+
var clientProfiles = /* @__PURE__ */ new WeakMap();
|
|
170
271
|
var ensureApiPath = (path6) => {
|
|
171
272
|
if (!path6.startsWith("/")) {
|
|
172
273
|
path6 = `/${path6}`;
|
|
@@ -176,15 +277,24 @@ var ensureApiPath = (path6) => {
|
|
|
176
277
|
}
|
|
177
278
|
return `/api${path6}`;
|
|
178
279
|
};
|
|
280
|
+
function normalizeWorkspaceForApi(workspace) {
|
|
281
|
+
const normalized = workspace?.trim();
|
|
282
|
+
if (!normalized) {
|
|
283
|
+
return normalized;
|
|
284
|
+
}
|
|
285
|
+
return normalized.startsWith("w:") ? normalized.slice(2) : normalized;
|
|
286
|
+
}
|
|
179
287
|
function createApiClient(profile) {
|
|
180
288
|
const instance = axios.create({
|
|
181
289
|
baseURL: profile.config.origin,
|
|
182
290
|
withCredentials: false
|
|
183
291
|
});
|
|
292
|
+
clientProfiles.set(instance, profile);
|
|
184
293
|
instance.interceptors.request.use((config) => {
|
|
294
|
+
const workspaceParam = config.params?.$workspace ?? profile.config.workspace;
|
|
185
295
|
config.params = {
|
|
186
296
|
...config.params || {},
|
|
187
|
-
$workspace:
|
|
297
|
+
$workspace: normalizeWorkspaceForApi(String(workspaceParam)),
|
|
188
298
|
$language: config.params?.$language ?? profile.config.language
|
|
189
299
|
};
|
|
190
300
|
if (profile.config.api_key) {
|
|
@@ -197,6 +307,10 @@ function createApiClient(profile) {
|
|
|
197
307
|
return instance;
|
|
198
308
|
}
|
|
199
309
|
async function apiRequest(client, method, path6, options = {}) {
|
|
310
|
+
const profile = clientProfiles.get(client);
|
|
311
|
+
if (profile) {
|
|
312
|
+
await ensureCapability(client, profile, options.capability ?? capabilityForRequest(method, path6));
|
|
313
|
+
}
|
|
200
314
|
const response = await client.request({
|
|
201
315
|
method,
|
|
202
316
|
url: ensureApiPath(path6),
|
|
@@ -347,7 +461,7 @@ function assertRawApiPathAllowed(method, path6) {
|
|
|
347
461
|
return;
|
|
348
462
|
}
|
|
349
463
|
throw new Error(
|
|
350
|
-
`Raw API ${method} ${path6} is blocked because /api/project/<id> falls back to project creation in huanpingtong-server. Do not call /project/es-search or /project/raw-es-search; huanpingtong-server does not expose those as public ES APIs. Use bpmax-cli project create --flow-id <id> --json <json> for project creation, or bpmax-cli
|
|
464
|
+
`Raw API ${method} ${path6} is blocked because /api/project/<id> falls back to project creation in huanpingtong-server. Do not call /project/es-search or /project/raw-es-search; huanpingtong-server does not expose those as public ES APIs. Use bpmax-cli project create --flow-id <id> --json <json> for project creation, or bpmax-cli project search / project list for project reads.`
|
|
351
465
|
);
|
|
352
466
|
}
|
|
353
467
|
function registerApiCommands(program2) {
|
|
@@ -366,7 +480,9 @@ function registerApiCommands(program2) {
|
|
|
366
480
|
}
|
|
367
481
|
const config = await loadConfig();
|
|
368
482
|
const profile = resolveProfile(config, options.profile);
|
|
369
|
-
const
|
|
483
|
+
const client = createApiClient(profile);
|
|
484
|
+
await ensureCapability(client, profile, "api.raw");
|
|
485
|
+
const result = await apiRequest(client, normalizedMethod, path6, {
|
|
370
486
|
params: options.params ? await parseJsonInput(options.params, "--params") : void 0,
|
|
371
487
|
data: await parseJsonAny(options.data, "--data")
|
|
372
488
|
});
|
|
@@ -631,6 +747,7 @@ function registerAuthCommands(program2, deps = {}) {
|
|
|
631
747
|
const browserLogin = deps.browserLogin || runBrowserLogin;
|
|
632
748
|
const startDevice = deps.startDeviceLogin || startDeviceLogin;
|
|
633
749
|
const completeDevice = deps.completeDeviceLogin || completeDeviceLogin;
|
|
750
|
+
const shouldProbeCapabilities = !deps.loadConfig && !deps.saveConfig;
|
|
634
751
|
const auth = program2.command("auth").description("Authenticate and manage API key state");
|
|
635
752
|
auth.command("login").description("Authorize and persist the returned API key").option("--profile <profile>", "Profile name").option("--key-name <keyName>", "Target API key name", "bpmax-cli").option("--mode <mode>", "Login mode: browser | device", "browser").option("--agent <agent>", "Agent adapter for device mode", "generic").option("--channel <channel>", "Interaction channel for device mode", "terminal").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
636
753
|
const config = await load();
|
|
@@ -666,12 +783,23 @@ function registerAuthCommands(program2, deps = {}) {
|
|
|
666
783
|
}
|
|
667
784
|
config.profiles[profile.name] = updateProfileAuth(config.profiles[profile.name], result);
|
|
668
785
|
await save(config);
|
|
786
|
+
let capabilitiesProbe;
|
|
787
|
+
if (shouldProbeCapabilities) {
|
|
788
|
+
try {
|
|
789
|
+
const authenticatedProfile = resolveProfile(await loadConfig(), profile.name);
|
|
790
|
+
const cache = await refreshCapabilities(createApiClient(authenticatedProfile), authenticatedProfile);
|
|
791
|
+
capabilitiesProbe = { status: "ok", count: cache.capabilities.filter((item) => item.enabled).length };
|
|
792
|
+
} catch (error) {
|
|
793
|
+
capabilitiesProbe = { status: "failed", error: error instanceof Error ? error.message : String(error) };
|
|
794
|
+
}
|
|
795
|
+
}
|
|
669
796
|
if (options.format === "json") {
|
|
670
797
|
printResult("json", {
|
|
671
798
|
ok: true,
|
|
672
799
|
profile: profile.name,
|
|
673
800
|
login: "authenticated",
|
|
674
801
|
user: result.user,
|
|
802
|
+
...capabilitiesProbe ? { capabilities_probe: capabilitiesProbe } : {},
|
|
675
803
|
...authorization ? {
|
|
676
804
|
authorization,
|
|
677
805
|
message_card: buildAuthorizationMessageCard({
|
|
@@ -711,11 +839,22 @@ function registerAuthCommands(program2, deps = {}) {
|
|
|
711
839
|
});
|
|
712
840
|
config.profiles[profile.name] = updateProfileAuth(config.profiles[profile.name], result);
|
|
713
841
|
await save(config);
|
|
842
|
+
let capabilitiesProbe;
|
|
843
|
+
if (shouldProbeCapabilities) {
|
|
844
|
+
try {
|
|
845
|
+
const authenticatedProfile = resolveProfile(await loadConfig(), profile.name);
|
|
846
|
+
const cache = await refreshCapabilities(createApiClient(authenticatedProfile), authenticatedProfile);
|
|
847
|
+
capabilitiesProbe = { status: "ok", count: cache.capabilities.filter((item) => item.enabled).length };
|
|
848
|
+
} catch (error) {
|
|
849
|
+
capabilitiesProbe = { status: "failed", error: error instanceof Error ? error.message : String(error) };
|
|
850
|
+
}
|
|
851
|
+
}
|
|
714
852
|
printResult(options.format, {
|
|
715
853
|
ok: true,
|
|
716
854
|
profile: profile.name,
|
|
717
855
|
login: "authenticated",
|
|
718
|
-
user: result.user
|
|
856
|
+
user: result.user,
|
|
857
|
+
...capabilitiesProbe ? { capabilities_probe: capabilitiesProbe } : {}
|
|
719
858
|
});
|
|
720
859
|
});
|
|
721
860
|
auth.command("status").description("Show saved auth state and validate /api/user/current").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
@@ -766,7 +905,7 @@ import { readFile as readFile5 } from "fs/promises";
|
|
|
766
905
|
// package.json
|
|
767
906
|
var package_default = {
|
|
768
907
|
name: "bpmax-cli",
|
|
769
|
-
version: "0.1.
|
|
908
|
+
version: "0.1.41",
|
|
770
909
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
771
910
|
type: "module",
|
|
772
911
|
bin: {
|
|
@@ -1000,15 +1139,16 @@ var knownBpmCommands = {
|
|
|
1000
1139
|
api: null,
|
|
1001
1140
|
auth: /* @__PURE__ */ new Set(["login", "status", "logout", "device"]),
|
|
1002
1141
|
bbs: /* @__PURE__ */ new Set(["list", "show", "create", "upgrade", "sync", "ensure", "install", "update", "uninstall", "lint", "gate"]),
|
|
1142
|
+
capabilities: /* @__PURE__ */ new Set(["status", "refresh"]),
|
|
1003
1143
|
config: null,
|
|
1004
1144
|
es: /* @__PURE__ */ new Set(["project-search"]),
|
|
1005
1145
|
flow: /* @__PURE__ */ new Set(["list", "options", "get"]),
|
|
1006
1146
|
init: null,
|
|
1007
|
-
project: /* @__PURE__ */ new Set(["list", "get", "my-step", "approval-context", "create"]),
|
|
1147
|
+
project: /* @__PURE__ */ new Set(["list", "search", "get", "my-step", "approval-context", "create"]),
|
|
1008
1148
|
recipe: /* @__PURE__ */ new Set(["list", "show", "run", "scaffold"]),
|
|
1009
1149
|
schema: /* @__PURE__ */ new Set(["list", "show"]),
|
|
1010
1150
|
setup: null,
|
|
1011
|
-
step: /* @__PURE__ */ new Set(["get"]),
|
|
1151
|
+
step: /* @__PURE__ */ new Set(["get", "context", "actions", "requirements", "submit"]),
|
|
1012
1152
|
update: null,
|
|
1013
1153
|
url: /* @__PURE__ */ new Set(["workspace", "project-create", "project-list", "project-detail", "project-step"]),
|
|
1014
1154
|
user: /* @__PURE__ */ new Set(["current"])
|
|
@@ -1682,6 +1822,30 @@ function registerBbsCommands(program2) {
|
|
|
1682
1822
|
});
|
|
1683
1823
|
}
|
|
1684
1824
|
|
|
1825
|
+
// src/commands/capabilities.ts
|
|
1826
|
+
function registerCapabilitiesCommands(program2) {
|
|
1827
|
+
const capabilities = program2.command("capabilities").description("Inspect bpmax-cli server capability whitelist");
|
|
1828
|
+
capabilities.command("status").description("Show cached server capabilities for a profile").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
1829
|
+
const profile = resolveProfile(await loadConfig(), options.profile);
|
|
1830
|
+
printResult(options.format, {
|
|
1831
|
+
profile: profile.name,
|
|
1832
|
+
origin: profile.config.origin,
|
|
1833
|
+
workspace: profile.config.workspace,
|
|
1834
|
+
capabilities_cache: profile.config.capabilities_cache || null
|
|
1835
|
+
});
|
|
1836
|
+
});
|
|
1837
|
+
capabilities.command("refresh").description("Refresh server capabilities for a profile").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
1838
|
+
const profile = resolveProfile(await loadConfig(), options.profile);
|
|
1839
|
+
const cache = await refreshCapabilities(createApiClient(profile), profile);
|
|
1840
|
+
printResult(options.format, {
|
|
1841
|
+
profile: profile.name,
|
|
1842
|
+
origin: profile.config.origin,
|
|
1843
|
+
workspace: profile.config.workspace,
|
|
1844
|
+
capabilities_cache: cache
|
|
1845
|
+
});
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1685
1849
|
// src/commands/config.ts
|
|
1686
1850
|
import { text } from "@clack/prompts";
|
|
1687
1851
|
async function ensureValue(current, label, placeholder) {
|
|
@@ -1764,22 +1928,27 @@ function registerConfigCommands(program2) {
|
|
|
1764
1928
|
});
|
|
1765
1929
|
}
|
|
1766
1930
|
|
|
1767
|
-
// src/
|
|
1931
|
+
// src/core/project-search.ts
|
|
1768
1932
|
function isRecord3(value) {
|
|
1769
1933
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1770
1934
|
}
|
|
1771
1935
|
function hasRawProjectSearchBody(value) {
|
|
1772
1936
|
return isRecord3(value) && Object.prototype.hasOwnProperty.call(value, "body");
|
|
1773
1937
|
}
|
|
1938
|
+
function assertProjectSearchBody(value) {
|
|
1939
|
+
if (hasRawProjectSearchBody(value)) {
|
|
1940
|
+
throw new Error(
|
|
1941
|
+
"Raw ES DTO with top-level body is not supported through huanpingtong-server. Use bpmax-cli project search so the CLI calls /api/project/list ES mode. /api/project/raw-es-search is not exposed by huanpingtong-server and legacy /api/project/<id> routing can create projects."
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
// src/commands/es.ts
|
|
1774
1947
|
function registerEsCommands(program2) {
|
|
1775
1948
|
const es = program2.command("es").description("Fast ES-backed data queries");
|
|
1776
|
-
es.command("project-search").description("
|
|
1949
|
+
es.command("project-search").description("Compatibility alias for project search through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number for project-list payloads", "1").option("--page-size <pageSize>", "Page size for project-list payloads", "20").requiredOption("--body <json>", "Project list body JSON or @file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
1777
1950
|
const body = await parseJsonInput(options.body, "--body");
|
|
1778
|
-
|
|
1779
|
-
throw new Error(
|
|
1780
|
-
"Raw ES DTO with top-level body is not supported through huanpingtong-server. Use a project-list body with bpmax-cli es project-search so the CLI calls /api/project/list. /api/project/raw-es-search is not exposed by huanpingtong-server and legacy /api/project/<id> routing can create projects."
|
|
1781
|
-
);
|
|
1782
|
-
}
|
|
1951
|
+
assertProjectSearchBody(body);
|
|
1783
1952
|
const config = await loadConfig();
|
|
1784
1953
|
const profile = resolveProfile(config, options.profile);
|
|
1785
1954
|
const client = createApiClient(profile);
|
|
@@ -1793,7 +1962,8 @@ function registerEsCommands(program2) {
|
|
|
1793
1962
|
page_size: Number(options.pageSize)
|
|
1794
1963
|
},
|
|
1795
1964
|
data: body,
|
|
1796
|
-
preserveErrorBody: true
|
|
1965
|
+
preserveErrorBody: true,
|
|
1966
|
+
capability: "project.search"
|
|
1797
1967
|
}
|
|
1798
1968
|
);
|
|
1799
1969
|
printResult(options.format, result);
|
|
@@ -2085,6 +2255,7 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
2085
2255
|
const saveConfig2 = deps.saveConfig || saveConfig;
|
|
2086
2256
|
const syncSkills2 = deps.syncSkills || syncSkills;
|
|
2087
2257
|
const startDeviceLogin2 = deps.startDeviceLogin || startDeviceLogin;
|
|
2258
|
+
const shouldProbeCapabilities = !deps.loadConfig && !deps.saveConfig;
|
|
2088
2259
|
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) => {
|
|
2089
2260
|
const parsed = parseBpmUrl(options.url);
|
|
2090
2261
|
const baseProfileName = options.name || "default";
|
|
@@ -2119,6 +2290,16 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
2119
2290
|
language: options.language || DEFAULT_LANGUAGE
|
|
2120
2291
|
});
|
|
2121
2292
|
await saveConfig2(nextConfig);
|
|
2293
|
+
let capabilitiesProbe;
|
|
2294
|
+
if (shouldProbeCapabilities) {
|
|
2295
|
+
try {
|
|
2296
|
+
const profile = resolveProfile(nextConfig, profileName);
|
|
2297
|
+
const cache = await refreshCapabilities(createApiClient(profile), profile);
|
|
2298
|
+
capabilitiesProbe = { status: "ok", count: cache.capabilities.filter((item) => item.enabled).length };
|
|
2299
|
+
} catch (error) {
|
|
2300
|
+
capabilitiesProbe = { status: "failed", error: error instanceof Error ? error.message : String(error) };
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2122
2303
|
const skills = await syncSkills2(VERSION, {
|
|
2123
2304
|
force: Boolean(options.forceSkills),
|
|
2124
2305
|
agent: options.agent,
|
|
@@ -2153,6 +2334,7 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
2153
2334
|
detail: parseSkillsDetail(skills.result?.stdout),
|
|
2154
2335
|
...skills.action === "failed" ? { error: skills.result?.stderr || skills.result?.stdout } : {}
|
|
2155
2336
|
},
|
|
2337
|
+
...capabilitiesProbe ? { capabilities_probe: capabilitiesProbe } : {},
|
|
2156
2338
|
authorization,
|
|
2157
2339
|
message_card: buildAuthorizationMessageCard({
|
|
2158
2340
|
...authorization,
|
|
@@ -3165,6 +3347,27 @@ async function buildApprovalContext(client, projectId, options) {
|
|
|
3165
3347
|
}
|
|
3166
3348
|
function registerProjectCommands(program2) {
|
|
3167
3349
|
const project = program2.command("project").description("Project commands");
|
|
3350
|
+
project.command("search").description("Search projects through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").requiredOption("--body <json>", "Project search body JSON or @file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
3351
|
+
const body = await parseJsonInput(options.body, "--body");
|
|
3352
|
+
assertProjectSearchBody(body);
|
|
3353
|
+
const config = await loadConfig();
|
|
3354
|
+
const profile = resolveProfile(config, options.profile);
|
|
3355
|
+
const result = await apiRequest(
|
|
3356
|
+
createApiClient(profile),
|
|
3357
|
+
"POST",
|
|
3358
|
+
"/project/list",
|
|
3359
|
+
{
|
|
3360
|
+
params: {
|
|
3361
|
+
page: Number(options.page),
|
|
3362
|
+
page_size: Number(options.pageSize)
|
|
3363
|
+
},
|
|
3364
|
+
data: body,
|
|
3365
|
+
preserveErrorBody: true,
|
|
3366
|
+
capability: "project.search"
|
|
3367
|
+
}
|
|
3368
|
+
);
|
|
3369
|
+
printResult(options.format, result);
|
|
3370
|
+
});
|
|
3168
3371
|
project.command("list").description("List projects").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--body <json>", "Project list body JSON", "{}").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
3169
3372
|
const config = await loadConfig();
|
|
3170
3373
|
const profile = resolveProfile(config, options.profile);
|
|
@@ -3726,14 +3929,19 @@ function registerRecipeCommands(program2, deps = {}) {
|
|
|
3726
3929
|
|
|
3727
3930
|
// src/core/manifest.ts
|
|
3728
3931
|
var schemaEntries = [
|
|
3729
|
-
{ name: "
|
|
3932
|
+
{ name: "capabilities.status", description: "Show cached server capability whitelist.", bootstrap: true },
|
|
3933
|
+
{ name: "capabilities.refresh", description: "Refresh server capability whitelist.", method: "GET", path: "/api/cli/capabilities", bootstrap: true },
|
|
3934
|
+
{ name: "auth.login", description: "Open hpt-frontend bridge page and persist API key locally.", bootstrap: true },
|
|
3730
3935
|
{ name: "auth.status", description: "Show current profile status and validate /api/user/current." },
|
|
3731
|
-
{ name: "auth.logout", description: "Clear the saved API key for the selected profile." },
|
|
3936
|
+
{ name: "auth.logout", description: "Clear the saved API key for the selected profile.", bootstrap: true },
|
|
3937
|
+
{ name: "auth.device.start", description: "Start device authorization.", method: "POST", path: "/api/cli/device_authorizations", bootstrap: true },
|
|
3938
|
+
{ name: "auth.device.complete", description: "Complete device authorization.", method: "POST", path: "/api/cli/device_token", bootstrap: true },
|
|
3732
3939
|
{ name: "user.current", description: "Get current user.", method: "GET", path: "/api/user/current" },
|
|
3733
3940
|
{ name: "flow.list", description: "List flows.", method: "GET", path: "/api/flow/flow_type" },
|
|
3734
3941
|
{ name: "flow.options", description: "List flow options.", method: "GET", path: "/api/flow/options" },
|
|
3735
3942
|
{ name: "flow.get", description: "Fetch flow details by id.", method: "POST", path: "/api/flow/batch_get" },
|
|
3736
|
-
{ name: "
|
|
3943
|
+
{ name: "project.search", description: "Search projects through huanpingtong /api/project/list ES mode.", method: "POST", path: "/api/project/list" },
|
|
3944
|
+
{ name: "es.project-search", description: "Compatibility alias for project.search; uses huanpingtong /api/project/list ES mode.", method: "POST", path: "/api/project/list" },
|
|
3737
3945
|
{ name: "project.list", description: "List projects.", method: "POST", path: "/api/project/list" },
|
|
3738
3946
|
{ name: "project.get", description: "Get project detail.", method: "GET", path: "/api/project/:id" },
|
|
3739
3947
|
{ name: "project.my-step", description: "List my pending steps.", method: "GET", path: "/api/project/my_step" },
|
|
@@ -3745,10 +3953,17 @@ var schemaEntries = [
|
|
|
3745
3953
|
{ name: "step.requirements", description: "List required step inputs before submitting.", method: "GET", path: "/api/project/:id + /api/step/:id" },
|
|
3746
3954
|
{ name: "step.submit", description: "Dry-run or submit a step action with safety checks.", method: "PUT", path: "/api/step/:id?action=:action" },
|
|
3747
3955
|
{ name: "bbs.list", description: "List BPMAX Business Skills.", method: "GET", path: "/api/business_skill" },
|
|
3956
|
+
{ name: "bbs.show", description: "Show a BPMAX Business Skill.", method: "GET", path: "/api/business_skill/:id" },
|
|
3748
3957
|
{ name: "bbs.create", description: "Create a BPMAX Business Skill from a standard skill zip.", method: "POST", path: "/api/business_skill" },
|
|
3749
|
-
{ name: "bbs.
|
|
3750
|
-
{ name: "bbs.
|
|
3751
|
-
{ name: "bbs.ensure", description: "Install or update a BPMAX Business Skill lazily before use." }
|
|
3958
|
+
{ name: "bbs.upgrade", description: "Publish a BPMAX Business Skill version.", method: "POST", path: "/api/business_skill/:id/versions" },
|
|
3959
|
+
{ name: "bbs.sync", description: "Sync BPMAX Business Skill catalog.", method: "GET", path: "/api/business_skill" },
|
|
3960
|
+
{ name: "bbs.ensure", description: "Install or update a BPMAX Business Skill lazily before use.", method: "GET", path: "/api/business_skill/:id/download + /api/business_skill/install_record" },
|
|
3961
|
+
{ name: "bbs.install", description: "Install a BPMAX Business Skill.", method: "GET", path: "/api/business_skill/:id/download + /api/business_skill/install_record" },
|
|
3962
|
+
{ name: "bbs.update", description: "Update a BPMAX Business Skill.", method: "GET", path: "/api/business_skill/:id/download + /api/business_skill/install_record" },
|
|
3963
|
+
{ name: "bbs.uninstall", description: "Uninstall a BPMAX Business Skill.", method: "POST", path: "/api/business_skill/install_record" },
|
|
3964
|
+
{ name: "bbs.lint", description: "Lint a BPMAX Business Skill package before publish.", bootstrap: true },
|
|
3965
|
+
{ name: "bbs.gate", description: "Run a BPMAX Business Skill business preflight or verify gate.", bootstrap: true },
|
|
3966
|
+
{ name: "api.raw", description: "Call raw BPMAX API paths allowed by server capability whitelist.", method: "*", path: "/api/*" }
|
|
3752
3967
|
];
|
|
3753
3968
|
|
|
3754
3969
|
// src/commands/schema.ts
|
|
@@ -4168,8 +4383,8 @@ function checkCurrentUserCanProcess(step, currentUser) {
|
|
|
4168
4383
|
}
|
|
4169
4384
|
async function buildStepContext(profile, client, stepId, projectId) {
|
|
4170
4385
|
const [project, step, currentUser] = await Promise.all([
|
|
4171
|
-
apiRequest(client, "GET", `/project/${projectId}
|
|
4172
|
-
apiRequest(client, "GET", `/step/${stepId}
|
|
4386
|
+
apiRequest(client, "GET", `/project/${projectId}`, { capability: "step.context" }),
|
|
4387
|
+
apiRequest(client, "GET", `/step/${stepId}`, { capability: "step.context" }),
|
|
4173
4388
|
apiRequest(client, "GET", "/user/current").catch(() => null)
|
|
4174
4389
|
]);
|
|
4175
4390
|
const actualProjectId = projectIdOfStep(step);
|
|
@@ -4882,6 +5097,7 @@ program.hook("preAction", (thisCommand) => {
|
|
|
4882
5097
|
setConfigDir(options.configDir);
|
|
4883
5098
|
});
|
|
4884
5099
|
registerConfigCommands(program);
|
|
5100
|
+
registerCapabilitiesCommands(program);
|
|
4885
5101
|
registerAuthCommands(program);
|
|
4886
5102
|
registerBbsCommands(program);
|
|
4887
5103
|
registerApiCommands(program);
|