@neus/sdk 1.2.0 → 1.2.2

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/index.cjs CHANGED
@@ -430,9 +430,9 @@ function deriveDid(address, chainIdOrChain) {
430
430
  async function resolveDID(params, options = {}) {
431
431
  const endpointPath = options.endpoint || "/api/v1/profile/did/resolve";
432
432
  const apiUrl = typeof options.apiUrl === "string" ? options.apiUrl.trim() : "";
433
- const resolveEndpoint = (path2) => {
434
- if (!path2 || typeof path2 !== "string") return null;
435
- const trimmedPath = path2.trim();
433
+ const resolveEndpoint = (path) => {
434
+ if (!path || typeof path !== "string") return null;
435
+ const trimmedPath = path.trim();
436
436
  if (!trimmedPath) return null;
437
437
  if (/^https?:\/\//i.test(trimmedPath)) return trimmedPath;
438
438
  if (trimmedPath.startsWith("/")) {
@@ -491,9 +491,9 @@ async function resolveDID(params, options = {}) {
491
491
  async function standardizeVerificationRequest(params, options = {}) {
492
492
  const endpointPath = options.endpoint || "/api/v1/verification/standardize";
493
493
  const apiUrl = typeof options.apiUrl === "string" ? options.apiUrl.trim() : "";
494
- const resolveEndpoint = (path2) => {
495
- if (!path2 || typeof path2 !== "string") return null;
496
- const trimmedPath = path2.trim();
494
+ const resolveEndpoint = (path) => {
495
+ if (!path || typeof path !== "string") return null;
496
+ const trimmedPath = path.trim();
497
497
  if (!trimmedPath) return null;
498
498
  if (/^https?:\/\//i.test(trimmedPath)) return trimmedPath;
499
499
  if (trimmedPath.startsWith("/")) {
@@ -3004,7 +3004,6 @@ __export(index_exports, {
3004
3004
  MCP_INSTALL_CLIENTS: () => MCP_INSTALL_CLIENTS,
3005
3005
  MCP_INSTALL_HOSTS: () => MCP_INSTALL_HOSTS,
3006
3006
  MONTH: () => MONTH,
3007
- MOUNT_MANIFEST_RELATIVE: () => MOUNT_MANIFEST_RELATIVE,
3008
3007
  NEUS_AUTH_CLI: () => NEUS_AUTH_CLI,
3009
3008
  NEUS_AUTH_NPX: () => NEUS_AUTH_NPX,
3010
3009
  NEUS_CHECK_CLI: () => NEUS_CHECK_CLI,
@@ -3035,7 +3034,6 @@ __export(index_exports, {
3035
3034
  VerificationError: () => VerificationError,
3036
3035
  WEEK: () => WEEK,
3037
3036
  YEAR: () => YEAR,
3038
- applyRuntimeBundle: () => applyRuntimeBundle,
3039
3037
  buildAuthCommandForClient: () => buildAuthCommandForClient,
3040
3038
  buildCursorMcpInstallUrl: () => buildCursorMcpInstallUrl,
3041
3039
  buildNeusMcpHttpConfig: () => buildNeusMcpHttpConfig,
@@ -3045,9 +3043,6 @@ __export(index_exports, {
3045
3043
  buildSetupNpxOneLiner: () => buildSetupNpxOneLiner,
3046
3044
  buildVerificationRequest: () => buildVerificationRequest,
3047
3045
  buildVsCodeMcpInstallUrl: () => buildVsCodeMcpInstallUrl,
3048
- bundleToClaudeMd: () => bundleToClaudeMd,
3049
- bundleToCodexJson: () => bundleToCodexJson,
3050
- bundleToCursorRules: () => bundleToCursorRules,
3051
3046
  combineGates: () => combineGates,
3052
3047
  computeContentHash: () => computeContentHash,
3053
3048
  constructVerificationMessage: () => constructVerificationMessage,
@@ -3077,12 +3072,10 @@ __export(index_exports, {
3077
3072
  pickActiveDelegation: () => pickActiveDelegation,
3078
3073
  pickIdentity: () => pickIdentity,
3079
3074
  profileAgentToIdentitySeed: () => profileAgentToIdentitySeed,
3080
- readMountManifest: () => readMountManifest,
3081
3075
  resolveDID: () => resolveDID,
3082
3076
  resolveEffectiveRuntime: () => resolveEffectiveRuntime,
3083
3077
  resolveRuntimeBundleFromMcp: () => resolveRuntimeBundleFromMcp,
3084
3078
  resolveZkPassportConfig: () => resolveZkPassportConfig,
3085
- sanitizeAgentIdForFilename: () => sanitizeAgentIdForFilename,
3086
3079
  signMessage: () => signMessage,
3087
3080
  standardizeVerificationRequest: () => standardizeVerificationRequest,
3088
3081
  supportsMcpInstallDeeplink: () => supportsMcpInstallDeeplink,
@@ -3094,8 +3087,7 @@ __export(index_exports, {
3094
3087
  validateUniversalAddress: () => validateUniversalAddress,
3095
3088
  validateVerifierPayload: () => validateVerifierPayload,
3096
3089
  validateWalletAddress: () => validateWalletAddress,
3097
- withRetry: () => withRetry,
3098
- writeMountManifest: () => writeMountManifest
3090
+ withRetry: () => withRetry
3099
3091
  });
3100
3092
  module.exports = __toCommonJS(index_exports);
3101
3093
  init_client();
@@ -3164,7 +3156,7 @@ function capabilitiesToArray(caps) {
3164
3156
  return Object.entries(caps).filter(([, enabled]) => enabled === true).map(([key]) => String(key).trim()).filter(Boolean);
3165
3157
  }
3166
3158
  function isDelegationExpired(expiresAt) {
3167
- if (expiresAt === null || expiresAt === void 0 || expiresAt === 0) return false;
3159
+ if (expiresAt === null || expiresAt === 0) return false;
3168
3160
  const ms = Number(expiresAt);
3169
3161
  return Number.isFinite(ms) && ms > 0 && ms <= Date.now();
3170
3162
  }
@@ -3261,7 +3253,7 @@ function extractAgentContextFromProofs(proofs) {
3261
3253
  runtimePolicy: vvData.runtimePolicy && typeof vvData.runtimePolicy === "object" ? vvData.runtimePolicy : void 0,
3262
3254
  expiresAt: vvData.expiresAt ?? null,
3263
3255
  isExpired: isDelegationExpired(vvData.expiresAt),
3264
- maxSpend: vvData.maxSpend !== null && vvData.maxSpend !== void 0 ? String(vvData.maxSpend) : void 0,
3256
+ maxSpend: vvData.maxSpend !== null ? String(vvData.maxSpend) : void 0,
3265
3257
  instructions: vvData.instructions || null,
3266
3258
  skills: Array.isArray(vvData.skills) ? vvData.skills : [],
3267
3259
  provider: vvData.provider || vvData.modelProvider || null,
@@ -3546,168 +3538,6 @@ function evaluateMountFileHealth(manifest) {
3546
3538
  };
3547
3539
  }
3548
3540
 
3549
- // runtime-adapters.js
3550
- var import_node_fs = __toESM(require("node:fs"), 1);
3551
- var import_node_path = __toESM(require("node:path"), 1);
3552
- var MOUNT_MANIFEST_RELATIVE = import_node_path.default.join(".neus", "mount.json");
3553
- function sanitizeAgentIdForFilename(agentId) {
3554
- return String(agentId || "agent").trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "agent";
3555
- }
3556
- function bundleToCursorRules(bundle) {
3557
- const id = bundle.identity.agentId;
3558
- const label = bundle.identity.agentLabel || id;
3559
- const skillsBlock = (bundle.identity.skills || []).map((skill) => {
3560
- if (typeof skill === "string") return `- ${skill}`;
3561
- const labelText = skill.label || skill.id || "skill";
3562
- const kind = skill.kind || "skill";
3563
- const provider = skill.provider ? ` / ${skill.provider}` : "";
3564
- return `- ${labelText} (${kind}${provider})`;
3565
- }).join("\n");
3566
- const denied = (bundle.enforce.deniedActions || []).map((action) => `- ${action}`).join("\n");
3567
- const capabilities = (bundle.identity.capabilities || []).map((cap) => `- ${cap}`).join("\n");
3568
- const services = (bundle.identity.services || []).map((svc) => `- ${svc.name}: ${svc.endpoint}${svc.version ? ` (v${svc.version})` : ""}`).join("\n");
3569
- return `---
3570
- description: NEUS proof-backed agent \u2014 ${label}
3571
- globs:
3572
- alwaysApply: true
3573
- ---
3574
-
3575
- # NEUS Agent \u2014 ${label}
3576
-
3577
- You are **${label}** (\`${id}\`). This project mounted trust context from NEUS.
3578
-
3579
- ## Identity
3580
- ${bundle.identity.description || bundle.identity.instructions || "Follow the agent instructions below."}
3581
-
3582
- ## Instructions
3583
- ${bundle.identity.instructions || "Use NEUS MCP for trust checks before sensitive actions."}
3584
-
3585
- ## Capabilities
3586
- ${capabilities || "- General purpose"}
3587
-
3588
- ## Skills
3589
- ${skillsBlock || "- None configured"}
3590
-
3591
- ## Services
3592
- ${services || "- None configured"}
3593
-
3594
- ## Scoped policy
3595
- ${denied ? `Denied actions (do not perform without new approval):
3596
- ${denied}` : "- Follow delegation on file via NEUS MCP."}
3597
-
3598
- ## Trust workflow
3599
- 1. Call \`neus_context\` once per session when NEUS MCP is available.
3600
- 2. Trust before action: \`neus_proofs_check\` then \`neus_verify_or_guide\`.
3601
- 3. Do not invent qHashes, wallets, or receipt fields.
3602
- 4. Summarize NEUS outcomes as Trust Result \u2014 never dump raw tool JSON.
3603
-
3604
- ## Proof references
3605
- - Identity: ${bundle.trust.identityProofUrl}
3606
- ${bundle.trust.delegationProofUrl ? `- Delegation: ${bundle.trust.delegationProofUrl}` : "- Delegation: not on file \u2014 call `neus_agent_link` before acting as this agent."}
3607
- `;
3608
- }
3609
- function bundleToClaudeMd(bundle) {
3610
- const id = bundle.identity.agentId;
3611
- const label = bundle.identity.agentLabel || id;
3612
- return `# NEUS Agent \u2014 ${label}
3613
-
3614
- Mounted from NEUS Runtime Mount (\`${RUNTIME_MOUNT_SCHEMA}\`).
3615
-
3616
- ## Identity
3617
- - **Agent ID:** ${id}
3618
- - **Label:** ${label}
3619
-
3620
- ## Description
3621
- ${bundle.identity.description || "Proof-backed agent on NEUS Network."}
3622
-
3623
- ## Instructions
3624
- ${bundle.identity.instructions || "Use NEUS MCP before sensitive actions."}
3625
-
3626
- ## Trust receipts
3627
- - Identity: \`${bundle.trust.identityQHash}\` \u2014 ${bundle.trust.identityProofUrl}
3628
- ${bundle.trust.delegationQHash ? `- Delegation: \`${bundle.trust.delegationQHash}\` \u2014 ${bundle.trust.delegationProofUrl}` : ""}
3629
-
3630
- ## Policy
3631
- - Do not invent qHashes or verifier outcomes.
3632
- - Call \`neus_context\` once; use profile context when signed in.
3633
- `;
3634
- }
3635
- function bundleToCodexJson(bundle) {
3636
- return JSON.stringify(
3637
- {
3638
- schema: RUNTIME_MOUNT_SCHEMA,
3639
- name: bundle.identity.agentLabel,
3640
- agentId: bundle.identity.agentId,
3641
- agentWallet: bundle.identity.agentWallet,
3642
- description: bundle.identity.description,
3643
- instructions: bundle.identity.instructions,
3644
- capabilities: bundle.identity.capabilities,
3645
- skills: bundle.identity.skills,
3646
- services: bundle.identity.services,
3647
- effectiveRuntime: bundle.effectiveRuntime,
3648
- enforce: bundle.enforce,
3649
- trust: bundle.trust,
3650
- mountedAt: bundle.mountedAt
3651
- },
3652
- null,
3653
- 2
3654
- );
3655
- }
3656
- function readMountManifest(cwd) {
3657
- const manifestPath = import_node_path.default.join(cwd, MOUNT_MANIFEST_RELATIVE);
3658
- if (!import_node_fs.default.existsSync(manifestPath)) return null;
3659
- try {
3660
- const parsed = JSON.parse(import_node_fs.default.readFileSync(manifestPath, "utf8"));
3661
- return parsed?.schema === RUNTIME_MOUNT_SCHEMA ? parsed : null;
3662
- } catch {
3663
- return null;
3664
- }
3665
- }
3666
- function writeMountManifest(bundle, cwd) {
3667
- const dir = import_node_path.default.join(cwd, ".neus");
3668
- import_node_fs.default.mkdirSync(dir, { recursive: true });
3669
- const manifestPath = import_node_path.default.join(dir, "mount.json");
3670
- import_node_fs.default.writeFileSync(manifestPath, `${JSON.stringify(bundle, null, 2)}
3671
- `, "utf8");
3672
- return manifestPath;
3673
- }
3674
- function applyRuntimeBundle(flavor, bundle, cwd, options = {}) {
3675
- const dryRun = Boolean(options.dryRun);
3676
- const safeId = sanitizeAgentIdForFilename(bundle.identity.agentId);
3677
- const written = [];
3678
- const manifestPath = dryRun ? import_node_path.default.join(cwd, MOUNT_MANIFEST_RELATIVE) : writeMountManifest(bundle, cwd);
3679
- written.push(manifestPath);
3680
- if (flavor === "cursor") {
3681
- const rulesDir = import_node_path.default.join(cwd, ".cursor", "rules");
3682
- const rulesPath = import_node_path.default.join(rulesDir, `neus-agent-${safeId}.mdc`);
3683
- if (!dryRun) {
3684
- import_node_fs.default.mkdirSync(rulesDir, { recursive: true });
3685
- import_node_fs.default.writeFileSync(rulesPath, bundleToCursorRules(bundle), "utf8");
3686
- }
3687
- written.push(rulesPath);
3688
- return { flavor, written, primary: rulesPath, manifestPath };
3689
- }
3690
- if (flavor === "claude") {
3691
- const claudePath = import_node_path.default.join(cwd, ".claude", "NEUS_AGENT.md");
3692
- if (!dryRun) {
3693
- import_node_fs.default.mkdirSync(import_node_path.default.join(cwd, ".claude"), { recursive: true });
3694
- import_node_fs.default.writeFileSync(claudePath, bundleToClaudeMd(bundle), "utf8");
3695
- }
3696
- written.push(claudePath);
3697
- return { flavor, written, primary: claudePath, manifestPath };
3698
- }
3699
- if (flavor === "codex") {
3700
- const codexPath = import_node_path.default.join(cwd, ".neus", `codex-agent-${safeId}.json`);
3701
- if (!dryRun) {
3702
- import_node_fs.default.mkdirSync(import_node_path.default.join(cwd, ".neus"), { recursive: true });
3703
- import_node_fs.default.writeFileSync(codexPath, bundleToCodexJson(bundle), "utf8");
3704
- }
3705
- written.push(codexPath);
3706
- return { flavor, written, primary: codexPath, manifestPath };
3707
- }
3708
- throw new Error(`Unsupported runtime adapter: ${flavor}`);
3709
- }
3710
-
3711
3541
  // index.js
3712
3542
  init_errors();
3713
3543
 
@@ -3765,6 +3595,9 @@ var IDE_HOST_BRAND_LOGOS = {
3765
3595
  };
3766
3596
  function buildNeusMcpHttpConfig(accessKey) {
3767
3597
  const key = String(accessKey || "").trim();
3598
+ if (key && !key.startsWith("npk_") && key.split(".").length === 3) {
3599
+ return { type: "http", url: NEUS_MCP_URL };
3600
+ }
3768
3601
  return {
3769
3602
  type: "http",
3770
3603
  url: NEUS_MCP_URL,
@@ -3850,7 +3683,6 @@ var index_default = {
3850
3683
  MCP_INSTALL_CLIENTS,
3851
3684
  MCP_INSTALL_HOSTS,
3852
3685
  MONTH,
3853
- MOUNT_MANIFEST_RELATIVE,
3854
3686
  NEUS_AUTH_CLI,
3855
3687
  NEUS_AUTH_NPX,
3856
3688
  NEUS_CHECK_CLI,
@@ -3881,7 +3713,6 @@ var index_default = {
3881
3713
  VerificationError,
3882
3714
  WEEK,
3883
3715
  YEAR,
3884
- applyRuntimeBundle,
3885
3716
  buildAuthCommandForClient,
3886
3717
  buildCursorMcpInstallUrl,
3887
3718
  buildNeusMcpHttpConfig,
@@ -3891,9 +3722,6 @@ var index_default = {
3891
3722
  buildSetupNpxOneLiner,
3892
3723
  buildVerificationRequest,
3893
3724
  buildVsCodeMcpInstallUrl,
3894
- bundleToClaudeMd,
3895
- bundleToCodexJson,
3896
- bundleToCursorRules,
3897
3725
  combineGates,
3898
3726
  computeContentHash,
3899
3727
  constructVerificationMessage,
@@ -3922,12 +3750,10 @@ var index_default = {
3922
3750
  pickActiveDelegation,
3923
3751
  pickIdentity,
3924
3752
  profileAgentToIdentitySeed,
3925
- readMountManifest,
3926
3753
  resolveDID,
3927
3754
  resolveEffectiveRuntime,
3928
3755
  resolveRuntimeBundleFromMcp,
3929
3756
  resolveZkPassportConfig,
3930
- sanitizeAgentIdForFilename,
3931
3757
  signMessage,
3932
3758
  standardizeVerificationRequest,
3933
3759
  supportsMcpInstallDeeplink,
@@ -3939,6 +3765,5 @@ var index_default = {
3939
3765
  validateUniversalAddress,
3940
3766
  validateVerifierPayload,
3941
3767
  validateWalletAddress,
3942
- withRetry,
3943
- writeMountManifest
3768
+ withRetry
3944
3769
  });
package/cjs/mcp-hosts.cjs CHANGED
@@ -112,6 +112,9 @@ var IDE_HOST_BRAND_LOGOS = {
112
112
  };
113
113
  function buildNeusMcpHttpConfig(accessKey) {
114
114
  const key = String(accessKey || "").trim();
115
+ if (key && !key.startsWith("npk_") && key.split(".").length === 3) {
116
+ return { type: "http", url: NEUS_MCP_URL };
117
+ }
115
118
  return {
116
119
  type: "http",
117
120
  url: NEUS_MCP_URL,
@@ -54,7 +54,7 @@ function capabilitiesToArray(caps) {
54
54
  return Object.entries(caps).filter(([, enabled]) => enabled === true).map(([key]) => String(key).trim()).filter(Boolean);
55
55
  }
56
56
  function isDelegationExpired(expiresAt) {
57
- if (expiresAt === null || expiresAt === void 0 || expiresAt === 0) return false;
57
+ if (expiresAt === null || expiresAt === 0) return false;
58
58
  const ms = Number(expiresAt);
59
59
  return Number.isFinite(ms) && ms > 0 && ms <= Date.now();
60
60
  }
@@ -151,7 +151,7 @@ function extractAgentContextFromProofs(proofs) {
151
151
  runtimePolicy: vvData.runtimePolicy && typeof vvData.runtimePolicy === "object" ? vvData.runtimePolicy : void 0,
152
152
  expiresAt: vvData.expiresAt ?? null,
153
153
  isExpired: isDelegationExpired(vvData.expiresAt),
154
- maxSpend: vvData.maxSpend !== null && vvData.maxSpend !== void 0 ? String(vvData.maxSpend) : void 0,
154
+ maxSpend: vvData.maxSpend !== null ? String(vvData.maxSpend) : void 0,
155
155
  instructions: vvData.instructions || null,
156
156
  skills: Array.isArray(vvData.skills) ? vvData.skills : [],
157
157
  provider: vvData.provider || vvData.modelProvider || null,