Skip to content

Commit db130cd

Browse files
author
fengjiayi
committed
feat: add library service injection and SDK docs
1 parent b1e1459 commit db130cd

18 files changed

Lines changed: 1151 additions & 36 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ frontend/sereinflow-web/coverage/
4242
frontend/sereinflow-web/output-vite.err
4343
/.artifacts
4444
/NuGet/Migrations
45+
/.dotnet-cli/.dotnet
46+
/.build-temp
47+
/.dotnet-session
48+
/.compile-check

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<ItemGroup>
88
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
99
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
10+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11" />
1011
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.11" />
1112
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.11" />
1213
<PackageVersion Include="SqlSugarCore" Version="5.1.4.217" />

src/SereinFlow.Api/mcp/sereinflow-library-package-skill.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,28 @@ output and its dependency closure first.
2222

2323
Use an SDK-style C# class library targeting a runtime supported by the
2424
deployment. The current repository examples target `net10.0`.
25-
`SereinFlow.Library` version `1.0.0` is published on
25+
`SereinFlow.Library` is published on
2626
[NuGet.org](https://www.nuget.org/packages/SereinFlow.Library/). Reference it
27-
as the standalone public SDK package:
27+
as the standalone public SDK package with NuGet's floating version to use the
28+
latest stable release by default:
2829

2930
```xml
3031
<ItemGroup>
31-
<PackageReference Include="SereinFlow.Library" Version="1.0.0" />
32+
<PackageReference Include="SereinFlow.Library" Version="*" />
3233
</ItemGroup>
3334
```
3435

36+
When the caller needs a specific compatible version for reproducible builds or
37+
deployment compatibility, they may replace `*` with the requested version:
38+
39+
```xml
40+
<PackageReference Include="SereinFlow.Library" Version="x.y.z" />
41+
```
42+
43+
For a project that uses Central Package Management, keep the project reference
44+
without a `Version` attribute and set either `*` or the caller's requested
45+
version in `Directory.Packages.props`.
46+
3547
The package supplies the public metadata attributes and restricted runtime
3648
context without referencing SereinFlow Domain, Application, or server
3749
implementation assemblies. Restore it from NuGet.org using the normal NuGet
@@ -42,9 +54,9 @@ Never replace the `PackageReference` with a DLL reference and never copy local
4254
definitions of the SDK contracts into the library. Do not add a custom SDK
4355
package source merely to obtain `SereinFlow.Library`. If the caller
4456
explicitly works offline or behind an approved package mirror, use their
45-
provided source only when it contains the published package version; report a
46-
missing source or unavailable package without silently modifying the user's
47-
global NuGet configuration.
57+
provided source only when it contains a suitable published package version;
58+
report a missing source or unavailable package without silently modifying the
59+
user's global NuGet configuration.
4860

4961
Let MSBuild evaluate these properties; do not parse inherited build files by
5062
hand:

src/SereinFlow.Contracts/LibraryAttributes.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
[assembly: TypeForwardedTo(typeof(FlowNodeAttribute))]
99
[assembly: TypeForwardedTo(typeof(NodeParamAttribute))]
1010
[assembly: TypeForwardedTo(typeof(NodeType))]
11+
[assembly: TypeForwardedTo(typeof(FlowServiceLifetime))]
12+
[assembly: TypeForwardedTo(typeof(FlowServiceAttribute))]
13+
[assembly: TypeForwardedTo(typeof(FlowServiceAttribute<>))]
1114
[assembly: TypeForwardedTo(typeof(LibraryAttributeContract))]
Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,76 @@
11
namespace SereinFlow.Runtime.Abstractions;
22

33
/// <summary>
4-
/// Restricted per-node context exposed to trusted node-library methods.
5-
/// It allows a node to select an execution branch without exposing arbitrary
6-
/// flow data, environment variables, or host services.
7-
/// 提供给受信任节点类库方法的受限上下文。节点可以选择执行分支,但不能访问任意流程数据
4+
/// Provides restricted per-node context to trusted node-library methods. It allows a node to
5+
/// select an execution branch without exposing arbitrary flow data, environment variables, or
6+
/// host services.
7+
/// 向受信任的节点类库方法提供受限的节点上下文。它允许节点选择执行分支,但不会公开任意流程数据
88
/// 环境变量或宿主服务。
99
/// </summary>
1010
public interface IFlowContext
1111
{
12+
/// <summary>
13+
/// Gets the unique identifier of the active flow run.
14+
/// 获取当前活动流程运行的唯一标识。
15+
/// </summary>
1216
Guid RunId { get; }
1317

18+
/// <summary>
19+
/// Gets the stable identifier of the node currently being invoked.
20+
/// 获取当前正在调用节点的稳定标识。
21+
/// </summary>
1422
string NodeId { get; }
1523

24+
/// <summary>
25+
/// Gets the token that is cancelled when the Worker stops or cancels the current flow run.
26+
/// 获取当 Worker 停止或取消当前流程运行时会被取消的令牌。
27+
/// </summary>
1628
CancellationToken CancellationToken { get; }
1729

30+
/// <summary>
31+
/// Selects the success branch for the current node invocation.
32+
/// 为当前节点调用选择成功分支。
33+
/// </summary>
1834
void SelectSuccess();
1935

36+
/// <summary>
37+
/// Selects the failure branch for the current node invocation.
38+
/// 为当前节点调用选择失败分支。
39+
/// </summary>
40+
/// <param name="code">
41+
/// An optional machine-readable failure code.
42+
/// 可选的、可供机器读取的失败代码。
43+
/// </param>
44+
/// <param name="message">
45+
/// An optional human-readable failure message.
46+
/// 可选的、供人阅读的失败消息。
47+
/// </param>
2048
void SelectFailure(string? code = null, string? message = null);
2149

50+
/// <summary>
51+
/// Selects the error branch for the current node invocation.
52+
/// 为当前节点调用选择错误分支。
53+
/// </summary>
54+
/// <param name="code">
55+
/// An optional machine-readable error code.
56+
/// 可选的、可供机器读取的错误代码。
57+
/// </param>
58+
/// <param name="message">
59+
/// An optional human-readable error message.
60+
/// 可选的、供人阅读的错误消息。
61+
/// </param>
2262
void SelectError(string? code = null, string? message = null);
2363
}
2464

2565
/// <summary>
26-
/// Metadata identity used by the safe PE scanner.
27-
/// 供安全 PE 扫描使用的元数据身份
66+
/// Provides the metadata identity used by the safe PE scanner.
67+
/// 提供安全 PE 扫描器使用的元数据标识
2868
/// </summary>
2969
public static class FlowContextContract
3070
{
71+
/// <summary>
72+
/// Gets the fully qualified metadata name of <see cref="IFlowContext"/>.
73+
/// 获取 <see cref="IFlowContext"/> 的完全限定元数据名称。
74+
/// </summary>
3175
public static readonly string FullName = typeof(IFlowContext).FullName ?? nameof(IFlowContext);
3276
}

0 commit comments

Comments
 (0)