Skip to content

AI Backend Architecture

Sciorex uses a 100% local architecture with no backend servers. All AI processing happens directly on your machine through CLI tools for multiple providers. This document explains the architecture, supported features, and why this approach was chosen.

Why Local-Only?

Sciorex deliberately avoids any intermediate servers between you and the AI providers:

Privacy & Security

  • Your code never leaves your machine except to go directly to the AI provider's API
  • No third-party servers storing or processing your conversations
  • Credentials stay on your device - managed by each provider's CLI
  • Complete control over what data is shared
  • Local model support - run completely offline with LM Studio or Ollama

Performance

  • Zero latency overhead from proxy servers
  • Direct streaming from provider to your UI
  • No network hops that could fail or slow down responses

Reliability

  • No dependency on external infrastructure beyond the AI provider APIs
  • Offline-capable session management - your history is stored locally
  • No account required with Sciorex - just configure your provider

Supported AI Providers

Sciorex supports multiple AI providers through their CLI tools:

ProviderCLI ToolTypeStatus
Claude CodeclaudeCloud✅ Supported
Google GeminigeminiCloud✅ Supported
OpenAI CodexcodexCloud✅ Supported
LM StudioLocal ServerLocal✅ Supported
OllamaollamaLocal✅ Supported

How It Works

Sciorex spawns the provider CLI as a child process and communicates via:

  • stdin - Send prompts and messages
  • stdout - Receive streaming JSON responses
  • Environment variables - Pass configuration
┌─────────────────┐      stdin       ┌──────────────────┐      HTTPS      ┌─────────────┐
│    Sciorex      │ ───────────────► │   Provider CLI   │ ─────────────► │  Provider   │
│   (Electron)    │ ◄─────────────── │    (Process)     │ ◄───────────── │    API      │
└─────────────────┘     stdout       └──────────────────┘                └─────────────┘

For local providers (LM Studio, Ollama), the connection is to a local server instead:

┌─────────────────┐                  ┌──────────────────┐
│    Sciorex      │ ◄──────────────► │   Local Server   │
│   (Electron)    │   HTTP API       │ (LM Studio/Ollama)│
└─────────────────┘                  └──────────────────┘

Prerequisites

Each provider has its own requirements. See Settings → AI Providers in the app for detailed setup instructions.

ProviderRequirement
Claude CodeCLI installed and authenticated
Google GeminiCLI installed and authenticated
OpenAI CodexCLI installed and authenticated
LM StudioServer running on configured port
OllamaServer running (ollama serve)

Supported Claude Code Features

Sciorex leverages most Claude Code CLI capabilities. Here's what's supported:

✅ Fully Supported

Core Features

FeatureCLI FlagDescription
Streaming JSON output--output-format stream-jsonReal-time event streaming
Print mode--printNon-interactive execution
Verbose output--verboseRequired for stream-json
Model selection--modelChoose Claude model
System prompts--system-promptAgent system prompts
Append system prompt--append-system-promptAdd to default prompt
MCP configuration--mcp-configConfigure MCP servers
Working directory--cwdSet execution context

Session Management

FeatureCLI FlagDescription
Session resume--resumeContinue previous session
Session forking--fork-sessionBranch from any message

Permission Control

FeatureCLI FlagDescription
Skip all permissions--dangerously-skip-permissionsYOLO mode
Accept edits mode--permission-mode acceptEditsAuto-approve file ops
Default mode--permission-mode defaultAsk for all tools
Permission prompt tool--permission-prompt-toolMCP-based permissions
Allowed tools filter-toolsRestrict tool access

Extended Thinking

FeatureEnvironment VariableDescription
Thinking budgetMAX_THINKING_TOKENSToken limit for thinking

Thinking levels map to token budgets:

LevelEnvironment Value
OffNot set
Think1024
Think Hard10,000
Think Harder16,000
Ultrathink32,000

Configurable Budgets

You can customize these token budgets in Settings → Thinking Budgets.

❌ Not Supported

The following Claude Code CLI features are not currently used:

FeatureReason
--max-tokensAPI-only parameter, not supported by CLI
--temperatureAPI-only parameter, not supported by CLI
Interactive modeUI handles interaction, CLI runs in print mode
claude chatOnly structured --print mode used

MCP Server Integration

Sciorex uses the Model Context Protocol (MCP) to extend Claude's capabilities:

Built-in MCP Servers

ServerPurposeAuto-Started
sciorex-ticketsTicket and epic managementWhen tools selected
sciorex-interactionsAsk user questionsWhen tools selected
sciorex-resourcesAgent and flow CRUD operationsWhen tools selected
sciorex-permissionsPermission promptsWhen MCP permissions enabled

How MCP Servers Are Configured

MCP servers are passed to Claude Code via the --mcp-config flag:

json
{
  "mcpServers": {
    "sciorex-tickets": {
      "command": "node",
      "args": ["/path/to/server.js", "--workspace", "/project/path"]
    }
  }
}

Custom MCP Servers

Custom MCP servers are automatically discovered from your Claude Code configuration and appear in the tool selector.

