Lending-Mind Protocol
Reference

TypeScript SDK

Hash, sign, verify, redact, and work with Mind packages from Node.js.

TypeScript SDK

The @lending-mind/sdk package is the Node.js and TypeScript library for the data and integrity layer of LMP. It gives application code a shared set of protocol types and deterministic helpers for working with Mind packages and evaluation artifacts.

The SDK is not the policy evaluator. The Rust runtime remains authoritative for scope resolution, evaluation, enforcement, and the final policy decision. Use the SDK when you are building tooling around that runtime: package publishers, registries, CI adapters, agent integrations, dashboards, and test fixtures.

Install

npm install @lending-mind/sdk

The package is ESM-only and exports its public API from one entry point:

import {
  type EvaluationArtifact,
  type MindPackage,
  computePackageDigest,
  redactSecrets,
  sha256,
  signEd25519,
  verifyEd25519,
} from "@lending-mind/sdk";

Public API

The package exports these stable groups from @lending-mind/sdk:

ExportParametersReturnsUse
canonicalJson(value)JSON-compatible valuestringSerialize objects with sorted keys before hashing or signing
sha256(payload)String, bytes, or JSON valuestringCreate a sha256:<hex> digest
computePackageDigest(path)Package directory pathPromise<string>Digest a complete package manifest
generateEd25519KeyPair()NoneKey objectsCreate an in-memory signing pair
signEd25519(payload, privateKey)Payload and private keystringCreate a detached signature
verifyEd25519(payload, signature, publicKey)Payload, signature, public keybooleanCheck detached signature validity
createKeyPair(directory)Output directoryPromise<{ privatePath, publicPath }>Write PEM key files with a protected private key
signMindPackage(path, privateKeyPath)Package path and key pathDigest and signatureSign a package directory
rotateMindPackageKey(path, currentKeyPath, nextKeyDirectory)Package path and current/next key pathsRotation recordRotate a package signer after verifying the current signature
verifyMindPackage(path, publicKeyPath?)Package path and optional key pathVerification resultValidate package integrity and signature state
redactSecrets(value)JSON-compatible valueRedacted valueRemove credential-like object fields
redactText(value)TextRedacted textRemove credential-like values from logs
workspaceConfig(input?, cwd?)Partial config and base pathWorkspaceConfigNormalize workspace metadata
readWorkspaceConfig(path)JSON config pathPromise<WorkspaceConfig>Read and normalize workspace metadata

The type exports include MindPackage, RuleDefinition, RuleResult, EvaluationArtifact, EvaluationState, EvaluationSummary, RegistryReference, PromotionRecord, and PromotionProposal. An artifact state can be pass, needs_revision, blocked, or evaluation_error; the last state is fail-closed and never means acceptance. The SDK does not export the Rust evaluator or silently invoke an agent host.

What it is for

CapabilityUse it for
Shared typesKeep Mind packages, findings, evaluation artifacts, registry entries, and promotion records consistent across tools.
Canonical JSONProduce stable serialized bytes before hashing or signing.
DigestsIdentify exact content with SHA-256, including complete package manifests.
Ed25519 integrityCreate and verify detached signatures for package content.
RedactionRemove credential-like values before writing logs or evidence.
Workspace metadataResolve a workspace configuration for Node-based tooling.

It is useful when a Node process needs to prepare or inspect protocol data, but it must not be used as a substitute for lmp evaluate or the Rust MCP server. Those paths provide the actual evaluation and enforcement boundary.

Applications and real-world use cases

The SDK is useful inside applications that need to move Mind packages and evidence safely between people, agents, and automation:

ApplicationSDK use case
AI coding platformLoad a selected Mind, verify its signature, and attach typed metadata to an agent task.
CI/CD quality gateVerify the package and redact evaluation output before publishing a pull-request or release artifact.
Private enterprise registryBuild a catalog for signed Mind versions, promotion records, provenance, and approval state.
IDE or editor extensionDisplay the active Mind, integrity status, and safe evaluation summaries in VS Code, JetBrains, or an internal editor.
Agent orchestration serviceSelect a repository-scoped Mind and persist hashes, findings, and redacted run metadata.
Security and compliance pipelineDetect package tampering and prevent credentials from entering logs or evidence.
Benchmarking platformBind baseline and guided runs to exact Mind versions, task metadata, and reproducible digests.
Developer portal or dashboardShow Mind versions, provenance, signature state, findings, and release history.
Publishing and promotion toolCreate keys, sign packages, rotate signers, and prepare registry promotion records.

