@aimf/shared
v0.1.1
Published
Shared utilities, types, and constants for AIMF
Downloads
456
Maintainers
Readme
@aimf/shared
Core utilities, types, and constants for the AI-MCP Framework (AIMF).
Installation
pnpm add @aimf/sharedUsage
Types
import type {
// NCP Protocol
NcpRequest,
NcpResponse,
NcpEnvelope,
NcpEndpoint,
// Storage
StorageRecord,
NeuralHash,
MerkleProof,
VerificationResult,
// Security
ZtniIdentity,
AuthRequest,
AuthResponse,
// Events
NeuralEvent,
EventSubscription,
// Manifest
NeuralManifest,
} from "@aimf/shared";
const request: NcpRequest = {
jsonrpc: "2.0",
id: "1",
method: "neural.store",
params: { content: "Hello, World!" },
};Error Handling
import { AimfError, ErrorCode } from "@aimf/shared";
throw new AimfError(
ErrorCode.VALIDATION_ERROR,
"Invalid input",
{ field: "name" }
);Utilities
import {
generateId,
computeHash,
isNcpRequest,
encodeBase64,
decodeBase64,
encodeFloat32Array,
decodeFloat32Array,
} from "@aimf/shared";
const id = generateId();
const hash = computeHash("content");
const isValid = isNcpRequest(message);
// Encode/decode embeddings
const embedding = new Float32Array([0.1, 0.2, 0.3]);
const encoded = encodeFloat32Array(embedding);
const decoded = decodeFloat32Array(encoded);Constants
import { NCP_METHODS, DEFAULT_TIMEOUTS } from "@aimf/shared";
console.log(NCP_METHODS.STORE); // "neural.store"
console.log(DEFAULT_TIMEOUTS.REQUEST); // 30000Type Categories
NCP Protocol Types
NcpRequest,NcpResponse,NcpNotification- JSON-RPC 2.0 messagesNcpEnvelope- Enterprise message wrapper with neural verificationNcpEndpoint,NcpHop- Routing typesNcpTransportConfig- Transport configuration
Storage Types
StorageRecord- Neural-verified storage recordNeuralHash- Dual-hash verification structureMerkleProof- Merkle tree proof for verificationStorageQuery,StorageResult- Query typesVerificationResult- Verification operation result
Security Types
ZtniIdentity- Zero-Trust Neural IdentityRole,Permission,Policy- RBAC typesAuthRequest,AuthResponse- Authentication typesCertificate,VerificationProof- Credential types
Event Types
NeuralEvent- Neural-verified eventEventSubscription- Subscription configurationEventSchema- Event schema with compatibilityEventTopic,ConsumerGroup- Topic management
Manifest Types
NeuralManifest- Full package manifestManifestCapabilities,NeuralRequirements- Capability declarationsPackageRegistryEntry- Registry types
Exports
- Types: NCP, Storage, Security, Events, Manifest, Common
- Errors: AimfError class, ErrorCode enum, error factories
- Constants: Protocol constants, default configuration values
- Utilities: Hash, ID, validation, encoding helpers
License
MIT