See MCP Servers Documentation for details on available tools.


Permission System

Sciorex supports two permission handling approaches:

Reactive Permissions (Default)

When Claude attempts a tool that requires permission:

  1. CLI emits permission_denied event
  2. Sciorex shows permission modal
  3. User approves/denies
  4. Session resumes with -tools for approved tools

Proactive Permissions (MCP-based)

When "Use MCP Permissions" is enabled:

  1. sciorex-permissions MCP server is started
  2. CLI uses --permission-prompt-tool mcp__sciorex-permissions__approval_prompt
  3. Permission requests go through MCP bridge
  4. Sciorex shows permission modal
  5. Response sent back through MCP

Permission Modes

ModeCLI ConfigurationBehavior
YOLO--dangerously-skip-permissionsNo prompts
Auto-edits--permission-mode acceptEditsAuto-approve file ops
Ask all--permission-mode defaultPrompt for everything

Process Management

Lifecycle

Each chat or agent session spawns a new Claude Code process:

Session Start → Spawn CLI → Send Prompt → Stream Output → Process Exit

Concurrent Execution

Sciorex limits concurrent processes (default: 3) to prevent resource exhaustion.

Process Control

ActionImplementation
PauseSIGSTOP signal
ResumeSIGCONT signal
CancelSIGKILL + cleanup
TimeoutAuto-kill after default timeout (5 minutes)

Session Continuation

When you send a follow-up message to a completed session:

  1. Previous Claude session ID is retrieved
  2. New CLI spawned with --resume [session-id]
  3. --fork-session creates new ID for branching support
  4. Conversation continues from previous state

Output Parsing

Claude Code CLI outputs streaming JSON events that Sciorex parses:

Event Types

EventDescription
session_initSession started, contains session ID and tools
textClaude's text output
tool_startTool execution begin
tool_endTool execution result
thinkingExtended thinking content
subagent_spawnSubagent (Task) started
subagent_resultSubagent completed
resultFinal result with usage summary
errorError occurred
permission_deniedTool permission denied
system_statusSystem messages (compacting, etc.)

Structured Output Extraction

For agents with output schemas, Sciorex extracts structured JSON from:

  • result event data
  • Markers in text output (OUTPUT_START / OUTPUT_END)

Configuration

CLI Path

Configure the Claude Code executable path in Settings → API → Claude CLI Path.

Default: claude (assumes it's in your PATH)

Working Directory

Each session uses your current workspace as the working directory (--cwd).

Environment Variables

Sciorex sets these environment variables for each session:

VariableDescription
SCIOREX_SESSION_IDSciorex session identifier
SCIOREX_AGENT_IDAgent identifier (if applicable)
MAX_THINKING_TOKENSExtended thinking budget

Error Handling

CLI Not Found

If Claude Code isn't installed or not in PATH:

  • Error message displayed
  • Sessions cannot start
  • Configure path in Settings

Rate Limits

Claude API rate limits are detected and displayed:

  • "5-hour limit reached" messages
  • Rate limit errors

Process Failures

Non-zero exit codes result in:

  • failed session status
  • Error message from stderr
  • Automatic cleanup

Timeouts

Sessions automatically terminate after the default timeout (5 minutes) to prevent resource leaks.


Troubleshooting

Claude Code Not Detected

Symptoms: Error message about CLI not found.

Solutions:

  1. Install Claude Code: npm install -g @anthropic-ai/claude-code
  2. Verify installation: claude --version
  3. Configure custom path in Settings if not in PATH

No Response from Claude

Symptoms: Session starts but nothing happens.

Solutions:

  1. Check Claude Code is authenticated: claude auth status
  2. Verify API key is valid
  3. Check network connectivity

Permission Errors

Symptoms: Tools fail with permission errors.

Solutions:

  1. Switch to a less restrictive permission mode
  2. Approve tools when prompted
  3. Use YOLO mode for trusted operations

Memory Issues

Symptoms: High memory usage, slowdowns.

Solutions:

  1. Reduce concurrent session limit
  2. Close unused sessions
  3. Restart the application

Provider-Specific Features

Claude Code

Claude Code CLI provides the most complete feature set:

  • Full tool execution - Built-in tool implementations
  • Context management - Session state handling
  • Workspace awareness - File system understanding
  • Permission system - Granular tool control
  • Extended thinking - All thinking levels supported

Google Gemini

Gemini CLI provides:

  • Large context windows - Up to 1M tokens
  • Fast responses - Optimized for speed
  • Tool execution - Function calling support
  • Extended thinking - Think and Think Hard levels

OpenAI Codex

Codex CLI provides:

  • Code optimization - Specialized for code tasks
  • Large context - Up to 400K tokens
  • Tool execution - Function calling support
  • OSS mode - Run local GPT-OSS models

Local Providers

LM Studio and Ollama provide:

  • Complete privacy - No data leaves your machine
  • Offline capability - Work without internet
  • Model flexibility - Choose any compatible model
  • No API costs - Run unlimited queries

Related Documentation

Released under the MIT License.