nexarch 0.5.3 → 0.5.5
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/commands/init-agent.js +26 -11
- package/dist/commands/init-project.js +20 -0
- package/dist/commands/setup.js +16 -1
- package/dist/lib/mcp.js +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import process from "process";
|
|
|
5
5
|
import { requireCredentials } from "../lib/credentials.js";
|
|
6
6
|
import { fetchAgentRegistryOrThrow } from "../lib/agent-registry.js";
|
|
7
7
|
import { callMcpTool, mcpInitialize, mcpListTools } from "../lib/mcp.js";
|
|
8
|
-
const CLI_VERSION = "0.5.
|
|
8
|
+
const CLI_VERSION = "0.5.5";
|
|
9
9
|
const AGENT_ENTITY_TYPE = "agent";
|
|
10
10
|
const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
|
|
11
11
|
function parseFlag(args, flag) {
|
|
@@ -271,6 +271,7 @@ function injectGenericAgentConfig(registry) {
|
|
|
271
271
|
export async function initAgent(args) {
|
|
272
272
|
const asJson = parseFlag(args, "--json");
|
|
273
273
|
const strict = parseFlag(args, "--strict");
|
|
274
|
+
const fromSetup = parseFlag(args, "--from-setup");
|
|
274
275
|
const redactHostname = parseFlag(args, "--redact-hostname");
|
|
275
276
|
const explicitAgentId = parseOptionValue(args, "--agent-id");
|
|
276
277
|
const bindToExternalKey = parseOptionValue(args, "--bind-to-external-key");
|
|
@@ -299,6 +300,7 @@ export async function initAgent(args) {
|
|
|
299
300
|
const toolNames = new Set(tools.map((t) => t.name));
|
|
300
301
|
const required = [
|
|
301
302
|
"nexarch_get_agent_registry",
|
|
303
|
+
"nexarch_get_company_onboarding",
|
|
302
304
|
"nexarch_get_applied_policies",
|
|
303
305
|
"nexarch_get_ingest_contract",
|
|
304
306
|
"nexarch_upsert_entities",
|
|
@@ -311,13 +313,30 @@ export async function initAgent(args) {
|
|
|
311
313
|
ok: missing.length === 0,
|
|
312
314
|
detail: missing.length ? `missing: ${missing.join(", ")}` : `required tools present (${required.length})`,
|
|
313
315
|
});
|
|
316
|
+
const onboardingRaw = await callMcpTool("nexarch_get_company_onboarding", {}, { companyId: selectedCompanyId });
|
|
317
|
+
const onboarding = parseToolText(onboardingRaw);
|
|
318
|
+
const onboardingReady = onboarding.isComplete === true;
|
|
319
|
+
checks.push({
|
|
320
|
+
name: "company.onboarding",
|
|
321
|
+
ok: onboardingReady,
|
|
322
|
+
detail: `status=${onboarding.onboardingStatus ?? "unknown"}`,
|
|
323
|
+
});
|
|
324
|
+
if (!onboardingReady) {
|
|
325
|
+
const onboardingMessage = "Company onboarding is incomplete. Complete onboarding before running init-agent or init-project.";
|
|
326
|
+
if (asJson) {
|
|
327
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: "COMPANY_ONBOARDING_INCOMPLETE", message: onboardingMessage, onboardingStatus: onboarding.onboardingStatus ?? null }, null, 2)}\n`);
|
|
328
|
+
process.exitCode = 1;
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
throw new Error(onboardingMessage);
|
|
332
|
+
}
|
|
314
333
|
const policiesRaw = await callMcpTool("nexarch_get_applied_policies", {}, { companyId: selectedCompanyId });
|
|
315
334
|
const policies = parseToolText(policiesRaw);
|
|
316
335
|
checks.push({
|
|
317
336
|
name: "governance.bootstrap",
|
|
318
337
|
ok: Boolean(policies.policyBundleHash),
|
|
319
338
|
detail: policies.policyBundleHash
|
|
320
|
-
? `policyBundleHash=${policies.policyBundleHash.slice(0, 12)}
|
|
339
|
+
? `policyBundleHash=${policies.policyBundleHash.slice(0, 12)}…`
|
|
321
340
|
: "missing policyBundleHash",
|
|
322
341
|
});
|
|
323
342
|
const contractRaw = await callMcpTool("nexarch_get_ingest_contract", {}, { companyId: selectedCompanyId });
|
|
@@ -822,21 +841,17 @@ export async function initAgent(args) {
|
|
|
822
841
|
}
|
|
823
842
|
const hasInjectedAgentInstructions = agentConfigResults.some((r) => r.status === "injected" || r.status === "updated");
|
|
824
843
|
if (hasInjectedAgentInstructions) {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
844
|
+
if (!fromSetup) {
|
|
845
|
+
console.log("\n➡ Next step: in your coding agent, run:");
|
|
846
|
+
console.log("\nrun npx nexarch@latest init-agent\n");
|
|
847
|
+
console.log(" (Registration instructions were already written into your agent config file.)");
|
|
848
|
+
}
|
|
828
849
|
}
|
|
829
850
|
else {
|
|
830
851
|
console.log("\n➡ Next step (required): complete agent identity in your coding agent");
|
|
831
852
|
console.log(" Paste this and fill in real values:");
|
|
832
853
|
console.log(`\nrun npx nexarch@latest agent identify --agent-id \"${agentId}\" --provider \"<provider>\" --model \"<model>\" --client \"<client>\" --framework \"<openclaw|n8n|m365-agent-framework|other>\" --tool-version \"<tool-version>\" --capabilities \"<capability1,capability2>\" --json\n`);
|
|
833
854
|
}
|
|
834
|
-
if (appDetection.detected) {
|
|
835
|
-
console.log("\n➡ Optional next step: likely application detected in current directory.");
|
|
836
|
-
console.log(` Detected manifests: ${appDetection.evidence.join(", ")}`);
|
|
837
|
-
console.log(" Ask the user: 'I found a likely application here. Do you want me to run init-project next?'");
|
|
838
|
-
console.log(" Suggested command: npx nexarch@latest init-project --dir . --json");
|
|
839
|
-
}
|
|
840
855
|
}
|
|
841
856
|
else {
|
|
842
857
|
console.log("⚠ Handshake/registration completed with issues.");
|
|
@@ -812,10 +812,30 @@ export async function initProject(args) {
|
|
|
812
812
|
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
813
813
|
return;
|
|
814
814
|
}
|
|
815
|
+
const onboardingRaw = await callMcpTool("nexarch_get_company_onboarding", {}, mcpOpts);
|
|
816
|
+
const onboarding = parseToolText(onboardingRaw);
|
|
817
|
+
if (onboarding.isComplete !== true) {
|
|
818
|
+
const message = "Company onboarding is incomplete. Complete onboarding before running init-project.";
|
|
819
|
+
if (asJson) {
|
|
820
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: "COMPANY_ONBOARDING_INCOMPLETE", message, onboardingStatus: onboarding.onboardingStatus ?? null }, null, 2)}\n`);
|
|
821
|
+
process.exitCode = 1;
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
throw new Error(message);
|
|
825
|
+
}
|
|
815
826
|
// Policy bootstrap
|
|
816
827
|
const policiesRaw = await callMcpTool("nexarch_get_applied_policies", {}, mcpOpts);
|
|
817
828
|
const policies = parseToolText(policiesRaw);
|
|
818
829
|
const policyBundleHash = policies.policyBundleHash ?? null;
|
|
830
|
+
if (!policyBundleHash) {
|
|
831
|
+
const message = "Policy bootstrap is missing for this company. Re-run onboarding setup before init-project.";
|
|
832
|
+
if (asJson) {
|
|
833
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: "POLICY_BOOTSTRAP_MISSING", message }, null, 2)}\n`);
|
|
834
|
+
process.exitCode = 1;
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
throw new Error(message);
|
|
838
|
+
}
|
|
819
839
|
const nowIso = new Date().toISOString();
|
|
820
840
|
const repoRef = repoRefOverride ?? detectedRepo?.rawRef ?? dir;
|
|
821
841
|
const repoPath = repoPathOverride ?? dir;
|
package/dist/commands/setup.js
CHANGED
|
@@ -3,6 +3,11 @@ import { detectClientsFromRegistry, writeClientConfig, nexarchServerBlockFromReg
|
|
|
3
3
|
import { fetchAgentRegistryOrThrow } from "../lib/agent-registry.js";
|
|
4
4
|
import { initAgent } from "./init-agent.js";
|
|
5
5
|
import { login } from "./login.js";
|
|
6
|
+
import { callMcpTool } from "../lib/mcp.js";
|
|
7
|
+
function parseToolText(result) {
|
|
8
|
+
const text = result.content?.[0]?.text ?? "{}";
|
|
9
|
+
return JSON.parse(text);
|
|
10
|
+
}
|
|
6
11
|
export async function setup(args) {
|
|
7
12
|
try {
|
|
8
13
|
requireCredentials();
|
|
@@ -12,6 +17,13 @@ export async function setup(args) {
|
|
|
12
17
|
await login(args);
|
|
13
18
|
}
|
|
14
19
|
requireCredentials(); // ensure login succeeded before continuing
|
|
20
|
+
const creds = requireCredentials();
|
|
21
|
+
// Block setup until onboarding is complete for the selected company.
|
|
22
|
+
const onboardingRaw = await callMcpTool("nexarch_get_company_onboarding", {}, { companyId: creds.companyId });
|
|
23
|
+
const onboarding = parseToolText(onboardingRaw);
|
|
24
|
+
if (onboarding.isComplete !== true) {
|
|
25
|
+
throw new Error(`Company onboarding is incomplete (status=${onboarding.onboardingStatus ?? "unknown"}). Complete onboarding before running nexarch setup.`);
|
|
26
|
+
}
|
|
15
27
|
let registry;
|
|
16
28
|
try {
|
|
17
29
|
registry = await fetchAgentRegistryOrThrow();
|
|
@@ -59,6 +71,9 @@ export async function setup(args) {
|
|
|
59
71
|
console.log("\nDone. Restart your MCP client for the changes to take effect.");
|
|
60
72
|
}
|
|
61
73
|
console.log("\nRegistering this runtime as a Nexarch agent…\n");
|
|
62
|
-
|
|
74
|
+
const initAgentArgs = args.includes("--strict") ? [...args] : [...args, "--strict"];
|
|
75
|
+
if (!initAgentArgs.includes("--from-setup"))
|
|
76
|
+
initAgentArgs.push("--from-setup");
|
|
77
|
+
await initAgent(initAgentArgs);
|
|
63
78
|
console.log("\nSetup complete: MCP client config + agent registration are now in place.");
|
|
64
79
|
}
|
package/dist/lib/mcp.js
CHANGED
|
@@ -68,7 +68,7 @@ export async function mcpInitialize(options = {}) {
|
|
|
68
68
|
return callMcpRpc("initialize", {
|
|
69
69
|
protocolVersion: "2024-11-05",
|
|
70
70
|
capabilities: {},
|
|
71
|
-
clientInfo: { name: "nexarch-cli", version: "0.5.
|
|
71
|
+
clientInfo: { name: "nexarch-cli", version: "0.5.5" },
|
|
72
72
|
}, options);
|
|
73
73
|
}
|
|
74
74
|
export async function mcpListTools(options = {}) {
|