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

@wangenius/taskie

v1.0.23

Published

## 特性

Downloads

7

Readme

Taskie - 智能任务执行框架

特性

  • 支持任务的创建、执行、暂停、恢复、取消等操作
  • 支持任务的依赖关系管理
  • 支持任务的并发执行
  • 支持任务执行状态的实时监控
  • 支持任务执行的重试机制
  • 支持任务执行的超时控制
  • 支持任务的事件监听和状态追踪
  • 支持任务的序列化和反序列化
  • 支持智能任务规划和自动重规划
  • 支持上下文感知和思维链追踪
  • 支持自定义模型和工具集成
  • 支持异步生成器模式的交互式执行

安装

npm install taskie

快速开始

智能代理模式

import { Agent, ChatModel } from "taskie";

// 创建语言模型实例
const model = new ChatModel({
  model: "gpt-4o",
  api_key: "your-api-key",
  api_url: "https://api.openai.com/v1/",
});

// 创建Agent实例
const agent = new Agent({
  model,
});

agent.tools([myTool1, myTool2]);

// 执行任务
const result = await agent.run("请帮我完成数据分析任务");

const result = agent.chat("最近有什么体育新闻");

// 使用生成器模式获取执行过程
for await (const step of result) {
  console.log(step);
}

工具创建

见 src / tools 目录;

任务流执行

基本用法

import { Task } from "taskie";

// 创建任务
const task = new Task({ name: "示例任务" });

// 注册任务(可选,用于状态管理)
task.register();

// 创建步骤
const step1 = task.step("步骤1").exe(async () => {
  return "Hello";
});

const step2 = task
  .step("步骤2")
  .after(step1) // 设置依赖关系
  .exe(async (deps) => {
    const step1Result = deps[step1.getId()];
    return `${step1Result} World`;
  });

// 执行任务
const results = await task.run();
console.log(results.get(step2.getId())); // 输出: Hello World

高级特性

重试机制

const step = task
  .step("网络请求")
  .retry({
    maxAttempts: 3,
    initialDelay: 1000,
    backoffFactor: 2,
    maxDelay: 5000,
  })
  .exe(async () => {
    // 执行可能失败的操作
  });

超时控制

const step = task
  .step("耗时操作")
  .timeout(5000) // 5秒超时
  .exe(async () => {
    // 执行耗时操作
  });

API 文档

Agent 类

构造函数

new Agent(params?: {
  model?: ChatModel;
  tools?: ToolFunctionHandler[];
  config?: Partial<AgentConfig>;
})

主要方法

  • run(input: string): Promise<any> - 执行任务
  • chat(input: string): AsyncGenerator<string> - 交互式执行任务
  • model(model: ChatModel): this - 设置语言模型
  • tools(tools: ToolFunctionHandler[]): this - 设置工具集

Context 类

主要方法

  • reset(): void - 重置上下文
  • setPlan(plan: TaskPlan): void - 设置执行计划
  • updateTaskStatus(result: ActionResult, stepId: string): void - 更新任务状态
  • recordChain(step: string, result: any, observation: string): void - 记录思维链
  • generate_context_info(): string - 生成上下文信息

配置选项

interface AgentConfig {
  maxIterations: number; // 最大迭代次数
  temperature: number; // 模型温度参数
}

interface TaskConfig {
  name: string; // 任务名称
  timeout?: number; // 任务超时时间
  retryConfig?: {
    // 重试配置
    maxAttempts: number;
    initialDelay: number;
    backoffFactor: number;
    maxDelay: number;
  };
}

事件系统

task.on((event) => {
  switch (event.type) {
    case "step:start":
      console.log(`步骤 ${event.stepId} 开始执行`);
      break;
    case "step:complete":
      console.log(`步骤 ${event.stepId} 执行完成`);
      break;
    case "step:fail":
      console.log(`步骤 ${event.stepId} 执行失败:`, event.error);
      break;
    case "plan:replan":
      console.log(`任务重新规划,原因:`, event.reason);
      break;
  }
});

许可证

MIT