nexarch 0.6.4 → 0.6.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/check-in.js +10 -20
- package/dist/commands/command-claim.js +3 -9
- package/dist/commands/init-agent.js +1 -1
- package/dist/commands/init-project.js +1 -26
- package/dist/commands/login.js +17 -0
- package/dist/commands/logout.js +7 -0
- package/dist/index.js +2 -5
- package/package.json +1 -1
|
@@ -23,29 +23,24 @@ function parseToolText(result) {
|
|
|
23
23
|
function loadIdentity() {
|
|
24
24
|
const identityPath = join(homedir(), ".nexarch", "identity.json");
|
|
25
25
|
if (!existsSync(identityPath))
|
|
26
|
-
return { agentKey: null,
|
|
26
|
+
return { agentKey: null, companyId: null };
|
|
27
27
|
try {
|
|
28
28
|
const data = JSON.parse(readFileSync(identityPath, "utf8"));
|
|
29
|
-
return {
|
|
30
|
-
agentKey: data.agentKey ?? null,
|
|
31
|
-
projectKeys: Array.isArray(data.projectKeys) ? data.projectKeys : [],
|
|
32
|
-
};
|
|
29
|
+
return { agentKey: data.agentKey ?? null, companyId: data.companyId ?? null };
|
|
33
30
|
}
|
|
34
31
|
catch {
|
|
35
|
-
return { agentKey: null,
|
|
32
|
+
return { agentKey: null, companyId: null };
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
export async function checkIn(args) {
|
|
39
36
|
const asJson = parseFlag(args, "--json");
|
|
40
37
|
const agentKeyArg = parseOptionValue(args, "--agent-key");
|
|
41
|
-
const projectKey = parseOptionValue(args, "--project");
|
|
42
38
|
const creds = requireCredentials();
|
|
43
39
|
const identity = loadIdentity();
|
|
44
40
|
const agentKey = agentKeyArg ?? identity.agentKey;
|
|
45
|
-
const resolvedProjectKeys = projectKey ? [projectKey] : identity.projectKeys;
|
|
46
41
|
if (!agentKey) {
|
|
47
42
|
if (asJson) {
|
|
48
|
-
process.stdout.write(JSON.stringify({
|
|
43
|
+
process.stdout.write(JSON.stringify({ commands: [], reason: "no-agent-key" }) + "\n");
|
|
49
44
|
}
|
|
50
45
|
else {
|
|
51
46
|
console.log("No agent key found. Pass --agent-key or run nexarch init-agent first.");
|
|
@@ -54,7 +49,6 @@ export async function checkIn(args) {
|
|
|
54
49
|
}
|
|
55
50
|
const raw = await callMcpTool("nexarch_claim_command", {
|
|
56
51
|
agentKey,
|
|
57
|
-
...(resolvedProjectKeys.length > 0 ? { projectKeys: resolvedProjectKeys } : {}),
|
|
58
52
|
companyId: creds.companyId,
|
|
59
53
|
}, { companyId: creds.companyId });
|
|
60
54
|
const result = parseToolText(raw);
|
|
@@ -68,9 +62,13 @@ export async function checkIn(args) {
|
|
|
68
62
|
return;
|
|
69
63
|
}
|
|
70
64
|
console.log("\nPending application-target commands (preview only; nothing claimed):");
|
|
65
|
+
console.log(`Company scope is resolved server-side from companyId=${creds.companyId}.`);
|
|
66
|
+
if (identity.companyId && identity.companyId !== creds.companyId) {
|
|
67
|
+
console.log(`Note: local identity companyId ${identity.companyId} differs from current credentials companyId ${creds.companyId}.`);
|
|
68
|
+
}
|
|
71
69
|
for (const cmd of commands) {
|
|
72
70
|
const claimable = cmd.claimable ? "yes" : "no";
|
|
73
|
-
const reason = cmd.claimReason ?? (cmd.claimable ? "
|
|
71
|
+
const reason = cmd.claimReason ?? (cmd.claimable ? "application_access_confirmed" : "application_not_found_for_company");
|
|
74
72
|
console.log(`\n- ID : ${cmd.id}`);
|
|
75
73
|
console.log(` Type : ${cmd.command_type}`);
|
|
76
74
|
console.log(` Target : ${cmd.target_entity_key ?? "(none)"}`);
|
|
@@ -81,17 +79,9 @@ export async function checkIn(args) {
|
|
|
81
79
|
if (cmd.resolved_runtime_handler)
|
|
82
80
|
console.log(` Runtime : ${cmd.resolved_runtime_handler}`);
|
|
83
81
|
if (cmd.claimable) {
|
|
84
|
-
console.log(` Claim cmd : npx nexarch command-claim --id "${cmd.id}"
|
|
82
|
+
console.log(` Claim cmd : npx nexarch command-claim --id "${cmd.id}"`);
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
|
-
console.log("\nCurrent project scope:");
|
|
88
|
-
if (resolvedProjectKeys.length === 0) {
|
|
89
|
-
console.log(" (none) — use --project <application:key> to scope claims");
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
for (const key of resolvedProjectKeys)
|
|
93
|
-
console.log(` - ${key}`);
|
|
94
|
-
}
|
|
95
85
|
console.log("\nTo validate an application target is accessible in Nexarch before claiming:");
|
|
96
86
|
console.log(" npx nexarch policy-controls --entity <application:key> --json");
|
|
97
87
|
}
|
|
@@ -23,23 +23,19 @@ function parseToolText(result) {
|
|
|
23
23
|
function loadIdentity() {
|
|
24
24
|
const identityPath = join(homedir(), ".nexarch", "identity.json");
|
|
25
25
|
if (!existsSync(identityPath))
|
|
26
|
-
return { agentKey: null
|
|
26
|
+
return { agentKey: null };
|
|
27
27
|
try {
|
|
28
28
|
const data = JSON.parse(readFileSync(identityPath, "utf8"));
|
|
29
|
-
return {
|
|
30
|
-
agentKey: data.agentKey ?? null,
|
|
31
|
-
projectKeys: Array.isArray(data.projectKeys) ? data.projectKeys : [],
|
|
32
|
-
};
|
|
29
|
+
return { agentKey: data.agentKey ?? null };
|
|
33
30
|
}
|
|
34
31
|
catch {
|
|
35
|
-
return { agentKey: null
|
|
32
|
+
return { agentKey: null };
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
export async function commandClaim(args) {
|
|
39
36
|
const asJson = parseFlag(args, "--json");
|
|
40
37
|
const id = parseOptionValue(args, "--id");
|
|
41
38
|
const agentKeyArg = parseOptionValue(args, "--agent-key");
|
|
42
|
-
const projectKey = parseOptionValue(args, "--project");
|
|
43
39
|
if (!id) {
|
|
44
40
|
console.error("error: --id <commandId> is required");
|
|
45
41
|
process.exit(1);
|
|
@@ -47,7 +43,6 @@ export async function commandClaim(args) {
|
|
|
47
43
|
const creds = requireCredentials();
|
|
48
44
|
const identity = loadIdentity();
|
|
49
45
|
const agentKey = agentKeyArg ?? identity.agentKey;
|
|
50
|
-
const resolvedProjectKeys = projectKey ? [projectKey] : identity.projectKeys;
|
|
51
46
|
if (!agentKey) {
|
|
52
47
|
console.error("error: no agent key found. Pass --agent-key or run nexarch init-agent first.");
|
|
53
48
|
process.exit(1);
|
|
@@ -55,7 +50,6 @@ export async function commandClaim(args) {
|
|
|
55
50
|
const raw = await callMcpTool("nexarch_claim_command_by_id", {
|
|
56
51
|
commandId: id,
|
|
57
52
|
agentKey,
|
|
58
|
-
...(resolvedProjectKeys.length > 0 ? { projectKeys: resolvedProjectKeys } : {}),
|
|
59
53
|
companyId: creds.companyId,
|
|
60
54
|
}, { companyId: creds.companyId });
|
|
61
55
|
const result = parseToolText(raw);
|
|
@@ -756,7 +756,7 @@ export async function initAgent(args) {
|
|
|
756
756
|
// Save identity so check-in can find the agent key
|
|
757
757
|
const identityDir = join(homedir(), ".nexarch");
|
|
758
758
|
mkdirSync(identityDir, { recursive: true });
|
|
759
|
-
writeFileSync(join(identityDir, "identity.json"), JSON.stringify({ agentKey: `agent:${agentId}
|
|
759
|
+
writeFileSync(join(identityDir, "identity.json"), JSON.stringify({ agentKey: `agent:${agentId}`, companyId: creds.companyId }, null, 2), { mode: 0o600 });
|
|
760
760
|
}
|
|
761
761
|
catch {
|
|
762
762
|
// non-fatal
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import process from "process";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { existsSync,
|
|
3
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
4
4
|
import { basename, join, relative, resolve as resolvePath } from "node:path";
|
|
5
|
-
import { homedir } from "node:os";
|
|
6
5
|
import { requireCredentials } from "../lib/credentials.js";
|
|
7
6
|
import { callMcpTool } from "../lib/mcp.js";
|
|
8
7
|
import { buildVersionAttributes } from "../lib/version-normalization.js";
|
|
@@ -1234,30 +1233,6 @@ ${subPkgSection}${gapCheckSection}`;
|
|
|
1234
1233
|
relationshipErrors: relsResult?.errors ?? [],
|
|
1235
1234
|
enrichmentTask,
|
|
1236
1235
|
};
|
|
1237
|
-
// Persist all application entity keys to ~/.nexarch/identity.json so nexarch check-in
|
|
1238
|
-
// can automatically claim commands targeted at any application in this project.
|
|
1239
|
-
if (output.ok) {
|
|
1240
|
-
try {
|
|
1241
|
-
const allAppKeys = [
|
|
1242
|
-
projectExternalKey,
|
|
1243
|
-
...subPackages
|
|
1244
|
-
.filter((sp) => sp.entityType === "application" && sp.externalKey)
|
|
1245
|
-
.map((sp) => sp.externalKey),
|
|
1246
|
-
];
|
|
1247
|
-
const identityDir = join(homedir(), ".nexarch");
|
|
1248
|
-
mkdirSync(identityDir, { recursive: true });
|
|
1249
|
-
const identityPath = join(identityDir, "identity.json");
|
|
1250
|
-
const existing = existsSync(identityPath)
|
|
1251
|
-
? JSON.parse(readFileSync(identityPath, "utf8"))
|
|
1252
|
-
: {};
|
|
1253
|
-
const stored = Array.isArray(existing.projectKeys) ? existing.projectKeys : [];
|
|
1254
|
-
const merged = Array.from(new Set([...allAppKeys, ...stored]));
|
|
1255
|
-
writeFileSync(identityPath, JSON.stringify({ ...existing, projectKeys: merged }, null, 2), { mode: 0o600 });
|
|
1256
|
-
}
|
|
1257
|
-
catch {
|
|
1258
|
-
// non-fatal
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
1236
|
if (asJson) {
|
|
1262
1237
|
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
1263
1238
|
if (!output.ok)
|
package/dist/commands/login.js
CHANGED
|
@@ -3,6 +3,9 @@ import { createServer as createNetServer } from "net";
|
|
|
3
3
|
import { randomBytes } from "crypto";
|
|
4
4
|
import { execFile } from "child_process";
|
|
5
5
|
import { saveCredentials } from "../lib/credentials.js";
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
7
|
+
import { homedir } from "os";
|
|
8
|
+
import { join } from "path";
|
|
6
9
|
const NEXARCH_URL = "https://nexarch.ai";
|
|
7
10
|
const LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
8
11
|
function printLoginBanner() {
|
|
@@ -152,6 +155,20 @@ export async function login(args) {
|
|
|
152
155
|
companyId,
|
|
153
156
|
expiresAt: expiresAt.toISOString(),
|
|
154
157
|
});
|
|
158
|
+
try {
|
|
159
|
+
const identityDir = join(homedir(), ".nexarch");
|
|
160
|
+
mkdirSync(identityDir, { recursive: true });
|
|
161
|
+
const identityPath = join(identityDir, "identity.json");
|
|
162
|
+
const existing = existsSync(identityPath)
|
|
163
|
+
? JSON.parse(readFileSync(identityPath, "utf8"))
|
|
164
|
+
: {};
|
|
165
|
+
const next = { ...existing, companyId };
|
|
166
|
+
delete next.projectKeys;
|
|
167
|
+
writeFileSync(identityPath, JSON.stringify(next, null, 2), { mode: 0o600 });
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// non-fatal
|
|
171
|
+
}
|
|
155
172
|
console.log("✓ Logged in successfully");
|
|
156
173
|
console.log("\nRun `nexarch status` to verify your connection.");
|
|
157
174
|
}
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { loadCredentials, removeCredentials } from "../lib/credentials.js";
|
|
2
|
+
import { existsSync, rmSync } from "fs";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { join } from "path";
|
|
2
5
|
export async function logout(_args) {
|
|
3
6
|
const creds = loadCredentials();
|
|
4
7
|
if (!creds) {
|
|
@@ -6,7 +9,11 @@ export async function logout(_args) {
|
|
|
6
9
|
return;
|
|
7
10
|
}
|
|
8
11
|
removeCredentials();
|
|
12
|
+
const identityPath = join(homedir(), ".nexarch", "identity.json");
|
|
13
|
+
if (existsSync(identityPath))
|
|
14
|
+
rmSync(identityPath);
|
|
9
15
|
console.log("✓ Logged out. Credentials removed from ~/.nexarch/credentials.json");
|
|
16
|
+
console.log("✓ Local identity removed from ~/.nexarch/identity.json");
|
|
10
17
|
console.log("\nNote: the token still exists in your Nexarch workspace until revoked.");
|
|
11
18
|
console.log("To revoke it, visit Workspace → Agents → Manage tokens.");
|
|
12
19
|
}
|
package/dist/index.js
CHANGED
|
@@ -119,17 +119,14 @@ Usage:
|
|
|
119
119
|
results before calling add-relationship.
|
|
120
120
|
Options: --names <csv> (required, e.g. "vercel,neon")
|
|
121
121
|
--json
|
|
122
|
-
nexarch check-in Preview pending application-target commands
|
|
123
|
-
|
|
124
|
-
(written by init-agent) or via --agent-key.
|
|
122
|
+
nexarch check-in Preview pending application-target commands (no auto-claim).
|
|
123
|
+
Scope is resolved server-side from active company context.
|
|
125
124
|
Options: --agent-key <key> override stored agent key
|
|
126
|
-
--project <key> application entity key
|
|
127
125
|
--json
|
|
128
126
|
nexarch command-claim
|
|
129
127
|
Explicitly claim a pending command by ID.
|
|
130
128
|
Options: --id <commandId> (required)
|
|
131
129
|
--agent-key <key> override stored agent key
|
|
132
|
-
--project <key> application entity key
|
|
133
130
|
--json
|
|
134
131
|
nexarch command-done
|
|
135
132
|
Mark a claimed command as completed.
|