@agentworkforce/workload-router

中文文档
4.2.1发布于 2026/10/05TypeScriptES Module构建来源已验证近 30 天下载 1.4万

Routing and profile utilities for AgentWorkforce workload orchestration.

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. usePersona(intent, options?)
  4. Persona shape
  5. Development

@agentworkforce/workload-router

Routing and profile utilities for AgentWorkforce workload orchestration.

Install

npm install @agentworkforce/workload-router

Usage

usePersona(intent, options?)

Despite the use* prefix, this is not a React hook. It is a plain synchronous factory: call it, get back a PersonaContext bundling the resolved persona and grouped install metadata. Nothing is installed, spawned, or written to disk — run install.commandString yourself when you are ready to materialize the persona's skills.

usePersona resolves only the internal built-in catalog (persona-maker / persona-authoring). Optional personas such as code-reviewer and frontend-implementer are distributed through installable persona packs and should be loaded through the CLI/source cascade, then passed to useSelection or materializeSkillsFor.

import { usePersona } from '@agentworkforce/workload-router';

Return shape

const { selection, install } = usePersona('persona-authoring');
  • selection: the resolved persona choice for the given intent/profile. Includes personaId, tier, runtime, skills, inputs, mount, and rationale.
  • install: grouped install metadata.
  • install.plan: a pure description of what skill installs would be needed for that persona on that harness. No processes run when you read this.
  • install.command: the full install command as an argv array for spawn/execFile.
  • install.commandString: the same full install command as a shell-escaped string.
  • install.cleanupCommand / install.cleanupCommandString: a rm -rf over the ephemeral artifact paths the provider scatters during install (the provider's lockfile is deliberately preserved). For empty plans this is a shell no-op (:). Run it after the agent has consumed the skills.

Example

import { spawnSync } from 'node:child_process';
import { usePersona } from '@agentworkforce/workload-router';

const { selection, install } = usePersona('persona-authoring');

spawnSync(install.commandString, { shell: true, stdio: 'inherit' });
// hand `selection` to your harness launcher of choice.

Persona shape

Personas may declare prompt-visible runtime inputs:

{
  "id": "release-checker",
  "intent": "release-check",
  "tags": ["release"],
  "description": "Checks release readiness.",
  "skills": [],
  "inputs": {
    "PACKAGE_NAME": {
      "description": "Package or workspace to inspect.",
      "env": "PACKAGE_NAME",
      "default": "."
    },
    "REPORT_PATH": "release-report.md"
  },
  "mount": {
    "readonlyPatterns": ["*", "!docs/**"]
  },
  "tiers": {
    "best": {
      "harness": "codex",
      "model": "openai-codex/gpt-5.3-codex",
      "systemPrompt": "Check $PACKAGE_NAME and write ${REPORT_PATH}.",
      "harnessSettings": {
        "reasoning": "high",
        "timeoutSeconds": 1200,
        "sandboxMode": "workspace-write",
        "workspaceWriteNetworkAccess": true
      }
    }
    // best-value and minimum omitted in this fragment
  }
}

Input keys must be env-style uppercase names. The router validates and carries the declarations through PersonaSpec and PersonaSelection; launchers decide how to resolve and render them. The standard persona-kit policy is explicit value, env var, default, then fail.

Codex runtimes may also set harnessSettings.sandboxMode, harnessSettings.approvalPolicy, harnessSettings.workspaceWriteNetworkAccess, and harnessSettings.webSearch; persona-kit maps those to Codex launch flags.

Development

pnpm --filter @agentworkforce/workload-router build
pnpm --filter @agentworkforce/workload-router test

版本与发布记录

@agentworkforce/workload-router 共发布 156 个版本,首次发布于 2026/04/09;过去 12 个月发布了 156 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.2.1latest2026/10/051 个月前
4.2.02026/10/021 个月前
4.1.612026/09/301 个月前
4.1.602026/09/301 个月前
4.1.592026/09/181 个月前
4.1.582026/09/151 个月前

关于 @agentworkforce/workload-router 的常见问题

@agentworkforce/workload-router 是什么?

Routing and profile utilities for AgentWorkforce workload orchestration.

如何安装 @agentworkforce/workload-router?

在项目目录运行 npm install @agentworkforce/workload-router,或使用 pnpm add / yarn add / bun add。

@agentworkforce/workload-router 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentworkforce/workload-router 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agentworkforce/workload-router 可以商用吗?

@agentworkforce/workload-router 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@agentworkforce/workload-router 的下载量有多少?

根据 npm 官方下载统计,@agentworkforce/workload-router 在 2026/10/05 – 2026/11/03 这 30 天内被下载 13,668 次,日均约 456 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentworkforce/workload-router 还在维护吗?

最新版本 4.2.1 发布于 2026/10/05(1 个月前);至今共发布 156 个版本,其中过去 12 个月发布了 156 个;首次发布于 2026/04/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。