SuperAPI AI 工具集

difyctl

通用与其它

查看项目

更新于 10-15 23:48

技能介绍

用途:difyctl 用于与 Dify 服务器交互。业务命令并非内置,服务器发布操作目录,每个操作在运行时被发现并作为命令执行。

主要能力:通过 help 树查看本地命令与服务器操作。difyctl help --json 是总览;difyctl help <namespace> --json 查看某命名空间;difyctl help <words> --json 按词搜索(最多 20 条);difyctl help <id> --json 查看单个描述符,含输入 JSON Schema、bind、kind、示例和 pins。--all 包含服务器标记为 internal 的操作。

使用方式:操作 id 为点分形式,如 run.console_app.chat,输入时用空格分隔:difyctl run console_app chat。运行操作示例:difyctl run console_app workflow --app-id <id> --inputs '{"a":1}'。input 的每个顶层字段对应一个标志,下划线转连字符;标量取值,对象、映射和对象列表取 JSON 字面量或 @file.json,标量列表重复该标志。名为 input、stream、only、output、verbose、json、help 的字段没有标志,需通过 --input 传入。--input 支持 JSON、@file.json 或 @-(stdin),字段标志会合并覆盖。运行应用需按模式选择操作:run console_app workflow、chat、advanced_chat、completion;先执行 difyctl describe console_app --app-id <id> --json 读取 input_schema。本地文件放在 files 下,以应用的文件变量名为键;运行附件放在 attachments;URL 直接放入 inputs。

difyctl 专有标志:--stream 将流式事件逐行输出为 JSON;--only <event> 过滤事件(可重复);--output <path> 保存文件类响应;--verbose 在错误中加入原始服务器响应。操作 kind 不支持的标志会以退出码 2 退出。

结果读取:流式操作折叠为 {status, text, outputs?, total_tokens?, message_id?, conversation_id?, error?, hints}。text.answer 是回复;status 为 ended、failed(退出码 1)、suspended(等待表单,按 hints 操作)或 incomplete。响应可能带 hints,即服务器建议的下一步,填入 input 中的 null 后用 difyctl <op> --input '<input>' 回传。

错误与退出码:错误以单个信封输出到 stderr:{"error":{"code","message","hint"?,"details"?,"schema"?}}。退出码 2 为输入错误(含 schema),4 为未登录或禁止,6 为目录不可用或未知操作,7 为限流。

登录与环境:difyctl login --server https://...(设备流程;--no-browser 打印 URL 和代码;--no-keyring 将令牌存文件;--insecure 跳过 TLS 校验)。一次只能一个登录。difyctl use workspace <id> 固定工作区;difyctl get workspace 查看。脚本可用 DIFY_SERVER 和 DIFY_TOKEN 跳过登录;DIFY_WORKSPACE_ID 覆盖固定;DIFY_CONFIG_DIR 和 DIFY_CACHE_DIR 移动文件。login 会阻塞直到浏览器批准;在沙箱中加 --no-keyring 并设置 DIFY_CONFIG_DIR 到持久存储。若后台任务不跨调用存活,可用 login --no-wait,转发 verification_uri 和 user_code,批准后运行 login --resume 直到不再打印 status: pending。

限制:删除或撤销类操作没有确认提示,需先与用户确认。其他场景技能可通过 difyctl get skills 查看,difyctl install skills <skills root> --skill <name> 安装,升级 difyctl 后重新运行可刷新所有技能。