mainspring-workflow 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mainspring_workflow/__init__.py +54 -0
- mainspring_workflow/context.py +236 -0
- mainspring_workflow/graph.py +351 -0
- mainspring_workflow/py.typed +0 -0
- mainspring_workflow/supervisor.py +128 -0
- mainspring_workflow-0.1.0.dist-info/METADATA +75 -0
- mainspring_workflow-0.1.0.dist-info/RECORD +9 -0
- mainspring_workflow-0.1.0.dist-info/WHEEL +4 -0
- mainspring_workflow-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""mainspring-workflow:图编排 / 多 agent 按需上(T4-2)。
|
|
2
|
+
|
|
3
|
+
依赖方向 extras → core:本包不实现新的 core Protocol,而是用 core 的 Runner / Session /
|
|
4
|
+
Hook / Tracing 组合出编排层,不另建第二套运行时;core 对「工作流」概念零感知,整目录
|
|
5
|
+
删除即卸载。用法:
|
|
6
|
+
|
|
7
|
+
from mainspring_workflow import Workflow, agent_as_tool, handoff_tool, Supervisor
|
|
8
|
+
|
|
9
|
+
wf = Workflow(runner=runner)
|
|
10
|
+
wf.add_agent(planner)
|
|
11
|
+
wf.add_agent(writer)
|
|
12
|
+
wf.add_function("review", lambda state: state["output"].upper()) # 或用条件边分流
|
|
13
|
+
result = await wf.run("写一段产品文案")
|
|
14
|
+
print(result.output, result.usage)
|
|
15
|
+
|
|
16
|
+
关键不变量(细节见各模块 docstring):
|
|
17
|
+
- 根 run 虚拟(`wf_<hex>`),子 run 用 `RunConfig.parent_run_id` 挂回根 → OTel 父子 / 用量归集;
|
|
18
|
+
- fan-out 分支各拿浅拷贝 state,reducer 按声明顺序聚合,`max_concurrency` 默认 50;
|
|
19
|
+
- agents-as-tools 是委托(结果回填),handoff 是控制权转移(调用者终答作废);
|
|
20
|
+
- 子 agent 独立上下文:新鲜会话、只带自己的工具面。
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
from .context import (
|
|
26
|
+
WorkflowContext,
|
|
27
|
+
WorkflowError,
|
|
28
|
+
WorkflowResult,
|
|
29
|
+
agent_as_tool,
|
|
30
|
+
current_context,
|
|
31
|
+
handoff_tool,
|
|
32
|
+
text_of,
|
|
33
|
+
with_tools,
|
|
34
|
+
)
|
|
35
|
+
from .graph import AgentNode, FunctionNode, NodeOutcome, ParallelNode, Workflow
|
|
36
|
+
from .supervisor import Supervisor, SupervisorResult
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"AgentNode",
|
|
40
|
+
"FunctionNode",
|
|
41
|
+
"NodeOutcome",
|
|
42
|
+
"ParallelNode",
|
|
43
|
+
"Supervisor",
|
|
44
|
+
"SupervisorResult",
|
|
45
|
+
"Workflow",
|
|
46
|
+
"WorkflowContext",
|
|
47
|
+
"WorkflowError",
|
|
48
|
+
"WorkflowResult",
|
|
49
|
+
"agent_as_tool",
|
|
50
|
+
"current_context",
|
|
51
|
+
"handoff_tool",
|
|
52
|
+
"text_of",
|
|
53
|
+
"with_tools",
|
|
54
|
+
]
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"""workflow 运行时上下文:根 run、用量归集、handoff 传递与「委托 / 转移」两种姿势。
|
|
2
|
+
|
|
3
|
+
设计结论(T4-2 设计小节):
|
|
4
|
+
|
|
5
|
+
1. **不另起一套 runtime**:子 agent 一律走 core `Runner`,复用 Session / Hook / Tracing;
|
|
6
|
+
工作流自身只持有一个根 run 标识,子 run 通过 `RunConfig.parent_run_id` 挂回根——
|
|
7
|
+
这就是 OTel span 父子与 Usage 归集的唯一接缝(core 五轮复审补的注入通道);
|
|
8
|
+
2. **根 run 是虚拟的**:工作流不是 agent,没有自己的 run 循环;`root_run_id = wf_<hex>`
|
|
9
|
+
只出现在子事件的 `parent_run_id` 里,OTel 侧据此合成根 span;
|
|
10
|
+
3. **用量归集是并发安全的**:fan-out 分支同时回填写用量,统一走 `add_usage` 的锁,
|
|
11
|
+
最后 `Usage.merge` 到根结果——不允许各分支自己记小账;
|
|
12
|
+
4. **agents-as-tools = 委托取结果**:专家独立新鲜会话、只带自己的工具面,结论文本回主线;
|
|
13
|
+
5. **handoff = 控制权转移**:工具只登记「要交给谁 + 带什么话」,由编排层真正执行目标
|
|
14
|
+
并**丢弃调用者的终答**——这是与委托的实质区别,不是同一个机制的两种叫法。
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import asyncio
|
|
20
|
+
import json
|
|
21
|
+
import re
|
|
22
|
+
import uuid
|
|
23
|
+
from contextvars import ContextVar, Token
|
|
24
|
+
from dataclasses import dataclass, field
|
|
25
|
+
from hashlib import sha1
|
|
26
|
+
from typing import Any
|
|
27
|
+
|
|
28
|
+
from mainspring.agent import Agent
|
|
29
|
+
from mainspring.runner import Runner
|
|
30
|
+
from mainspring.session import Session
|
|
31
|
+
from mainspring.tool import Tool
|
|
32
|
+
from mainspring.types import RunConfig, RunResult, ToolSpec, Usage
|
|
33
|
+
from pydantic import BaseModel, ConfigDict, create_model
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"WorkflowContext",
|
|
37
|
+
"WorkflowError",
|
|
38
|
+
"WorkflowResult",
|
|
39
|
+
"agent_as_tool",
|
|
40
|
+
"current_context",
|
|
41
|
+
"handoff_tool",
|
|
42
|
+
"reset_context",
|
|
43
|
+
"set_context",
|
|
44
|
+
"text_of",
|
|
45
|
+
"with_tools",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
_CURRENT_CONTEXT: ContextVar[WorkflowContext | None] = ContextVar(
|
|
49
|
+
"mainspring_workflow_context", default=None
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def set_context(ctx: WorkflowContext) -> Token[WorkflowContext | None]:
|
|
54
|
+
"""把当前工作流上下文挂到 contextvar(编排层负责 set / reset)。"""
|
|
55
|
+
return _CURRENT_CONTEXT.set(ctx)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def reset_context(token: Token[WorkflowContext | None]) -> None:
|
|
59
|
+
"""恢复进入编排前的 contextvar 值。"""
|
|
60
|
+
_CURRENT_CONTEXT.reset(token)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def current_context() -> WorkflowContext:
|
|
64
|
+
"""工具侧取当前工作流上下文:不在编排内调用直接报错,而不是静默降级。"""
|
|
65
|
+
ctx = _CURRENT_CONTEXT.get()
|
|
66
|
+
if ctx is None:
|
|
67
|
+
raise WorkflowError("当前不在 workflow / supervisor 执行中,拿不到工作流上下文")
|
|
68
|
+
return ctx
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class WorkflowError(RuntimeError):
|
|
72
|
+
"""编排错误:未知节点 / 循环超限 / 子 agent 挂起 / 并行分支失败。"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@dataclass
|
|
76
|
+
class WorkflowResult:
|
|
77
|
+
"""一次工作流的出口:根 run 标识 + 最终输出 + 归集用量。"""
|
|
78
|
+
|
|
79
|
+
run_id: str
|
|
80
|
+
output: Any
|
|
81
|
+
state: dict[str, Any]
|
|
82
|
+
usage: Usage
|
|
83
|
+
node_outputs: dict[str, Any] = field(default_factory=dict)
|
|
84
|
+
agent_run_ids: list[str] = field(default_factory=list)
|
|
85
|
+
handoffs: list[tuple[str, str]] = field(default_factory=list)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass
|
|
89
|
+
class WorkflowContext:
|
|
90
|
+
"""工作流单次运行的共享上下文(根 run、用量、handoff 登记)。
|
|
91
|
+
|
|
92
|
+
生命周期:每次 Workflow.run / Supervisor.run 新建一个,工作流结束即弃,不可跨工作流
|
|
93
|
+
复用。用量并入只走 `add_usage`(锁内 merge);handoff 是单槽而非队列——同一节点内多次
|
|
94
|
+
`request_handoff` 只保留最后一次,编排层 `consume_handoff` 取走即清空。
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
runner: Runner
|
|
98
|
+
root_run_id: str = field(default_factory=lambda: f"wf_{uuid.uuid4().hex}")
|
|
99
|
+
deps: Any = None
|
|
100
|
+
usage: Usage = field(default_factory=Usage)
|
|
101
|
+
node_outputs: dict[str, Any] = field(default_factory=dict)
|
|
102
|
+
agent_run_ids: list[str] = field(default_factory=list)
|
|
103
|
+
handoffs: list[tuple[str, str]] = field(default_factory=list)
|
|
104
|
+
_usage_lock: asyncio.Lock = field(default_factory=asyncio.Lock)
|
|
105
|
+
_handoff: tuple[Agent, str] | None = field(default=None, init=False, repr=False)
|
|
106
|
+
|
|
107
|
+
async def add_usage(self, usage: Usage) -> None:
|
|
108
|
+
"""并发安全地把子 run 用量并入根。"""
|
|
109
|
+
async with self._usage_lock:
|
|
110
|
+
self.usage = self.usage.merge(usage)
|
|
111
|
+
|
|
112
|
+
def request_handoff(self, target: Agent, message: str) -> None:
|
|
113
|
+
"""登记控制权转移(由 handoff 工具调用,编排层执行)。"""
|
|
114
|
+
self._handoff = (target, message)
|
|
115
|
+
|
|
116
|
+
def consume_handoff(self) -> tuple[Agent, str] | None:
|
|
117
|
+
"""取出并清空 handoff 请求。"""
|
|
118
|
+
pending, self._handoff = self._handoff, None
|
|
119
|
+
return pending
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
async def run_child(
|
|
123
|
+
ctx: WorkflowContext,
|
|
124
|
+
agent: Agent,
|
|
125
|
+
value: str,
|
|
126
|
+
*,
|
|
127
|
+
deps: Any = None,
|
|
128
|
+
session: Session | None = None,
|
|
129
|
+
) -> RunResult:
|
|
130
|
+
"""执行一个子 agent run:挂到根 run 下,并把用量并入根。
|
|
131
|
+
|
|
132
|
+
run_id 登记进 ctx.agent_run_ids;结果为 pending(挂起待审批)直接抛 WorkflowError——
|
|
133
|
+
工作流 v1 不自动推进审批,宁可显式失败也不静默挂住编排。
|
|
134
|
+
"""
|
|
135
|
+
result = await ctx.runner.run(
|
|
136
|
+
agent,
|
|
137
|
+
value,
|
|
138
|
+
deps=ctx.deps if deps is None else deps,
|
|
139
|
+
cfg=RunConfig(parent_run_id=ctx.root_run_id),
|
|
140
|
+
session=session,
|
|
141
|
+
)
|
|
142
|
+
await ctx.add_usage(result.usage)
|
|
143
|
+
ctx.agent_run_ids.append(result.run_id)
|
|
144
|
+
if result.status == "pending":
|
|
145
|
+
raise WorkflowError(
|
|
146
|
+
f"子 agent {agent.name} 挂起待审批(run_id={result.run_id});工作流 v1 不自动推进审批"
|
|
147
|
+
)
|
|
148
|
+
return result
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def text_of(result: RunResult) -> str:
|
|
152
|
+
"""子 run → 干净文本:结构化输出优先,否则助手消息正文。"""
|
|
153
|
+
if result.output is not None:
|
|
154
|
+
if isinstance(result.output, BaseModel):
|
|
155
|
+
return result.output.model_dump_json()
|
|
156
|
+
if isinstance(result.output, str):
|
|
157
|
+
return result.output
|
|
158
|
+
return json.dumps(result.output, ensure_ascii=False, default=str)
|
|
159
|
+
if result.message is None:
|
|
160
|
+
return ""
|
|
161
|
+
return result.message.text_content()
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def with_tools(agent: Agent, extra: list[Tool]) -> Agent:
|
|
165
|
+
"""返回带附加工具的 agent 副本(Agent 是声明对象,不改原实例)。"""
|
|
166
|
+
if not extra:
|
|
167
|
+
return agent
|
|
168
|
+
return agent.model_copy(update={"tools": [*agent.tools, *extra]})
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def agent_as_tool(
|
|
172
|
+
agent: Agent,
|
|
173
|
+
ctx: WorkflowContext | None = None,
|
|
174
|
+
*,
|
|
175
|
+
name: str | None = None,
|
|
176
|
+
description: str | None = None,
|
|
177
|
+
) -> Tool:
|
|
178
|
+
"""agents-as-tools:把专家封装成工具,**委托取结果**(专家独立会话、只带自己的工具)。
|
|
179
|
+
|
|
180
|
+
调用者的 run 继续存在;专家结论以普通工具结果回填主线,上下文互不污染。
|
|
181
|
+
`ctx` 省略时在工具调用瞬间从 contextvar 取当前工作流上下文。
|
|
182
|
+
"""
|
|
183
|
+
args_model, spec = _task_contract(
|
|
184
|
+
name or f"consult_{_safe_name(agent.name)}",
|
|
185
|
+
description or f"咨询专家 {agent.name},返回其结论(独立上下文)",
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
async def delegate(task: str) -> str:
|
|
189
|
+
result = await run_child(ctx or current_context(), agent, task)
|
|
190
|
+
return text_of(result)
|
|
191
|
+
|
|
192
|
+
return Tool(spec=spec, func=delegate, params_model=args_model)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def handoff_tool(
|
|
196
|
+
target: Agent,
|
|
197
|
+
ctx: WorkflowContext | None = None,
|
|
198
|
+
*,
|
|
199
|
+
name: str | None = None,
|
|
200
|
+
description: str | None = None,
|
|
201
|
+
) -> Tool:
|
|
202
|
+
"""handoff 工具:只登记转移请求,不执行目标——执行权归编排层(控制权真正交出去)。"""
|
|
203
|
+
args_model, spec = _task_contract(
|
|
204
|
+
name or f"transfer_to_{_safe_name(target.name)}",
|
|
205
|
+
description or f"把控制权交给 {target.name}(携带任务上下文,本 agent 终答作废)",
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
async def transfer(task: str) -> str:
|
|
209
|
+
(ctx or current_context()).request_handoff(target, task)
|
|
210
|
+
return f"控制权已转交给 {target.name};等待其结论,本 agent 不再作答。"
|
|
211
|
+
|
|
212
|
+
return Tool(spec=spec, func=transfer, params_model=args_model)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def _task_contract(name: str, description: str) -> tuple[type[BaseModel], ToolSpec]:
|
|
216
|
+
"""委托 / 转移工具的公共参数契约:单一 task 字符串。"""
|
|
217
|
+
model: type[BaseModel] = create_model( # type: ignore[call-overload]
|
|
218
|
+
"TaskArgs",
|
|
219
|
+
__config__=ConfigDict(extra="forbid"),
|
|
220
|
+
task=(str, ...),
|
|
221
|
+
)
|
|
222
|
+
schema = model.model_json_schema()
|
|
223
|
+
schema.pop("title", None)
|
|
224
|
+
schema.setdefault("type", "object")
|
|
225
|
+
spec = ToolSpec(
|
|
226
|
+
name=_safe_name(name), description=description, parameters=schema, timeout=300.0
|
|
227
|
+
)
|
|
228
|
+
return model, spec
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def _safe_name(name: str) -> str:
|
|
232
|
+
safe = re.sub(r"[^A-Za-z0-9_-]", "_", name) or "agent"
|
|
233
|
+
if len(safe) <= 64:
|
|
234
|
+
return safe
|
|
235
|
+
digest = sha1(safe.encode("utf-8")).hexdigest()[:8]
|
|
236
|
+
return f"{safe[:55]}_{digest}"
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"""图编排:条件边、并行 fan-out + reducer、handoff 收口;所有执行都落到 core Runner。
|
|
2
|
+
|
|
3
|
+
设计小节(T4-2):
|
|
4
|
+
|
|
5
|
+
1. **节点只做两件事**:准备输入 → 调 core(AgentNode 走 `Runner.run`,FunctionNode 走
|
|
6
|
+
普通函数);节点不拥有运行时,会话 / Hook / 追踪全部来自传入的 Runner 与 Agent;
|
|
7
|
+
2. **状态是一条浅拷贝链**:串行节点原地写 state;fan-out 每个分支拿独立浅拷贝,只回传
|
|
8
|
+
输出,reducer 按声明顺序聚合——50 路并发也不会因共享 dict 丢结果;
|
|
9
|
+
3. **路由优先级**:节点显式 next > 条件边 router > 静态边 > 隐式插入顺序;
|
|
10
|
+
4. **handoff 在节点结束后收口**:目标 agent 立刻执行,调用者终答被覆盖,工作流以目标
|
|
11
|
+
结论收尾(控制权转移,不是委托);
|
|
12
|
+
5. **循环有硬上限**:`max_steps` 防状态机写错导致死循环,超限报错而不是挂住。
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import asyncio
|
|
18
|
+
import inspect
|
|
19
|
+
from collections.abc import Awaitable, Callable, Sequence
|
|
20
|
+
from dataclasses import dataclass, field
|
|
21
|
+
from typing import Any, Protocol
|
|
22
|
+
|
|
23
|
+
from mainspring.agent import Agent
|
|
24
|
+
from mainspring.runner import Runner
|
|
25
|
+
from mainspring.session import Session
|
|
26
|
+
from mainspring.types import Usage
|
|
27
|
+
|
|
28
|
+
from .context import (
|
|
29
|
+
WorkflowContext,
|
|
30
|
+
WorkflowError,
|
|
31
|
+
WorkflowResult,
|
|
32
|
+
handoff_tool,
|
|
33
|
+
reset_context,
|
|
34
|
+
run_child,
|
|
35
|
+
set_context,
|
|
36
|
+
text_of,
|
|
37
|
+
with_tools,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"AgentNode",
|
|
42
|
+
"FunctionNode",
|
|
43
|
+
"NodeOutcome",
|
|
44
|
+
"ParallelNode",
|
|
45
|
+
"Workflow",
|
|
46
|
+
"WorkflowError",
|
|
47
|
+
"WorkflowResult",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
Router = Callable[[dict[str, Any]], str | Awaitable[str | None] | None]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dataclass
|
|
54
|
+
class NodeOutcome:
|
|
55
|
+
"""单节点出口:输出值 + 用量 + 子 run 标识 + 可选的显式下一跳。"""
|
|
56
|
+
|
|
57
|
+
output: Any
|
|
58
|
+
usage: Usage = field(default_factory=Usage)
|
|
59
|
+
run_id: str | None = None
|
|
60
|
+
next_node: str | None = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class Node(Protocol):
|
|
64
|
+
"""图节点协议(只要求名字与执行方法)。"""
|
|
65
|
+
|
|
66
|
+
name: str
|
|
67
|
+
|
|
68
|
+
async def run(self, ctx: WorkflowContext, state: dict[str, Any]) -> NodeOutcome: ...
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class FunctionNode:
|
|
72
|
+
"""纯函数节点:读 state、算输出;异步函数直接 await,同步函数原样调用。"""
|
|
73
|
+
|
|
74
|
+
def __init__(
|
|
75
|
+
self,
|
|
76
|
+
name: str,
|
|
77
|
+
func: Callable[[dict[str, Any]], Any],
|
|
78
|
+
*,
|
|
79
|
+
output_key: str = "output",
|
|
80
|
+
) -> None:
|
|
81
|
+
self.name = name
|
|
82
|
+
self.func = func
|
|
83
|
+
self.output_key = output_key
|
|
84
|
+
|
|
85
|
+
async def run(self, ctx: WorkflowContext, state: dict[str, Any]) -> NodeOutcome:
|
|
86
|
+
value = self.func(state)
|
|
87
|
+
if inspect.isawaitable(value):
|
|
88
|
+
value = await value
|
|
89
|
+
state[self.output_key] = value
|
|
90
|
+
return NodeOutcome(output=value)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AgentNode:
|
|
94
|
+
"""Agent 节点:子 run 挂到根 run 下,结论文本写回 state。
|
|
95
|
+
|
|
96
|
+
handoff_targets 非空时给 agent 附加对应的 handoff 工具(控制权转移的登记入口);
|
|
97
|
+
input_fn 缺省读 state["input"] 并 str() 化;session 缺省为新鲜会话(子 agent 上下文
|
|
98
|
+
隔离),给了就复用。
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
def __init__(
|
|
102
|
+
self,
|
|
103
|
+
agent: Agent,
|
|
104
|
+
*,
|
|
105
|
+
name: str | None = None,
|
|
106
|
+
input_fn: Callable[[dict[str, Any]], str] | None = None,
|
|
107
|
+
output_key: str = "output",
|
|
108
|
+
deps: Any = None,
|
|
109
|
+
session: Session | None = None,
|
|
110
|
+
handoff_targets: Sequence[Agent] = (),
|
|
111
|
+
) -> None:
|
|
112
|
+
self.agent = agent
|
|
113
|
+
self.name = name or agent.name
|
|
114
|
+
self.input_fn = input_fn
|
|
115
|
+
self.output_key = output_key
|
|
116
|
+
self.deps = deps
|
|
117
|
+
self.session = session
|
|
118
|
+
self.handoff_targets = tuple(handoff_targets)
|
|
119
|
+
|
|
120
|
+
async def run(self, ctx: WorkflowContext, state: dict[str, Any]) -> NodeOutcome:
|
|
121
|
+
agent = self.agent
|
|
122
|
+
if self.handoff_targets:
|
|
123
|
+
agent = with_tools(
|
|
124
|
+
agent, [handoff_tool(target, ctx) for target in self.handoff_targets]
|
|
125
|
+
)
|
|
126
|
+
value = self.input_fn(state) if self.input_fn is not None else state.get("input", "")
|
|
127
|
+
if not isinstance(value, str):
|
|
128
|
+
value = str(value)
|
|
129
|
+
result = await run_child(ctx, agent, value, deps=self.deps, session=self.session)
|
|
130
|
+
text = text_of(result)
|
|
131
|
+
state[self.output_key] = text
|
|
132
|
+
return NodeOutcome(output=text, usage=result.usage, run_id=result.run_id)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class ParallelNode:
|
|
136
|
+
"""fan-out:分支并发执行(独立浅拷贝 state),按声明顺序 reducer 汇聚。"""
|
|
137
|
+
|
|
138
|
+
def __init__(
|
|
139
|
+
self,
|
|
140
|
+
name: str,
|
|
141
|
+
branches: Sequence[Node],
|
|
142
|
+
reducer: Callable[[list[Any]], Any],
|
|
143
|
+
*,
|
|
144
|
+
max_concurrency: int = 50,
|
|
145
|
+
output_key: str = "output",
|
|
146
|
+
) -> None:
|
|
147
|
+
if not branches:
|
|
148
|
+
raise WorkflowError(f"并行节点 {name} 至少需要一个分支")
|
|
149
|
+
if max_concurrency < 1:
|
|
150
|
+
raise WorkflowError("max_concurrency 必须 >= 1")
|
|
151
|
+
self.name = name
|
|
152
|
+
self.branches = tuple(branches)
|
|
153
|
+
self.reducer = reducer
|
|
154
|
+
self.max_concurrency = max_concurrency
|
|
155
|
+
self.output_key = output_key
|
|
156
|
+
|
|
157
|
+
async def run(self, ctx: WorkflowContext, state: dict[str, Any]) -> NodeOutcome:
|
|
158
|
+
semaphore = asyncio.Semaphore(self.max_concurrency)
|
|
159
|
+
|
|
160
|
+
async def run_branch(branch: Node) -> Any:
|
|
161
|
+
async with semaphore:
|
|
162
|
+
# 浅拷贝隔离并发分支;分支对拷贝的写入被丢弃——只有输出经 reducer 聚合,
|
|
163
|
+
# 汇聚结果由本节点统一写回 state,分支间不会互相覆盖
|
|
164
|
+
branch_state = dict(state)
|
|
165
|
+
outcome = await branch.run(ctx, branch_state)
|
|
166
|
+
return outcome.output
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
outputs = await asyncio.gather(*(run_branch(branch) for branch in self.branches))
|
|
170
|
+
except Exception as exc:
|
|
171
|
+
raise WorkflowError(
|
|
172
|
+
f"并行节点 {self.name} 分支失败:{type(exc).__name__}: {exc}"
|
|
173
|
+
) from exc
|
|
174
|
+
merged = self.reducer(list(outputs))
|
|
175
|
+
state[self.output_key] = merged
|
|
176
|
+
return NodeOutcome(output=merged)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class Workflow:
|
|
180
|
+
"""图执行器:节点 / 边 / 条件边 + 根 run 用量归集。"""
|
|
181
|
+
|
|
182
|
+
def __init__(
|
|
183
|
+
self,
|
|
184
|
+
name: str = "workflow",
|
|
185
|
+
*,
|
|
186
|
+
runner: Runner,
|
|
187
|
+
max_steps: int = 1000,
|
|
188
|
+
) -> None:
|
|
189
|
+
self.name = name
|
|
190
|
+
self.runner = runner
|
|
191
|
+
self.max_steps = max_steps
|
|
192
|
+
self._nodes: dict[str, Node] = {}
|
|
193
|
+
self._order: list[str] = []
|
|
194
|
+
self._edges: dict[str, str] = {}
|
|
195
|
+
self._routers: dict[str, Router] = {}
|
|
196
|
+
self._entry: str | None = None
|
|
197
|
+
|
|
198
|
+
# ---------------------------------------------------------------- 构图
|
|
199
|
+
|
|
200
|
+
def add_node(self, node: Node) -> Workflow:
|
|
201
|
+
if node.name in self._nodes:
|
|
202
|
+
raise WorkflowError(f"节点名重复:{node.name}")
|
|
203
|
+
self._nodes[node.name] = node
|
|
204
|
+
self._order.append(node.name)
|
|
205
|
+
if self._entry is None:
|
|
206
|
+
self._entry = node.name
|
|
207
|
+
return self
|
|
208
|
+
|
|
209
|
+
def add_function(
|
|
210
|
+
self, name: str, func: Callable[[dict[str, Any]], Any], *, output_key: str = "output"
|
|
211
|
+
) -> Workflow:
|
|
212
|
+
return self.add_node(FunctionNode(name, func, output_key=output_key))
|
|
213
|
+
|
|
214
|
+
def add_agent(
|
|
215
|
+
self,
|
|
216
|
+
agent: Agent,
|
|
217
|
+
*,
|
|
218
|
+
name: str | None = None,
|
|
219
|
+
input_fn: Callable[[dict[str, Any]], str] | None = None,
|
|
220
|
+
output_key: str = "output",
|
|
221
|
+
deps: Any = None,
|
|
222
|
+
session: Session | None = None,
|
|
223
|
+
handoff_targets: Sequence[Agent] = (),
|
|
224
|
+
) -> Workflow:
|
|
225
|
+
return self.add_node(
|
|
226
|
+
AgentNode(
|
|
227
|
+
agent,
|
|
228
|
+
name=name,
|
|
229
|
+
input_fn=input_fn,
|
|
230
|
+
output_key=output_key,
|
|
231
|
+
deps=deps,
|
|
232
|
+
session=session,
|
|
233
|
+
handoff_targets=handoff_targets,
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
def add_parallel(
|
|
238
|
+
self,
|
|
239
|
+
name: str,
|
|
240
|
+
branches: Sequence[Node],
|
|
241
|
+
reducer: Callable[[list[Any]], Any],
|
|
242
|
+
*,
|
|
243
|
+
max_concurrency: int = 50,
|
|
244
|
+
output_key: str = "output",
|
|
245
|
+
) -> Workflow:
|
|
246
|
+
return self.add_node(
|
|
247
|
+
ParallelNode(
|
|
248
|
+
name,
|
|
249
|
+
branches,
|
|
250
|
+
reducer,
|
|
251
|
+
max_concurrency=max_concurrency,
|
|
252
|
+
output_key=output_key,
|
|
253
|
+
)
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
def add_edge(self, source: str, target: str) -> Workflow:
|
|
257
|
+
self._edges[source] = target
|
|
258
|
+
return self
|
|
259
|
+
|
|
260
|
+
def add_conditional_edge(self, source: str, router: Router) -> Workflow:
|
|
261
|
+
self._routers[source] = router
|
|
262
|
+
return self
|
|
263
|
+
|
|
264
|
+
def set_entry(self, name: str) -> Workflow:
|
|
265
|
+
self._entry = name
|
|
266
|
+
return self
|
|
267
|
+
|
|
268
|
+
# ---------------------------------------------------------------- 执行
|
|
269
|
+
|
|
270
|
+
async def run(self, workflow_input: str, *, deps: Any = None) -> WorkflowResult:
|
|
271
|
+
"""执行整张图:输入写入 state["input"];执行期间挂 contextvar,结束(含异常)恢复。"""
|
|
272
|
+
if self._entry is None:
|
|
273
|
+
raise WorkflowError("工作流没有任何节点")
|
|
274
|
+
self._validate()
|
|
275
|
+
ctx = WorkflowContext(runner=self.runner, deps=deps)
|
|
276
|
+
token = set_context(ctx)
|
|
277
|
+
try:
|
|
278
|
+
return await self._run(ctx, workflow_input)
|
|
279
|
+
finally:
|
|
280
|
+
reset_context(token)
|
|
281
|
+
|
|
282
|
+
async def _run(self, ctx: WorkflowContext, workflow_input: str) -> WorkflowResult:
|
|
283
|
+
state: dict[str, Any] = {"input": workflow_input}
|
|
284
|
+
current: str | None = self._entry
|
|
285
|
+
last_output: Any = None
|
|
286
|
+
path: list[str] = []
|
|
287
|
+
steps = 0
|
|
288
|
+
|
|
289
|
+
while current is not None:
|
|
290
|
+
if current not in self._nodes:
|
|
291
|
+
raise WorkflowError(
|
|
292
|
+
f"路由到未知节点 {current};已走路径:{' -> '.join(path) or '(空)'}"
|
|
293
|
+
)
|
|
294
|
+
steps += 1
|
|
295
|
+
if steps > self.max_steps:
|
|
296
|
+
raise WorkflowError(
|
|
297
|
+
f"工作流超过 {self.max_steps} 步仍未结束,疑似死循环;路径:{' -> '.join(path)}"
|
|
298
|
+
)
|
|
299
|
+
path.append(current)
|
|
300
|
+
outcome = await self._nodes[current].run(ctx, state)
|
|
301
|
+
last_output = outcome.output
|
|
302
|
+
ctx.node_outputs[current] = outcome.output
|
|
303
|
+
|
|
304
|
+
handoff = ctx.consume_handoff()
|
|
305
|
+
if handoff is not None:
|
|
306
|
+
target, message = handoff
|
|
307
|
+
ctx.handoffs.append((current, target.name))
|
|
308
|
+
result = await run_child(ctx, target, message)
|
|
309
|
+
last_output = text_of(result)
|
|
310
|
+
state["output"] = last_output
|
|
311
|
+
ctx.node_outputs[f"{current}->{target.name}"] = last_output
|
|
312
|
+
break # 控制权已转移:调用者终答作废,以目标结论收尾
|
|
313
|
+
|
|
314
|
+
current = await self._next_node(current, outcome, state)
|
|
315
|
+
|
|
316
|
+
return WorkflowResult(
|
|
317
|
+
run_id=ctx.root_run_id,
|
|
318
|
+
output=last_output,
|
|
319
|
+
state=state,
|
|
320
|
+
usage=ctx.usage,
|
|
321
|
+
node_outputs=dict(ctx.node_outputs),
|
|
322
|
+
agent_run_ids=list(ctx.agent_run_ids),
|
|
323
|
+
handoffs=list(ctx.handoffs),
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
async def _next_node(
|
|
327
|
+
self, current: str, outcome: NodeOutcome, state: dict[str, Any]
|
|
328
|
+
) -> str | None:
|
|
329
|
+
if outcome.next_node is not None:
|
|
330
|
+
return outcome.next_node
|
|
331
|
+
router = self._routers.get(current)
|
|
332
|
+
if router is not None:
|
|
333
|
+
target = router(state)
|
|
334
|
+
if inspect.isawaitable(target):
|
|
335
|
+
target = await target
|
|
336
|
+
return target
|
|
337
|
+
if current in self._edges:
|
|
338
|
+
return self._edges[current]
|
|
339
|
+
index = self._order.index(current)
|
|
340
|
+
return self._order[index + 1] if index + 1 < len(self._order) else None
|
|
341
|
+
|
|
342
|
+
def _validate(self) -> None:
|
|
343
|
+
assert self._entry is not None
|
|
344
|
+
if self._entry not in self._nodes:
|
|
345
|
+
raise WorkflowError(f"入口节点 {self._entry} 不存在")
|
|
346
|
+
for source, target in self._edges.items():
|
|
347
|
+
if source not in self._nodes or target not in self._nodes:
|
|
348
|
+
raise WorkflowError(f"边 {source} -> {target} 引用了不存在的节点")
|
|
349
|
+
for source in self._routers:
|
|
350
|
+
if source not in self._nodes:
|
|
351
|
+
raise WorkflowError(f"条件边挂在不存在的节点:{source}")
|
|
File without changes
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Supervisor:一个调度 agent + 若干 worker,用 handoff 做控制权转移。
|
|
2
|
+
|
|
3
|
+
与 agents-as-tools 的差别(T4-2 设计小节):
|
|
4
|
+
|
|
5
|
+
- 委托(agent_as_tool):worker 在调用者的 run 内部执行,结果回填成工具输出,主 run 继续;
|
|
6
|
+
- handoff(本模块):调度 agent 只做决策,**worker 拿到控制权后独立执行**,调度 agent 的
|
|
7
|
+
终答不进入结果;worker 结论再交回调度 agent 进行下一轮判断,直到调度 agent 不再转交。
|
|
8
|
+
|
|
9
|
+
所有子 run 都经 core Runner(`RunConfig.parent_run_id = 根 run`),用量归集到
|
|
10
|
+
`SupervisorResult.usage`;worker 不带会话,避免跨专家上下文污染。
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from collections.abc import Sequence
|
|
16
|
+
from dataclasses import dataclass, field
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
from mainspring.agent import Agent
|
|
20
|
+
from mainspring.runner import Runner
|
|
21
|
+
from mainspring.types import Usage
|
|
22
|
+
|
|
23
|
+
from .context import (
|
|
24
|
+
WorkflowContext,
|
|
25
|
+
handoff_tool,
|
|
26
|
+
reset_context,
|
|
27
|
+
run_child,
|
|
28
|
+
set_context,
|
|
29
|
+
text_of,
|
|
30
|
+
with_tools,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
__all__ = ["Supervisor", "SupervisorResult"]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class SupervisorResult:
|
|
38
|
+
"""Supervisor 出口:最终结论 + 归集用量 + 委派记录。"""
|
|
39
|
+
|
|
40
|
+
run_id: str
|
|
41
|
+
output: str
|
|
42
|
+
usage: Usage
|
|
43
|
+
rounds: int
|
|
44
|
+
worker_runs: list[tuple[str, str]] = field(default_factory=list)
|
|
45
|
+
handoffs: list[tuple[str, str]] = field(default_factory=list)
|
|
46
|
+
exhausted: bool = False
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Supervisor:
|
|
50
|
+
"""调度 agent + workers:决策交给模型,执行交给 core Runner。
|
|
51
|
+
|
|
52
|
+
每轮给调度 agent 附加指向各 worker 的 handoff 工具后跑一遍;它调用 handoff 就执行
|
|
53
|
+
对应 worker,结论拼进下一轮 prompt;不再转交即收尾。max_rounds 是硬上限:轮次用尽
|
|
54
|
+
仍想转交时标记 exhausted 并以最后一轮 worker 结论收尾,不报错也不挂住。
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(
|
|
58
|
+
self,
|
|
59
|
+
supervisor: Agent,
|
|
60
|
+
workers: Sequence[Agent],
|
|
61
|
+
*,
|
|
62
|
+
runner: Runner,
|
|
63
|
+
max_rounds: int = 5,
|
|
64
|
+
deps: Any = None,
|
|
65
|
+
) -> None:
|
|
66
|
+
if not workers:
|
|
67
|
+
raise ValueError("Supervisor 至少需要一个 worker")
|
|
68
|
+
if max_rounds < 1:
|
|
69
|
+
raise ValueError("max_rounds 必须 >= 1")
|
|
70
|
+
self.supervisor = supervisor
|
|
71
|
+
self.workers = tuple(workers)
|
|
72
|
+
self.runner = runner
|
|
73
|
+
self.max_rounds = max_rounds
|
|
74
|
+
self.deps = deps
|
|
75
|
+
|
|
76
|
+
async def run(self, task: str) -> SupervisorResult:
|
|
77
|
+
ctx = WorkflowContext(runner=self.runner, deps=self.deps)
|
|
78
|
+
token = set_context(ctx)
|
|
79
|
+
try:
|
|
80
|
+
return await self._run(ctx, task)
|
|
81
|
+
finally:
|
|
82
|
+
reset_context(token)
|
|
83
|
+
|
|
84
|
+
async def _run(self, ctx: WorkflowContext, task: str) -> SupervisorResult:
|
|
85
|
+
dispatcher = with_tools(
|
|
86
|
+
self.supervisor, [handoff_tool(worker, ctx) for worker in self.workers]
|
|
87
|
+
)
|
|
88
|
+
transcript: list[tuple[str, str]] = []
|
|
89
|
+
output = ""
|
|
90
|
+
rounds = 0
|
|
91
|
+
exhausted = False
|
|
92
|
+
|
|
93
|
+
for _ in range(self.max_rounds):
|
|
94
|
+
rounds += 1
|
|
95
|
+
result = await run_child(ctx, dispatcher, _prompt(task, transcript))
|
|
96
|
+
output = text_of(result)
|
|
97
|
+
handoff = ctx.consume_handoff()
|
|
98
|
+
if handoff is None:
|
|
99
|
+
break
|
|
100
|
+
target, message = handoff
|
|
101
|
+
ctx.handoffs.append((self.supervisor.name, target.name))
|
|
102
|
+
worker_result = await run_child(ctx, target, message)
|
|
103
|
+
worker_text = text_of(worker_result)
|
|
104
|
+
transcript.append((target.name, worker_text))
|
|
105
|
+
output = worker_text
|
|
106
|
+
else:
|
|
107
|
+
exhausted = True # 轮次用尽仍想转交:以最后一轮 worker 结论收尾
|
|
108
|
+
|
|
109
|
+
return SupervisorResult(
|
|
110
|
+
run_id=ctx.root_run_id,
|
|
111
|
+
output=output,
|
|
112
|
+
usage=ctx.usage,
|
|
113
|
+
rounds=rounds,
|
|
114
|
+
worker_runs=transcript,
|
|
115
|
+
handoffs=list(ctx.handoffs),
|
|
116
|
+
exhausted=exhausted,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _prompt(task: str, transcript: list[tuple[str, str]]) -> str:
|
|
121
|
+
"""首轮直接给任务;之后把已完成委派的 (worker, 结论) 拼进 prompt,供调度 agent
|
|
122
|
+
判断继续转交还是收尾。
|
|
123
|
+
"""
|
|
124
|
+
if not transcript:
|
|
125
|
+
return task
|
|
126
|
+
lines = ["", "已完成的委派(可用于判断是否收尾):"]
|
|
127
|
+
lines.extend(f"- {name}:{text}" for name, text in transcript)
|
|
128
|
+
return f"{task}\n" + "\n".join(lines)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mainspring-workflow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Graph orchestration for mainspring: sequential nodes, parallel fan-out, supervisor routing, and handoff.
|
|
5
|
+
Author: mainspring contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
18
|
+
Requires-Dist: mainspring-agent
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Project-URL: Homepage, https://github.com/chyong/mainspring
|
|
21
|
+
Project-URL: Documentation, https://github.com/chyong/mainspring/tree/main/docs
|
|
22
|
+
Project-URL: Repository, https://github.com/chyong/mainspring
|
|
23
|
+
Project-URL: Issues, https://github.com/chyong/mainspring/issues
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# mainspring-workflow
|
|
27
|
+
|
|
28
|
+
图编排与多 agent 外挂(T4-2):条件节点、并行 fan-out + reducer、supervisor、
|
|
29
|
+
agents-as-tools(委托)与 handoff(控制权转移)。只复用 core 的 Runner / Session / Hook / Tracing。
|
|
30
|
+
|
|
31
|
+
## 设计小节
|
|
32
|
+
|
|
33
|
+
1. 工作流不是第二套 runtime:节点准备输入 → 调 core `Runner.run`;会话/Hook/追踪全部随 Agent 与 Runner 走。
|
|
34
|
+
2. 根 run 虚拟 `wf_<hex>`;子 run 用 `RunConfig.parent_run_id` 挂回根,OTel 父子与用量归集的唯一接缝。
|
|
35
|
+
3. fan-out 分支各拿浅拷贝 state,`asyncio.gather` + 信号量(默认 50),reducer 按声明顺序聚合。
|
|
36
|
+
4. 路由优先级:节点显式 next > 条件边 router > 静态边 > 隐式插入顺序;`max_steps` 防死循环。
|
|
37
|
+
5. agents-as-tools = 委托取结果(专家独立会话、只带自己的工具,结论回填主线)。
|
|
38
|
+
6. handoff = 控制权转移(工具只登记,编排层执行目标并丢弃调用者终答)。
|
|
39
|
+
7. 子 agent 挂起(待审批)时工作流显式报错,不把 pending 当结论。
|
|
40
|
+
|
|
41
|
+
## fan-out + reducer
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from mainspring_workflow import FunctionNode, Workflow
|
|
45
|
+
|
|
46
|
+
wf = Workflow(runner=runner)
|
|
47
|
+
wf.add_parallel(
|
|
48
|
+
"research",
|
|
49
|
+
[FunctionNode(f"source-{i}", lambda state, i=i: state["input"] + f" via {i}") for i in range(50)],
|
|
50
|
+
reducer=lambda outs: "\n".join(outs),
|
|
51
|
+
)
|
|
52
|
+
result = await wf.run("调研主题")
|
|
53
|
+
print(result.usage) # 所有分支用量归集到根
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## supervisor
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from mainspring_workflow import Supervisor
|
|
60
|
+
|
|
61
|
+
result = await Supervisor(dispatcher, [search_agent, writer_agent], runner=runner, max_rounds=5).run(task)
|
|
62
|
+
# result.worker_runs / result.handoffs 可审计;调度 agent 的终答只在它不再转交时生效
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 委托与 handoff
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from mainspring_workflow import agent_as_tool, handoff_tool
|
|
69
|
+
|
|
70
|
+
parent = Agent(..., tools=[agent_as_tool(expert)]) # 委托:结论回到主线
|
|
71
|
+
caller = Agent(..., tools=[handoff_tool(expert)]) # 转移:调用者终答作废
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
验收覆盖(`tests/test_workflow.py`):条件路由、50 路并发 barrier、Session/Hook/Tracing 复用、
|
|
75
|
+
parent_run_id 全事件注入、Usage 归集、专家上下文隔离、handoff 覆盖终答、supervisor 轮次、循环护栏。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
mainspring_workflow/__init__.py,sha256=8hHCKWzFjd5-OkOVKgI2zv-_04C0MV_d6gIoR2fdB4M,1737
|
|
2
|
+
mainspring_workflow/context.py,sha256=irKaSHZ50SYOhtAR1JZruNnjDst0IEneAPhwnBkH49k,8823
|
|
3
|
+
mainspring_workflow/graph.py,sha256=kCIo6sUPqkEALJHk0rbHwfJOzukXg3N1z11AQIeyBe8,12242
|
|
4
|
+
mainspring_workflow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
mainspring_workflow/supervisor.py,sha256=LU0TpR2WkmRI_B58JocT3PzGEY_P8EDw--B3UfC9DwE,4371
|
|
6
|
+
mainspring_workflow-0.1.0.dist-info/licenses/LICENSE,sha256=wRDF_w9CNQSolm8Pjiu3W13uQJ7Iw2K00IrirvJepqY,1080
|
|
7
|
+
mainspring_workflow-0.1.0.dist-info/WHEEL,sha256=wfHFB5CQ4yOA68LQ_ISeFjKJGxj2GfVzMH9QxkYgrCw,81
|
|
8
|
+
mainspring_workflow-0.1.0.dist-info/METADATA,sha256=hjhGtWR6NWqcD6d-6QUi5G2i5RQqCfAd49g0u-3TV9k,3330
|
|
9
|
+
mainspring_workflow-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mainspring contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|