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

localbot

v1.0.1

Published

LocalBot is an open-source AI agent framework that runs locally on your device, prioritizing data privacy and offering a wide range of skills.

Readme

LocalBot JavaScript 实现

LocalBot 是一个开源的 AI 智能体框架,可在您的设备上本地运行,优先考虑数据隐私并提供广泛的技能支持。

English | 简体中文

功能特性

  • 本地化运行: 在本地机器上运行,无需依赖云服务
  • 技能系统: 可扩展的技能框架,支持各种任务
  • 双内存系统: 使用 Markdown 存储的短期和长期记忆
  • 多种界面: 包含命令行界面和 Web 界面
  • 网关系统: 处理与外部系统的通信
  • 多模型支持: 支持阿里云、OpenAI、Anthropic、Google 等 16+ 种 AI 提供商
  • 技能配置: 类似 MCP 的技能配置系统,每个技能可独立配置
  • 热重载: 技能支持热重载,无需重启即可更新

安装

前提条件

  • Node.js (v14 或更高版本)
  • npm

安装步骤

  1. 克隆仓库

    git clone <repository-url>
    cd localbot-js
  2. 安装依赖

    npm install
  3. 启动 LocalBot

    npm start

项目结构

localbot-js/
├── src/
│   ├── ai/             # AI 提供商管理
│   ├── core/           # 核心运行时和网关
│   ├── skills/         # 技能系统和技能管理
│   ├── memory/         # 记忆系统
│   ├── interface/      # 用户界面
│   ├── config/         # 配置管理
│   ├── task/           # 任务处理(分析、分解、递归处理)
│   ├── web/            # Web 服务器
│   └── utils/          # 工具函数
├── skills/             # 本地技能目录
├── memory/             # 长期记忆存储
├── config.json         # 配置文件
├── package.json        # 项目配置
├── README.md           # 英文文档
├── README.zh-CN.md     # 中文文档
└── USAGE.md            # 使用指南

核心组件

  1. LocalBot: 主运行时类
  2. Gateway: 处理与外部系统的通信
  3. SkillManager: 管理技能加载和热重载
  4. MemoryManager: 管理短期和长期记忆
  5. InterfaceManager: 管理用户界面
  6. ConfigManager: 管理配置持久化
  7. AIProviderManager: 管理多个 AI 提供商
  8. TaskAnalyzer: 分析任务复杂度
  9. TaskDecomposer: 分解复杂任务
  10. RecursiveProcessor: 递归处理子任务

支持的 AI 提供商

  • OpenAI - GPT-4, GPT-3.5
  • Anthropic - Claude 系列
  • Google - Gemini 系列
  • 阿里云 - 通义千问系列
  • Azure OpenAI - Azure 托管的 OpenAI 模型
  • Cohere - Command 系列
  • Mistral AI - Mistral 系列
  • 深度求索 - DeepSeek 系列
  • Groq - Llama 系列高速推理
  • Together AI - 开源模型聚合
  • OpenRouter - 多模型路由
  • 百度文心一言
  • 智谱 AI - ChatGLM 系列
  • 月之暗面 - Kimi 系列
  • 字节豆包
  • Ollama - 本地模型支持

内置技能

基础技能

  • HelloSkill: 响应问候语
  • TimeSkill: 告诉当前时间
  • WeatherSkill: 提供天气信息
  • LocationSkill: 提供位置信息

文件与代码

  • FileManager: 文件读写、目录管理
  • CodeInterpreter: 代码执行与解释
  • Git: Git 操作支持
  • TerminalPro: 终端命令执行

内容处理

  • Search: 多搜索引擎集成(百度、Bing、Google、知乎等)
  • Summarize: 文本摘要
  • Markdown: Markdown 格式处理

服装相关

  • ClothingAnalysisSkill: 服装分析
  • ClothingRecommendationSkill: 服装推荐

技能配置系统

每个技能都可以定义自己的配置 Schema,类似 MCP(Model Context Protocol):

class MySkill extends Skill {
  getConfigSchema() {
    return {
      apiKey: {
        type: 'string',
        title: 'API Key',
        description: '服务的 API 密钥',
        default: '',
        required: true,
        secret: true  // 敏感信息,不在界面显示
      },
      timeout: {
        type: 'number',
        title: '超时时间 (ms)',
        description: '请求超时时间',
        default: 30000,
        required: false,
        min: 1000,
        max: 120000
      },
      engine: {
        type: 'enum',
        title: '搜索引擎',
        description: '选择默认搜索引擎',
        default: 'baidu',
        options: [
          { value: 'baidu', label: '百度' },
          { value: 'google', label: 'Google' }
        ]
      }
    };
  }
}

配置 API

| 方法 | 路径 | 说明 | |------|------|------| | GET | /api/skills | 获取所有技能列表 | | GET | /api/skills/:name | 获取单个技能详情 | | GET | /api/skills/:name/schema | 获取技能配置 Schema | | GET | /api/skills/:name/config | 获取技能配置 | | PUT | /api/skills/:name/config | 更新技能配置 | | PATCH | /api/skills/:name/config/:key | 更新单个配置项 | | DELETE | /api/skills/:name/config | 重置技能配置 |

配置说明

LocalBot 使用 .env 文件进行配置。config.json 文件用于存储技能配置和运行时数据。

.env 文件配置

  1. 基于 .env.example 模板创建 .env 文件
  2. 使用您的配置更新环境变量
# 复制示例文件
cp .env.example .env

# 编辑 .env 文件

API 密钥配置

配置您要使用的 AI 提供商的 API 密钥:

# 阿里云
ALIYUN_API_KEY=your-aliyun-api-key

# OpenAI
OPENAI_API_KEY=your-openai-api-key

# Anthropic
ANTHROPIC_API_KEY=your-anthropic-api-key

# 其他提供商...

可选配置

# 记忆配置
MEMORY_COMPACTION_THRESHOLD=100

# 界面配置
COMMAND_LINE_ENABLED=true

# 网关配置
GATEWAY_PORT=3000

# Web 服务器配置
WEB_PORT=3000

记忆系统

LocalBot 使用双记忆系统:

  • 短期记忆: 在内存中存储最近的消息
  • 长期记忆: 在 memory 目录中以 Markdown 文件形式存储压缩后的消息

Web 界面

LocalBot 提供 Web 界面进行交互:

  1. 启动后访问 http://localhost:3000
  2. 支持实时对话
  3. 支持历史记录查看和切换
  4. 支持 AI 提供商切换
  5. 支持消息复制功能

添加自定义技能

  1. skills/ 目录下创建新文件夹
  2. 创建 index.js 文件,继承 Skill 基类
  3. 实现 canHandle()handle() 方法
  4. 可选:实现 getConfigSchema() 定义配置

示例:

const Skill = require('../../src/skills/Skill');

class MySkill extends Skill {
  constructor(localbot) {
    super(localbot);
    this.name = 'MySkill';
    this.description = '我的自定义技能';
  }

  async canHandle(message) {
    return message.includes('关键词');
  }

  async handle(message) {
    return '处理结果';
  }
}

module.exports = MySkill;

更多详情请参阅 USAGE.md

贡献

欢迎贡献!请随时提交 Pull Request。

许可证

MIT 许可证