workflow-exec-engine 0.0.9__tar.gz → 0.1.0__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.
Files changed (45) hide show
  1. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/LICENSE +17 -17
  2. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/MANIFEST.in +4 -4
  3. {workflow_exec_engine-0.0.9/workflow_exec_engine.egg-info → workflow_exec_engine-0.1.0}/PKG-INFO +161 -161
  4. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/README.md +123 -123
  5. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/examples/execute_psop_demo.py +48 -48
  6. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/examples/quickstart.py +65 -65
  7. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/pyproject.toml +1 -1
  8. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/requirements.txt +2 -2
  9. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/setup.cfg +4 -4
  10. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/__init__.py +74 -74
  11. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/__init__.py +36 -36
  12. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/a2a_transport.py +322 -322
  13. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/agentcard_normalizer.py +100 -100
  14. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/auth_manager.py +112 -112
  15. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/auth_provider.py +42 -42
  16. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/credential_crypto.py +114 -114
  17. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/credential_service.py +180 -180
  18. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/env_file_loader.py +68 -68
  19. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/extension_interceptor.py +58 -58
  20. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/extensions.py +36 -36
  21. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/sse_normalization.py +90 -90
  22. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/ssl_context.py +48 -48
  23. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/stub_engine_client.py +45 -45
  24. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/control/__init__.py +25 -25
  25. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/control/control_points.py +89 -89
  26. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/core/__init__.py +31 -31
  27. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/core/context_builder.py +48 -48
  28. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/core/workflow_validator.py +92 -92
  29. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/registry/__init__.py +21 -21
  30. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/registry/registry_client.py +132 -132
  31. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/runner.py +211 -211
  32. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0/workflow_exec_engine.egg-info}/PKG-INFO +161 -161
  33. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/README_en.md +0 -0
  34. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/a2at_messages.py +0 -0
  35. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/engine_client.py +0 -0
  36. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/extension_sender.py +0 -0
  37. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/protocol_interceptor.py +0 -0
  38. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/client/protocol_logger.py +0 -0
  39. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/core/executor.py +0 -0
  40. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/core/failure_mapping.py +0 -0
  41. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_engine/core/models.py +0 -0
  42. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_exec_engine.egg-info/SOURCES.txt +0 -0
  43. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_exec_engine.egg-info/dependency_links.txt +0 -0
  44. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/workflow_exec_engine.egg-info/requires.txt +0 -0
  45. {workflow_exec_engine-0.0.9 → workflow_exec_engine-0.1.0}/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
