mistralai-workflows-plugins-triggers 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 (34) hide show
  1. mistralai_workflows_plugins_triggers-0.1.0/.gitignore +32 -0
  2. mistralai_workflows_plugins_triggers-0.1.0/Makefile +22 -0
  3. mistralai_workflows_plugins_triggers-0.1.0/PKG-INFO +140 -0
  4. mistralai_workflows_plugins_triggers-0.1.0/README.md +120 -0
  5. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/__init__.py +4 -0
  6. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/__init__.py +10 -0
  7. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/__init__.py +11 -0
  8. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/_provider_event.py +63 -0
  9. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/github.py +2242 -0
  10. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/linear.py +243 -0
  11. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/lucca.py +231 -0
  12. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/notion.py +220 -0
  13. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/slack.py +495 -0
  14. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/models/trigger_event.py +36 -0
  15. mistralai_workflows_plugins_triggers-0.1.0/mistralai/workflows/plugins/triggers/py.typed +0 -0
  16. mistralai_workflows_plugins_triggers-0.1.0/pyproject.toml +103 -0
  17. mistralai_workflows_plugins_triggers-0.1.0/scripts/generate_github_models.py +554 -0
  18. mistralai_workflows_plugins_triggers-0.1.0/tasks.py +91 -0
  19. mistralai_workflows_plugins_triggers-0.1.0/tests/conftest.py +14 -0
  20. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/github/check_run_completed.json +311 -0
  21. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/github/issue_comment_created.json +311 -0
  22. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/github/pull_request_opened.json +520 -0
  23. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/github/pull_request_review_comment_created.json +573 -0
  24. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/github/pull_request_review_requested.json +551 -0
  25. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/github/pull_request_review_submitted.json +548 -0
  26. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/github/push.json +139 -0
  27. mistralai_workflows_plugins_triggers-0.1.0/tests/fixtures/trigger_input_github_push.json +152 -0
  28. mistralai_workflows_plugins_triggers-0.1.0/tests/test_github.py +172 -0
  29. mistralai_workflows_plugins_triggers-0.1.0/tests/test_linear.py +154 -0
  30. mistralai_workflows_plugins_triggers-0.1.0/tests/test_lucca.py +102 -0
  31. mistralai_workflows_plugins_triggers-0.1.0/tests/test_models.py +158 -0
  32. mistralai_workflows_plugins_triggers-0.1.0/tests/test_notion.py +99 -0
  33. mistralai_workflows_plugins_triggers-0.1.0/tests/test_slack.py +296 -0
  34. mistralai_workflows_plugins_triggers-0.1.0/tests/test_workflow.py +175 -0
