ENTERPRISE DEVELOPER DOCUMENTATION

Moven AI Technical Specification & Manual

Complete architectural deep-dive, mathematical trip formulas, multi-agent context propagation, database schemas, and provider proxy specifications.

1. Automated CLI Quickstart (`npx moven-ai-cli`)

Zero-config agent discovery, setup, and key pairing.

Run npx moven-ai-cli init in your project repository root. Moven automatically inspects `package.json` dependencies, parses your source files for model declarations, prompts for your **Production Agent Name** and **Moven Project Name**, and pairs authentication via browser pairing link.

$ npx -y moven-ai-cli@latest init
What the Installer Executes:
  • Detects installed agent frameworks (LangGraph, LlamaIndex, Vercel AI SDK, CrewAI, AutoGen).
  • Scans local code files for model strings (`gpt-4o`, `claude-3-5-sonnet`, `gemini-1.5-pro`).
  • Launches browser magic URL (`https://moven.dev/auth/cli-login?token=...`).
  • Generates type-safe moven.config.ts configuration file.
  • Appends authenticated MOVEN_API_KEY into local `.env`.

2. Deep Fuse Engine Architecture Specification

Sub-millisecond in-memory tool wrapping, thread safety & distributed event pipeline.

The Moven Fuse Engine operates as an in-process interceptor around native AI agent tool execution functions. Designed for high-concurrency enterprise workloads (100,000+ operations/sec), it guarantees zero blocking latency (<0.8ms evaluation overhead) by conducting deterministic state evaluations in-memory prior to passing control to the underlying tool runtime.

Detailed Execution Lifecycle & State PipelineEvaluation Overhead <0.8ms
Step 1: Interception
wrapTools() Trap
Captures tool name, input payload, timestamp, and active stack trace.
Step 2: Canonical Hash
SHA-256 Hash Delta
Deterministically sorts object keys to prevent false payload mismatch.
Step 3: Heuristics
4 Rules Evaluated
Runs 60s sliding window repeat, cost headroom, depth & hash stagnation.
Step 4: Recovery
Fallback or Kill
Routes to cheaper model, dispatches webhooks, or throws MovenKillError.
1. In-Memory Run Container

Instantiates a lightweight MovenRunState instance storing ring-buffered tool call logs. Automatically cleans up expired state objects after 1 hour to prevent memory bloat.

2. Thread-Safe Hash Ring

Utilizes O(1) hash map indexing for rapid sliding-window repeat call calculations across concurrent asynchronous tool execution threads.

3. Async Telemetry Stream

Telemetry events (spans, kill alerts, money saved metrics) are dispatched non-blockingly in background batches to /api/events with automatic retry backoff.

3. Mathematical Trip Heuristics & Formulas

Exact mathematical equations evaluating tool executions in real-time.

Rule 1: Sliding-Window Repeat Equation

Given tool calls T = {t_1, t_2, ..., t_n}, evaluate timestamp window Δt = t_now - t_i <= 60000ms:

Count = sum(1 for t in recentCalls where SHA256(t.args) == SHA256(current.args))
If Count >= maxRepeatCalls (default 5) -> TRIP FUSE
Rule 2: Intelligent Cost Headroom Equation

Calculates cumulative dollar expenditure and evaluates progress uniqueness across state hashes:

IsProgress = unique_count(recent_state_hashes[-3:]) == 3
EffectiveCap = IsProgress ? (maxCostDollar * 1.25) : maxCostDollar
If cumulativeCost >= EffectiveCap -> TRIP FUSE
Rule 3: Money Saved Math Formula

Estimates prevented token cost burn when a runaway agent is intercepted early:

PreventedSteps = max(15 - executedToolCount, 5)
PreventedTokens = PreventedSteps * 4,000 tokens
MoneySaved = max(((PreventedTokens / 1,000,000) * $2.50) - actualRunCost, $0.50)

4. Adaptive Recovery Lifecycle Specifications

Dynamic model downgrading and automatic primary model restoration.

