=============== LIBRARY RULES =============== From library maintainers: - Eidentic is a TypeScript SDK published on npm as `eidentic` (umbrella) and `@eidentic/*` (32 packages). Always use the TypeScript API and ESM imports. - Construct an agent with `new Agent({ id, model, store })`; wrap any AI SDK provider via `new AIModel(provider(modelId))`. - Use `@eidentic/libsql` (LibsqlStore, pure-JS, no native addon) for Next.js/serverless; `@eidentic/sqlite` (SqliteStore) for Node/Bun. - `agent.query(input, { sessionId })` returns an async generator of StreamEvents; text deltas are `ev.type === 'stream.delta'` carrying `ev.delta.text`; the terminal event is `ev.type === 'result'`. - Memory: `new Memory({ store, vector, embedder, graph })` — four tiers (lexical+vector recall, self-editing blocks, temporal knowledge graph, consolidation). - Next.js: `export const POST = withEidentic(agent)` from `@eidentic/nextjs`. React: `useEidenticStream(endpoint)` from `@eidentic/react`. Server: `createServer({ agents })` + `serveNode(app, { port })` from `@eidentic/server`. - The umbrella package `eidentic` re-exports core+types+model+sqlite+memory; install adapters (`@eidentic/server`, `@eidentic/workflow`, etc.) separately as needed. ### Install and Build Eidentic Examples Source: https://github.com/eidentic/eidentic/blob/main/README.md Installs dependencies, builds packages, and runs a 'hello' command with a mock model. No API key is needed for this step. ```bash pnpm install pnpm -r build pnpm --filter eidentic-examples hello ``` -------------------------------- ### Install Dependencies and Run Development Server Source: https://github.com/eidentic/eidentic/blob/main/packages/create-eidentic/README.md After scaffolding, navigate to the project directory, install dependencies using pnpm, set your API key environment variable, and start the development server. ```bash cd my-agent pnpm install # Set your API key, e.g.: export ANTHROPIC_API_KEY=sk-ant-... pnpm dev ``` -------------------------------- ### Install Eidentic and AI SDK Source: https://github.com/eidentic/eidentic/blob/main/README.md Install the necessary packages for Eidentic and the Anthropic AI SDK. This is the initial setup step for using Eidentic in your application. ```bash npm install eidentic ai @ai-sdk/anthropic ``` -------------------------------- ### Basic Usage with Node.js Source: https://github.com/eidentic/eidentic/blob/main/packages/server/README.md Set up and run the Eidentic server in a Node.js environment. This example demonstrates agent creation, authentication setup, and starting the server on port 3000. The server exposes endpoints for querying agents, checking run status, and listing workflows. ```typescript import { createServer, serveNode, ApiKeyAuth } from "@eidentic/server"; import { Agent, AIModel, SqliteStore } from "eidentic"; import { anthropic } from "@ai-sdk/anthropic"; const agent = new Agent({ id: "support", model: new AIModel(anthropic("claude-sonnet-4-5")), store: new SqliteStore("./eidentic.sqlite"), }); const app = createServer({ agents: { support: agent }, auth: ApiKeyAuth({ "key_live_abc123": { userId: "u-1" } }), }); // Node.js await serveNode(app, { port: 3000 }); // POST /v1/agents/support/query → NDJSON stream // GET /v1/runs/:id/status → async run status // GET /v1/workflows → workflow run list ``` -------------------------------- ### Run Context Compaction Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:compaction' example to test token-budget-triggered window compaction that preserves failure evidence and atomic tool pairs. ```bash pnpm -C examples hello:compaction ``` -------------------------------- ### Install @eidentic/prompts Source: https://github.com/eidentic/eidentic/blob/main/packages/prompts/README.md Install the library using pnpm. ```bash pnpm add @eidentic/prompts ``` -------------------------------- ### Run MCP Host Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:mcp' example to test consuming external MCP servers' tools as first-class Eidentic tools. ```bash pnpm -C examples hello:mcp ``` -------------------------------- ### Run Reasoning Strategies Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:strategies' example to test composable reasoning strategies like 'reflection' (using a different model as a critic) and 'planAndExecute'. ```bash pnpm -C examples hello:strategies ``` -------------------------------- ### Run Token Streaming Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:stream' example to test the agent's ability to stream model output token-by-token. ```bash pnpm -C examples hello:stream ``` -------------------------------- ### Run Prompt Skills Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:skill' example to test the agent's ability to search and use skills defined in SKILL.md files. ```bash pnpm -C examples hello:skill ``` -------------------------------- ### Run Any Eidentic Feature Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute any feature example by specifying its name after 'hello:'. ```bash # run any feature: ``` ```bash pnpm -C examples hello: ``` -------------------------------- ### Install @eidentic/libsql Source: https://github.com/eidentic/eidentic/blob/main/packages/libsql/README.md Install the package using pnpm. ```bash pnpm add @eidentic/libsql ``` -------------------------------- ### Initialize Eidentic Agent with PostgreSQL Store Source: https://github.com/eidentic/eidentic/blob/main/packages/postgres/README.md Set up a PostgreSQL connection pool and initialize an Eidentic agent using the PostgresStore. This example demonstrates how to connect to a database and start an agent interaction. ```typescript import { PostgresStore } from "@eidentic/postgres"; import pg from "pg"; import { Agent, AIModel } from "eidentic"; import { anthropic } from "@ai-sdk/anthropic"; const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL }); const store = await PostgresStore.create({ client: pool }); const agent = new Agent({ id: "support", model: new AIModel(anthropic("claude-sonnet-4-5")), store, }); for await (const ev of agent.query("Hello", { sessionId: "s-1" })) { if (ev.type === "stream.delta") process.stdout.write(ev.delta.text); } ``` -------------------------------- ### Run MCP Server Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:mcp-server' example to test exposing Eidentic tools/agents as an MCP server compatible with any MCP client. ```bash pnpm -C examples hello:mcp-server ``` -------------------------------- ### Run Schema Evolution Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:schema-evolution' example to test event upcasting for replaying old logs on new code and embedding re-indexing. ```bash pnpm -C examples hello:schema-evolution ``` -------------------------------- ### Install @eidentic/skills Source: https://github.com/eidentic/eidentic/blob/main/packages/skills/README.md Install the package using pnpm. ```bash pnpm add @eidentic/skills ``` -------------------------------- ### Install PostgreSQL Adapter and pg Source: https://github.com/eidentic/eidentic/blob/main/packages/postgres/README.md Install the @eidentic/postgres package and the 'pg' library using pnpm. ```bash pnpm add @eidentic/postgres pg ``` -------------------------------- ### Run Sleep-Time Consolidation Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:consolidation' example to test background distillation of episodes into durable facts, grounded and without invention. ```bash pnpm -C examples hello:consolidation ``` -------------------------------- ### Install @eidentic/bench Source: https://github.com/eidentic/eidentic/blob/main/packages/bench/README.md Install the benchmark package using pnpm. ```bash pnpm add @eidentic/bench ``` -------------------------------- ### Install @eidentic/workflow Source: https://github.com/eidentic/eidentic/blob/main/packages/workflow/README.md Install the workflow package using pnpm. ```bash pnpm add @eidentic/workflow ``` -------------------------------- ### Install @eidentic/server Source: https://github.com/eidentic/eidentic/blob/main/packages/server/README.md Install the @eidentic/server package using pnpm. ```bash pnpm add @eidentic/server ``` -------------------------------- ### Run Temporal Knowledge Graph Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:graph' example to test the temporal knowledge graph, which stores facts with validity over time and handles contradictions. ```bash pnpm -C examples hello:graph ``` -------------------------------- ### Install @eidentic/better-auth and better-auth Source: https://github.com/eidentic/eidentic/blob/main/packages/better-auth/README.md Install the necessary packages for the better-auth session adapter. ```bash pnpm add @eidentic/better-auth better-auth ``` -------------------------------- ### Run Executable Skills Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:executable-skill' example to test gated executable skills, allowed tools, ed25519 signing, and quarantine mechanisms. ```bash pnpm -C examples hello:executable-skill ``` -------------------------------- ### Install @eidentic/tools Source: https://github.com/eidentic/eidentic/blob/main/packages/tools/README.md Install the @eidentic/tools package using pnpm. ```bash pnpm add @eidentic/tools ``` -------------------------------- ### Run Durable Execution Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:durable' example to test checkpoint/resume functionality and exactly-once tool dispatch that survives crashes. ```bash pnpm -C examples hello:durable ``` -------------------------------- ### Run Skill Self-Evolution Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:skill-evolution' example to test a skill improving its own playbook, using unit tests as the reflection signal (off by default). ```bash pnpm -C examples hello:skill-evolution ``` -------------------------------- ### Install @eidentic/convex Source: https://github.com/eidentic/eidentic/blob/main/packages/convex/README.md Install the Eidentic Convex adapter and its peer dependency Convex. ```bash npm i @eidentic/convex convex ``` -------------------------------- ### Install Qdrant Adapter Source: https://github.com/eidentic/eidentic/blob/main/packages/qdrant/README.md Install the Qdrant vector store adapter for Eidentic using pnpm. ```bash pnpm add @eidentic/qdrant ``` -------------------------------- ### Run Multi-Agent Delegation Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:multi-agent' example to test agent delegation using 'spawn_agent' with context isolation and a shared tree budget. ```bash pnpm -C examples hello:multi-agent ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/eidentic/eidentic/blob/main/CONTRIBUTING.md Installs dependencies, compiles native addons, builds all packages, runs the full test suite, and typechecks every package. ```bash pnpm install # installs deps and compiles native addons pnpm -r build # build all packages (emits dist/) npx vitest run # run the full test suite pnpm -r typecheck # typecheck every package ``` -------------------------------- ### Run Hosted Embedder Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:hosted-embedding' example to test using hosted embeddings with your own API key across any AI SDK provider. ```bash pnpm -C examples hello:hosted-embedding ``` -------------------------------- ### Run Agent-to-Agent (A2A) Protocol Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:a2a' example to test the Agent-to-Agent protocol for exposing and consuming remote agents. ```bash pnpm -C examples hello:a2a ``` -------------------------------- ### Install @eidentic/sqlite Source: https://github.com/eidentic/eidentic/blob/main/packages/sqlite/README.md Install the SQLite store adapter package using pnpm. ```bash pnpm add @eidentic/sqlite ``` -------------------------------- ### Run Cancellation Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:cancellation' example to test cooperative aborts, resulting in an 'aborted' status, checkpointing, and child teardown. ```bash pnpm -C examples hello:cancellation ``` -------------------------------- ### Install HuggingFace Hub Library Source: https://github.com/eidentic/eidentic/blob/main/packages/bench/BASELINES.md Installs the necessary Python library for interacting with the HuggingFace Hub. ```bash pip install huggingface_hub ``` -------------------------------- ### Run Memory Maintenance Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:memory-maintenance' example to test fact staleness, archival deduplication/merging, and single-flight consolidation. ```bash pnpm -C examples hello:memory-maintenance ``` -------------------------------- ### Run Right to Erasure (GDPR) Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:erasure' example to test the hard deletion of all data associated with a scope across stores, vectors, and graphs. ```bash pnpm -C examples hello:erasure ``` -------------------------------- ### Install @eidentic/studio with pnpm Source: https://github.com/eidentic/eidentic/blob/main/packages/studio/README.md Install the studio package using pnpm. This command adds the necessary dependencies to your project. ```bash pnpm add @eidentic/studio ``` -------------------------------- ### Run Passive Extraction and Scopes Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:memory-completion' example to test auto fact extraction without an LLM and organization/shared memory scopes. ```bash pnpm -C examples hello:memory-completion ``` -------------------------------- ### Run Self-Editing Memory Blocks Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:self-editing' example to test the agent's ability to edit its own always-in-context memory during reasoning. ```bash pnpm -C examples hello:self-editing ``` -------------------------------- ### Install pgvector Adapter Source: https://github.com/eidentic/eidentic/blob/main/packages/pgvector/README.md Install the pgvector adapter for Eidentic. Choose between a standard PostgreSQL setup or an in-process PGlite setup. ```bash pnpm add @eidentic/pgvector pg # or with pglite (in-process, no server needed): pnpm add @eidentic/pgvector @electric-sql/pglite ``` -------------------------------- ### Quickstart Eidentic Agent Source: https://github.com/eidentic/eidentic/blob/main/packages/umbrella/README.md Initialize an Eidentic agent with a model and a durable store, then query it for information. This example uses the Anthropic Claude Sonnet model and a local SQLite store. ```typescript import { Agent, AIModel, SqliteStore } from "eidentic"; import { anthropic } from "@ai-sdk/anthropic"; const agent = new Agent({ id: "support", model: new AIModel(anthropic("claude-sonnet-4-5")), store: new SqliteStore("./eidentic.sqlite"), }); for await (const ev of agent.query("What did we decide last week?", { sessionId: "u-42" })) { if (ev.type === "stream.delta") process.stdout.write(ev.delta.text); if (ev.type === "result") console.log("\nDone:", ev.subtype); } ``` -------------------------------- ### Run Built-in Tools Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:tools' example to test the agent's built-in tools, including file, bash, and web tools with security guards. ```bash pnpm -C examples hello:tools ``` -------------------------------- ### Standalone Node.js Eidentic Server Source: https://github.com/eidentic/eidentic/blob/main/docs/DEPLOYMENT.md Sets up a standalone Eidentic agent server using `@eidentic/server`. This example configures an agent with a specific model and store, sets up API key authentication, and starts the server on a specified port. ```typescript // server.ts import { Agent, AIModel, SqliteStore } from "eidentic"; import { createServer, serveNode, ApiKeyAuth } from "@eidentic/server"; import { anthropic } from "@ai-sdk/anthropic"; const store = new SqliteStore("./eidentic.sqlite"); const agent = new Agent({ id: "support", model: new AIModel(anthropic("claude-sonnet-4-5")), store, instructions: "You are a helpful support assistant.", }); const app = createServer({ agents: { support: agent }, auth: ApiKeyAuth({ [process.env.API_KEY!]: { userId: "service" } }), }); await serveNode(app, { port: Number(process.env.PORT ?? 3000) }); console.log(`Listening on :${process.env.PORT ?? 3000}`); ``` -------------------------------- ### Quick Start: Registering and Deploying Prompts Source: https://github.com/eidentic/eidentic/blob/main/packages/prompts/README.md Demonstrates registering new prompt versions, deploying a version as 'stable', and retrieving the stable prompt. Identical prompt bodies are de-duplicated. ```typescript import { createPromptRegistry, filePromptStore, renderPrompt } from "@eidentic/prompts"; const registry = createPromptRegistry(filePromptStore("./data/prompts.json")); // Register versions (identical body = no-op) const v1 = await registry.register("support-agent-system", "You are a helpful assistant."); const v2 = await registry.register("support-agent-system", "You are a concise, helpful assistant."); // Deploy v2 as stable await registry.tag("support-agent-system", 2, "stable"); // Resolve the stable prompt per request const prompt = await registry.get("support-agent-system", "stable"); ``` -------------------------------- ### Integrate and Serve Studio with Custom Agents Source: https://github.com/eidentic/eidentic/blob/main/packages/studio/README.md Integrate the Eidentic Studio with your custom agents and serve it on a specified port. This TypeScript example shows how to create a studio instance, associate it with agents, and start the development server. Authentication is optional and can be configured separately. ```typescript import { createStudio, serveNode } from "@eidentic/studio"; const studio = createStudio({ agents: { support: myAgent }, // auth: ApiKeyAuth({ "dev-key": { userId: "dev" } }), // optional }); await serveNode(studio, { port: 4000 }); // Open http://localhost:4000 in your browser ``` -------------------------------- ### Install @eidentic/core Package Source: https://github.com/eidentic/eidentic/blob/main/packages/core/README.md Install the core Eidentic package using pnpm. Ensure you have the 'ai' peer dependency installed. ```bash pnpm add @eidentic/core ``` -------------------------------- ### Run Lazy Tool Discovery Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:lazy-tools' example to test lazy tool discovery using 'search_tools' and 'load_tool' for smaller manifests with large toolsets. ```bash pnpm -C examples hello:lazy-tools ``` -------------------------------- ### Install @eidentic/langfuse Source: https://github.com/eidentic/eidentic/blob/main/packages/langfuse/README.md Install the package using npm. ```bash npm install @eidentic/langfuse ``` -------------------------------- ### Run Stateful ReAct Agent Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello' example to test the core Stateful ReAct agent, which uses a reason → tool → observe loop. ```bash pnpm -C examples hello ``` -------------------------------- ### Install @eidentic/types Source: https://github.com/eidentic/eidentic/blob/main/packages/types/README.md Install the @eidentic/types package using pnpm. ```bash pnpm add @eidentic/types ``` -------------------------------- ### Run Remote Vector Stores Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:remote-vector' example to test adapters for remote vector stores like pgvector, Qdrant, and Pinecone, including in-memory fakes. ```bash pnpm -C examples hello:remote-vector ``` -------------------------------- ### Run Real Model Agent Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:real' example to test the agent against a real AI provider using AI SDK v6. Requires an API key. ```bash pnpm -C examples hello:real ``` -------------------------------- ### Install @eidentic/mcp Source: https://github.com/eidentic/eidentic/blob/main/packages/mcp/README.md Install the MCP package using pnpm. ```bash pnpm add @eidentic/mcp ``` -------------------------------- ### Install @eidentic/eval Package Source: https://github.com/eidentic/eidentic/blob/main/packages/eval/README.md Install the @eidentic/eval package using pnpm. ```bash pnpm add @eidentic/eval ``` -------------------------------- ### Install @eidentic/a2a Package Source: https://github.com/eidentic/eidentic/blob/main/packages/a2a/README.md Install the A2A package using pnpm. ```bash pnpm add @eidentic/a2a ``` -------------------------------- ### Install RAG Package Source: https://github.com/eidentic/eidentic/blob/main/packages/rag/README.md Install the core @eidentic/rag package using pnpm. ```bash pnpm add @eidentic/rag ``` -------------------------------- ### Run Embedded Usage Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:embedded' example to test dropping the agent into a plain Node.js HTTP server without requiring a dedicated server package. ```bash pnpm -C examples hello:embedded ``` -------------------------------- ### Install @eidentic/cli Source: https://github.com/eidentic/eidentic/blob/main/packages/cli/README.md Install the eidentic command-line tool globally using npm. ```bash npm install -g @eidentic/cli # or use via the umbrella (eidentic ships the CLI) npm install eidentic ``` -------------------------------- ### Initialize LibsqlStore and Agent Source: https://github.com/eidentic/eidentic/blob/main/packages/libsql/README.md Demonstrates initializing the LibsqlStore for both local file-based and remote Turso connections, and then creating an Eidentic Agent with it. Ensure necessary environment variables are set for Turso. ```typescript import { LibsqlStore } from "@eidentic/libsql"; import { Agent, AIModel } from "eidentic"; import { anthropic } from "@ai-sdk/anthropic"; // Local file (development) const store = new LibsqlStore("file:eidentic.db"); // Turso remote (production) const store = new LibsqlStore({ url: process.env.LIBSQL_URL!, authToken: process.env.LIBSQL_AUTH_TOKEN, }); const agent = new Agent({ id: "support", model: new AIModel(anthropic("claude-sonnet-4-5")), store, }); for await (const ev of agent.query("Hello", { sessionId: "s-1" })) { if (ev.type === "stream.delta") process.stdout.write(ev.delta.text); } ``` -------------------------------- ### Run Lexical Recall and Memory Blocks Example Source: https://github.com/eidentic/eidentic/blob/main/docs/TESTING.md Execute the 'hello:memory' example to test lexical recall and always-in-context memory blocks, which require no external infrastructure. ```bash pnpm -C examples hello:memory ``` -------------------------------- ### Install better-sqlite3 Peer Dependency Source: https://github.com/eidentic/eidentic/blob/main/packages/sqlite/README.md Install the better-sqlite3 peer dependency separately as required by the adapter. ```bash pnpm add better-sqlite3 ``` -------------------------------- ### Run End-to-End Demo Source: https://github.com/eidentic/eidentic/blob/main/CONTRIBUTING.md Executes the end-to-end 'hello' demo, which uses a scripted mock model and does not require an API key. ```bash pnpm --filter eidentic-examples hello ```