@neus/sdk 1.1.7 → 1.2.1

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/cjs/mcp-hosts.cjs CHANGED
@@ -25,24 +25,79 @@ __export(mcp_hosts_exports, {
25
25
  MCP_INSTALL_CLIENTS: () => MCP_INSTALL_CLIENTS,
26
26
  MCP_INSTALL_HOSTS: () => MCP_INSTALL_HOSTS,
27
27
  NEUS_AUTH_CLI: () => NEUS_AUTH_CLI,
28
+ NEUS_AUTH_NPX: () => NEUS_AUTH_NPX,
29
+ NEUS_CHECK_CLI: () => NEUS_CHECK_CLI,
30
+ NEUS_CHECK_NPX: () => NEUS_CHECK_NPX,
31
+ NEUS_DOCTOR_CLI: () => NEUS_DOCTOR_CLI,
32
+ NEUS_DOCTOR_NPX: () => NEUS_DOCTOR_NPX,
33
+ NEUS_EXAMPLES_CLI: () => NEUS_EXAMPLES_CLI,
34
+ NEUS_EXAMPLES_NPX: () => NEUS_EXAMPLES_NPX,
35
+ NEUS_INSTALL_CLI: () => NEUS_INSTALL_CLI,
28
36
  NEUS_MCP_SERVER_NAME: () => NEUS_MCP_SERVER_NAME,
29
37
  NEUS_MCP_SETUP_DOCS_URL: () => NEUS_MCP_SETUP_DOCS_URL,
30
38
  NEUS_MCP_URL: () => NEUS_MCP_URL,
39
+ NEUS_MOUNT_WORKFLOW: () => NEUS_MOUNT_WORKFLOW,
40
+ NEUS_NPX: () => NEUS_NPX,
41
+ NEUS_PKG: () => NEUS_PKG,
42
+ NEUS_QUICKSTART_INSTALLED: () => NEUS_QUICKSTART_INSTALLED,
43
+ NEUS_QUICKSTART_NPX: () => NEUS_QUICKSTART_NPX,
31
44
  NEUS_SETUP_CLI: () => NEUS_SETUP_CLI,
45
+ NEUS_SETUP_NPX: () => NEUS_SETUP_NPX,
32
46
  buildAuthCommandForClient: () => buildAuthCommandForClient,
33
47
  buildCursorMcpInstallUrl: () => buildCursorMcpInstallUrl,
34
48
  buildNeusMcpHttpConfig: () => buildNeusMcpHttpConfig,
35
49
  buildSetupCommandForClient: () => buildSetupCommandForClient,
36
50
  buildSetupCommandForHost: () => buildSetupCommandForHost,
51
+ buildSetupNpxOneLiner: () => buildSetupNpxOneLiner,
37
52
  buildVsCodeMcpInstallUrl: () => buildVsCodeMcpInstallUrl,
53
+ neusCmd: () => neusCmd,
54
+ neusMountApply: () => neusMountApply,
55
+ neusMountApplyNpx: () => neusMountApplyNpx,
56
+ neusNpx: () => neusNpx,
38
57
  supportsMcpInstallDeeplink: () => supportsMcpInstallDeeplink
39
58
  });
40
59
  module.exports = __toCommonJS(mcp_hosts_exports);
60
+
61
+ // cli-commands.js
62
+ var NEUS_PKG = "@neus/sdk";
63
+ var NEUS_INSTALL_CLI = `npm i -g ${NEUS_PKG}`;
64
+ var NEUS_NPX = `npx ${NEUS_PKG}`;
65
+ var NEUS_SETUP_CLI = "neus setup";
66
+ var NEUS_AUTH_CLI = "neus auth";
67
+ var NEUS_CHECK_CLI = "neus check";
68
+ var NEUS_DOCTOR_CLI = "neus doctor --live";
69
+ var NEUS_EXAMPLES_CLI = "neus examples";
70
+ var NEUS_SETUP_NPX = `${NEUS_NPX} setup`;
71
+ var NEUS_AUTH_NPX = `${NEUS_NPX} auth`;
72
+ var NEUS_CHECK_NPX = `${NEUS_NPX} check`;
73
+ var NEUS_DOCTOR_NPX = `${NEUS_NPX} doctor --live`;
74
+ var NEUS_EXAMPLES_NPX = `${NEUS_NPX} examples`;
75
+ function neusMountApply(agentId, host = "cursor") {
76
+ const id = String(agentId || "").trim();
77
+ return `neus mount ${id} --apply ${host}`;
78
+ }
79
+ function neusMountApplyNpx(agentId, host = "cursor") {
80
+ const id = String(agentId || "").trim();
81
+ return `${NEUS_NPX} mount ${id} --apply ${host}`;
82
+ }
83
+ var NEUS_QUICKSTART_INSTALLED = `${NEUS_INSTALL_CLI}
84
+ ${NEUS_SETUP_CLI}
85
+ ${NEUS_AUTH_CLI}`;
86
+ var NEUS_QUICKSTART_NPX = NEUS_SETUP_NPX;
87
+ var NEUS_MOUNT_WORKFLOW = `${NEUS_AUTH_CLI}
88
+ neus mount <agentId> --apply cursor
89
+ ${NEUS_DOCTOR_CLI}`;
90
+ function neusCmd(subcommand) {
91
+ return `neus ${String(subcommand || "").trim()}`;
92
+ }
93
+ function neusNpx(subcommand) {
94
+ return `${NEUS_NPX} ${String(subcommand || "").trim()}`;
95
+ }
96
+
97
+ // mcp-hosts.js
41
98
  var NEUS_MCP_SERVER_NAME = "neus";
42
99
  var NEUS_MCP_URL = "https://mcp.neus.network/mcp";
43
- var NEUS_SETUP_CLI = "npx -y -p @neus/sdk neus setup";
44
- var NEUS_AUTH_CLI = "npx -y -p @neus/sdk neus auth";
45
- var NEUS_MCP_SETUP_DOCS_URL = "https://docs.neus.network/mcp/ide-plugin";
100
+ var NEUS_MCP_SETUP_DOCS_URL = "https://docs.neus.network/mcp/setup";
46
101
  var MCP_INSTALL_CLIENTS = ["claude", "codex", "cursor", "vscode"];
47
102
  var MCP_INSTALL_HOSTS = ["cursor", "claude", "codex"];
