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

@shareai-lab/kode-sdk

v2.7.4

Published

Event-driven, long-running AI Agent development framework with enterprise-grade persistence and context management

Readme

KODE SDK

English | 中文

事件驱动的长时运行 AI Agent 框架,支持企业级持久化和多 Agent 协作。

核心特性

  • 事件驱动架构 - 三通道系统 (Progress/Control/Monitor) 清晰分离关注点
  • 长时运行与恢复 - 七段断点机制,支持 Safe-Fork-Point 崩溃恢复
  • 多 Agent 协作 - AgentPool、Room 消息、任务委派
  • 企业级持久化 - 支持 SQLite/PostgreSQL,统一 WAL 日志
  • 云端沙箱 - 集成 E2B 与 OpenSandbox,提供隔离的远程代码执行环境
  • 可扩展生态 - MCP 工具、自定义 Provider、Skills 系统

快速开始

一键启动(安装依赖并构建):

./quickstart.sh

或作为依赖安装:

npm install @shareai-lab/kode-sdk

设置环境变量:

Linux / macOS

export ANTHROPIC_API_KEY=sk-...
export ANTHROPIC_MODEL_ID=claude-sonnet-4-20250514  # 可选,默认: claude-sonnet-4-20250514
export ANTHROPIC_BASE_URL=https://api.anthropic.com  # 可选,默认: https://api.anthropic.com

Windows (PowerShell)

$env:ANTHROPIC_API_KEY="sk-..."
$env:ANTHROPIC_MODEL_ID="claude-sonnet-4-20250514"  # 可选,默认: claude-sonnet-4-20250514
$env:ANTHROPIC_BASE_URL="https://api.anthropic.com"  # 可选,默认: https://api.anthropic.com

最简示例:

import { Agent, AnthropicProvider, JSONStore } from '@shareai-lab/kode-sdk';

const provider = new AnthropicProvider(
  process.env.ANTHROPIC_API_KEY!,
  process.env.ANTHROPIC_MODEL_ID
);

const agent = await Agent.create({
  provider,
  store: new JSONStore('./.kode'),
  systemPrompt: '你是一个乐于助人的助手。'
});

// 订阅 progress 事件
for await (const envelope of agent.subscribe(['progress'])) {
  if (envelope.event.type === 'text_chunk') {
    process.stdout.write(envelope.event.delta);
  }
  if (envelope.event.type === 'done') break;
}

await agent.send('你好!');

运行示例:

npm run example:getting-started    # 最简对话
npm run example:agent-inbox        # 事件驱动收件箱
npm run example:approval           # 工具审批流程
npm run example:room               # 多Agent协作
npm run example:opensandbox        # OpenSandbox 基础使用

OpenSandbox 快速配置:

export OPEN_SANDBOX_API_KEY=...                      # 可选(仅在服务开启鉴权时需要)
export OPEN_SANDBOX_ENDPOINT=http://127.0.0.1:8080  # 可选
export OPEN_SANDBOX_IMAGE=ubuntu                     # 可选

支持的 Provider

| Provider | 流式输出 | 工具调用 | 推理 | 文件 | |----------|---------|---------|------|------| | Anthropic | ✅ | ✅ | ✅ Extended Thinking | ✅ | | OpenAI | ✅ | ✅ | ✅ | ✅ | | Gemini | ✅ | ✅ | ✅ | ✅ |

说明:OpenAI 兼容的服务(DeepSeek、GLM、Qwen、Minimax、OpenRouter 等)可以通过 OpenAIProvider 配置自定义 baseURL 来使用。详见 Provider 配置指南

文档

| 章节 | 说明 | |------|------| | 入门指南 | | | 安装配置 | 环境配置与安装 | | 快速上手 | 创建第一个 Agent | | 核心概念 | 核心概念详解 | | 使用指南 | | | 事件系统 | 三通道事件系统 | | 工具系统 | 内置工具与自定义工具 | | E2B 沙箱 | E2B 云端沙箱接入 | | OpenSandbox 沙箱 | OpenSandbox 自托管沙箱接入 | | Skills 系统 | Skills 可复用提示词系统 | | Provider 配置 | 模型 Provider 配置 | | 数据库存储 | SQLite/PostgreSQL 持久化 | | 恢复与分叉 | 崩溃恢复与分支 | | 项目 | | | 贡献指南 | 提交 PR 的要求与流程 | | 参考 | | | API 参考 | 完整 API 文档 | | 示例集 | 所有示例详解 |

许可证

MIT