Sign In

@codmir/agent

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@codmir/agent

Core agent logic for Codmir - reusable in IDE (local) and cloud (remote) modes

npmnpm
Version
0.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@codmir/agent

Core agent logic for Codmir - reusable in IDE (local) and cloud (remote) modes.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        @codmir/agent                             │
│                                                                  │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────┐   │
│  │   Session    │  │    Tools     │  │     AI Client        │   │
│  │   Manager    │  │   Executor   │  │   (Streaming)        │   │
│  └──────────────┘  └──────────────┘  └──────────────────────┘   │
│                                                                  │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────┐   │
│  │   Context    │  │    Tool      │  │     Approval         │   │
│  │   Provider   │  │  Definitions │  │     Handler          │   │
│  └──────────────┘  └──────────────┘  └──────────────────────┘   │
└─────────────────────────────────────────────────────────────────┘
                              │
              ┌───────────────┼───────────────┐
              ▼               ▼               ▼
        ┌──────────┐   ┌──────────┐   ┌──────────────┐
        │   IDE    │   │  Cloud   │   │   Claude     │
        │  (local) │   │ (remote) │   │   Code API   │
        └──────────┘   └──────────┘   └──────────────┘

Modes

Local Mode (IDE)

  • Session runs on user's machine
  • Connection active while IDE is open
  • Session ends when IDE closes
  • Faster response (no network latency for tools)

Cloud Mode (Remote)

  • Session runs on Codmir servers
  • User can close IDE, session persists
  • Session continues in background
  • Results synced when user reconnects

Usage

In IDE (Local Mode)

import { createAgent, LocalSessionManager } from '@codmir/agent';
import { FileSystemAdapter } from './adapters/filesystem';

const agent = createAgent({
  mode: 'local',
  sessionManager: new LocalSessionManager(),
  contextProvider: new FileSystemAdapter(workspaceRoot),
  aiConfig: {
    provider: 'codmir', // or 'openai', 'anthropic'
    apiKey: process.env.CODMIR_API_KEY,
  },
});

// Start a session
const session = await agent.createSession({
  prompt: 'Fix the bug in auth.ts',
});

// Listen to events
agent.on('thinking', (data) => updateUI('thinking', data));
agent.on('tool_call', (data) => showToolCall(data));
agent.on('response_chunk', (data) => appendToChat(data));
agent.on('complete', (data) => finalizeResponse(data));

// Approve tool calls
await agent.approveToolCall(session.id, toolCallId);

In Cloud (Remote Mode)

import { createAgent, CloudSessionManager } from '@codmir/agent';
import { RemoteFileAdapter } from './adapters/remote';

const agent = createAgent({
  mode: 'cloud',
  sessionManager: new CloudSessionManager({
    redis: redisClient,
    persistSessions: true,
  }),
  contextProvider: new RemoteFileAdapter(ideConnection),
  aiConfig: {
    provider: 'codmir',
    apiKey: process.env.CODMIR_API_KEY,
  },
});

// Session persists even if client disconnects
const session = await agent.resumeSession(sessionId);

Tools

Built-in tools available to the agent:

ToolDescription
read_fileRead file contents
write_fileWrite/create file
edit_fileApply targeted edits
list_directoryList files in directory
search_filesSearch for text in files
run_commandExecute terminal command
git_statusGet git status
git_diffGet git diff
ask_userAsk user a question

Custom Tools

import { defineTool } from '@codmir/agent/tools';

const myTool = defineTool({
  name: 'my_custom_tool',
  description: 'Does something custom',
  parameters: z.object({
    input: z.string(),
  }),
  execute: async (params, context) => {
    // Your logic here
    return { result: 'done' };
  },
});

agent.registerTool(myTool);

Session Lifecycle

User Input
    │
    ▼
┌─────────────────┐
│ Create Session  │ ◄─── New conversation
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│   AI Thinking   │ ◄─── Streaming response
└────────┬────────┘
         │
         ▼
┌─────────────────┐     ┌─────────────────┐
│   Tool Call?    │────►│ Execute Tool    │
└────────┬────────┘     └────────┬────────┘
         │                       │
         │◄──────────────────────┘
         ▼
┌─────────────────┐
│    Response     │ ◄─── Final answer
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Session Active  │ ◄─── Ready for next message
└─────────────────┘
         │
    Local: closes with IDE
    Cloud: persists until timeout

Events

EventDescription
session_createdNew session started
thinking_startedAI is processing
response_chunkStreaming text chunk
tool_call_createdAI wants to use a tool
tool_call_approvedUser approved tool
tool_call_rejectedUser rejected tool
tool_call_startedTool execution began
tool_call_completedTool finished successfully
tool_call_failedTool execution failed
response_completeFull response ready
session_errorError occurred
session_endedSession terminated

FAQs

Package last updated on 31 Jan 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