These are integration use cases: the SDK prepares and verifies protocol data. It does not independently decide whether source code is acceptable. Use the Rust runtime for evaluation, lmpd for daemon behavior, and the MCP server for agent-host connectivity.

Hash a Mind package

Use sha256 for a stable digest of a JSON value, string, or byte sequence. The SDK canonicalizes JSON objects by sorting their keys, so equivalent objects produce the same digest.

import { sha256, type MindPackage } from "@lending-mind/sdk";

const mind: MindPackage = {
  id: "lmp:mind:example",
  version: "1.0.0",
  name: "Example Mind",
  rules: [{ id: "errors.keep-cause", severity: "error" }],
};

const digest = sha256(mind as Parameters<typeof sha256>[0]);
console.log(digest); // sha256:...

For a package on disk, computePackageDigest hashes the complete file manifest. It excludes local state such as .git, node_modules, signatures, and private key files.

import { computePackageDigest } from "@lending-mind/sdk";

const digest = await computePackageDigest("./profiles/baseline");

Sign and verify content

Use Ed25519 when publishing or checking a detached integrity record. Signing proves that the verified bytes came from the holder of the private key; it does not prove that the policy itself is correct or safe.

import {
  generateEd25519KeyPair,
  signEd25519,
  verifyEd25519,
} from "@lending-mind/sdk";

const { publicKey, privateKey } = generateEd25519KeyPair();
const payload = { packageId: "lmp:mind:example", version: "1.0.0" };
const signature = signEd25519(payload, privateKey);

const valid = verifyEd25519(payload, signature, publicKey);
console.log(valid); // true

For a package directory, use the higher-level helpers. They create and check the package's detached signature files and enforce the package-manifest flow used by the CLI:

import {
  createKeyPair,
  signMindPackage,
  verifyMindPackage,
} from "@lending-mind/sdk";

await createKeyPair("./.lending-mind/keys");
await signMindPackage(
  "./profiles/baseline",
  "./.lending-mind/keys/private-key.pem",
);

const result = await verifyMindPackage(
  "./profiles/baseline",
  "./profiles/baseline/signatures/public-key.pem",
);
console.log(result.signatureStatus); // verified, invalid, or another status

Keep private keys outside committed package content. Rotate a signer only from an already verified package with rotateMindPackageKey; the CLI exposes that same operation as lmp skill rotate-key.

Redact logs and evidence

Redaction is intended for command output, telemetry, and evidence metadata. It does not encrypt data and it should not be treated as a secret store.

import { redactSecrets, redactText } from "@lending-mind/sdk";

const safeMetadata = redactSecrets({
  command: "lmp evaluate",
  apiToken: "do-not-write-this",
});

const safeOutput = redactText("token=do-not-write-this");

Workspace configuration

Node tooling can normalize a workspace-relative configuration or read one from disk:

import { readWorkspaceConfig, workspaceConfig } from "@lending-mind/sdk";

const config = workspaceConfig({
  workspacePath: ".",
  environment: "ci",
});

const fromDisk = await readWorkspaceConfig(".lending-mind/sdk.json");

SDK versus CLI and runtime

Choose the layer that owns the job:

NeedUse
Build, validate, sign, or inspect package data in a Node tool@lending-mind/sdk
Run an evaluation and produce an evidence artifactlmp evaluate
Connect an agent host over Model Context Protocollmp-mcp or @lending-mind/mcp
Compile and validate the Mind schema@lending-mind/skill and the CLI
Enforce policy decisionsRust runtime

The SDK is therefore the integration layer around LMP, not a second evaluator. An integration should use it for typed data, stable hashes, signatures, and safe serialization, then hand evaluation and enforcement to the native runtime.

Stability and trust

The package follows the protocol version published with the repository. A valid TypeScript type or cryptographic signature does not make a Mind package trusted by itself: consumers must still validate the schema, inspect provenance, verify the signer against an operator trust root, and evaluate the selected workspace scope with the Rust runtime.

Ask DeepWiki about Lending-Mind Protocol

On this page