hegemony-steps-flow 0.46.1__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.
- hegemony_steps_flow/__init__.py +35 -0
- hegemony_steps_flow/docs/flow.notify.md +51 -0
- hegemony_steps_flow/docs/flow.run.md +69 -0
- hegemony_steps_flow/notify.py +300 -0
- hegemony_steps_flow/run.py +441 -0
- hegemony_steps_flow-0.46.1.dist-info/METADATA +27 -0
- hegemony_steps_flow-0.46.1.dist-info/RECORD +10 -0
- hegemony_steps_flow-0.46.1.dist-info/WHEEL +4 -0
- hegemony_steps_flow-0.46.1.dist-info/entry_points.txt +3 -0
- hegemony_steps_flow-0.46.1.dist-info/licenses/LICENSE-AGPL-3.0-or-later.txt +235 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025-2026 Rexonix s.r.o.
|
|
2
|
+
# SPDX-FileContributor: Jakub Trávník <jakub.travnik@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
|
|
6
|
+
"""Flow orchestration step handlers for Hegemony.
|
|
7
|
+
|
|
8
|
+
Platform-orchestration steps: launch nested flow runs and send on-demand
|
|
9
|
+
notifications.
|
|
10
|
+
|
|
11
|
+
Registers under the ``hegemony.step_handlers`` entry-point group; the entry
|
|
12
|
+
point name is the claimed handler-id namespace prefix (``flow``).
|
|
13
|
+
Handlers reach every platform facility through ``ctx.services``.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from hegemony_step_sdk import BaseHandler, StepHandlerRegistry
|
|
19
|
+
|
|
20
|
+
from .notify import SendNotificationHandler
|
|
21
|
+
from .run import RunFlowHandler
|
|
22
|
+
|
|
23
|
+
ALL_HANDLERS: tuple[type[BaseHandler], ...] = (
|
|
24
|
+
RunFlowHandler,
|
|
25
|
+
SendNotificationHandler,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def register(registry: StepHandlerRegistry) -> None:
|
|
30
|
+
"""Entry point: register this wheel's handlers with the host registry."""
|
|
31
|
+
for handler_class in ALL_HANDLERS:
|
|
32
|
+
registry.register_handler_type(handler_class)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__all__ = ["ALL_HANDLERS", "register", *sorted(cls.__name__ for cls in ALL_HANDLERS)]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
SPDX-FileCopyrightText: 2025-2026 Rexonix s.r.o.
|
|
3
|
+
SPDX-FileContributor: Jakub Trávník <jakub.travnik@gmail.com>
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
# Send Notification
|
|
9
|
+
|
|
10
|
+
`flow.notify` sends a custom notification from the middle of a flow to one
|
|
11
|
+
of the platform's configured notification destinations (Slack, Teams, and
|
|
12
|
+
similar). Use it to announce milestones, results, or hand-off points while
|
|
13
|
+
the run is still going, with a title and message you write yourself.
|
|
14
|
+
|
|
15
|
+
## Using It
|
|
16
|
+
|
|
17
|
+
Notification Destination is the only required field: pick one of the
|
|
18
|
+
destinations already configured on the platform. The step looks the
|
|
19
|
+
destination up at run time, so a destination that has since been removed or
|
|
20
|
+
disabled fails the step.
|
|
21
|
+
|
|
22
|
+
Title and Message are templates edited with the notification-template
|
|
23
|
+
editor. Unlike ordinary step config they are not resolved by the step
|
|
24
|
+
engine; the notification renderer evaluates them with the full notification
|
|
25
|
+
context — `run.*` values, the event name, the UI base URL, target lines,
|
|
26
|
+
the outputs of preceding steps under `steps.*`, plus `secret()`, `env()`,
|
|
27
|
+
and flow variables. A blank Title or Message falls back to the shared
|
|
28
|
+
default notification template for that part.
|
|
29
|
+
|
|
30
|
+
Besides delivering the notification, the step records a run event noting
|
|
31
|
+
the destination and whether the send succeeded, so on-demand notifications
|
|
32
|
+
show up in the run's event log.
|
|
33
|
+
|
|
34
|
+
## Output
|
|
35
|
+
|
|
36
|
+
The step returns no chainable output keys. Once a send is
|
|
37
|
+
attempted, it records a `notification_result` evidence artifact holding
|
|
38
|
+
the destination id and name, the rendered title, whether the send
|
|
39
|
+
succeeded, and the error text when it did not, and metrics record `sent`
|
|
40
|
+
and `failed` — one of them 1, the other 0. Failures before dispatch (no
|
|
41
|
+
destination configured, or the destination cannot be fetched) return only
|
|
42
|
+
the step error, with no metrics and no evidence.
|
|
43
|
+
|
|
44
|
+
## When It Fails
|
|
45
|
+
|
|
46
|
+
The step fails when no destination is configured, when the destination
|
|
47
|
+
cannot be fetched (unknown or disabled, an API error, or a 30-second
|
|
48
|
+
timeout while looking it up), or when handing the rendered notification to
|
|
49
|
+
the destination's provider raises an error — the provider's error text
|
|
50
|
+
becomes the step error. A send the provider accepts succeeds; failure to
|
|
51
|
+
write the informational run event is logged but never fails the step.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
SPDX-FileCopyrightText: 2025-2026 Rexonix s.r.o.
|
|
3
|
+
SPDX-FileContributor: Jakub Trávník <jakub.travnik@gmail.com>
|
|
4
|
+
|
|
5
|
+
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
# Run Flow
|
|
9
|
+
|
|
10
|
+
`flow.run` launches another committed flow as a child run of the current
|
|
11
|
+
flow. Pick the child flow, map its input fields and target roles, and the
|
|
12
|
+
step starts the run; by default it then waits until the child finishes and
|
|
13
|
+
succeeds or fails with it, making the child flow's outputs available to
|
|
14
|
+
later steps.
|
|
15
|
+
|
|
16
|
+
## Using It
|
|
17
|
+
|
|
18
|
+
Select the child flow either by id or by name — exactly one of the two must
|
|
19
|
+
be set. Selecting by name resolves to the newest flow with that name at
|
|
20
|
+
launch time, which keeps imported flow bundles portable. Version pins a
|
|
21
|
+
specific committed version of the child flow; omitted, the latest committed
|
|
22
|
+
version runs.
|
|
23
|
+
|
|
24
|
+
Field mappings feed the child flow's input fields: each field either keeps
|
|
25
|
+
the child's default, receives a literal value, or receives a template that
|
|
26
|
+
is resolved with this flow's context before the child starts. A template
|
|
27
|
+
that is a single expression keeps its value's type, so a run input that is
|
|
28
|
+
false, empty, a number or null reaches the child as such. Target
|
|
29
|
+
mappings bind the child's target roles — each role uses mode child_default,
|
|
30
|
+
parent_role (forwarding the devices this run bound to a chosen parent
|
|
31
|
+
role), or none. Both mappings are edited with the dedicated run-flow
|
|
32
|
+
widget.
|
|
33
|
+
|
|
34
|
+
The child run is named after the parent run plus a short random suffix
|
|
35
|
+
unless Child run name sets an explicit name. With Wait for completion on
|
|
36
|
+
(the default), the step polls the child run at the configured poll interval
|
|
37
|
+
(1-60 seconds, default 5) until it reaches SUCCESS, FAILED, or CANCELLED
|
|
38
|
+
and mirrors that result. With waiting off, the step succeeds as soon as the
|
|
39
|
+
child run is created and does not track it further. The default step
|
|
40
|
+
timeout is 2 hours; if the step is cancelled or times out while waiting,
|
|
41
|
+
the handler asks the platform to cancel the child run as well.
|
|
42
|
+
|
|
43
|
+
A template in Version, Wait for completion or Poll interval is read as that
|
|
44
|
+
setting's type once rendered: `3` pins version 3, and `false` turns waiting
|
|
45
|
+
off.
|
|
46
|
+
|
|
47
|
+
## Output
|
|
48
|
+
|
|
49
|
+
Later steps can read `steps.NODE_ID.output.child_run_id`,
|
|
50
|
+
`steps.NODE_ID.output.child_workflow_id`, `steps.NODE_ID.output.child_status`, and
|
|
51
|
+
`steps.NODE_ID.output.waited`. Without waiting, the reported status is
|
|
52
|
+
`PENDING`. When the step waited and the child succeeded, the child flow's
|
|
53
|
+
evaluated outputs land under `steps.NODE_ID.output.outputs`, one key per child
|
|
54
|
+
flow output. Metrics record `child_run_count` (always 1) and, when the step
|
|
55
|
+
waited, `wait_seconds`; a polling error that fails the step records no
|
|
56
|
+
metrics. Progress events carry the child run id while the
|
|
57
|
+
step starts and waits; no evidence artifacts are produced.
|
|
58
|
+
|
|
59
|
+
## When It Fails
|
|
60
|
+
|
|
61
|
+
The step fails before starting anything when the configuration is invalid:
|
|
62
|
+
both or neither of flow id and flow name set, a malformed flow id, a bad
|
|
63
|
+
version, a poll interval outside 1-60 seconds, or field/target mapping
|
|
64
|
+
entries missing a valid mode or a required value. It fails when the platform rejects creating the child run, and —
|
|
65
|
+
while waiting — when polling the child errors out (the reported status is
|
|
66
|
+
then `UNKNOWN`) or the child run ends FAILED or CANCELLED, in which case
|
|
67
|
+
the child's error message becomes the step error. A child that succeeds but
|
|
68
|
+
whose outputs cannot be evaluated also fails the step. With Wait for
|
|
69
|
+
completion off, nothing that happens to the child later affects this step.
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025-2026 Rexonix s.r.o.
|
|
2
|
+
# SPDX-FileContributor: Jakub Trávník <jakub.travnik@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
|
|
6
|
+
"""SendNotificationHandler: send on-demand notifications from worker."""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
12
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
13
|
+
|
|
14
|
+
from hegemony_step_sdk import (
|
|
15
|
+
BaseHandler,
|
|
16
|
+
HandlerContext,
|
|
17
|
+
HandlerResult,
|
|
18
|
+
HandlerTargeting,
|
|
19
|
+
StepKind,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SendNotificationConfig(BaseModel):
|
|
26
|
+
"""Config for ``flow.notify``.
|
|
27
|
+
|
|
28
|
+
``title``/``message`` are raw notification templates rendered by this
|
|
29
|
+
handler's own JIT renderer (see ``raw_config_keys``); the editor manages
|
|
30
|
+
them with a dedicated notification-template editor, so only the
|
|
31
|
+
destination is schema-driven.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
model_config = ConfigDict(extra="allow")
|
|
35
|
+
|
|
36
|
+
destination_id: str = Field(
|
|
37
|
+
min_length=1,
|
|
38
|
+
title="Notification Destination",
|
|
39
|
+
description="Where to send the notification (Slack, Teams, etc.)",
|
|
40
|
+
json_schema_extra={
|
|
41
|
+
"x_widget": "destination-select",
|
|
42
|
+
"x_placeholder": "Select destination...",
|
|
43
|
+
"x_col_span": 2,
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
title: str = Field(
|
|
47
|
+
default="",
|
|
48
|
+
title="Title",
|
|
49
|
+
description=(
|
|
50
|
+
"Notification title template, rendered by the notification "
|
|
51
|
+
"renderer with the full notification context (run values, step "
|
|
52
|
+
"outputs, secret()/env() helpers). Leave empty to use the shared "
|
|
53
|
+
"default title template."
|
|
54
|
+
),
|
|
55
|
+
json_schema_extra={"x_hidden": True},
|
|
56
|
+
)
|
|
57
|
+
message: str = Field(
|
|
58
|
+
default="",
|
|
59
|
+
title="Message",
|
|
60
|
+
description=(
|
|
61
|
+
"Notification body template, rendered by the notification "
|
|
62
|
+
"renderer with the full notification context (run values, step "
|
|
63
|
+
"outputs, secret()/env() helpers). Leave empty to use the shared "
|
|
64
|
+
"default body template."
|
|
65
|
+
),
|
|
66
|
+
json_schema_extra={"x_hidden": True},
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class SendNotificationHandler(BaseHandler):
|
|
71
|
+
"""Handler for sending on-demand notifications to configured destinations.
|
|
72
|
+
|
|
73
|
+
This allows flows to send custom notifications at any point, using
|
|
74
|
+
existing notification destinations but with custom messages.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
handler_id = "flow.notify"
|
|
78
|
+
supported_kinds = [StepKind.ACTION]
|
|
79
|
+
display_name = "Send Notification"
|
|
80
|
+
description = "Send an on-demand notification to a configured destination."
|
|
81
|
+
category = "Notifications"
|
|
82
|
+
targeting = HandlerTargeting(roles=False, ips=False)
|
|
83
|
+
config_model = SendNotificationConfig
|
|
84
|
+
|
|
85
|
+
# title/message are notification templates rendered by this handler with the
|
|
86
|
+
# notification context (run.*, event, ui_base_url, target_lines, steps, plus
|
|
87
|
+
# secret()/env()/vars). Keep them raw so the strict step engine does not try
|
|
88
|
+
# to resolve notification vars it does not know about.
|
|
89
|
+
raw_config_keys = frozenset({"title", "message"})
|
|
90
|
+
|
|
91
|
+
async def execute(self, ctx: HandlerContext) -> HandlerResult:
|
|
92
|
+
"""Send a notification to the configured destination."""
|
|
93
|
+
services = ctx.require_services()
|
|
94
|
+
|
|
95
|
+
destination_id = ctx.config.get("destination_id")
|
|
96
|
+
if not destination_id:
|
|
97
|
+
return HandlerResult(
|
|
98
|
+
success=False,
|
|
99
|
+
error="Missing required config: destination_id",
|
|
100
|
+
summary="No notification destination specified",
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# title/message are RAW templates (see raw_config_keys); collect the ones
|
|
104
|
+
# the user set as per-step overrides over the shared default templates.
|
|
105
|
+
override: dict[str, str] = {}
|
|
106
|
+
title_template = ctx.config.get("title")
|
|
107
|
+
if isinstance(title_template, str) and title_template.strip():
|
|
108
|
+
override["title"] = title_template
|
|
109
|
+
message_template = ctx.config.get("message")
|
|
110
|
+
if isinstance(message_template, str) and message_template.strip():
|
|
111
|
+
override["body"] = message_template
|
|
112
|
+
|
|
113
|
+
# Fetch destination info from API
|
|
114
|
+
try:
|
|
115
|
+
async with services.open_api_client(timeout=30) as client:
|
|
116
|
+
response = await client.get(
|
|
117
|
+
f"/internal/notification-destinations/{destination_id}",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
if response.status_code == 404:
|
|
121
|
+
return HandlerResult(
|
|
122
|
+
success=False,
|
|
123
|
+
error="Notification destination not found or disabled",
|
|
124
|
+
summary="Invalid destination",
|
|
125
|
+
)
|
|
126
|
+
elif response.status_code != 200:
|
|
127
|
+
return HandlerResult(
|
|
128
|
+
success=False,
|
|
129
|
+
error=f"API error fetching destination: {response.status_code}",
|
|
130
|
+
summary="Failed to fetch destination",
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
dest_data = response.json()
|
|
134
|
+
|
|
135
|
+
# Validate required keys in destination response
|
|
136
|
+
required_keys = {"id", "name", "type", "config_json"}
|
|
137
|
+
missing = required_keys - dest_data.keys()
|
|
138
|
+
if missing:
|
|
139
|
+
return HandlerResult(
|
|
140
|
+
success=False,
|
|
141
|
+
error=f"Destination response missing keys: {missing}",
|
|
142
|
+
summary="Invalid destination data from API",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
except httpx.TimeoutException:
|
|
146
|
+
return HandlerResult(
|
|
147
|
+
success=False,
|
|
148
|
+
error="Timeout fetching destination info",
|
|
149
|
+
summary="Timeout fetching destination",
|
|
150
|
+
)
|
|
151
|
+
except Exception as e:
|
|
152
|
+
logger.error(
|
|
153
|
+
f"Error fetching destination: run_id={ctx.run_id}, step_id={ctx.step_id}, error={e}"
|
|
154
|
+
)
|
|
155
|
+
return HandlerResult(
|
|
156
|
+
success=False,
|
|
157
|
+
error=str(e),
|
|
158
|
+
summary="Error fetching destination info",
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Render title/body via the notification single-JIT renderer: per-step
|
|
162
|
+
# overrides over the shared defaults, with the full notification context
|
|
163
|
+
# (run.*, event, ui_base_url, target_lines), preceding step outputs, and
|
|
164
|
+
# secret()/env()/vars resolution -- all in one pass.
|
|
165
|
+
run_context = {
|
|
166
|
+
"id": ctx.run_id,
|
|
167
|
+
"name": ctx.run_name,
|
|
168
|
+
"flow_name": ctx.flow_name,
|
|
169
|
+
"status": "running",
|
|
170
|
+
}
|
|
171
|
+
title, rendered_message = await services.format_run_notification(
|
|
172
|
+
"notification.sent",
|
|
173
|
+
run_context=run_context,
|
|
174
|
+
overrides=override or None,
|
|
175
|
+
steps=ctx.step_outputs or None,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Dispatch notification directly from worker
|
|
179
|
+
try:
|
|
180
|
+
await services.dispatch_notification(
|
|
181
|
+
destination_type=dest_data["type"],
|
|
182
|
+
destination_config=dest_data["config_json"],
|
|
183
|
+
title=title,
|
|
184
|
+
body=rendered_message,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
logger.info(
|
|
188
|
+
f"On-demand notification sent: run_id={ctx.run_id}, step_id={ctx.step_id}, "
|
|
189
|
+
f"destination={dest_data['name']}, type={dest_data['type']}"
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
await self._emit_notification_event(
|
|
193
|
+
ctx=ctx,
|
|
194
|
+
destination_name=dest_data["name"],
|
|
195
|
+
sent=1,
|
|
196
|
+
failed=0,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
return HandlerResult(
|
|
200
|
+
success=True,
|
|
201
|
+
summary="Notification sent successfully",
|
|
202
|
+
metrics={"sent": 1, "failed": 0},
|
|
203
|
+
evidence=[
|
|
204
|
+
{
|
|
205
|
+
"kind": "step_result",
|
|
206
|
+
"name": "notification_result",
|
|
207
|
+
"content_json": {
|
|
208
|
+
"destination_id": destination_id,
|
|
209
|
+
"destination_name": dest_data["name"],
|
|
210
|
+
"title": title,
|
|
211
|
+
"sent": True,
|
|
212
|
+
},
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
except Exception as e:
|
|
218
|
+
error_msg = str(e)
|
|
219
|
+
logger.warning(
|
|
220
|
+
f"On-demand notification failed: run_id={ctx.run_id}, step_id={ctx.step_id}, "
|
|
221
|
+
f"destination={dest_data['name']}, error={e}"
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
await self._emit_notification_event(
|
|
225
|
+
ctx=ctx,
|
|
226
|
+
destination_name=dest_data["name"],
|
|
227
|
+
sent=0,
|
|
228
|
+
failed=1,
|
|
229
|
+
error=error_msg,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
return HandlerResult(
|
|
233
|
+
success=False,
|
|
234
|
+
error=f"Notification failed: {error_msg}",
|
|
235
|
+
summary="Failed to send notification",
|
|
236
|
+
metrics={"sent": 0, "failed": 1},
|
|
237
|
+
evidence=[
|
|
238
|
+
{
|
|
239
|
+
"kind": "step_result",
|
|
240
|
+
"name": "notification_result",
|
|
241
|
+
"content_json": {
|
|
242
|
+
"destination_id": destination_id,
|
|
243
|
+
"destination_name": dest_data.get("name", "Unknown"),
|
|
244
|
+
"title": title,
|
|
245
|
+
"sent": False,
|
|
246
|
+
"error": error_msg,
|
|
247
|
+
},
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
async def _emit_notification_event(
|
|
253
|
+
self,
|
|
254
|
+
ctx: HandlerContext,
|
|
255
|
+
destination_name: str,
|
|
256
|
+
sent: int,
|
|
257
|
+
failed: int,
|
|
258
|
+
error: str | None = None,
|
|
259
|
+
) -> None:
|
|
260
|
+
"""Emit a run event for an on-demand notification send."""
|
|
261
|
+
message = (
|
|
262
|
+
f"Notification sent to {destination_name}"
|
|
263
|
+
if failed == 0
|
|
264
|
+
else f"Notification failed to {destination_name}"
|
|
265
|
+
)
|
|
266
|
+
attrs: dict[str, Any] = {
|
|
267
|
+
"event": "flow.notify",
|
|
268
|
+
"destination": destination_name,
|
|
269
|
+
"sent": sent,
|
|
270
|
+
"failed": failed,
|
|
271
|
+
}
|
|
272
|
+
if error:
|
|
273
|
+
attrs["error"] = error
|
|
274
|
+
|
|
275
|
+
try:
|
|
276
|
+
async with ctx.require_services().open_api_client(timeout=30) as client:
|
|
277
|
+
response = await client.post(
|
|
278
|
+
f"/internal/runs/{ctx.run_id}/events",
|
|
279
|
+
json={
|
|
280
|
+
"step_run_id": ctx.step_run_id,
|
|
281
|
+
"step_id": ctx.step_id,
|
|
282
|
+
"phase": ctx.tags.get("phase", ""),
|
|
283
|
+
"kind": "notification",
|
|
284
|
+
"message": message,
|
|
285
|
+
"attrs": attrs,
|
|
286
|
+
},
|
|
287
|
+
)
|
|
288
|
+
if response.status_code not in (200, 201):
|
|
289
|
+
logger.warning(
|
|
290
|
+
"Failed to emit notification event: "
|
|
291
|
+
f"status={response.status_code}, run_id={ctx.run_id}, step_id={ctx.step_id}"
|
|
292
|
+
)
|
|
293
|
+
except httpx.TimeoutException:
|
|
294
|
+
logger.warning(
|
|
295
|
+
f"Notification event emit timed out: run_id={ctx.run_id}, step_id={ctx.step_id}"
|
|
296
|
+
)
|
|
297
|
+
except Exception as emit_error:
|
|
298
|
+
logger.warning(
|
|
299
|
+
f"Failed to emit notification event: run_id={ctx.run_id}, step_id={ctx.step_id}, error={emit_error}"
|
|
300
|
+
)
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025-2026 Rexonix s.r.o.
|
|
2
|
+
# SPDX-FileContributor: Jakub Trávník <jakub.travnik@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
|
|
6
|
+
"""Nested flow launcher handler."""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import asyncio
|
|
11
|
+
import secrets
|
|
12
|
+
import time
|
|
13
|
+
from contextlib import suppress
|
|
14
|
+
from typing import Any
|
|
15
|
+
from uuid import UUID
|
|
16
|
+
|
|
17
|
+
import httpx
|
|
18
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
19
|
+
|
|
20
|
+
from hegemony_step_sdk import (
|
|
21
|
+
BaseHandler,
|
|
22
|
+
HandlerContext,
|
|
23
|
+
HandlerResult,
|
|
24
|
+
HandlerTargeting,
|
|
25
|
+
InvalidConfigError,
|
|
26
|
+
StepKind,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
_TERMINAL_STATUSES = {"SUCCESS", "FAILED", "CANCELLED"}
|
|
30
|
+
_DEFAULT_RUN_NAME_HASH_BYTES = 3
|
|
31
|
+
_FIELD_MAPPING_MODES = {"default", "literal", "template"}
|
|
32
|
+
_TARGET_MAPPING_MODES = {"child_default", "parent_role", "none"}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _http_error_detail(exc: Exception) -> str:
|
|
36
|
+
if isinstance(exc, httpx.HTTPStatusError):
|
|
37
|
+
try:
|
|
38
|
+
payload = exc.response.json()
|
|
39
|
+
detail = payload.get("detail") if isinstance(payload, dict) else None
|
|
40
|
+
if detail:
|
|
41
|
+
return str(detail)
|
|
42
|
+
except Exception:
|
|
43
|
+
pass
|
|
44
|
+
return f"API returned HTTP {exc.response.status_code}"
|
|
45
|
+
return str(exc)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _device_ids_for_parent_role(
|
|
49
|
+
target_devices_by_role: dict[str, list[dict[str, Any]]],
|
|
50
|
+
role: str,
|
|
51
|
+
) -> list[str]:
|
|
52
|
+
device_ids: list[str] = []
|
|
53
|
+
for device in target_devices_by_role.get(role, []):
|
|
54
|
+
raw_device_id = device.get("id")
|
|
55
|
+
if isinstance(raw_device_id, str) and raw_device_id.strip():
|
|
56
|
+
device_ids.append(raw_device_id.strip())
|
|
57
|
+
return device_ids
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _validate_field_mappings(value: Any) -> list[str]:
|
|
61
|
+
if value is None:
|
|
62
|
+
return ["field_mappings is required"]
|
|
63
|
+
if not isinstance(value, dict) or isinstance(value, list):
|
|
64
|
+
return ["field_mappings must be an object"]
|
|
65
|
+
|
|
66
|
+
errors: list[str] = []
|
|
67
|
+
for field_id, mapping in value.items():
|
|
68
|
+
if not isinstance(field_id, str) or not field_id.strip():
|
|
69
|
+
errors.append("field_mappings keys must be non-empty field ids")
|
|
70
|
+
break
|
|
71
|
+
if not isinstance(mapping, dict) or isinstance(mapping, list):
|
|
72
|
+
errors.append(f"field_mappings.{field_id} must be an object")
|
|
73
|
+
continue
|
|
74
|
+
|
|
75
|
+
mode = mapping.get("mode")
|
|
76
|
+
if mode not in _FIELD_MAPPING_MODES:
|
|
77
|
+
errors.append(
|
|
78
|
+
f"field_mappings.{field_id}.mode must be one of "
|
|
79
|
+
f"{', '.join(sorted(_FIELD_MAPPING_MODES))}"
|
|
80
|
+
)
|
|
81
|
+
continue
|
|
82
|
+
# The platform checks these settings as written (saving a flow) and
|
|
83
|
+
# again once rendered (running it). Rendering keeps each value's own
|
|
84
|
+
# type, so a template's value then is whatever it rendered to: false,
|
|
85
|
+
# a number, null or empty text are all values to pass to the child.
|
|
86
|
+
if mode in {"literal", "template"} and "value" not in mapping:
|
|
87
|
+
errors.append(f"field_mappings.{field_id}.value is required for {mode} mode")
|
|
88
|
+
return errors
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _validate_target_mappings(value: Any) -> list[str]:
|
|
92
|
+
if value is None:
|
|
93
|
+
return ["target_mappings is required"]
|
|
94
|
+
if not isinstance(value, dict) or isinstance(value, list):
|
|
95
|
+
return ["target_mappings must be an object"]
|
|
96
|
+
|
|
97
|
+
errors: list[str] = []
|
|
98
|
+
for child_role, mapping in value.items():
|
|
99
|
+
if not isinstance(child_role, str) or not child_role.strip():
|
|
100
|
+
errors.append("target_mappings keys must be non-empty child target roles")
|
|
101
|
+
break
|
|
102
|
+
if not isinstance(mapping, dict) or isinstance(mapping, list):
|
|
103
|
+
errors.append(f"target_mappings.{child_role} must be an object")
|
|
104
|
+
continue
|
|
105
|
+
|
|
106
|
+
mode = mapping.get("mode")
|
|
107
|
+
if mode not in _TARGET_MAPPING_MODES:
|
|
108
|
+
errors.append(
|
|
109
|
+
f"target_mappings.{child_role}.mode must be one of "
|
|
110
|
+
f"{', '.join(sorted(_TARGET_MAPPING_MODES))}"
|
|
111
|
+
)
|
|
112
|
+
continue
|
|
113
|
+
parent_role = mapping.get("parent_role_id")
|
|
114
|
+
if mode == "parent_role" and (not isinstance(parent_role, str) or not parent_role.strip()):
|
|
115
|
+
errors.append(
|
|
116
|
+
f"target_mappings.{child_role}.parent_role_id is required for parent_role mode"
|
|
117
|
+
)
|
|
118
|
+
return errors
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _params_from_field_mappings(field_mappings: dict[str, Any]) -> dict[str, Any]:
|
|
122
|
+
params: dict[str, Any] = {}
|
|
123
|
+
for field_id, mapping in field_mappings.items():
|
|
124
|
+
if not isinstance(mapping, dict):
|
|
125
|
+
continue
|
|
126
|
+
if mapping.get("mode") in {"literal", "template"}:
|
|
127
|
+
params[str(field_id)] = mapping.get("value")
|
|
128
|
+
return params
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _related_targets_from_mappings(
|
|
132
|
+
target_mappings: dict[str, Any],
|
|
133
|
+
target_devices_by_role: dict[str, list[dict[str, Any]]],
|
|
134
|
+
) -> dict[str, list[str]]:
|
|
135
|
+
related_targets: dict[str, list[str]] = {}
|
|
136
|
+
for child_role, mapping in target_mappings.items():
|
|
137
|
+
if not isinstance(mapping, dict) or mapping.get("mode") != "parent_role":
|
|
138
|
+
continue
|
|
139
|
+
parent_role = str(mapping.get("parent_role_id") or "").strip()
|
|
140
|
+
related_targets[str(child_role)] = _device_ids_for_parent_role(
|
|
141
|
+
target_devices_by_role,
|
|
142
|
+
parent_role,
|
|
143
|
+
)
|
|
144
|
+
return related_targets
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class RunFlowConfig(BaseModel):
|
|
148
|
+
"""Config for ``flow.run``.
|
|
149
|
+
|
|
150
|
+
The editor renders the entire config with the dedicated run-flow widget
|
|
151
|
+
(flow picker + field/target mappings); semantic validation lives in
|
|
152
|
+
:meth:`RunFlowHandler.validate_config`.
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
model_config = ConfigDict(extra="allow", json_schema_extra={"x_widget": "run-flow"})
|
|
156
|
+
|
|
157
|
+
flow_id: str = Field(
|
|
158
|
+
default="",
|
|
159
|
+
title="Flow",
|
|
160
|
+
description=(
|
|
161
|
+
"UUID of the committed child flow to launch. Provide exactly one "
|
|
162
|
+
"of flow_id / flow_name; leave this empty when selecting the "
|
|
163
|
+
"child flow by name."
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
flow_name: str = Field(
|
|
167
|
+
default="",
|
|
168
|
+
title="Flow name",
|
|
169
|
+
description=(
|
|
170
|
+
"Child flow name, resolved to the newest flow at launch time — the "
|
|
171
|
+
"portable alternative to flow_id for imported bundles. Provide "
|
|
172
|
+
"exactly one of flow_id / flow_name."
|
|
173
|
+
),
|
|
174
|
+
)
|
|
175
|
+
version: int | None = Field(
|
|
176
|
+
default=None,
|
|
177
|
+
ge=1,
|
|
178
|
+
title="Version",
|
|
179
|
+
description=(
|
|
180
|
+
"Committed version number of the child flow to run, starting at "
|
|
181
|
+
"1. Omit to launch the newest committed version at start time."
|
|
182
|
+
),
|
|
183
|
+
)
|
|
184
|
+
wait_for_completion: bool = Field(
|
|
185
|
+
default=True,
|
|
186
|
+
title="Wait for completion",
|
|
187
|
+
description=(
|
|
188
|
+
"When enabled (the default), the step polls the child run until "
|
|
189
|
+
"it finishes and mirrors its result, exposing the child flow's "
|
|
190
|
+
"outputs. Disable to succeed as soon as the child run is created."
|
|
191
|
+
),
|
|
192
|
+
)
|
|
193
|
+
run_name: str | None = Field(
|
|
194
|
+
default=None,
|
|
195
|
+
title="Child run name",
|
|
196
|
+
description=(
|
|
197
|
+
"Name given to the child run. Leave empty to derive one from the "
|
|
198
|
+
"parent run's name plus a short random suffix."
|
|
199
|
+
),
|
|
200
|
+
)
|
|
201
|
+
field_mappings: dict[str, Any] = Field(
|
|
202
|
+
default_factory=dict,
|
|
203
|
+
title="Field mappings",
|
|
204
|
+
description=(
|
|
205
|
+
"Values for the child flow's input fields: one entry per field "
|
|
206
|
+
"id with mode default (keep the child's default), literal, or "
|
|
207
|
+
"template, plus the value to pass. Managed by the run-flow "
|
|
208
|
+
"editor widget."
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
target_mappings: dict[str, Any] = Field(
|
|
212
|
+
default_factory=dict,
|
|
213
|
+
title="Target mappings",
|
|
214
|
+
description=(
|
|
215
|
+
"Device binding for each child target role: mode child_default, "
|
|
216
|
+
"parent_role (forwarding the devices this run bound to the given "
|
|
217
|
+
"parent_role_id), or none. Managed by the run-flow editor widget."
|
|
218
|
+
),
|
|
219
|
+
)
|
|
220
|
+
poll_interval_seconds: float = Field(
|
|
221
|
+
default=5,
|
|
222
|
+
ge=1,
|
|
223
|
+
le=60,
|
|
224
|
+
title="Poll interval (sec)",
|
|
225
|
+
description=(
|
|
226
|
+
"Seconds between status checks of the child run while waiting "
|
|
227
|
+
"for completion, from 1 to 60 (default 5). Ignored when the step "
|
|
228
|
+
"does not wait."
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class RunFlowHandler(BaseHandler):
|
|
234
|
+
"""Launch another committed flow from the current flow."""
|
|
235
|
+
|
|
236
|
+
handler_id = "flow.run"
|
|
237
|
+
default_timeout_seconds = 7200
|
|
238
|
+
supported_kinds = [StepKind.ACTION, StepKind.EXECUTE]
|
|
239
|
+
display_name = "Run Flow"
|
|
240
|
+
description = "Launch another committed flow as a child run."
|
|
241
|
+
category = "Actions"
|
|
242
|
+
targeting = HandlerTargeting(roles=False, ips=False)
|
|
243
|
+
config_model = RunFlowConfig
|
|
244
|
+
|
|
245
|
+
def validate_config(self, config: dict[str, Any]) -> list[str]:
|
|
246
|
+
errors: list[str] = []
|
|
247
|
+
raw_flow_id = config.get("flow_id")
|
|
248
|
+
raw_flow_name = config.get("flow_name")
|
|
249
|
+
if raw_flow_id is not None and not isinstance(raw_flow_id, str):
|
|
250
|
+
errors.append("flow_id must be a string")
|
|
251
|
+
if raw_flow_name is not None and not isinstance(raw_flow_name, str):
|
|
252
|
+
errors.append("flow_name must be a string")
|
|
253
|
+
flow_id = raw_flow_id.strip() if isinstance(raw_flow_id, str) else ""
|
|
254
|
+
flow_name = raw_flow_name.strip() if isinstance(raw_flow_name, str) else ""
|
|
255
|
+
if flow_id and flow_name:
|
|
256
|
+
errors.append("provide either flow_id or flow_name, not both")
|
|
257
|
+
elif not flow_id and not flow_name and not errors:
|
|
258
|
+
errors.append("flow_id or flow_name is required")
|
|
259
|
+
elif flow_id:
|
|
260
|
+
try:
|
|
261
|
+
UUID(flow_id)
|
|
262
|
+
except ValueError:
|
|
263
|
+
errors.append("flow_id must be a UUID")
|
|
264
|
+
|
|
265
|
+
if "input_mappings" in config:
|
|
266
|
+
errors.append("input_mappings is no longer supported; configure field_mappings")
|
|
267
|
+
|
|
268
|
+
errors.extend(_validate_field_mappings(config.get("field_mappings")))
|
|
269
|
+
errors.extend(_validate_target_mappings(config.get("target_mappings")))
|
|
270
|
+
if errors:
|
|
271
|
+
return errors
|
|
272
|
+
# The other settings as the model reads them (types and bounds), so a
|
|
273
|
+
# rendered "false" or "3" is checked as the step will run with it.
|
|
274
|
+
return super().validate_config(config)
|
|
275
|
+
|
|
276
|
+
async def execute(self, ctx: HandlerContext) -> HandlerResult:
|
|
277
|
+
"""Start a child flow run and optionally wait for its terminal result."""
|
|
278
|
+
# The settings as the model reads them: the platform renders templates
|
|
279
|
+
# as text, and a rendered "false" must not read as true.
|
|
280
|
+
try:
|
|
281
|
+
config = self.parse_config(ctx.config, RunFlowConfig)
|
|
282
|
+
except InvalidConfigError as exc:
|
|
283
|
+
return HandlerResult(
|
|
284
|
+
success=False,
|
|
285
|
+
summary="Nested flow configuration error",
|
|
286
|
+
error="; ".join(exc.errors),
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
services = ctx.require_services()
|
|
290
|
+
|
|
291
|
+
flow_id = config.flow_id.strip()
|
|
292
|
+
flow_name = config.flow_name.strip()
|
|
293
|
+
version = config.version
|
|
294
|
+
wait_for_completion = config.wait_for_completion
|
|
295
|
+
run_name = (config.run_name or "").strip() or None
|
|
296
|
+
if run_name is None:
|
|
297
|
+
parent_run_name = ctx.run_name.strip() if ctx.run_name else ctx.run_id[:8]
|
|
298
|
+
run_name = f"{parent_run_name}_{secrets.token_hex(_DEFAULT_RUN_NAME_HASH_BYTES)}"
|
|
299
|
+
|
|
300
|
+
# The platform renders the mappings keeping each value's own type: used as they arrive.
|
|
301
|
+
field_mappings = ctx.config.get("field_mappings")
|
|
302
|
+
target_mappings = ctx.config.get("target_mappings")
|
|
303
|
+
assert isinstance(field_mappings, dict)
|
|
304
|
+
assert isinstance(target_mappings, dict)
|
|
305
|
+
|
|
306
|
+
params = _params_from_field_mappings(field_mappings)
|
|
307
|
+
related_targets = _related_targets_from_mappings(
|
|
308
|
+
target_mappings,
|
|
309
|
+
ctx.target_devices_by_role,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
payload = {
|
|
313
|
+
"name": run_name,
|
|
314
|
+
"related_targets": related_targets,
|
|
315
|
+
"params": params,
|
|
316
|
+
"parent_run_id": ctx.run_id,
|
|
317
|
+
"parent_step_run_id": ctx.step_run_id,
|
|
318
|
+
}
|
|
319
|
+
if flow_id:
|
|
320
|
+
payload["flow_id"] = flow_id
|
|
321
|
+
else:
|
|
322
|
+
payload["flow_name"] = flow_name
|
|
323
|
+
if version is not None:
|
|
324
|
+
payload["version"] = version
|
|
325
|
+
|
|
326
|
+
try:
|
|
327
|
+
created = await services.create_child_run(payload)
|
|
328
|
+
except Exception as exc:
|
|
329
|
+
return HandlerResult(
|
|
330
|
+
success=False,
|
|
331
|
+
summary="Failed to start child flow",
|
|
332
|
+
error=_http_error_detail(exc),
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
raw_child_run_id = created.get("run_id")
|
|
336
|
+
if not isinstance(raw_child_run_id, str) or not raw_child_run_id.strip():
|
|
337
|
+
return HandlerResult(
|
|
338
|
+
success=False,
|
|
339
|
+
summary="Failed to start child flow",
|
|
340
|
+
error="Child run creation response missing run_id",
|
|
341
|
+
)
|
|
342
|
+
child_run_id = raw_child_run_id.strip()
|
|
343
|
+
raw_child_workflow_id = created.get("workflow_id")
|
|
344
|
+
child_workflow_id = (
|
|
345
|
+
raw_child_workflow_id.strip()
|
|
346
|
+
if isinstance(raw_child_workflow_id, str) and raw_child_workflow_id.strip()
|
|
347
|
+
else child_run_id
|
|
348
|
+
)
|
|
349
|
+
await ctx.emit_progress(
|
|
350
|
+
"Started child flow run",
|
|
351
|
+
attrs={
|
|
352
|
+
"child_run_id": child_run_id,
|
|
353
|
+
"child_workflow_id": child_workflow_id,
|
|
354
|
+
"child_flow_id": flow_id or None,
|
|
355
|
+
"child_flow_name": flow_name or None,
|
|
356
|
+
"child_version": version if version is not None else "latest",
|
|
357
|
+
},
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
if not wait_for_completion:
|
|
361
|
+
return HandlerResult(
|
|
362
|
+
success=True,
|
|
363
|
+
summary="Started child flow",
|
|
364
|
+
metrics={"child_run_count": 1},
|
|
365
|
+
output={
|
|
366
|
+
"child_run_id": child_run_id,
|
|
367
|
+
"child_workflow_id": child_workflow_id,
|
|
368
|
+
"child_status": "PENDING",
|
|
369
|
+
"waited": False,
|
|
370
|
+
},
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
poll_interval = config.poll_interval_seconds
|
|
374
|
+
started = time.monotonic()
|
|
375
|
+
|
|
376
|
+
try:
|
|
377
|
+
while True:
|
|
378
|
+
child = await services.fetch_run(child_run_id)
|
|
379
|
+
status = str(child.get("status") or "UNKNOWN")
|
|
380
|
+
if status in _TERMINAL_STATUSES:
|
|
381
|
+
error_message = child.get("error_message")
|
|
382
|
+
break
|
|
383
|
+
await ctx.emit_progress(
|
|
384
|
+
"Waiting for child flow",
|
|
385
|
+
attrs={"child_run_id": child_run_id, "child_status": status},
|
|
386
|
+
)
|
|
387
|
+
await asyncio.sleep(poll_interval)
|
|
388
|
+
except asyncio.CancelledError:
|
|
389
|
+
with suppress(Exception):
|
|
390
|
+
await services.cancel_run(child_run_id)
|
|
391
|
+
raise
|
|
392
|
+
except Exception as exc:
|
|
393
|
+
return HandlerResult(
|
|
394
|
+
success=False,
|
|
395
|
+
summary="Failed while waiting for child flow",
|
|
396
|
+
error=_http_error_detail(exc),
|
|
397
|
+
output={
|
|
398
|
+
"child_run_id": child_run_id,
|
|
399
|
+
"child_workflow_id": child_workflow_id,
|
|
400
|
+
"child_status": "UNKNOWN",
|
|
401
|
+
"waited": True,
|
|
402
|
+
},
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
elapsed_seconds = round(time.monotonic() - started, 3)
|
|
406
|
+
base_output: dict[str, Any] = {
|
|
407
|
+
"child_run_id": child_run_id,
|
|
408
|
+
"child_workflow_id": child_workflow_id,
|
|
409
|
+
"child_status": status,
|
|
410
|
+
"waited": True,
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if status != "SUCCESS":
|
|
414
|
+
return HandlerResult(
|
|
415
|
+
success=False,
|
|
416
|
+
summary=f"Child flow ended with {status}",
|
|
417
|
+
error=str(error_message or f"Child flow status: {status}"),
|
|
418
|
+
metrics={"child_run_count": 1, "wait_seconds": elapsed_seconds},
|
|
419
|
+
output=base_output,
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
try:
|
|
423
|
+
outputs_payload = await services.fetch_run_outputs(child_run_id)
|
|
424
|
+
outputs = outputs_payload.get("outputs", {})
|
|
425
|
+
if not isinstance(outputs, dict):
|
|
426
|
+
outputs = {}
|
|
427
|
+
except Exception as exc:
|
|
428
|
+
return HandlerResult(
|
|
429
|
+
success=False,
|
|
430
|
+
summary="Child flow succeeded but output evaluation failed",
|
|
431
|
+
error=_http_error_detail(exc),
|
|
432
|
+
metrics={"child_run_count": 1, "wait_seconds": elapsed_seconds},
|
|
433
|
+
output=base_output,
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
return HandlerResult(
|
|
437
|
+
success=True,
|
|
438
|
+
summary="Child flow completed",
|
|
439
|
+
metrics={"child_run_count": 1, "wait_seconds": elapsed_seconds},
|
|
440
|
+
output={**base_output, "outputs": outputs},
|
|
441
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hegemony-steps-flow
|
|
3
|
+
Version: 0.46.1
|
|
4
|
+
Summary: Flow orchestration step handlers for Hegemony
|
|
5
|
+
License-Expression: AGPL-3.0-or-later
|
|
6
|
+
License-File: LICENSE-AGPL-3.0-or-later.txt
|
|
7
|
+
Requires-Dist: hegemony-step-sdk==0.46.1
|
|
8
|
+
Requires-Dist: httpx>=0.27.0
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
<!--
|
|
13
|
+
SPDX-FileCopyrightText: 2025-2026 Rexonix s.r.o.
|
|
14
|
+
SPDX-FileContributor: Jakub Trávník <jakub.travnik@gmail.com>
|
|
15
|
+
|
|
16
|
+
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
# hegemony-steps-flow
|
|
20
|
+
|
|
21
|
+
Platform-orchestration steps: launch nested flow runs and send on-demand
|
|
22
|
+
notifications.
|
|
23
|
+
|
|
24
|
+
Handlers: `flow.run`, `flow.notify`.
|
|
25
|
+
|
|
26
|
+
Namespace prefix (= entry-point name): `flow.` — see the repo-level
|
|
27
|
+
`CONVENTIONS.md` for the naming rules.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
hegemony_steps_flow/__init__.py,sha256=rVqFnXpJBjGqLuA7dq5QVlRURlTASRnYHhij7yy5LcA,1107
|
|
2
|
+
hegemony_steps_flow/docs/flow.notify.md,sha256=yM3B7LTeleQLTFHqb8A7PpCSUIqZnoqX_1PYy5naTu0,2323
|
|
3
|
+
hegemony_steps_flow/docs/flow.run.md,sha256=KAcMkF3hOD4w11K_HzcQ8U5bYjvtxXAlmuvJDckHm2s,3499
|
|
4
|
+
hegemony_steps_flow/notify.py,sha256=PjM37FLN9Rkv4dCFeS7V2_GKsQtAEl5YPkfU718SaW0,11259
|
|
5
|
+
hegemony_steps_flow/run.py,sha256=A0ukN25dJfaEy3JcaPBeYYKZO_R4fhboTilMjieysrw,16715
|
|
6
|
+
hegemony_steps_flow-0.46.1.dist-info/licenses/LICENSE-AGPL-3.0-or-later.txt,sha256=2KbMMavBa2dIx6IfIWEfWh7DP2fSLKI9faHBm5VJa-4,34020
|
|
7
|
+
hegemony_steps_flow-0.46.1.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
8
|
+
hegemony_steps_flow-0.46.1.dist-info/entry_points.txt,sha256=JM9NwESR2tvuBqsW5Gq1dGiyILnENmp11la4vmwi8pQ,62
|
|
9
|
+
hegemony_steps_flow-0.46.1.dist-info/METADATA,sha256=7l79QF2dX6DY9tj2rw3rOFcwt6tA8TLea6ndvoyN3L8,762
|
|
10
|
+
hegemony_steps_flow-0.46.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 19 November 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
Preamble
|
|
9
|
+
|
|
10
|
+
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
|
|
11
|
+
|
|
12
|
+
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
|
|
13
|
+
|
|
14
|
+
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
|
15
|
+
|
|
16
|
+
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
|
|
17
|
+
|
|
18
|
+
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
|
|
19
|
+
|
|
20
|
+
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
|
|
21
|
+
|
|
22
|
+
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
|
|
23
|
+
|
|
24
|
+
The precise terms and conditions for copying, distribution and modification follow.
|
|
25
|
+
|
|
26
|
+
TERMS AND CONDITIONS
|
|
27
|
+
|
|
28
|
+
0. Definitions.
|
|
29
|
+
|
|
30
|
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
|
31
|
+
|
|
32
|
+
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
|
33
|
+
|
|
34
|
+
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
|
35
|
+
|
|
36
|
+
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
|
37
|
+
|
|
38
|
+
A "covered work" means either the unmodified Program or a work based on the Program.
|
|
39
|
+
|
|
40
|
+
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
|
41
|
+
|
|
42
|
+
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
|
43
|
+
|
|
44
|
+
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
|
45
|
+
|
|
46
|
+
1. Source Code.
|
|
47
|
+
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
|
48
|
+
|
|
49
|
+
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
|
50
|
+
|
|
51
|
+
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
|
52
|
+
|
|
53
|
+
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
|
|
54
|
+
subprograms and other parts of the work.
|
|
55
|
+
|
|
56
|
+
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
|
57
|
+
|
|
58
|
+
The Corresponding Source for a work in source code form is that same work.
|
|
59
|
+
|
|
60
|
+
2. Basic Permissions.
|
|
61
|
+
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
|
62
|
+
|
|
63
|
+
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
|
64
|
+
|
|
65
|
+
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
|
66
|
+
|
|
67
|
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
68
|
+
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
|
69
|
+
|
|
70
|
+
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
|
71
|
+
|
|
72
|
+
4. Conveying Verbatim Copies.
|
|
73
|
+
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
|
74
|
+
|
|
75
|
+
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
|
76
|
+
|
|
77
|
+
5. Conveying Modified Source Versions.
|
|
78
|
+
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
|
79
|
+
|
|
80
|
+
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
|
81
|
+
|
|
82
|
+
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
|
83
|
+
|
|
84
|
+
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
|
85
|
+
|
|
86
|
+
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
|
87
|
+
|
|
88
|
+
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
|
89
|
+
|
|
90
|
+
6. Conveying Non-Source Forms.
|
|
91
|
+
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
|
92
|
+
|
|
93
|
+
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
|
94
|
+
|
|
95
|
+
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
|
96
|
+
|
|
97
|
+
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
|
98
|
+
|
|
99
|
+
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
|
100
|
+
|
|
101
|
+
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
|
102
|
+
|
|
103
|
+
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
|
104
|
+
|
|
105
|
+
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
|
106
|
+
|
|
107
|
+
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
|
108
|
+
|
|
109
|
+
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
|
110
|
+
|
|
111
|
+
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
|
112
|
+
|
|
113
|
+
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
|
114
|
+
|
|
115
|
+
7. Additional Terms.
|
|
116
|
+
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
|
117
|
+
|
|
118
|
+
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
|
119
|
+
|
|
120
|
+
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
|
121
|
+
|
|
122
|
+
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
|
123
|
+
|
|
124
|
+
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
|
125
|
+
|
|
126
|
+
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
|
127
|
+
|
|
128
|
+
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
|
129
|
+
|
|
130
|
+
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
|
131
|
+
|
|
132
|
+
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
|
133
|
+
|
|
134
|
+
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
|
135
|
+
|
|
136
|
+
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
|
137
|
+
|
|
138
|
+
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
|
139
|
+
|
|
140
|
+
8. Termination.
|
|
141
|
+
|
|
142
|
+
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
|
143
|
+
|
|
144
|
+
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
|
145
|
+
|
|
146
|
+
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
|
147
|
+
|
|
148
|
+
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
|
149
|
+
|
|
150
|
+
9. Acceptance Not Required for Having Copies.
|
|
151
|
+
|
|
152
|
+
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
|
153
|
+
|
|
154
|
+
10. Automatic Licensing of Downstream Recipients.
|
|
155
|
+
|
|
156
|
+
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
|
157
|
+
|
|
158
|
+
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
|
159
|
+
|
|
160
|
+
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
|
161
|
+
|
|
162
|
+
11. Patents.
|
|
163
|
+
|
|
164
|
+
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
|
165
|
+
|
|
166
|
+
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
|
167
|
+
|
|
168
|
+
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
|
169
|
+
|
|
170
|
+
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
|
171
|
+
|
|
172
|
+
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
|
|
173
|
+
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
|
174
|
+
|
|
175
|
+
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
|
176
|
+
|
|
177
|
+
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
|
178
|
+
|
|
179
|
+
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
|
180
|
+
|
|
181
|
+
12. No Surrender of Others' Freedom.
|
|
182
|
+
|
|
183
|
+
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
|
|
184
|
+
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
|
185
|
+
|
|
186
|
+
13. Remote Network Interaction; Use with the GNU General Public License.
|
|
187
|
+
|
|
188
|
+
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
|
|
189
|
+
|
|
190
|
+
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
|
191
|
+
|
|
192
|
+
14. Revised Versions of this License.
|
|
193
|
+
|
|
194
|
+
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
|
195
|
+
|
|
196
|
+
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
|
|
197
|
+
|
|
198
|
+
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
|
199
|
+
|
|
200
|
+
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
|
201
|
+
|
|
202
|
+
15. Disclaimer of Warranty.
|
|
203
|
+
|
|
204
|
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
205
|
+
|
|
206
|
+
16. Limitation of Liability.
|
|
207
|
+
|
|
208
|
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
209
|
+
|
|
210
|
+
17. Interpretation of Sections 15 and 16.
|
|
211
|
+
|
|
212
|
+
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
|
213
|
+
|
|
214
|
+
END OF TERMS AND CONDITIONS
|
|
215
|
+
|
|
216
|
+
How to Apply These Terms to Your New Programs
|
|
217
|
+
|
|
218
|
+
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
|
219
|
+
|
|
220
|
+
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
|
221
|
+
|
|
222
|
+
<one line to give the program's name and a brief idea of what it does.>
|
|
223
|
+
Copyright (C) <year> <name of author>
|
|
224
|
+
|
|
225
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
226
|
+
|
|
227
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
228
|
+
|
|
229
|
+
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
230
|
+
|
|
231
|
+
Also add information on how to contact you by electronic and paper mail.
|
|
232
|
+
|
|
233
|
+
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
|
|
234
|
+
|
|
235
|
+
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
|