workflow-exec-engine 0.0.9__tar.gz → 0.1.1__tar.gz
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.
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/LICENSE +17 -17
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/MANIFEST.in +4 -4
- {workflow_exec_engine-0.0.9/workflow_exec_engine.egg-info → workflow_exec_engine-0.1.1}/PKG-INFO +206 -161
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/README.md +169 -124
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/README_en.md +17 -2
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/examples/execute_psop_demo.py +48 -48
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/examples/quickstart.py +65 -65
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/pyproject.toml +7 -2
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/requirements.txt +3 -3
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/setup.cfg +4 -4
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/__init__.py +74 -74
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/__init__.py +40 -38
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/a2a_transport.py +512 -340
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/agentcard_normalizer.py +100 -100
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/auth_manager.py +126 -114
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/auth_provider.py +42 -42
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/credential_crypto.py +133 -114
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/credential_service.py +197 -186
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/engine_client.py +169 -24
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/env_file_loader.py +79 -68
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/extension_interceptor.py +58 -58
- workflow_exec_engine-0.1.1/workflow_engine/client/extension_sender.py +442 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/extensions.py +36 -36
- workflow_exec_engine-0.1.1/workflow_engine/client/protocol_logger.py +120 -0
- workflow_exec_engine-0.1.1/workflow_engine/client/remote_error.py +145 -0
- workflow_exec_engine-0.1.1/workflow_engine/client/sensitive_data.py +65 -0
- workflow_exec_engine-0.1.1/workflow_engine/client/sse_normalization.py +95 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/ssl_context.py +77 -48
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/stub_engine_client.py +45 -45
- workflow_exec_engine-0.1.1/workflow_engine/client/transport_activity.py +122 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/control/__init__.py +25 -25
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/control/control_points.py +89 -89
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/core/__init__.py +31 -31
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/core/context_builder.py +48 -48
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/core/executor.py +10 -4
- workflow_exec_engine-0.1.1/workflow_engine/core/failure_mapping.py +91 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/core/models.py +16 -2
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/core/workflow_validator.py +92 -92
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/registry/__init__.py +22 -21
- workflow_exec_engine-0.1.1/workflow_engine/registry/http_auth.py +268 -0
- workflow_exec_engine-0.1.1/workflow_engine/registry/registry_client.py +355 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/runner.py +217 -211
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1/workflow_exec_engine.egg-info}/PKG-INFO +206 -161
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_exec_engine.egg-info/SOURCES.txt +4 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_exec_engine.egg-info/requires.txt +1 -1
- workflow_exec_engine-0.0.9/workflow_engine/client/extension_sender.py +0 -244
- workflow_exec_engine-0.0.9/workflow_engine/client/protocol_logger.py +0 -76
- workflow_exec_engine-0.0.9/workflow_engine/client/sse_normalization.py +0 -90
- workflow_exec_engine-0.0.9/workflow_engine/core/failure_mapping.py +0 -59
- workflow_exec_engine-0.0.9/workflow_engine/registry/registry_client.py +0 -165
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/a2at_messages.py +0 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_engine/client/protocol_interceptor.py +0 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_exec_engine.egg-info/dependency_links.txt +0 -0
- {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.1}/workflow_exec_engine.egg-info/top_level.txt +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
Copyright 2026 Huawei Technologies Co., Ltd.
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Huawei Technologies Co., Ltd.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
include README.md
|
|
2
|
-
include README_en.md
|
|
3
|
-
include requirements.txt
|
|
4
|
-
recursive-include examples *.py
|
|
1
|
+
include README.md
|
|
2
|
+
include README_en.md
|
|
3
|
+
include requirements.txt
|
|
4
|
+
recursive-include examples *.py
|
{workflow_exec_engine-0.0.9/workflow_exec_engine.egg-info → workflow_exec_engine-0.1.1}/PKG-INFO
RENAMED
|
@@ -1,161 +1,206 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: workflow-exec-engine
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Standalone workflow execution SDK for A2A-T multi-agent orchestration
|
|
5
|
-
Author-email: A2A SDK Team <ivo.zhou@huawei.com>
|
|
6
|
-
License-Expression: Apache-2.0
|
|
7
|
-
Project-URL: Homepage, https://github.com/project-openan/workflow-engine-sdk-python
|
|
8
|
-
Project-URL: Documentation, https://github.com/project-openan/workflow-engine-sdk-python#readme
|
|
9
|
-
Project-URL: Repository, https://github.com/project-openan/workflow-engine-sdk-python
|
|
10
|
-
Project-URL: Issues, https://github.com/project-openan/workflow-engine-sdk-python/issues
|
|
11
|
-
Project-URL: Changelog, https://github.com/project-openan/workflow-engine-sdk-python/blob/main/CHANGELOG.md
|
|
12
|
-
Keywords: a2a,agent,orchestration,workflow,sdk
|
|
13
|
-
Classifier: Development Status :: 2 - Pre-Alpha
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
-
Requires-Python: >=3.12
|
|
20
|
-
Description-Content-Type: text/markdown
|
|
21
|
-
License-File: LICENSE
|
|
22
|
-
Requires-Dist: a2a-sdk<2,>=1.1.2
|
|
23
|
-
Requires-Dist: a2a-t-sdk<2,>=1.0
|
|
24
|
-
Requires-Dist: httpx>=0.27.0
|
|
25
|
-
Requires-Dist: loguru>=0.7.0
|
|
26
|
-
Requires-Dist: protobuf>=4.25.0
|
|
27
|
-
Requires-Dist: packaging>=23.0
|
|
28
|
-
Requires-Dist: cryptography>=42.0.0
|
|
29
|
-
Provides-Extra: dev
|
|
30
|
-
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
31
|
-
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
32
|
-
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
33
|
-
Dynamic: license-file
|
|
34
|
-
|
|
35
|
-
# A2A-T Workflow Engine SDK(Python)
|
|
36
|
-
|
|
37
|
-
面向宿主智能体的嵌入式工作流执行引擎。引擎负责工作流 DAG、A2A 消息封装、任务与会话关联、远端任务等待、Negotiation-T 交互循环和生命周期;宿主负责业务输入解释、A2A-T 内容生成与语义校验,以及路由和协商决策。
|
|
38
|
-
|
|
39
|
-
Python 与 Java 版本遵循同一业务契约。Python 当前要求 Python 3.12+、`a2a-sdk>=1.1.2,<2` 和 `a2a-t-sdk>=1.0
|
|
40
|
-
|
|
41
|
-
## 安装
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
python -m pip install workflow-exec-engine
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
执行引擎直接使用最新版 A2A-T core 元数据类型识别协议,但不会调用 LLM,也不会替宿主生成或校验 Task-T、Negotiation-T、Authorization-T、Notification-T 的业务内容;这些内容操作仍由宿主调用 `a2a-t-sdk` 完成。
|
|
48
|
-
|
|
49
|
-
## 最小集成
|
|
50
|
-
|
|
51
|
-
```python
|
|
52
|
-
from a2a.types import Part
|
|
53
|
-
from a2a_t.client import A2ATClient
|
|
54
|
-
from a2a_t.core.standard_templates import PRIVATE_LINE_COMPLAINT_URI
|
|
55
|
-
from workflow_engine import (
|
|
56
|
-
A2ATransport, A2atMessages, ControlPoint, ExtensionSender,
|
|
57
|
-
MessageContent, NegotiationReply, RouteDecision, TaskResult,
|
|
58
|
-
WorkflowEngineClient, WorkflowExecutor,
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class BusinessCallbacks(ControlPoint):
|
|
63
|
-
async def on_task(self, request):
|
|
64
|
-
# a2a-t-sdk 负责内容生成;执行引擎只接收生成结果并发送。
|
|
65
|
-
generated = a2at.generate_task_prompt_from_text(
|
|
66
|
-
request.input.text,
|
|
67
|
-
PRIVATE_LINE_COMPLAINT_URI,
|
|
68
|
-
)
|
|
69
|
-
return A2atMessages.from_generated(
|
|
70
|
-
generated,
|
|
71
|
-
[Part(text=request.instruction)],
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
async def on_self_task(self, request):
|
|
75
|
-
outputs = aggregate(request.workflow_input.upstream_results)
|
|
76
|
-
return TaskResult.succeeded(outputs)
|
|
77
|
-
|
|
78
|
-
async def on_route(self, request):
|
|
79
|
-
# 每条非空条件边独立调用;允许多条边同时返回 true。
|
|
80
|
-
return RouteDecision.allow() if matches(request.condition) else RouteDecision.deny()
|
|
81
|
-
|
|
82
|
-
async def on_negotiation(self, request):
|
|
83
|
-
generated = generate_terminal_negotiation_reply_with_a2at(request)
|
|
84
|
-
return NegotiationReply.send(
|
|
85
|
-
A2atMessages.from_generated(generated, [Part(text="补充后的业务内容")])
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
a2at = A2ATClient(env_path=a2at_env_path)
|
|
90
|
-
transport = A2ATransport(agent_cards=agent_cards)
|
|
91
|
-
client = WorkflowEngineClient(transport)
|
|
92
|
-
result = await WorkflowExecutor(workflow, BusinessCallbacks(), client).run()
|
|
93
|
-
await transport.close()
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
`on_task` 不接收客户端对象,也不自行发送消息。这样业务代码只负责最终内容,引擎统一保证 A2A 信封、上下文 ID、远端任务 ID、协议头和后续协商仍属于同一次任务交互。
|
|
97
|
-
|
|
98
|
-
## 路由规则
|
|
99
|
-
|
|
100
|
-
- 空条件边:无需调用 `on_route`,默认放行。
|
|
101
|
-
- 非空条件边:每条边独立调用一次 `on_route(RouteRequest)`。
|
|
102
|
-
- 一个节点可激活 0 到 N 条后继边;全部拒绝表示该分支正常结束。
|
|
103
|
-
- 同一节点的全部条件判断完成后才调度后继节点;任一判断异常时不调度任何后继节点。
|
|
104
|
-
|
|
105
|
-
## 上游结果
|
|
106
|
-
|
|
107
|
-
引擎不再把前置结果拼成 `Runtime Context` Markdown。回调通过 `request.workflow_input` 获取:
|
|
108
|
-
|
|
109
|
-
- `runtime_intent`:本次执行的运行时意图;
|
|
110
|
-
- `upstream_results`:按步骤分组的上游任务结果;
|
|
111
|
-
- 每个任务结果包含有序 `outputs`、来源 Agent/skill、逻辑任务 ID、状态和安全错误信息。
|
|
112
|
-
|
|
113
|
-
工作流的 `context_from` 控制聚合范围:省略时使用直接前驱,`["*"]` 使用全部祖先,空列表表示不传上游结果,指定名称时仅传对应祖先步骤。
|
|
114
|
-
|
|
115
|
-
## 独立协议操作
|
|
116
|
-
|
|
117
|
-
Authorization-T 和 Notification-T
|
|
118
|
-
|
|
119
|
-
```python
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
await
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
await
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
await
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: workflow-exec-engine
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Standalone workflow execution SDK for A2A-T multi-agent orchestration
|
|
5
|
+
Author-email: A2A SDK Team <ivo.zhou@huawei.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/project-openan/workflow-engine-sdk-python
|
|
8
|
+
Project-URL: Documentation, https://github.com/project-openan/workflow-engine-sdk-python#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/project-openan/workflow-engine-sdk-python
|
|
10
|
+
Project-URL: Issues, https://github.com/project-openan/workflow-engine-sdk-python/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/project-openan/workflow-engine-sdk-python/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: a2a,agent,orchestration,workflow,sdk
|
|
13
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: a2a-sdk<2,>=1.1.2
|
|
23
|
+
Requires-Dist: a2a-t-sdk<2,>=1.2.0
|
|
24
|
+
Requires-Dist: httpx>=0.27.0
|
|
25
|
+
Requires-Dist: loguru>=0.7.0
|
|
26
|
+
Requires-Dist: protobuf>=4.25.0
|
|
27
|
+
Requires-Dist: packaging>=23.0
|
|
28
|
+
Requires-Dist: cryptography>=42.0.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# A2A-T Workflow Engine SDK(Python)
|
|
36
|
+
|
|
37
|
+
面向宿主智能体的嵌入式工作流执行引擎。引擎负责工作流 DAG、A2A 消息封装、任务与会话关联、远端任务等待、Negotiation-T 交互循环和生命周期;宿主负责业务输入解释、A2A-T 内容生成与语义校验,以及路由和协商决策。
|
|
38
|
+
|
|
39
|
+
Python 与 Java 版本遵循同一业务契约。Python 当前要求 Python 3.12+、`a2a-sdk>=1.1.2,<2` 和 `a2a-t-sdk>=1.2.0,<2`。
|
|
40
|
+
|
|
41
|
+
## 安装
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
python -m pip install workflow-exec-engine
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
执行引擎直接使用最新版 A2A-T core 元数据类型识别协议,但不会调用 LLM,也不会替宿主生成或校验 Task-T、Negotiation-T、Authorization-T、Notification-T 的业务内容;这些内容操作仍由宿主调用 `a2a-t-sdk` 完成。
|
|
48
|
+
|
|
49
|
+
## 最小集成
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from a2a.types import Part
|
|
53
|
+
from a2a_t.client import A2ATClient
|
|
54
|
+
from a2a_t.core.standard_templates import PRIVATE_LINE_COMPLAINT_URI
|
|
55
|
+
from workflow_engine import (
|
|
56
|
+
A2ATransport, A2atMessages, ControlPoint, ExtensionSender,
|
|
57
|
+
MessageContent, NegotiationReply, RouteDecision, TaskResult,
|
|
58
|
+
WorkflowEngineClient, WorkflowExecutor,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class BusinessCallbacks(ControlPoint):
|
|
63
|
+
async def on_task(self, request):
|
|
64
|
+
# a2a-t-sdk 负责内容生成;执行引擎只接收生成结果并发送。
|
|
65
|
+
generated = a2at.generate_task_prompt_from_text(
|
|
66
|
+
request.input.text,
|
|
67
|
+
PRIVATE_LINE_COMPLAINT_URI,
|
|
68
|
+
)
|
|
69
|
+
return A2atMessages.from_generated(
|
|
70
|
+
generated,
|
|
71
|
+
[Part(text=request.instruction)],
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
async def on_self_task(self, request):
|
|
75
|
+
outputs = aggregate(request.workflow_input.upstream_results)
|
|
76
|
+
return TaskResult.succeeded(outputs)
|
|
77
|
+
|
|
78
|
+
async def on_route(self, request):
|
|
79
|
+
# 每条非空条件边独立调用;允许多条边同时返回 true。
|
|
80
|
+
return RouteDecision.allow() if matches(request.condition) else RouteDecision.deny()
|
|
81
|
+
|
|
82
|
+
async def on_negotiation(self, request):
|
|
83
|
+
generated = generate_terminal_negotiation_reply_with_a2at(request)
|
|
84
|
+
return NegotiationReply.send(
|
|
85
|
+
A2atMessages.from_generated(generated, [Part(text="补充后的业务内容")])
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
a2at = A2ATClient(env_path=a2at_env_path)
|
|
90
|
+
transport = A2ATransport(agent_cards=agent_cards)
|
|
91
|
+
client = WorkflowEngineClient(transport)
|
|
92
|
+
result = await WorkflowExecutor(workflow, BusinessCallbacks(), client).run()
|
|
93
|
+
await transport.close()
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`on_task` 不接收客户端对象,也不自行发送消息。这样业务代码只负责最终内容,引擎统一保证 A2A 信封、上下文 ID、远端任务 ID、协议头和后续协商仍属于同一次任务交互。
|
|
97
|
+
|
|
98
|
+
## 路由规则
|
|
99
|
+
|
|
100
|
+
- 空条件边:无需调用 `on_route`,默认放行。
|
|
101
|
+
- 非空条件边:每条边独立调用一次 `on_route(RouteRequest)`。
|
|
102
|
+
- 一个节点可激活 0 到 N 条后继边;全部拒绝表示该分支正常结束。
|
|
103
|
+
- 同一节点的全部条件判断完成后才调度后继节点;任一判断异常时不调度任何后继节点。
|
|
104
|
+
|
|
105
|
+
## 上游结果
|
|
106
|
+
|
|
107
|
+
引擎不再把前置结果拼成 `Runtime Context` Markdown。回调通过 `request.workflow_input` 获取:
|
|
108
|
+
|
|
109
|
+
- `runtime_intent`:本次执行的运行时意图;
|
|
110
|
+
- `upstream_results`:按步骤分组的上游任务结果;
|
|
111
|
+
- 每个任务结果包含有序 `outputs`、来源 Agent/skill、逻辑任务 ID、状态和安全错误信息。
|
|
112
|
+
|
|
113
|
+
工作流的 `context_from` 控制聚合范围:省略时使用直接前驱,`["*"]` 使用全部祖先,空列表表示不传上游结果,指定名称时仅传对应祖先步骤。
|
|
114
|
+
|
|
115
|
+
## 独立协议操作
|
|
116
|
+
|
|
117
|
+
Authorization-T 和 Notification-T 不属于工作流因果链。工作流任务、一次性授权和长订阅应分别持有 `A2ATransport`;协议处理能力可以共用,但 HTTP 通道和生命周期不能共用:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
auth_transport = A2ATransport(agent_cards)
|
|
121
|
+
notification_transport = A2ATransport(agent_cards)
|
|
122
|
+
try:
|
|
123
|
+
authorization = await ExtensionSender(auth_transport).send_authorization(
|
|
124
|
+
agent_name, authorization_content,
|
|
125
|
+
)
|
|
126
|
+
finally:
|
|
127
|
+
await auth_transport.close() # 授权操作结束即释放,不影响订阅
|
|
128
|
+
|
|
129
|
+
subscription = ExtensionSender(notification_transport).open_notification(
|
|
130
|
+
agent_name, notification_content, on_notification,
|
|
131
|
+
)
|
|
132
|
+
try:
|
|
133
|
+
ack = await subscription.acknowledgement # 仅表示订阅已接受,流继续保持
|
|
134
|
+
# 单条通知结果不结束订阅;保持监听,直到明确取消、停机或流异常结束。
|
|
135
|
+
await subscription.completion
|
|
136
|
+
finally:
|
|
137
|
+
subscription.close()
|
|
138
|
+
await notification_transport.close()
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
授权或订阅失败不会自动阻断后续工作流。`send_authorization` 会等待授权任务到达终态,集成方通过 `is_success` 判断结果;订阅拒绝会让 `acknowledgement` 抛错,普通消息和 artifact 不算 ACK。订阅确认与长连接结束是两个不同 Future;业务任务终态不会自动关闭独立订阅,持续到达的 SSE 心跳可保持长连接存活。显式关闭、远端 EOF、空闲超时或传输异常会结束流。`heartbeat` 和 `is_healthy()` 可用于本地存活性判断。
|
|
142
|
+
|
|
143
|
+
## 远端任务管理
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
await client.get_task(agent_name, task_id)
|
|
147
|
+
page = await client.list_tasks(agent_name, list_tasks_request)
|
|
148
|
+
await client.cancel_task(agent_name, task_id)
|
|
149
|
+
await client.subscribe_to_task(agent_name, task_id, on_event)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
这些是标准 A2A 任务接口;取消任务不等同于 Negotiation-T Abort。
|
|
153
|
+
|
|
154
|
+
同一个 `WorkflowEngineClient` 同一时刻只能绑定一个工作流执行;并发执行应创建独立 client。协商在本地停止、超时、取消或协议校验失败时,引擎会对已知远端任务做有界的尽力取消,取消失败只记录日志,不覆盖原始错误。
|
|
155
|
+
|
|
156
|
+
## 认证与 TLS
|
|
157
|
+
|
|
158
|
+
`A2ATransport` 支持 AgentCard 声明的凭据配置、自定义 `AuthProvider`、自定义 CA、mTLS 客户端证书、CRL、协议偏好和发送超时。默认验证服务端证书;指定的证书文件缺失或无效时启动失败,不会静默降级为不校验。
|
|
159
|
+
|
|
160
|
+
仅受控开发环境可显式配置 `ssl_verify=False`。调用方传入的 `httpx.AsyncClient` 仍由调用方关闭;执行引擎只关闭自己创建的客户端资源。
|
|
161
|
+
|
|
162
|
+
管理面 HTTP 认证独立于 AgentCard 凭据。`load_psop` / `search_psop` 可共享一个
|
|
163
|
+
`OrchestrationAccountAuth`:首次请求登录 `/api/v1/auth/token`,缓存 Token,过期时续取,
|
|
164
|
+
被 401 拒绝后只重登重试一次。账号只用于指定中心的公开编排 API,不跟随重定向。
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
import os
|
|
168
|
+
from workflow_engine import OrchestrationAccountAuth, load_psop, search_psop
|
|
169
|
+
|
|
170
|
+
center = "https://center.example:5001"
|
|
171
|
+
auth = OrchestrationAccountAuth(
|
|
172
|
+
center, os.environ["HOST_ORCHESTRATION_USERNAME"],
|
|
173
|
+
os.environ["HOST_ORCHESTRATION_PASSWORD"],
|
|
174
|
+
)
|
|
175
|
+
options = dict(auth_provider=auth, ssl_verify=True, ca_certs_path="/run/secrets/center-ca.pem")
|
|
176
|
+
# 服务端要求 mTLS 时,额外传 client_cert_path / client_key_path;
|
|
177
|
+
# client_key_password 支持加密私钥。登录和业务请求使用同一套 TLS 身份。
|
|
178
|
+
matches = await search_psop(center, "诊断专线投诉", **options)
|
|
179
|
+
workflow = await load_psop(center, matches[0].workflow_id, **options)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
静态 Bearer 场景继续传 `access_token`,与 `auth_provider` 二选一;注册中心使用它自己的
|
|
183
|
+
Token 和 TLS 身份,不能复用中心账号或 Agent 登录凭据。
|
|
184
|
+
|
|
185
|
+
`RegistryClient(..., auth_provider=BearerAuth(token_supplier))` 可在每次请求时读取最新
|
|
186
|
+
Bearer Token;OAuth2 的申请、刷新由业务已有认证库完成,也可直接实现异步的
|
|
187
|
+
`HttpAuthProvider.headers(url, client)` 注入认证头。提供者可选实现
|
|
188
|
+
`invalidate(url, rejected_headers) -> bool`,返回 `True` 才允许 PSOP 查询/搜索在 401
|
|
189
|
+
后重试一次。注册中心操作不自动重放。认证头不允许重复名称、换行或覆盖 Host 等传输头。
|
|
190
|
+
中心地址支持部署路径前缀,账号令牌仍限定在该前缀下的公开编排 API。
|
|
191
|
+
|
|
192
|
+
源码版本现为 `0.1.1`,包含已发布 `0.1.0` 之后的主干修复。发布前可运行
|
|
193
|
+
`python -m build` 后安装 `dist/workflow_exec_engine-0.1.1-py3-none-any.whl`;
|
|
194
|
+
此说明不代表该版本已发布到 PyPI。
|
|
195
|
+
|
|
196
|
+
## 文档与验证
|
|
197
|
+
|
|
198
|
+
- [设计说明](DESIGN.md)
|
|
199
|
+
- [集成开发指南](DEVELOPER_GUIDE.md)
|
|
200
|
+
- [英文 README](README_en.md)
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
python -m pip install -e ".[dev]"
|
|
204
|
+
python -m pytest -q
|
|
205
|
+
python -m build
|
|
206
|
+
```
|