@@ -1,161 +1,161 @@
1
- Metadata-Version: 2.4
2
- Name: workflow-exec-engine
3
- Version: 0.0.9
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.9
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.9,<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` 和 `ExtensionSender`:
118
-
119
- ```python
120
- sender = ExtensionSender(independent_transport)
121
- authorization = await sender.send_authorization(agent_name, authorization_content)
122
-
123
- subscription = sender.open_notification(agent_name, notification_content, on_notification)
124
- ack = await subscription.acknowledgement
125
- # 收到业务结果后由集成方显式关闭:
126
- subscription.close()
127
- await subscription.completion
128
- ```
129
-
130
- 授权或订阅失败不会自动阻断后续工作流。`send_authorization` 会等待授权任务到达终态,集成方通过 `is_success` 判断结果;订阅确认通过 `is_failure` 排除失败、拒绝或取消。订阅确认与长连接结束是两个不同 Future;`heartbeat` 和 `is_healthy()` 可用于本地存活性判断。
131
-
132
- ## 远端任务管理
133
-
134
- ```python
135
- await client.get_task(agent_name, task_id)
136
- page = await client.list_tasks(agent_name, list_tasks_request)
137
- await client.cancel_task(agent_name, task_id)
138
- await client.subscribe_to_task(agent_name, task_id, on_event)
139
- ```
140
-
141
- 这些是标准 A2A 任务接口;取消任务不等同于 Negotiation-T Abort。
142
-
143
- 同一个 `WorkflowEngineClient` 同一时刻只能绑定一个工作流执行;并发执行应创建独立 client。协商在本地停止、超时、取消或协议校验失败时,引擎会对已知远端任务做有界的尽力取消,取消失败只记录日志,不覆盖原始错误。
144
-
145
- ## 认证与 TLS
146
-
147
- `A2ATransport` 支持 AgentCard 声明的凭据配置、自定义 `AuthProvider`、自定义 CA、mTLS 客户端证书、CRL、协议偏好和发送超时。默认验证服务端证书;指定的证书文件缺失或无效时启动失败,不会静默降级为不校验。
148
-
149
- 仅受控开发环境可显式配置 `ssl_verify=False`。调用方传入的 `httpx.AsyncClient` 仍由调用方关闭;执行引擎只关闭自己创建的客户端资源。
150
-
151
- ## 文档与验证
152
-
153
- - [设计说明](DESIGN.md)
154
- - [集成开发指南](DEVELOPER_GUIDE.md)
155
- - [英文 README](README_en.md)
156
-
157
- ```bash
158
- python -m pip install -e ".[dev]"
159
- python -m pytest -q
160
- python -m build
161
- ```
1
+ Metadata-Version: 2.4
2
+ Name: workflow-exec-engine
3
+ Version: 0.1.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.9
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.9,<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` 和 `ExtensionSender`:
118
+
119
+ ```python
120
+ sender = ExtensionSender(independent_transport)
121
+ authorization = await sender.send_authorization(agent_name, authorization_content)
122
+
123
+ subscription = sender.open_notification(agent_name, notification_content, on_notification)
124
+ ack = await subscription.acknowledgement
125
+ # 收到业务结果后由集成方显式关闭:
126
+ subscription.close()
127
+ await subscription.completion
128
+ ```
129
+
130
+ 授权或订阅失败不会自动阻断后续工作流。`send_authorization` 会等待授权任务到达终态,集成方通过 `is_success` 判断结果;订阅确认通过 `is_failure` 排除失败、拒绝或取消。订阅确认与长连接结束是两个不同 Future;`heartbeat` 和 `is_healthy()` 可用于本地存活性判断。
131
+
132
+ ## 远端任务管理
133
+
134
+ ```python
135
+ await client.get_task(agent_name, task_id)
136
+ page = await client.list_tasks(agent_name, list_tasks_request)
137
+ await client.cancel_task(agent_name, task_id)
138
+ await client.subscribe_to_task(agent_name, task_id, on_event)
139
+ ```
140
+
141
+ 这些是标准 A2A 任务接口;取消任务不等同于 Negotiation-T Abort。
142
+
143
+ 同一个 `WorkflowEngineClient` 同一时刻只能绑定一个工作流执行;并发执行应创建独立 client。协商在本地停止、超时、取消或协议校验失败时,引擎会对已知远端任务做有界的尽力取消,取消失败只记录日志,不覆盖原始错误。
144
+
145
+ ## 认证与 TLS
146
+
147
+ `A2ATransport` 支持 AgentCard 声明的凭据配置、自定义 `AuthProvider`、自定义 CA、mTLS 客户端证书、CRL、协议偏好和发送超时。默认验证服务端证书;指定的证书文件缺失或无效时启动失败,不会静默降级为不校验。
148
+
149
+ 仅受控开发环境可显式配置 `ssl_verify=False`。调用方传入的 `httpx.AsyncClient` 仍由调用方关闭;执行引擎只关闭自己创建的客户端资源。
150
+
151
+ ## 文档与验证
152
+
153
+ - [设计说明](DESIGN.md)
154
+ - [集成开发指南](DEVELOPER_GUIDE.md)
155
+ - [英文 README](README_en.md)
156
+
157
+ ```bash
158
+ python -m pip install -e ".[dev]"
159
+ python -m pytest -q
160
+ python -m build
161
+ ```
@@ -1,127 +1,127 @@
1
- # A2A-T Workflow Engine SDK(Python)
2
-
3
- 面向宿主智能体的嵌入式工作流执行引擎。引擎负责工作流 DAG、A2A 消息封装、任务与会话关联、远端任务等待、Negotiation-T 交互循环和生命周期;宿主负责业务输入解释、A2A-T 内容生成与语义校验,以及路由和协商决策。
4
-
1
+ # A2A-T Workflow Engine SDK(Python)
2
+
3
+ 面向宿主智能体的嵌入式工作流执行引擎。引擎负责工作流 DAG、A2A 消息封装、任务与会话关联、远端任务等待、Negotiation-T 交互循环和生命周期;宿主负责业务输入解释、A2A-T 内容生成与语义校验,以及路由和协商决策。
4
+
5
5
  Python 与 Java 版本遵循同一业务契约。Python 当前要求 Python 3.12+、`a2a-sdk>=1.1.2,<2` 和 `a2a-t-sdk>=1.0.9,<2`。
