nexarch 0.4.4 → 0.4.6

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.
@@ -33,6 +33,7 @@ function parseCsv(value) {
33
33
  export async function agentIdentify(args) {
34
34
  const asJson = parseFlag(args, "--json");
35
35
  const agentId = parseOptionValue(args, "--agent-id") ?? getDefaultAgentId();
36
+ const looksLikeUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(agentId);
36
37
  const provider = parseOptionValue(args, "--provider");
37
38
  const model = parseOptionValue(args, "--model");
38
39
  const client = parseOptionValue(args, "--client");
@@ -44,6 +45,9 @@ export async function agentIdentify(args) {
44
45
  if (!provider || !model || !client) {
45
46
  throw new Error("agent-identify requires --provider, --model, and --client");
46
47
  }
48
+ if (looksLikeUuid) {
49
+ throw new Error(`agent-identify expects the stable agent id (e.g. nexarch-cli:user@host), not a graph entity UUID (${agentId}). Re-run using --agent-id \"${getDefaultAgentId()}\" or omit --agent-id.`);
50
+ }
47
51
  const creds = requireCredentials();
48
52
  await mcpInitialize({ companyId: creds.companyId });
49
53
  const tools = await mcpListTools({ companyId: creds.companyId });
@@ -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.4.4";
8
+ const CLI_VERSION = "0.4.6";
9
9
  const AGENT_ENTITY_TYPE = "agent";
10
10
  const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
11
11
  function parseFlag(args, flag) {
@@ -214,6 +214,34 @@ function injectAgentConfigs(registry) {
214
214
  }
215
215
  return results;
216
216
  }
217
+ function injectGenericAgentConfig(registry) {
218
+ const templateByCode = new Map(registry.instructionTemplates.map((t) => [t.code, t]));
219
+ const genericTargets = [...registry.instructionTargets]
220
+ .filter((t) => t.runtimeCode === "generic" && t.matchMode === "exact")
221
+ .sort((a, b) => a.sortOrder - b.sortOrder || a.filePathPattern.localeCompare(b.filePathPattern));
222
+ for (const target of genericTargets) {
223
+ const template = templateByCode.get(target.templateCode);
224
+ if (!template)
225
+ continue;
226
+ const filePath = join(process.cwd(), target.filePathPattern);
227
+ if (!existsSync(filePath))
228
+ continue;
229
+ const existing = readFileSync(filePath, "utf8");
230
+ const sectionBody = template.body.trim();
231
+ const sectionHeading = target.sectionHeading ?? "## Nexarch Agent Registration";
232
+ if (target.insertionMode === "replace_section") {
233
+ const replaced = replaceInjectedSection(existing, sectionHeading, sectionBody);
234
+ if (replaced !== existing) {
235
+ writeFileSync(filePath, replaced, "utf8");
236
+ return [{ path: filePath, status: "updated" }];
237
+ }
238
+ }
239
+ const separator = existing.endsWith("\n") ? "" : "\n";
240
+ writeFileSync(filePath, existing + separator + sectionBody + "\n", "utf8");
241
+ return [{ path: filePath, status: "injected" }];
242
+ }
243
+ throw new Error("No runtime instruction target matched this repository, and no generic target could be applied. Add a matching instruction target in the agent registry (or create the expected target file in this repo).");
244
+ }
217
245
  export async function initAgent(args) {
218
246
  const asJson = parseFlag(args, "--json");
219
247
  const strict = parseFlag(args, "--strict");
@@ -651,7 +679,6 @@ export async function initAgent(args) {
651
679
  }
652
680
  }
653
681
  }
654
- let bootstrapFilePath = null;
655
682
  let agentConfigResults = [];
656
683
  if (registration.ok) {
657
684
  try {
@@ -663,24 +690,9 @@ export async function initAgent(args) {
663
690
  catch {
664
691
  // non-fatal
665
692
  }
666
- try {
667
- bootstrapFilePath = writeAgentBootstrap({
668
- agentId,
669
- hostname: runtime.hostname,
670
- osPlatform: runtime.osPlatform,
671
- osRelease: runtime.osRelease,
672
- nodeVersion: runtime.nodeVersion,
673
- arch: runtime.arch,
674
- });
675
- }
676
- catch {
677
- // non-fatal
678
- }
679
- try {
680
- agentConfigResults = injectAgentConfigs(registry);
681
- }
682
- catch {
683
- // non-fatal
693
+ agentConfigResults = injectAgentConfigs(registry);
694
+ if (agentConfigResults.length === 0) {
695
+ agentConfigResults = injectGenericAgentConfig(registry);
684
696
  }
685
697
  }
686
698
  checks.push({
@@ -742,7 +754,6 @@ export async function initAgent(args) {
742
754
  },
743
755
  companyId: creds.companyId,
744
756
  registry: { version: registry.release.version, registryVersion: registry.registryVersion, publishedAt: registry.release.publishedAt },
745
- bootstrapFile: bootstrapFilePath,
746
757
  agentConfigs: agentConfigResults,
747
758
  };
748
759
  process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
@@ -762,9 +773,7 @@ export async function initAgent(args) {
762
773
  console.log("");
763
774
  if (allPassed) {
764
775
  console.log("āœ… Agent handshake + registration completed.");
765
- if (bootstrapFilePath) {
766
- console.log(`\nšŸ“‹ Bootstrap instructions written to: ${bootstrapFilePath}`);
767
- }
776
+ // instructions were injected from registry templates
768
777
  for (const r of agentConfigResults) {
769
778
  if (r.status === "injected") {
770
779
  console.log(`šŸ“ Nexarch registration instructions added to: ${r.path}`);
@@ -773,9 +782,17 @@ export async function initAgent(args) {
773
782
  console.log(`šŸ“ Nexarch registration instructions updated in: ${r.path}`);
774
783
  }
775
784
  }
776
- console.log("\nāž” Next step (required): complete agent identity in your coding agent");
777
- console.log(" Paste this and fill in real values:");
778
- 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`);
785
+ const hasInjectedAgentInstructions = agentConfigResults.some((r) => r.status === "injected" || r.status === "updated");
786
+ if (hasInjectedAgentInstructions) {
787
+ console.log("\nāž” Next step: in your coding agent, run:");
788
+ console.log("\nrun npx nexarch@latest init-agent\n");
789
+ console.log(" (Registration instructions were already written into your agent config file.)");
790
+ }
791
+ else {
792
+ console.log("\nāž” Next step (required): complete agent identity in your coding agent");
793
+ console.log(" Paste this and fill in real values:");
794
+ 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`);
795
+ }
779
796
  }
780
797
  else {
781
798
  console.log("⚠ Handshake/registration completed with issues.");
@@ -44,6 +44,9 @@ export async function fetchAgentRegistryOrThrow() {
44
44
  }
45
45
  catch (err) {
46
46
  const message = err instanceof Error ? err.message : String(err);
47
+ if (/token is invalid, expired, or revoked/i.test(message)) {
48
+ throw new Error("Your Nexarch session has expired. Run `nexarch login` and then retry `nexarch setup`.");
49
+ }
47
50
  throw new Error(`Nexarch integration registry unavailable. This command is blocked until service is restored. (${message})`);
48
51
  }
49
52
  }
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.4.4" },
71
+ clientInfo: { name: "nexarch-cli", version: "0.4.6" },
72
72
  }, options);
73
73
  }
74
74
  export async function mcpListTools(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexarch",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Your architecture workspace for AI delivery.",
5
5
  "keywords": [
6
6
  "nexarch",