@neus/sdk 1.1.6 → 1.2.0
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/README.md +17 -4
- package/cjs/cli-commands.cjs +101 -0
- package/cjs/client.cjs +3 -4
- package/cjs/index.cjs +801 -12
- package/cjs/mcp-hosts.cjs +91 -8
- package/cjs/runtime-adapters.cjs +218 -0
- package/cjs/runtime-mount.cjs +452 -0
- package/cli/neus.mjs +337 -86
- package/client.js +2121 -2122
- package/index.js +69 -2
- package/mcp-hosts.js +54 -12
- package/package.json +17 -2
- package/types.d.ts +90 -1
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 = (
|
|
434
|
-
if (!
|
|
435
|
-
const trimmedPath =
|
|
433
|
+
const resolveEndpoint = (path2) => {
|
|
434
|
+
if (!path2 || typeof path2 !== "string") return null;
|
|
435
|
+
const trimmedPath = path2.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 = (
|
|
495
|
-
if (!
|
|
496
|
-
const trimmedPath =
|
|
494
|
+
const resolveEndpoint = (path2) => {
|
|
495
|
+
if (!path2 || typeof path2 !== "string") return null;
|
|
496
|
+
const trimmedPath = path2.trim();
|
|
497
497
|
if (!trimmedPath) return null;
|
|
498
498
|
if (/^https?:\/\//i.test(trimmedPath)) return trimmedPath;
|
|
499
499
|
if (trimmedPath.startsWith("/")) {
|
|
@@ -2436,13 +2436,12 @@ ${bytes.length}`;
|
|
|
2436
2436
|
}
|
|
2437
2437
|
throw new ValidationError(`Failed to sign revocation: ${error.message}`);
|
|
2438
2438
|
}
|
|
2439
|
-
const
|
|
2439
|
+
const json = await this._makeRequest("POST", `/api/v1/proofs/revoke-self/${qHash}`, {
|
|
2440
2440
|
walletAddress: address,
|
|
2441
2441
|
signature,
|
|
2442
2442
|
signedTimestamp,
|
|
2443
2443
|
...signerIsEvm ? {} : { chain, signatureMethod }
|
|
2444
2444
|
});
|
|
2445
|
-
const json = await res.json();
|
|
2446
2445
|
if (!json.success) {
|
|
2447
2446
|
throw new ApiError(json.error?.message || "Failed to revoke proof", json.error);
|
|
2448
2447
|
}
|
|
@@ -2692,7 +2691,7 @@ ${bytes.length}`;
|
|
|
2692
2691
|
if (!id || id.length > 80 || !/^[a-zA-Z0-9:_-]+$/.test(id)) {
|
|
2693
2692
|
throw new ValidationError("Valid gateId is required");
|
|
2694
2693
|
}
|
|
2695
|
-
const response = await this._makeRequest("GET", `/api/v1/gates/${encodeURIComponent(id)}`);
|
|
2694
|
+
const response = await this._makeRequest("GET", `/api/v1/profile/gates/${encodeURIComponent(id)}`);
|
|
2696
2695
|
if (!response.success || !response.data?.gate) {
|
|
2697
2696
|
throw new ApiError(`Gate lookup failed: ${response.error?.message || "Gate not found"}`, response.error);
|
|
2698
2697
|
}
|
|
@@ -2729,7 +2728,7 @@ ${bytes.length}`;
|
|
|
2729
2728
|
if (paymentTxHash) body.paymentTxHash = paymentTxHash;
|
|
2730
2729
|
const response = await this._makeRequest(
|
|
2731
2730
|
"POST",
|
|
2732
|
-
`/api/v1/gates/${encodeURIComponent(gateId)}/fulfill`,
|
|
2731
|
+
`/api/v1/profile/gates/${encodeURIComponent(gateId)}/fulfill`,
|
|
2733
2732
|
body
|
|
2734
2733
|
);
|
|
2735
2734
|
if (!response.success) {
|
|
@@ -3000,18 +2999,55 @@ __export(index_exports, {
|
|
|
3000
2999
|
GATE_TOKEN_HOLDER: () => GATE_TOKEN_HOLDER,
|
|
3001
3000
|
GATE_WALLET_RISK: () => GATE_WALLET_RISK,
|
|
3002
3001
|
HOUR: () => HOUR,
|
|
3002
|
+
IDE_HOST_BRAND_LOGOS: () => IDE_HOST_BRAND_LOGOS,
|
|
3003
|
+
IDE_HOST_LABELS: () => IDE_HOST_LABELS,
|
|
3004
|
+
MCP_INSTALL_CLIENTS: () => MCP_INSTALL_CLIENTS,
|
|
3005
|
+
MCP_INSTALL_HOSTS: () => MCP_INSTALL_HOSTS,
|
|
3003
3006
|
MONTH: () => MONTH,
|
|
3007
|
+
MOUNT_MANIFEST_RELATIVE: () => MOUNT_MANIFEST_RELATIVE,
|
|
3008
|
+
NEUS_AUTH_CLI: () => NEUS_AUTH_CLI,
|
|
3009
|
+
NEUS_AUTH_NPX: () => NEUS_AUTH_NPX,
|
|
3010
|
+
NEUS_CHECK_CLI: () => NEUS_CHECK_CLI,
|
|
3011
|
+
NEUS_CHECK_NPX: () => NEUS_CHECK_NPX,
|
|
3004
3012
|
NEUS_CONSTANTS: () => NEUS_CONSTANTS,
|
|
3013
|
+
NEUS_DOCTOR_CLI: () => NEUS_DOCTOR_CLI,
|
|
3014
|
+
NEUS_DOCTOR_NPX: () => NEUS_DOCTOR_NPX,
|
|
3015
|
+
NEUS_EXAMPLES_CLI: () => NEUS_EXAMPLES_CLI,
|
|
3016
|
+
NEUS_EXAMPLES_NPX: () => NEUS_EXAMPLES_NPX,
|
|
3017
|
+
NEUS_INSTALL_CLI: () => NEUS_INSTALL_CLI,
|
|
3018
|
+
NEUS_MCP_SERVER_NAME: () => NEUS_MCP_SERVER_NAME,
|
|
3019
|
+
NEUS_MCP_SETUP_DOCS_URL: () => NEUS_MCP_SETUP_DOCS_URL,
|
|
3020
|
+
NEUS_MCP_URL: () => NEUS_MCP_URL,
|
|
3021
|
+
NEUS_MOUNT_WORKFLOW: () => NEUS_MOUNT_WORKFLOW,
|
|
3022
|
+
NEUS_NPX: () => NEUS_NPX,
|
|
3023
|
+
NEUS_PKG: () => NEUS_PKG,
|
|
3024
|
+
NEUS_QUICKSTART_INSTALLED: () => NEUS_QUICKSTART_INSTALLED,
|
|
3025
|
+
NEUS_QUICKSTART_NPX: () => NEUS_QUICKSTART_NPX,
|
|
3026
|
+
NEUS_SETUP_CLI: () => NEUS_SETUP_CLI,
|
|
3027
|
+
NEUS_SETUP_NPX: () => NEUS_SETUP_NPX,
|
|
3005
3028
|
NetworkError: () => NetworkError,
|
|
3006
3029
|
NeusClient: () => NeusClient,
|
|
3007
3030
|
PORTABLE_PROOF_SIGNER_HEADER: () => PORTABLE_PROOF_SIGNER_HEADER,
|
|
3031
|
+
RUNTIME_MOUNT_SCHEMA: () => RUNTIME_MOUNT_SCHEMA,
|
|
3008
3032
|
SDKError: () => SDKError,
|
|
3009
3033
|
StatusPoller: () => StatusPoller,
|
|
3010
3034
|
ValidationError: () => ValidationError,
|
|
3011
3035
|
VerificationError: () => VerificationError,
|
|
3012
3036
|
WEEK: () => WEEK,
|
|
3013
3037
|
YEAR: () => YEAR,
|
|
3038
|
+
applyRuntimeBundle: () => applyRuntimeBundle,
|
|
3039
|
+
buildAuthCommandForClient: () => buildAuthCommandForClient,
|
|
3040
|
+
buildCursorMcpInstallUrl: () => buildCursorMcpInstallUrl,
|
|
3041
|
+
buildNeusMcpHttpConfig: () => buildNeusMcpHttpConfig,
|
|
3042
|
+
buildRuntimeBundle: () => buildRuntimeBundle,
|
|
3043
|
+
buildSetupCommandForClient: () => buildSetupCommandForClient,
|
|
3044
|
+
buildSetupCommandForHost: () => buildSetupCommandForHost,
|
|
3045
|
+
buildSetupNpxOneLiner: () => buildSetupNpxOneLiner,
|
|
3014
3046
|
buildVerificationRequest: () => buildVerificationRequest,
|
|
3047
|
+
buildVsCodeMcpInstallUrl: () => buildVsCodeMcpInstallUrl,
|
|
3048
|
+
bundleToClaudeMd: () => bundleToClaudeMd,
|
|
3049
|
+
bundleToCodexJson: () => bundleToCodexJson,
|
|
3050
|
+
bundleToCursorRules: () => bundleToCursorRules,
|
|
3015
3051
|
combineGates: () => combineGates,
|
|
3016
3052
|
computeContentHash: () => computeContentHash,
|
|
3017
3053
|
constructVerificationMessage: () => constructVerificationMessage,
|
|
@@ -3020,19 +3056,36 @@ __export(index_exports, {
|
|
|
3020
3056
|
default: () => index_default,
|
|
3021
3057
|
delay: () => delay,
|
|
3022
3058
|
deriveDid: () => deriveDid,
|
|
3059
|
+
evaluateMountFileHealth: () => evaluateMountFileHealth,
|
|
3060
|
+
extractAgentContextFromProofs: () => extractAgentContextFromProofs,
|
|
3023
3061
|
fetchSponsorGrant: () => fetchSponsorGrant,
|
|
3024
3062
|
formatTimestamp: () => formatTimestamp,
|
|
3025
3063
|
formatVerificationStatus: () => formatVerificationStatus,
|
|
3026
3064
|
getHostedCheckoutUrl: () => getHostedCheckoutUrl,
|
|
3065
|
+
isDelegationExpired: () => isDelegationExpired,
|
|
3027
3066
|
isFailureStatus: () => isFailureStatus,
|
|
3067
|
+
isRuntimeBundle: () => isRuntimeBundle,
|
|
3028
3068
|
isSuccessStatus: () => isSuccessStatus,
|
|
3029
3069
|
isSupportedChain: () => isSupportedChain,
|
|
3030
3070
|
isTerminalStatus: () => isTerminalStatus,
|
|
3071
|
+
neusCmd: () => neusCmd,
|
|
3072
|
+
neusMountApply: () => neusMountApply,
|
|
3073
|
+
neusMountApplyNpx: () => neusMountApplyNpx,
|
|
3074
|
+
neusNpx: () => neusNpx,
|
|
3031
3075
|
normalizeAddress: () => normalizeAddress,
|
|
3076
|
+
normalizeWallet: () => normalizeWallet,
|
|
3077
|
+
pickActiveDelegation: () => pickActiveDelegation,
|
|
3078
|
+
pickIdentity: () => pickIdentity,
|
|
3079
|
+
profileAgentToIdentitySeed: () => profileAgentToIdentitySeed,
|
|
3080
|
+
readMountManifest: () => readMountManifest,
|
|
3032
3081
|
resolveDID: () => resolveDID,
|
|
3082
|
+
resolveEffectiveRuntime: () => resolveEffectiveRuntime,
|
|
3083
|
+
resolveRuntimeBundleFromMcp: () => resolveRuntimeBundleFromMcp,
|
|
3033
3084
|
resolveZkPassportConfig: () => resolveZkPassportConfig,
|
|
3085
|
+
sanitizeAgentIdForFilename: () => sanitizeAgentIdForFilename,
|
|
3034
3086
|
signMessage: () => signMessage,
|
|
3035
3087
|
standardizeVerificationRequest: () => standardizeVerificationRequest,
|
|
3088
|
+
supportsMcpInstallDeeplink: () => supportsMcpInstallDeeplink,
|
|
3036
3089
|
toAgentDelegationMaxSpend: () => toAgentDelegationMaxSpend,
|
|
3037
3090
|
toHexUtf8: () => toHexUtf8,
|
|
3038
3091
|
validateQHash: () => validateQHash,
|
|
@@ -3041,7 +3094,8 @@ __export(index_exports, {
|
|
|
3041
3094
|
validateUniversalAddress: () => validateUniversalAddress,
|
|
3042
3095
|
validateVerifierPayload: () => validateVerifierPayload,
|
|
3043
3096
|
validateWalletAddress: () => validateWalletAddress,
|
|
3044
|
-
withRetry: () => withRetry
|
|
3097
|
+
withRetry: () => withRetry,
|
|
3098
|
+
writeMountManifest: () => writeMountManifest
|
|
3045
3099
|
});
|
|
3046
3100
|
module.exports = __toCommonJS(index_exports);
|
|
3047
3101
|
init_client();
|
|
@@ -3088,7 +3142,687 @@ function combineGates(...gates) {
|
|
|
3088
3142
|
|
|
3089
3143
|
// index.js
|
|
3090
3144
|
init_sponsor();
|
|
3145
|
+
|
|
3146
|
+
// runtime-mount.js
|
|
3147
|
+
var RUNTIME_MOUNT_SCHEMA = "neus.runtime-mount.v1";
|
|
3148
|
+
var PROOF_URL_BASE = "https://neus.network/proof/";
|
|
3149
|
+
function normalizeWallet(value) {
|
|
3150
|
+
const wallet = String(value || "").trim().toLowerCase();
|
|
3151
|
+
return /^0x[a-f0-9]{40}$/.test(wallet) ? wallet : "";
|
|
3152
|
+
}
|
|
3153
|
+
function asString(value) {
|
|
3154
|
+
const trimmed = String(value ?? "").trim();
|
|
3155
|
+
return trimmed.length > 0 ? trimmed : "";
|
|
3156
|
+
}
|
|
3157
|
+
function asStringArray(value) {
|
|
3158
|
+
if (!Array.isArray(value)) return [];
|
|
3159
|
+
return value.map((item) => String(item || "").trim()).filter(Boolean);
|
|
3160
|
+
}
|
|
3161
|
+
function capabilitiesToArray(caps) {
|
|
3162
|
+
if (Array.isArray(caps)) return asStringArray(caps);
|
|
3163
|
+
if (!caps || typeof caps !== "object") return [];
|
|
3164
|
+
return Object.entries(caps).filter(([, enabled]) => enabled === true).map(([key]) => String(key).trim()).filter(Boolean);
|
|
3165
|
+
}
|
|
3166
|
+
function isDelegationExpired(expiresAt) {
|
|
3167
|
+
if (expiresAt === null || expiresAt === void 0 || expiresAt === 0) return false;
|
|
3168
|
+
const ms = Number(expiresAt);
|
|
3169
|
+
return Number.isFinite(ms) && ms > 0 && ms <= Date.now();
|
|
3170
|
+
}
|
|
3171
|
+
function pickIdentity(identities, selector) {
|
|
3172
|
+
const list = Array.isArray(identities) ? identities : [];
|
|
3173
|
+
const qHash = asString(selector.identityQHash).toLowerCase();
|
|
3174
|
+
if (qHash) {
|
|
3175
|
+
return list.find((row) => asString(row.qHash).toLowerCase() === qHash) || null;
|
|
3176
|
+
}
|
|
3177
|
+
const agentId = asString(selector.agentId).toLowerCase();
|
|
3178
|
+
const agentWallet = normalizeWallet(selector.agentWallet);
|
|
3179
|
+
if (agentId) {
|
|
3180
|
+
const byId = list.filter((row) => asString(row.agentId).toLowerCase() === agentId);
|
|
3181
|
+
if (agentWallet) {
|
|
3182
|
+
return byId.find((row) => normalizeWallet(row.agentWallet) === agentWallet) || byId[0] || null;
|
|
3183
|
+
}
|
|
3184
|
+
return byId[0] || null;
|
|
3185
|
+
}
|
|
3186
|
+
if (agentWallet) {
|
|
3187
|
+
return list.find((row) => normalizeWallet(row.agentWallet) === agentWallet) || null;
|
|
3188
|
+
}
|
|
3189
|
+
return null;
|
|
3190
|
+
}
|
|
3191
|
+
function pickActiveDelegation(delegations, controllerWallet, agentWallet, agentId) {
|
|
3192
|
+
const list = Array.isArray(delegations) ? delegations : [];
|
|
3193
|
+
const controller = normalizeWallet(controllerWallet);
|
|
3194
|
+
const agent = normalizeWallet(agentWallet);
|
|
3195
|
+
const id = asString(agentId).toLowerCase();
|
|
3196
|
+
const candidates = list.filter((row) => {
|
|
3197
|
+
if (isDelegationExpired(row.expiresAt)) return false;
|
|
3198
|
+
const rowAgent = normalizeWallet(row.agentWallet);
|
|
3199
|
+
const rowController = normalizeWallet(row.controllerWallet);
|
|
3200
|
+
if (agent && rowAgent && rowAgent !== agent) return false;
|
|
3201
|
+
if (controller && rowController && rowController !== controller) return false;
|
|
3202
|
+
if (id && row.agentId && asString(row.agentId).toLowerCase() !== id) return false;
|
|
3203
|
+
return true;
|
|
3204
|
+
});
|
|
3205
|
+
return candidates[0] || null;
|
|
3206
|
+
}
|
|
3207
|
+
function resolveEffectiveRuntime(identity, delegation) {
|
|
3208
|
+
const delProvider = asString(delegation?.provider);
|
|
3209
|
+
const delModel = asString(delegation?.model);
|
|
3210
|
+
if (delProvider || delModel) {
|
|
3211
|
+
return {
|
|
3212
|
+
provider: delProvider || "openai",
|
|
3213
|
+
model: delModel || ""
|
|
3214
|
+
};
|
|
3215
|
+
}
|
|
3216
|
+
const defaultRuntime = identity?.defaultRuntime && typeof identity.defaultRuntime === "object" ? identity.defaultRuntime : null;
|
|
3217
|
+
const idProvider = asString(defaultRuntime?.provider);
|
|
3218
|
+
const idModel = asString(defaultRuntime?.model);
|
|
3219
|
+
if (idProvider || idModel) {
|
|
3220
|
+
return {
|
|
3221
|
+
provider: idProvider || "openai",
|
|
3222
|
+
model: idModel || ""
|
|
3223
|
+
};
|
|
3224
|
+
}
|
|
3225
|
+
return null;
|
|
3226
|
+
}
|
|
3227
|
+
function extractAgentContextFromProofs(proofs) {
|
|
3228
|
+
const identities = [];
|
|
3229
|
+
const delegations = [];
|
|
3230
|
+
const list = Array.isArray(proofs) ? proofs : [];
|
|
3231
|
+
for (const proof of list) {
|
|
3232
|
+
const qHash = asString(proof?.qHash);
|
|
3233
|
+
const verifiedVerifiers = Array.isArray(proof?.verifiedVerifiers) ? proof.verifiedVerifiers : [];
|
|
3234
|
+
for (const vv of verifiedVerifiers) {
|
|
3235
|
+
const verifierId = asString(vv?.verifierId);
|
|
3236
|
+
const vvData = vv?.data && typeof vv.data === "object" ? vv.data : {};
|
|
3237
|
+
if (verifierId === "agent-identity") {
|
|
3238
|
+
identities.push({
|
|
3239
|
+
qHash,
|
|
3240
|
+
agentId: vvData.agentId || null,
|
|
3241
|
+
agentWallet: vvData.agentWallet || null,
|
|
3242
|
+
agentLabel: vvData.agentLabel || vvData.agentId || "Agent",
|
|
3243
|
+
agentType: vvData.agentType || "agent",
|
|
3244
|
+
description: vvData.description || null,
|
|
3245
|
+
capabilities: capabilitiesToArray(vvData.capabilities),
|
|
3246
|
+
skills: Array.isArray(vvData.skills) ? vvData.skills : [],
|
|
3247
|
+
instructions: vvData.instructions || null,
|
|
3248
|
+
services: Array.isArray(vvData.services) ? vvData.services : [],
|
|
3249
|
+
defaultRuntime: vvData.defaultRuntime && typeof vvData.defaultRuntime === "object" ? vvData.defaultRuntime : void 0
|
|
3250
|
+
});
|
|
3251
|
+
}
|
|
3252
|
+
if (verifierId === "agent-delegation") {
|
|
3253
|
+
delegations.push({
|
|
3254
|
+
qHash,
|
|
3255
|
+
controllerWallet: vvData.controllerWallet || null,
|
|
3256
|
+
agentWallet: vvData.agentWallet || null,
|
|
3257
|
+
agentId: vvData.agentId || null,
|
|
3258
|
+
scope: vvData.scope || "global",
|
|
3259
|
+
allowedActions: asStringArray(vvData.allowedActions),
|
|
3260
|
+
deniedActions: asStringArray(vvData.deniedActions),
|
|
3261
|
+
runtimePolicy: vvData.runtimePolicy && typeof vvData.runtimePolicy === "object" ? vvData.runtimePolicy : void 0,
|
|
3262
|
+
expiresAt: vvData.expiresAt ?? null,
|
|
3263
|
+
isExpired: isDelegationExpired(vvData.expiresAt),
|
|
3264
|
+
maxSpend: vvData.maxSpend !== null && vvData.maxSpend !== void 0 ? String(vvData.maxSpend) : void 0,
|
|
3265
|
+
instructions: vvData.instructions || null,
|
|
3266
|
+
skills: Array.isArray(vvData.skills) ? vvData.skills : [],
|
|
3267
|
+
provider: vvData.provider || vvData.modelProvider || null,
|
|
3268
|
+
model: vvData.model || null
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
return { identities, delegations };
|
|
3274
|
+
}
|
|
3275
|
+
function buildRuntimeBundle(input) {
|
|
3276
|
+
const identity = input.identity || {};
|
|
3277
|
+
const delegation = input.delegation || null;
|
|
3278
|
+
const identityQHash = asString(input.identityQHash || identity.qHash);
|
|
3279
|
+
const delegationQHash = delegation ? asString(input.delegationQHash || delegation.qHash) : null;
|
|
3280
|
+
const agentId = asString(identity.agentId);
|
|
3281
|
+
const agentWallet = normalizeWallet(identity.agentWallet);
|
|
3282
|
+
if (!identityQHash || !agentId || !agentWallet) {
|
|
3283
|
+
throw new Error("Runtime mount requires verified agent identity (agentId, agentWallet, identityQHash).");
|
|
3284
|
+
}
|
|
3285
|
+
const effectiveRuntime = resolveEffectiveRuntime(identity, delegation);
|
|
3286
|
+
const deniedActions = delegation ? asStringArray(delegation.deniedActions) : [];
|
|
3287
|
+
const allowedActions = delegation ? asStringArray(delegation.allowedActions) : void 0;
|
|
3288
|
+
const requiresHumanApproval = delegation?.runtimePolicy && typeof delegation.runtimePolicy === "object" && delegation.runtimePolicy.requiresHumanApproval === true;
|
|
3289
|
+
const capabilities = asStringArray(identity.capabilities);
|
|
3290
|
+
const skills = Array.isArray(identity.skills) ? identity.skills : [];
|
|
3291
|
+
const skillIds = skills.map(
|
|
3292
|
+
(skill) => typeof skill === "string" ? skill : asString(skill?.id || skill?.label)
|
|
3293
|
+
).filter(Boolean);
|
|
3294
|
+
const delegations = delegation ? [delegation] : [];
|
|
3295
|
+
const activeDelegations = delegations.filter((row) => !row.isExpired).length;
|
|
3296
|
+
return {
|
|
3297
|
+
schema: RUNTIME_MOUNT_SCHEMA,
|
|
3298
|
+
mountedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3299
|
+
trust: {
|
|
3300
|
+
identityQHash,
|
|
3301
|
+
delegationQHash: delegationQHash || null,
|
|
3302
|
+
identityProofUrl: `${PROOF_URL_BASE}${identityQHash}`,
|
|
3303
|
+
delegationProofUrl: delegationQHash ? `${PROOF_URL_BASE}${delegationQHash}` : null
|
|
3304
|
+
},
|
|
3305
|
+
identity: {
|
|
3306
|
+
agentId,
|
|
3307
|
+
agentWallet,
|
|
3308
|
+
agentLabel: asString(identity.agentLabel) || agentId,
|
|
3309
|
+
agentType: asString(identity.agentType) || "agent",
|
|
3310
|
+
description: asString(identity.description) || void 0,
|
|
3311
|
+
instructions: asString(identity.instructions) || void 0,
|
|
3312
|
+
capabilities,
|
|
3313
|
+
skills,
|
|
3314
|
+
services: Array.isArray(identity.services) ? identity.services : void 0,
|
|
3315
|
+
defaultRuntime: identity.defaultRuntime && typeof identity.defaultRuntime === "object" ? identity.defaultRuntime : void 0
|
|
3316
|
+
},
|
|
3317
|
+
delegation: delegation ? {
|
|
3318
|
+
controllerWallet: normalizeWallet(delegation.controllerWallet) || asString(delegation.controllerWallet),
|
|
3319
|
+
scope: asString(delegation.scope) || void 0,
|
|
3320
|
+
allowedActions,
|
|
3321
|
+
deniedActions,
|
|
3322
|
+
runtimePolicy: delegation.runtimePolicy,
|
|
3323
|
+
expiresAt: delegation.expiresAt ?? null,
|
|
3324
|
+
isExpired: Boolean(delegation.isExpired),
|
|
3325
|
+
maxSpend: delegation.maxSpend,
|
|
3326
|
+
instructions: asString(delegation.instructions) || void 0,
|
|
3327
|
+
skills: Array.isArray(delegation.skills) ? delegation.skills : void 0,
|
|
3328
|
+
provider: asString(delegation.provider) || void 0,
|
|
3329
|
+
model: asString(delegation.model) || void 0
|
|
3330
|
+
} : null,
|
|
3331
|
+
effectiveRuntime,
|
|
3332
|
+
tools: Array.isArray(input.tools) ? input.tools : [],
|
|
3333
|
+
secretBindings: Array.isArray(input.secretBindings) ? input.secretBindings : [],
|
|
3334
|
+
memoryRefs: Array.isArray(input.memoryRefs) ? input.memoryRefs : void 0,
|
|
3335
|
+
enforce: {
|
|
3336
|
+
deniedActions,
|
|
3337
|
+
...allowedActions?.length ? { allowedActions } : {},
|
|
3338
|
+
...requiresHumanApproval ? { requiresHumanApproval: true } : {}
|
|
3339
|
+
},
|
|
3340
|
+
contextPack: {
|
|
3341
|
+
identityCount: 1,
|
|
3342
|
+
delegationCount: delegations.length,
|
|
3343
|
+
activeDelegations,
|
|
3344
|
+
capabilitiesSummary: capabilities.slice(0, 32),
|
|
3345
|
+
skillsSummary: skillIds.slice(0, 32)
|
|
3346
|
+
}
|
|
3347
|
+
};
|
|
3348
|
+
}
|
|
3349
|
+
function profileAgentToIdentitySeed(profileAgent) {
|
|
3350
|
+
return {
|
|
3351
|
+
agentId: profileAgent.agentId,
|
|
3352
|
+
agentWallet: profileAgent.agentWallet,
|
|
3353
|
+
agentLabel: profileAgent.agentLabel || profileAgent.name,
|
|
3354
|
+
agentType: profileAgent.agentType || profileAgent.typeLabel,
|
|
3355
|
+
description: profileAgent.description,
|
|
3356
|
+
instructions: profileAgent.instructions,
|
|
3357
|
+
capabilities: capabilitiesToArray(profileAgent.capabilities),
|
|
3358
|
+
skills: Array.isArray(profileAgent.skills) ? profileAgent.skills : [],
|
|
3359
|
+
services: Array.isArray(profileAgent.services) ? profileAgent.services : [],
|
|
3360
|
+
identityQHash: profileAgent.identityQHash || profileAgent.qHash
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
function isRuntimeBundle(value) {
|
|
3364
|
+
return Boolean(value && typeof value === "object" && value.schema === RUNTIME_MOUNT_SCHEMA);
|
|
3365
|
+
}
|
|
3366
|
+
async function resolveRuntimeBundleFromMcp(input) {
|
|
3367
|
+
const accessKey = asString(input.accessKey);
|
|
3368
|
+
if (!accessKey) {
|
|
3369
|
+
throw new Error("NEUS access key or authenticated MCP session is required for runtime mount.");
|
|
3370
|
+
}
|
|
3371
|
+
const selector = {
|
|
3372
|
+
agentId: input.agentId,
|
|
3373
|
+
agentWallet: input.agentWallet,
|
|
3374
|
+
identityQHash: input.identityQHash
|
|
3375
|
+
};
|
|
3376
|
+
if (!selector.agentId && !selector.agentWallet && !selector.identityQHash) {
|
|
3377
|
+
throw new Error("Provide agentId, agentWallet, or identityQHash.");
|
|
3378
|
+
}
|
|
3379
|
+
let sessionId = "";
|
|
3380
|
+
if (input.initializeMcp) {
|
|
3381
|
+
const init = await input.initializeMcp();
|
|
3382
|
+
sessionId = init.sessionId || "";
|
|
3383
|
+
}
|
|
3384
|
+
const mountArgs = {
|
|
3385
|
+
...selector.agentId ? { agentId: selector.agentId } : {},
|
|
3386
|
+
...selector.agentWallet ? { agentWallet: selector.agentWallet } : {},
|
|
3387
|
+
...selector.identityQHash ? { identityQHash: selector.identityQHash } : {}
|
|
3388
|
+
};
|
|
3389
|
+
const serverMount = await input.callMcpTool({
|
|
3390
|
+
name: "neus_agent_mount",
|
|
3391
|
+
args: mountArgs,
|
|
3392
|
+
accessKey,
|
|
3393
|
+
sessionId,
|
|
3394
|
+
signal: input.signal
|
|
3395
|
+
});
|
|
3396
|
+
if (serverMount.ok) {
|
|
3397
|
+
const payload = serverMount.payload;
|
|
3398
|
+
if (isRuntimeBundle(payload)) {
|
|
3399
|
+
return (
|
|
3400
|
+
/** @type {import('./runtime-mount.js').RuntimeBundle} */
|
|
3401
|
+
payload
|
|
3402
|
+
);
|
|
3403
|
+
}
|
|
3404
|
+
if (payload && typeof payload === "object" && isRuntimeBundle(payload.data)) {
|
|
3405
|
+
return (
|
|
3406
|
+
/** @type {import('./runtime-mount.js').RuntimeBundle} */
|
|
3407
|
+
payload.data
|
|
3408
|
+
);
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
const me = await input.callMcpTool({
|
|
3412
|
+
name: "neus_me",
|
|
3413
|
+
args: {},
|
|
3414
|
+
accessKey,
|
|
3415
|
+
sessionId,
|
|
3416
|
+
signal: input.signal
|
|
3417
|
+
});
|
|
3418
|
+
if (!me.ok) {
|
|
3419
|
+
throw new Error(me.error || "Could not load profile context. Run `neus auth` and retry.");
|
|
3420
|
+
}
|
|
3421
|
+
const mePayload = (
|
|
3422
|
+
/** @type {Record<string, unknown>} */
|
|
3423
|
+
me.payload || {}
|
|
3424
|
+
);
|
|
3425
|
+
if (mePayload.status === "auth_required") {
|
|
3426
|
+
throw new Error("Profile authentication required. Run `neus auth` or set NEUS_ACCESS_KEY.");
|
|
3427
|
+
}
|
|
3428
|
+
const principal = (
|
|
3429
|
+
/** @type {Record<string, unknown>} */
|
|
3430
|
+
mePayload.principal || {}
|
|
3431
|
+
);
|
|
3432
|
+
const controllerWallet = normalizeWallet(principal.primaryAccount);
|
|
3433
|
+
const profileAgents = Array.isArray(mePayload.agents) ? mePayload.agents : [];
|
|
3434
|
+
let agentWallet = normalizeWallet(selector.agentWallet);
|
|
3435
|
+
let agentId = asString(selector.agentId);
|
|
3436
|
+
if (!agentWallet && agentId) {
|
|
3437
|
+
const row = profileAgents.find(
|
|
3438
|
+
(row2) => asString(row2.agentId).toLowerCase() === agentId.toLowerCase()
|
|
3439
|
+
);
|
|
3440
|
+
if (row) {
|
|
3441
|
+
agentWallet = normalizeWallet(row.agentWallet);
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
if (!agentId && agentWallet) {
|
|
3445
|
+
const row = profileAgents.find((row2) => normalizeWallet(row2.agentWallet) === agentWallet);
|
|
3446
|
+
if (row) agentId = asString(row.agentId);
|
|
3447
|
+
}
|
|
3448
|
+
if (!agentWallet && selector.identityQHash) {
|
|
3449
|
+
const idProof = await input.callMcpTool({
|
|
3450
|
+
name: "neus_proofs_get",
|
|
3451
|
+
args: { qHash: selector.identityQHash, verifierId: "agent-identity" },
|
|
3452
|
+
accessKey,
|
|
3453
|
+
sessionId,
|
|
3454
|
+
signal: input.signal
|
|
3455
|
+
});
|
|
3456
|
+
if (idProof.ok) {
|
|
3457
|
+
const data = (
|
|
3458
|
+
/** @type {Record<string, unknown>} */
|
|
3459
|
+
idProof.payload?.data || idProof.payload || {}
|
|
3460
|
+
);
|
|
3461
|
+
const proofs = Array.isArray(data.proofs) ? data.proofs : [];
|
|
3462
|
+
const extracted = extractAgentContextFromProofs(proofs);
|
|
3463
|
+
const identity2 = pickIdentity(extracted.identities, selector);
|
|
3464
|
+
if (identity2) {
|
|
3465
|
+
agentWallet = normalizeWallet(identity2.agentWallet);
|
|
3466
|
+
agentId = asString(identity2.agentId);
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
if (!agentWallet) {
|
|
3471
|
+
throw new Error("Could not resolve agent wallet. Check agentId or link the agent on your profile.");
|
|
3472
|
+
}
|
|
3473
|
+
const [identityPage, delegationPage] = await Promise.all([
|
|
3474
|
+
input.callMcpTool({
|
|
3475
|
+
name: "neus_proofs_get",
|
|
3476
|
+
args: { identifier: agentWallet, verifierId: "agent-identity", limit: 25 },
|
|
3477
|
+
accessKey,
|
|
3478
|
+
sessionId,
|
|
3479
|
+
signal: input.signal
|
|
3480
|
+
}),
|
|
3481
|
+
controllerWallet ? input.callMcpTool({
|
|
3482
|
+
name: "neus_proofs_get",
|
|
3483
|
+
args: { identifier: controllerWallet, verifierId: "agent-delegation", limit: 50 },
|
|
3484
|
+
accessKey,
|
|
3485
|
+
sessionId,
|
|
3486
|
+
signal: input.signal
|
|
3487
|
+
}) : Promise.resolve({ ok: false })
|
|
3488
|
+
]);
|
|
3489
|
+
const identityProofs = identityPage.ok ? (
|
|
3490
|
+
/** @type {unknown[]} */
|
|
3491
|
+
identityPage.payload?.data?.proofs || identityPage.payload?.proofs || []
|
|
3492
|
+
) : [];
|
|
3493
|
+
const delegationProofs = delegationPage.ok ? (
|
|
3494
|
+
/** @type {unknown[]} */
|
|
3495
|
+
delegationPage.payload?.data?.proofs || delegationPage.payload?.proofs || []
|
|
3496
|
+
) : [];
|
|
3497
|
+
const idCtx = extractAgentContextFromProofs(identityProofs);
|
|
3498
|
+
const delCtx = extractAgentContextFromProofs(delegationProofs);
|
|
3499
|
+
let identity = pickIdentity(idCtx.identities, { ...selector, agentId, agentWallet });
|
|
3500
|
+
if (!identity && profileAgents.length > 0) {
|
|
3501
|
+
const row = profileAgents.find(
|
|
3502
|
+
(a) => asString(a.agentId).toLowerCase() === agentId.toLowerCase() || normalizeWallet(a.agentWallet) === agentWallet
|
|
3503
|
+
);
|
|
3504
|
+
if (row) {
|
|
3505
|
+
identity = { ...profileAgentToIdentitySeed(row), agentWallet, agentId: agentId || asString(row.agentId) };
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
if (!identity) {
|
|
3509
|
+
throw new Error("Agent identity proof not found. Complete agent setup on neus.network first.");
|
|
3510
|
+
}
|
|
3511
|
+
const delegation = pickActiveDelegation(
|
|
3512
|
+
delCtx.delegations,
|
|
3513
|
+
controllerWallet,
|
|
3514
|
+
agentWallet,
|
|
3515
|
+
agentId || asString(identity.agentId)
|
|
3516
|
+
);
|
|
3517
|
+
return buildRuntimeBundle({
|
|
3518
|
+
identity,
|
|
3519
|
+
delegation,
|
|
3520
|
+
identityQHash: asString(identity.qHash || selector.identityQHash),
|
|
3521
|
+
delegationQHash: delegation ? asString(delegation.qHash) : null,
|
|
3522
|
+
tools: [],
|
|
3523
|
+
secretBindings: []
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3526
|
+
function evaluateMountFileHealth(manifest) {
|
|
3527
|
+
if (!manifest || manifest.schema !== RUNTIME_MOUNT_SCHEMA) {
|
|
3528
|
+
return {
|
|
3529
|
+
mountFileValid: false,
|
|
3530
|
+
missingDelegation: true,
|
|
3531
|
+
delegationExpired: false,
|
|
3532
|
+
needsRefresh: true,
|
|
3533
|
+
reason: "missing_or_invalid"
|
|
3534
|
+
};
|
|
3535
|
+
}
|
|
3536
|
+
const delegationQHash = asString(manifest.trust?.delegationQHash);
|
|
3537
|
+
const missingDelegation = !delegationQHash;
|
|
3538
|
+
const expiresAt = manifest.delegation?.expiresAt;
|
|
3539
|
+
const delegationExpired = Boolean(manifest.delegation?.isExpired) || isDelegationExpired(expiresAt);
|
|
3540
|
+
return {
|
|
3541
|
+
mountFileValid: true,
|
|
3542
|
+
missingDelegation,
|
|
3543
|
+
delegationExpired,
|
|
3544
|
+
needsRefresh: missingDelegation || delegationExpired,
|
|
3545
|
+
reason: delegationExpired ? "delegation_expired" : missingDelegation ? "delegation_missing" : null
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3548
|
+
|
|
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
|
+
// index.js
|
|
3091
3712
|
init_errors();
|
|
3713
|
+
|
|
3714
|
+
// cli-commands.js
|
|
3715
|
+
var NEUS_PKG = "@neus/sdk";
|
|
3716
|
+
var NEUS_INSTALL_CLI = `npm i -g ${NEUS_PKG}`;
|
|
3717
|
+
var NEUS_NPX = `npx ${NEUS_PKG}`;
|
|
3718
|
+
var NEUS_SETUP_CLI = "neus setup";
|
|
3719
|
+
var NEUS_AUTH_CLI = "neus auth";
|
|
3720
|
+
var NEUS_CHECK_CLI = "neus check";
|
|
3721
|
+
var NEUS_DOCTOR_CLI = "neus doctor --live";
|
|
3722
|
+
var NEUS_EXAMPLES_CLI = "neus examples";
|
|
3723
|
+
var NEUS_SETUP_NPX = `${NEUS_NPX} setup`;
|
|
3724
|
+
var NEUS_AUTH_NPX = `${NEUS_NPX} auth`;
|
|
3725
|
+
var NEUS_CHECK_NPX = `${NEUS_NPX} check`;
|
|
3726
|
+
var NEUS_DOCTOR_NPX = `${NEUS_NPX} doctor --live`;
|
|
3727
|
+
var NEUS_EXAMPLES_NPX = `${NEUS_NPX} examples`;
|
|
3728
|
+
function neusMountApply(agentId, host = "cursor") {
|
|
3729
|
+
const id = String(agentId || "").trim();
|
|
3730
|
+
return `neus mount ${id} --apply ${host}`;
|
|
3731
|
+
}
|
|
3732
|
+
function neusMountApplyNpx(agentId, host = "cursor") {
|
|
3733
|
+
const id = String(agentId || "").trim();
|
|
3734
|
+
return `${NEUS_NPX} mount ${id} --apply ${host}`;
|
|
3735
|
+
}
|
|
3736
|
+
var NEUS_QUICKSTART_INSTALLED = `${NEUS_INSTALL_CLI}
|
|
3737
|
+
${NEUS_SETUP_CLI}
|
|
3738
|
+
${NEUS_AUTH_CLI}`;
|
|
3739
|
+
var NEUS_QUICKSTART_NPX = NEUS_SETUP_NPX;
|
|
3740
|
+
var NEUS_MOUNT_WORKFLOW = `${NEUS_AUTH_CLI}
|
|
3741
|
+
neus mount <agentId> --apply cursor
|
|
3742
|
+
${NEUS_DOCTOR_CLI}`;
|
|
3743
|
+
function neusCmd(subcommand) {
|
|
3744
|
+
return `neus ${String(subcommand || "").trim()}`;
|
|
3745
|
+
}
|
|
3746
|
+
function neusNpx(subcommand) {
|
|
3747
|
+
return `${NEUS_NPX} ${String(subcommand || "").trim()}`;
|
|
3748
|
+
}
|
|
3749
|
+
|
|
3750
|
+
// mcp-hosts.js
|
|
3751
|
+
var NEUS_MCP_SERVER_NAME = "neus";
|
|
3752
|
+
var NEUS_MCP_URL = "https://mcp.neus.network/mcp";
|
|
3753
|
+
var NEUS_MCP_SETUP_DOCS_URL = "https://docs.neus.network/mcp/setup";
|
|
3754
|
+
var MCP_INSTALL_CLIENTS = ["claude", "codex", "cursor", "vscode"];
|
|
3755
|
+
var MCP_INSTALL_HOSTS = ["cursor", "claude", "codex"];
|
|
3756
|
+
var IDE_HOST_LABELS = {
|
|
3757
|
+
cursor: "Cursor",
|
|
3758
|
+
claude: "Claude Code",
|
|
3759
|
+
codex: "Codex"
|
|
3760
|
+
};
|
|
3761
|
+
var IDE_HOST_BRAND_LOGOS = {
|
|
3762
|
+
cursor: "/images/brandLogos/cursor.svg",
|
|
3763
|
+
claude: "/images/brandLogos/anthropic.svg",
|
|
3764
|
+
codex: "/images/brandLogos/openai.svg"
|
|
3765
|
+
};
|
|
3766
|
+
function buildNeusMcpHttpConfig(accessKey) {
|
|
3767
|
+
const key = String(accessKey || "").trim();
|
|
3768
|
+
return {
|
|
3769
|
+
type: "http",
|
|
3770
|
+
url: NEUS_MCP_URL,
|
|
3771
|
+
...key ? { headers: { Authorization: `Bearer ${key}` } } : {}
|
|
3772
|
+
};
|
|
3773
|
+
}
|
|
3774
|
+
function encodeBase64Json(value) {
|
|
3775
|
+
const json = JSON.stringify(value);
|
|
3776
|
+
if (typeof globalThis.btoa === "function") {
|
|
3777
|
+
return globalThis.btoa(json);
|
|
3778
|
+
}
|
|
3779
|
+
return Buffer.from(json, "utf8").toString("base64");
|
|
3780
|
+
}
|
|
3781
|
+
function buildCursorMcpInstallUrl(accessKey) {
|
|
3782
|
+
const config = buildNeusMcpHttpConfig(accessKey);
|
|
3783
|
+
const encoded = encodeBase64Json(config);
|
|
3784
|
+
return `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(NEUS_MCP_SERVER_NAME)}&config=${encodeURIComponent(encoded)}`;
|
|
3785
|
+
}
|
|
3786
|
+
function buildVsCodeMcpInstallUrl(accessKey) {
|
|
3787
|
+
const payload = {
|
|
3788
|
+
name: NEUS_MCP_SERVER_NAME,
|
|
3789
|
+
...buildNeusMcpHttpConfig(accessKey)
|
|
3790
|
+
};
|
|
3791
|
+
return `vscode:mcp/install?${encodeURIComponent(JSON.stringify(payload))}`;
|
|
3792
|
+
}
|
|
3793
|
+
function buildAuthCommandForClient(client) {
|
|
3794
|
+
if (client === "codex") {
|
|
3795
|
+
return neusCmd(`auth --client codex`);
|
|
3796
|
+
}
|
|
3797
|
+
return NEUS_AUTH_CLI;
|
|
3798
|
+
}
|
|
3799
|
+
function buildSetupCommandForClient(client, accessKey) {
|
|
3800
|
+
const key = String(accessKey || "").trim();
|
|
3801
|
+
const setup = key ? neusCmd(`setup --client ${client} --access-key ${key}`) : neusCmd(`setup --client ${client}`);
|
|
3802
|
+
if (key) {
|
|
3803
|
+
return `${NEUS_INSTALL_CLI}
|
|
3804
|
+
${setup}`;
|
|
3805
|
+
}
|
|
3806
|
+
const auth = buildAuthCommandForClient(client);
|
|
3807
|
+
return `${NEUS_INSTALL_CLI}
|
|
3808
|
+
${setup}
|
|
3809
|
+
${auth}`;
|
|
3810
|
+
}
|
|
3811
|
+
function buildSetupCommandForHost(host, accessKey) {
|
|
3812
|
+
return buildSetupCommandForClient(host, accessKey);
|
|
3813
|
+
}
|
|
3814
|
+
function buildSetupNpxOneLiner(client) {
|
|
3815
|
+
if (!client) return NEUS_SETUP_NPX;
|
|
3816
|
+
return `${NEUS_NPX} setup --client ${client}`;
|
|
3817
|
+
}
|
|
3818
|
+
function supportsMcpInstallDeeplink(host) {
|
|
3819
|
+
if (host !== "cursor") return false;
|
|
3820
|
+
if (typeof navigator === "undefined") return false;
|
|
3821
|
+
const ua = navigator.userAgent || "";
|
|
3822
|
+
return !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3825
|
+
// index.js
|
|
3092
3826
|
var index_default = {
|
|
3093
3827
|
NeusClient: () => Promise.resolve().then(() => (init_client(), client_exports)).then((m) => m.NeusClient),
|
|
3094
3828
|
toString: () => "[neus/sdk]"
|
|
@@ -3111,18 +3845,55 @@ var index_default = {
|
|
|
3111
3845
|
GATE_TOKEN_HOLDER,
|
|
3112
3846
|
GATE_WALLET_RISK,
|
|
3113
3847
|
HOUR,
|
|
3848
|
+
IDE_HOST_BRAND_LOGOS,
|
|
3849
|
+
IDE_HOST_LABELS,
|
|
3850
|
+
MCP_INSTALL_CLIENTS,
|
|
3851
|
+
MCP_INSTALL_HOSTS,
|
|
3114
3852
|
MONTH,
|
|
3853
|
+
MOUNT_MANIFEST_RELATIVE,
|
|
3854
|
+
NEUS_AUTH_CLI,
|
|
3855
|
+
NEUS_AUTH_NPX,
|
|
3856
|
+
NEUS_CHECK_CLI,
|
|
3857
|
+
NEUS_CHECK_NPX,
|
|
3115
3858
|
NEUS_CONSTANTS,
|
|
3859
|
+
NEUS_DOCTOR_CLI,
|
|
3860
|
+
NEUS_DOCTOR_NPX,
|
|
3861
|
+
NEUS_EXAMPLES_CLI,
|
|
3862
|
+
NEUS_EXAMPLES_NPX,
|
|
3863
|
+
NEUS_INSTALL_CLI,
|
|
3864
|
+
NEUS_MCP_SERVER_NAME,
|
|
3865
|
+
NEUS_MCP_SETUP_DOCS_URL,
|
|
3866
|
+
NEUS_MCP_URL,
|
|
3867
|
+
NEUS_MOUNT_WORKFLOW,
|
|
3868
|
+
NEUS_NPX,
|
|
3869
|
+
NEUS_PKG,
|
|
3870
|
+
NEUS_QUICKSTART_INSTALLED,
|
|
3871
|
+
NEUS_QUICKSTART_NPX,
|
|
3872
|
+
NEUS_SETUP_CLI,
|
|
3873
|
+
NEUS_SETUP_NPX,
|
|
3116
3874
|
NetworkError,
|
|
3117
3875
|
NeusClient,
|
|
3118
3876
|
PORTABLE_PROOF_SIGNER_HEADER,
|
|
3877
|
+
RUNTIME_MOUNT_SCHEMA,
|
|
3119
3878
|
SDKError,
|
|
3120
3879
|
StatusPoller,
|
|
3121
3880
|
ValidationError,
|
|
3122
3881
|
VerificationError,
|
|
3123
3882
|
WEEK,
|
|
3124
3883
|
YEAR,
|
|
3884
|
+
applyRuntimeBundle,
|
|
3885
|
+
buildAuthCommandForClient,
|
|
3886
|
+
buildCursorMcpInstallUrl,
|
|
3887
|
+
buildNeusMcpHttpConfig,
|
|
3888
|
+
buildRuntimeBundle,
|
|
3889
|
+
buildSetupCommandForClient,
|
|
3890
|
+
buildSetupCommandForHost,
|
|
3891
|
+
buildSetupNpxOneLiner,
|
|
3125
3892
|
buildVerificationRequest,
|
|
3893
|
+
buildVsCodeMcpInstallUrl,
|
|
3894
|
+
bundleToClaudeMd,
|
|
3895
|
+
bundleToCodexJson,
|
|
3896
|
+
bundleToCursorRules,
|
|
3126
3897
|
combineGates,
|
|
3127
3898
|
computeContentHash,
|
|
3128
3899
|
constructVerificationMessage,
|
|
@@ -3130,19 +3901,36 @@ var index_default = {
|
|
|
3130
3901
|
createVerificationData,
|
|
3131
3902
|
delay,
|
|
3132
3903
|
deriveDid,
|
|
3904
|
+
evaluateMountFileHealth,
|
|
3905
|
+
extractAgentContextFromProofs,
|
|
3133
3906
|
fetchSponsorGrant,
|
|
3134
3907
|
formatTimestamp,
|
|
3135
3908
|
formatVerificationStatus,
|
|
3136
3909
|
getHostedCheckoutUrl,
|
|
3910
|
+
isDelegationExpired,
|
|
3137
3911
|
isFailureStatus,
|
|
3912
|
+
isRuntimeBundle,
|
|
3138
3913
|
isSuccessStatus,
|
|
3139
3914
|
isSupportedChain,
|
|
3140
3915
|
isTerminalStatus,
|
|
3916
|
+
neusCmd,
|
|
3917
|
+
neusMountApply,
|
|
3918
|
+
neusMountApplyNpx,
|
|
3919
|
+
neusNpx,
|
|
3141
3920
|
normalizeAddress,
|
|
3921
|
+
normalizeWallet,
|
|
3922
|
+
pickActiveDelegation,
|
|
3923
|
+
pickIdentity,
|
|
3924
|
+
profileAgentToIdentitySeed,
|
|
3925
|
+
readMountManifest,
|
|
3142
3926
|
resolveDID,
|
|
3927
|
+
resolveEffectiveRuntime,
|
|
3928
|
+
resolveRuntimeBundleFromMcp,
|
|
3143
3929
|
resolveZkPassportConfig,
|
|
3930
|
+
sanitizeAgentIdForFilename,
|
|
3144
3931
|
signMessage,
|
|
3145
3932
|
standardizeVerificationRequest,
|
|
3933
|
+
supportsMcpInstallDeeplink,
|
|
3146
3934
|
toAgentDelegationMaxSpend,
|
|
3147
3935
|
toHexUtf8,
|
|
3148
3936
|
validateQHash,
|
|
@@ -3151,5 +3939,6 @@ var index_default = {
|
|
|
3151
3939
|
validateUniversalAddress,
|
|
3152
3940
|
validateVerifierPayload,
|
|
3153
3941
|
validateWalletAddress,
|
|
3154
|
-
withRetry
|
|
3942
|
+
withRetry,
|
|
3943
|
+
writeMountManifest
|
|
3155
3944
|
});
|