6
-
7
- ## 安装
8
-
9
- ```bash
10
- python -m pip install workflow-exec-engine
11
- ```
12
-
13
- 执行引擎直接使用最新版 A2A-T core 元数据类型识别协议,但不会调用 LLM,也不会替宿主生成或校验 Task-T、Negotiation-T、Authorization-T、Notification-T 的业务内容;这些内容操作仍由宿主调用 `a2a-t-sdk` 完成。
14
-
15
- ## 最小集成
16
-
17
- ```python
18
- from a2a.types import Part
19
- from a2a_t.client import A2ATClient
20
- from a2a_t.core.standard_templates import PRIVATE_LINE_COMPLAINT_URI
21
- from workflow_engine import (
22
- A2ATransport, A2atMessages, ControlPoint, ExtensionSender,
23
- MessageContent, NegotiationReply, RouteDecision, TaskResult,
24
- WorkflowEngineClient, WorkflowExecutor,
25
- )
26
-
27
-
28
- class BusinessCallbacks(ControlPoint):
29
- async def on_task(self, request):
30
- # a2a-t-sdk 负责内容生成;执行引擎只接收生成结果并发送。
31
- generated = a2at.generate_task_prompt_from_text(
32
- request.input.text,
33
- PRIVATE_LINE_COMPLAINT_URI,
34
- )
35
- return A2atMessages.from_generated(
36
- generated,
37
- [Part(text=request.instruction)],
38
- )
39
-
40
- async def on_self_task(self, request):
41
- outputs = aggregate(request.workflow_input.upstream_results)
42
- return TaskResult.succeeded(outputs)
43
-
44
- async def on_route(self, request):
45
- # 每条非空条件边独立调用;允许多条边同时返回 true。
46
- return RouteDecision.allow() if matches(request.condition) else RouteDecision.deny()
47
-
48
- async def on_negotiation(self, request):
49
- generated = generate_terminal_negotiation_reply_with_a2at(request)
50
- return NegotiationReply.send(
51
- A2atMessages.from_generated(generated, [Part(text="补充后的业务内容")])
52
- )
53
-
54
-
55
- a2at = A2ATClient(env_path=a2at_env_path)
56
- transport = A2ATransport(agent_cards=agent_cards)
57
- client = WorkflowEngineClient(transport)
58
- result = await WorkflowExecutor(workflow, BusinessCallbacks(), client).run()
59
- await transport.close()
60
- ```
61
-
62
- `on_task` 不接收客户端对象,也不自行发送消息。这样业务代码只负责最终内容,引擎统一保证 A2A 信封、上下文 ID、远端任务 ID、协议头和后续协商仍属于同一次任务交互。
63
-
64
- ## 路由规则
65
-
66
- - 空条件边:无需调用 `on_route`,默认放行。
67
- - 非空条件边:每条边独立调用一次 `on_route(RouteRequest)`。
68
- - 一个节点可激活 0 到 N 条后继边;全部拒绝表示该分支正常结束。
69
- - 同一节点的全部条件判断完成后才调度后继节点;任一判断异常时不调度任何后继节点。
70
-
71
- ## 上游结果
72
-
73
- 引擎不再把前置结果拼成 `Runtime Context` Markdown。回调通过 `request.workflow_input` 获取:
74
-
75
- - `runtime_intent`:本次执行的运行时意图;
76
- - `upstream_results`:按步骤分组的上游任务结果;
77
- - 每个任务结果包含有序 `outputs`、来源 Agent/skill、逻辑任务 ID、状态和安全错误信息。
78
-
79
- 工作流的 `context_from` 控制聚合范围:省略时使用直接前驱,`["*"]` 使用全部祖先,空列表表示不传上游结果,指定名称时仅传对应祖先步骤。
80
-
81
- ## 独立协议操作
82
-
83
- Authorization-T 和 Notification-T 不属于工作流因果链,应使用独立 `A2ATransport` 和 `ExtensionSender`:
84
-
85
- ```python
86
- sender = ExtensionSender(independent_transport)
87
- authorization = await sender.send_authorization(agent_name, authorization_content)
88
-
89
- subscription = sender.open_notification(agent_name, notification_content, on_notification)
90
- ack = await subscription.acknowledgement
91
- # 收到业务结果后由集成方显式关闭:
92
- subscription.close()
93
- await subscription.completion
94
- ```
95
-
96
- 授权或订阅失败不会自动阻断后续工作流。`send_authorization` 会等待授权任务到达终态,集成方通过 `is_success` 判断结果;订阅确认通过 `is_failure` 排除失败、拒绝或取消。订阅确认与长连接结束是两个不同 Future;`heartbeat` 和 `is_healthy()` 可用于本地存活性判断。
97
-
98
- ## 远端任务管理
99
-
100
- ```python
101
- await client.get_task(agent_name, task_id)
102
- page = await client.list_tasks(agent_name, list_tasks_request)
103
- await client.cancel_task(agent_name, task_id)
104
- await client.subscribe_to_task(agent_name, task_id, on_event)
105
- ```
106
-
107
- 这些是标准 A2A 任务接口;取消任务不等同于 Negotiation-T Abort。
108
-
109
- 同一个 `WorkflowEngineClient` 同一时刻只能绑定一个工作流执行;并发执行应创建独立 client。协商在本地停止、超时、取消或协议校验失败时,引擎会对已知远端任务做有界的尽力取消,取消失败只记录日志,不覆盖原始错误。
110
-
111
- ## 认证与 TLS
112
-
113
- `A2ATransport` 支持 AgentCard 声明的凭据配置、自定义 `AuthProvider`、自定义 CA、mTLS 客户端证书、CRL、协议偏好和发送超时。默认验证服务端证书;指定的证书文件缺失或无效时启动失败,不会静默降级为不校验。
114
-
115
- 仅受控开发环境可显式配置 `ssl_verify=False`。调用方传入的 `httpx.AsyncClient` 仍由调用方关闭;执行引擎只关闭自己创建的客户端资源。
116
-
117
- ## 文档与验证
118
-
119
- - [设计说明](DESIGN.md)
120
- - [集成开发指南](DEVELOPER_GUIDE.md)
121
- - [英文 README](README_en.md)
122
-
123
- ```bash
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ python -m pip install workflow-exec-engine
11
+ ```
12
+
13
+ 执行引擎直接使用最新版 A2A-T core 元数据类型识别协议,但不会调用 LLM,也不会替宿主生成或校验 Task-T、Negotiation-T、Authorization-T、Notification-T 的业务内容;这些内容操作仍由宿主调用 `a2a-t-sdk` 完成。
14
+
15
+ ## 最小集成
16
+
17
+ ```python
18
+ from a2a.types import Part
19
+ from a2a_t.client import A2ATClient
20
+ from a2a_t.core.standard_templates import PRIVATE_LINE_COMPLAINT_URI
21
+ from workflow_engine import (
22
+ A2ATransport, A2atMessages, ControlPoint, ExtensionSender,
23
+ MessageContent, NegotiationReply, RouteDecision, TaskResult,
24
+ WorkflowEngineClient, WorkflowExecutor,
25
+ )
26
+
27
+
28
+ class BusinessCallbacks(ControlPoint):
29
+ async def on_task(self, request):
30
+ # a2a-t-sdk 负责内容生成;执行引擎只接收生成结果并发送。
31
+ generated = a2at.generate_task_prompt_from_text(
32
+ request.input.text,
33
+ PRIVATE_LINE_COMPLAINT_URI,
34
+ )
35
+ return A2atMessages.from_generated(
36
+ generated,
37
+ [Part(text=request.instruction)],
38
+ )
39
+
40
+ async def on_self_task(self, request):
41
+ outputs = aggregate(request.workflow_input.upstream_results)
42
+ return TaskResult.succeeded(outputs)
43
+
44
+ async def on_route(self, request):
45
+ # 每条非空条件边独立调用;允许多条边同时返回 true。
46
+ return RouteDecision.allow() if matches(request.condition) else RouteDecision.deny()
47
+
48
+ async def on_negotiation(self, request):
49
+ generated = generate_terminal_negotiation_reply_with_a2at(request)
50
+ return NegotiationReply.send(
51
+ A2atMessages.from_generated(generated, [Part(text="补充后的业务内容")])
52
+ )
53
+
54
+
55
+ a2at = A2ATClient(env_path=a2at_env_path)
56
+ transport = A2ATransport(agent_cards=agent_cards)
57
+ client = WorkflowEngineClient(transport)
58
+ result = await WorkflowExecutor(workflow, BusinessCallbacks(), client).run()
59
+ await transport.close()
60
+ ```
61
+
62
+ `on_task` 不接收客户端对象,也不自行发送消息。这样业务代码只负责最终内容,引擎统一保证 A2A 信封、上下文 ID、远端任务 ID、协议头和后续协商仍属于同一次任务交互。
63
+
64
+ ## 路由规则
65
+
66
+ - 空条件边:无需调用 `on_route`,默认放行。
67
+ - 非空条件边:每条边独立调用一次 `on_route(RouteRequest)`。
68
+ - 一个节点可激活 0 到 N 条后继边;全部拒绝表示该分支正常结束。
69
+ - 同一节点的全部条件判断完成后才调度后继节点;任一判断异常时不调度任何后继节点。
70
+
71
+ ## 上游结果
72
+
73
+ 引擎不再把前置结果拼成 `Runtime Context` Markdown。回调通过 `request.workflow_input` 获取:
74
+
75
+ - `runtime_intent`:本次执行的运行时意图;
76
+ - `upstream_results`:按步骤分组的上游任务结果;
77
+ - 每个任务结果包含有序 `outputs`、来源 Agent/skill、逻辑任务 ID、状态和安全错误信息。
78
+
79
+ 工作流的 `context_from` 控制聚合范围:省略时使用直接前驱,`["*"]` 使用全部祖先,空列表表示不传上游结果,指定名称时仅传对应祖先步骤。
80
+
81
+ ## 独立协议操作
82
+
83
+ Authorization-T 和 Notification-T 不属于工作流因果链,应使用独立 `A2ATransport` 和 `ExtensionSender`:
84
+
85
+ ```python
86
+ sender = ExtensionSender(independent_transport)
87
+ authorization = await sender.send_authorization(agent_name, authorization_content)
88
+
89
+ subscription = sender.open_notification(agent_name, notification_content, on_notification)
90
+ ack = await subscription.acknowledgement
91
+ # 收到业务结果后由集成方显式关闭:
92
+ subscription.close()
93
+ await subscription.completion
94
+ ```
95
+
96
+ 授权或订阅失败不会自动阻断后续工作流。`send_authorization` 会等待授权任务到达终态,集成方通过 `is_success` 判断结果;订阅确认通过 `is_failure` 排除失败、拒绝或取消。订阅确认与长连接结束是两个不同 Future;`heartbeat` 和 `is_healthy()` 可用于本地存活性判断。
97
+
98
+ ## 远端任务管理
99
+
100
+ ```python
101
+ await client.get_task(agent_name, task_id)
102
+ page = await client.list_tasks(agent_name, list_tasks_request)
103
+ await client.cancel_task(agent_name, task_id)
104
+ await client.subscribe_to_task(agent_name, task_id, on_event)
105
+ ```
106
+
107
+ 这些是标准 A2A 任务接口;取消任务不等同于 Negotiation-T Abort。
108
+
109
+ 同一个 `WorkflowEngineClient` 同一时刻只能绑定一个工作流执行;并发执行应创建独立 client。协商在本地停止、超时、取消或协议校验失败时,引擎会对已知远端任务做有界的尽力取消,取消失败只记录日志,不覆盖原始错误。
110
+
111
+ ## 认证与 TLS
112
+
113
+ `A2ATransport` 支持 AgentCard 声明的凭据配置、自定义 `AuthProvider`、自定义 CA、mTLS 客户端证书、CRL、协议偏好和发送超时。默认验证服务端证书;指定的证书文件缺失或无效时启动失败,不会静默降级为不校验。
114
+
115
+ 仅受控开发环境可显式配置 `ssl_verify=False`。调用方传入的 `httpx.AsyncClient` 仍由调用方关闭;执行引擎只关闭自己创建的客户端资源。
116
+
117
+ ## 文档与验证
118
+
119
+ - [设计说明](DESIGN.md)
120
+ - [集成开发指南](DEVELOPER_GUIDE.md)
121
+ - [英文 README](README_en.md)
122
+
123
+ ```bash
124
124
  python -m pip install -e ".[dev]"
125
- python -m pytest -q
125
+ python -m pytest -q
126
126
  python -m build
127
127
  ```