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

sdkwork-browser-agent

v1.0.0

Published

Browser-compatible agent architecture with Skills, MCP, and Tool support

Readme

SDKWork Browser Agent

npm version TypeScript License: MIT

一个浏览器兼容的 Agent 架构,支持 Skills、MCP、Tools 和灵活的 LLM Provider 体系。

英文 | 中文

✨ 特性

  • 🤖 智能决策引擎 - 自动选择最合适的 Skill,基于嵌入相似度匹配
  • 🔄 动态 Skill 加载 - 懒加载机制,支持文件、URL、模块多种来源
  • 💰 Token 优化 - 智能压缩和截断,最小化 Token 消耗
  • 🔌 多 LLM 支持 - OpenAI、Anthropic、Google Gemini 等主流模型
  • 📦 MCP 协议 - 完整的 Model Context Protocol 支持
  • 🔧 插件系统 - 可扩展的插件架构
  • 🌐 浏览器兼容 - 同时支持浏览器和 Node.js 环境
  • 📘 TypeScript - 完整的类型支持

🚀 快速开始

安装

npm install sdkwork-browser-agent
# 或
yarn add sdkwork-browser-agent
# 或
pnpm add sdkwork-browser-agent

基础使用

import { SmartAgent, OpenAIProvider, builtInSkills } from 'sdkwork-browser-agent';

// 创建智能 Agent
const agent = new SmartAgent({
  name: 'my-agent',
  llmProvider: new OpenAIProvider({
    apiKey: process.env.OPENAI_API_KEY,
  }),
  skills: builtInSkills,
  autoDecide: true,
});

// 初始化
await agent.initialize();

// 自动处理输入
const result = await agent.process('计算 2 + 2');
console.log(result.result); // 4

使用不同的 LLM Provider

import { AnthropicProvider, GeminiProvider } from 'sdkwork-browser-agent';

// Anthropic Claude
const claudeAgent = new SmartAgent({
  llmProvider: new AnthropicProvider({
    apiKey: process.env.ANTHROPIC_API_KEY,
  }),
});

// Google Gemini
const geminiAgent = new SmartAgent({
  llmProvider: new GeminiProvider({
    apiKey: process.env.GEMINI_API_KEY,
  }),
});

📚 文档

完整文档请访问:https://sdkwork-browser-agent.vercel.app

🏗️ 架构

sdkwork-browser-agent/
├── src/
│   ├── core/              # Agent 核心
│   │   ├── agent.ts       # 基础 Agent
│   │   ├── smart-agent.ts # 智能 Agent(自动决策)
│   │   ├── decision-engine.ts  # 决策引擎
│   │   ├── skill-loader.ts     # 动态加载
│   │   └── token-optimizer.ts  # Token 优化
│   ├── llm/               # LLM Provider
│   ├── skills/            # Skill 系统
│   ├── tools/             # Tool 系统
│   ├── mcp/               # MCP 协议
│   └── plugins/           # 插件系统

🎯 核心功能

1. 智能决策引擎

自动根据输入选择最合适的 Skill:

const agent = new SmartAgent({
  decisionEngine: {
    enableEmbeddings: true, // 启用嵌入相似度
    enableCaching: true, // 启用决策缓存
    threshold: 0.6, // 相似度阈值
    maxSkills: 3, // 最大选择 Skill 数
  },
});

2. 动态 Skill 加载

支持从多种来源懒加载 Skill:

// 注册 Skill 源
agent.registerSkillSource('my-skill', 'https://example.com/skills/my-skill.json', 'url');

// 动态加载
const skill = await agent.skillLoader.load('my-skill');

3. Token 优化

自动优化 Token 消耗:

const optimizer = new TokenOptimizer({
  enableCompression: true,
  maxSkillDescriptionLength: 200,
  maxContextTokens: 4000,
});

const optimized = optimizer.optimizeSkills(skills);
const stats = optimizer.getOptimizationStats(skills, optimized);
console.log(`节省了 ${stats.savingsPercent}% tokens`);

4. 自定义 Skill

import { Skill } from 'sdkwork-browser-agent';

const mySkill: Skill = {
  name: 'translate',
  description: '将文本翻译为另一种语言',
  parameters: {
    type: 'object',
    properties: {
      text: { type: 'string', description: '要翻译的文本' },
      targetLang: { type: 'string', description: '目标语言' },
    },
    required: ['text', 'targetLang'],
  },
  handler: async params => {
    // 实现翻译逻辑
    return { success: true, data: translatedText };
  },
  metadata: {
    category: 'language',
    tags: ['translate', 'nlp'],
  },
};

agent.registerSkill(mySkill);

🧪 测试

# 运行所有测试
npm test

# 监视模式
npm run test:watch

# 覆盖率报告
npm run test:coverage

🛠️ 开发

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建
npm run build

# 类型检查
npm run typecheck

# 代码格式化
npm run format

🤝 贡献

欢迎提交 Issue 和 PR!请阅读 贡献指南

📄 许可证

MIT

🙏 致谢