├── src ├── core │ ├── logger │ │ ├── index.d.ts │ │ └── index.ts │ ├── brain │ │ ├── llm │ │ │ ├── messages │ │ │ │ ├── index.ts │ │ │ │ ├── history │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ ├── __test__ │ │ │ │ │ │ ├── types.test.ts │ │ │ │ │ │ ├── utils.ts │ │ │ │ │ │ ├── wal.test.ts │ │ │ │ │ │ ├── multi-backend.test.ts │ │ │ │ │ │ └── factory.test.ts │ │ │ │ │ ├── factory.ts │ │ │ │ │ ├── wal.ts │ │ │ │ │ └── multi-backend.ts │ │ │ │ ├── formatters │ │ │ │ │ ├── index.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── utils.ts │ │ │ │ ├── types.ts │ │ │ │ └── factory.ts │ │ │ ├── index.ts │ │ │ ├── errors.ts │ │ │ ├── services │ │ │ │ ├── index.ts │ │ │ │ ├── types.ts │ │ │ │ └── __test__ │ │ │ │ │ └── azure.test.ts │ │ │ ├── compression │ │ │ │ ├── index.ts │ │ │ │ └── types.ts │ │ │ └── tokenizer │ │ │ │ ├── index.ts │ │ │ │ ├── types.ts │ │ │ │ └── factory.ts │ │ ├── index.ts │ │ ├── memAgent │ │ │ ├── index.ts │ │ │ └── loader.ts │ │ ├── reasoning │ │ │ └── index.ts │ │ ├── tools │ │ │ ├── definitions │ │ │ │ ├── system │ │ │ │ │ └── index.ts │ │ │ │ ├── web-search │ │ │ │ │ ├── config.ts │ │ │ │ │ ├── constants.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── factory.ts │ │ │ │ └── knowledge_graph │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── get-neighbors.ts │ │ │ │ │ └── delete-node.ts │ │ │ └── index.ts │ │ ├── systemPrompt │ │ │ ├── providers │ │ │ │ ├── index.ts │ │ │ │ ├── base-provider.ts │ │ │ │ └── static-provider.ts │ │ │ ├── index.ts │ │ │ └── __test__ │ │ │ │ └── interfaces.test.ts │ │ ├── memory │ │ │ └── index.ts │ │ └── embedding │ │ │ ├── backend │ │ │ └── index.ts │ │ │ ├── types.ts │ │ │ └── index.ts │ ├── utils │ │ ├── index.ts │ │ └── path.ts │ ├── mcp │ │ └── index.ts │ ├── session │ │ └── index.ts │ ├── knowledge_graph │ │ ├── index.ts │ │ └── types.ts │ ├── index.ts │ ├── events │ │ ├── index.ts │ │ └── __tests__ │ │ │ └── env-variables.test.ts │ ├── vector_storage │ │ ├── backend │ │ │ └── index.ts │ │ ├── types.ts │ │ └── index.ts │ └── storage │ │ ├── backend │ │ └── index.ts │ │ ├── types.ts │ │ ├── index.ts │ │ ├── memory-history │ │ └── index.ts │ │ └── constants.ts ├── app │ ├── ui │ │ ├── src │ │ │ ├── types │ │ │ │ ├── index.ts │ │ │ │ ├── search.ts │ │ │ │ ├── api.ts │ │ │ │ └── websocket.ts │ │ │ ├── stores │ │ │ │ └── index.ts │ │ │ ├── hooks │ │ │ │ └── index.ts │ │ │ ├── contexts │ │ │ │ └── index.ts │ │ │ ├── components │ │ │ │ ├── modals │ │ │ │ │ └── index.ts │ │ │ │ ├── ui │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── scroll-area.tsx │ │ │ │ │ ├── separator.tsx │ │ │ │ │ ├── label.tsx │ │ │ │ │ ├── textarea.tsx │ │ │ │ │ ├── input.tsx │ │ │ │ │ ├── checkbox.tsx │ │ │ │ │ ├── switch.tsx │ │ │ │ │ ├── badge.tsx │ │ │ │ │ ├── popover.tsx │ │ │ │ │ ├── avatar.tsx │ │ │ │ │ ├── tooltip.tsx │ │ │ │ │ ├── alert.tsx │ │ │ │ │ ├── button.tsx │ │ │ │ │ ├── card.tsx │ │ │ │ │ └── dropdown-menu.tsx │ │ │ │ ├── sliding-panel.tsx │ │ │ │ ├── index.ts │ │ │ │ ├── error-notification.tsx │ │ │ │ ├── quick-action-card.tsx │ │ │ │ ├── welcome-screen.tsx │ │ │ │ ├── thinking-indicator.tsx │ │ │ │ ├── header.tsx │ │ │ │ ├── action-bar.tsx │ │ │ │ ├── navigation.tsx │ │ │ │ └── providers │ │ │ │ │ └── query-provider.tsx │ │ │ ├── app │ │ │ │ ├── loading.tsx │ │ │ │ ├── layout.tsx │ │ │ │ ├── error.tsx │ │ │ │ └── globals.css │ │ │ └── lib │ │ │ │ └── utils.ts │ │ ├── public │ │ │ ├── favicon.png │ │ │ └── cipher-logo.png │ │ ├── postcss.config.mjs │ │ ├── .eslintrc.js │ │ ├── components.json │ │ ├── .gitignore │ │ ├── tsconfig.json │ │ ├── package.json │ │ ├── next.config.ts │ │ └── tailwind.config.js │ ├── cli │ │ ├── commands.ts │ │ └── utils │ │ │ └── options.ts │ └── api │ │ ├── websocket │ │ └── index.ts │ │ ├── utils │ │ ├── mcp-endpoint.ts │ │ └── security.ts │ │ └── middleware │ │ └── logging.ts └── index.ts ├── matrix ├── .gitignore ├── src │ └── matrix.gleam ├── test │ └── matrix_test.gleam ├── .github │ └── workflows │ │ └── test.yml ├── README.md ├── gleam.toml └── manifest.toml ├── assets ├── cipher-logo.png ├── cipher_webUI.png ├── demo_claude_code.png ├── cipher_store_memory.png └── cipher_retrieve_memory.png ├── .github ├── copilot-instructions.md ├── workflows │ ├── publish-docker.yml │ ├── publish.yml │ └── ci.yml └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── .prettierrc ├── .prettierignore ├── tsconfig.typecheck.json ├── vitest.config.ts ├── memAgent ├── project-guidelines.md └── cipher-advanced-prompt.yml ├── tsconfig.json ├── tsup.config.ts ├── docker-compose.yml ├── examples ├── 05-workspace-memory-team-progress │ └── mcp.example.json ├── 03-strict-memory-layer │ ├── cipher.yml │ └── README.md ├── 04-mcp-aggregator-hub │ └── cipher.yml └── 02-cli-coding-agents │ └── README.md ├── .dockerignore ├── smithery.yaml ├── .gitignore ├── CHANGELOG.md ├── Dockerfile └── docs └── builtin-tools.md /src/core/logger/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './logger'; 2 | -------------------------------------------------------------------------------- /src/core/logger/index.ts: -------------------------------------------------------------------------------- 1 | export * from './logger.js'; 2 | -------------------------------------------------------------------------------- /matrix/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.ez 3 | /build 4 | erl_crash.dump 5 | -------------------------------------------------------------------------------- /src/app/ui/src/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './server-registry'; 2 | -------------------------------------------------------------------------------- /assets/cipher-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campfirein/cipher/HEAD/assets/cipher-logo.png -------------------------------------------------------------------------------- /assets/cipher_webUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campfirein/cipher/HEAD/assets/cipher_webUI.png -------------------------------------------------------------------------------- /src/core/brain/llm/messages/index.ts: -------------------------------------------------------------------------------- 1 | export * from './manager.js'; 2 | export * from './types.js'; 3 | -------------------------------------------------------------------------------- /src/core/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './path.js'; 2 | export * from './service-initializer.js'; 3 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | // Main entry point for @byterover/cipher package 2 | export * from './core/index.js'; 3 | -------------------------------------------------------------------------------- /assets/demo_claude_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campfirein/cipher/HEAD/assets/demo_claude_code.png -------------------------------------------------------------------------------- /assets/cipher_store_memory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campfirein/cipher/HEAD/assets/cipher_store_memory.png -------------------------------------------------------------------------------- /src/app/ui/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campfirein/cipher/HEAD/src/app/ui/public/favicon.png -------------------------------------------------------------------------------- /src/app/ui/src/stores/index.ts: -------------------------------------------------------------------------------- 1 | // Re-export all stores for easy importing 2 | export * from './session-store'; 3 | -------------------------------------------------------------------------------- /assets/cipher_retrieve_memory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campfirein/cipher/HEAD/assets/cipher_retrieve_memory.png -------------------------------------------------------------------------------- /matrix/src/matrix.gleam: -------------------------------------------------------------------------------- 1 | import gleam/io 2 | 3 | pub fn main() -> Nil { 4 | io.println("Hello from matrix!") 5 | } 6 | -------------------------------------------------------------------------------- /src/app/ui/public/cipher-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campfirein/cipher/HEAD/src/app/ui/public/cipher-logo.png -------------------------------------------------------------------------------- /src/core/mcp/index.ts: -------------------------------------------------------------------------------- 1 | export * from './client.js'; 2 | export * from './manager.js'; 3 | export * from './constants.js'; 4 | -------------------------------------------------------------------------------- /src/core/brain/index.ts: -------------------------------------------------------------------------------- 1 | export * from './memAgent/index.js'; 2 | export * from './llm/index.js'; 3 | export * from './reasoning/index.js'; 4 | -------------------------------------------------------------------------------- /src/core/brain/llm/messages/history/index.ts: -------------------------------------------------------------------------------- 1 | export * from './types.js'; 2 | export * from './database.js'; 3 | export * from './factory.js'; 4 | -------------------------------------------------------------------------------- /src/app/ui/src/hooks/index.ts: -------------------------------------------------------------------------------- 1 | export { useServerRegistry } from './use-server-registry'; 2 | export { useChat } from './use-chat'; 3 | export * from './use-sessions'; 4 | -------------------------------------------------------------------------------- /src/app/ui/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | const config = { 2 | plugins: { 3 | "@tailwindcss/postcss": {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /src/app/ui/src/contexts/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | ChatProvider, 3 | useChatContext, 4 | useChatSession, 5 | useChatMessages, 6 | useChatStatus, 7 | } from './chat-context'; 8 | -------------------------------------------------------------------------------- /src/core/brain/llm/index.ts: -------------------------------------------------------------------------------- 1 | export * from './messages/index.js'; 2 | export * from './services/index.js'; 3 | export * from './config.js'; 4 | export * from './errors.js'; 5 | -------------------------------------------------------------------------------- /src/core/session/index.ts: -------------------------------------------------------------------------------- 1 | export { ConversationSession } from './coversation-session.js'; 2 | export { SessionManager } from './session-manager.js'; 3 | export type { SessionMetadata } from './session-manager.js'; 4 | -------------------------------------------------------------------------------- /src/core/brain/memAgent/index.ts: -------------------------------------------------------------------------------- 1 | export { MemAgent } from './agent.js'; 2 | export { AgentConfig, AgentConfigSchema } from './config.js'; 3 | export { ConversationSession, SessionManager } from '../../session/index.js'; 4 | -------------------------------------------------------------------------------- /src/app/ui/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** @type {import("eslint").Linter.Config} */ 2 | module.exports = { 3 | extends: ["next/core-web-vitals"], 4 | parser: "@typescript-eslint/parser", 5 | parserOptions: { 6 | project: true, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /src/app/ui/src/components/modals/index.ts: -------------------------------------------------------------------------------- 1 | export { AddCustomServerModal } from './add-custom-server-modal'; 2 | export { ConnectServerModal } from './connect-server-modal'; 3 | export { GlobalSearchModal } from './global-search-modal'; 4 | -------------------------------------------------------------------------------- /src/core/brain/llm/errors.ts: -------------------------------------------------------------------------------- 1 | export class CantInferProviderError extends Error { 2 | constructor(model: string) { 3 | super(`Unrecognized model '${model}'. Could not infer provider.`); 4 | this.name = 'CantInferProviderError'; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.github/copilot-instructions.md: -------------------------------------------------------------------------------- 1 | [byterover-mcp] 2 | 3 | # important 4 | always use byterover-retrive-knowledge tool to get the related context before any tasks 5 | always use byterover-store-knowledge to store all the critical informations after sucessful tasks -------------------------------------------------------------------------------- /src/core/brain/llm/services/index.ts: -------------------------------------------------------------------------------- 1 | export * from './types.js'; 2 | export * from './openrouter.js'; 3 | export * from './ollama.js'; 4 | export * from './lmstudio.js'; 5 | export * from './aws.js'; 6 | export * from './azure.js'; 7 | export * from './deepseek.js'; 8 | -------------------------------------------------------------------------------- /matrix/test/matrix_test.gleam: -------------------------------------------------------------------------------- 1 | import gleeunit 2 | 3 | pub fn main() -> Nil { 4 | gleeunit.main() 5 | } 6 | 7 | // gleeunit test functions end in `_test` 8 | pub fn hello_world_test() { 9 | let name = "Joe" 10 | let greeting = "Hello, " <> name <> "!" 11 | 12 | assert greeting == "Hello, Joe!" 13 | } 14 | -------------------------------------------------------------------------------- /src/core/knowledge_graph/index.ts: -------------------------------------------------------------------------------- 1 | export * from './types.js'; 2 | export * from './config.js'; 3 | export * from './constants.js'; 4 | export * from './factory.js'; 5 | export * from './manager.js'; 6 | export * from './backend/knowledge-graph.js'; 7 | export * from './backend/neo4j.js'; 8 | export * from './backend/in-memory.js'; 9 | export * from './backend/types.js'; 10 | -------------------------------------------------------------------------------- /src/core/brain/llm/compression/index.ts: -------------------------------------------------------------------------------- 1 | // Compression module exports 2 | export * from './types.js'; 3 | export * from './factory.js'; 4 | export * from './utils.js'; 5 | 6 | // Strategy exports 7 | export { MiddleRemovalStrategy } from './strategies/middle-removal.js'; 8 | export { OldestRemovalStrategy } from './strategies/oldest-removal.js'; 9 | export { HybridStrategy } from './strategies/hybrid.js'; 10 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "tabWidth": 2, 4 | "useTabs": true, 5 | "semi": true, 6 | "singleQuote": true, 7 | "quoteProps": "as-needed", 8 | "jsxSingleQuote": true, 9 | "trailingComma": "es5", 10 | "bracketSpacing": true, 11 | "bracketSameLine": false, 12 | "arrowParens": "avoid", 13 | "endOfLine": "lf", 14 | "embeddedLanguageFormatting": "auto", 15 | "singleAttributePerLine": false 16 | } 17 | -------------------------------------------------------------------------------- /src/app/ui/src/app/loading.tsx: -------------------------------------------------------------------------------- 1 | export default function Loading() { 2 | return ( 3 |
4 |
5 |
6 |

