codecraftai-agent-kit 1.3.0__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.
Files changed (230) hide show
  1. ccai/agentkit/__init__.py +304 -0
  2. ccai/agentkit/addressresolver.py +177 -0
  3. ccai/agentkit/agent.py +2945 -0
  4. ccai/agentkit/agentaddress.py +187 -0
  5. ccai/agentkit/agentconfiguration.py +581 -0
  6. ccai/agentkit/agentidentity.py +152 -0
  7. ccai/agentkit/agentregistry.py +221 -0
  8. ccai/agentkit/agentstatemachine.py +134 -0
  9. ccai/agentkit/alternateproviderstrategy.py +36 -0
  10. ccai/agentkit/approvalgate.py +238 -0
  11. ccai/agentkit/approvalrequest.py +250 -0
  12. ccai/agentkit/asyncagent.py +187 -0
  13. ccai/agentkit/breakpoint.py +150 -0
  14. ccai/agentkit/builtinagentmetrics.py +114 -0
  15. ccai/agentkit/builtins/__init__.py +11 -0
  16. ccai/agentkit/builtins/filereadtool.py +90 -0
  17. ccai/agentkit/builtins/filewritetool.py +93 -0
  18. ccai/agentkit/builtins/httprequesttool.py +169 -0
  19. ccai/agentkit/builtins/shellcommandtool.py +190 -0
  20. ccai/agentkit/cachedresultstrategy.py +43 -0
  21. ccai/agentkit/checkpointmanager.py +219 -0
  22. ccai/agentkit/circuitbreaker.py +230 -0
  23. ccai/agentkit/circuitbreakerconfiguration.py +158 -0
  24. ccai/agentkit/circuitbreakerevent.py +158 -0
  25. ccai/agentkit/circuitbreakerhealthcheck.py +32 -0
  26. ccai/agentkit/circuitbreakerregistry.py +116 -0
  27. ccai/agentkit/circuitbreakerstate.py +44 -0
  28. ccai/agentkit/clearcacheaction.py +46 -0
  29. ccai/agentkit/concurrencybridge.py +143 -0
  30. ccai/agentkit/concurrencymodel.py +19 -0
  31. ccai/agentkit/conditionevaluator.py +594 -0
  32. ccai/agentkit/configurationchangeevent.py +179 -0
  33. ccai/agentkit/configurationerrors.py +152 -0
  34. ccai/agentkit/configurationlayer.py +160 -0
  35. ccai/agentkit/configurationlayersource.py +46 -0
  36. ccai/agentkit/configurationmanager.py +680 -0
  37. ccai/agentkit/configurationschema.py +224 -0
  38. ccai/agentkit/configurationschemafield.py +217 -0
  39. ccai/agentkit/configurationserializer.py +163 -0
  40. ccai/agentkit/configurationvalidationresult.py +118 -0
  41. ccai/agentkit/contextsummarizer.py +170 -0
  42. ccai/agentkit/contextwindow.py +264 -0
  43. ccai/agentkit/contextwindowstrategy.py +57 -0
  44. ccai/agentkit/correlationcontext.py +156 -0
  45. ccai/agentkit/costestimate.py +139 -0
  46. ccai/agentkit/costtracker.py +121 -0
  47. ccai/agentkit/deadletterentry.py +134 -0
  48. ccai/agentkit/deadletterquery.py +119 -0
  49. ccai/agentkit/deadletterqueue.py +123 -0
  50. ccai/agentkit/deadletterstore.py +86 -0
  51. ccai/agentkit/debuginspector.py +211 -0
  52. ccai/agentkit/debugsession.py +223 -0
  53. ccai/agentkit/defaultvaluestrategy.py +43 -0
  54. ccai/agentkit/degradationchangeevent.py +120 -0
  55. ccai/agentkit/degradationlevel.py +44 -0
  56. ccai/agentkit/degradationmanager.py +212 -0
  57. ccai/agentkit/degradationpolicy.py +130 -0
  58. ccai/agentkit/degradationstrategy.py +66 -0
  59. ccai/agentkit/embeddingprovider.py +106 -0
  60. ccai/agentkit/errors.py +95 -0
  61. ccai/agentkit/executionrecord.py +213 -0
  62. ccai/agentkit/executionrecorder.py +180 -0
  63. ccai/agentkit/executionrecording.py +230 -0
  64. ccai/agentkit/executionreplayer.py +187 -0
  65. ccai/agentkit/expirationpolicy.py +116 -0
  66. ccai/agentkit/fallbackchain.py +82 -0
  67. ccai/agentkit/featureflag.py +154 -0
  68. ccai/agentkit/featureflagevaluator.py +109 -0
  69. ccai/agentkit/featureflagregistry.py +258 -0
  70. ccai/agentkit/filedeadletterstore.py +112 -0
  71. ccai/agentkit/filememorystore.py +291 -0
  72. ccai/agentkit/healthcheck.py +46 -0
  73. ccai/agentkit/healthcheckregistry.py +51 -0
  74. ccai/agentkit/healthmonitor.py +258 -0
  75. ccai/agentkit/healthstatus.py +105 -0
  76. ccai/agentkit/hotreloadmonitor.py +214 -0
  77. ccai/agentkit/hotreloadpolicy.py +160 -0
  78. ccai/agentkit/inmemorydeadletterstore.py +61 -0
  79. ccai/agentkit/inmemorystore.py +173 -0
  80. ccai/agentkit/jsonmessageserializer.py +89 -0
  81. ccai/agentkit/jsonoutputparser.py +50 -0
  82. ccai/agentkit/lifecyclestate.py +22 -0
  83. ccai/agentkit/llmconversation.py +153 -0
  84. ccai/agentkit/llmerrors.py +193 -0
  85. ccai/agentkit/llmmessage.py +158 -0
  86. ccai/agentkit/llmprovider.py +158 -0
  87. ccai/agentkit/llmproviderregistry.py +200 -0
  88. ccai/agentkit/llmresponse.py +190 -0
  89. ccai/agentkit/llmstreamchunk.py +65 -0
  90. ccai/agentkit/llmstreamhandler.py +48 -0
  91. ccai/agentkit/llmtoolbridge.py +154 -0
  92. ccai/agentkit/logexporter.py +316 -0
  93. ccai/agentkit/logformatter.py +169 -0
  94. ccai/agentkit/memoryconfiguration.py +243 -0
  95. ccai/agentkit/memoryentry.py +254 -0
  96. ccai/agentkit/memoryerrors.py +135 -0
  97. ccai/agentkit/memoryindex.py +213 -0
  98. ccai/agentkit/memoryquery.py +248 -0
  99. ccai/agentkit/memoryqueryresult.py +86 -0
  100. ccai/agentkit/memoryscope.py +54 -0
  101. ccai/agentkit/memorystore.py +260 -0
  102. ccai/agentkit/memorystorehealthcheck.py +33 -0
  103. ccai/agentkit/memorystoreregistry.py +106 -0
  104. ccai/agentkit/message.py +310 -0
  105. ccai/agentkit/messageenvelope.py +144 -0
  106. ccai/agentkit/messagepattern.py +50 -0
  107. ccai/agentkit/messagerouter.py +290 -0
  108. ccai/agentkit/messageserializer.py +106 -0
  109. ccai/agentkit/messageserializerregistry.py +163 -0
  110. ccai/agentkit/messagingconfiguration.py +397 -0
  111. ccai/agentkit/messagingerrors.py +338 -0
  112. ccai/agentkit/metricdefinition.py +164 -0
  113. ccai/agentkit/metricmeasurement.py +178 -0
  114. ccai/agentkit/metricscollector.py +258 -0
  115. ccai/agentkit/metricsexporter.py +303 -0
  116. ccai/agentkit/metricsregistry.py +130 -0
  117. ccai/agentkit/metricssnapshot.py +155 -0
  118. ccai/agentkit/metrictype.py +51 -0
  119. ccai/agentkit/msgpackmessageserializer.py +97 -0
  120. ccai/agentkit/observabilityconfiguration.py +546 -0
  121. ccai/agentkit/observabilityerror.py +67 -0
  122. ccai/agentkit/observabilitypipeline.py +252 -0
  123. ccai/agentkit/outputparser.py +82 -0
  124. ccai/agentkit/outputschema.py +142 -0
  125. ccai/agentkit/parallelbranch.py +87 -0
  126. ccai/agentkit/platform/__init__.py +43 -0
  127. ccai/agentkit/platform/adapters/__init__.py +18 -0
  128. ccai/agentkit/platform/adapters/awsplatformadapter.py +1272 -0
  129. ccai/agentkit/platform/adapters/azureplatformadapter.py +1227 -0
  130. ccai/agentkit/platform/adapters/gcpplatformadapter.py +1257 -0
  131. ccai/agentkit/platform/adapters/localplatformadapter.py +956 -0
  132. ccai/agentkit/platform/adapters/platformadapter.py +139 -0
  133. ccai/agentkit/platform/deployment/__init__.py +15 -0
  134. ccai/agentkit/platform/deployment/deploymentdescriptor.py +234 -0
  135. ccai/agentkit/platform/deployment/deploymentdescriptorparser.py +178 -0
  136. ccai/agentkit/platform/deployment/deploymentdescriptorprinter.py +97 -0
  137. ccai/agentkit/platform/errors.py +224 -0
  138. ccai/agentkit/platform/platformconfiguration.py +412 -0
  139. ccai/agentkit/platform/platformdetector.py +125 -0
  140. ccai/agentkit/platform/platformruntime.py +331 -0
  141. ccai/agentkit/platform/platformserviceregistry.py +149 -0
  142. ccai/agentkit/platform/platformtype.py +60 -0
  143. ccai/agentkit/platform/services/__init__.py +19 -0
  144. ccai/agentkit/platform/services/computeservice.py +112 -0
  145. ccai/agentkit/platform/services/invocationresult.py +173 -0
  146. ccai/agentkit/platform/services/messagingservice.py +135 -0
  147. ccai/agentkit/platform/services/platformservice.py +111 -0
  148. ccai/agentkit/platform/services/queuemessage.py +193 -0
  149. ccai/agentkit/platform/services/storageobject.py +195 -0
  150. ccai/agentkit/platform/services/storageservice.py +159 -0
  151. ccai/agentkit/pluginconfiguration.py +241 -0
  152. ccai/agentkit/plugindependency.py +129 -0
  153. ccai/agentkit/plugindescriptor.py +225 -0
  154. ccai/agentkit/pluginlifecyclehook.py +41 -0
  155. ccai/agentkit/pluginmanager.py +360 -0
  156. ccai/agentkit/pluginstatus.py +47 -0
  157. ccai/agentkit/pooledagent.py +116 -0
  158. ccai/agentkit/prompttemplate.py +221 -0
  159. ccai/agentkit/prompttemplateregistry.py +145 -0
  160. ccai/agentkit/protobufmessageserializer.py +144 -0
  161. ccai/agentkit/pubsubbroker.py +311 -0
  162. ccai/agentkit/py.typed +0 -0
  163. ccai/agentkit/reconnecttransportaction.py +47 -0
  164. ccai/agentkit/regexoutputparser.py +68 -0
  165. ccai/agentkit/requestresponsehandler.py +274 -0
  166. ccai/agentkit/resetcircuitbreakeraction.py +48 -0
  167. ccai/agentkit/resilienceconfiguration.py +191 -0
  168. ccai/agentkit/resilienceerrors.py +103 -0
  169. ccai/agentkit/resiliencepipeline.py +201 -0
  170. ccai/agentkit/retryattempt.py +158 -0
  171. ccai/agentkit/retryexecutor.py +157 -0
  172. ccai/agentkit/retrypolicy.py +195 -0
  173. ccai/agentkit/retryresult.py +186 -0
  174. ccai/agentkit/selfhealingaction.py +42 -0
  175. ccai/agentkit/selfhealingpolicy.py +67 -0
  176. ccai/agentkit/selfhealingresult.py +130 -0
  177. ccai/agentkit/stepexecutionstatus.py +52 -0
  178. ccai/agentkit/stepresult.py +198 -0
  179. ccai/agentkit/steps/__init__.py +9 -0
  180. ccai/agentkit/steps/agentstep.py +247 -0
  181. ccai/agentkit/steps/approvalstep.py +276 -0
  182. ccai/agentkit/steps/llmstep.py +403 -0
  183. ccai/agentkit/steps/subworkflowstep.py +270 -0
  184. ccai/agentkit/steps/toolstep.py +265 -0
  185. ccai/agentkit/structuredlogentry.py +222 -0
  186. ccai/agentkit/structuredlogger.py +189 -0
  187. ccai/agentkit/subscription.py +141 -0
  188. ccai/agentkit/threadedagent.py +94 -0
  189. ccai/agentkit/tokenusage.py +136 -0
  190. ccai/agentkit/tool.py +203 -0
  191. ccai/agentkit/toolchain.py +268 -0
  192. ccai/agentkit/toolchainexecutor.py +134 -0
  193. ccai/agentkit/toolchainresult.py +166 -0
  194. ccai/agentkit/tooldescriptor.py +203 -0
  195. ccai/agentkit/toolerrors.py +160 -0
  196. ccai/agentkit/toolexecutor.py +168 -0
  197. ccai/agentkit/toolfactory.py +60 -0
  198. ccai/agentkit/toolregistry.py +184 -0
  199. ccai/agentkit/toolresult.py +142 -0
  200. ccai/agentkit/toolschema.py +197 -0
  201. ccai/agentkit/tracecontext.py +294 -0
  202. ccai/agentkit/traceevent.py +166 -0
  203. ccai/agentkit/traceexporter.py +305 -0
  204. ccai/agentkit/tracer.py +234 -0
  205. ccai/agentkit/tracespan.py +349 -0
  206. ccai/agentkit/transitionrecord.py +84 -0
  207. ccai/agentkit/transport.py +334 -0
  208. ccai/agentkit/transportconfiguration.py +436 -0
  209. ccai/agentkit/transporthealthcheck.py +36 -0
  210. ccai/agentkit/transportregistry.py +224 -0
  211. ccai/agentkit/transports/__init__.py +28 -0
  212. ccai/agentkit/transports/grpctransport.py +410 -0
  213. ccai/agentkit/transports/httptransport.py +423 -0
  214. ccai/agentkit/transports/messagequeuetransport.py +489 -0
  215. ccai/agentkit/transports/websockettransport.py +473 -0
  216. ccai/agentkit/workflowcheckpoint.py +208 -0
  217. ccai/agentkit/workflowconfiguration.py +295 -0
  218. ccai/agentkit/workflowcontext.py +249 -0
  219. ccai/agentkit/workflowdefinition.py +790 -0
  220. ccai/agentkit/workflowedge.py +128 -0
  221. ccai/agentkit/workflowerrors.py +295 -0
  222. ccai/agentkit/workflowexecutionstatus.py +48 -0
  223. ccai/agentkit/workflowexecutor.py +1121 -0
  224. ccai/agentkit/workflowregistry.py +185 -0
  225. ccai/agentkit/workflowresult.py +250 -0
  226. ccai/agentkit/workflowstep.py +195 -0
  227. codecraftai_agent_kit-1.3.0.dist-info/METADATA +99 -0
  228. codecraftai_agent_kit-1.3.0.dist-info/RECORD +230 -0
  229. codecraftai_agent_kit-1.3.0.dist-info/WHEEL +4 -0
  230. codecraftai_agent_kit-1.3.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,128 @@
