perceptic-workflow-sdk 0.50.94__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.
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: perceptic-workflow-sdk
3
+ Version: 0.50.94
4
+ Summary: Python SDK for Perceptic Workflow definitions - cross-language Temporal workflow types
5
+ Author: Perceptic Technologies Ltd.
6
+ License: Proprietary
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: temporalio>=1.7.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: pytest-cov; extra == "dev"
19
+ Requires-Dist: ruff; extra == "dev"
20
+ Requires-Dist: mypy; extra == "dev"
21
+ Requires-Dist: build; extra == "dev"
22
+
23
+ # Perceptic Workflow SDK
24
+
25
+ Python SDK for Perceptic Workflow definitions. This package provides cross-language Temporal workflow types that are compatible with the Java workflow definitions in perceptic-core-client.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install perceptic-workflow-sdk
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ### Workflow Events
36
+
37
+ ```python
38
+ from perceptic_workflow import (
39
+ WorkflowEvent,
40
+ InfoEvent,
41
+ CheckpointEvent,
42
+ UserInputEvent,
43
+ UserInputRequestEvent,
44
+ WorkflowCheckpointStatus,
45
+ )
46
+
47
+ # Create events
48
+ info_event = InfoEvent(
49
+ event_id=1,
50
+ type="progress",
51
+ payload={"step": "processing"},
52
+ timestamp=datetime.now()
53
+ )
54
+ ```
55
+
56
+ ### Implementing Workflows
57
+
58
+ The SDK provides a mixin class for implementing Perceptic-compatible workflows:
59
+
60
+ ```python
61
+ from temporalio import workflow
62
+ from perceptic_workflow import PercepticWorkflowMixin, WorkflowEvent
63
+
64
+ @workflow.defn
65
+ class MyWorkflow(PercepticWorkflowMixin):
66
+ def __init__(self):
67
+ self._events: list[WorkflowEvent] = []
68
+ self._paused = False
69
+
70
+ @workflow.run
71
+ async def run(self, input: dict) -> dict:
72
+ # Your workflow logic here
73
+ pass
74
+
75
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_SUBMIT_USER_INPUT)
76
+ async def submit_user_input(self, inputs: dict) -> None:
77
+ self._paused = False
78
+ # Handle user input
79
+
80
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_INTERRUPT)
81
+ async def interrupt(self, reason: str) -> None:
82
+ # Handle interruption
83
+ pass
84
+
85
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_IS_PAUSED)
86
+ def is_paused(self) -> bool:
87
+ return self._paused
88
+
89
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_GET_EVENTS)
90
+ def get_events(self, after_event_id: int | None = None) -> list[WorkflowEvent]:
91
+ if after_event_id is None:
92
+ return self._events
93
+ return [e for e in self._events if e.event_id > after_event_id]
94
+ ```
95
+
96
+ ## Compatibility
97
+
98
+ This package is designed to be compatible with:
99
+ - perceptic-core-client (Java)
100
+ - perceptic-core-workflow-runtime (Java)
101
+
102
+ The workflow definitions and event types are generated from the same JSON Schema sources to ensure cross-language compatibility.
@@ -0,0 +1,80 @@
1
+ # Perceptic Workflow SDK
2
+
3
+ Python SDK for Perceptic Workflow definitions. This package provides cross-language Temporal workflow types that are compatible with the Java workflow definitions in perceptic-core-client.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install perceptic-workflow-sdk
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Workflow Events
14
+
15
+ ```python
16
+ from perceptic_workflow import (
17
+ WorkflowEvent,
18
+ InfoEvent,
19
+ CheckpointEvent,
20
+ UserInputEvent,
21
+ UserInputRequestEvent,
22
+ WorkflowCheckpointStatus,
23
+ )
24
+
25
+ # Create events
26
+ info_event = InfoEvent(
27
+ event_id=1,
28
+ type="progress",
29
+ payload={"step": "processing"},
30
+ timestamp=datetime.now()
31
+ )
32
+ ```
33
+
34
+ ### Implementing Workflows
35
+
36
+ The SDK provides a mixin class for implementing Perceptic-compatible workflows:
37
+
38
+ ```python
39
+ from temporalio import workflow
40
+ from perceptic_workflow import PercepticWorkflowMixin, WorkflowEvent
41
+
42
+ @workflow.defn
43
+ class MyWorkflow(PercepticWorkflowMixin):
44
+ def __init__(self):
45
+ self._events: list[WorkflowEvent] = []
46
+ self._paused = False
47
+
48
+ @workflow.run
49
+ async def run(self, input: dict) -> dict:
50
+ # Your workflow logic here
51
+ pass
52
+
53
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_SUBMIT_USER_INPUT)
54
+ async def submit_user_input(self, inputs: dict) -> None:
55
+ self._paused = False
56
+ # Handle user input
57
+
58
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_INTERRUPT)
59
+ async def interrupt(self, reason: str) -> None:
60
+ # Handle interruption
61
+ pass
62
+
63
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_IS_PAUSED)
64
+ def is_paused(self) -> bool:
65
+ return self._paused
66
+
67
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_GET_EVENTS)
68
+ def get_events(self, after_event_id: int | None = None) -> list[WorkflowEvent]:
69
+ if after_event_id is None:
70
+ return self._events
71
+ return [e for e in self._events if e.event_id > after_event_id]
72
+ ```
73
+
74
+ ## Compatibility
75
+
76
+ This package is designed to be compatible with:
77
+ - perceptic-core-client (Java)
78
+ - perceptic-core-workflow-runtime (Java)
79
+
80
+ The workflow definitions and event types are generated from the same JSON Schema sources to ensure cross-language compatibility.
@@ -0,0 +1 @@
1
+ 0.50.94
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "perceptic-workflow-sdk"
7
+ dynamic = ["version"]
8
+ description = "Python SDK for Perceptic Workflow definitions - cross-language Temporal workflow types"
9
+ authors = [{name = "Perceptic Technologies Ltd."}]
10
+ readme = "README.md"
11
+ requires-python = ">=3.10"
12
+ license = {text = "Proprietary"}
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Typing :: Typed",
20
+ ]
21
+
22
+ # Runtime dependencies - minimal, only what's needed for the types
23
+ dependencies = [
24
+ "temporalio >= 1.7.0",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ # Development dependencies (install with 'pip install -e .[dev]')
29
+ dev = [
30
+ "pytest",
31
+ "pytest-cov",
32
+ "ruff",
33
+ "mypy",
34
+ "build",
35
+ ]
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.setuptools.dynamic]
41
+ version = { file = "VERSION" }
42
+
43
+ [tool.ruff]
44
+ line-length = 120
45
+ target-version = "py310"
46
+
47
+ [tool.ruff.lint]
48
+ select = ["E", "F", "I", "W"]
49
+
50
+ [tool.mypy]
51
+ python_version = "3.10"
52
+ strict = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ """Perceptic Workflow SDK - Cross-language workflow definitions."""
4
+
5
+ from perceptic_workflow.definitions import (
6
+ AgentInput,
7
+ AgentOutput,
8
+ CheckpointEvent,
9
+ InfoEvent,
10
+ UserInputEvent,
11
+ UserInputRequestEvent,
12
+ WorkflowCheckpointStatus,
13
+ WorkflowEvent,
14
+ )
15
+ from perceptic_workflow.workflows import PercepticWorkflowMixin
16
+
17
+ __all__ = [
18
+ "AgentInput",
19
+ "AgentOutput",
20
+ "WorkflowCheckpointStatus",
21
+ "WorkflowEvent",
22
+ "CheckpointEvent",
23
+ "InfoEvent",
24
+ "UserInputEvent",
25
+ "UserInputRequestEvent",
26
+ "PercepticWorkflowMixin",
27
+ ]
@@ -0,0 +1,25 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ """Workflow definition types."""
4
+
5
+ from perceptic_workflow.definitions.agent_input import AgentInput
6
+ from perceptic_workflow.definitions.agent_output import AgentOutput
7
+ from perceptic_workflow.definitions.workflow_checkpoint_status import WorkflowCheckpointStatus
8
+ from perceptic_workflow.definitions.workflow_event import (
9
+ CheckpointEvent,
10
+ InfoEvent,
11
+ UserInputEvent,
12
+ UserInputRequestEvent,
13
+ WorkflowEvent,
14
+ )
15
+
16
+ __all__ = [
17
+ "AgentInput",
18
+ "AgentOutput",
19
+ "WorkflowCheckpointStatus",
20
+ "WorkflowEvent",
21
+ "CheckpointEvent",
22
+ "InfoEvent",
23
+ "UserInputEvent",
24
+ "UserInputRequestEvent",
25
+ ]
@@ -0,0 +1,20 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Any
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class AgentInput:
11
+ """Input to an agent within a workflow conversation."""
12
+
13
+ run_rid: str
14
+ """Resource identifier for the workflow run."""
15
+
16
+ user_id: str
17
+ """Identifier of the user providing input."""
18
+
19
+ payload: dict[str, Any] | None = None
20
+ """Optional JSON payload containing the input data."""
@@ -0,0 +1,14 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Any
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class AgentOutput:
11
+ """Output from an agent within a workflow conversation."""
12
+
13
+ payload: dict[str, Any]
14
+ """JSON payload containing the output data."""
@@ -0,0 +1,13 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ from __future__ import annotations
4
+
5
+ from enum import Enum
6
+
7
+
8
+ class WorkflowCheckpointStatus(str, Enum):
9
+ """Status of a workflow checkpoint."""
10
+
11
+ ACCEPTED = "ACCEPTED"
12
+ COMPLETED = "COMPLETED"
13
+ REJECTED = "REJECTED"
@@ -0,0 +1,53 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from datetime import datetime
7
+ from typing import Any, Union
8
+
9
+ from perceptic_workflow.definitions.workflow_checkpoint_status import WorkflowCheckpointStatus
10
+
11
+
12
+ @dataclass(frozen=True)
13
+ class InfoEvent:
14
+ """Generic information event with a type and payload."""
15
+
16
+ event_id: int
17
+ type: str
18
+ payload: dict[str, Any]
19
+ timestamp: datetime
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class UserInputEvent:
24
+ """Event representing user input submitted to the workflow."""
25
+
26
+ event_id: int
27
+ input: dict[str, Any]
28
+ timestamp: datetime
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class UserInputRequestEvent:
33
+ """Event requesting user input from the client."""
34
+
35
+ event_id: int
36
+ requested_data: dict[str, Any]
37
+ timestamp: datetime
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class CheckpointEvent:
42
+ """Event representing a workflow checkpoint status update."""
43
+
44
+ event_id: int
45
+ checkpoint_name: str
46
+ update_id: str
47
+ status: WorkflowCheckpointStatus
48
+ payload: dict[str, Any]
49
+ timestamp: datetime
50
+
51
+
52
+ # Union type representing all WorkflowEvent variants
53
+ WorkflowEvent = Union[InfoEvent, UserInputEvent, UserInputRequestEvent, CheckpointEvent]
@@ -0,0 +1,9 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ """Workflow interfaces and mixins."""
4
+
5
+ from perceptic_workflow.workflows.perceptic_workflow_mixin import PercepticWorkflowMixin
6
+
7
+ __all__ = [
8
+ "PercepticWorkflowMixin",
9
+ ]
@@ -0,0 +1,109 @@
1
+ # (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.
2
+
3
+ from __future__ import annotations
4
+
5
+ from abc import ABC, abstractmethod
6
+ from typing import Any
7
+
8
+ from perceptic_workflow.definitions import WorkflowEvent
9
+
10
+
11
+ class PercepticWorkflowMixin(ABC):
12
+ """
13
+ Defines the standard Perceptic Workflow control updates that all workflows must support
14
+ to handle user interaction and interruption.
15
+
16
+ These update names are reserved and invoked directly by the Perceptic Core V3 API.
17
+ Workflows should implement this mixin in their main workflow to ensure they handle
18
+ these signals correctly.
19
+
20
+ This is a mixin class that provides the method signatures and constants for
21
+ the Perceptic workflow interface. Since Temporal's @workflow.defn decorator
22
+ must be applied to concrete classes, implement this mixin in your workflow class
23
+ and apply the appropriate decorators.
24
+
25
+ Example:
26
+ @workflow.defn
27
+ class MyWorkflow(PercepticWorkflowMixin):
28
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_SUBMIT_USER_INPUT)
29
+ async def submit_user_input(self, inputs: dict[str, Any]) -> None:
30
+ # Handle user input
31
+ pass
32
+
33
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_INTERRUPT)
34
+ async def interrupt(self, reason: str) -> None:
35
+ # Handle interruption
36
+ pass
37
+
38
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_IS_PAUSED)
39
+ def is_paused(self) -> bool:
40
+ return self._paused
41
+
42
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_GET_EVENTS)
43
+ def get_events(self, after_event_id: int | None = None) -> list[WorkflowEvent]:
44
+ return self._events
45
+ """
46
+
47
+ # The reserved update name for submitting user input to a paused workflow.
48
+ UPDATE_SUBMIT_USER_INPUT: str = "submitUserInput"
49
+
50
+ # The reserved update name for interrupting a running workflow.
51
+ UPDATE_INTERRUPT: str = "interrupt"
52
+
53
+ # The reserved query name for checking if a workflow is paused (waiting for user input).
54
+ QUERY_IS_PAUSED: str = "isPaused"
55
+
56
+ # The reserved query name for retrieving workflow events.
57
+ QUERY_GET_EVENTS: str = "getEvents"
58
+
59
+ @abstractmethod
60
+ async def submit_user_input(
61
+ self,
62
+ inputs: dict[str, Any],
63
+ ) -> None:
64
+ """
65
+ Handles user input submission.
66
+
67
+ Args:
68
+ inputs: The input data provided by the user (matching the schema requested by the workflow).
69
+ """
70
+ ...
71
+
72
+ @abstractmethod
73
+ async def interrupt(
74
+ self,
75
+ reason: str,
76
+ ) -> None:
77
+ """
78
+ Handles an interrupt signal.
79
+
80
+ Args:
81
+ reason: The reason for the interruption.
82
+ """
83
+ ...
84
+
85
+ @abstractmethod
86
+ def is_paused(self) -> bool:
87
+ """
88
+ Checks if the workflow is currently paused (waiting for user input).
89
+
90
+ Returns:
91
+ True if the workflow is paused, False otherwise.
92
+ """
93
+ ...
94
+
95
+ @abstractmethod
96
+ def get_events(
97
+ self,
98
+ after_event_id: int | None = None,
99
+ ) -> list[WorkflowEvent]:
100
+ """
101
+ Retrieves workflow events, optionally filtered to events after a given event ID.
102
+
103
+ Args:
104
+ after_event_id: If provided, only return events with eventId greater than this value.
105
+
106
+ Returns:
107
+ List of workflow events.
108
+ """
109
+ ...
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: perceptic-workflow-sdk
3
+ Version: 0.50.94
4
+ Summary: Python SDK for Perceptic Workflow definitions - cross-language Temporal workflow types
5
+ Author: Perceptic Technologies Ltd.
6
+ License: Proprietary
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: temporalio>=1.7.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: pytest-cov; extra == "dev"
19
+ Requires-Dist: ruff; extra == "dev"
20
+ Requires-Dist: mypy; extra == "dev"
21
+ Requires-Dist: build; extra == "dev"
22
+
23
+ # Perceptic Workflow SDK
24
+
25
+ Python SDK for Perceptic Workflow definitions. This package provides cross-language Temporal workflow types that are compatible with the Java workflow definitions in perceptic-core-client.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install perceptic-workflow-sdk
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ### Workflow Events
36
+
37
+ ```python
38
+ from perceptic_workflow import (
39
+ WorkflowEvent,
40
+ InfoEvent,
41
+ CheckpointEvent,
42
+ UserInputEvent,
43
+ UserInputRequestEvent,
44
+ WorkflowCheckpointStatus,
45
+ )
46
+
47
+ # Create events
48
+ info_event = InfoEvent(
49
+ event_id=1,
50
+ type="progress",
51
+ payload={"step": "processing"},
52
+ timestamp=datetime.now()
53
+ )
54
+ ```
55
+
56
+ ### Implementing Workflows
57
+
58
+ The SDK provides a mixin class for implementing Perceptic-compatible workflows:
59
+
60
+ ```python
61
+ from temporalio import workflow
62
+ from perceptic_workflow import PercepticWorkflowMixin, WorkflowEvent
63
+
64
+ @workflow.defn
65
+ class MyWorkflow(PercepticWorkflowMixin):
66
+ def __init__(self):
67
+ self._events: list[WorkflowEvent] = []
68
+ self._paused = False
69
+
70
+ @workflow.run
71
+ async def run(self, input: dict) -> dict:
72
+ # Your workflow logic here
73
+ pass
74
+
75
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_SUBMIT_USER_INPUT)
76
+ async def submit_user_input(self, inputs: dict) -> None:
77
+ self._paused = False
78
+ # Handle user input
79
+
80
+ @workflow.update(name=PercepticWorkflowMixin.UPDATE_INTERRUPT)
81
+ async def interrupt(self, reason: str) -> None:
82
+ # Handle interruption
83
+ pass
84
+
85
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_IS_PAUSED)
86
+ def is_paused(self) -> bool:
87
+ return self._paused
88
+
89
+ @workflow.query(name=PercepticWorkflowMixin.QUERY_GET_EVENTS)
90
+ def get_events(self, after_event_id: int | None = None) -> list[WorkflowEvent]:
91
+ if after_event_id is None:
92
+ return self._events
93
+ return [e for e in self._events if e.event_id > after_event_id]
94
+ ```
95
+
96
+ ## Compatibility
97
+
98
+ This package is designed to be compatible with:
99
+ - perceptic-core-client (Java)
100
+ - perceptic-core-workflow-runtime (Java)
101
+
102
+ The workflow definitions and event types are generated from the same JSON Schema sources to ensure cross-language compatibility.
@@ -0,0 +1,17 @@
1
+ README.md
2
+ VERSION
3
+ pyproject.toml
4
+ src/perceptic_workflow/__init__.py
5
+ src/perceptic_workflow/py.typed
6
+ src/perceptic_workflow/definitions/__init__.py
7
+ src/perceptic_workflow/definitions/agent_input.py
8
+ src/perceptic_workflow/definitions/agent_output.py
9
+ src/perceptic_workflow/definitions/workflow_checkpoint_status.py
10
+ src/perceptic_workflow/definitions/workflow_event.py
11
+ src/perceptic_workflow/workflows/__init__.py
12
+ src/perceptic_workflow/workflows/perceptic_workflow_mixin.py
13
+ src/perceptic_workflow_sdk.egg-info/PKG-INFO
14
+ src/perceptic_workflow_sdk.egg-info/SOURCES.txt
15
+ src/perceptic_workflow_sdk.egg-info/dependency_links.txt
16
+ src/perceptic_workflow_sdk.egg-info/requires.txt
17
+ src/perceptic_workflow_sdk.egg-info/top_level.txt
@@ -0,0 +1,8 @@
1
+ temporalio>=1.7.0
2
+
3
+ [dev]
4
+ pytest
5
+ pytest-cov
6
+ ruff
7
+ mypy
8
+ build