@@ -0,0 +1,32 @@
1
+ # python sdk
2
+ build
3
+ *.egg-info
4
+ *.egg
5
+
6
+ # Env files
7
+ .env
8
+ .env.*
9
+ !.env.example
10
+
11
+ # Python
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+ .pytest_cache/
16
+ .coverage
17
+ htmlcov/
18
+
19
+ # IDEs
20
+ .idea/
21
+ .vscode/
22
+ *.swp
23
+ *.swo
24
+
25
+ # docs
26
+ docs/node_modules/**
27
+ docs/.docusaurus/**
28
+ docs/pnpm-lock.yaml
29
+ .docs.temporal.io/
30
+
31
+ #test
32
+ /.test_durations
@@ -0,0 +1,22 @@
1
+ .PHONY: lint format typecheck test installdeps generate-github-models check-generated
2
+
3
+ lint:
4
+ uv run invoke lint
5
+
6
+ format:
7
+ uv run invoke lint --fix
8
+
9
+ typecheck:
10
+ uv run invoke typecheck
11
+
12
+ test:
13
+ uv run invoke tests
14
+
15
+ installdeps:
16
+ uv sync
17
+
18
+ generate-github-models:
19
+ uv run python scripts/generate_github_models.py
20
+
21
+ check-generated:
22
+ uv run python scripts/generate_github_models.py --check
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.5
2
+ Name: mistralai-workflows-plugins-triggers
3
+ Version: 0.1.0
4
+ Summary: Triggers plugin for Mistral Workflows
5
+ Project-URL: Homepage, https://mistral.ai
6
+ Project-URL: Documentation, https://docs.mistral.ai/workflows/getting-started/introduction
7
+ Author-email: Mistral AI <support@mistral.ai>
8
+ License: Apache-2.0
9
+ Keywords: ai,mistral,plugin,triggers,webhook,workflows
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: <3.15,>=3.12
18
+ Requires-Dist: mistralai-workflows<4.0.0,>=3.0.0a1
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Mistral Workflows - Triggers Plugin
22
+
23
+ Typed models for workflows started by triggers.
24
+
25
+ A trigger links an event source (for example a GitHub or Slack webhook) to a workflow. When the source receives an
26
+ event that matches the trigger's filter, the Workflows API starts the workflow asynchronously, passing the webhook
27
+ request as input. Signature verification happens before the workflow starts, and the workflow's return value is not
28
+ sent back to the webhook caller.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install mistralai-workflows-plugins-triggers
34
+ ```
35
+
36
+ It requires `mistralai-workflows>=3.0.0,<4.0.0` and Python `>=3.12,<3.15`.
37
+
38
+ ## Maturity and limits
39
+
40
+ - Alpha: models and module layout can change between releases without a deprecation period. Pin an exact version.
41
+ - The models describe the payload sent by the trigger system only. Workflows behind the legacy
42
+ `/v1/workflows/webhooks/{name}` route keep using the webhook plugin.
43
+ - Provider models cover the events listed in [Provider events](#provider-events); other events validate as the
44
+ provider's `EventReceived` with an untyped body.
45
+ - The workflow's return value is not sent back to the webhook caller: the plugin cannot answer a webhook
46
+ synchronously (e.g. a Slack interaction response).
47
+
48
+ ## Quick Start
49
+
50
+ ```python
51
+ from pydantic import BaseModel
52
+
53
+ import mistralai.workflows as workflows
54
+ from mistralai.workflows.plugins.triggers import TriggerEvent
55
+
56
+
57
+ class PushBody(BaseModel):
58
+ ref: str
59
+
60
+
61
+ @workflows.workflow.define(name="on-github-push")
62
+ class OnGithubPush:
63
+ @workflows.workflow.entrypoint
64
+ async def run(self, event: TriggerEvent) -> None:
65
+ if event.header("x-github-event") != "push":
66
+ return
67
+ push = event.parse_body(PushBody)
68
+ ...
69
+ ```
70
+
71
+ Then create a trigger targeting the `on-github-push` workflow.
72
+
73
+ ## `TriggerEvent`
74
+
75
+ | Field | Description |
76
+ |-------|-------------|
77
+ | `method` | HTTP method of the webhook request |
78
+ | `headers` | Request headers, with lowercase names and credential headers stripped |
79
+ | `query_params` | Query string parameters |
80
+ | `body` | Body parsed as JSON, or `None` if empty or not valid JSON |
81
+ | `raw_body` | Body decoded as UTF-8, or `None` if empty |
82
+
83
+ Unknown fields are ignored, so workers keep accepting payloads when the API adds new ones.
84
+
85
+ For custom webhooks, parse the body inside the workflow with `parse_body` rather than typing the entrypoint with a
86
+ strict model: the API validates the input against the workflow's input schema before starting it, so a payload that
87
+ does not match is rejected without any execution to inspect.
88
+
89
+ ## Provider events
90
+
91
+ The `github`, `slack`, `linear`, `notion` and `lucca` modules each expose an `Event` class to use as the entrypoint type. It validates
92
+ into the subclass matching the payload, a `TriggerEvent` whose `body` is a provider model, so the request fields stay
93
+ available.
94
+
95
+ ```python
96
+ from mistralai.workflows.plugins.triggers import github
97
+
98
+
99
+ @workflows.workflow.define(name="on-github-event")
100
+ class OnGithubEvent:
101
+ @workflows.workflow.entrypoint
102
+ async def run(self, event: github.Event) -> None:
103
+ match event:
104
+ case github.PullRequestOpened(body=body):
105
+ ...
106
+ case github.IssueCommentCreated(body=body):
107
+ ...
108
+ case _:
109
+ return
110
+ ```
111
+
112
+ - Every event class registers the permissive `TriggerEvent` input schema, so the API starts the workflow for every
113
+ event and the dispatch happens on the worker.
114
+ - Events without a dedicated model validate as the provider's `EventReceived`. A known event with a malformed body
115
+ raises a pydantic `ValidationError`: like any workflow-level error, it fails the workflow task, which Temporal
116
+ retries, and the execution shows the error.
117
+ - Events keep their class when serialized and validated again as `Event`, e.g. when passed to an activity.
118
+ - A workflow taking a generic `TriggerEvent` can still get the typed event with `github.Event.model_validate(event)`.
119
+ - The entrypoint can take a single event class (e.g. `event: github.PullRequestOpened`) or a family class (e.g.
120
+ `event: github.PullRequestEvent`, any pull request action). It is parsed like through `Event`, and a payload of
121
+ another event raises a `ValidationError` (`Expected PullRequestOpened, got PullRequestClosed`): filter the trigger
122
+ so that it only fires for that event.
123
+
124
+ | Module | Event type taken from | Events |
125
+ |--------|-----------------------|--------|
126
+ | `github` | `X-GitHub-Event` header and body `action` | `<Event><Action>` for every action of `pull_request`, `pull_request_review`, `pull_request_review_comment`, `issue_comment` and `check_run` (e.g. `PullRequestOpened`, `PullRequestReviewRequested`, `CheckRunCompleted`), each a subclass of its family's `<Event>Event` (e.g. `PullRequestEvent`); `Push` |
127
+ | `slack` | Events API `event.type` / `subtype`, the interaction `type`, or the slash command `command` | `MessagePosted`, `MessageEdited`, `MessageDeleted`, `MessageOther`, `ReactionAdded`, `ReactionRemoved`, `AppMentioned`, `MemberJoined`, `AgentSessionStopped`, `BlockActions`, `ViewSubmission`, `ViewClosed`, `SlashCommand`, `AppRateLimited` |
128
+ | `linear` | Body `type` and `action` | `IssueCreated`, `IssueUpdated`, `IssueDeleted`, `IssueCommentCreated`, `IssueCommentUpdated`, `IssueCommentDeleted`, `ProjectUpdated`, `AgentSessionCreated`, `AgentSessionPrompted` |
129
+ | `notion` | Body `type` | `Page{Created,PropertiesUpdated,ContentUpdated,Moved,Deleted,Undeleted,Locked,Unlocked}`, `PageTranscriptionBlockTranscriptDeleted`, `Database{Created,ContentUpdated,Moved,Deleted,Undeleted,SchemaUpdated}`, `DataSource{Created,ContentUpdated,Moved,Deleted,Undeleted,SchemaUpdated}`, `Comment{Created,Updated,Deleted}`, `FileUpload{Created,Completed,Expired,Failed}`, `View{Created,Updated,Deleted}` |
130
+ | `lucca` | Body `topic` | `<Resource>{Created,Updated,Deleted}` for `LegalEntity`, `BusinessEstablishment`, `Department`, `Employee`, `EmployeePersonalRecord`, `Employment`, `JobPosition`, `JobQualification`, `OccupationCategory`, `EmployeeAttribute` |
131
+
132
+ The `github` module is generated from GitHub's OpenAPI description by `scripts/generate_github_models.py`: don't
133
+ edit it by hand, change the generator and run `make generate-github-models`. CI fails if the module is stale. GitHub
134
+ spells out every nested object at each place it is used: the generator merges those copies into one class per object
135
+ (`User`, `Repository`, `PullRequest`, ...), with a field required only when GitHub always sends it.
136
+
137
+ Notion and Lucca send a thin envelope (the changed resource's id and URL): fetch the full resource from their API.
138
+
139
+ Slack interactions and slash commands are delivered form-encoded: for `BlockActions`, `ViewSubmission`, `ViewClosed`
140
+ and `SlashCommand`, `body` is the decoded payload and `raw_body` keeps the original form body.
@@ -0,0 +1,120 @@
1
+ # Mistral Workflows - Triggers Plugin
2
+
3
+ Typed models for workflows started by triggers.
4
+
5
+ A trigger links an event source (for example a GitHub or Slack webhook) to a workflow. When the source receives an
6
+ event that matches the trigger's filter, the Workflows API starts the workflow asynchronously, passing the webhook
7
+ request as input. Signature verification happens before the workflow starts, and the workflow's return value is not
8
+ sent back to the webhook caller.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pip install mistralai-workflows-plugins-triggers
14
+ ```
15
+
16
+ It requires `mistralai-workflows>=3.0.0,<4.0.0` and Python `>=3.12,<3.15`.
17
+
18
+ ## Maturity and limits
19
+
20
+ - Alpha: models and module layout can change between releases without a deprecation period. Pin an exact version.
21
+ - The models describe the payload sent by the trigger system only. Workflows behind the legacy
22
+ `/v1/workflows/webhooks/{name}` route keep using the webhook plugin.
23
+ - Provider models cover the events listed in [Provider events](#provider-events); other events validate as the
24
+ provider's `EventReceived` with an untyped body.
25
+ - The workflow's return value is not sent back to the webhook caller: the plugin cannot answer a webhook
26
+ synchronously (e.g. a Slack interaction response).
27
+
28
+ ## Quick Start
29
+
30
+ ```python
31
+ from pydantic import BaseModel
32
+
33
+ import mistralai.workflows as workflows
34
+ from mistralai.workflows.plugins.triggers import TriggerEvent
35
+
36
+
37
+ class PushBody(BaseModel):
38
+ ref: str
39
+
40
+
41
+ @workflows.workflow.define(name="on-github-push")
42
+ class OnGithubPush:
43
+ @workflows.workflow.entrypoint
44
+ async def run(self, event: TriggerEvent) -> None:
45
+ if event.header("x-github-event") != "push":
46
+ return
47
+ push = event.parse_body(PushBody)
48
+ ...
49
+ ```
50
+
51
+ Then create a trigger targeting the `on-github-push` workflow.
52
+
53
+ ## `TriggerEvent`
54
+
55
+ | Field | Description |
56
+ |-------|-------------|
57
+ | `method` | HTTP method of the webhook request |
58
+ | `headers` | Request headers, with lowercase names and credential headers stripped |
59
+ | `query_params` | Query string parameters |
60
+ | `body` | Body parsed as JSON, or `None` if empty or not valid JSON |
61
+ | `raw_body` | Body decoded as UTF-8, or `None` if empty |
62
+
63
+ Unknown fields are ignored, so workers keep accepting payloads when the API adds new ones.
64
+
65
+ For custom webhooks, parse the body inside the workflow with `parse_body` rather than typing the entrypoint with a
66
+ strict model: the API validates the input against the workflow's input schema before starting it, so a payload that
67
+ does not match is rejected without any execution to inspect.
68
+
69
+ ## Provider events
70
+
71
+ The `github`, `slack`, `linear`, `notion` and `lucca` modules each expose an `Event` class to use as the entrypoint type. It validates
72
+ into the subclass matching the payload, a `TriggerEvent` whose `body` is a provider model, so the request fields stay
73
+ available.
74
+
75
+ ```python
76
+ from mistralai.workflows.plugins.triggers import github
77
+
78
+
79
+ @workflows.workflow.define(name="on-github-event")
80
+ class OnGithubEvent:
81
+ @workflows.workflow.entrypoint
82
+ async def run(self, event: github.Event) -> None:
83
+ match event:
84
+ case github.PullRequestOpened(body=body):
85
+ ...
86
+ case github.IssueCommentCreated(body=body):
87
+ ...
88
+ case _:
89
+ return
90
+ ```
91
+
92
+ - Every event class registers the permissive `TriggerEvent` input schema, so the API starts the workflow for every
93
+ event and the dispatch happens on the worker.
94
+ - Events without a dedicated model validate as the provider's `EventReceived`. A known event with a malformed body
95
+ raises a pydantic `ValidationError`: like any workflow-level error, it fails the workflow task, which Temporal
96
+ retries, and the execution shows the error.
97
+ - Events keep their class when serialized and validated again as `Event`, e.g. when passed to an activity.
98
+ - A workflow taking a generic `TriggerEvent` can still get the typed event with `github.Event.model_validate(event)`.
99
+ - The entrypoint can take a single event class (e.g. `event: github.PullRequestOpened`) or a family class (e.g.
100
+ `event: github.PullRequestEvent`, any pull request action). It is parsed like through `Event`, and a payload of
101
+ another event raises a `ValidationError` (`Expected PullRequestOpened, got PullRequestClosed`): filter the trigger
102
+ so that it only fires for that event.
103
+
104
+ | Module | Event type taken from | Events |
105
+ |--------|-----------------------|--------|
106
+ | `github` | `X-GitHub-Event` header and body `action` | `<Event><Action>` for every action of `pull_request`, `pull_request_review`, `pull_request_review_comment`, `issue_comment` and `check_run` (e.g. `PullRequestOpened`, `PullRequestReviewRequested`, `CheckRunCompleted`), each a subclass of its family's `<Event>Event` (e.g. `PullRequestEvent`); `Push` |
107
+ | `slack` | Events API `event.type` / `subtype`, the interaction `type`, or the slash command `command` | `MessagePosted`, `MessageEdited`, `MessageDeleted`, `MessageOther`, `ReactionAdded`, `ReactionRemoved`, `AppMentioned`, `MemberJoined`, `AgentSessionStopped`, `BlockActions`, `ViewSubmission`, `ViewClosed`, `SlashCommand`, `AppRateLimited` |
108
+ | `linear` | Body `type` and `action` | `IssueCreated`, `IssueUpdated`, `IssueDeleted`, `IssueCommentCreated`, `IssueCommentUpdated`, `IssueCommentDeleted`, `ProjectUpdated`, `AgentSessionCreated`, `AgentSessionPrompted` |
109
+ | `notion` | Body `type` | `Page{Created,PropertiesUpdated,ContentUpdated,Moved,Deleted,Undeleted,Locked,Unlocked}`, `PageTranscriptionBlockTranscriptDeleted`, `Database{Created,ContentUpdated,Moved,Deleted,Undeleted,SchemaUpdated}`, `DataSource{Created,ContentUpdated,Moved,Deleted,Undeleted,SchemaUpdated}`, `Comment{Created,Updated,Deleted}`, `FileUpload{Created,Completed,Expired,Failed}`, `View{Created,Updated,Deleted}` |
110
+ | `lucca` | Body `topic` | `<Resource>{Created,Updated,Deleted}` for `LegalEntity`, `BusinessEstablishment`, `Department`, `Employee`, `EmployeePersonalRecord`, `Employment`, `JobPosition`, `JobQualification`, `OccupationCategory`, `EmployeeAttribute` |
111
+
112
+ The `github` module is generated from GitHub's OpenAPI description by `scripts/generate_github_models.py`: don't
113
+ edit it by hand, change the generator and run `make generate-github-models`. CI fails if the module is stale. GitHub
114
+ spells out every nested object at each place it is used: the generator merges those copies into one class per object
115
+ (`User`, `Repository`, `PullRequest`, ...), with a field required only when GitHub always sends it.
116
+
117
+ Notion and Lucca send a thin envelope (the changed resource's id and URL): fetch the full resource from their API.
118
+
119
+ Slack interactions and slash commands are delivered form-encoded: for `BlockActions`, `ViewSubmission`, `ViewClosed`
120
+ and `SlashCommand`, `body` is the decoded payload and `raw_body` keeps the original form body.
@@ -0,0 +1,4 @@
1
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
2
+
3
+ from mistralai.workflows.exports import * # noqa: F403
4
+ from mistralai.workflows.exports import __all__ as __all__
@@ -0,0 +1,10 @@
1
+ from mistralai.workflows.plugins.triggers.models import TriggerEvent, github, linear, lucca, notion, slack
2
+
3
+ __all__ = [
4
+ "TriggerEvent",
5
+ "github",
6
+ "linear",
7
+ "lucca",
8
+ "notion",
9
+ "slack",
10
+ ]
@@ -0,0 +1,11 @@
1
+ from mistralai.workflows.plugins.triggers.models import github, linear, lucca, notion, slack
2
+ from mistralai.workflows.plugins.triggers.models.trigger_event import TriggerEvent
3
+
4
+ __all__ = [
5
+ "TriggerEvent",
6
+ "github",
7
+ "linear",
8
+ "lucca",
9
+ "notion",
10
+ "slack",
11
+ ]
@@ -0,0 +1,63 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Self
4
+
5
+ from pydantic import BaseModel, GetJsonSchemaHandler, ModelWrapValidatorHandler, model_validator
6
+ from pydantic.json_schema import JsonSchemaValue
7
+ from pydantic_core import CoreSchema, PydanticCustomError
8
+
9
+ from mistralai.workflows.plugins.triggers.models.trigger_event import TriggerEvent
10
+
11
+
12
+ class ProviderEvent(TriggerEvent):
13
+ """Base of a provider's event classes, which validate into the class matching the payload.
14
+
15
+ The provider's root class implements ``_resolve_event_class``. Validating any class of the provider dispatches
16
+ through it, so a subclass used as an entrypoint type (e.g. ``github.PullRequestOpened``) gets the same parsing as
17
+ the root (e.g. Slack's form-encoded interactions) and rejects payloads of other events. The JSON schema stays the
18
+ permissive ``TriggerEvent`` one for every class, so the API starts the workflow for every payload and dispatch
19
+ happens on the worker, where a payload of another event fails the execution with a ``ValidationError``.
20
+ """
21
+
22
+ @classmethod
23
+ def _resolve_event_class(cls, data: dict[str, Any]) -> tuple[type[Self], dict[str, Any]]:
24
+ """Return the event class matching ``data`` and the data to validate it with."""
25
+ raise NotImplementedError
26
+
27
+ @classmethod
28
+ def _root(cls) -> type[ProviderEvent] | None:
29
+ return next((base for base in cls.__mro__ if "_resolve_event_class" in base.__dict__), None)
30
+
31
+ @model_validator(mode="wrap")
32
+ @classmethod
33
+ def _dispatch(cls, data: Any, handler: ModelWrapValidatorHandler[Self]) -> Self:
34
+ root = cls._root()
35
+ if root is None or root is ProviderEvent or isinstance(data, cls):
36
+ return handler(data)
37
+ if isinstance(data, BaseModel):
38
+ data = data.model_dump()
39
+ if not isinstance(data, dict):
40
+ return handler(data)
41
+ event_cls, event_data = root._resolve_event_class(data)
42
+ if event_cls is cls:
43
+ return handler(event_data)
44
+ if not issubclass(event_cls, cls):
45
+ raise PydanticCustomError(
46
+ "trigger_event_mismatch",
47
+ "Expected {expected}, got {actual}",
48
+ {"expected": cls.__name__, "actual": event_cls.__name__},
49
+ )
50
+ return event_cls.model_validate(event_data)
51
+
52
+ @classmethod
53
+ def __get_pydantic_json_schema__(cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue:
54
+ # The API validates trigger inputs against this schema before starting the workflow, and a mismatch is a
55
+ # permanent failure with no execution to inspect: register the permissive TriggerEvent schema for every class.
56
+ return handler(TriggerEvent.__pydantic_core_schema__)
57
+
58
+
59
+ def lowercase_headers(data: dict[str, Any]) -> dict[str, str]:
60
+ headers = data.get("headers")
61
+ if not isinstance(headers, dict):
62
+ return {}
63
+ return {str(name).lower(): value for name, value in headers.items()}