48
103
  var IDE_HOST_LABELS = {
@@ -84,20 +139,29 @@ function buildVsCodeMcpInstallUrl(accessKey) {
84
139
  }
85
140
  function buildAuthCommandForClient(client) {
86
141
  if (client === "codex") {
87
- return `${NEUS_AUTH_CLI} --client codex`;
142
+ return neusCmd(`auth --client codex`);
88
143
  }
89
144
  return NEUS_AUTH_CLI;
90
145
  }
91
146
  function buildSetupCommandForClient(client, accessKey) {
92
147
  const key = String(accessKey || "").trim();
93
- const setup = key ? `${NEUS_SETUP_CLI} --client ${client} --access-key ${key}` : `${NEUS_SETUP_CLI} --client ${client}`;
94
- if (key) return setup;
95
- return `${setup}
96
- ${buildAuthCommandForClient(client)}`;
148
+ const setup = key ? neusCmd(`setup --client ${client} --access-key ${key}`) : neusCmd(`setup --client ${client}`);
149
+ if (key) {
150
+ return `${NEUS_INSTALL_CLI}
151
+ ${setup}`;
152
+ }
153
+ const auth = buildAuthCommandForClient(client);
154
+ return `${NEUS_INSTALL_CLI}
155
+ ${setup}
156
+ ${auth}`;
97
157
  }
98
158
  function buildSetupCommandForHost(host, accessKey) {
99
159
  return buildSetupCommandForClient(host, accessKey);
100
160
  }
161
+ function buildSetupNpxOneLiner(client) {
162
+ if (!client) return NEUS_SETUP_NPX;
163
+ return `${NEUS_NPX} setup --client ${client}`;
164
+ }
101
165
  function supportsMcpInstallDeeplink(host) {
102
166
  if (host !== "cursor") return false;
103
167
  if (typeof navigator === "undefined") return false;
@@ -111,15 +175,34 @@ function supportsMcpInstallDeeplink(host) {
111
175
  MCP_INSTALL_CLIENTS,
112
176
  MCP_INSTALL_HOSTS,
113
177
  NEUS_AUTH_CLI,
178
+ NEUS_AUTH_NPX,
179
+ NEUS_CHECK_CLI,
180
+ NEUS_CHECK_NPX,
181
+ NEUS_DOCTOR_CLI,
182
+ NEUS_DOCTOR_NPX,
183
+ NEUS_EXAMPLES_CLI,
184
+ NEUS_EXAMPLES_NPX,
185
+ NEUS_INSTALL_CLI,
114
186
  NEUS_MCP_SERVER_NAME,
115
187
  NEUS_MCP_SETUP_DOCS_URL,
116
188
  NEUS_MCP_URL,
189
+ NEUS_MOUNT_WORKFLOW,
190
+ NEUS_NPX,
191
+ NEUS_PKG,
192
+ NEUS_QUICKSTART_INSTALLED,
193
+ NEUS_QUICKSTART_NPX,
117
194
  NEUS_SETUP_CLI,
195
+ NEUS_SETUP_NPX,
118
196
  buildAuthCommandForClient,
119
197
  buildCursorMcpInstallUrl,
120
198
  buildNeusMcpHttpConfig,
121
199
  buildSetupCommandForClient,
122
200
  buildSetupCommandForHost,
201
+ buildSetupNpxOneLiner,
123
202
  buildVsCodeMcpInstallUrl,
203
+ neusCmd,
204
+ neusMountApply,
205
+ neusMountApplyNpx,
206
+ neusNpx,
124
207
  supportsMcpInstallDeeplink
125
208
  });
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // runtime-adapters.js
31
+ var runtime_adapters_exports = {};
32
+ __export(runtime_adapters_exports, {
33
+ MOUNT_MANIFEST_RELATIVE: () => MOUNT_MANIFEST_RELATIVE,
34
+ applyRuntimeBundle: () => applyRuntimeBundle,
35
+ bundleToClaudeMd: () => bundleToClaudeMd,
36
+ bundleToCodexJson: () => bundleToCodexJson,
37
+ bundleToCursorRules: () => bundleToCursorRules,
38
+ readMountManifest: () => readMountManifest,
39
+ sanitizeAgentIdForFilename: () => sanitizeAgentIdForFilename,
40
+ writeMountManifest: () => writeMountManifest
41
+ });
42
+ module.exports = __toCommonJS(runtime_adapters_exports);
43
+ var import_node_fs = __toESM(require("node:fs"), 1);
44
+ var import_node_path = __toESM(require("node:path"), 1);
45
+
46
+ // runtime-mount.js
47
+ var RUNTIME_MOUNT_SCHEMA = "neus.runtime-mount.v1";
48
+
49
+ // runtime-adapters.js
50
+ var MOUNT_MANIFEST_RELATIVE = import_node_path.default.join(".neus", "mount.json");
51
+ function sanitizeAgentIdForFilename(agentId) {
52
+ return String(agentId || "agent").trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "agent";
53
+ }
54
+ function bundleToCursorRules(bundle) {
55
+ const id = bundle.identity.agentId;
56
+ const label = bundle.identity.agentLabel || id;
57
+ const skillsBlock = (bundle.identity.skills || []).map((skill) => {
58
+ if (typeof skill === "string") return `- ${skill}`;
59
+ const labelText = skill.label || skill.id || "skill";
60
+ const kind = skill.kind || "skill";
61
+ const provider = skill.provider ? ` / ${skill.provider}` : "";
62
+ return `- ${labelText} (${kind}${provider})`;
63
+ }).join("\n");
64
+ const denied = (bundle.enforce.deniedActions || []).map((action) => `- ${action}`).join("\n");
65
+ const capabilities = (bundle.identity.capabilities || []).map((cap) => `- ${cap}`).join("\n");
66
+ const services = (bundle.identity.services || []).map((svc) => `- ${svc.name}: ${svc.endpoint}${svc.version ? ` (v${svc.version})` : ""}`).join("\n");
67
+ return `---
68
+ description: NEUS proof-backed agent \u2014 ${label}
69
+ globs:
70
+ alwaysApply: true
71
+ ---
72
+
73
+ # NEUS Agent \u2014 ${label}
74
+
75
+ You are **${label}** (\`${id}\`). This project mounted trust context from NEUS.
76
+
77
+ ## Identity
78
+ ${bundle.identity.description || bundle.identity.instructions || "Follow the agent instructions below."}
79
+
80
+ ## Instructions
81
+ ${bundle.identity.instructions || "Use NEUS MCP for trust checks before sensitive actions."}
82
+
83
+ ## Capabilities
84
+ ${capabilities || "- General purpose"}
85
+
86
+ ## Skills
87
+ ${skillsBlock || "- None configured"}
88
+
89
+ ## Services
90
+ ${services || "- None configured"}
91
+
92
+ ## Scoped policy
93
+ ${denied ? `Denied actions (do not perform without new approval):
94
+ ${denied}` : "- Follow delegation on file via NEUS MCP."}
95
+
96
+ ## Trust workflow
97
+ 1. Call \`neus_context\` once per session when NEUS MCP is available.
98
+ 2. Trust before action: \`neus_proofs_check\` then \`neus_verify_or_guide\`.
99
+ 3. Do not invent qHashes, wallets, or receipt fields.
100
+ 4. Summarize NEUS outcomes as Trust Result \u2014 never dump raw tool JSON.
101
+
102
+ ## Proof references
103
+ - Identity: ${bundle.trust.identityProofUrl}
104
+ ${bundle.trust.delegationProofUrl ? `- Delegation: ${bundle.trust.delegationProofUrl}` : "- Delegation: not on file \u2014 call `neus_agent_link` before acting as this agent."}
105
+ `;
106
+ }
107
+ function bundleToClaudeMd(bundle) {
108
+ const id = bundle.identity.agentId;
109
+ const label = bundle.identity.agentLabel || id;
110
+ return `# NEUS Agent \u2014 ${label}
111
+
112
+ Mounted from NEUS Runtime Mount (\`${RUNTIME_MOUNT_SCHEMA}\`).
113
+
114
+ ## Identity
115
+ - **Agent ID:** ${id}
116
+ - **Label:** ${label}
117
+
118
+ ## Description
119
+ ${bundle.identity.description || "Proof-backed agent on NEUS Network."}
120
+
121
+ ## Instructions
122
+ ${bundle.identity.instructions || "Use NEUS MCP before sensitive actions."}
123
+
124
+ ## Trust receipts
125
+ - Identity: \`${bundle.trust.identityQHash}\` \u2014 ${bundle.trust.identityProofUrl}
126
+ ${bundle.trust.delegationQHash ? `- Delegation: \`${bundle.trust.delegationQHash}\` \u2014 ${bundle.trust.delegationProofUrl}` : ""}
127
+
128
+ ## Policy
129
+ - Do not invent qHashes or verifier outcomes.
130
+ - Call \`neus_context\` once; use profile context when signed in.
131
+ `;
132
+ }
133
+ function bundleToCodexJson(bundle) {
134
+ return JSON.stringify(
135
+ {
136
+ schema: RUNTIME_MOUNT_SCHEMA,
137
+ name: bundle.identity.agentLabel,
138
+ agentId: bundle.identity.agentId,
139
+ agentWallet: bundle.identity.agentWallet,
140
+ description: bundle.identity.description,
141
+ instructions: bundle.identity.instructions,
142
+ capabilities: bundle.identity.capabilities,
143
+ skills: bundle.identity.skills,
144
+ services: bundle.identity.services,
145
+ effectiveRuntime: bundle.effectiveRuntime,
146
+ enforce: bundle.enforce,
147
+ trust: bundle.trust,
148
+ mountedAt: bundle.mountedAt
149
+ },
150
+ null,
151
+ 2
152
+ );
153
+ }
154
+ function readMountManifest(cwd) {
155
+ const manifestPath = import_node_path.default.join(cwd, MOUNT_MANIFEST_RELATIVE);
156
+ if (!import_node_fs.default.existsSync(manifestPath)) return null;
157
+ try {
158
+ const parsed = JSON.parse(import_node_fs.default.readFileSync(manifestPath, "utf8"));
159
+ return parsed?.schema === RUNTIME_MOUNT_SCHEMA ? parsed : null;
160
+ } catch {
161
+ return null;
162
+ }
163
+ }
164
+ function writeMountManifest(bundle, cwd) {
165
+ const dir = import_node_path.default.join(cwd, ".neus");
166
+ import_node_fs.default.mkdirSync(dir, { recursive: true });
167
+ const manifestPath = import_node_path.default.join(dir, "mount.json");
168
+ import_node_fs.default.writeFileSync(manifestPath, `${JSON.stringify(bundle, null, 2)}
169
+ `, "utf8");
170
+ return manifestPath;
171
+ }
172
+ function applyRuntimeBundle(flavor, bundle, cwd, options = {}) {
173
+ const dryRun = Boolean(options.dryRun);
174
+ const safeId = sanitizeAgentIdForFilename(bundle.identity.agentId);
175
+ const written = [];
176
+ const manifestPath = dryRun ? import_node_path.default.join(cwd, MOUNT_MANIFEST_RELATIVE) : writeMountManifest(bundle, cwd);
177
+ written.push(manifestPath);
178
+ if (flavor === "cursor") {
179
+ const rulesDir = import_node_path.default.join(cwd, ".cursor", "rules");
180
+ const rulesPath = import_node_path.default.join(rulesDir, `neus-agent-${safeId}.mdc`);
181
+ if (!dryRun) {
182
+ import_node_fs.default.mkdirSync(rulesDir, { recursive: true });
183
+ import_node_fs.default.writeFileSync(rulesPath, bundleToCursorRules(bundle), "utf8");
184
+ }
185
+ written.push(rulesPath);
186
+ return { flavor, written, primary: rulesPath, manifestPath };
187
+ }
188
+ if (flavor === "claude") {
189
+ const claudePath = import_node_path.default.join(cwd, ".claude", "NEUS_AGENT.md");
190
+ if (!dryRun) {
191
+ import_node_fs.default.mkdirSync(import_node_path.default.join(cwd, ".claude"), { recursive: true });
192
+ import_node_fs.default.writeFileSync(claudePath, bundleToClaudeMd(bundle), "utf8");
193
+ }
194
+ written.push(claudePath);
195
+ return { flavor, written, primary: claudePath, manifestPath };
196
+ }
197
+ if (flavor === "codex") {
198
+ const codexPath = import_node_path.default.join(cwd, ".neus", `codex-agent-${safeId}.json`);
199
+ if (!dryRun) {
200
+ import_node_fs.default.mkdirSync(import_node_path.default.join(cwd, ".neus"), { recursive: true });
201
+ import_node_fs.default.writeFileSync(codexPath, bundleToCodexJson(bundle), "utf8");
202
+ }
203
+ written.push(codexPath);
204
+ return { flavor, written, primary: codexPath, manifestPath };
205
+ }
206
+ throw new Error(`Unsupported runtime adapter: ${flavor}`);
207
+ }
208
+ // Annotate the CommonJS export names for ESM import in node:
209
+ 0 && (module.exports = {
210
+ MOUNT_MANIFEST_RELATIVE,
211
+ applyRuntimeBundle,
212
+ bundleToClaudeMd,
213
+ bundleToCodexJson,
214
+ bundleToCursorRules,
215
+ readMountManifest,
216
+ sanitizeAgentIdForFilename,
217
+ writeMountManifest
218
+ });