OpenRobot.Litegraph.Cloud
1.0.0
dotnet add package OpenRobot.Litegraph.Cloud --version 1.0.0
NuGet\Install-Package OpenRobot.Litegraph.Cloud -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenRobot.Litegraph.Cloud" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenRobot.Litegraph.Cloud" Version="1.0.0" />
<PackageReference Include="OpenRobot.Litegraph.Cloud" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenRobot.Litegraph.Cloud --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OpenRobot.Litegraph.Cloud, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenRobot.Litegraph.Cloud@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenRobot.Litegraph.Cloud&version=1.0.0
#tool nuget:?package=OpenRobot.Litegraph.Cloud&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
OpenRobot.Litegraph.Cloud
Litegraph 云端对接(net8.0):取云端流程 → 交给 OpenRobot.Litegraph.Core 装配 → 灌元数据 → 落本地备份,
以及把执行概要回存云端。传输层留一条缝,进程直连或经宿主通道转发都能用。
- 一条缝,两种传输:6 个云端接口的实现只写一遍(
LitegraphCloudClientBase), 传输由子类决定 ——HttpLitegraphCloudClient直连,ForwardedLitegraphCloudClient交给宿主的ILitegraphApiForwarder。上层(加载器 / 回存器)不认识传输方式。 - 失败收敛成数据:任何一条云端流程失败都不抛,返回
GraphLoadResult(错误码E009), 与本地LoadDirectory的契约一致 —— 宿主把两边结果并进同一个列表即可。 - 引擎吃原始画布:
GetContext返回的字符串直接喂给LitegraphService.Load,不做中间转换; 本地备份是旁路动作,不会被回读,删掉也不影响执行。 - 不绑传输栈:包内不引任何转发框架,
ILitegraphApiForwarder只描述 「方法 / 地址 / query / 请求体 → 原始响应」。Microsoft.Extensions.*停在 8.0.x,与 .NET 8 宿主一致。
安装
<PackageReference Include="OpenRobot.Litegraph.Cloud" Version="1.0.0" />
包由本仓库产出:
dotnet pack Litegraph/OpenRobot.Litegraph.Cloud/OpenRobot.Litegraph.Cloud.csproj -c Release
依赖:
OpenRobot.Litegraph.Common1.0.0OpenRobot.Litegraph.Core1.0.0(传递OpenRobot.Framework.Modularity1.0.0)Microsoft.Extensions.Logging.Abstractions8.0.2(经 Modularity 传递)
本包不引
Microsoft.AspNetCore.SignalR.Client、OpenRobot.Framework.WebApiProxy一类转发框架。 宿主若要经自己的 Web 代理出网,实现ILitegraphApiForwarder即可 —— 把这类依赖加在宿主上,别加在包里。
快速开始
配置写在宿主 appsettings.json 的顶层 LitegraphCloud 节:
{
"LitegraphCloud": {
"BaseUrl": "http://192.168.1.10:9900",
"ProjectId": 1,
"TimeoutMs": 15000,
"BackupEnabled": true,
"BackupDirectory": "assets/remote"
}
}
直连:拉取并装配
using OpenRobot.Litegraph.Cloud;
var cloudOptions = LitegraphCloudOptions.Load();
if (!cloudOptions.IsConfigured)
return; // BaseUrl 为空 = 不启用云端对接
using ILitegraphCloudClient client = new HttpLitegraphCloudClient(cloudOptions, logger);
var loader = new CloudGraphLoader(client, cloudOptions, logger);
// service 是已装配的 LitegraphService;graphId 直接用 flowId,重新拉取不会产生第二张图
var results = loader.LoadMany(service, new[] { "3f2b9c41-…", "9c11d7a0-…" });
foreach (var result in results)
{
if (!result.Success)
logger.LogError("云端图 {File} 加载失败:{Code} {Message}",
result.File, result.Error!.Code, result.Error.Message);
}
接进模块宿主时,把加载挂到 LitegraphModule.AdditionalGraphLoader —— 它在引擎 Start 之前执行,
这样云端图也能拿到主流程的周期 tick:
var module = new LitegraphModule(logger);
module.AdditionalGraphLoader = service => loader.LoadMany(service, flowIds);
转发:宿主提供出网通道
设备端只允许一个进程出网时,子应用不要自己开 HttpClient,实现传输缝即可:
public sealed class HostApiForwarder : ILitegraphApiForwarder
{
public async Task<LitegraphApiForwardResult?> RequestAsync(
string method,
string url,
IReadOnlyList<(string Key, string? Value)> query,
object? body,
CancellationToken cancellationToken)
{
// 交给宿主自己的出网通道;没拿到回传(超时 / 未连接)就返回 null,
// 拿到了但服务端判失败 → Success = false,
// 否则 Data 就是响应体原文(含 ABP 信封)
return await _channel.SendAsync(method, url, query, body, cancellationToken).ConfigureAwait(false);
}
}
using ILitegraphCloudClient client = new ForwardedLitegraphCloudClient(forwarder, cloudOptions, logger);
回存执行概要
var publisher = new CloudArtifactsPublisher(client, logger);
// ⚠️ 必须在模块 Shutdown 之前调用:Shutdown 会清空 Service 与 LoadResults
var pushResults = await publisher.PushAsync(service, flowIds, cancellationToken);
foreach (var r in pushResults.Where(r => !r.Ok))
logger.LogWarning("流程 {FlowId} 回存失败:{Detail}", r.FlowId, r.Detail);
API 速查
客户端
| 类型 | 说明 |
|---|---|
ILitegraphCloudClient |
6 个方法:CreateFlowAsync / GetAllFlowsAsync / GetMetadataAsync / GetContextAsync / UpdateDataAsync / UpdateArtifactsAsync;IDisposable |
LitegraphCloudClientBase |
6 个方法的实现与 ABP 信封 / 翻页 / 错误收敛;子类只实现一次传输 |
HttpLitegraphCloudClient(options, logger) |
直连实现:自带 HttpClient,超时取 TimeoutMs |
ForwardedLitegraphCloudClient(forwarder, options, logger) |
转发实现:请求交给 ILitegraphApiForwarder |
ILitegraphApiForwarder |
传输缝:RequestAsync(method, url, query, body, ct) |
LitegraphApiForwardResult |
Success / Data / FailureDetail / Error;返回 null 表示通道没拿到回传 |
编排器
| 类型 | 说明 |
|---|---|
CloudGraphLoader(client, options, logger) |
LoadOne(service, flowId, contextValues?) / LoadMany(...) / Backup(flowId, canvas, artifactsJson?) |
CloudArtifactsPublisher(client, logger?) |
PushAsync(service, flowIds, ct) → IReadOnlyList<ArtifactPushResult> |
ArtifactPushResult |
FlowId / Ok / Detail |
配置
| 项 | 默认 | 说明 |
|---|---|---|
BaseUrl |
空 | ABP 根(/api/services/app 之前的部分);空 = 不启用云端对接 |
ProjectId |
1 |
创建流程时的 projectID;不传会落成 0,必须显式给 |
TimeoutMs |
15000 |
HTTP 超时(毫秒);只作用于直连实现(最小按 1 秒生效),转发实现的超时由宿主的出网通道决定 |
AuthToken |
空 | 需登录接口的 Bearer token;当前这几个接口已匿名,留空即可 |
BackupDirectory |
assets/remote |
备份目录;相对路径以 AppContext.BaseDirectory 为基准 |
BackupEnabled |
true |
是否落备份;落盘失败只记 Warn,不影响执行 |
Load() / IsConfigured |
— | 从 LitegraphCloud 节读取 / 是否配了基址 |
信封与 DTO
| 类型 | 说明 |
|---|---|
AbpEnvelopeParser |
ParseResult / ParseAs<T> / ParseStringResult:拆 ABP 信封并统一处理 success=false |
AbpEnvelopeException |
信封级失败(success=false / 非 2xx / 解析失败) |
LitegraphConfigDto |
流程条目:FlowID / Name / FlowType / Parms / BuildArtifacts … |
LitegraphDataDto |
元数据:UserVariables / ContextVariables / Project |
LitegraphFlowTypes |
Main / Sub |
已知限制
LitegraphCloudOptions不是凭据容器:AuthToken对应的接口在云端已放开为匿名,正常不需要填; 确需填写时请走环境变量或本地未入库的配置,不要把 token 写进被提交的appsettings.json。GetContextAsync返回空串不是错误:那表示「流程存在但还没画过画布」。CloudGraphLoader会把它 转成E009("先去云端设计器保存一次"),以便与网络故障区分开;直接调客户端时要自己判空。CloudGraphLoader是同步阻塞的:它被设计成挂在LitegraphModule.AdditionalGraphLoader上, 而那个钩子的签名就是同步的 —— 网络抓取发生在模块初始化的同步路径上,只适合轻量宿主。- 参数名大小写是照抄云端的:
Get用FlowId(大写 D),GetContext用flowId(小写 d)。不要统一。 - 备份不是归档:默认写到
bin/…/assets/remote,dotnet clean或重新发布就没了 —— 云端才是权威。 PushAsync必须在Shutdown()之前:Shutdown会置Service = null并清空LoadResults,之后连概要都拿不到。
版本历史
1.0.0(首次发布)
ILitegraphCloudClient6 个云端接口 + ABP 信封解析与自动翻页HttpLitegraphCloudClient(直连)与ForwardedLitegraphCloudClient(宿主转发),共用ILitegraphApiForwarder传输缝CloudGraphLoader:拉取 → 装配 → 灌元数据 → 落备份,逐条失败收敛为GraphLoadResultCloudArtifactsPublisher:回存执行概要,逐条返回ArtifactPushResultLitegraphCloudOptions(LitegraphCloud顶层节)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- OpenRobot.Litegraph.Common (>= 1.0.0)
- OpenRobot.Litegraph.Core (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 41 | 10/28/2026 |