bpmax-cli 0.1.44-beta.14 → 0.1.44-beta.16
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/dist/bin.js +698 -105
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-ai-taskbook/SKILL.md +3 -0
- package/skills/bpmax-approval-matrix/SKILL.md +87 -0
- package/skills/bpmax-cli/SKILL.md +2 -0
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +3 -0
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +8 -8
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +11 -3
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +4 -4
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +4 -4
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +4 -4
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +4 -4
- package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +2 -2
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +3 -3
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +6 -4
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +11 -11
- package/skills/bpmax-flow-template-editor/SKILL.md +1 -1
- package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +3 -3
- package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +7 -4
- package/skills/bpmax-form-template-editor/SKILL.md +14 -9
- package/skills/bpmax-project/SKILL.md +8 -1
- package/skills/form-control-library/references/form-controls.md +37 -37
package/dist/bin.js
CHANGED
|
@@ -337,6 +337,7 @@ function capabilityForRequest(method, path11) {
|
|
|
337
337
|
if (normalizedMethod === "PUT" && /^\/configuration\/[^/]+$/.test(normalizedPath)) return "config.nav_config.submit";
|
|
338
338
|
if (normalizedMethod === "DELETE" && /^\/configuration\/[^/]+$/.test(normalizedPath)) return "config.nav_config.delete";
|
|
339
339
|
if (normalizedMethod === "POST" && normalizedPath === "/project_staging/prefill") return "project.create";
|
|
340
|
+
if (normalizedMethod === "GET" && /^\/project_staging\/prefill\/[^/]+$/.test(normalizedPath)) return "project.create";
|
|
340
341
|
if (normalizedMethod === "POST" && normalizedPath === "/project/search") return "project.search";
|
|
341
342
|
if (normalizedMethod === "POST" && normalizedPath === "/project/list") return "project.list";
|
|
342
343
|
if (normalizedMethod === "POST" && normalizedPath === "/project") return "project.create";
|
|
@@ -448,7 +449,7 @@ function normalizePath2(path11) {
|
|
|
448
449
|
// package.json
|
|
449
450
|
var package_default = {
|
|
450
451
|
name: "bpmax-cli",
|
|
451
|
-
version: "0.1.44-beta.
|
|
452
|
+
version: "0.1.44-beta.16",
|
|
452
453
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
453
454
|
type: "module",
|
|
454
455
|
bin: {
|
|
@@ -2917,6 +2918,23 @@ function numericId(value) {
|
|
|
2917
2918
|
}
|
|
2918
2919
|
return void 0;
|
|
2919
2920
|
}
|
|
2921
|
+
var UUID_VALUE_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
2922
|
+
function isUuidValue(value) {
|
|
2923
|
+
return UUID_VALUE_PATTERN.test(value.trim());
|
|
2924
|
+
}
|
|
2925
|
+
function assertNotLocalUuidConfigId(domain, id, action) {
|
|
2926
|
+
if (!isUuidValue(id)) {
|
|
2927
|
+
return;
|
|
2928
|
+
}
|
|
2929
|
+
if (domain === "form-template") {
|
|
2930
|
+
throw new Error(
|
|
2931
|
+
`Refusing to ${action} form-template local UUID ${id}. This is a local config mirror id, not an editable remote draft id; read the real published form id from flow meta.form_template, then export it so bpmax-cli can point you to the draft id.`
|
|
2932
|
+
);
|
|
2933
|
+
}
|
|
2934
|
+
throw new Error(
|
|
2935
|
+
`Refusing to ${action} ${domain} local UUID ${id}. BPMAX config writes must use platform-returned numeric ids or flow<number> ids.`
|
|
2936
|
+
);
|
|
2937
|
+
}
|
|
2920
2938
|
function formTemplateDetail(value) {
|
|
2921
2939
|
if (isRecord3(value) && isRecord3(value.data)) {
|
|
2922
2940
|
return value.data;
|
|
@@ -3003,11 +3021,19 @@ function summarizeOperationPlan(payload) {
|
|
|
3003
3021
|
];
|
|
3004
3022
|
}
|
|
3005
3023
|
function diffJsonNormalized(domain, before, after) {
|
|
3024
|
+
return diffJsonComparable(
|
|
3025
|
+
domain,
|
|
3026
|
+
before,
|
|
3027
|
+
after,
|
|
3028
|
+
(value) => buildDomainSubmitPayload(domain, value)
|
|
3029
|
+
);
|
|
3030
|
+
}
|
|
3031
|
+
function diffJsonComparable(domain, before, after, normalize) {
|
|
3006
3032
|
let beforeComparable;
|
|
3007
3033
|
let afterComparable;
|
|
3008
3034
|
try {
|
|
3009
|
-
beforeComparable =
|
|
3010
|
-
afterComparable =
|
|
3035
|
+
beforeComparable = normalize(before);
|
|
3036
|
+
afterComparable = normalize(after);
|
|
3011
3037
|
} catch {
|
|
3012
3038
|
beforeComparable = before;
|
|
3013
3039
|
afterComparable = after;
|
|
@@ -3950,6 +3976,19 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
3950
3976
|
payload.source_field = source.field ?? source.sourceField ?? source.source_field ?? "";
|
|
3951
3977
|
payload.source_fk = source.fk ?? source.sourceFk ?? source.source_fk ?? "";
|
|
3952
3978
|
}
|
|
3979
|
+
payload.sourceTable = payload.source_table;
|
|
3980
|
+
payload.sourceField = payload.source_field;
|
|
3981
|
+
payload.sourceFk = payload.source_fk;
|
|
3982
|
+
if (mode === "create") {
|
|
3983
|
+
const missingSource = [
|
|
3984
|
+
["source_table", payload.source_table],
|
|
3985
|
+
["source_field", payload.source_field],
|
|
3986
|
+
["source_fk", payload.source_fk]
|
|
3987
|
+
].filter(([, value]) => typeof value !== "string" || value.trim() === "");
|
|
3988
|
+
if (missingSource.length > 0) {
|
|
3989
|
+
throw new Error(`dataset-field create requires source mapping fields: ${missingSource.map(([key]) => key).join(", ")}.`);
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3953
3992
|
const advanced = isRecord3(work.advanced) ? work.advanced : {};
|
|
3954
3993
|
if (Object.prototype.hasOwnProperty.call(advanced, "sourceComputed")) {
|
|
3955
3994
|
payload.source_computed = normalizeOptionalText(advanced.sourceComputed);
|
|
@@ -4028,6 +4067,13 @@ function refreshSettingToSubmit(value) {
|
|
|
4028
4067
|
}
|
|
4029
4068
|
var FORM_RULE_ID_KEYS = /* @__PURE__ */ new Set(["form_rule_id", "form_template_id", "id"]);
|
|
4030
4069
|
var FORM_VALUE_ID_KEYS = /* @__PURE__ */ new Set(["template_id", "id"]);
|
|
4070
|
+
var FORM_TEMPLATE_SERVER_FIELD_KEYS = /* @__PURE__ */ new Set([
|
|
4071
|
+
"form_rule_id",
|
|
4072
|
+
"form_template_id",
|
|
4073
|
+
"template_id",
|
|
4074
|
+
"visibility",
|
|
4075
|
+
"visibility_scope"
|
|
4076
|
+
]);
|
|
4031
4077
|
function stripKeys(source, keys) {
|
|
4032
4078
|
const result = {};
|
|
4033
4079
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -4037,6 +4083,21 @@ function stripKeys(source, keys) {
|
|
|
4037
4083
|
}
|
|
4038
4084
|
return result;
|
|
4039
4085
|
}
|
|
4086
|
+
function stripServerFilledFields(value, keys) {
|
|
4087
|
+
if (Array.isArray(value)) {
|
|
4088
|
+
return value.map((item) => stripServerFilledFields(item, keys));
|
|
4089
|
+
}
|
|
4090
|
+
if (!isRecord3(value)) {
|
|
4091
|
+
return value;
|
|
4092
|
+
}
|
|
4093
|
+
const result = {};
|
|
4094
|
+
for (const [key, child] of Object.entries(value)) {
|
|
4095
|
+
if (!keys.has(key)) {
|
|
4096
|
+
result[key] = stripServerFilledFields(child, keys);
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
return result;
|
|
4100
|
+
}
|
|
4040
4101
|
function normalizeRemovedFields(value) {
|
|
4041
4102
|
if (!Array.isArray(value)) {
|
|
4042
4103
|
return /* @__PURE__ */ new Set();
|
|
@@ -5298,6 +5359,11 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
|
|
|
5298
5359
|
workspace,
|
|
5299
5360
|
name,
|
|
5300
5361
|
operation_plan: dryRunPlan,
|
|
5362
|
+
post_create_checklist: [
|
|
5363
|
+
"If this flow-app is an approval matrix app, create online matrix rule records separately; flow-app create only creates the app/form/flow/workspace binding.",
|
|
5364
|
+
"Verify matrix rule records contain real approver user values before connecting business flow matrix_owner or cc_matrix.",
|
|
5365
|
+
"Use bpmax-project safe project create/handoff for matrix rule records; do not treat local seed-rules.json as online data."
|
|
5366
|
+
],
|
|
5301
5367
|
next: `Run again with --confirm "${expectedConfirm}" to create.`
|
|
5302
5368
|
};
|
|
5303
5369
|
}
|
|
@@ -5430,6 +5496,41 @@ async function readBackConfigDomain(profile, domain, id, definition) {
|
|
|
5430
5496
|
readback_hash: hashJson(data)
|
|
5431
5497
|
};
|
|
5432
5498
|
}
|
|
5499
|
+
function comparableSubmitPayload(domain, value, options) {
|
|
5500
|
+
const comparable = domain === "form-template" && options.ignoreServerFields ? stripServerFilledFields(value, FORM_TEMPLATE_SERVER_FIELD_KEYS) : value;
|
|
5501
|
+
return buildDomainSubmitPayload(domain, comparable);
|
|
5502
|
+
}
|
|
5503
|
+
async function verifyConfigDomain(config, profile, domain, id, options = {}) {
|
|
5504
|
+
void config;
|
|
5505
|
+
assertNotLocalUuidConfigId(domain, id, "verify");
|
|
5506
|
+
const exported = await exportConfigDomain(
|
|
5507
|
+
config,
|
|
5508
|
+
profile,
|
|
5509
|
+
domain,
|
|
5510
|
+
id,
|
|
5511
|
+
options.outDir || `.codex/tmp/${domain}-verify`
|
|
5512
|
+
);
|
|
5513
|
+
const actual = await readJsonFile(String(exported.raw_file));
|
|
5514
|
+
const expected = options.expectFile ? await readJsonFile(options.expectFile) : void 0;
|
|
5515
|
+
const actualComparable = expected ? comparableSubmitPayload(domain, actual, options) : void 0;
|
|
5516
|
+
const expectedComparable = expected ? comparableSubmitPayload(domain, expected, options) : void 0;
|
|
5517
|
+
const ok = expected ? JSON.stringify(actualComparable) === JSON.stringify(expectedComparable) : true;
|
|
5518
|
+
const diff = expected ? diffJsonComparable(domain, expected, actual, (value) => comparableSubmitPayload(domain, value, options)) : void 0;
|
|
5519
|
+
return {
|
|
5520
|
+
domain,
|
|
5521
|
+
id,
|
|
5522
|
+
ok,
|
|
5523
|
+
compare: expected ? "normalized_submit_payload" : "readback_only",
|
|
5524
|
+
...expected ? {
|
|
5525
|
+
expected_hash: expectedComparable ? hashJson(expectedComparable) : null,
|
|
5526
|
+
actual_hash: actualComparable ? hashJson(actualComparable) : null,
|
|
5527
|
+
actual_config_hash: exported.base_hash,
|
|
5528
|
+
...domain === "form-template" && options.ignoreServerFields ? { ignored_server_fields: [...FORM_TEMPLATE_SERVER_FIELD_KEYS] } : {},
|
|
5529
|
+
diff
|
|
5530
|
+
} : {},
|
|
5531
|
+
exported
|
|
5532
|
+
};
|
|
5533
|
+
}
|
|
5433
5534
|
async function readRemoteConfigDomain(profile, domain, id, definition) {
|
|
5434
5535
|
if (!definition.exportPath) {
|
|
5435
5536
|
throw new Error(`Config readback is not implemented for ${domain}.`);
|
|
@@ -5466,6 +5567,8 @@ async function writeJsonFile(file, value) {
|
|
|
5466
5567
|
`, "utf8");
|
|
5467
5568
|
}
|
|
5468
5569
|
async function exportConfigDomain(config, profile, domain, id, outDir, options = {}) {
|
|
5570
|
+
void config;
|
|
5571
|
+
assertNotLocalUuidConfigId(domain, id, "export");
|
|
5469
5572
|
if (domain === "api-platform") {
|
|
5470
5573
|
const { raw, work: work2 } = await collectApiPlatformAggregate(profile, id);
|
|
5471
5574
|
const baseHash2 = hashJson(raw);
|
|
@@ -5619,6 +5722,7 @@ async function lintConfigWorkFile(file) {
|
|
|
5619
5722
|
async function submitConfigDomain(config, profile, domain, id, submitFile, confirm3, options = {}) {
|
|
5620
5723
|
void config;
|
|
5621
5724
|
const definition = CONFIG_DOMAINS[domain];
|
|
5725
|
+
assertNotLocalUuidConfigId(domain, id, "submit");
|
|
5622
5726
|
if (domain === "workspace-flow") {
|
|
5623
5727
|
if (definition.submitStatus !== "supported") {
|
|
5624
5728
|
throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
|
|
@@ -5642,6 +5746,11 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
5642
5746
|
throw new Error(`Config submit metadata profile mismatch. Expected ${profile.name}, got ${String(meta2.profile)}.`);
|
|
5643
5747
|
}
|
|
5644
5748
|
const createMode = meta2.mode === "create";
|
|
5749
|
+
if (typeof submit2.base_hash !== "string") {
|
|
5750
|
+
throw new Error(
|
|
5751
|
+
"workspace-flow submit requires a current base_hash from export/build because /workspace/workspace_flow is a full replacement API. Re-export current workspace-flow, merge new bindings, rebuild, then submit."
|
|
5752
|
+
);
|
|
5753
|
+
}
|
|
5645
5754
|
await ensureConfigCapability(profile, `${definition.capability}.${createMode ? "create" : "submit"}`);
|
|
5646
5755
|
const workspace = normalizeWorkspaceKey(String(submit2.payload.workspace || id));
|
|
5647
5756
|
const metaWorkspace = normalizeWorkspaceKey(String(meta2.workspace || meta2.id || ""));
|
|
@@ -5651,7 +5760,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
5651
5760
|
const endpoint2 = "/workspace/workspace_flow";
|
|
5652
5761
|
const submitPayload2 = { workspace_flow: normalizeWorkspaceFlowItems(submit2.payload.workspace_flow) };
|
|
5653
5762
|
const current2 = await readRemoteConfigDomain(profile, domain, workspace, definition);
|
|
5654
|
-
if (
|
|
5763
|
+
if (hashJson(current2) !== submit2.base_hash) {
|
|
5655
5764
|
throw new Error("Remote config changed after export. Re-export before submitting.");
|
|
5656
5765
|
}
|
|
5657
5766
|
const expectedConfirm2 = `submit ${domain} ${id}`;
|
|
@@ -6078,6 +6187,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
6078
6187
|
async function deleteConfigDomain(config, profile, domain, id, confirm3) {
|
|
6079
6188
|
void config;
|
|
6080
6189
|
const definition = CONFIG_DOMAINS[domain];
|
|
6190
|
+
assertNotLocalUuidConfigId(domain, id, "delete");
|
|
6081
6191
|
if (domain === "workspace-flow") {
|
|
6082
6192
|
return deleteWorkspaceFlowBinding(profile, id, confirm3);
|
|
6083
6193
|
}
|
|
@@ -6969,6 +7079,51 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
6969
7079
|
}
|
|
6970
7080
|
|
|
6971
7081
|
// src/commands/config.ts
|
|
7082
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7083
|
+
function stringValue(value) {
|
|
7084
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
7085
|
+
}
|
|
7086
|
+
function arrayValue(value) {
|
|
7087
|
+
return Array.isArray(value) ? value : [];
|
|
7088
|
+
}
|
|
7089
|
+
function flowTemplateNodes(work) {
|
|
7090
|
+
const data = isRecord4(work.data) ? work.data : void 0;
|
|
7091
|
+
return arrayValue(data?.nodes).filter(isRecord4);
|
|
7092
|
+
}
|
|
7093
|
+
function summarizeFlowTemplateWork(work) {
|
|
7094
|
+
if (!isRecord4(work)) {
|
|
7095
|
+
return { available: false, reason: "flow-template work file is not a JSON object" };
|
|
7096
|
+
}
|
|
7097
|
+
const data = isRecord4(work.data) ? work.data : {};
|
|
7098
|
+
const meta = isRecord4(data.meta) ? data.meta : {};
|
|
7099
|
+
const nodes = flowTemplateNodes(work);
|
|
7100
|
+
const matrixOwnerNodes = nodes.filter((node) => JSON.stringify(node).includes("matrix_owner")).map((node) => ({
|
|
7101
|
+
id: stringValue(node.id),
|
|
7102
|
+
name: stringValue(node.name),
|
|
7103
|
+
type: stringValue(node.type)
|
|
7104
|
+
}));
|
|
7105
|
+
const ccMatrixNodes = nodes.filter((node) => JSON.stringify(node).includes("cc_matrix")).map((node) => ({
|
|
7106
|
+
id: stringValue(node.id),
|
|
7107
|
+
name: stringValue(node.name),
|
|
7108
|
+
type: stringValue(node.type)
|
|
7109
|
+
}));
|
|
7110
|
+
const publish = isRecord4(work.publish) ? work.publish : void 0;
|
|
7111
|
+
return {
|
|
7112
|
+
available: true,
|
|
7113
|
+
name: stringValue(work.name),
|
|
7114
|
+
flow_type: stringValue(work.flow_type),
|
|
7115
|
+
key: stringValue(work.key) ?? "",
|
|
7116
|
+
type: stringValue(work.type),
|
|
7117
|
+
status: work.status,
|
|
7118
|
+
publish_status: publish?.status ?? work.publish_status,
|
|
7119
|
+
meta_form_id: work.meta_form_id ?? meta.form_template,
|
|
7120
|
+
node_count: nodes.length,
|
|
7121
|
+
matrix_owner_node_count: matrixOwnerNodes.length,
|
|
7122
|
+
matrix_owner_nodes: matrixOwnerNodes,
|
|
7123
|
+
cc_matrix_node_count: ccMatrixNodes.length,
|
|
7124
|
+
cc_matrix_nodes: ccMatrixNodes
|
|
7125
|
+
};
|
|
7126
|
+
}
|
|
6972
7127
|
async function ensureValue(current, label, placeholder) {
|
|
6973
7128
|
if (current) {
|
|
6974
7129
|
return current;
|
|
@@ -7050,7 +7205,8 @@ function registerConfigCommands(program2) {
|
|
|
7050
7205
|
user: target.user || null
|
|
7051
7206
|
});
|
|
7052
7207
|
});
|
|
7053
|
-
config.command("adapters").description("Show typed config domain adapter coverage and verified API surfaces").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
7208
|
+
config.command("adapters").description("Show typed config domain adapter coverage and verified API surfaces").option("--profile <profile>", "Profile name (accepted for consistency; adapter coverage is local and profile-independent)").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
7209
|
+
void options.profile;
|
|
7054
7210
|
printResult(options.format, configAdapterMatrix());
|
|
7055
7211
|
});
|
|
7056
7212
|
const latest = config.command("latest").description("Sync latest BPMAX sysconfig repositories");
|
|
@@ -7154,11 +7310,21 @@ function registerConfigCommands(program2) {
|
|
|
7154
7310
|
await saveConfig(configData);
|
|
7155
7311
|
printResult(options.format, result);
|
|
7156
7312
|
});
|
|
7157
|
-
domainCommand.command("export").description(`Export remote ${domain} configuration into raw/work/meta files`).requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--out <outDir>", "Output directory", `.codex/tmp/${domain}-editor`).option("--work-format <format>", "Work file format for supported domains: raw | structured", "raw").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
7313
|
+
domainCommand.command("export").description(`Export remote ${domain} configuration into raw/work/meta files`).requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--out <outDir>", "Output directory", `.codex/tmp/${domain}-editor`).option("--work-format <format>", "Work file format for supported domains: raw | structured", "raw").option("--summary", "For flow-template, include a compact configuration summary in command output").option("--inline", "For flow-template, include the exported work JSON inline in command output").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
7158
7314
|
const configData = await loadConfig();
|
|
7159
7315
|
const resolved = resolveProfile(configData, options.profile);
|
|
7160
7316
|
const workFormat = options.workFormat === "structured" ? "structured" : "raw";
|
|
7161
7317
|
const result = await exportConfigDomain(configData, resolved, domain, options.id, options.out, { workFormat });
|
|
7318
|
+
if (domain === "flow-template" && (options.summary || options.inline)) {
|
|
7319
|
+
const workFile = typeof result.work_file === "string" ? result.work_file : void 0;
|
|
7320
|
+
const work = workFile ? await readJsonFile(workFile) : void 0;
|
|
7321
|
+
if (options.summary) {
|
|
7322
|
+
result.summary = summarizeFlowTemplateWork(work);
|
|
7323
|
+
}
|
|
7324
|
+
if (options.inline) {
|
|
7325
|
+
result.work = work;
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7162
7328
|
await saveConfig(configData);
|
|
7163
7329
|
printResult(options.format, result);
|
|
7164
7330
|
});
|
|
@@ -7242,46 +7408,32 @@ function registerConfigCommands(program2) {
|
|
|
7242
7408
|
});
|
|
7243
7409
|
});
|
|
7244
7410
|
}
|
|
7245
|
-
domainCommand.command("verify").description(`Read back a ${domain} config and optionally compare with an expected JSON file`).requiredOption("--id <id>", "Remote config id").option("--expect <file>", "Expected JSON file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
7411
|
+
domainCommand.command("verify").description(`Read back a ${domain} config and optionally compare with an expected JSON file`).requiredOption("--id <id>", "Remote config id").option("--expect <file>", "Expected JSON file").option("--ignore-server-fields", "For form-template verify, ignore platform-filled system fields such as form_rule_id/template_id/visibility").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
7246
7412
|
const configData = await loadConfig();
|
|
7247
7413
|
const resolved = resolveProfile(configData, options.profile);
|
|
7248
|
-
const
|
|
7414
|
+
const result = await verifyConfigDomain(
|
|
7249
7415
|
configData,
|
|
7250
7416
|
resolved,
|
|
7251
7417
|
domain,
|
|
7252
7418
|
options.id,
|
|
7253
|
-
|
|
7419
|
+
{
|
|
7420
|
+
expectFile: options.expect,
|
|
7421
|
+
outDir: `.codex/tmp/${domain}-verify`,
|
|
7422
|
+
ignoreServerFields: Boolean(options.ignoreServerFields)
|
|
7423
|
+
}
|
|
7254
7424
|
);
|
|
7255
|
-
const actual = await readJsonFile(String(exported.raw_file));
|
|
7256
|
-
const expected = options.expect ? await readJsonFile(options.expect) : void 0;
|
|
7257
|
-
const actualComparable = expected ? buildDomainSubmitPayload(domain, actual) : void 0;
|
|
7258
|
-
const expectedComparable = expected ? buildDomainSubmitPayload(domain, expected) : void 0;
|
|
7259
|
-
const ok = expected ? JSON.stringify(actualComparable) === JSON.stringify(expectedComparable) : true;
|
|
7260
|
-
const diff = expected ? diffJsonNormalized(domain, expected, actual) : void 0;
|
|
7261
7425
|
await saveConfig(configData);
|
|
7262
|
-
printResult(options.format,
|
|
7263
|
-
domain,
|
|
7264
|
-
id: options.id,
|
|
7265
|
-
ok,
|
|
7266
|
-
compare: expected ? "normalized_submit_payload" : "readback_only",
|
|
7267
|
-
...expected ? {
|
|
7268
|
-
expected_hash: expectedComparable ? hashJson(expectedComparable) : null,
|
|
7269
|
-
actual_hash: actualComparable ? hashJson(actualComparable) : null,
|
|
7270
|
-
actual_config_hash: exported.base_hash,
|
|
7271
|
-
diff
|
|
7272
|
-
} : {},
|
|
7273
|
-
exported
|
|
7274
|
-
});
|
|
7426
|
+
printResult(options.format, result);
|
|
7275
7427
|
});
|
|
7276
7428
|
});
|
|
7277
7429
|
}
|
|
7278
7430
|
|
|
7279
7431
|
// src/core/project-search.ts
|
|
7280
|
-
function
|
|
7432
|
+
function isRecord5(value) {
|
|
7281
7433
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7282
7434
|
}
|
|
7283
7435
|
function hasRawProjectSearchBody(value) {
|
|
7284
|
-
return
|
|
7436
|
+
return isRecord5(value) && Object.prototype.hasOwnProperty.call(value, "body");
|
|
7285
7437
|
}
|
|
7286
7438
|
function assertProjectSearchBody(value) {
|
|
7287
7439
|
if (hasRawProjectSearchBody(value)) {
|
|
@@ -7782,6 +7934,194 @@ function registerMemoryCommands(program2) {
|
|
|
7782
7934
|
});
|
|
7783
7935
|
}
|
|
7784
7936
|
|
|
7937
|
+
// src/commands/matrix.ts
|
|
7938
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
7939
|
+
var UUID_VALUE_PATTERN2 = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i;
|
|
7940
|
+
var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
|
|
7941
|
+
async function parseSeedRules(input) {
|
|
7942
|
+
const source = input.startsWith("@") ? input.slice(1) : void 0;
|
|
7943
|
+
if (source === "") {
|
|
7944
|
+
throw new Error("--rules file path is empty.");
|
|
7945
|
+
}
|
|
7946
|
+
const raw = source ? await readFile9(source, "utf8") : input;
|
|
7947
|
+
let parsed;
|
|
7948
|
+
try {
|
|
7949
|
+
parsed = JSON.parse(raw);
|
|
7950
|
+
} catch (error) {
|
|
7951
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
7952
|
+
throw new Error(`--rules is not valid JSON: ${detail}`);
|
|
7953
|
+
}
|
|
7954
|
+
const rules = Array.isArray(parsed) ? parsed : [parsed];
|
|
7955
|
+
if (rules.length === 0) {
|
|
7956
|
+
throw new Error("--rules must contain at least one rule object.");
|
|
7957
|
+
}
|
|
7958
|
+
rules.forEach((rule, index) => {
|
|
7959
|
+
if (typeof rule !== "object" || rule === null || Array.isArray(rule)) {
|
|
7960
|
+
throw new Error(`--rules[${index}] must be a JSON object.`);
|
|
7961
|
+
}
|
|
7962
|
+
});
|
|
7963
|
+
return rules;
|
|
7964
|
+
}
|
|
7965
|
+
function collectUuidPaths(value, path11 = "$") {
|
|
7966
|
+
if (typeof value === "string") {
|
|
7967
|
+
return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path11] : [];
|
|
7968
|
+
}
|
|
7969
|
+
if (Array.isArray(value)) {
|
|
7970
|
+
return value.flatMap((item, index) => collectUuidPaths(item, `${path11}[${index}]`));
|
|
7971
|
+
}
|
|
7972
|
+
if (typeof value === "object" && value !== null) {
|
|
7973
|
+
return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path11}.${key}`));
|
|
7974
|
+
}
|
|
7975
|
+
return [];
|
|
7976
|
+
}
|
|
7977
|
+
function ruleForm(rule) {
|
|
7978
|
+
const form = rule.form;
|
|
7979
|
+
if (typeof form === "object" && form !== null && !Array.isArray(form)) {
|
|
7980
|
+
return form;
|
|
7981
|
+
}
|
|
7982
|
+
return rule;
|
|
7983
|
+
}
|
|
7984
|
+
function isEmptyApproverValue(value) {
|
|
7985
|
+
if (value === null || value === void 0 || value === "") {
|
|
7986
|
+
return true;
|
|
7987
|
+
}
|
|
7988
|
+
if (Array.isArray(value)) {
|
|
7989
|
+
return value.length === 0;
|
|
7990
|
+
}
|
|
7991
|
+
return false;
|
|
7992
|
+
}
|
|
7993
|
+
function shellQuote6(value) {
|
|
7994
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
7995
|
+
}
|
|
7996
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7997
|
+
function dataArray(value) {
|
|
7998
|
+
if (Array.isArray(value)) return value;
|
|
7999
|
+
if (isRecord6(value) && Array.isArray(value.data)) return value.data;
|
|
8000
|
+
return [];
|
|
8001
|
+
}
|
|
8002
|
+
function collectMatrixOwnerPaths(value, path11 = "$") {
|
|
8003
|
+
if (Array.isArray(value)) {
|
|
8004
|
+
return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path11}[${index}]`));
|
|
8005
|
+
}
|
|
8006
|
+
if (!isRecord6(value)) {
|
|
8007
|
+
return [];
|
|
8008
|
+
}
|
|
8009
|
+
const matches = [];
|
|
8010
|
+
Object.entries(value).forEach(([key, child]) => {
|
|
8011
|
+
const childPath = `${path11}.${key}`;
|
|
8012
|
+
if (key.includes("matrix_owner") || typeof child === "string" && child.includes("matrix_owner")) {
|
|
8013
|
+
matches.push({ path: childPath, value: child });
|
|
8014
|
+
}
|
|
8015
|
+
matches.push(...collectMatrixOwnerPaths(child, childPath));
|
|
8016
|
+
});
|
|
8017
|
+
return matches;
|
|
8018
|
+
}
|
|
8019
|
+
function projectFormKeys(project) {
|
|
8020
|
+
const metaForm = isRecord6(project.metaForm) ? project.metaForm : {};
|
|
8021
|
+
const values = dataArray(metaForm.value ?? project.formList);
|
|
8022
|
+
return values.filter(isRecord6).map((item) => String(item.key ?? item.field_key ?? "")).filter(Boolean);
|
|
8023
|
+
}
|
|
8024
|
+
function findFlowNode(flow, nodeId) {
|
|
8025
|
+
const data = isRecord6(flow.data) ? flow.data : {};
|
|
8026
|
+
return dataArray(data.nodes).filter(isRecord6).find((node) => String(node.id ?? node.key ?? node.flow_step_id ?? "") === nodeId);
|
|
8027
|
+
}
|
|
8028
|
+
function registerMatrixCommands(program2) {
|
|
8029
|
+
const matrix = program2.command("matrix").description("Plan and validate BPMAX approval matrix operations");
|
|
8030
|
+
matrix.command("seed <flowType>").description("Validate approval matrix seed rule records and print safe project create commands").requiredOption("--rules <jsonOrFile>", "Seed rule object/array JSON or @file").option("--profile <profile>", "Profile name").option("--approver-field <field...>", "Required approver field key(s) inside each rule form").option("--format <format>", "Output format", "pretty").action(async (flowType, options) => {
|
|
8031
|
+
const rules = await parseSeedRules(options.rules);
|
|
8032
|
+
const approverFields = options.approverField || [];
|
|
8033
|
+
const errors = [];
|
|
8034
|
+
rules.forEach((rule, index) => {
|
|
8035
|
+
collectUuidPaths(rule).forEach((uuidPath) => {
|
|
8036
|
+
errors.push({
|
|
8037
|
+
rule_index: index,
|
|
8038
|
+
code: "uuid_not_allowed",
|
|
8039
|
+
path: uuidPath,
|
|
8040
|
+
message: "UUID values are not allowed in approval matrix rule seed data."
|
|
8041
|
+
});
|
|
8042
|
+
});
|
|
8043
|
+
const form = ruleForm(rule);
|
|
8044
|
+
approverFields.forEach((field) => {
|
|
8045
|
+
if (isEmptyApproverValue(form[field])) {
|
|
8046
|
+
errors.push({
|
|
8047
|
+
rule_index: index,
|
|
8048
|
+
code: "missing_approver",
|
|
8049
|
+
path: `$.form.${field}`,
|
|
8050
|
+
message: `Approver field "${field}" must contain a real BPMAX user value before seeding matrix rules.`
|
|
8051
|
+
});
|
|
8052
|
+
}
|
|
8053
|
+
});
|
|
8054
|
+
});
|
|
8055
|
+
if (errors.length > 0) {
|
|
8056
|
+
throw new Error(`Matrix seed validation failed:
|
|
8057
|
+
${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` ${error.path}` : ""}: ${error.message}`).join("\n")}`);
|
|
8058
|
+
}
|
|
8059
|
+
const projectCreatePayloads = rules.map((rule) => ({ form: ruleForm(rule) }));
|
|
8060
|
+
const profileArgs = options.profile ? ` --profile ${shellQuote6(options.profile)}` : "";
|
|
8061
|
+
const nextCommands = projectCreatePayloads.map(
|
|
8062
|
+
(payload) => `bpmax-cli project create${profileArgs} --flow-type ${shellQuote6(flowType)} --json ${shellQuote6(JSON.stringify(payload))} --format json`
|
|
8063
|
+
);
|
|
8064
|
+
printResult(options.format, {
|
|
8065
|
+
domain: "approval-matrix",
|
|
8066
|
+
action: "seed",
|
|
8067
|
+
flow_type: flowType,
|
|
8068
|
+
dry_run: true,
|
|
8069
|
+
rule_count: rules.length,
|
|
8070
|
+
approver_fields: approverFields,
|
|
8071
|
+
project_create_payloads: projectCreatePayloads,
|
|
8072
|
+
next_commands: nextCommands,
|
|
8073
|
+
notes: [
|
|
8074
|
+
"This command does not write BPMAX project records.",
|
|
8075
|
+
"Run each project create command and follow handoff output when the form requires page runtime initialization.",
|
|
8076
|
+
"Do not use --no-interactive unless the matrix form is proven safe for direct create."
|
|
8077
|
+
]
|
|
8078
|
+
});
|
|
8079
|
+
});
|
|
8080
|
+
matrix.command("owner-resolve").description("Inspect matrix_owner configuration inputs for one flow node and project").requiredOption("--flow-type <flowType>", "Business flow type").requiredOption("--node <nodeId>", "Flow node id/key to inspect").requiredOption("--project-id <projectId>", "Runtime project id used as matrix input context").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
8081
|
+
const config = await loadConfig();
|
|
8082
|
+
const profile = resolveProfile(config, options.profile);
|
|
8083
|
+
const client = createApiClient(profile);
|
|
8084
|
+
const [project, flow] = await Promise.all([
|
|
8085
|
+
apiRequest(client, "GET", `/project/${encodeURIComponent(options.projectId)}`),
|
|
8086
|
+
apiRequest(client, "GET", "/flow", {
|
|
8087
|
+
params: {
|
|
8088
|
+
flow_type: options.flowType,
|
|
8089
|
+
draft: 0,
|
|
8090
|
+
skip_i18n: true
|
|
8091
|
+
}
|
|
8092
|
+
})
|
|
8093
|
+
]);
|
|
8094
|
+
const node = findFlowNode(flow, options.node);
|
|
8095
|
+
const matrixOwnerConfig = node ? collectMatrixOwnerPaths(node) : [];
|
|
8096
|
+
printResult(options.format, {
|
|
8097
|
+
domain: "approval-matrix",
|
|
8098
|
+
action: "owner-resolve",
|
|
8099
|
+
flow_type: options.flowType,
|
|
8100
|
+
node: options.node,
|
|
8101
|
+
project_id: options.projectId,
|
|
8102
|
+
config_found: matrixOwnerConfig.length > 0,
|
|
8103
|
+
runtime_owner_verified: false,
|
|
8104
|
+
flow_node: node ? {
|
|
8105
|
+
id: node.id,
|
|
8106
|
+
name: node.name,
|
|
8107
|
+
type: node.type
|
|
8108
|
+
} : null,
|
|
8109
|
+
matrix_owner_config: matrixOwnerConfig,
|
|
8110
|
+
project_context: {
|
|
8111
|
+
id: project.id,
|
|
8112
|
+
name: project.name,
|
|
8113
|
+
form_keys: projectFormKeys(project)
|
|
8114
|
+
},
|
|
8115
|
+
notes: [
|
|
8116
|
+
"This command is read-only and does not write matrix rule records.",
|
|
8117
|
+
"If matrix_owner_config is empty, the target node is not configured for matrix owner resolution or the node id is wrong.",
|
|
8118
|
+
"config_found only means matrix_owner-like config exists on the node; it does not prove runtime owner resolution.",
|
|
8119
|
+
"Use bpmax-cli matrix seed to validate rule seed data before creating matrix rule project records."
|
|
8120
|
+
]
|
|
8121
|
+
});
|
|
8122
|
+
});
|
|
8123
|
+
}
|
|
8124
|
+
|
|
7785
8125
|
// src/core/form-schema.ts
|
|
7786
8126
|
var FIELD_KEY_NAMES = [
|
|
7787
8127
|
"key",
|
|
@@ -7801,7 +8141,7 @@ var OPTION_NAMES = ["options", "items", "choices", "values"];
|
|
|
7801
8141
|
var REQUIRED_NAMES = ["required", "is_required", "isRequired", "require", "must", "validateRequired"];
|
|
7802
8142
|
var HIDDEN_NAMES = ["hidden", "is_hidden", "isHidden", "hide", "hideInForm"];
|
|
7803
8143
|
var VISIBLE_NAMES = ["visible", "display", "show"];
|
|
7804
|
-
function
|
|
8144
|
+
function isRecord7(value) {
|
|
7805
8145
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7806
8146
|
}
|
|
7807
8147
|
function pickString(source, keys) {
|
|
@@ -7828,10 +8168,10 @@ function pickBoolean(source, keys) {
|
|
|
7828
8168
|
}
|
|
7829
8169
|
const rules = source.rules;
|
|
7830
8170
|
if (Array.isArray(rules)) {
|
|
7831
|
-
return rules.some((rule) =>
|
|
8171
|
+
return rules.some((rule) => isRecord7(rule) && pickBoolean(rule, REQUIRED_NAMES));
|
|
7832
8172
|
}
|
|
7833
8173
|
const validateMap = source.validateMap;
|
|
7834
|
-
if (
|
|
8174
|
+
if (isRecord7(validateMap) && pickBoolean(validateMap, REQUIRED_NAMES)) {
|
|
7835
8175
|
return true;
|
|
7836
8176
|
}
|
|
7837
8177
|
return false;
|
|
@@ -7855,7 +8195,7 @@ function optionValue(option) {
|
|
|
7855
8195
|
if (typeof option === "string" || typeof option === "number") {
|
|
7856
8196
|
return String(option);
|
|
7857
8197
|
}
|
|
7858
|
-
if (!
|
|
8198
|
+
if (!isRecord7(option)) {
|
|
7859
8199
|
return null;
|
|
7860
8200
|
}
|
|
7861
8201
|
return pickString(option, ["value", "key", "id", "name", "label", "title"]) ?? null;
|
|
@@ -7920,7 +8260,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
7920
8260
|
}
|
|
7921
8261
|
return;
|
|
7922
8262
|
}
|
|
7923
|
-
if (!
|
|
8263
|
+
if (!isRecord7(value)) {
|
|
7924
8264
|
return;
|
|
7925
8265
|
}
|
|
7926
8266
|
const field = fieldFromRecord(value);
|
|
@@ -7928,7 +8268,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
7928
8268
|
if (isSubFormField(field)) {
|
|
7929
8269
|
const childFields = /* @__PURE__ */ new Map();
|
|
7930
8270
|
for (const child of Object.values(value)) {
|
|
7931
|
-
if (
|
|
8271
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
7932
8272
|
collectFieldCandidates(child, childFields, depth + 1);
|
|
7933
8273
|
}
|
|
7934
8274
|
}
|
|
@@ -7942,7 +8282,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
7942
8282
|
fields.set(field.key, mergeField(fields.get(field.key), field));
|
|
7943
8283
|
}
|
|
7944
8284
|
for (const child of Object.values(value)) {
|
|
7945
|
-
if (
|
|
8285
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
7946
8286
|
collectFieldCandidates(child, fields, depth + 1);
|
|
7947
8287
|
}
|
|
7948
8288
|
}
|
|
@@ -7960,7 +8300,7 @@ function validateComplexSelector(field, value) {
|
|
|
7960
8300
|
if (!isComplexSelectorType(type)) {
|
|
7961
8301
|
return null;
|
|
7962
8302
|
}
|
|
7963
|
-
const validObject = (item) =>
|
|
8303
|
+
const validObject = (item) => isRecord7(item);
|
|
7964
8304
|
if (Array.isArray(value)) {
|
|
7965
8305
|
return value.every(validObject) ? null : `${field.key} must contain selector option object(s), not scalar values`;
|
|
7966
8306
|
}
|
|
@@ -7976,7 +8316,7 @@ function isEnumSelectType(type) {
|
|
|
7976
8316
|
return /enum_select/.test(type);
|
|
7977
8317
|
}
|
|
7978
8318
|
function optionComparableValue(value) {
|
|
7979
|
-
if (
|
|
8319
|
+
if (isRecord7(value) && ("value" in value || "label" in value)) {
|
|
7980
8320
|
return value.value ?? value.label;
|
|
7981
8321
|
}
|
|
7982
8322
|
return value;
|
|
@@ -7990,7 +8330,7 @@ function validateType(field, value) {
|
|
|
7990
8330
|
if (!Array.isArray(value)) {
|
|
7991
8331
|
return `${field.key} must be a JSON array of row objects`;
|
|
7992
8332
|
}
|
|
7993
|
-
const invalidRowIndex = value.findIndex((row) => !
|
|
8333
|
+
const invalidRowIndex = value.findIndex((row) => !isRecord7(row));
|
|
7994
8334
|
return invalidRowIndex >= 0 ? `${field.key}[${invalidRowIndex}] must be a row object` : null;
|
|
7995
8335
|
}
|
|
7996
8336
|
const selectorError = validateComplexSelector(field, value);
|
|
@@ -8016,7 +8356,7 @@ function validateType(field, value) {
|
|
|
8016
8356
|
if (/(array|multi|multiple)/.test(type) && !Array.isArray(value)) {
|
|
8017
8357
|
return `${field.key} must be an array`;
|
|
8018
8358
|
}
|
|
8019
|
-
if (isEnumSelectType(type) &&
|
|
8359
|
+
if (isEnumSelectType(type) && isRecord7(value)) {
|
|
8020
8360
|
const optionValue2 = value.value ?? value.label;
|
|
8021
8361
|
return typeof optionValue2 === "string" || typeof optionValue2 === "number" ? null : `${field.key} must be an enum option object with a scalar value`;
|
|
8022
8362
|
}
|
|
@@ -8046,7 +8386,7 @@ function validateFormEntries(form, fields, prefix = "") {
|
|
|
8046
8386
|
}
|
|
8047
8387
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
8048
8388
|
for (const [index, row] of value.entries()) {
|
|
8049
|
-
if (
|
|
8389
|
+
if (isRecord7(row)) {
|
|
8050
8390
|
errors.push(...validateFormEntries(row, field.children, `${prefix}${field.key}[${index}].`));
|
|
8051
8391
|
}
|
|
8052
8392
|
}
|
|
@@ -8269,15 +8609,15 @@ async function promptProjectCreateForm(input) {
|
|
|
8269
8609
|
}
|
|
8270
8610
|
|
|
8271
8611
|
// src/core/project-form.ts
|
|
8272
|
-
function
|
|
8612
|
+
function isRecord8(value) {
|
|
8273
8613
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8274
8614
|
}
|
|
8275
8615
|
function clone(value) {
|
|
8276
8616
|
return JSON.parse(JSON.stringify(value));
|
|
8277
8617
|
}
|
|
8278
8618
|
function getFlowFormTemplateId(flowDetail) {
|
|
8279
|
-
const data =
|
|
8280
|
-
const meta =
|
|
8619
|
+
const data = isRecord8(flowDetail?.data) ? flowDetail.data : void 0;
|
|
8620
|
+
const meta = isRecord8(data?.meta) ? data.meta : void 0;
|
|
8281
8621
|
const templateId = meta?.form_template;
|
|
8282
8622
|
if (typeof templateId === "number" && Number.isFinite(templateId)) {
|
|
8283
8623
|
return templateId;
|
|
@@ -8302,7 +8642,7 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
8302
8642
|
if (Array.isArray(value)) {
|
|
8303
8643
|
return value.some((item) => hasAutoInitLambda(item, seen));
|
|
8304
8644
|
}
|
|
8305
|
-
if (!
|
|
8645
|
+
if (!isRecord8(value)) {
|
|
8306
8646
|
return false;
|
|
8307
8647
|
}
|
|
8308
8648
|
if (seen.has(value)) {
|
|
@@ -8317,14 +8657,14 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
8317
8657
|
function setControlValue(control, value) {
|
|
8318
8658
|
const next = clone(control);
|
|
8319
8659
|
next.value = {
|
|
8320
|
-
...
|
|
8660
|
+
...isRecord8(next.value) ? next.value : {},
|
|
8321
8661
|
type: next.value?.type ?? next.field_type,
|
|
8322
8662
|
value
|
|
8323
8663
|
};
|
|
8324
8664
|
return next;
|
|
8325
8665
|
}
|
|
8326
8666
|
function applyRowValues(rowTemplate, rowValue) {
|
|
8327
|
-
const source =
|
|
8667
|
+
const source = isRecord8(rowValue) ? rowValue : {};
|
|
8328
8668
|
return rowTemplate.map((control) => {
|
|
8329
8669
|
if (control.key && Object.prototype.hasOwnProperty.call(source, control.key)) {
|
|
8330
8670
|
return setControlValue(control, source[control.key]);
|
|
@@ -8363,12 +8703,35 @@ async function buildProjectFormPayload(client, flowDetail, form, knownTemplate)
|
|
|
8363
8703
|
}
|
|
8364
8704
|
|
|
8365
8705
|
// src/commands/project.ts
|
|
8706
|
+
function projectCreateErrorDiagnostic(error, context) {
|
|
8707
|
+
const baseMessage = error instanceof Error ? error.message : String(error || "");
|
|
8708
|
+
const response = typeof error === "object" && error !== null && "response" in error ? error.response : void 0;
|
|
8709
|
+
const status = response?.status;
|
|
8710
|
+
const body = response?.data;
|
|
8711
|
+
const bodyText = body === void 0 ? "" : typeof body === "string" ? body : JSON.stringify(body);
|
|
8712
|
+
const summary = bodyText.length > 1e3 ? `${bodyText.slice(0, 1e3)}...` : bodyText;
|
|
8713
|
+
return new Error([
|
|
8714
|
+
`Project create failed${status ? ` with status ${String(status)}` : ""}: ${baseMessage}`,
|
|
8715
|
+
`local_form_validation=${context.localFormValidation}`,
|
|
8716
|
+
`direct_body=${context.usedBody ? "true" : "false"}`,
|
|
8717
|
+
`no_interactive=${context.noInteractive ? "true" : "false"}`,
|
|
8718
|
+
`handoff_available=${context.handoffAvailable ? "true" : "false"}`,
|
|
8719
|
+
summary ? `server_error_summary=${summary}` : "",
|
|
8720
|
+
context.handoffAvailable ? "next_action=Use the generated form handoff path unless the template is proven safe for direct create." : "next_action=Check field keys/types and server error body; do not bypass with raw API."
|
|
8721
|
+
].filter(Boolean).join("\n"));
|
|
8722
|
+
}
|
|
8366
8723
|
async function parseProjectJson(input, label = "--json") {
|
|
8367
8724
|
if (!input) {
|
|
8368
8725
|
return {};
|
|
8369
8726
|
}
|
|
8370
8727
|
return parseJsonInput(input, label);
|
|
8371
8728
|
}
|
|
8729
|
+
function errorMessage2(error) {
|
|
8730
|
+
return error instanceof Error ? error.message : String(error || "");
|
|
8731
|
+
}
|
|
8732
|
+
function isUnsupportedPrefillStatusError(message) {
|
|
8733
|
+
return /(^|[^0-9])404([^0-9]|$)/.test(message) || /not found/i.test(message) || /unsupported/i.test(message) || /Cannot GET \/api\/project_staging\/prefill/i.test(message);
|
|
8734
|
+
}
|
|
8372
8735
|
async function resolveFlowIdentifiers(client, options, resolveOptions = {}) {
|
|
8373
8736
|
if (options.flowType) {
|
|
8374
8737
|
const flowKey = options.flowKey ?? "";
|
|
@@ -8590,8 +8953,8 @@ function fieldsForValidation(flowDetail, projectFormTemplate) {
|
|
|
8590
8953
|
}));
|
|
8591
8954
|
}
|
|
8592
8955
|
function metaUsesTemplateProjectName(flowDetail) {
|
|
8593
|
-
const data =
|
|
8594
|
-
const meta =
|
|
8956
|
+
const data = isRecord9(flowDetail?.data) ? flowDetail.data : void 0;
|
|
8957
|
+
const meta = isRecord9(data?.meta) ? data.meta : void 0;
|
|
8595
8958
|
const hideFields = Array.isArray(meta?.hide_fields) ? meta.hide_fields.map(String) : [];
|
|
8596
8959
|
return meta?.use_template_project_name === true || hideFields.includes("project.name");
|
|
8597
8960
|
}
|
|
@@ -8681,7 +9044,7 @@ function collectPrefillContextForFields(fields, form, result, options = {}) {
|
|
|
8681
9044
|
result.filled_fields.push(contextField(field, "prefilled", fieldOptions));
|
|
8682
9045
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
8683
9046
|
value.forEach((row, index) => {
|
|
8684
|
-
if (
|
|
9047
|
+
if (isRecord9(row)) {
|
|
8685
9048
|
collectPrefillContextForFields(field.children ?? [], row, result, {
|
|
8686
9049
|
prefix: `${field.key}[${index}]`,
|
|
8687
9050
|
rootKey: field.key,
|
|
@@ -8708,7 +9071,7 @@ function buildPrefillContext(fields, form) {
|
|
|
8708
9071
|
}
|
|
8709
9072
|
};
|
|
8710
9073
|
}
|
|
8711
|
-
function
|
|
9074
|
+
function isRecord9(value) {
|
|
8712
9075
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8713
9076
|
}
|
|
8714
9077
|
function isEndedStep(step) {
|
|
@@ -8731,7 +9094,7 @@ function stepIdOf(step) {
|
|
|
8731
9094
|
function pickStepFormPayload(step) {
|
|
8732
9095
|
const formList = Array.isArray(step.formList) ? step.formList : [];
|
|
8733
9096
|
const forms = Array.isArray(step.forms) ? step.forms : [];
|
|
8734
|
-
const metaForm =
|
|
9097
|
+
const metaForm = isRecord9(step.metaForm) ? step.metaForm : void 0;
|
|
8735
9098
|
return {
|
|
8736
9099
|
step_id: step.id,
|
|
8737
9100
|
flow_step_id: step.flow_step_id,
|
|
@@ -8748,7 +9111,7 @@ function pickStepFormPayload(step) {
|
|
|
8748
9111
|
}
|
|
8749
9112
|
async function buildApprovalContext(client, projectId, options) {
|
|
8750
9113
|
const projectDetail = await apiRequest(client, "GET", `/project/${projectId}`);
|
|
8751
|
-
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(
|
|
9114
|
+
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(isRecord9) : [];
|
|
8752
9115
|
const targetStepIds = /* @__PURE__ */ new Set();
|
|
8753
9116
|
for (const step of steps) {
|
|
8754
9117
|
const id = stepIdOf(step);
|
|
@@ -8774,7 +9137,7 @@ async function buildApprovalContext(client, projectId, options) {
|
|
|
8774
9137
|
}
|
|
8775
9138
|
return {
|
|
8776
9139
|
project: projectDetail,
|
|
8777
|
-
project_form:
|
|
9140
|
+
project_form: isRecord9(projectDetail.metaForm) ? projectDetail.metaForm : null,
|
|
8778
9141
|
inspected_step_count: stepForms.length,
|
|
8779
9142
|
step_forms: stepForms,
|
|
8780
9143
|
failed_steps: failedSteps
|
|
@@ -8830,13 +9193,14 @@ function registerProjectCommands(program2) {
|
|
|
8830
9193
|
);
|
|
8831
9194
|
printResult(options.format, attachProjectDetailUrl(profile, result));
|
|
8832
9195
|
});
|
|
8833
|
-
project.command("my-step").description("List my pending project steps").option("--profile <profile>", "Profile name").option("--finished <finished>", "Finished flag", "0").option("--flow-type <flowType>", "Flow type filter").option("--flow-key <flowKey>", "Flow key filter").option("--key-of-flow-node <keyOfFlowNode>", "Flow/node filter, e.g. flow_type:flow_key or flow_type:flow_key:node_id").option("--flow-step-id <flowStepId>", "Flow node id filter").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
9196
|
+
project.command("my-step").description("List my pending project steps").option("--profile <profile>", "Profile name").option("--finished <finished>", "Finished flag", "0").option("--flow-type <flowType>", "Flow type filter").option("--flow-key <flowKey>", "Flow key filter").option("--key-of-flow-node <keyOfFlowNode>", "Flow/node filter, e.g. flow_type:flow_key or flow_type:flow_key:node_id").option("--flow-step-id <flowStepId>", "Flow node id filter").option("--workspace <workspace>", "Workspace filter, defaults to the active profile workspace").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
8834
9197
|
const config = await loadConfig();
|
|
8835
9198
|
const profile = resolveProfile(config, options.profile);
|
|
8836
9199
|
const params = {
|
|
8837
9200
|
finished: options.finished,
|
|
8838
9201
|
page: Number(options.page),
|
|
8839
|
-
page_size: Number(options.pageSize)
|
|
9202
|
+
page_size: Number(options.pageSize),
|
|
9203
|
+
$workspace: normalizeWorkspaceForApi(options.workspace ?? profile.config.workspace)
|
|
8840
9204
|
};
|
|
8841
9205
|
if (options.flowType) {
|
|
8842
9206
|
params.flow_type = options.flowType;
|
|
@@ -8871,7 +9235,44 @@ function registerProjectCommands(program2) {
|
|
|
8871
9235
|
project: attachProjectDetailUrl(profile, context.project)
|
|
8872
9236
|
});
|
|
8873
9237
|
});
|
|
8874
|
-
|
|
9238
|
+
const handoff = project.command("handoff").description("Inspect BPMAX project create-page handoff state");
|
|
9239
|
+
handoff.command("status").description("Check whether a create-page prefill token is still readable by the platform").requiredOption("--prefill-token <token>", "Prefill token returned by project create handoff output").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
9240
|
+
const config = await loadConfig();
|
|
9241
|
+
const profile = resolveProfile(config, options.profile);
|
|
9242
|
+
const client = createApiClient(profile);
|
|
9243
|
+
const token = options.prefillToken.trim();
|
|
9244
|
+
if (!token) {
|
|
9245
|
+
throw new Error("--prefill-token cannot be empty.");
|
|
9246
|
+
}
|
|
9247
|
+
try {
|
|
9248
|
+
const result = await apiRequest(
|
|
9249
|
+
client,
|
|
9250
|
+
"GET",
|
|
9251
|
+
`/project_staging/prefill/${encodeURIComponent(token)}`
|
|
9252
|
+
);
|
|
9253
|
+
printResult(options.format, {
|
|
9254
|
+
ok: true,
|
|
9255
|
+
prefill_token: token,
|
|
9256
|
+
supported: true,
|
|
9257
|
+
browser_verified: false,
|
|
9258
|
+
result,
|
|
9259
|
+
next_action: "Token lookup only proves the prefill payload is readable; open the returned handoff URL in a real browser page before claiming creation succeeded."
|
|
9260
|
+
});
|
|
9261
|
+
} catch (error) {
|
|
9262
|
+
const message = errorMessage2(error);
|
|
9263
|
+
if (!isUnsupportedPrefillStatusError(message)) {
|
|
9264
|
+
throw error;
|
|
9265
|
+
}
|
|
9266
|
+
printResult(options.format, {
|
|
9267
|
+
ok: false,
|
|
9268
|
+
prefill_token: token,
|
|
9269
|
+
supported: false,
|
|
9270
|
+
error: message,
|
|
9271
|
+
next_action: "If this platform does not expose prefill token status, verify the returned handoff URL in a real browser page before claiming creation succeeded."
|
|
9272
|
+
});
|
|
9273
|
+
}
|
|
9274
|
+
});
|
|
9275
|
+
project.command("create").description("Minimal project create shortcut").option("--profile <profile>", "Profile name").option("--flow-id <flowId>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key", "").option("--name <name>", "Project name").option("--json <json>", "Additional request JSON").option("--body <body>", "Full request body JSON override").option("--unsafe-direct-create", "Allow raw --body direct project creation without form-template safety checks").option("--interactive", "Guide the user through filling project form fields").option("--no-interactive", "Disable the project create guide and submit directly when safe").option("--allow-form-handoff", "Allow interactive mode to hand off to the BPMAX web create form").option("--handoff-only", "Return a prefilled BPMAX create-page handoff URL without prompting or direct project creation").option("--skip-form-validation", "Skip local form schema validation before submit").option("--format <format>", "Output format", "pretty").action(async (options, command) => {
|
|
8875
9276
|
const interactiveSource = command.getOptionValueSource("interactive");
|
|
8876
9277
|
if (options.body && options.interactive === true && interactiveSource === "cli") {
|
|
8877
9278
|
throw new Error("--body and --interactive cannot be used together.");
|
|
@@ -8889,6 +9290,8 @@ function registerProjectCommands(program2) {
|
|
|
8889
9290
|
const profile = resolveProfile(config, options.profile);
|
|
8890
9291
|
const client = createApiClient(profile);
|
|
8891
9292
|
const useInteractive = !options.body && options.interactive !== false;
|
|
9293
|
+
let localFormValidation = options.body ? "not_applicable" : "skipped";
|
|
9294
|
+
let handoffAvailable = false;
|
|
8892
9295
|
let payload = await parseProjectJson(options.body, "--body");
|
|
8893
9296
|
if (!options.body) {
|
|
8894
9297
|
const flow = await resolveFlowIdentifiers(client, options, { loadDetail: true });
|
|
@@ -8904,6 +9307,19 @@ function registerProjectCommands(program2) {
|
|
|
8904
9307
|
return projectFormTemplate;
|
|
8905
9308
|
};
|
|
8906
9309
|
const usesTemplateProjectName = metaUsesTemplateProjectName(flowDetail);
|
|
9310
|
+
if (options.handoffOnly) {
|
|
9311
|
+
projectFormTemplate = await loadProjectFormTemplate();
|
|
9312
|
+
const handoffFields2 = fieldsForValidation(flowDetail, projectFormTemplate);
|
|
9313
|
+
assertHandoffFormCompatible(handoffFields2, form);
|
|
9314
|
+
await printCreateFormHandoff(client, options.format, profile, flowIdentifiers, {
|
|
9315
|
+
name: name ?? "",
|
|
9316
|
+
form,
|
|
9317
|
+
fields: handoffFields2,
|
|
9318
|
+
reason: "handoff_only",
|
|
9319
|
+
message: "\u5DF2\u751F\u6210 BPMAX \u521B\u5EFA\u9875\u94FE\u63A5\uFF0C\u8BF7\u70B9\u51FB\u7EE7\u7EED\u586B\u5199\u5E76\u63D0\u4EA4\u3002"
|
|
9320
|
+
});
|
|
9321
|
+
return;
|
|
9322
|
+
}
|
|
8907
9323
|
if (useInteractive) {
|
|
8908
9324
|
if (!flowDetail) {
|
|
8909
9325
|
throw new Error("Interactive project creation requires --flow-id so the form schema can be discovered.");
|
|
@@ -8928,6 +9344,7 @@ function registerProjectCommands(program2) {
|
|
|
8928
9344
|
}
|
|
8929
9345
|
const handoffReasons2 = collectHandoffReasons(fields, projectFormTemplate?.template);
|
|
8930
9346
|
if (handoffReasons2.length > 0) {
|
|
9347
|
+
handoffAvailable = true;
|
|
8931
9348
|
const handoffFields2 = fieldsForValidation(flowDetail, projectFormTemplate);
|
|
8932
9349
|
assertHandoffFormCompatible(handoffFields2, form);
|
|
8933
9350
|
await printCreateFormHandoff(client, options.format, profile, flowIdentifiers, {
|
|
@@ -8962,6 +9379,7 @@ function registerProjectCommands(program2) {
|
|
|
8962
9379
|
const handoffFields = fieldsForValidation(flowDetail, projectFormTemplate);
|
|
8963
9380
|
const handoffReasons = collectHandoffReasons(handoffFields, projectFormTemplate?.template);
|
|
8964
9381
|
if (handoffReasons.length > 0) {
|
|
9382
|
+
handoffAvailable = true;
|
|
8965
9383
|
assertHandoffFormCompatible(handoffFields, form);
|
|
8966
9384
|
await printCreateFormHandoff(client, options.format, profile, flowIdentifiers, {
|
|
8967
9385
|
name: name ?? "",
|
|
@@ -8985,16 +9403,29 @@ function registerProjectCommands(program2) {
|
|
|
8985
9403
|
};
|
|
8986
9404
|
if (!options.skipFormValidation) {
|
|
8987
9405
|
await validateCreateForm(client, { flowId: options.flowId, flowDetail, form, projectFormTemplate });
|
|
9406
|
+
localFormValidation = "passed";
|
|
9407
|
+
} else {
|
|
9408
|
+
localFormValidation = "skipped";
|
|
8988
9409
|
}
|
|
8989
9410
|
}
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
9411
|
+
let result;
|
|
9412
|
+
try {
|
|
9413
|
+
result = await apiRequest(
|
|
9414
|
+
client,
|
|
9415
|
+
"POST",
|
|
9416
|
+
"/project",
|
|
9417
|
+
{
|
|
9418
|
+
data: payload
|
|
9419
|
+
}
|
|
9420
|
+
);
|
|
9421
|
+
} catch (error) {
|
|
9422
|
+
throw projectCreateErrorDiagnostic(error, {
|
|
9423
|
+
localFormValidation,
|
|
9424
|
+
usedBody: Boolean(options.body),
|
|
9425
|
+
noInteractive: options.interactive === false,
|
|
9426
|
+
handoffAvailable
|
|
9427
|
+
});
|
|
9428
|
+
}
|
|
8998
9429
|
printResult(options.format, attachProjectDetailUrl(profile, result));
|
|
8999
9430
|
});
|
|
9000
9431
|
}
|
|
@@ -9004,7 +9435,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
9004
9435
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
9005
9436
|
|
|
9006
9437
|
// src/core/recipes.ts
|
|
9007
|
-
import { access, mkdir as mkdir7, readdir, readFile as
|
|
9438
|
+
import { access, mkdir as mkdir7, readdir, readFile as readFile10, writeFile as writeFile7 } from "fs/promises";
|
|
9008
9439
|
import path7 from "path";
|
|
9009
9440
|
var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
9010
9441
|
var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
@@ -9036,7 +9467,7 @@ function getRecipesDir(options) {
|
|
|
9036
9467
|
const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
|
|
9037
9468
|
return path7.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
|
|
9038
9469
|
}
|
|
9039
|
-
function
|
|
9470
|
+
function isRecord10(value) {
|
|
9040
9471
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9041
9472
|
}
|
|
9042
9473
|
function asString(value, fieldName) {
|
|
@@ -9046,7 +9477,7 @@ function asString(value, fieldName) {
|
|
|
9046
9477
|
return value;
|
|
9047
9478
|
}
|
|
9048
9479
|
function parseRecipeDefinition(input) {
|
|
9049
|
-
if (!
|
|
9480
|
+
if (!isRecord10(input)) {
|
|
9050
9481
|
throw new Error("recipe.json must be a JSON object.");
|
|
9051
9482
|
}
|
|
9052
9483
|
if (input.version !== 1) {
|
|
@@ -9054,7 +9485,7 @@ function parseRecipeDefinition(input) {
|
|
|
9054
9485
|
}
|
|
9055
9486
|
const name = asString(input.name, "recipe.name");
|
|
9056
9487
|
assertSafeName("Recipe name", name);
|
|
9057
|
-
if (!
|
|
9488
|
+
if (!isRecord10(input.command)) {
|
|
9058
9489
|
throw new Error("recipe.command must be an object.");
|
|
9059
9490
|
}
|
|
9060
9491
|
const argv = input.command.argv;
|
|
@@ -9062,7 +9493,7 @@ function parseRecipeDefinition(input) {
|
|
|
9062
9493
|
throw new Error("recipe.command.argv must be a non-empty string array.");
|
|
9063
9494
|
}
|
|
9064
9495
|
const variables = Array.isArray(input.variables) ? input.variables.map((item, index) => {
|
|
9065
|
-
if (!
|
|
9496
|
+
if (!isRecord10(item)) {
|
|
9066
9497
|
throw new Error(`recipe.variables[${index}] must be an object.`);
|
|
9067
9498
|
}
|
|
9068
9499
|
const variableName = asString(item.name, `recipe.variables[${index}].name`);
|
|
@@ -9086,7 +9517,7 @@ function parseRecipeDefinition(input) {
|
|
|
9086
9517
|
};
|
|
9087
9518
|
}
|
|
9088
9519
|
async function loadRecipe(recipeDir) {
|
|
9089
|
-
const raw = await
|
|
9520
|
+
const raw = await readFile10(path7.join(recipeDir, "recipe.json"), "utf8");
|
|
9090
9521
|
return parseRecipeDefinition(JSON.parse(raw));
|
|
9091
9522
|
}
|
|
9092
9523
|
async function listRecipes(recipesDir) {
|
|
@@ -9138,7 +9569,7 @@ function parseVarsJson(input) {
|
|
|
9138
9569
|
return {};
|
|
9139
9570
|
}
|
|
9140
9571
|
const parsed = JSON.parse(input);
|
|
9141
|
-
if (!
|
|
9572
|
+
if (!isRecord10(parsed)) {
|
|
9142
9573
|
throw new Error("--vars must be a JSON object.");
|
|
9143
9574
|
}
|
|
9144
9575
|
const variables = {};
|
|
@@ -9185,7 +9616,7 @@ async function renderArgv(options) {
|
|
|
9185
9616
|
const rendered = [];
|
|
9186
9617
|
for (const token of options.recipe.command.argv) {
|
|
9187
9618
|
if (token.startsWith("@")) {
|
|
9188
|
-
const raw = await
|
|
9619
|
+
const raw = await readFile10(resolveRecipeFile(options.recipeDir, token), "utf8");
|
|
9189
9620
|
rendered.push(renderTemplate(raw, options.variables));
|
|
9190
9621
|
} else {
|
|
9191
9622
|
rendered.push(renderTemplate(token, options.variables));
|
|
@@ -9508,7 +9939,7 @@ async function promptConfirm(message) {
|
|
|
9508
9939
|
const value = await confirm2({ message, initialValue: true });
|
|
9509
9940
|
return value === true;
|
|
9510
9941
|
}
|
|
9511
|
-
function
|
|
9942
|
+
function shellQuote7(value) {
|
|
9512
9943
|
if (/^[A-Za-z0-9_./:@=-]+$/.test(value)) {
|
|
9513
9944
|
return value;
|
|
9514
9945
|
}
|
|
@@ -9518,7 +9949,7 @@ function configWorkspaceNextCommands2(profileName, cache) {
|
|
|
9518
9949
|
if (!capabilityEnabled(cache, "config.repository.view") || !capabilityEnabled(cache, "config.latest.pull")) {
|
|
9519
9950
|
return void 0;
|
|
9520
9951
|
}
|
|
9521
|
-
const configDirPrefix = isConfigDirOverridden() ? ` --config-dir ${
|
|
9952
|
+
const configDirPrefix = isConfigDirOverridden() ? ` --config-dir ${shellQuote7(getConfigDir())}` : "";
|
|
9522
9953
|
return {
|
|
9523
9954
|
config_workspace_init: `bpmax-cli${configDirPrefix} config workspace init <env> --profile ${profileName} --workspace-dir <dir> --format json`
|
|
9524
9955
|
};
|
|
@@ -9637,10 +10068,10 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
9637
10068
|
}
|
|
9638
10069
|
|
|
9639
10070
|
// src/commands/step.ts
|
|
9640
|
-
function
|
|
10071
|
+
function isRecord11(value) {
|
|
9641
10072
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9642
10073
|
}
|
|
9643
|
-
function
|
|
10074
|
+
function stringValue2(value) {
|
|
9644
10075
|
if (value === void 0 || value === null) {
|
|
9645
10076
|
return void 0;
|
|
9646
10077
|
}
|
|
@@ -9648,7 +10079,7 @@ function stringValue(value) {
|
|
|
9648
10079
|
return next ? next : void 0;
|
|
9649
10080
|
}
|
|
9650
10081
|
function idValue(value) {
|
|
9651
|
-
const next =
|
|
10082
|
+
const next = stringValue2(value);
|
|
9652
10083
|
return next && /^\d+$/.test(next) ? next : void 0;
|
|
9653
10084
|
}
|
|
9654
10085
|
function hasMeaningfulValue(value) {
|
|
@@ -9664,7 +10095,7 @@ function hasMeaningfulValue(value) {
|
|
|
9664
10095
|
if (Array.isArray(value)) {
|
|
9665
10096
|
return value.some(hasMeaningfulValue);
|
|
9666
10097
|
}
|
|
9667
|
-
if (
|
|
10098
|
+
if (isRecord11(value)) {
|
|
9668
10099
|
return Object.values(value).some(hasMeaningfulValue);
|
|
9669
10100
|
}
|
|
9670
10101
|
return false;
|
|
@@ -9673,11 +10104,11 @@ function isEmptyValue2(value) {
|
|
|
9673
10104
|
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
9674
10105
|
}
|
|
9675
10106
|
function projectIdOfStep(step) {
|
|
9676
|
-
const nestedProjectId =
|
|
10107
|
+
const nestedProjectId = isRecord11(step.project) ? step.project.id : void 0;
|
|
9677
10108
|
return idValue(step.project_id ?? step.projectId ?? nestedProjectId);
|
|
9678
10109
|
}
|
|
9679
10110
|
function stepFlowNodeId(step) {
|
|
9680
|
-
return
|
|
10111
|
+
return stringValue2(step.flow_step_id ?? step.flowStepId ?? step.flow_node_id ?? step.flowNodeId);
|
|
9681
10112
|
}
|
|
9682
10113
|
function isStepFinished(step) {
|
|
9683
10114
|
if (step.real_end_time || step.end_time) {
|
|
@@ -9701,18 +10132,18 @@ function collectRecords(value, output = [], seen = /* @__PURE__ */ new Set()) {
|
|
|
9701
10132
|
value.forEach((item) => collectRecords(item, output, seen));
|
|
9702
10133
|
return output;
|
|
9703
10134
|
}
|
|
9704
|
-
if (!
|
|
10135
|
+
if (!isRecord11(value)) {
|
|
9705
10136
|
return output;
|
|
9706
10137
|
}
|
|
9707
10138
|
output.push(value);
|
|
9708
10139
|
for (const child of Object.values(value)) {
|
|
9709
|
-
if (Array.isArray(child) ||
|
|
10140
|
+
if (Array.isArray(child) || isRecord11(child)) {
|
|
9710
10141
|
collectRecords(child, output, seen);
|
|
9711
10142
|
}
|
|
9712
10143
|
}
|
|
9713
10144
|
return output;
|
|
9714
10145
|
}
|
|
9715
|
-
function
|
|
10146
|
+
function findFlowNode2(project, step) {
|
|
9716
10147
|
const flowStepId = stepFlowNodeId(step);
|
|
9717
10148
|
if (!flowStepId) {
|
|
9718
10149
|
return null;
|
|
@@ -9728,7 +10159,7 @@ function findFlowNode(project, step) {
|
|
|
9728
10159
|
project.config
|
|
9729
10160
|
];
|
|
9730
10161
|
for (const candidate of candidates) {
|
|
9731
|
-
const match = collectRecords(candidate).find((item) =>
|
|
10162
|
+
const match = collectRecords(candidate).find((item) => stringValue2(item.id) === flowStepId);
|
|
9732
10163
|
if (match) {
|
|
9733
10164
|
return match;
|
|
9734
10165
|
}
|
|
@@ -9790,7 +10221,7 @@ function formListOfStep(step) {
|
|
|
9790
10221
|
return values.filter(hasMeaningfulValue);
|
|
9791
10222
|
}
|
|
9792
10223
|
function unwrapFormValue(value) {
|
|
9793
|
-
if (!
|
|
10224
|
+
if (!isRecord11(value)) {
|
|
9794
10225
|
return value;
|
|
9795
10226
|
}
|
|
9796
10227
|
if ("value" in value && Object.keys(value).length <= 3) {
|
|
@@ -9807,10 +10238,10 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
9807
10238
|
value.forEach((item) => collectFormValues(item, output, seen));
|
|
9808
10239
|
return output;
|
|
9809
10240
|
}
|
|
9810
|
-
if (!
|
|
10241
|
+
if (!isRecord11(value)) {
|
|
9811
10242
|
return output;
|
|
9812
10243
|
}
|
|
9813
|
-
const key =
|
|
10244
|
+
const key = stringValue2(value.key ?? value.field_key ?? value.fieldKey ?? value.name);
|
|
9814
10245
|
if (key && "value" in value) {
|
|
9815
10246
|
const nextValue = unwrapFormValue(value.value);
|
|
9816
10247
|
if (hasMeaningfulValue(nextValue)) {
|
|
@@ -9818,7 +10249,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
9818
10249
|
}
|
|
9819
10250
|
}
|
|
9820
10251
|
for (const child of Object.values(value)) {
|
|
9821
|
-
if (Array.isArray(child) ||
|
|
10252
|
+
if (Array.isArray(child) || isRecord11(child)) {
|
|
9822
10253
|
collectFormValues(child, output, seen);
|
|
9823
10254
|
}
|
|
9824
10255
|
}
|
|
@@ -9865,7 +10296,7 @@ function collectMissingRequiredInputs(fields, values) {
|
|
|
9865
10296
|
continue;
|
|
9866
10297
|
}
|
|
9867
10298
|
value.forEach((row, index) => {
|
|
9868
|
-
if (!
|
|
10299
|
+
if (!isRecord11(row)) {
|
|
9869
10300
|
return;
|
|
9870
10301
|
}
|
|
9871
10302
|
for (const child of field.children ?? []) {
|
|
@@ -9920,7 +10351,7 @@ function ownerIdsFromStep(step) {
|
|
|
9920
10351
|
];
|
|
9921
10352
|
const ids = /* @__PURE__ */ new Set();
|
|
9922
10353
|
for (const owner of owners) {
|
|
9923
|
-
if (
|
|
10354
|
+
if (isRecord11(owner)) {
|
|
9924
10355
|
const id = idValue(owner.owner_id ?? owner.user_id ?? owner.id);
|
|
9925
10356
|
if (id) {
|
|
9926
10357
|
ids.add(id);
|
|
@@ -9934,6 +10365,47 @@ function ownerIdsFromStep(step) {
|
|
|
9934
10365
|
}
|
|
9935
10366
|
return [...ids];
|
|
9936
10367
|
}
|
|
10368
|
+
function ownerDiagnosticsFromStep(step, currentUser) {
|
|
10369
|
+
const sources = [
|
|
10370
|
+
{ source: "owner_id", value: step.owner_id },
|
|
10371
|
+
{ source: "ownerId", value: step.ownerId },
|
|
10372
|
+
{ source: "user_id", value: step.user_id },
|
|
10373
|
+
{ source: "userId", value: step.userId },
|
|
10374
|
+
{ source: "owners", value: step.owners },
|
|
10375
|
+
{ source: "owner_list", value: step.owner_list },
|
|
10376
|
+
{ source: "step_owners", value: step.step_owners }
|
|
10377
|
+
];
|
|
10378
|
+
const ownerIds = /* @__PURE__ */ new Set();
|
|
10379
|
+
const ownerSources = /* @__PURE__ */ new Set();
|
|
10380
|
+
const emptyOwnerArrays = [];
|
|
10381
|
+
for (const { source, value } of sources) {
|
|
10382
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
10383
|
+
emptyOwnerArrays.push(source);
|
|
10384
|
+
}
|
|
10385
|
+
const values = Array.isArray(value) ? value : [value];
|
|
10386
|
+
for (const item of values) {
|
|
10387
|
+
let id;
|
|
10388
|
+
if (isRecord11(item)) {
|
|
10389
|
+
id = idValue(item.owner_id ?? item.user_id ?? item.id);
|
|
10390
|
+
} else {
|
|
10391
|
+
id = idValue(item);
|
|
10392
|
+
}
|
|
10393
|
+
if (id) {
|
|
10394
|
+
ownerIds.add(id);
|
|
10395
|
+
ownerSources.add(source);
|
|
10396
|
+
}
|
|
10397
|
+
}
|
|
10398
|
+
}
|
|
10399
|
+
const currentUserId = currentUser ? idValue(currentUser.id ?? currentUser.user_id ?? currentUser.owner_id) : void 0;
|
|
10400
|
+
return {
|
|
10401
|
+
explicit_owner_ids: [...ownerIds],
|
|
10402
|
+
owner_sources: [...ownerSources],
|
|
10403
|
+
...currentUserId ? { current_user_id: currentUserId } : {},
|
|
10404
|
+
current_user_matched_explicit_owner: currentUserId ? ownerIds.has(currentUserId) : null,
|
|
10405
|
+
empty_owner_arrays: emptyOwnerArrays,
|
|
10406
|
+
...ownerIds.size === 0 ? { note: "No explicit step owner ids were returned; processability may come from admin fallback, permission fallback, or unresolved matrix owner behavior." } : {}
|
|
10407
|
+
};
|
|
10408
|
+
}
|
|
9937
10409
|
function checkCurrentUserCanProcess(step, currentUser) {
|
|
9938
10410
|
const ownerIds = ownerIdsFromStep(step);
|
|
9939
10411
|
if (ownerIds.length === 0) {
|
|
@@ -9964,11 +10436,12 @@ async function buildStepContext(profile, client, stepId, projectId) {
|
|
|
9964
10436
|
if (actualProjectId && actualProjectId !== projectId) {
|
|
9965
10437
|
throw new Error(`Step ${stepId} belongs to project ${actualProjectId}, not project ${projectId}.`);
|
|
9966
10438
|
}
|
|
9967
|
-
const flowNode =
|
|
10439
|
+
const flowNode = findFlowNode2(project, step);
|
|
9968
10440
|
const formSummary = buildFormSummary(project, step);
|
|
9969
10441
|
const requirements = buildStepRequirements(step, flowNode);
|
|
9970
10442
|
const identityUnverified = !formSummary.has_identity_evidence;
|
|
9971
10443
|
const userCheck = checkCurrentUserCanProcess(step, currentUser);
|
|
10444
|
+
const ownerDiagnostics = ownerDiagnosticsFromStep(step, currentUser);
|
|
9972
10445
|
const stepFinished = isStepFinished(step);
|
|
9973
10446
|
const riskWarnings = [];
|
|
9974
10447
|
if (identityUnverified) {
|
|
@@ -9993,6 +10466,7 @@ async function buildStepContext(profile, client, stepId, projectId) {
|
|
|
9993
10466
|
url: buildBpmaxUrl(profile, "project-step", { projectId, stepId }).url,
|
|
9994
10467
|
current_user: currentUser,
|
|
9995
10468
|
...userCheck,
|
|
10469
|
+
owner_diagnostics: ownerDiagnostics,
|
|
9996
10470
|
step_finished: stepFinished,
|
|
9997
10471
|
form_summary: formSummary,
|
|
9998
10472
|
requirements,
|
|
@@ -10023,12 +10497,12 @@ function extractSubmitInputValues(data) {
|
|
|
10023
10497
|
const candidates = [data.form, data.form_data, data.formData, data.fields, data.values];
|
|
10024
10498
|
const values = {};
|
|
10025
10499
|
for (const candidate of candidates) {
|
|
10026
|
-
if (
|
|
10500
|
+
if (isRecord11(candidate)) {
|
|
10027
10501
|
Object.assign(values, candidate);
|
|
10028
10502
|
}
|
|
10029
10503
|
}
|
|
10030
10504
|
for (const [key, value] of Object.entries(data)) {
|
|
10031
|
-
if (!SUBMIT_NON_FORM_KEYS.has(key) && !
|
|
10505
|
+
if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord11(value) && !Array.isArray(value)) {
|
|
10032
10506
|
values[key] = value;
|
|
10033
10507
|
}
|
|
10034
10508
|
}
|
|
@@ -10152,7 +10626,7 @@ function registerStepCommands(program2) {
|
|
|
10152
10626
|
}
|
|
10153
10627
|
|
|
10154
10628
|
// src/core/taskbook.ts
|
|
10155
|
-
import { mkdir as mkdir8, readFile as
|
|
10629
|
+
import { mkdir as mkdir8, readFile as readFile11, writeFile as writeFile8 } from "fs/promises";
|
|
10156
10630
|
import path8 from "path";
|
|
10157
10631
|
var TaskbookError = class extends Error {
|
|
10158
10632
|
};
|
|
@@ -10200,8 +10674,15 @@ var PROMPT_REQUIRED_TERMS = [
|
|
|
10200
10674
|
];
|
|
10201
10675
|
var BPMAX_SKILL_PATTERN = /bpmax-[a-z0-9-]+|form-control-library|bpmax-memory-protocol/;
|
|
10202
10676
|
var FLOW_LOCK_PATTERN = /\bflow:([A-Za-z0-9_-]+)/g;
|
|
10677
|
+
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi;
|
|
10678
|
+
function uuidErrors(text5, target) {
|
|
10679
|
+
const values = [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
|
|
10680
|
+
return values.map(
|
|
10681
|
+
(value) => `UUID values are not allowed in BPMAX configuration ${target}: ${value}. Use platform-returned numeric ids or flow<number>; use new-flow:<name> before creation.`
|
|
10682
|
+
);
|
|
10683
|
+
}
|
|
10203
10684
|
async function readTaskbookText(file) {
|
|
10204
|
-
const raw = await
|
|
10685
|
+
const raw = await readFile11(file, "utf8");
|
|
10205
10686
|
try {
|
|
10206
10687
|
const parsed = JSON.parse(raw);
|
|
10207
10688
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -10238,6 +10719,7 @@ async function lintTaskbook(file, options = {}) {
|
|
|
10238
10719
|
if (!options.allowGeneratedFlowTypeMissing) {
|
|
10239
10720
|
errors.push(...missingTermErrors(text5, GENERATED_FLOW_TYPE_TERMS, "missing generated flow_type rule term"));
|
|
10240
10721
|
}
|
|
10722
|
+
errors.push(...uuidErrors(text5, "taskbooks"));
|
|
10241
10723
|
errors.push(...missingTermErrors(text5, SUBAGENT_TERMS, "missing subagent rule term"));
|
|
10242
10724
|
for (const match of text5.matchAll(FLOW_LOCK_PATTERN)) {
|
|
10243
10725
|
const value = match[1] || "";
|
|
@@ -10262,6 +10744,7 @@ async function lintTaskPrompt(file, options = {}) {
|
|
|
10262
10744
|
if (!BPMAX_SKILL_PATTERN.test(text5)) {
|
|
10263
10745
|
errors.push("prompt missing BPMAX related skill name in required_skills");
|
|
10264
10746
|
}
|
|
10747
|
+
errors.push(...uuidErrors(text5, "task prompts"));
|
|
10265
10748
|
for (const term of options.forbidTerms || []) {
|
|
10266
10749
|
if (term && text5.includes(term)) {
|
|
10267
10750
|
errors.push(`prompt forbidden term present: ${term}`);
|
|
@@ -10488,7 +10971,7 @@ import {
|
|
|
10488
10971
|
cp as cp2,
|
|
10489
10972
|
mkdir as mkdir9,
|
|
10490
10973
|
readdir as readdir2,
|
|
10491
|
-
readFile as
|
|
10974
|
+
readFile as readFile12,
|
|
10492
10975
|
rm as rm3,
|
|
10493
10976
|
stat as stat4,
|
|
10494
10977
|
writeFile as writeFile9
|
|
@@ -10580,7 +11063,7 @@ async function exists2(filePath) {
|
|
|
10580
11063
|
}
|
|
10581
11064
|
}
|
|
10582
11065
|
async function readText(filePath) {
|
|
10583
|
-
return
|
|
11066
|
+
return readFile12(filePath, "utf8");
|
|
10584
11067
|
}
|
|
10585
11068
|
function fail(message) {
|
|
10586
11069
|
throw new TestSuiteError(message);
|
|
@@ -10843,10 +11326,10 @@ async function fileMap(root) {
|
|
|
10843
11326
|
return result;
|
|
10844
11327
|
}
|
|
10845
11328
|
async function sha256(filePath) {
|
|
10846
|
-
return createHash4("sha256").update(await
|
|
11329
|
+
return createHash4("sha256").update(await readFile12(filePath)).digest("hex");
|
|
10847
11330
|
}
|
|
10848
11331
|
async function readForDiff(filePath) {
|
|
10849
|
-
const buffer = await
|
|
11332
|
+
const buffer = await readFile12(filePath);
|
|
10850
11333
|
if (buffer.includes(0)) return [`<binary sha256=${createHash4("sha256").update(buffer).digest("hex")}>
|
|
10851
11334
|
`];
|
|
10852
11335
|
return buffer.toString("utf8").split(/(?<=\n)/);
|
|
@@ -11121,7 +11604,7 @@ function registerTestSuiteCommands(program2) {
|
|
|
11121
11604
|
}
|
|
11122
11605
|
|
|
11123
11606
|
// src/core/update.ts
|
|
11124
|
-
import { access as access2, mkdir as mkdir10, readFile as
|
|
11607
|
+
import { access as access2, mkdir as mkdir10, readFile as readFile13, realpath, writeFile as writeFile10 } from "fs/promises";
|
|
11125
11608
|
import path10 from "path";
|
|
11126
11609
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
11127
11610
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -11238,7 +11721,7 @@ function updateStatePath(configDir = getConfigDir()) {
|
|
|
11238
11721
|
}
|
|
11239
11722
|
async function readUpdateState(configDir) {
|
|
11240
11723
|
try {
|
|
11241
|
-
const raw = await
|
|
11724
|
+
const raw = await readFile13(updateStatePath(configDir), "utf8");
|
|
11242
11725
|
const parsed = JSON.parse(raw);
|
|
11243
11726
|
if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
|
|
11244
11727
|
return null;
|
|
@@ -11620,6 +12103,7 @@ async function setupNotices(argv = process.argv) {
|
|
|
11620
12103
|
|
|
11621
12104
|
// src/bin.ts
|
|
11622
12105
|
var program = new Command();
|
|
12106
|
+
program.exitOverride();
|
|
11623
12107
|
function configDirFromArgv(argv) {
|
|
11624
12108
|
const option = "--config-dir";
|
|
11625
12109
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -11633,7 +12117,111 @@ function configDirFromArgv(argv) {
|
|
|
11633
12117
|
}
|
|
11634
12118
|
return void 0;
|
|
11635
12119
|
}
|
|
12120
|
+
function formatFromArgv(argv) {
|
|
12121
|
+
const option = "--format";
|
|
12122
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
12123
|
+
const arg = argv[index];
|
|
12124
|
+
if (arg === option) {
|
|
12125
|
+
return argv[index + 1];
|
|
12126
|
+
}
|
|
12127
|
+
if (arg.startsWith(`${option}=`)) {
|
|
12128
|
+
return arg.slice(option.length + 1);
|
|
12129
|
+
}
|
|
12130
|
+
}
|
|
12131
|
+
return void 0;
|
|
12132
|
+
}
|
|
12133
|
+
var OPTIONS_WITH_VALUES = /* @__PURE__ */ new Set([
|
|
12134
|
+
"--action-key",
|
|
12135
|
+
"--config-dir",
|
|
12136
|
+
"--confirm",
|
|
12137
|
+
"--execution-token",
|
|
12138
|
+
"--format",
|
|
12139
|
+
"--id",
|
|
12140
|
+
"--out",
|
|
12141
|
+
"--payload",
|
|
12142
|
+
"--profile",
|
|
12143
|
+
"--session-key",
|
|
12144
|
+
"--trace-id",
|
|
12145
|
+
"--work-format"
|
|
12146
|
+
]);
|
|
12147
|
+
function commandTokensFromArgv(argv) {
|
|
12148
|
+
const tokens = [];
|
|
12149
|
+
const args = argv.slice(2);
|
|
12150
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
12151
|
+
const arg = args[index];
|
|
12152
|
+
if (arg === "--") {
|
|
12153
|
+
break;
|
|
12154
|
+
}
|
|
12155
|
+
if (arg.startsWith("--")) {
|
|
12156
|
+
const [option] = arg.split("=", 1);
|
|
12157
|
+
if (!arg.includes("=") && OPTIONS_WITH_VALUES.has(option)) {
|
|
12158
|
+
index += 1;
|
|
12159
|
+
}
|
|
12160
|
+
continue;
|
|
12161
|
+
}
|
|
12162
|
+
tokens.push(arg);
|
|
12163
|
+
}
|
|
12164
|
+
return tokens;
|
|
12165
|
+
}
|
|
12166
|
+
function commandDomainFromArgv(argv) {
|
|
12167
|
+
const args = commandTokensFromArgv(argv);
|
|
12168
|
+
if (args[0] === "config" && args[1]) {
|
|
12169
|
+
return args[1];
|
|
12170
|
+
}
|
|
12171
|
+
return args[0];
|
|
12172
|
+
}
|
|
12173
|
+
function commandEndpointHint(argv) {
|
|
12174
|
+
const args = commandTokensFromArgv(argv);
|
|
12175
|
+
if (args[0] === "config" && args[2] === "create" && args[1]) {
|
|
12176
|
+
const endpointByDomain = {
|
|
12177
|
+
"dataset-field": "/data_set_field",
|
|
12178
|
+
dataset: "/data_set",
|
|
12179
|
+
workspace: "/workspace",
|
|
12180
|
+
"form-template": "/form_template",
|
|
12181
|
+
"list-template": "/flow_page_template",
|
|
12182
|
+
"filter-template": "/flow_page_template",
|
|
12183
|
+
"project-detail-template": "/flow_page_template",
|
|
12184
|
+
"console-template": "/flow_page_template"
|
|
12185
|
+
};
|
|
12186
|
+
return endpointByDomain[args[1]];
|
|
12187
|
+
}
|
|
12188
|
+
return void 0;
|
|
12189
|
+
}
|
|
12190
|
+
function printCommandError(error) {
|
|
12191
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
12192
|
+
if (formatFromArgv(process.argv) === "json") {
|
|
12193
|
+
console.log(JSON.stringify({
|
|
12194
|
+
ok: false,
|
|
12195
|
+
error: message,
|
|
12196
|
+
...commandDomainFromArgv(process.argv) ? { domain: commandDomainFromArgv(process.argv) } : {},
|
|
12197
|
+
...commandEndpointHint(process.argv) ? { endpoint: commandEndpointHint(process.argv) } : {}
|
|
12198
|
+
}, null, 2));
|
|
12199
|
+
return;
|
|
12200
|
+
}
|
|
12201
|
+
console.error(message);
|
|
12202
|
+
}
|
|
12203
|
+
function commanderExitCode(error) {
|
|
12204
|
+
if (typeof error === "object" && error !== null && "exitCode" in error && typeof error.exitCode === "number") {
|
|
12205
|
+
return error.exitCode;
|
|
12206
|
+
}
|
|
12207
|
+
return void 0;
|
|
12208
|
+
}
|
|
12209
|
+
function isCommanderDisplayOnlyExit(error) {
|
|
12210
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
12211
|
+
return false;
|
|
12212
|
+
}
|
|
12213
|
+
const code = error.code;
|
|
12214
|
+
return code === "commander.helpDisplayed" || code === "commander.version";
|
|
12215
|
+
}
|
|
11636
12216
|
program.name(CLI_NAME).description("BPMAX multi-environment CLI").version(VERSION).option("--config-dir <dir>", "Root directory for bpmax-cli local state").option("--execution-token <token>", "Short-lived BPMAX AI execution token").option("--action-key <actionKey>", "AI action key for execution audit").option("--session-key <sessionKey>", "AI conversation session key").option("--trace-id <traceId>", "AI execution trace id");
|
|
12217
|
+
program.configureOutput({
|
|
12218
|
+
writeErr: (str) => {
|
|
12219
|
+
if (formatFromArgv(process.argv) === "json") {
|
|
12220
|
+
return;
|
|
12221
|
+
}
|
|
12222
|
+
process.stderr.write(str);
|
|
12223
|
+
}
|
|
12224
|
+
});
|
|
11637
12225
|
program.hook("preAction", (thisCommand) => {
|
|
11638
12226
|
const options = thisCommand.optsWithGlobals();
|
|
11639
12227
|
setConfigDir(options.configDir);
|
|
@@ -11665,6 +12253,7 @@ registerUserCommands(program);
|
|
|
11665
12253
|
registerEsCommands(program);
|
|
11666
12254
|
registerFlowCommands(program);
|
|
11667
12255
|
registerMemoryCommands(program);
|
|
12256
|
+
registerMatrixCommands(program);
|
|
11668
12257
|
registerProjectCommands(program);
|
|
11669
12258
|
registerStepCommands(program);
|
|
11670
12259
|
registerTaskbookCommands(program);
|
|
@@ -11677,9 +12266,13 @@ registerUpdateCommands(program);
|
|
|
11677
12266
|
var isCompletion = process.argv.includes("completion") || process.argv.includes("__complete");
|
|
11678
12267
|
setConfigDir(configDirFromArgv(process.argv));
|
|
11679
12268
|
(isCompletion ? Promise.resolve() : setupNotices()).then(() => program.parseAsync(process.argv)).catch((error) => {
|
|
12269
|
+
if (isCommanderDisplayOnlyExit(error)) {
|
|
12270
|
+
process.exitCode = commanderExitCode(error) ?? 0;
|
|
12271
|
+
return;
|
|
12272
|
+
}
|
|
11680
12273
|
finishCommandAuditScope("failed", error).catch(() => void 0).finally(() => {
|
|
11681
|
-
|
|
11682
|
-
process.exitCode = 1;
|
|
12274
|
+
printCommandError(error);
|
|
12275
|
+
process.exitCode = commanderExitCode(error) ?? 1;
|
|
11683
12276
|
});
|
|
11684
12277
|
});
|
|
11685
12278
|
//# sourceMappingURL=bin.js.map
|