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

@roasmax/comfyui

v1.1.0

Published

A modern TypeScript SDK for ComfyUI with flexible template system and elegant callback mechanisms

Downloads

7

Readme

@roasmax/comfyui

一个现代化的 ComfyUI TypeScript SDK,专注于提供灵活的模板系统和优雅的回调机制。

特性

  • 🎯 类型安全: 完整的 TypeScript 类型定义
  • 🔧 模板系统: 灵活的工作流模板管理和参数化
  • 🔄 实时监控: WebSocket 实时事件监听
  • 📦 易于使用: 简洁的 API 设计和优雅的回调机制
  • 🧪 测试覆盖: 完整的单元测试覆盖
  • 📚 文档完善: 详细的 API 文档和使用示例

安装

npm install @roasmax/comfyui
# 或
yarn add @roasmax/comfyui
# 或
pnpm add @roasmax/comfyui

快速开始

基本使用

import { ComfyUIClient, WorkflowTemplate } from '@roasmax/comfyui';

// 创建客户端
const client = new ComfyUIClient({
  baseUrl: 'http://localhost:8188'
});

// 创建模板
const template = new WorkflowTemplate({
  metadata: {
    id: 'text-to-image',
    name: 'Text to Image',
    description: 'Simple text to image generation'
  },
  workflow: {
    "1": {
      "class_type": "CLIPTextEncode",
      "inputs": {
        "text": "{{prompt}}",
        "clip": ["2", 0]
      }
    }
    // ... 更多节点
  },
  parameters: {
    prompt: {
      type: 'string',
      required: true,
      description: 'The text prompt for image generation'
    }
  }
});

// 执行模板
const result = await client.executeTemplate(template, {
  prompt: 'A beautiful sunset over mountains'
}, {
  onProgress: (progress) => {
    console.log(`Progress: ${progress.progress}/${progress.max}`);
  },
  onExecuted: (result) => {
    console.log('Execution completed:', result);
  },
  onError: (error) => {
    console.error('Execution failed:', error);
  }
});

模板管理

import { TemplateManager } from '@roasmax/comfyui';

const manager = new TemplateManager();

// 注册模板
manager.register(template);

// 按 ID 执行模板
const result = await client.executeTemplateById('text-to-image', {
  prompt: 'A serene lake at dawn'
});

// 查找模板
const templates = manager.findByCategory('image-generation');

API 文档

ComfyUIClient

主要的客户端类,提供与 ComfyUI 服务器交互的功能。

构造函数

new ComfyUIClient(config: ComfyUIClientConfig)

方法

  • executeTemplate(template, parameters, options?): 执行工作流模板
  • executeTemplateById(templateId, parameters, options?): 按 ID 执行模板
  • connect(): 建立 WebSocket 连接
  • disconnect(): 断开连接

WorkflowTemplate

工作流模板类,支持参数化和验证。

构造函数

new WorkflowTemplate(data: WorkflowTemplateData)

方法

  • createInstance(parameters): 创建模板实例
  • validate(parameters): 验证参数
  • getParameterSchema(): 获取参数模式

TemplateManager

模板管理器,提供模板注册、查找和分类功能。

方法

  • register(template): 注册模板
  • unregister(templateId): 注销模板
  • findById(templateId): 按 ID 查找模板
  • findByCategory(category): 按分类查找模板
  • list(): 列出所有模板

开发

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建
npm run build

# 测试
npm run test

# 代码检查
npm run lint

许可证

MIT License - 详见 LICENSE 文件。

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

详见 CHANGELOG.md