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

we0-auto-workflow

v1.0.0

Published

A workflow automation package with we0Task and we0SSE functions for seamless integration with we0.ai platform

Readme

we0-auto-workflow

一个用于与 we0.ai 平台无缝集成的工作流自动化包,提供 we0Taskwe0SSE 函数。

安装

npm install we0-auto-workflow

特性

  • 🚀 任务执行: 支持阻塞和非阻塞任务执行
  • 🔄 实时流式: 通过 SSE 获取实时任务状态
  • 📁 文件支持: 支持多种文件类型(文档、图片、音频、视频)
  • 🛠️ TypeScript: 完整的 TypeScript 类型定义
  • 🔧 轻量级: 无额外依赖,开箱即用

快速开始

基本任务执行

import { we0Task } from 'we0-auto-workflow';

// 执行一个简单任务
const result = await we0Task(
  'your-api-key',
  { 
    message: 'Hello, world!',
    count: 10
  },
  (result) => {
    console.log('任务完成:', result);
  }
);

console.log('执行结果:', result);

实时流式处理

import { we0SSE } from 'we0-auto-workflow';

// 使用 SSE 获取实时更新
const result = await we0SSE(
  'your-api-key',
  { 
    message: 'Hello, world!',
    streaming: true
  },
  (event, data) => {
    console.log('SSE 事件:', event, data);
  }
);

文件处理

import { we0Task, FileObject } from 'we0-auto-workflow';

// 处理文件输入
const fileInput: FileObject[] = [
  {
    type: 'document',
    transfer_method: 'remote_url',
    url: 'https://example.com/document.pdf'
  },
  {
    type: 'image',
    transfer_method: 'local_file',
    upload_file_id: 'uploaded-file-id'
  }
];

const result = await we0Task(
  'your-api-key',
  { 
    files: fileInput,
    instruction: '处理这些文件'
  }
);

API 文档

we0Task

执行一个非阻塞任务,通过轮询获取状态。

function we0Task(
  apiKey: string,
  inputs: WorkflowInputs,
  callback?: TaskCallback,
  baseUrl?: string,
  pollingInterval?: number
): Promise<WorkflowResult>

参数:

  • apiKey: 您的 API 密钥
  • inputs: 输入参数对象
  • callback: 可选的任务完成回调函数
  • baseUrl: 可选的基础 URL,默认为 https://dify.we0.ai
  • pollingInterval: 可选的轮询间隔,默认为 200ms

we0SSE

创建并执行一个流式 SSE 连接。

function we0SSE(
  apiKey: string,
  inputs: WorkflowInputs,
  callback?: SSECallback,
  baseUrl?: string
): Promise<WorkflowResult>

参数:

  • apiKey: 您的 API 密钥
  • inputs: 输入参数对象
  • callback: 可选的 SSE 事件回调函数
  • baseUrl: 可选的基础 URL,默认为 https://dify.we0.ai

类型定义

WorkflowInputs

type WorkflowInputs = Record<string, InputValue>;
type InputValue = string | number | boolean | FileObject[] | any;

WorkflowResult

interface WorkflowResult {
  success: boolean;
  data?: any;
  error?: string;
  workflowRunId?: string;
  taskId?: string;
}

FileObject

interface FileObject {
  type: FileType;
  transfer_method: TransferMethod;
  url?: string; // 当 transfer_method 为 'remote_url' 时
  upload_file_id?: string; // 当 transfer_method 为 'local_file' 时
}

支持的文件类型

  • 文档类型: TXT, MD, MARKDOWN, PDF, HTML, XLSX, XLS, DOCX, CSV, EML, MSG, PPTX, PPT, XML, EPUB
  • 图片类型: JPG, JPEG, PNG, GIF, WEBP, SVG
  • 音频类型: MP3, M4A, WAV, WEBM, AMR
  • 视频类型: MP4, MOV, MPEG, MPGA

错误处理

try {
  const result = await we0Task('your-api-key', { message: 'test' });
  if (!result.success) {
    console.error('任务失败:', result.error);
  }
} catch (error) {
  console.error('执行错误:', error);
}

许可证

MIT

贡献

欢迎提交问题和拉取请求!

支持

如果您有任何问题或需要帮助,请访问 GitHub Issues