npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@codmir/agent

v0.1.1

Published

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

Readme

@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:

| Tool | Description | |------|-------------| | read_file | Read file contents | | write_file | Write/create file | | edit_file | Apply targeted edits | | list_directory | List files in directory | | search_files | Search for text in files | | run_command | Execute terminal command | | git_status | Get git status | | git_diff | Get git diff | | ask_user | Ask 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

| Event | Description | |-------|-------------| | session_created | New session started | | thinking_started | AI is processing | | response_chunk | Streaming text chunk | | tool_call_created | AI wants to use a tool | | tool_call_approved | User approved tool | | tool_call_rejected | User rejected tool | | tool_call_started | Tool execution began | | tool_call_completed | Tool finished successfully | | tool_call_failed | Tool execution failed | | response_complete | Full response ready | | session_error | Error occurred | | session_ended | Session terminated |