• 简体中文
  • 当前版本快速开始

    如果你第一次使用 commflow,请从本页开始。本页只展示 commflow@0.0.2 已经存在并可运行的 API。

    安装

    npm install commflow

    运行时要求

    commflow npm 包运行时要求是 Node.js >=20.0.0

    文档站使用 Rspress 构建,它有单独的构建期 Node.js 要求;这个要求不会改变只安装 commflow 的应用运行时要求。

    读取 manifest

    创建 quick-start.mjs

    import {
      COMMFLOW_CHANNELS,
      createCommflowManifest
    } from 'commflow';
    
    const manifest = createCommflowManifest();
    
    console.log(JSON.stringify({
      channels: COMMFLOW_CHANNELS,
      primaryIntegration: manifest.primaryIntegration,
      plannedReplacement: manifest.plannedReplacement,
      descriptors: manifest.descriptors.map((item) => ({
        name: item.name,
        streaming: item.streaming,
        bidirectional: item.bidirectional
      }))
    }, null, 2));

    运行示例

    node quick-start.mjs

    预期输出

    {
      "channels": [
        "request",
        "sse",
        "rpc",
        "socket"
      ],
      "primaryIntegration": "vextjs",
      "plannedReplacement": "vext/app.fetch",
      "descriptors": [
        {
          "name": "request",
          "streaming": false,
          "bidirectional": false
        },
        {
          "name": "sse",
          "streaming": true,
          "bidirectional": false
        },
        {
          "name": "rpc",
          "streaming": true,
          "bidirectional": true
        },
        {
          "name": "socket",
          "streaming": true,
          "bidirectional": true
        }
      ]
    }

    如果你看到这段输出,说明包已正确安装,已发布的 manifest API 可以正常运行。

    输出含义

    manifest 描述的是项目方向,不是已经发布的 runtime client:

    • request:计划中的首个 runtime,用于一次性请求/响应编排。
    • sse:计划中的服务端单向流推送。
    • rpc:计划中的 typed contract / procedure-style 通信。
    • socket:计划中的长连接双向消息通道。

    primaryIntegration 当前是 vextjs,表示 VextJS 是第一个重点集成目标。plannedReplacementvext/app.fetch,表示真实 request runtime 存在后计划替换的 VextJS request 路径。

    当前还不包含什么

    commflow@0.0.2 还没有发布 request runtime client。不要把规划 API 文档里的名称当作生产 import 使用。

    下一步