Loading Cipher UI...

7 |
8 |
9 | ) 10 | } -------------------------------------------------------------------------------- /src/core/brain/llm/messages/history/types.ts: -------------------------------------------------------------------------------- 1 | // Conversation history provider interface for persistent storage 2 | import type { InternalMessage } from '../types.js'; 3 | 4 | export interface IConversationHistoryProvider { 5 | getHistory(sessionId: string, limit?: number): Promise; 6 | saveMessage(sessionId: string, message: InternalMessage): Promise; 7 | clearHistory(sessionId: string): Promise; 8 | } 9 | -------------------------------------------------------------------------------- /src/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './logger/index.js'; 2 | export * from './mcp/index.js'; 3 | export * from './brain/index.js'; 4 | export * from './utils/index.js'; 5 | export * from './env.js'; 6 | 7 | // Storage modules with namespace disambiguation 8 | export * as Storage from './storage/index.js'; 9 | export * as VectorStorage from './vector_storage/index.js'; 10 | export * as KnowledgeGraph from './knowledge_graph/index.js'; 11 | -------------------------------------------------------------------------------- /src/app/cli/commands.ts: -------------------------------------------------------------------------------- 1 | import { MemAgent } from '@core/index.js'; 2 | import { commandParser } from './parser.js'; 3 | 4 | /** 5 | * Cipher slash command execution 6 | * This function integrates with the command parser to handle slash commands 7 | */ 8 | export async function executeCommand( 9 | command: string, 10 | args: string[], 11 | agent: MemAgent 12 | ): Promise { 13 | return await commandParser.executeCommand(command, args, agent); 14 | } 15 | -------------------------------------------------------------------------------- /src/core/brain/llm/messages/formatters/index.ts: -------------------------------------------------------------------------------- 1 | // Message formatters for different LLM providers 2 | // OpenAI-compatible providers: OpenAI, OpenRouter, Ollama, LM Studio, Qwen, Gemini 3 | export { OpenAIMessageFormatter } from './openai.js'; 4 | export { AnthropicMessageFormatter } from './anthropic.js'; 5 | export { AzureMessageFormatter } from './azure.js'; 6 | export { BedrockAnthropicMessageFormatter } from './aws.js'; 7 | export type { IMessageFormatter } from './types.js'; 8 | -------------------------------------------------------------------------------- /src/core/brain/llm/tokenizer/index.ts: -------------------------------------------------------------------------------- 1 | // Tokenizer module exports 2 | export * from './types.js'; 3 | export * from './factory.js'; 4 | export * from './utils.js'; 5 | export * from './cache.js'; 6 | 7 | // Provider exports 8 | export { OpenAITokenizer } from './providers/openai.js'; 9 | export { AnthropicTokenizer } from './providers/anthropic.js'; 10 | export { GoogleTokenizer } from './providers/google.js'; 11 | export { DefaultTokenizer } from './providers/default.js'; 12 | -------------------------------------------------------------------------------- /src/core/brain/reasoning/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Reasoning Services 3 | * 4 | * Content-based reasoning detection and search context management 5 | * for reflection memory tools activation. 6 | */ 7 | 8 | export { 9 | ReasoningContentDetector, 10 | ReasoningDetectionResult, 11 | ReasoningDetectionOptions, 12 | } from './content-detector.js'; 13 | export { 14 | SearchContextManager, 15 | SearchResult, 16 | SortedContext, 17 | SearchContextOptions, 18 | } from './search-context-manager.js'; 19 | -------------------------------------------------------------------------------- /src/app/api/websocket/index.ts: -------------------------------------------------------------------------------- 1 | export { WebSocketConnectionManager } from './connection-manager.js'; 2 | export { WebSocketMessageRouter } from './message-router.js'; 3 | export { WebSocketEventSubscriber } from './event-subscriber.js'; 4 | export * from './types.js'; 5 | 6 | // Convenience re-exports 7 | export type { 8 | WebSocketMessage, 9 | WebSocketResponse, 10 | WebSocketConnection, 11 | WebSocketConnectionStats, 12 | WebSocketConfig, 13 | WebSocketEventType, 14 | WebSocketEventData, 15 | } from './types.js'; 16 | -------------------------------------------------------------------------------- /src/core/brain/tools/definitions/system/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * System Tools Module 3 | * 4 | * Provides system-level operations including bash command execution, 5 | * file operations, and system information gathering. 6 | */ 7 | 8 | import type { InternalToolSet } from '../../types.js'; 9 | import { bashTool } from './bash.js'; 10 | 11 | /** 12 | * Get all system tools 13 | */ 14 | export function getSystemTools(): InternalToolSet { 15 | return { 16 | [bashTool.name]: bashTool, 17 | }; 18 | } 19 | 20 | export { bashTool }; 21 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules/ 3 | pnpm-lock.yaml 4 | package-lock.json 5 | yarn.lock 6 | 7 | # Build outputs 8 | dist/ 9 | build/ 10 | coverage/ 11 | 12 | # Logs 13 | *.log 14 | logs/ 15 | 16 | # Environment files 17 | .env 18 | .env.local 19 | .env.*.local 20 | 21 | # IDE files 22 | .vscode/ 23 | .idea/ 24 | 25 | # OS files 26 | .DS_Store 27 | Thumbs.db 28 | 29 | # Generated files 30 | *.generated.* 31 | *.min.js 32 | *.min.css 33 | 34 | # Documentation that should preserve formatting 35 | CHANGELOG.md 36 | LICENSE -------------------------------------------------------------------------------- /src/core/brain/systemPrompt/providers/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Provider exports 3 | * 4 | * Central export file for all prompt provider implementations. 5 | */ 6 | 7 | export { BasePromptProvider } from './base-provider.js'; 8 | export { StaticPromptProvider, type StaticProviderConfig } from './static-provider.js'; 9 | export { 10 | DynamicPromptProvider, 11 | type DynamicProviderConfig, 12 | type DynamicContentGenerator, 13 | } from './dynamic-provider.js'; 14 | export { FilePromptProvider, type FileProviderConfig } from './file-provider.js'; 15 | -------------------------------------------------------------------------------- /src/app/ui/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "app/globals.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils", 16 | "ui": "@/components/ui", 17 | "lib": "@/lib", 18 | "hooks": "@/hooks" 19 | }, 20 | "iconLibrary": "lucide" 21 | } -------------------------------------------------------------------------------- /src/app/ui/src/components/ui/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alert'; 2 | export * from './badge'; 3 | export * from './button'; 4 | export * from './card'; 5 | export * from './checkbox'; 6 | export * from './dialog'; 7 | export * from './dropdown-menu'; 8 | export * from './input'; 9 | export * from './key-value-editor'; 10 | export * from './label'; 11 | export * from './popover'; 12 | export * from './scroll-area'; 13 | export * from './select'; 14 | export * from './separator'; 15 | export * from './switch'; 16 | export * from './textarea'; 17 | export * from './tooltip'; 18 | -------------------------------------------------------------------------------- /src/app/ui/src/components/ui/scroll-area.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | export type ScrollAreaProps = React.HTMLAttributes 6 | 7 | const ScrollArea = React.forwardRef( 8 | ({ className, children, ...props }, ref) => ( 9 |
14 | {children} 15 |
16 | ) 17 | ) 18 | ScrollArea.displayName = "ScrollArea" 19 | 20 | export { ScrollArea } -------------------------------------------------------------------------------- /tsconfig.typecheck.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "strict": true, 6 | "noUncheckedIndexedAccess": true, 7 | "noImplicitReturns": true, 8 | "noFallthroughCasesInSwitch": true, 9 | "noImplicitOverride": true, 10 | "exactOptionalPropertyTypes": true, 11 | "skipLibCheck": true 12 | }, 13 | "include": ["src/core/**/*", "src/app/**/*"], 14 | "exclude": [ 15 | "node_modules", 16 | "dist", 17 | "**/*.d.ts", 18 | "**/__test__/**", 19 | "**/__tests__/**", 20 | "src/app/ui/**/*" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /matrix/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | pull_request: 9 | 10 | jobs: 11 | test: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: erlef/setup-beam@v1 16 | with: 17 | otp-version: "27.1.2" 18 | gleam-version: "1.11.1" 19 | rebar3-version: "3" 20 | # elixir-version: "1" 21 | - run: gleam deps download 22 | - run: gleam test 23 | - run: gleam format --check src test 24 | -------------------------------------------------------------------------------- /src/app/ui/src/lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { type ClassValue, clsx } from 'clsx'; 2 | import { twMerge } from 'tailwind-merge'; 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)); 6 | } 7 | 8 | export function formatTimestamp(timestamp: number): string { 9 | return new Date(timestamp).toLocaleTimeString(); 10 | } 11 | 12 | export function generateId(): string { 13 | return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); 14 | } 15 | 16 | // Re-export chat utilities 17 | export * from './chat-utils'; 18 | -------------------------------------------------------------------------------- /matrix/README.md: -------------------------------------------------------------------------------- 1 | # matrix 2 | 3 | [![Package Version](https://img.shields.io/hexpm/v/matrix)](https://hex.pm/packages/matrix) 4 | [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/matrix/) 5 | 6 | ```sh 7 | gleam add matrix@1 8 | ``` 9 | ```gleam 10 | import matrix 11 | 12 | pub fn main() -> Nil { 13 | // TODO: An example of the project in use 14 | } 15 | ``` 16 | 17 | Further documentation can be found at . 18 | 19 | ## Development 20 | 21 | ```sh 22 | gleam run # Run the project 23 | gleam test # Run the tests 24 | ``` 25 | -------------------------------------------------------------------------------- /matrix/gleam.toml: -------------------------------------------------------------------------------- 1 | name = "matrix" 2 | version = "1.0.0" 3 | 4 | # Fill out these fields if you intend to generate HTML documentation or publish 5 | # your project to the Hex package manager. 6 | # 7 | # description = "" 8 | # licences = ["Apache-2.0"] 9 | # repository = { type = "github", user = "", repo = "" } 10 | # links = [{ title = "Website", href = "" }] 11 | # 12 | # For a full reference of all the available options, you can have a look at 13 | # https://gleam.run/writing-gleam/gleam-toml/. 14 | 15 | [dependencies] 16 | gleam_stdlib = ">= 0.44.0 and < 2.0.0" 17 | 18 | [dev-dependencies] 19 | gleeunit = ">= 1.0.0 and < 2.0.0" 20 | -------------------------------------------------------------------------------- /src/core/brain/llm/messages/history/__test__/types.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest'; 2 | import type { IConversationHistoryProvider } from '../types.js'; 3 | 4 | describe('IConversationHistoryProvider interface', () => { 5 | it('should define required methods', () => { 6 | const provider: IConversationHistoryProvider = { 7 | getHistory: async () => [], 8 | saveMessage: async () => {}, 9 | clearHistory: async () => {}, 10 | }; 11 | expect(typeof provider.getHistory).toBe('function'); 12 | expect(typeof provider.saveMessage).toBe('function'); 13 | expect(typeof provider.clearHistory).toBe('function'); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/app/ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .pnpm-debug.log* 32 | 33 | # env files (can opt-in for committing if needed) 34 | .env* 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | -------------------------------------------------------------------------------- /matrix/manifest.toml: -------------------------------------------------------------------------------- 1 | # This file was generated by Gleam 2 | # You typically do not need to edit this file 3 | 4 | packages = [ 5 | { name = "gleam_stdlib", version = "0.62.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "0080706D3A5A9A36C40C68481D1D231D243AF602E6D2A2BE67BA8F8F4DFF45EC" }, 6 | { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, 7 | ] 8 | 9 | [requirements] 10 | gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 11 | gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 12 | -------------------------------------------------------------------------------- /src/app/ui/src/components/ui/separator.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | export interface SeparatorProps extends React.HTMLAttributes { 6 | orientation?: "horizontal" | "vertical" 7 | } 8 | 9 | const Separator = React.forwardRef( 10 | ({ className, orientation = "horizontal", ...props }, ref) => ( 11 |
20 | ) 21 | ) 22 | Separator.displayName = "Separator" 23 | 24 | export { Separator } -------------------------------------------------------------------------------- /src/app/ui/src/components/sliding-panel.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import { cn } from "@/lib/utils" 5 | import { SlidingPanelProps } from "@/types/chat" 6 | 7 | export function SlidingPanel({ 8 | isOpen, 9 | width = "w-80", 10 | children, 11 | side = "right" 12 | }: SlidingPanelProps) { 13 | return ( 14 |
19 | {isOpen && ( 20 |
21 | {children} 22 |
23 | )} 24 |
25 | ); 26 | } -------------------------------------------------------------------------------- /src/app/ui/src/components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import * as LabelPrimitive from "@radix-ui/react-label" 3 | 4 | import { cn } from "@/lib/utils" 5 | 6 | const Label = React.forwardRef< 7 | React.ElementRef, 8 | React.ComponentPropsWithoutRef 9 | >(({ className, ...props }, ref) => ( 10 | 19 | )) 20 | Label.displayName = LabelPrimitive.Root.displayName 21 | 22 | export { Label } -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config'; 2 | import path from 'path'; 3 | 4 | export default defineConfig({ 5 | resolve: { 6 | alias: { 7 | '@core': path.resolve(__dirname, 'src/core'), 8 | '@app': path.resolve(__dirname, 'src/app'), 9 | }, 10 | }, 11 | test: { 12 | globals: true, 13 | environment: 'node', 14 | include: process.env.INTEGRATION_TESTS_ONLY 15 | ? ['src/**/*integration*.test.ts'] 16 | : ['src/**/*.test.ts', 'src/**/*.spec.ts'], 17 | exclude: [ 18 | '**/node_modules/**', 19 | '**/dist/**', 20 | '**/build/**', 21 | ...(process.env.CI ? ['**/integration/**'] : []), 22 | ...(process.env.INTEGRATION_TESTS_ONLY ? [] : ['**/*integration*.test.ts']), 23 | ], 24 | watch: true, 25 | }, 26 | }); 27 | -------------------------------------------------------------------------------- /src/core/brain/llm/messages/utils.ts: -------------------------------------------------------------------------------- 1 | import { logger } from '../../../logger/index.js'; 2 | 3 | export function getImageData(imagePart: { 4 | image: string | Uint8Array | Buffer | ArrayBuffer | URL; 5 | }): string { 6 | const { image } = imagePart; 7 | if (typeof image === 'string') { 8 | return image; 9 | } else if (image instanceof Buffer) { 10 | return image.toString('base64'); 11 | } else if (image instanceof Uint8Array) { 12 | return Buffer.from(image).toString('base64'); 13 | } else if (image instanceof ArrayBuffer) { 14 | return Buffer.from(new Uint8Array(image)).toString('base64'); 15 | } else if (image instanceof URL) { 16 | return image.toString(); 17 | } 18 | logger.warn('Unexpected image data type in getImageData', { image }); 19 | return ''; 20 | } 21 | -------------------------------------------------------------------------------- /src/core/events/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Event System - Main Export 3 | * 4 | * Central export point for the two-tier event system infrastructure. 5 | */ 6 | 7 | // Core event system components 8 | export * from './typed-event-emitter.js'; 9 | export * from './service-event-bus.js'; 10 | export * from './session-event-bus.js'; 11 | export * from './event-manager.js'; 12 | export * from './event-types.js'; 13 | 14 | // Advanced features 15 | export * from './filtering.js'; 16 | export * from './persistence.js'; 17 | export * from './metrics.js'; 18 | export * from './webhooks.js'; 19 | export * from './replay.js'; 20 | 21 | // Vector store integration 22 | export { EventAwareVectorStore } from '../vector_storage/event-aware-store.js'; 23 | export { EventFilter } from './event-types.js'; 24 | -------------------------------------------------------------------------------- /src/app/ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ES2017", 5 | "lib": ["dom", "dom.iterable", "esnext"], 6 | "allowJs": true, 7 | "skipLibCheck": true, 8 | "strict": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "bundler", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "plugins": [ 18 | { 19 | "name": "next" 20 | } 21 | ], 22 | "paths": { 23 | "@/*": ["./src/*"], 24 | "@core/*": ["../../core/*"] 25 | } 26 | }, 27 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 28 | "exclude": ["node_modules"] 29 | } 30 | -------------------------------------------------------------------------------- /src/core/brain/systemPrompt/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * System Prompt Architecture - Main Exports 3 | * 4 | * This module provides a complete plugin-based system prompt management solution 5 | * with backward compatibility for existing code. 6 | */ 7 | 8 | // Core interfaces and types 9 | export * from './interfaces.js'; 10 | 11 | // Provider implementations 12 | export * from './providers/index.js'; 13 | 14 | // Registry and configuration 15 | export { providerRegistry, DefaultProviderRegistry } from './registry.js'; 16 | export { SystemPromptConfigManager } from './config-manager.js'; 17 | export * from './config-schemas.js'; 18 | 19 | // Built-in generators 20 | export * from './built-in-generators.js'; 21 | 22 | // Enhanced manager 23 | export { EnhancedPromptManager } from './enhanced-manager.js'; 24 | -------------------------------------------------------------------------------- /src/core/brain/systemPrompt/__test__/interfaces.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests for System Prompt Architecture Interfaces 3 | */ 4 | 5 | import { describe, it, expect } from 'vitest'; 6 | import { ProviderType } from '../interfaces.js'; 7 | 8 | describe('System Prompt Interfaces', () => { 9 | describe('ProviderType', () => { 10 | it('should have correct enum values', () => { 11 | expect(ProviderType.STATIC).toBe('static'); 12 | expect(ProviderType.DYNAMIC).toBe('dynamic'); 13 | expect(ProviderType.FILE_BASED).toBe('file-based'); 14 | }); 15 | 16 | it('should have all expected types', () => { 17 | const types = Object.values(ProviderType); 18 | expect(types).toHaveLength(3); 19 | expect(types).toContain('static'); 20 | expect(types).toContain('dynamic'); 21 | expect(types).toContain('file-based'); 22 | }); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /src/core/vector_storage/backend/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Vector Storage Backend Exports 3 | * 4 | * Central export point for all backend types, interfaces, and implementations. 5 | * This module provides a clean API for accessing backend functionality. 6 | * 7 | * @module vector_storage/backend 8 | */ 9 | 10 | // Export core types and interfaces 11 | export type { VectorStore, VectorStoreResult, SearchFilters } from './types.js'; 12 | 13 | // Export error classes 14 | export { 15 | VectorStoreError, 16 | VectorStoreConnectionError, 17 | VectorDimensionError, 18 | CollectionNotFoundError, 19 | } from './types.js'; 20 | 21 | // Export backend implementations 22 | // Note: Implementations are lazily loaded by the manager to reduce startup time 23 | // export { QdrantBackend } from './qdrant.js'; 24 | // export { InMemoryBackend } from './in-memory.js'; 25 | -------------------------------------------------------------------------------- /src/app/ui/src/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | export type TextareaProps = React.TextareaHTMLAttributes 6 | 7 | const Textarea = React.forwardRef( 8 | ({ className, ...props }, ref) => { 9 | return ( 10 |