@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/index.cjs CHANGED
@@ -2999,18 +2999,50 @@ __export(index_exports, {
2999
2999
  GATE_TOKEN_HOLDER: () => GATE_TOKEN_HOLDER,
3000
3000
  GATE_WALLET_RISK: () => GATE_WALLET_RISK,
3001
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,
3002
3006
  MONTH: () => MONTH,
3007
+ NEUS_AUTH_CLI: () => NEUS_AUTH_CLI,
3008
+ NEUS_AUTH_NPX: () => NEUS_AUTH_NPX,
3009
+ NEUS_CHECK_CLI: () => NEUS_CHECK_CLI,
3010
+ NEUS_CHECK_NPX: () => NEUS_CHECK_NPX,
3003
3011
  NEUS_CONSTANTS: () => NEUS_CONSTANTS,
3012
+ NEUS_DOCTOR_CLI: () => NEUS_DOCTOR_CLI,
3013
+ NEUS_DOCTOR_NPX: () => NEUS_DOCTOR_NPX,
3014
+ NEUS_EXAMPLES_CLI: () => NEUS_EXAMPLES_CLI,
3015
+ NEUS_EXAMPLES_NPX: () => NEUS_EXAMPLES_NPX,
3016
+ NEUS_INSTALL_CLI: () => NEUS_INSTALL_CLI,
3017
+ NEUS_MCP_SERVER_NAME: () => NEUS_MCP_SERVER_NAME,
3018
+ NEUS_MCP_SETUP_DOCS_URL: () => NEUS_MCP_SETUP_DOCS_URL,
3019
+ NEUS_MCP_URL: () => NEUS_MCP_URL,
3020
+ NEUS_MOUNT_WORKFLOW: () => NEUS_MOUNT_WORKFLOW,
3021
+ NEUS_NPX: () => NEUS_NPX,
3022
+ NEUS_PKG: () => NEUS_PKG,
3023
+ NEUS_QUICKSTART_INSTALLED: () => NEUS_QUICKSTART_INSTALLED,
3024
+ NEUS_QUICKSTART_NPX: () => NEUS_QUICKSTART_NPX,
3025
+ NEUS_SETUP_CLI: () => NEUS_SETUP_CLI,
3026
+ NEUS_SETUP_NPX: () => NEUS_SETUP_NPX,
3004
3027
  NetworkError: () => NetworkError,
3005
3028
  NeusClient: () => NeusClient,
3006
3029
  PORTABLE_PROOF_SIGNER_HEADER: () => PORTABLE_PROOF_SIGNER_HEADER,
3030
+ RUNTIME_MOUNT_SCHEMA: () => RUNTIME_MOUNT_SCHEMA,
3007
3031
  SDKError: () => SDKError,
3008
3032
  StatusPoller: () => StatusPoller,
3009
3033
  ValidationError: () => ValidationError,
3010
3034
  VerificationError: () => VerificationError,
3011
3035
  WEEK: () => WEEK,
3012
3036
  YEAR: () => YEAR,
3037
+ buildAuthCommandForClient: () => buildAuthCommandForClient,
3038
+ buildCursorMcpInstallUrl: () => buildCursorMcpInstallUrl,
3039
+ buildNeusMcpHttpConfig: () => buildNeusMcpHttpConfig,
3040
+ buildRuntimeBundle: () => buildRuntimeBundle,
3041
+ buildSetupCommandForClient: () => buildSetupCommandForClient,
3042
+ buildSetupCommandForHost: () => buildSetupCommandForHost,
3043
+ buildSetupNpxOneLiner: () => buildSetupNpxOneLiner,
3013
3044
  buildVerificationRequest: () => buildVerificationRequest,
3045
+ buildVsCodeMcpInstallUrl: () => buildVsCodeMcpInstallUrl,
3014
3046
  combineGates: () => combineGates,
3015
3047
  computeContentHash: () => computeContentHash,
3016
3048
  constructVerificationMessage: () => constructVerificationMessage,
@@ -3019,19 +3051,34 @@ __export(index_exports, {
3019
3051
  default: () => index_default,
3020
3052
  delay: () => delay,
3021
3053
  deriveDid: () => deriveDid,
3054
+ evaluateMountFileHealth: () => evaluateMountFileHealth,
3055
+ extractAgentContextFromProofs: () => extractAgentContextFromProofs,
3022
3056
  fetchSponsorGrant: () => fetchSponsorGrant,
3023
3057
  formatTimestamp: () => formatTimestamp,
3024
3058
  formatVerificationStatus: () => formatVerificationStatus,
3025
3059
  getHostedCheckoutUrl: () => getHostedCheckoutUrl,
3060
+ isDelegationExpired: () => isDelegationExpired,
3026
3061
  isFailureStatus: () => isFailureStatus,
3062
+ isRuntimeBundle: () => isRuntimeBundle,
3027
3063
  isSuccessStatus: () => isSuccessStatus,
3028
3064
  isSupportedChain: () => isSupportedChain,
3029
3065
  isTerminalStatus: () => isTerminalStatus,
3066
+ neusCmd: () => neusCmd,
3067
+ neusMountApply: () => neusMountApply,
3068
+ neusMountApplyNpx: () => neusMountApplyNpx,
3069
+ neusNpx: () => neusNpx,
3030
3070
  normalizeAddress: () => normalizeAddress,
3071
+ normalizeWallet: () => normalizeWallet,
3072
+ pickActiveDelegation: () => pickActiveDelegation,
3073
+ pickIdentity: () => pickIdentity,
3074
+ profileAgentToIdentitySeed: () => profileAgentToIdentitySeed,
3031
3075
  resolveDID: () => resolveDID,
3076
+ resolveEffectiveRuntime: () => resolveEffectiveRuntime,
3077
+ resolveRuntimeBundleFromMcp: () => resolveRuntimeBundleFromMcp,
3032
3078
  resolveZkPassportConfig: () => resolveZkPassportConfig,
3033
3079
  signMessage: () => signMessage,
3034
3080
  standardizeVerificationRequest: () => standardizeVerificationRequest,
3081
+ supportsMcpInstallDeeplink: () => supportsMcpInstallDeeplink,
3035
3082
  toAgentDelegationMaxSpend: () => toAgentDelegationMaxSpend,
3036
3083
  toHexUtf8: () => toHexUtf8,
3037
3084
  validateQHash: () => validateQHash,
@@ -3087,7 +3134,525 @@ function combineGates(...gates) {
3087
3134
 
3088
3135
  // index.js
3089
3136
  init_sponsor();
3137
+
3138
+ // runtime-mount.js
3139
+ var RUNTIME_MOUNT_SCHEMA = "neus.runtime-mount.v1";
3140
+ var PROOF_URL_BASE = "https://neus.network/proof/";
3141
+ function normalizeWallet(value) {
3142
+ const wallet = String(value || "").trim().toLowerCase();
3143
+ return /^0x[a-f0-9]{40}$/.test(wallet) ? wallet : "";
3144
+ }
3145
+ function asString(value) {
3146
+ const trimmed = String(value ?? "").trim();
3147
+ return trimmed.length > 0 ? trimmed : "";
3148
+ }
3149
+ function asStringArray(value) {
3150
+ if (!Array.isArray(value)) return [];
3151
+ return value.map((item) => String(item || "").trim()).filter(Boolean);
3152
+ }
3153
+ function capabilitiesToArray(caps) {
3154
+ if (Array.isArray(caps)) return asStringArray(caps);
3155
+ if (!caps || typeof caps !== "object") return [];
3156
+ return Object.entries(caps).filter(([, enabled]) => enabled === true).map(([key]) => String(key).trim()).filter(Boolean);
3157
+ }
3158
+ function isDelegationExpired(expiresAt) {
3159
+ if (expiresAt === null || expiresAt === 0) return false;
3160
+ const ms = Number(expiresAt);
3161
+ return Number.isFinite(ms) && ms > 0 && ms <= Date.now();
3162
+ }
3163
+ function pickIdentity(identities, selector) {
3164
+ const list = Array.isArray(identities) ? identities : [];
3165
+ const qHash = asString(selector.identityQHash).toLowerCase();
3166
+ if (qHash) {
3167
+ return list.find((row) => asString(row.qHash).toLowerCase() === qHash) || null;
3168
+ }
3169
+ const agentId = asString(selector.agentId).toLowerCase();
3170
+ const agentWallet = normalizeWallet(selector.agentWallet);
3171
+ if (agentId) {
3172
+ const byId = list.filter((row) => asString(row.agentId).toLowerCase() === agentId);
3173
+ if (agentWallet) {
3174
+ return byId.find((row) => normalizeWallet(row.agentWallet) === agentWallet) || byId[0] || null;
3175
+ }
3176
+ return byId[0] || null;
3177
+ }
3178
+ if (agentWallet) {
3179
+ return list.find((row) => normalizeWallet(row.agentWallet) === agentWallet) || null;
3180
+ }
3181
+ return null;
3182
+ }
3183
+ function pickActiveDelegation(delegations, controllerWallet, agentWallet, agentId) {
3184
+ const list = Array.isArray(delegations) ? delegations : [];
3185
+ const controller = normalizeWallet(controllerWallet);
3186
+ const agent = normalizeWallet(agentWallet);
3187
+ const id = asString(agentId).toLowerCase();
3188
+ const candidates = list.filter((row) => {
3189
+ if (isDelegationExpired(row.expiresAt)) return false;
3190
+ const rowAgent = normalizeWallet(row.agentWallet);
3191
+ const rowController = normalizeWallet(row.controllerWallet);
3192
+ if (agent && rowAgent && rowAgent !== agent) return false;
3193
+ if (controller && rowController && rowController !== controller) return false;
3194
+ if (id && row.agentId && asString(row.agentId).toLowerCase() !== id) return false;
3195
+ return true;
3196
+ });
3197
+ return candidates[0] || null;
3198
+ }
3199
+ function resolveEffectiveRuntime(identity, delegation) {
3200
+ const delProvider = asString(delegation?.provider);
3201
+ const delModel = asString(delegation?.model);
3202
+ if (delProvider || delModel) {
3203
+ return {
3204
+ provider: delProvider || "openai",
3205
+ model: delModel || ""
3206
+ };
3207
+ }
3208
+ const defaultRuntime = identity?.defaultRuntime && typeof identity.defaultRuntime === "object" ? identity.defaultRuntime : null;
3209
+ const idProvider = asString(defaultRuntime?.provider);
3210
+ const idModel = asString(defaultRuntime?.model);
3211
+ if (idProvider || idModel) {
3212
+ return {
3213
+ provider: idProvider || "openai",
3214
+ model: idModel || ""
3215
+ };
3216
+ }
3217
+ return null;
3218
+ }
3219
+ function extractAgentContextFromProofs(proofs) {
3220
+ const identities = [];
3221
+ const delegations = [];
3222
+ const list = Array.isArray(proofs) ? proofs : [];
3223
+ for (const proof of list) {
3224
+ const qHash = asString(proof?.qHash);
3225
+ const verifiedVerifiers = Array.isArray(proof?.verifiedVerifiers) ? proof.verifiedVerifiers : [];
3226
+ for (const vv of verifiedVerifiers) {
3227
+ const verifierId = asString(vv?.verifierId);
3228
+ const vvData = vv?.data && typeof vv.data === "object" ? vv.data : {};
3229
+ if (verifierId === "agent-identity") {
3230
+ identities.push({
3231
+ qHash,
3232
+ agentId: vvData.agentId || null,
3233
+ agentWallet: vvData.agentWallet || null,
3234
+ agentLabel: vvData.agentLabel || vvData.agentId || "Agent",
3235
+ agentType: vvData.agentType || "agent",
3236
+ description: vvData.description || null,
3237
+ capabilities: capabilitiesToArray(vvData.capabilities),
3238
+ skills: Array.isArray(vvData.skills) ? vvData.skills : [],
3239
+ instructions: vvData.instructions || null,
3240
+ services: Array.isArray(vvData.services) ? vvData.services : [],
3241
+ defaultRuntime: vvData.defaultRuntime && typeof vvData.defaultRuntime === "object" ? vvData.defaultRuntime : void 0
3242
+ });
3243
+ }
3244
+ if (verifierId === "agent-delegation") {
3245
+ delegations.push({
3246
+ qHash,
3247
+ controllerWallet: vvData.controllerWallet || null,
3248
+ agentWallet: vvData.agentWallet || null,
3249
+ agentId: vvData.agentId || null,
3250
+ scope: vvData.scope || "global",
3251
+ allowedActions: asStringArray(vvData.allowedActions),
3252
+ deniedActions: asStringArray(vvData.deniedActions),
3253
+ runtimePolicy: vvData.runtimePolicy && typeof vvData.runtimePolicy === "object" ? vvData.runtimePolicy : void 0,
3254
+ expiresAt: vvData.expiresAt ?? null,
3255
+ isExpired: isDelegationExpired(vvData.expiresAt),
3256
+ maxSpend: vvData.maxSpend !== null ? String(vvData.maxSpend) : void 0,
3257
+ instructions: vvData.instructions || null,
3258
+ skills: Array.isArray(vvData.skills) ? vvData.skills : [],
3259
+ provider: vvData.provider || vvData.modelProvider || null,
3260
+ model: vvData.model || null
3261
+ });
3262
+ }
3263
+ }
3264
+ }
3265
+ return { identities, delegations };
3266
+ }
3267
+ function buildRuntimeBundle(input) {
3268
+ const identity = input.identity || {};
3269
+ const delegation = input.delegation || null;
3270
+ const identityQHash = asString(input.identityQHash || identity.qHash);
3271
+ const delegationQHash = delegation ? asString(input.delegationQHash || delegation.qHash) : null;
3272
+ const agentId = asString(identity.agentId);
3273
+ const agentWallet = normalizeWallet(identity.agentWallet);
3274
+ if (!identityQHash || !agentId || !agentWallet) {
3275
+ throw new Error("Runtime mount requires verified agent identity (agentId, agentWallet, identityQHash).");
3276
+ }
3277
+ const effectiveRuntime = resolveEffectiveRuntime(identity, delegation);
3278
+ const deniedActions = delegation ? asStringArray(delegation.deniedActions) : [];
3279
+ const allowedActions = delegation ? asStringArray(delegation.allowedActions) : void 0;
3280
+ const requiresHumanApproval = delegation?.runtimePolicy && typeof delegation.runtimePolicy === "object" && delegation.runtimePolicy.requiresHumanApproval === true;
3281
+ const capabilities = asStringArray(identity.capabilities);
3282
+ const skills = Array.isArray(identity.skills) ? identity.skills : [];
3283
+ const skillIds = skills.map(
3284
+ (skill) => typeof skill === "string" ? skill : asString(skill?.id || skill?.label)
3285
+ ).filter(Boolean);
3286
+ const delegations = delegation ? [delegation] : [];
3287
+ const activeDelegations = delegations.filter((row) => !row.isExpired).length;
3288
+ return {
3289
+ schema: RUNTIME_MOUNT_SCHEMA,
3290
+ mountedAt: (/* @__PURE__ */ new Date()).toISOString(),
3291
+ trust: {
3292
+ identityQHash,
3293
+ delegationQHash: delegationQHash || null,
3294
+ identityProofUrl: `${PROOF_URL_BASE}${identityQHash}`,
3295
+ delegationProofUrl: delegationQHash ? `${PROOF_URL_BASE}${delegationQHash}` : null
3296
+ },
3297
+ identity: {
3298
+ agentId,
3299
+ agentWallet,
3300
+ agentLabel: asString(identity.agentLabel) || agentId,
3301
+ agentType: asString(identity.agentType) || "agent",
3302
+ description: asString(identity.description) || void 0,
3303
+ instructions: asString(identity.instructions) || void 0,
3304
+ capabilities,
3305
+ skills,
3306
+ services: Array.isArray(identity.services) ? identity.services : void 0,
3307
+ defaultRuntime: identity.defaultRuntime && typeof identity.defaultRuntime === "object" ? identity.defaultRuntime : void 0
3308
+ },
3309
+ delegation: delegation ? {
3310
+ controllerWallet: normalizeWallet(delegation.controllerWallet) || asString(delegation.controllerWallet),
3311
+ scope: asString(delegation.scope) || void 0,
3312
+ allowedActions,
3313
+ deniedActions,
3314
+ runtimePolicy: delegation.runtimePolicy,
3315
+ expiresAt: delegation.expiresAt ?? null,
3316
+ isExpired: Boolean(delegation.isExpired),
3317
+ maxSpend: delegation.maxSpend,
3318
+ instructions: asString(delegation.instructions) || void 0,
3319
+ skills: Array.isArray(delegation.skills) ? delegation.skills : void 0,
3320
+ provider: asString(delegation.provider) || void 0,
3321
+ model: asString(delegation.model) || void 0
3322
+ } : null,
3323
+ effectiveRuntime,
3324
+ tools: Array.isArray(input.tools) ? input.tools : [],
3325
+ secretBindings: Array.isArray(input.secretBindings) ? input.secretBindings : [],
3326
+ memoryRefs: Array.isArray(input.memoryRefs) ? input.memoryRefs : void 0,
3327
+ enforce: {
3328
+ deniedActions,
3329
+ ...allowedActions?.length ? { allowedActions } : {},
3330
+ ...requiresHumanApproval ? { requiresHumanApproval: true } : {}
3331
+ },
3332
+ contextPack: {
3333
+ identityCount: 1,
3334
+ delegationCount: delegations.length,
3335
+ activeDelegations,
3336
+ capabilitiesSummary: capabilities.slice(0, 32),
3337
+ skillsSummary: skillIds.slice(0, 32)
3338
+ }
3339
+ };
3340
+ }
3341
+ function profileAgentToIdentitySeed(profileAgent) {
3342
+ return {
3343
+ agentId: profileAgent.agentId,
3344
+ agentWallet: profileAgent.agentWallet,
3345
+ agentLabel: profileAgent.agentLabel || profileAgent.name,
3346
+ agentType: profileAgent.agentType || profileAgent.typeLabel,
3347
+ description: profileAgent.description,
3348
+ instructions: profileAgent.instructions,
3349
+ capabilities: capabilitiesToArray(profileAgent.capabilities),
3350
+ skills: Array.isArray(profileAgent.skills) ? profileAgent.skills : [],
3351
+ services: Array.isArray(profileAgent.services) ? profileAgent.services : [],
3352
+ identityQHash: profileAgent.identityQHash || profileAgent.qHash
3353
+ };
3354
+ }
3355
+ function isRuntimeBundle(value) {
3356
+ return Boolean(value && typeof value === "object" && value.schema === RUNTIME_MOUNT_SCHEMA);
3357
+ }
3358
+ async function resolveRuntimeBundleFromMcp(input) {
3359
+ const accessKey = asString(input.accessKey);
3360
+ if (!accessKey) {
3361
+ throw new Error("NEUS access key or authenticated MCP session is required for runtime mount.");
3362
+ }
3363
+ const selector = {
3364
+ agentId: input.agentId,
3365
+ agentWallet: input.agentWallet,
3366
+ identityQHash: input.identityQHash
3367
+ };
3368
+ if (!selector.agentId && !selector.agentWallet && !selector.identityQHash) {
3369
+ throw new Error("Provide agentId, agentWallet, or identityQHash.");
3370
+ }
3371
+ let sessionId = "";
3372
+ if (input.initializeMcp) {
3373
+ const init = await input.initializeMcp();
3374
+ sessionId = init.sessionId || "";
3375
+ }
3376
+ const mountArgs = {
3377
+ ...selector.agentId ? { agentId: selector.agentId } : {},
3378
+ ...selector.agentWallet ? { agentWallet: selector.agentWallet } : {},
3379
+ ...selector.identityQHash ? { identityQHash: selector.identityQHash } : {}
3380
+ };
3381
+ const serverMount = await input.callMcpTool({
3382
+ name: "neus_agent_mount",
3383
+ args: mountArgs,
3384
+ accessKey,
3385
+ sessionId,
3386
+ signal: input.signal
3387
+ });
3388
+ if (serverMount.ok) {
3389
+ const payload = serverMount.payload;
3390
+ if (isRuntimeBundle(payload)) {
3391
+ return (
3392
+ /** @type {import('./runtime-mount.js').RuntimeBundle} */
3393
+ payload
3394
+ );
3395
+ }
3396
+ if (payload && typeof payload === "object" && isRuntimeBundle(payload.data)) {
3397
+ return (
3398
+ /** @type {import('./runtime-mount.js').RuntimeBundle} */
3399
+ payload.data
3400
+ );
3401
+ }
3402
+ }
3403
+ const me = await input.callMcpTool({
3404
+ name: "neus_me",
3405
+ args: {},
3406
+ accessKey,
3407
+ sessionId,
3408
+ signal: input.signal
3409
+ });
3410
+ if (!me.ok) {
3411
+ throw new Error(me.error || "Could not load profile context. Run `neus auth` and retry.");
3412
+ }
3413
+ const mePayload = (
3414
+ /** @type {Record<string, unknown>} */
3415
+ me.payload || {}
3416
+ );
3417
+ if (mePayload.status === "auth_required") {
3418
+ throw new Error("Profile authentication required. Run `neus auth` or set NEUS_ACCESS_KEY.");
3419
+ }
3420
+ const principal = (
3421
+ /** @type {Record<string, unknown>} */
3422
+ mePayload.principal || {}
3423
+ );
3424
+ const controllerWallet = normalizeWallet(principal.primaryAccount);
3425
+ const profileAgents = Array.isArray(mePayload.agents) ? mePayload.agents : [];
3426
+ let agentWallet = normalizeWallet(selector.agentWallet);
3427
+ let agentId = asString(selector.agentId);
3428
+ if (!agentWallet && agentId) {
3429
+ const row = profileAgents.find(
3430
+ (row2) => asString(row2.agentId).toLowerCase() === agentId.toLowerCase()
3431
+ );
3432
+ if (row) {
3433
+ agentWallet = normalizeWallet(row.agentWallet);
3434
+ }
3435
+ }
3436
+ if (!agentId && agentWallet) {
3437
+ const row = profileAgents.find((row2) => normalizeWallet(row2.agentWallet) === agentWallet);
3438
+ if (row) agentId = asString(row.agentId);
3439
+ }
3440
+ if (!agentWallet && selector.identityQHash) {
3441
+ const idProof = await input.callMcpTool({
3442
+ name: "neus_proofs_get",
3443
+ args: { qHash: selector.identityQHash, verifierId: "agent-identity" },
3444
+ accessKey,
3445
+ sessionId,
3446
+ signal: input.signal
3447
+ });
3448
+ if (idProof.ok) {
3449
+ const data = (
3450
+ /** @type {Record<string, unknown>} */
3451
+ idProof.payload?.data || idProof.payload || {}
3452
+ );
3453
+ const proofs = Array.isArray(data.proofs) ? data.proofs : [];
3454
+ const extracted = extractAgentContextFromProofs(proofs);
3455
+ const identity2 = pickIdentity(extracted.identities, selector);
3456
+ if (identity2) {
3457
+ agentWallet = normalizeWallet(identity2.agentWallet);
3458
+ agentId = asString(identity2.agentId);
3459
+ }
3460
+ }
3461
+ }
3462
+ if (!agentWallet) {
3463
+ throw new Error("Could not resolve agent wallet. Check agentId or link the agent on your profile.");
3464
+ }
3465
+ const [identityPage, delegationPage] = await Promise.all([
3466
+ input.callMcpTool({
3467
+ name: "neus_proofs_get",
3468
+ args: { identifier: agentWallet, verifierId: "agent-identity", limit: 25 },
3469
+ accessKey,
3470
+ sessionId,
3471
+ signal: input.signal
3472
+ }),
3473
+ controllerWallet ? input.callMcpTool({
3474
+ name: "neus_proofs_get",
3475
+ args: { identifier: controllerWallet, verifierId: "agent-delegation", limit: 50 },
3476
+ accessKey,
3477
+ sessionId,
3478
+ signal: input.signal
3479
+ }) : Promise.resolve({ ok: false })
3480
+ ]);
3481
+ const identityProofs = identityPage.ok ? (
3482
+ /** @type {unknown[]} */
3483
+ identityPage.payload?.data?.proofs || identityPage.payload?.proofs || []
3484
+ ) : [];
3485
+ const delegationProofs = delegationPage.ok ? (
3486
+ /** @type {unknown[]} */
3487
+ delegationPage.payload?.data?.proofs || delegationPage.payload?.proofs || []
3488
+ ) : [];
3489
+ const idCtx = extractAgentContextFromProofs(identityProofs);
3490
+ const delCtx = extractAgentContextFromProofs(delegationProofs);
3491
+ let identity = pickIdentity(idCtx.identities, { ...selector, agentId, agentWallet });
3492
+ if (!identity && profileAgents.length > 0) {
3493
+ const row = profileAgents.find(
3494
+ (a) => asString(a.agentId).toLowerCase() === agentId.toLowerCase() || normalizeWallet(a.agentWallet) === agentWallet
3495
+ );
3496
+ if (row) {
3497
+ identity = { ...profileAgentToIdentitySeed(row), agentWallet, agentId: agentId || asString(row.agentId) };
3498
+ }
3499
+ }
3500
+ if (!identity) {
3501
+ throw new Error("Agent identity proof not found. Complete agent setup on neus.network first.");
3502
+ }
3503
+ const delegation = pickActiveDelegation(
3504
+ delCtx.delegations,
3505
+ controllerWallet,
3506
+ agentWallet,
3507
+ agentId || asString(identity.agentId)
3508
+ );
3509
+ return buildRuntimeBundle({
3510
+ identity,
3511
+ delegation,
3512
+ identityQHash: asString(identity.qHash || selector.identityQHash),
3513
+ delegationQHash: delegation ? asString(delegation.qHash) : null,
3514
+ tools: [],
3515
+ secretBindings: []
3516
+ });
3517
+ }
3518
+ function evaluateMountFileHealth(manifest) {
3519
+ if (!manifest || manifest.schema !== RUNTIME_MOUNT_SCHEMA) {
3520
+ return {
3521
+ mountFileValid: false,
3522
+ missingDelegation: true,
3523
+ delegationExpired: false,
3524
+ needsRefresh: true,
3525
+ reason: "missing_or_invalid"
3526
+ };
3527
+ }
3528
+ const delegationQHash = asString(manifest.trust?.delegationQHash);
3529
+ const missingDelegation = !delegationQHash;
3530
+ const expiresAt = manifest.delegation?.expiresAt;
3531
+ const delegationExpired = Boolean(manifest.delegation?.isExpired) || isDelegationExpired(expiresAt);
3532
+ return {
3533
+ mountFileValid: true,
3534
+ missingDelegation,
3535
+ delegationExpired,
3536
+ needsRefresh: missingDelegation || delegationExpired,
3537
+ reason: delegationExpired ? "delegation_expired" : missingDelegation ? "delegation_missing" : null
3538
+ };
3539
+ }
3540
+
3541
+ // index.js
3090
3542
  init_errors();
3543
+
3544
+ // cli-commands.js
3545
+ var NEUS_PKG = "@neus/sdk";
3546
+ var NEUS_INSTALL_CLI = `npm i -g ${NEUS_PKG}`;
3547
+ var NEUS_NPX = `npx ${NEUS_PKG}`;
3548
+ var NEUS_SETUP_CLI = "neus setup";
3549
+ var NEUS_AUTH_CLI = "neus auth";
3550
+ var NEUS_CHECK_CLI = "neus check";
3551
+ var NEUS_DOCTOR_CLI = "neus doctor --live";
3552
+ var NEUS_EXAMPLES_CLI = "neus examples";
3553
+ var NEUS_SETUP_NPX = `${NEUS_NPX} setup`;
3554
+ var NEUS_AUTH_NPX = `${NEUS_NPX} auth`;
3555
+ var NEUS_CHECK_NPX = `${NEUS_NPX} check`;
3556
+ var NEUS_DOCTOR_NPX = `${NEUS_NPX} doctor --live`;
3557
+ var NEUS_EXAMPLES_NPX = `${NEUS_NPX} examples`;
3558
+ function neusMountApply(agentId, host = "cursor") {
3559
+ const id = String(agentId || "").trim();
3560
+ return `neus mount ${id} --apply ${host}`;
3561
+ }
3562
+ function neusMountApplyNpx(agentId, host = "cursor") {
3563
+ const id = String(agentId || "").trim();
3564
+ return `${NEUS_NPX} mount ${id} --apply ${host}`;
3565
+ }
3566
+ var NEUS_QUICKSTART_INSTALLED = `${NEUS_INSTALL_CLI}
3567
+ ${NEUS_SETUP_CLI}
3568
+ ${NEUS_AUTH_CLI}`;
3569
+ var NEUS_QUICKSTART_NPX = NEUS_SETUP_NPX;
3570
+ var NEUS_MOUNT_WORKFLOW = `${NEUS_AUTH_CLI}
3571
+ neus mount <agentId> --apply cursor
3572
+ ${NEUS_DOCTOR_CLI}`;
3573
+ function neusCmd(subcommand) {
3574
+ return `neus ${String(subcommand || "").trim()}`;
3575
+ }
3576
+ function neusNpx(subcommand) {
3577
+ return `${NEUS_NPX} ${String(subcommand || "").trim()}`;
3578
+ }
3579
+
3580
+ // mcp-hosts.js
3581
+ var NEUS_MCP_SERVER_NAME = "neus";
3582
+ var NEUS_MCP_URL = "https://mcp.neus.network/mcp";
3583
+ var NEUS_MCP_SETUP_DOCS_URL = "https://docs.neus.network/mcp/setup";
3584
+ var MCP_INSTALL_CLIENTS = ["claude", "codex", "cursor", "vscode"];
3585
+ var MCP_INSTALL_HOSTS = ["cursor", "claude", "codex"];
3586
+ var IDE_HOST_LABELS = {
3587
+ cursor: "Cursor",
3588
+ claude: "Claude Code",
3589
+ codex: "Codex"
3590
+ };
3591
+ var IDE_HOST_BRAND_LOGOS = {
3592
+ cursor: "/images/brandLogos/cursor.svg",
3593
+ claude: "/images/brandLogos/anthropic.svg",
3594
+ codex: "/images/brandLogos/openai.svg"
3595
+ };
3596
+ function buildNeusMcpHttpConfig(accessKey) {
3597
+ const key = String(accessKey || "").trim();
3598
+ return {
3599
+ type: "http",
3600
+ url: NEUS_MCP_URL,
3601
+ ...key ? { headers: { Authorization: `Bearer ${key}` } } : {}
3602
+ };
3603
+ }
3604
+ function encodeBase64Json(value) {
3605
+ const json = JSON.stringify(value);
3606
+ if (typeof globalThis.btoa === "function") {
3607
+ return globalThis.btoa(json);
3608
+ }
3609
+ return Buffer.from(json, "utf8").toString("base64");
3610
+ }
3611
+ function buildCursorMcpInstallUrl(accessKey) {
3612
+ const config = buildNeusMcpHttpConfig(accessKey);
3613
+ const encoded = encodeBase64Json(config);
3614
+ return `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(NEUS_MCP_SERVER_NAME)}&config=${encodeURIComponent(encoded)}`;
3615
+ }
3616
+ function buildVsCodeMcpInstallUrl(accessKey) {
3617
+ const payload = {
3618
+ name: NEUS_MCP_SERVER_NAME,
3619
+ ...buildNeusMcpHttpConfig(accessKey)
3620
+ };
3621
+ return `vscode:mcp/install?${encodeURIComponent(JSON.stringify(payload))}`;
3622
+ }
3623
+ function buildAuthCommandForClient(client) {
3624
+ if (client === "codex") {
3625
+ return neusCmd(`auth --client codex`);
3626
+ }
3627
+ return NEUS_AUTH_CLI;
3628
+ }
3629
+ function buildSetupCommandForClient(client, accessKey) {
3630
+ const key = String(accessKey || "").trim();
3631
+ const setup = key ? neusCmd(`setup --client ${client} --access-key ${key}`) : neusCmd(`setup --client ${client}`);
3632
+ if (key) {
3633
+ return `${NEUS_INSTALL_CLI}
3634
+ ${setup}`;
3635
+ }
3636
+ const auth = buildAuthCommandForClient(client);
3637
+ return `${NEUS_INSTALL_CLI}
3638
+ ${setup}
3639
+ ${auth}`;
3640
+ }
3641
+ function buildSetupCommandForHost(host, accessKey) {
3642
+ return buildSetupCommandForClient(host, accessKey);
3643
+ }
3644
+ function buildSetupNpxOneLiner(client) {
3645
+ if (!client) return NEUS_SETUP_NPX;
3646
+ return `${NEUS_NPX} setup --client ${client}`;
3647
+ }
3648
+ function supportsMcpInstallDeeplink(host) {
3649
+ if (host !== "cursor") return false;
3650
+ if (typeof navigator === "undefined") return false;
3651
+ const ua = navigator.userAgent || "";
3652
+ return !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
3653
+ }
3654
+
3655
+ // index.js
3091
3656
  var index_default = {
3092
3657
  NeusClient: () => Promise.resolve().then(() => (init_client(), client_exports)).then((m) => m.NeusClient),
3093
3658
  toString: () => "[neus/sdk]"
@@ -3110,18 +3675,50 @@ var index_default = {
3110
3675
  GATE_TOKEN_HOLDER,
3111
3676
  GATE_WALLET_RISK,
3112
3677
  HOUR,
3678
+ IDE_HOST_BRAND_LOGOS,
3679
+ IDE_HOST_LABELS,
3680
+ MCP_INSTALL_CLIENTS,
3681
+ MCP_INSTALL_HOSTS,
3113
3682
  MONTH,
3683
+ NEUS_AUTH_CLI,
3684
+ NEUS_AUTH_NPX,
3685
+ NEUS_CHECK_CLI,
3686
+ NEUS_CHECK_NPX,
3114
3687
  NEUS_CONSTANTS,
3688
+ NEUS_DOCTOR_CLI,
3689
+ NEUS_DOCTOR_NPX,
3690
+ NEUS_EXAMPLES_CLI,
3691
+ NEUS_EXAMPLES_NPX,
3692
+ NEUS_INSTALL_CLI,
3693
+ NEUS_MCP_SERVER_NAME,
3694
+ NEUS_MCP_SETUP_DOCS_URL,
3695
+ NEUS_MCP_URL,
3696
+ NEUS_MOUNT_WORKFLOW,
3697
+ NEUS_NPX,
3698
+ NEUS_PKG,
3699
+ NEUS_QUICKSTART_INSTALLED,
3700
+ NEUS_QUICKSTART_NPX,
3701
+ NEUS_SETUP_CLI,
3702
+ NEUS_SETUP_NPX,
3115
3703
  NetworkError,
3116
3704
  NeusClient,
3117
3705
  PORTABLE_PROOF_SIGNER_HEADER,
3706
+ RUNTIME_MOUNT_SCHEMA,
3118
3707
  SDKError,
3119
3708
  StatusPoller,
3120
3709
  ValidationError,
3121
3710
  VerificationError,
3122
3711
  WEEK,
3123
3712
  YEAR,
3713
+ buildAuthCommandForClient,
3714
+ buildCursorMcpInstallUrl,
3715
+ buildNeusMcpHttpConfig,
3716
+ buildRuntimeBundle,
3717
+ buildSetupCommandForClient,
3718
+ buildSetupCommandForHost,
3719
+ buildSetupNpxOneLiner,
3124
3720
  buildVerificationRequest,
3721
+ buildVsCodeMcpInstallUrl,
3125
3722
  combineGates,
3126
3723
  computeContentHash,
3127
3724
  constructVerificationMessage,
@@ -3129,19 +3726,34 @@ var index_default = {
3129
3726
  createVerificationData,
3130
3727
  delay,
3131
3728
  deriveDid,
3729
+ evaluateMountFileHealth,
3730
+ extractAgentContextFromProofs,
3132
3731
  fetchSponsorGrant,
3133
3732
  formatTimestamp,
3134
3733
  formatVerificationStatus,
3135
3734
  getHostedCheckoutUrl,
3735
+ isDelegationExpired,
3136
3736
  isFailureStatus,
3737
+ isRuntimeBundle,
3137
3738
  isSuccessStatus,
3138
3739
  isSupportedChain,
3139
3740
  isTerminalStatus,
3741
+ neusCmd,
3742
+ neusMountApply,
3743
+ neusMountApplyNpx,
3744
+ neusNpx,
3140
3745
  normalizeAddress,
3746
+ normalizeWallet,
3747
+ pickActiveDelegation,
3748
+ pickIdentity,
3749
+ profileAgentToIdentitySeed,
3141
3750
  resolveDID,
3751
+ resolveEffectiveRuntime,
3752
+ resolveRuntimeBundleFromMcp,
3142
3753
  resolveZkPassportConfig,
3143
3754
  signMessage,
3144
3755
  standardizeVerificationRequest,
3756
+ supportsMcpInstallDeeplink,
3145
3757
  toAgentDelegationMaxSpend,
3146
3758
  toHexUtf8,
3147
3759
  validateQHash,