> ## Documentation Index
> Fetch the complete documentation index at: https://oom-wg.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 模块安装流

> 建立连接后后端执行模块安装

传入 `url` 查询参数时后端下载模块 ZIP，客户端不需要发送 ZIP 二进制

没有 `url` 查询参数时客户端必须先发送 ZIP 二进制消息，并以 `{"type":"uploadEnd"}` 结束上传

客户端可以发送文本信息或二进制消息作为进程标准输入

服务端以 JSON 文本信息返回标准输出、标准错误和退出状态，
错误会以 `exit` 消息返回，其中 `code` 可能是 HTTP 状态码




## AsyncAPI

````yaml apis/ssu/asyncapi.yml moduleInstall
id: moduleInstall
title: 模块安装流
description: |
  建立连接后后端执行模块安装

  传入 `url` 查询参数时后端下载模块 ZIP，客户端不需要发送 ZIP 二进制

  没有 `url` 查询参数时客户端必须先发送 ZIP 二进制消息，并以 `{"type":"uploadEnd"}` 结束上传

  客户端可以发送文本信息或二进制消息作为进程标准输入

  服务端以 JSON 文本信息返回标准输出、标准错误和退出状态，
  错误会以 `exit` 消息返回，其中 `code` 可能是 HTTP 状态码
servers:
  - id: superuser
    protocol: ws
    host: '{host}:{port}'
    bindings: []
    variables:
      - id: host
        defaultValue: 127.0.0.1
        allowedValues: []
        examples: []
      - id: port
        defaultValue: '5355'
        allowedValues: []
        examples: []
address: /modules/install
parameters: []
bindings: []
operations:
  - &ref_2
    id: sendModuleInstallZip
    title: 发送模块安装包
    description: 未传入 `url` 时发送模块 ZIP 二进制并结束上传
    type: send
    messages:
      - &ref_5
        id: upload
        contentType: application/zip
        payload:
          - type: string
            format: binary
            x-parser-schema-id: <anonymous-schema-2>
            name: 模块 ZIP 二进制
            description: 未传入 `url` 时写入模块安装包
        headers: []
        jsonPayloadSchema:
          type: string
          format: binary
          x-parser-schema-id: <anonymous-schema-2>
        title: 模块 ZIP 二进制
        description: 未传入 `url` 时写入模块安装包
        example: '{}'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: upload
      - &ref_6
        id: uploadEnd
        contentType: application/json
        payload:
          - name: 模块 ZIP 上传结束
            description: 结束模块 ZIP 上传并开始安装
            type: object
            properties:
              - name: type
                type: string
                description: uploadEnd
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: uploadEnd
              x-parser-schema-id: <anonymous-schema-4>
          x-parser-schema-id: <anonymous-schema-3>
        title: 模块 ZIP 上传结束
        description: 结束模块 ZIP 上传并开始安装
        example: |-
          {
            "type": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: uploadEnd
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: moduleInstall
  - &ref_1
    id: receiveModuleInstallOutput
    title: 接收模块安装输出
    description: 接收模块安装的标准输出、标准错误和退出状态
    type: receive
    messages:
      - &ref_3
        id: stdio
        contentType: application/json
        payload:
          - name: 标准输出或标准错误消息
            description: 进程输出
            type: object
            properties:
              - name: type
                type: string
                description: stdio
                required: true
              - name: stdout
                type: string
                required: false
              - name: stderr
                type: string
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: stdio
              x-parser-schema-id: <anonymous-schema-6>
            stdout:
              type: string
              x-parser-schema-id: <anonymous-schema-7>
            stderr:
              type: string
              x-parser-schema-id: <anonymous-schema-8>
          x-parser-schema-id: <anonymous-schema-5>
        title: 标准输出或标准错误消息
        description: 进程输出
        example: |-
          {
            "type": "<string>",
            "stdout": "<string>",
            "stderr": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: stdio
      - &ref_4
        id: exit
        contentType: application/json
        payload:
          - name: 退出状态消息
            description: 进程退出状态
            type: object
            properties:
              - name: type
                type: string
                description: exit
                required: true
              - name: code
                type: integer
                description: 进程退出码或安装前置错误的 HTTP 状态码
                required: false
              - name: signal
                type: integer
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: exit
              x-parser-schema-id: <anonymous-schema-10>
            code:
              type: integer
              description: 进程退出码或安装前置错误的 HTTP 状态码
              x-parser-schema-id: <anonymous-schema-11>
            signal:
              type: integer
              x-parser-schema-id: <anonymous-schema-12>
          x-parser-schema-id: <anonymous-schema-9>
        title: 退出状态消息
        description: 进程退出状态
        example: |-
          {
            "type": "<string>",
            "code": 123,
            "signal": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: exit
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
receiveOperations:
  - *ref_2
sendMessages:
  - *ref_3
  - *ref_4
receiveMessages:
  - *ref_5
  - *ref_6
extensions:
  - id: x-parser-unique-object-id
    value: moduleInstall
securitySchemes:
  - id: wsTicket
    name: ws
    type: httpApiKey
    description: 通过 HTTP 请求 `POST /ws` 返回的一次性票证
    in: query
    extensions: []

````