1
+ """
2
+ Defines the WorkflowEdge class representing an immutable directed
3
+ connection between two WorkflowStep nodes in a WorkflowDefinition.
4
+
5
+ A WorkflowEdge carries a source step identifier, a target step identifier,
6
+ an optional condition expression string for conditional branching, and an
7
+ optional priority integer for ordering when multiple edges leave a step.
8
+ """
9
+
10
+ from typing import Optional
11
+
12
+
13
+ class WorkflowEdge:
14
+ """
15
+ Immutable directed connection between two WorkflowStep nodes
16
+ in a WorkflowDefinition.
17
+
18
+ A WorkflowEdge connects a source step to a target step. When a
19
+ condition expression is provided, the edge is only traversed if
20
+ the condition evaluates to True against the WorkflowContext. When
21
+ no condition is provided, the edge is unconditional and always
22
+ traversed. The priority integer controls evaluation order when
23
+ multiple conditional edges leave the same step; lower values
24
+ are evaluated first.
25
+
26
+ :param source_step_id: The identifier of the step where the edge originates.
27
+ :param target_step_id: The identifier of the step where the edge terminates.
28
+ :param condition: An optional condition expression string evaluated
29
+ against the WorkflowContext to determine traversal.
30
+ :param priority: An optional integer controlling evaluation order
31
+ among sibling edges. Lower values are evaluated first. Defaults to 0.
32
+ """
33
+
34
+ def __init__(self, source_step_id: str, target_step_id: str,
35
+ condition: Optional[str] = None, priority: int = 0) -> None:
36
+ self._source_step_id = source_step_id
37
+ self._target_step_id = target_step_id
38
+ self._condition = condition
39
+ self._priority = priority
40
+ return
41
+
42
+ @property
43
+ def source_step_id(self) -> str:
44
+ """
45
+ The identifier of the step where the edge originates.
46
+
47
+ :returns: The source step identifier string.
48
+ """
49
+ return self._source_step_id
50
+
51
+ @property
52
+ def target_step_id(self) -> str:
53
+ """
54
+ The identifier of the step where the edge terminates.
55
+
56
+ :returns: The target step identifier string.
57
+ """
58
+ return self._target_step_id
59
+
60
+ @property
61
+ def condition(self) -> Optional[str]:
62
+ """
63
+ The optional condition expression string for this edge.
64
+
65
+ When None, the edge is unconditional and always traversed.
66
+
67
+ :returns: The condition expression string or None.
68
+ """
69
+ return self._condition
70
+
71
+ @property
72
+ def priority(self) -> int:
73
+ """
74
+ The priority integer controlling evaluation order among
75
+ sibling edges originating from the same step.
76
+
77
+ Lower values are evaluated first.
78
+
79
+ :returns: The priority integer.
80
+ """
81
+ return self._priority
82
+
83
+ def as_dict(self) -> dict:
84
+ """
85
+ Returns a dictionary representation of the edge fields.
86
+
87
+ :returns: A dictionary containing source_step_id, target_step_id,
88
+ condition, and priority.
89
+ """
90
+ rtnval = {
91
+ "source_step_id": self._source_step_id,
92
+ "target_step_id": self._target_step_id,
93
+ "condition": self._condition,
94
+ "priority": self._priority
95
+ }
96
+ return rtnval
97
+
98
+ def __repr__(self) -> str:
99
+ """
100
+ Returns a detailed string representation including the class name,
101
+ source step identifier, target step identifier, and whether a
102
+ condition is present.
103
+
104
+ :returns: A repr string for debugging.
105
+ """
106
+ has_condition = self._condition is not None
107
+ repr_str = "{}(source_step_id={!r}, target_step_id={!r}, has_condition={})".format(
108
+ self.__class__.__name__, self._source_step_id, self._target_step_id, has_condition
109
+ )
110
+ return repr_str
111
+
112
+ def __str__(self) -> str:
113
+ """
114
+ Returns a human-readable summary including the source step,
115
+ target step, and condition expression.
116
+
117
+ :returns: A human-readable string describing the edge.
118
+ """
119
+ if self._condition is not None:
120
+ str_val = "Edge: {} -> {} [condition: {}, priority: {}]".format(
121
+ self._source_step_id, self._target_step_id,
122
+ self._condition, self._priority
123
+ )
124
+ else:
125
+ str_val = "Edge: {} -> {} [unconditional, priority: {}]".format(
126
+ self._source_step_id, self._target_step_id, self._priority
127
+ )
128
+ return str_val
@@ -0,0 +1,295 @@
1
+ """
2
+ Exception classes for the Workflow & Orchestration feature.
3
+
4
+ Provides WorkflowDefinitionError for structurally invalid workflow definitions,
5
+ WorkflowExecutionError for runtime step execution failures,
6
+ WorkflowCheckpointError for checkpoint save and restore failures,
7
+ and ApprovalTimeoutError for approval request timeout conditions.
8
+ """
9
+
10
+ from typing import Optional
11
+
12
+ from ccai.agentkit.errors import AgentKitError
13
+
14
+
15
+ class WorkflowDefinitionError(AgentKitError):
16
+ """
17
+ Raised when a WorkflowDefinition is structurally invalid.
18
+
19
+ Structural problems include cycles in the DAG, a missing start step,
20
+ unreachable steps, and invalid edge references.
21
+
22
+ :param workflow_name: The name of the workflow that failed validation.
23
+ :param detail: A descriptive string identifying the structural problem.
24
+ """
25
+
26
+ def __init__(self, workflow_name: str, detail: str) -> None:
27
+ self._workflow_name = workflow_name
28
+ self._detail = detail
29
+
30
+ errmsg = self._format_message()
31
+ super().__init__(errmsg)
32
+
33
+ return
34
+
35
+ @property
36
+ def workflow_name(self) -> str:
37
+ """
38
+ The name of the workflow that failed validation.
39
+
40
+ :returns: The workflow name string.
41
+ """
42
+ return self._workflow_name
43
+
44
+ @property
45
+ def detail(self) -> str:
46
+ """
47
+ A descriptive string identifying the structural problem.
48
+
49
+ :returns: The detail string.
50
+ """
51
+ return self._detail
52
+
53
+ def _format_message(self) -> str:
54
+ """
55
+ Builds a descriptive error message from the workflow name and detail.
56
+
57
+ :returns: A formatted error message string.
58
+ """
59
+ errmsg = "Workflow definition '{}' is invalid: {}".format(
60
+ self._workflow_name, self._detail
61
+ )
62
+ return errmsg
63
+
64
+ def __repr__(self) -> str:
65
+ """
66
+ Returns a detailed string representation including class name,
67
+ workflow name, and detail.
68
+
69
+ :returns: A repr string for debugging.
70
+ """
71
+ repr_str = "{}(workflow_name={!r}, detail={!r})".format(
72
+ self.__class__.__name__, self._workflow_name, self._detail
73
+ )
74
+ return repr_str
75
+
76
+
77
+ class WorkflowExecutionError(AgentKitError):
78
+ """
79
+ Raised when a workflow execution fails during step execution.
80
+
81
+ :param workflow_name: The name of the workflow that failed.
82
+ :param step_id: The identifier of the step where the error occurred.
83
+ :param cause: An optional exception that caused the failure.
84
+ """
85
+
86
+ def __init__(self, workflow_name: str, step_id: str, cause: Optional[Exception] = None) -> None:
87
+ self._workflow_name = workflow_name
88
+ self._step_id = step_id
89
+ self._cause = cause
90
+
91
+ errmsg = self._format_message()
92
+ super().__init__(errmsg, cause=cause)
93
+
94
+ return
95
+
96
+ @property
97
+ def workflow_name(self) -> str:
98
+ """
99
+ The name of the workflow that failed.
100
+
101
+ :returns: The workflow name string.
102
+ """
103
+ return self._workflow_name
104
+
105
+ @property
106
+ def step_id(self) -> str:
107
+ """
108
+ The identifier of the step where the error occurred.
109
+
110
+ :returns: The step identifier string.
111
+ """
112
+ return self._step_id
113
+
114
+ @property
115
+ def cause(self) -> Optional[Exception]:
116
+ """
117
+ The optional exception that caused the failure.
118
+
119
+ :returns: The cause exception or None.
120
+ """
121
+ return self._cause
122
+
123
+ def _format_message(self) -> str:
124
+ """
125
+ Builds a descriptive error message from the workflow name,
126
+ step identifier, and optional cause.
127
+
128
+ :returns: A formatted error message string.
129
+ """
130
+ errmsg = "Workflow '{}' execution failed at step '{}'".format(
131
+ self._workflow_name, self._step_id
132
+ )
133
+
134
+ if self._cause is not None:
135
+ errmsg = "{}: {}".format(errmsg, self._cause)
136
+
137
+ return errmsg
138
+
139
+ def __repr__(self) -> str:
140
+ """
141
+ Returns a detailed string representation including class name,
142
+ workflow name, step identifier, and cause.
143
+
144
+ :returns: A repr string for debugging.
145
+ """
146
+ repr_str = "{}(workflow_name={!r}, step_id={!r}, cause={!r})".format(
147
+ self.__class__.__name__, self._workflow_name, self._step_id, self._cause
148
+ )
149
+ return repr_str
150
+
151
+
152
+ class WorkflowCheckpointError(AgentKitError):
153
+ """
154
+ Raised when a checkpoint save or restore operation fails.
155
+
156
+ :param execution_id: The workflow execution identifier.
157
+ :param operation: The operation that failed (e.g. 'save' or 'load').
158
+ :param cause: An optional exception that caused the failure.
159
+ """
160
+
161
+ def __init__(self, execution_id: str, operation: str, cause: Optional[Exception] = None) -> None:
162
+ self._execution_id = execution_id
163
+ self._operation = operation
164
+ self._cause = cause
165
+
166
+ errmsg = self._format_message()
167
+ super().__init__(errmsg, cause=cause)
168
+
169
+ return
170
+
171
+ @property
172
+ def execution_id(self) -> str:
173
+ """
174
+ The workflow execution identifier.
175
+
176
+ :returns: The execution identifier string.
177
+ """
178
+ return self._execution_id
179
+
180
+ @property
181
+ def operation(self) -> str:
182
+ """
183
+ The checkpoint operation that failed.
184
+
185
+ :returns: The operation string (e.g. 'save' or 'load').
186
+ """
187
+ return self._operation
188
+
189
+ @property
190
+ def cause(self) -> Optional[Exception]:
191
+ """
192
+ The optional exception that caused the failure.
193
+
194
+ :returns: The cause exception or None.
195
+ """
196
+ return self._cause
197
+
198
+ def _format_message(self) -> str:
199
+ """
200
+ Builds a descriptive error message from the execution identifier,
201
+ operation, and optional cause.
202
+
203
+ :returns: A formatted error message string.
204
+ """
205
+ errmsg = "Checkpoint {} failed for execution '{}'".format(
206
+ self._operation, self._execution_id
207
+ )
208
+
209
+ if self._cause is not None:
210
+ errmsg = "{}: {}".format(errmsg, self._cause)
211
+
212
+ return errmsg
213
+
214
+ def __repr__(self) -> str:
215
+ """
216
+ Returns a detailed string representation including class name,
217
+ execution identifier, operation, and cause.
218
+
219
+ :returns: A repr string for debugging.
220
+ """
221
+ repr_str = "{}(execution_id={!r}, operation={!r}, cause={!r})".format(
222
+ self.__class__.__name__, self._execution_id, self._operation, self._cause
223
+ )
224
+ return repr_str
225
+
226
+
227
+ class ApprovalTimeoutError(AgentKitError):
228
+ """
229
+ Raised when an ApprovalRequest exceeds the configured timeout duration.
230
+
231
+ :param request_id: The approval request identifier.
232
+ :param step_id: The step identifier where the timeout occurred.
233
+ :param timeout: The timeout duration in seconds.
234
+ """
235
+
236
+ def __init__(self, request_id: str, step_id: str, timeout: float) -> None:
237
+ self._request_id = request_id
238
+ self._step_id = step_id
239
+ self._timeout = timeout
240
+
241
+ errmsg = self._format_message()
242
+ super().__init__(errmsg)
243
+
244
+ return
245
+
246
+ @property
247
+ def request_id(self) -> str:
248
+ """
249
+ The approval request identifier.
250
+
251
+ :returns: The request identifier string.
252
+ """
253
+ return self._request_id
254
+
255
+ @property
256
+ def step_id(self) -> str:
257
+ """
258
+ The step identifier where the timeout occurred.
259
+
260
+ :returns: The step identifier string.
261
+ """
262
+ return self._step_id
263
+
264
+ @property
265
+ def timeout(self) -> float:
266
+ """
267
+ The timeout duration in seconds.
268
+
269
+ :returns: The timeout value as a float.
270
+ """
271
+ return self._timeout
272
+
273
+ def _format_message(self) -> str:
274
+ """
275
+ Builds a descriptive error message from the request identifier,
276
+ step identifier, and timeout duration.
277
+
278
+ :returns: A formatted error message string.
279
+ """
280
+ errmsg = "Approval request '{}' for step '{}' timed out after {} seconds".format(
281
+ self._request_id, self._step_id, self._timeout
282
+ )
283
+ return errmsg
284
+
285
+ def __repr__(self) -> str:
286
+ """
287
+ Returns a detailed string representation including class name,
288
+ request identifier, step identifier, and timeout.
289
+
290
+ :returns: A repr string for debugging.
291
+ """
292
+ repr_str = "{}(request_id={!r}, step_id={!r}, timeout={!r})".format(
293
+ self.__class__.__name__, self._request_id, self._step_id, self._timeout
294
+ )
295
+ return repr_str
@@ -0,0 +1,48 @@
1
+ """
2
+ Defines the WorkflowExecutionStatus enum representing the possible
3
+ states of a workflow execution in the Workflow & Orchestration feature.
4
+ """
5
+
6
+ import enum
7
+
8
+ from ccai.agentkit.errors import SemanticError
9
+
10
+
11
+ class WorkflowExecutionStatus(enum.Enum):
12
+ """
13
+ Enumeration of workflow execution states.
14
+
15
+ RUNNING: The workflow is currently executing steps.
16
+ COMPLETED: The workflow has finished all steps successfully.
17
+ FAILED: The workflow has stopped due to a step failure.
18
+ PAUSED: The workflow is paused, typically awaiting approval.
19
+ CANCELLED: The workflow has been cancelled before completion.
20
+ """
21
+
22
+ RUNNING = "RUNNING"
23
+ COMPLETED = "COMPLETED"
24
+ FAILED = "FAILED"
25
+ PAUSED = "PAUSED"
26
+ CANCELLED = "CANCELLED"
27
+
28
+ @classmethod
29
+ def from_string(cls, value: str) -> "WorkflowExecutionStatus":
30
+ """
31
+ Returns the WorkflowExecutionStatus member matching the given string.
32
+
33
+ :param value: The string value to match.
34
+
35
+ :returns: The matching WorkflowExecutionStatus member.
36
+ :raises SemanticError: If the value does not match any member.
37
+ """
38
+ upper_value = value.upper()
39
+
40
+ for member in cls:
41
+ if member.value == upper_value:
42
+ return member
43
+
44
+ valid_values = [m.value for m in cls]
45
+ errmsg = "Invalid WorkflowExecutionStatus value '{}'. Valid values are: {}.".format(
46
+ value, ", ".join(valid_values)
47
+ )
48
+ raise SemanticError(errmsg)