Upon detecting a soft hallucination warning or repeat pattern, Moven routes subsequent LLM calls to a cheaper fallback model (e.g. `openai/gpt-4o-mini` or `google/gemini-2.5-flash-lite`). The run state monitors execution: once the agent completes 3 consecutive clean turns, Moven automatically restores execution to the primary model.

5. Multi-Agent DAG Context Propagation

Tracking recursive parent-child sub-agent trees across AsyncLocalStorage.

In multi-agent architectures (`LangGraph` state graphs, `CrewAI` manager/worker teams, `AutoGen` chat groups), sub-agents spawn nested sub-threads. Moven uses Node.js AsyncLocalStorage to propagate parent `traceId` and execution depth levels implicitly across sub-agent calls.

6. 20+ Enterprise AI Provider Proxy Specs

Universal Time-Travel Replay endpoint at `/api/replay` supporting all major models.

OpenAI Anthropic Google Gemini Groq Mistral AI OpenRouter Together AI Fireworks AI DeepInfra Cerebras SambaNova NVIDIA NIM Ollama vLLM LM Studio Azure OpenAI AWS Bedrock Replicate Custom Proxy

8. Webhook Ingestion & Slack Alerts

Instant HTTP POST alert dispatches when a fuse trips.

When a fuse trips, /api/events dispatches real HTTP POST payloads to configured Slack channels and custom HTTP webhooks containing offending tool parameters, exact reasons, and money saved estimates.

9. moven.config.ts Parameter Reference

Exhaustive specification for all MovenCircuitBreaker options.

ParameterTypeDefaultDescription & Trip Mechanics
agentIdstring"agent_run"Unique deterministic slug for tracing multi-agent execution sub-trees.
agentNamestring"default-agent"Human-readable agent identifier shown in terminal banners & cloud telemetry.
maxRepeatCallsnumber5Trips when tool calls with identical SHA-256 argument hashes occur N times within repeatTimeWindowMs.
repeatTimeWindowMsnumbernumberSliding time window duration in milliseconds for repeat tool call evaluation.
maxCostDollarnumber$2.00Dollar spending ceiling. Grants 25% cost headroom buffer if active non-repetitive state progress is detected.
maxDepthnumber15Maximum allowed recursion depth for sub-agent call chains before tripping depth_ceiling.
maxNoProgressTurnsnumber3Trips when N consecutive tool execution turns produce 100% identical output state hashes.
cheaperModelstring"openai/gpt-4o-mini"Target model ID dynamically resolved per model author/provider during hallucination alerts.
onHallucinationfunctionundefinedCallback receiving { agentName, reason, toolName, args } when fuse intercepts a run.
import { createMovenCircuitBreaker } from 'moven-sdk';

export const movenCircuitBreaker = createMovenCircuitBreaker({
  agentId: 'agent_inventory_production_agent',
  agentName: 'inventory_production_agent',
  framework: 'LangGraph / LangChain',
  
  maxRepeatCalls: 3,
  repeatTimeWindowMs: 60000,
  maxCostDollar: 2.00,
  maxDepth: 15,
  maxNoProgressTurns: 3,

  provider: 'openrouter',
  currentModel: 'openai/gpt-4o-mini',
  cheaperModel: 'openai/gpt-5.6-luna-pro',
  autoFallbackCheaperModel: true,
  enableLlmJudgeArbitrator: true,

  onHallucination: ({ agentName, reason, toolName }) => {
    console.warn(`[Moven Alert] Agent '${agentName}' hallucinated on tool '${toolName}': ${reason}`);
  },

  apiKey: process.env.MOVEN_API_KEY,
});

10. Production Troubleshooting & FAQs

Common enterprise integration scenarios and resolutions.

Q: What happens if the Moven cloud telemetry API is unreachable?

Moven operates in standalone mode. All local circuit breaker rules continue evaluating in-memory and throwing `MovenKillError` cleanly without crashing the agent execution thread.

Q: How does Moven handle tools with non-JSON return values?

Moven serializes all tool input arguments using deterministic canonical stringifiers (`JSON.stringify` with sorted keys) to guarantee exact hash equality regardless of object key order.