UNPKG

anon-identity

Version:

Decentralized identity framework with DIDs, Verifiable Credentials, and privacy-preserving selective disclosure

309 lines 13.8 kB
"use strict"; /** * MCP (Model Context Protocol) Type Definitions * * Core types and interfaces for MCP integration in the Anonymous Identity Framework */ Object.defineProperty(exports, "__esModule", { value: true }); exports.AgentMessageType = exports.ThreatSeverity = exports.ThreatType = exports.SelectionStrategy = exports.MCPErrorCode = exports.MCPError = exports.ReferenceType = exports.RequestPriority = exports.ResponseFormatType = exports.CacheStrategy = exports.CacheProvider = exports.HealthCheckType = exports.AlertSeverity = exports.AlertOperator = exports.AlertChannelType = exports.LogOutputType = exports.LogFormat = exports.LogLevel = exports.MetricExporterType = exports.CredentialStorageType = exports.AuditExportFormat = exports.AccessAction = exports.AuthenticationMethod = exports.FunctionRiskLevel = exports.ContextPriority = exports.MessageRole = exports.ConnectionStatus = exports.ProviderStatus = exports.ResponseStatus = exports.LLMRequestType = exports.MCPMessageType = void 0; var MCPMessageType; (function (MCPMessageType) { MCPMessageType["REQUEST"] = "request"; MCPMessageType["RESPONSE"] = "response"; MCPMessageType["NOTIFICATION"] = "notification"; MCPMessageType["ERROR"] = "error"; MCPMessageType["HEARTBEAT"] = "heartbeat"; })(MCPMessageType || (exports.MCPMessageType = MCPMessageType = {})); var LLMRequestType; (function (LLMRequestType) { LLMRequestType["COMPLETION"] = "completion"; LLMRequestType["FUNCTION_CALL"] = "function_call"; LLMRequestType["EMBEDDING"] = "embedding"; LLMRequestType["MODERATION"] = "moderation"; LLMRequestType["STREAMING"] = "streaming"; })(LLMRequestType || (exports.LLMRequestType = LLMRequestType = {})); var ResponseStatus; (function (ResponseStatus) { ResponseStatus["SUCCESS"] = "success"; ResponseStatus["ERROR"] = "error"; ResponseStatus["PARTIAL"] = "partial"; ResponseStatus["TIMEOUT"] = "timeout"; ResponseStatus["RATE_LIMITED"] = "rate_limited"; })(ResponseStatus || (exports.ResponseStatus = ResponseStatus = {})); var ProviderStatus; (function (ProviderStatus) { ProviderStatus["AVAILABLE"] = "available"; ProviderStatus["UNAVAILABLE"] = "unavailable"; ProviderStatus["RATE_LIMITED"] = "rate_limited"; ProviderStatus["MAINTENANCE"] = "maintenance"; ProviderStatus["ERROR"] = "error"; })(ProviderStatus || (exports.ProviderStatus = ProviderStatus = {})); var ConnectionStatus; (function (ConnectionStatus) { ConnectionStatus["CONNECTED"] = "connected"; ConnectionStatus["DISCONNECTED"] = "disconnected"; ConnectionStatus["CONNECTING"] = "connecting"; ConnectionStatus["RECONNECTING"] = "reconnecting"; ConnectionStatus["ERROR"] = "error"; })(ConnectionStatus || (exports.ConnectionStatus = ConnectionStatus = {})); var MessageRole; (function (MessageRole) { MessageRole["USER"] = "user"; MessageRole["ASSISTANT"] = "assistant"; MessageRole["SYSTEM"] = "system"; MessageRole["FUNCTION"] = "function"; })(MessageRole || (exports.MessageRole = MessageRole = {})); var ContextPriority; (function (ContextPriority) { ContextPriority["LOW"] = "low"; ContextPriority["MEDIUM"] = "medium"; ContextPriority["HIGH"] = "high"; ContextPriority["CRITICAL"] = "critical"; })(ContextPriority || (exports.ContextPriority = ContextPriority = {})); var FunctionRiskLevel; (function (FunctionRiskLevel) { FunctionRiskLevel["LOW"] = "low"; FunctionRiskLevel["MEDIUM"] = "medium"; FunctionRiskLevel["HIGH"] = "high"; FunctionRiskLevel["CRITICAL"] = "critical"; })(FunctionRiskLevel || (exports.FunctionRiskLevel = FunctionRiskLevel = {})); var AuthenticationMethod; (function (AuthenticationMethod) { AuthenticationMethod["API_KEY"] = "api_key"; AuthenticationMethod["OAUTH2"] = "oauth2"; AuthenticationMethod["JWT"] = "jwt"; AuthenticationMethod["CERTIFICATE"] = "certificate"; AuthenticationMethod["DELEGATION"] = "delegation"; })(AuthenticationMethod || (exports.AuthenticationMethod = AuthenticationMethod = {})); var AccessAction; (function (AccessAction) { AccessAction["ALLOW"] = "allow"; AccessAction["DENY"] = "deny"; })(AccessAction || (exports.AccessAction = AccessAction = {})); var AuditExportFormat; (function (AuditExportFormat) { AuditExportFormat["JSON"] = "json"; AuditExportFormat["CSV"] = "csv"; AuditExportFormat["SYSLOG"] = "syslog"; })(AuditExportFormat || (exports.AuditExportFormat = AuditExportFormat = {})); var CredentialStorageType; (function (CredentialStorageType) { CredentialStorageType["MEMORY"] = "memory"; CredentialStorageType["FILE"] = "file"; CredentialStorageType["DATABASE"] = "database"; CredentialStorageType["VAULT"] = "vault"; CredentialStorageType["ENV"] = "environment"; })(CredentialStorageType || (exports.CredentialStorageType = CredentialStorageType = {})); var MetricExporterType; (function (MetricExporterType) { MetricExporterType["PROMETHEUS"] = "prometheus"; MetricExporterType["INFLUXDB"] = "influxdb"; MetricExporterType["CONSOLE"] = "console"; MetricExporterType["FILE"] = "file"; })(MetricExporterType || (exports.MetricExporterType = MetricExporterType = {})); var LogLevel; (function (LogLevel) { LogLevel["TRACE"] = "trace"; LogLevel["DEBUG"] = "debug"; LogLevel["INFO"] = "info"; LogLevel["WARN"] = "warn"; LogLevel["ERROR"] = "error"; LogLevel["FATAL"] = "fatal"; })(LogLevel || (exports.LogLevel = LogLevel = {})); var LogFormat; (function (LogFormat) { LogFormat["JSON"] = "json"; LogFormat["TEXT"] = "text"; LogFormat["STRUCTURED"] = "structured"; })(LogFormat || (exports.LogFormat = LogFormat = {})); var LogOutputType; (function (LogOutputType) { LogOutputType["CONSOLE"] = "console"; LogOutputType["FILE"] = "file"; LogOutputType["SYSLOG"] = "syslog"; LogOutputType["REMOTE"] = "remote"; })(LogOutputType || (exports.LogOutputType = LogOutputType = {})); var AlertChannelType; (function (AlertChannelType) { AlertChannelType["EMAIL"] = "email"; AlertChannelType["SLACK"] = "slack"; AlertChannelType["WEBHOOK"] = "webhook"; AlertChannelType["SMS"] = "sms"; AlertChannelType["PAGERDUTY"] = "pagerduty"; })(AlertChannelType || (exports.AlertChannelType = AlertChannelType = {})); var AlertOperator; (function (AlertOperator) { AlertOperator["GREATER_THAN"] = "gt"; AlertOperator["LESS_THAN"] = "lt"; AlertOperator["EQUALS"] = "eq"; AlertOperator["NOT_EQUALS"] = "ne"; AlertOperator["GREATER_EQUAL"] = "ge"; AlertOperator["LESS_EQUAL"] = "le"; })(AlertOperator || (exports.AlertOperator = AlertOperator = {})); var AlertSeverity; (function (AlertSeverity) { AlertSeverity["LOW"] = "low"; AlertSeverity["MEDIUM"] = "medium"; AlertSeverity["HIGH"] = "high"; AlertSeverity["CRITICAL"] = "critical"; })(AlertSeverity || (exports.AlertSeverity = AlertSeverity = {})); var HealthCheckType; (function (HealthCheckType) { HealthCheckType["HTTP"] = "http"; HealthCheckType["TCP"] = "tcp"; HealthCheckType["DATABASE"] = "database"; HealthCheckType["CUSTOM"] = "custom"; })(HealthCheckType || (exports.HealthCheckType = HealthCheckType = {})); var CacheProvider; (function (CacheProvider) { CacheProvider["MEMORY"] = "memory"; CacheProvider["REDIS"] = "redis"; CacheProvider["MEMCACHED"] = "memcached"; })(CacheProvider || (exports.CacheProvider = CacheProvider = {})); var CacheStrategy; (function (CacheStrategy) { CacheStrategy["LRU"] = "lru"; CacheStrategy["LFU"] = "lfu"; CacheStrategy["TTL"] = "ttl"; })(CacheStrategy || (exports.CacheStrategy = CacheStrategy = {})); var ResponseFormatType; (function (ResponseFormatType) { ResponseFormatType["TEXT"] = "text"; ResponseFormatType["JSON"] = "json"; ResponseFormatType["JSON_OBJECT"] = "json_object"; })(ResponseFormatType || (exports.ResponseFormatType = ResponseFormatType = {})); var RequestPriority; (function (RequestPriority) { RequestPriority["LOW"] = "low"; RequestPriority["MEDIUM"] = "medium"; RequestPriority["HIGH"] = "high"; RequestPriority["URGENT"] = "urgent"; RequestPriority["CRITICAL"] = "critical"; })(RequestPriority || (exports.RequestPriority = RequestPriority = {})); var ReferenceType; (function (ReferenceType) { ReferenceType["REPLY"] = "reply"; ReferenceType["QUOTE"] = "quote"; ReferenceType["THREAD"] = "thread"; })(ReferenceType || (exports.ReferenceType = ReferenceType = {})); class MCPError extends Error { constructor(options) { super(options.message); this.name = 'MCPError'; this.code = options.code; this.timestamp = options.timestamp; this.requestId = options.requestId; this.provider = options.provider; this.retryable = options.retryable; this.details = options.details; } } exports.MCPError = MCPError; var MCPErrorCode; (function (MCPErrorCode) { // General errors MCPErrorCode["UNKNOWN"] = "UNKNOWN"; MCPErrorCode["INVALID_REQUEST"] = "INVALID_REQUEST"; MCPErrorCode["INVALID_RESPONSE"] = "INVALID_RESPONSE"; MCPErrorCode["TIMEOUT"] = "TIMEOUT"; MCPErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR"; // Authentication/Authorization errors MCPErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED"; MCPErrorCode["FORBIDDEN"] = "FORBIDDEN"; MCPErrorCode["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS"; MCPErrorCode["TOKEN_EXPIRED"] = "TOKEN_EXPIRED"; // Provider errors MCPErrorCode["PROVIDER_UNAVAILABLE"] = "PROVIDER_UNAVAILABLE"; MCPErrorCode["PROVIDER_ERROR"] = "PROVIDER_ERROR"; MCPErrorCode["MODEL_NOT_FOUND"] = "MODEL_NOT_FOUND"; MCPErrorCode["RATE_LIMITED"] = "RATE_LIMITED"; MCPErrorCode["QUOTA_EXCEEDED"] = "QUOTA_EXCEEDED"; // Context errors MCPErrorCode["CONTEXT_TOO_LARGE"] = "CONTEXT_TOO_LARGE"; MCPErrorCode["CONTEXT_NOT_FOUND"] = "CONTEXT_NOT_FOUND"; MCPErrorCode["CONTEXT_EXPIRED"] = "CONTEXT_EXPIRED"; // Function calling errors MCPErrorCode["FUNCTION_NOT_FOUND"] = "FUNCTION_NOT_FOUND"; MCPErrorCode["FUNCTION_ERROR"] = "FUNCTION_ERROR"; MCPErrorCode["INVALID_FUNCTION_CALL"] = "INVALID_FUNCTION_CALL"; MCPErrorCode["FUNCTION_TIMEOUT"] = "FUNCTION_TIMEOUT"; // Configuration errors MCPErrorCode["INVALID_CONFIG"] = "INVALID_CONFIG"; MCPErrorCode["MISSING_CONFIG"] = "MISSING_CONFIG"; MCPErrorCode["CONFIG_VALIDATION_ERROR"] = "CONFIG_VALIDATION_ERROR"; // Connection errors MCPErrorCode["CONNECTION_ERROR"] = "CONNECTION_ERROR"; MCPErrorCode["NO_AVAILABLE_PROVIDERS"] = "NO_AVAILABLE_PROVIDERS"; MCPErrorCode["MAX_RETRIES_EXCEEDED"] = "MAX_RETRIES_EXCEEDED"; })(MCPErrorCode || (exports.MCPErrorCode = MCPErrorCode = {})); // Additional Phase 4 types that were missing exports /** * Provider selection strategy */ var SelectionStrategy; (function (SelectionStrategy) { SelectionStrategy["PERFORMANCE"] = "performance"; SelectionStrategy["COST_OPTIMIZED"] = "cost_optimized"; SelectionStrategy["RELIABILITY"] = "reliability"; SelectionStrategy["CAPABILITY_MATCH"] = "capability_match"; SelectionStrategy["LOAD_BALANCED"] = "load_balanced"; SelectionStrategy["SMART_ADAPTIVE"] = "smart_adaptive"; })(SelectionStrategy || (exports.SelectionStrategy = SelectionStrategy = {})); /** * Security threat types */ var ThreatType; (function (ThreatType) { ThreatType["UNAUTHORIZED_ACCESS"] = "unauthorized_access"; ThreatType["DATA_EXFILTRATION"] = "data_exfiltration"; ThreatType["PRIVILEGE_ESCALATION"] = "privilege_escalation"; ThreatType["INJECTION_ATTACK"] = "injection_attack"; ThreatType["DENIAL_OF_SERVICE"] = "denial_of_service"; ThreatType["ANOMALOUS_BEHAVIOR"] = "anomalous_behavior"; ThreatType["POLICY_VIOLATION"] = "policy_violation"; ThreatType["SUSPICIOUS_PATTERN"] = "suspicious_pattern"; })(ThreatType || (exports.ThreatType = ThreatType = {})); /** * Threat severity levels */ var ThreatSeverity; (function (ThreatSeverity) { ThreatSeverity["LOW"] = "low"; ThreatSeverity["MEDIUM"] = "medium"; ThreatSeverity["HIGH"] = "high"; ThreatSeverity["CRITICAL"] = "critical"; })(ThreatSeverity || (exports.ThreatSeverity = ThreatSeverity = {})); /** * Agent message types - re-export from agent communication */ var AgentMessageType; (function (AgentMessageType) { // Delegation requests AgentMessageType["DELEGATION_REQUEST"] = "delegation.request"; AgentMessageType["DELEGATION_GRANT"] = "delegation.grant"; AgentMessageType["DELEGATION_DENY"] = "delegation.deny"; AgentMessageType["DELEGATION_REVOKE"] = "delegation.revoke"; // Queries AgentMessageType["QUERY_STATUS"] = "query.status"; AgentMessageType["QUERY_CAPABILITIES"] = "query.capabilities"; AgentMessageType["QUERY_CHAIN"] = "query.chain"; // Responses AgentMessageType["RESPONSE_STATUS"] = "response.status"; AgentMessageType["RESPONSE_CAPABILITIES"] = "response.capabilities"; AgentMessageType["RESPONSE_CHAIN"] = "response.chain"; // Notifications AgentMessageType["NOTIFY_REVOCATION"] = "notify.revocation"; AgentMessageType["NOTIFY_EXPIRATION"] = "notify.expiration"; AgentMessageType["NOTIFY_POLICY_CHANGE"] = "notify.policy_change"; // System AgentMessageType["PING"] = "system.ping"; AgentMessageType["PONG"] = "system.pong"; AgentMessageType["ERROR"] = "system.error"; AgentMessageType["ACK"] = "system.ack"; // MCP-specific extensions AgentMessageType["REQUEST"] = "mcp.request"; AgentMessageType["COMMAND"] = "mcp.command"; AgentMessageType["QUERY"] = "mcp.query"; AgentMessageType["NOTIFICATION"] = "mcp.notification"; })(AgentMessageType || (exports.AgentMessageType = AgentMessageType = {})); //# sourceMappingURL=types.js.map