🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@essentialai/cogent

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@essentialai/cogent

Shared types, schemas, and contracts for Cogent Bridge

latest
Source
npmnpm
Version
3.6.1
Version published
Maintainers
1
Created
Source

@essentialai/cogent

npm version license downloads

Shared types, Zod schemas, and error codes for the Cogent bridge ecosystem.

This package provides the contract layer used by both @essentialai/cogent-bridge (MCP client) and @essentialai/cogent-server (cloud relay server).

Install

npm install @essentialai/cogent

Peer dependency: zod (^3.25.0 || ^4.0.0)

What's Included

Type Definitions

  • Session types -- SessionInfo, CreateSessionRequest/Response, JoinSessionRequest/Response
  • Peer types -- PeerInfo, RegisterPeerRequest/Response, ListPeersResponse
  • Message types -- SendMessageRequest/Response, MessageRecord, GetHistoryResponse
  • WebSocket frame types -- WsFrame, PeerConnectedFrame, MessagePushFrame, HeartbeatFrame
  • API contracts -- RouteContract mapping all 9 REST endpoints

Zod Schemas

Every type has a corresponding Zod schema for runtime validation:

import { CreateSessionRequestSchema, JoinSessionResponseSchema } from "@essentialai/cogent";

// Validate incoming request
const parsed = CreateSessionRequestSchema.parse(requestBody);

// Validate API response
const response = JoinSessionResponseSchema.parse(apiResponse);

Error Codes

31 unified error codes across file, HTTP, WebSocket, and auth domains:

import { ErrorCode, BridgeError } from "@essentialai/cogent";

throw new BridgeError(
  ErrorCode.SESSION_NOT_FOUND,
  "Session abc-123 not found",
  "Check the session ID or create a new session"
);

Route Contracts

Type-safe API endpoint definitions:

import { API_ROUTES } from "@essentialai/cogent";

// API_ROUTES.createSession -> { method, path, request schema, response schema }
// API_ROUTES.joinSession -> ...
// API_ROUTES.registerPeer -> ...

Helpers

  • generateSessionId() / generatePeerId() / generateMessageId() -- UUID v4 generators
  • generateSessionLabel() -- human-readable adjective-noun-hex labels
  • isValidSessionId() / isValidSessionLabel() -- format validators

File Transport Types (subpath)

import { BridgeState, PeerInfo } from "@essentialai/cogent/file";

Types for the local file-based transport (used in local-only mode).

License

Apache-2.0

FAQs

Package last updated on 06 Aug 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts