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.
- ccai/agentkit/__init__.py +304 -0
- ccai/agentkit/addressresolver.py +177 -0
- ccai/agentkit/agent.py +2945 -0
- ccai/agentkit/agentaddress.py +187 -0
- ccai/agentkit/agentconfiguration.py +581 -0
- ccai/agentkit/agentidentity.py +152 -0
- ccai/agentkit/agentregistry.py +221 -0
- ccai/agentkit/agentstatemachine.py +134 -0
- ccai/agentkit/alternateproviderstrategy.py +36 -0
- ccai/agentkit/approvalgate.py +238 -0
- ccai/agentkit/approvalrequest.py +250 -0
- ccai/agentkit/asyncagent.py +187 -0
- ccai/agentkit/breakpoint.py +150 -0
- ccai/agentkit/builtinagentmetrics.py +114 -0
- ccai/agentkit/builtins/__init__.py +11 -0
- ccai/agentkit/builtins/filereadtool.py +90 -0
- ccai/agentkit/builtins/filewritetool.py +93 -0
- ccai/agentkit/builtins/httprequesttool.py +169 -0
- ccai/agentkit/builtins/shellcommandtool.py +190 -0
- ccai/agentkit/cachedresultstrategy.py +43 -0
- ccai/agentkit/checkpointmanager.py +219 -0
- ccai/agentkit/circuitbreaker.py +230 -0
- ccai/agentkit/circuitbreakerconfiguration.py +158 -0
- ccai/agentkit/circuitbreakerevent.py +158 -0
- ccai/agentkit/circuitbreakerhealthcheck.py +32 -0
- ccai/agentkit/circuitbreakerregistry.py +116 -0
- ccai/agentkit/circuitbreakerstate.py +44 -0
- ccai/agentkit/clearcacheaction.py +46 -0
- ccai/agentkit/concurrencybridge.py +143 -0
- ccai/agentkit/concurrencymodel.py +19 -0
- ccai/agentkit/conditionevaluator.py +594 -0
- ccai/agentkit/configurationchangeevent.py +179 -0
- ccai/agentkit/configurationerrors.py +152 -0
- ccai/agentkit/configurationlayer.py +160 -0
- ccai/agentkit/configurationlayersource.py +46 -0
- ccai/agentkit/configurationmanager.py +680 -0
- ccai/agentkit/configurationschema.py +224 -0
- ccai/agentkit/configurationschemafield.py +217 -0
- ccai/agentkit/configurationserializer.py +163 -0
- ccai/agentkit/configurationvalidationresult.py +118 -0
- ccai/agentkit/contextsummarizer.py +170 -0
- ccai/agentkit/contextwindow.py +264 -0
- ccai/agentkit/contextwindowstrategy.py +57 -0
- ccai/agentkit/correlationcontext.py +156 -0
- ccai/agentkit/costestimate.py +139 -0
- ccai/agentkit/costtracker.py +121 -0
- ccai/agentkit/deadletterentry.py +134 -0
- ccai/agentkit/deadletterquery.py +119 -0
- ccai/agentkit/deadletterqueue.py +123 -0
- ccai/agentkit/deadletterstore.py +86 -0
- ccai/agentkit/debuginspector.py +211 -0
- ccai/agentkit/debugsession.py +223 -0
- ccai/agentkit/defaultvaluestrategy.py +43 -0
- ccai/agentkit/degradationchangeevent.py +120 -0
- ccai/agentkit/degradationlevel.py +44 -0
- ccai/agentkit/degradationmanager.py +212 -0
- ccai/agentkit/degradationpolicy.py +130 -0
- ccai/agentkit/degradationstrategy.py +66 -0
- ccai/agentkit/embeddingprovider.py +106 -0
- ccai/agentkit/errors.py +95 -0
- ccai/agentkit/executionrecord.py +213 -0
- ccai/agentkit/executionrecorder.py +180 -0
- ccai/agentkit/executionrecording.py +230 -0
- ccai/agentkit/executionreplayer.py +187 -0
- ccai/agentkit/expirationpolicy.py +116 -0
- ccai/agentkit/fallbackchain.py +82 -0
- ccai/agentkit/featureflag.py +154 -0
- ccai/agentkit/featureflagevaluator.py +109 -0
- ccai/agentkit/featureflagregistry.py +258 -0
- ccai/agentkit/filedeadletterstore.py +112 -0
- ccai/agentkit/filememorystore.py +291 -0
- ccai/agentkit/healthcheck.py +46 -0
- ccai/agentkit/healthcheckregistry.py +51 -0
- ccai/agentkit/healthmonitor.py +258 -0
- ccai/agentkit/healthstatus.py +105 -0
- ccai/agentkit/hotreloadmonitor.py +214 -0
- ccai/agentkit/hotreloadpolicy.py +160 -0
- ccai/agentkit/inmemorydeadletterstore.py +61 -0
- ccai/agentkit/inmemorystore.py +173 -0
- ccai/agentkit/jsonmessageserializer.py +89 -0
- ccai/agentkit/jsonoutputparser.py +50 -0
- ccai/agentkit/lifecyclestate.py +22 -0
- ccai/agentkit/llmconversation.py +153 -0
- ccai/agentkit/llmerrors.py +193 -0
- ccai/agentkit/llmmessage.py +158 -0
- ccai/agentkit/llmprovider.py +158 -0
- ccai/agentkit/llmproviderregistry.py +200 -0
- ccai/agentkit/llmresponse.py +190 -0
- ccai/agentkit/llmstreamchunk.py +65 -0
- ccai/agentkit/llmstreamhandler.py +48 -0
- ccai/agentkit/llmtoolbridge.py +154 -0
- ccai/agentkit/logexporter.py +316 -0
- ccai/agentkit/logformatter.py +169 -0
- ccai/agentkit/memoryconfiguration.py +243 -0
- ccai/agentkit/memoryentry.py +254 -0
- ccai/agentkit/memoryerrors.py +135 -0
- ccai/agentkit/memoryindex.py +213 -0
- ccai/agentkit/memoryquery.py +248 -0
- ccai/agentkit/memoryqueryresult.py +86 -0
- ccai/agentkit/memoryscope.py +54 -0
- ccai/agentkit/memorystore.py +260 -0
- ccai/agentkit/memorystorehealthcheck.py +33 -0
- ccai/agentkit/memorystoreregistry.py +106 -0
- ccai/agentkit/message.py +310 -0
- ccai/agentkit/messageenvelope.py +144 -0
- ccai/agentkit/messagepattern.py +50 -0
- ccai/agentkit/messagerouter.py +290 -0
- ccai/agentkit/messageserializer.py +106 -0
- ccai/agentkit/messageserializerregistry.py +163 -0
- ccai/agentkit/messagingconfiguration.py +397 -0
- ccai/agentkit/messagingerrors.py +338 -0
- ccai/agentkit/metricdefinition.py +164 -0
- ccai/agentkit/metricmeasurement.py +178 -0
- ccai/agentkit/metricscollector.py +258 -0
- ccai/agentkit/metricsexporter.py +303 -0
- ccai/agentkit/metricsregistry.py +130 -0
- ccai/agentkit/metricssnapshot.py +155 -0
- ccai/agentkit/metrictype.py +51 -0
- ccai/agentkit/msgpackmessageserializer.py +97 -0
- ccai/agentkit/observabilityconfiguration.py +546 -0
- ccai/agentkit/observabilityerror.py +67 -0
- ccai/agentkit/observabilitypipeline.py +252 -0
- ccai/agentkit/outputparser.py +82 -0
- ccai/agentkit/outputschema.py +142 -0
- ccai/agentkit/parallelbranch.py +87 -0
- ccai/agentkit/platform/__init__.py +43 -0
- ccai/agentkit/platform/adapters/__init__.py +18 -0
- ccai/agentkit/platform/adapters/awsplatformadapter.py +1272 -0
- ccai/agentkit/platform/adapters/azureplatformadapter.py +1227 -0
- ccai/agentkit/platform/adapters/gcpplatformadapter.py +1257 -0
- ccai/agentkit/platform/adapters/localplatformadapter.py +956 -0
- ccai/agentkit/platform/adapters/platformadapter.py +139 -0
- ccai/agentkit/platform/deployment/__init__.py +15 -0
- ccai/agentkit/platform/deployment/deploymentdescriptor.py +234 -0
- ccai/agentkit/platform/deployment/deploymentdescriptorparser.py +178 -0
- ccai/agentkit/platform/deployment/deploymentdescriptorprinter.py +97 -0
- ccai/agentkit/platform/errors.py +224 -0
- ccai/agentkit/platform/platformconfiguration.py +412 -0
- ccai/agentkit/platform/platformdetector.py +125 -0
- ccai/agentkit/platform/platformruntime.py +331 -0
- ccai/agentkit/platform/platformserviceregistry.py +149 -0
- ccai/agentkit/platform/platformtype.py +60 -0
- ccai/agentkit/platform/services/__init__.py +19 -0
- ccai/agentkit/platform/services/computeservice.py +112 -0
- ccai/agentkit/platform/services/invocationresult.py +173 -0
- ccai/agentkit/platform/services/messagingservice.py +135 -0
- ccai/agentkit/platform/services/platformservice.py +111 -0
- ccai/agentkit/platform/services/queuemessage.py +193 -0
- ccai/agentkit/platform/services/storageobject.py +195 -0
- ccai/agentkit/platform/services/storageservice.py +159 -0
- ccai/agentkit/pluginconfiguration.py +241 -0
- ccai/agentkit/plugindependency.py +129 -0
- ccai/agentkit/plugindescriptor.py +225 -0
- ccai/agentkit/pluginlifecyclehook.py +41 -0
- ccai/agentkit/pluginmanager.py +360 -0
- ccai/agentkit/pluginstatus.py +47 -0
- ccai/agentkit/pooledagent.py +116 -0
- ccai/agentkit/prompttemplate.py +221 -0
- ccai/agentkit/prompttemplateregistry.py +145 -0
- ccai/agentkit/protobufmessageserializer.py +144 -0
- ccai/agentkit/pubsubbroker.py +311 -0
- ccai/agentkit/py.typed +0 -0
- ccai/agentkit/reconnecttransportaction.py +47 -0
- ccai/agentkit/regexoutputparser.py +68 -0
- ccai/agentkit/requestresponsehandler.py +274 -0
- ccai/agentkit/resetcircuitbreakeraction.py +48 -0
- ccai/agentkit/resilienceconfiguration.py +191 -0
- ccai/agentkit/resilienceerrors.py +103 -0
- ccai/agentkit/resiliencepipeline.py +201 -0
- ccai/agentkit/retryattempt.py +158 -0
- ccai/agentkit/retryexecutor.py +157 -0
- ccai/agentkit/retrypolicy.py +195 -0
- ccai/agentkit/retryresult.py +186 -0
- ccai/agentkit/selfhealingaction.py +42 -0
- ccai/agentkit/selfhealingpolicy.py +67 -0
- ccai/agentkit/selfhealingresult.py +130 -0
- ccai/agentkit/stepexecutionstatus.py +52 -0
- ccai/agentkit/stepresult.py +198 -0
- ccai/agentkit/steps/__init__.py +9 -0
- ccai/agentkit/steps/agentstep.py +247 -0
- ccai/agentkit/steps/approvalstep.py +276 -0
- ccai/agentkit/steps/llmstep.py +403 -0
- ccai/agentkit/steps/subworkflowstep.py +270 -0
- ccai/agentkit/steps/toolstep.py +265 -0
- ccai/agentkit/structuredlogentry.py +222 -0
- ccai/agentkit/structuredlogger.py +189 -0
- ccai/agentkit/subscription.py +141 -0
- ccai/agentkit/threadedagent.py +94 -0
- ccai/agentkit/tokenusage.py +136 -0
- ccai/agentkit/tool.py +203 -0
- ccai/agentkit/toolchain.py +268 -0
- ccai/agentkit/toolchainexecutor.py +134 -0
- ccai/agentkit/toolchainresult.py +166 -0
- ccai/agentkit/tooldescriptor.py +203 -0
- ccai/agentkit/toolerrors.py +160 -0
- ccai/agentkit/toolexecutor.py +168 -0
- ccai/agentkit/toolfactory.py +60 -0
- ccai/agentkit/toolregistry.py +184 -0
- ccai/agentkit/toolresult.py +142 -0
- ccai/agentkit/toolschema.py +197 -0
- ccai/agentkit/tracecontext.py +294 -0
- ccai/agentkit/traceevent.py +166 -0
- ccai/agentkit/traceexporter.py +305 -0
- ccai/agentkit/tracer.py +234 -0
- ccai/agentkit/tracespan.py +349 -0
- ccai/agentkit/transitionrecord.py +84 -0
- ccai/agentkit/transport.py +334 -0
- ccai/agentkit/transportconfiguration.py +436 -0
- ccai/agentkit/transporthealthcheck.py +36 -0
- ccai/agentkit/transportregistry.py +224 -0
- ccai/agentkit/transports/__init__.py +28 -0
- ccai/agentkit/transports/grpctransport.py +410 -0
- ccai/agentkit/transports/httptransport.py +423 -0
- ccai/agentkit/transports/messagequeuetransport.py +489 -0
- ccai/agentkit/transports/websockettransport.py +473 -0
- ccai/agentkit/workflowcheckpoint.py +208 -0
- ccai/agentkit/workflowconfiguration.py +295 -0
- ccai/agentkit/workflowcontext.py +249 -0
- ccai/agentkit/workflowdefinition.py +790 -0
- ccai/agentkit/workflowedge.py +128 -0
- ccai/agentkit/workflowerrors.py +295 -0
- ccai/agentkit/workflowexecutionstatus.py +48 -0
- ccai/agentkit/workflowexecutor.py +1121 -0
- ccai/agentkit/workflowregistry.py +185 -0
- ccai/agentkit/workflowresult.py +250 -0
- ccai/agentkit/workflowstep.py +195 -0
- codecraftai_agent_kit-1.3.0.dist-info/METADATA +99 -0
- codecraftai_agent_kit-1.3.0.dist-info/RECORD +230 -0
- codecraftai_agent_kit-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_agent_kit-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the ComputeService abstract base class representing a compute
|
|
3
|
+
service that can invoke functions, manage execution contexts, and report
|
|
4
|
+
execution status. Concrete implementations wrap AWS Lambda, Azure
|
|
5
|
+
Functions, GCP Cloud Functions, and local process execution.
|
|
6
|
+
|
|
7
|
+
.. module:: ccai.agentkit.platform.services.computeservice
|
|
8
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
9
|
+
:synopsis: Abstract compute service interface for platform compute services.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import abc
|
|
13
|
+
|
|
14
|
+
from ccai.agentkit.platform.platformtype import PlatformType
|
|
15
|
+
from ccai.agentkit.platform.services.platformservice import PlatformService
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ComputeService(PlatformService, abc.ABC):
|
|
19
|
+
"""
|
|
20
|
+
Abstract base class representing a compute service that can invoke
|
|
21
|
+
functions, manage execution contexts, and report execution status.
|
|
22
|
+
|
|
23
|
+
Inherits from PlatformService with service_type fixed to "compute".
|
|
24
|
+
Subclasses must implement invoke, invoke_async, get_invocation_status,
|
|
25
|
+
and list_functions in addition to is_available and health_check.
|
|
26
|
+
|
|
27
|
+
:param service_name: A string identifying this compute service instance.
|
|
28
|
+
:param platform_type: The PlatformType this service targets.
|
|
29
|
+
:param configuration: An optional PlatformConfiguration for service-specific settings.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, service_name: str, platform_type: PlatformType,
|
|
33
|
+
configuration: "PlatformConfiguration" = None) -> None:
|
|
34
|
+
super().__init__(
|
|
35
|
+
service_name=service_name,
|
|
36
|
+
service_type="compute",
|
|
37
|
+
platform_type=platform_type,
|
|
38
|
+
configuration=configuration
|
|
39
|
+
)
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
@abc.abstractmethod
|
|
43
|
+
def invoke(self, function_name: str, payload: dict,
|
|
44
|
+
timeout: float = None) -> "InvocationResult":
|
|
45
|
+
"""
|
|
46
|
+
Invokes a function synchronously.
|
|
47
|
+
|
|
48
|
+
:param function_name: Name of the function to invoke.
|
|
49
|
+
:param payload: Dictionary payload to pass to the function.
|
|
50
|
+
:param timeout: Optional timeout in seconds.
|
|
51
|
+
|
|
52
|
+
:returns: An InvocationResult with the execution outcome.
|
|
53
|
+
:raises: ComputeError
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
@abc.abstractmethod
|
|
57
|
+
def invoke_async(self, function_name: str, payload: dict) -> str:
|
|
58
|
+
"""
|
|
59
|
+
Invokes a function asynchronously.
|
|
60
|
+
|
|
61
|
+
:param function_name: Name of the function to invoke.
|
|
62
|
+
:param payload: Dictionary payload to pass to the function.
|
|
63
|
+
|
|
64
|
+
:returns: A request identifier string for tracking.
|
|
65
|
+
:raises: ComputeError
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
@abc.abstractmethod
|
|
69
|
+
def get_invocation_status(self, request_id: str) -> "InvocationResult":
|
|
70
|
+
"""
|
|
71
|
+
Returns the current status of an asynchronous invocation.
|
|
72
|
+
|
|
73
|
+
:param request_id: The request identifier from invoke_async.
|
|
74
|
+
|
|
75
|
+
:returns: An InvocationResult representing the current status.
|
|
76
|
+
:raises: ComputeError
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
@abc.abstractmethod
|
|
80
|
+
def list_functions(self) -> list:
|
|
81
|
+
"""
|
|
82
|
+
Returns a list of available function name strings.
|
|
83
|
+
|
|
84
|
+
:returns: List of function name strings.
|
|
85
|
+
:raises: ComputeError
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
def __repr__(self) -> str:
|
|
89
|
+
"""
|
|
90
|
+
Returns a detailed string representation including class name,
|
|
91
|
+
service name, and platform type.
|
|
92
|
+
|
|
93
|
+
:returns: A repr string for debugging.
|
|
94
|
+
"""
|
|
95
|
+
rtnval = "{}(service_name={}, platform_type={})".format(
|
|
96
|
+
self.__class__.__name__, self._service_name,
|
|
97
|
+
self._platform_type.to_string()
|
|
98
|
+
)
|
|
99
|
+
return rtnval
|
|
100
|
+
|
|
101
|
+
def __str__(self) -> str:
|
|
102
|
+
"""
|
|
103
|
+
Returns a human-readable summary including the service name
|
|
104
|
+
and platform type.
|
|
105
|
+
|
|
106
|
+
:returns: A human-readable string.
|
|
107
|
+
"""
|
|
108
|
+
rtnval = "{}: name={}, platform={}".format(
|
|
109
|
+
self.__class__.__name__, self._service_name,
|
|
110
|
+
self._platform_type.to_string()
|
|
111
|
+
)
|
|
112
|
+
return rtnval
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the InvocationResult class representing an immutable result of
|
|
3
|
+
a compute invocation with status, response payload, optional error
|
|
4
|
+
message, execution duration, and request identifier. Supports
|
|
5
|
+
serialization to and from dictionary and JSON representations.
|
|
6
|
+
|
|
7
|
+
.. module:: ccai.agentkit.platform.services.invocationresult
|
|
8
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
9
|
+
:synopsis: Immutable compute invocation result for platform compute services.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
|
|
14
|
+
from typing import Optional
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class InvocationResult:
|
|
18
|
+
"""
|
|
19
|
+
Immutable object representing the result of a compute invocation.
|
|
20
|
+
Contains a status string (one of "success", "error", "timeout"),
|
|
21
|
+
a response payload as a Python object, an optional error message,
|
|
22
|
+
the execution duration in seconds, and a request identifier.
|
|
23
|
+
|
|
24
|
+
All fields are exposed as read-only properties.
|
|
25
|
+
|
|
26
|
+
:param status: The invocation status ("success", "error", or "timeout").
|
|
27
|
+
:param response: The response payload as a Python object.
|
|
28
|
+
:param error_message: An optional error message string.
|
|
29
|
+
:param duration: The execution duration in seconds.
|
|
30
|
+
:param request_id: A request identifier string.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
VALID_STATUSES = ("success", "error", "timeout")
|
|
34
|
+
|
|
35
|
+
def __init__(self, status: str, response: object = None,
|
|
36
|
+
error_message: Optional[str] = None,
|
|
37
|
+
duration: float = 0.0, request_id: str = "") -> None:
|
|
38
|
+
self._status = status
|
|
39
|
+
self._response = response
|
|
40
|
+
self._error_message = error_message
|
|
41
|
+
self._duration = duration
|
|
42
|
+
self._request_id = request_id
|
|
43
|
+
return
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def status(self) -> str:
|
|
47
|
+
"""
|
|
48
|
+
The invocation status string.
|
|
49
|
+
|
|
50
|
+
:returns: One of "success", "error", or "timeout".
|
|
51
|
+
"""
|
|
52
|
+
rtnval = self._status
|
|
53
|
+
return rtnval
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def response(self) -> object:
|
|
57
|
+
"""
|
|
58
|
+
The response payload as a Python object.
|
|
59
|
+
|
|
60
|
+
:returns: The response object.
|
|
61
|
+
"""
|
|
62
|
+
rtnval = self._response
|
|
63
|
+
return rtnval
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def error_message(self) -> str:
|
|
67
|
+
"""
|
|
68
|
+
The optional error message string.
|
|
69
|
+
|
|
70
|
+
:returns: The error message string or None.
|
|
71
|
+
"""
|
|
72
|
+
rtnval = self._error_message
|
|
73
|
+
return rtnval
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def duration(self) -> float:
|
|
77
|
+
"""
|
|
78
|
+
The execution duration in seconds.
|
|
79
|
+
|
|
80
|
+
:returns: The duration float.
|
|
81
|
+
"""
|
|
82
|
+
rtnval = self._duration
|
|
83
|
+
return rtnval
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def request_id(self) -> str:
|
|
87
|
+
"""
|
|
88
|
+
The request identifier string.
|
|
89
|
+
|
|
90
|
+
:returns: The request identifier string.
|
|
91
|
+
"""
|
|
92
|
+
rtnval = self._request_id
|
|
93
|
+
return rtnval
|
|
94
|
+
|
|
95
|
+
def as_dict(self) -> dict:
|
|
96
|
+
"""
|
|
97
|
+
Returns a dictionary representation of the result fields.
|
|
98
|
+
|
|
99
|
+
:returns: A dictionary with all result fields.
|
|
100
|
+
"""
|
|
101
|
+
rtnval = {
|
|
102
|
+
"status": self._status,
|
|
103
|
+
"response": self._response,
|
|
104
|
+
"error_message": self._error_message,
|
|
105
|
+
"duration": self._duration,
|
|
106
|
+
"request_id": self._request_id
|
|
107
|
+
}
|
|
108
|
+
return rtnval
|
|
109
|
+
|
|
110
|
+
def to_json(self) -> str:
|
|
111
|
+
"""
|
|
112
|
+
Returns a JSON string representation of the result fields.
|
|
113
|
+
|
|
114
|
+
:returns: A JSON string.
|
|
115
|
+
"""
|
|
116
|
+
data = self.as_dict()
|
|
117
|
+
rtnval = json.dumps(data)
|
|
118
|
+
return rtnval
|
|
119
|
+
|
|
120
|
+
@classmethod
|
|
121
|
+
def from_dict(cls, data: dict) -> "InvocationResult":
|
|
122
|
+
"""
|
|
123
|
+
Constructs an InvocationResult from a dictionary.
|
|
124
|
+
|
|
125
|
+
:param data: Dictionary containing result fields.
|
|
126
|
+
|
|
127
|
+
:returns: An InvocationResult instance.
|
|
128
|
+
"""
|
|
129
|
+
rtnval = cls(
|
|
130
|
+
status=data["status"],
|
|
131
|
+
response=data.get("response"),
|
|
132
|
+
error_message=data.get("error_message"),
|
|
133
|
+
duration=data.get("duration", 0.0),
|
|
134
|
+
request_id=data.get("request_id", "")
|
|
135
|
+
)
|
|
136
|
+
return rtnval
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def from_json(cls, json_str: str) -> "InvocationResult":
|
|
140
|
+
"""
|
|
141
|
+
Deserializes a JSON string into an InvocationResult instance.
|
|
142
|
+
|
|
143
|
+
:param json_str: A JSON string containing result fields.
|
|
144
|
+
|
|
145
|
+
:returns: An InvocationResult instance.
|
|
146
|
+
"""
|
|
147
|
+
data = json.loads(json_str)
|
|
148
|
+
rtnval = cls.from_dict(data)
|
|
149
|
+
return rtnval
|
|
150
|
+
|
|
151
|
+
def __repr__(self) -> str:
|
|
152
|
+
"""
|
|
153
|
+
Returns a detailed string representation including class name,
|
|
154
|
+
status, and request identifier.
|
|
155
|
+
|
|
156
|
+
:returns: A repr string for debugging.
|
|
157
|
+
"""
|
|
158
|
+
rtnval = "InvocationResult(status={}, request_id={})".format(
|
|
159
|
+
self._status, self._request_id
|
|
160
|
+
)
|
|
161
|
+
return rtnval
|
|
162
|
+
|
|
163
|
+
def __str__(self) -> str:
|
|
164
|
+
"""
|
|
165
|
+
Returns a human-readable summary including the status,
|
|
166
|
+
request identifier, and execution duration.
|
|
167
|
+
|
|
168
|
+
:returns: A human-readable string.
|
|
169
|
+
"""
|
|
170
|
+
rtnval = "InvocationResult: status={}, request_id={}, duration={:.3f}s".format(
|
|
171
|
+
self._status, self._request_id, self._duration
|
|
172
|
+
)
|
|
173
|
+
return rtnval
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the MessagingService abstract base class representing a message
|
|
3
|
+
queuing service that can send messages, receive messages, and manage
|
|
4
|
+
queue subscriptions. Concrete implementations wrap AWS SQS, Azure
|
|
5
|
+
Service Bus, GCP Pub/Sub, and local in-memory queuing.
|
|
6
|
+
|
|
7
|
+
.. module:: ccai.agentkit.platform.services.messagingservice
|
|
8
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
9
|
+
:synopsis: Abstract messaging service interface for platform messaging services.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import abc
|
|
13
|
+
|
|
14
|
+
from ccai.agentkit.platform.platformtype import PlatformType
|
|
15
|
+
from ccai.agentkit.platform.services.platformservice import PlatformService
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MessagingService(PlatformService, abc.ABC):
|
|
19
|
+
"""
|
|
20
|
+
Abstract base class representing a message queuing service that can
|
|
21
|
+
send messages, receive messages, and manage queue subscriptions.
|
|
22
|
+
|
|
23
|
+
Inherits from PlatformService with service_type fixed to "messaging".
|
|
24
|
+
Subclasses must implement send_message, receive_messages,
|
|
25
|
+
acknowledge_message, create_queue, delete_queue, and list_queues
|
|
26
|
+
in addition to is_available and health_check.
|
|
27
|
+
|
|
28
|
+
:param service_name: A string identifying this messaging service instance.
|
|
29
|
+
:param platform_type: The PlatformType this service targets.
|
|
30
|
+
:param configuration: An optional PlatformConfiguration for service-specific settings.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, service_name: str, platform_type: PlatformType,
|
|
34
|
+
configuration: "PlatformConfiguration" = None) -> None:
|
|
35
|
+
super().__init__(
|
|
36
|
+
service_name=service_name,
|
|
37
|
+
service_type="messaging",
|
|
38
|
+
platform_type=platform_type,
|
|
39
|
+
configuration=configuration
|
|
40
|
+
)
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
@abc.abstractmethod
|
|
44
|
+
def send_message(self, queue_name: str, body: object,
|
|
45
|
+
attributes: dict = None) -> str:
|
|
46
|
+
"""
|
|
47
|
+
Sends a message to the specified queue.
|
|
48
|
+
|
|
49
|
+
:param queue_name: Name of the target queue.
|
|
50
|
+
:param body: Message body as a Python object.
|
|
51
|
+
:param attributes: Optional message attributes dictionary.
|
|
52
|
+
|
|
53
|
+
:returns: A message identifier string.
|
|
54
|
+
:raises: MessagingError
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
@abc.abstractmethod
|
|
58
|
+
def receive_messages(self, queue_name: str, max_count: int = 1,
|
|
59
|
+
wait_time: float = None) -> list:
|
|
60
|
+
"""
|
|
61
|
+
Receives messages from the specified queue.
|
|
62
|
+
|
|
63
|
+
:param queue_name: Name of the source queue.
|
|
64
|
+
:param max_count: Maximum number of messages to receive.
|
|
65
|
+
:param wait_time: Optional wait time in seconds.
|
|
66
|
+
|
|
67
|
+
:returns: A list of QueueMessage objects.
|
|
68
|
+
:raises: MessagingError
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
@abc.abstractmethod
|
|
72
|
+
def acknowledge_message(self, queue_name: str, receipt_handle: str) -> None:
|
|
73
|
+
"""
|
|
74
|
+
Acknowledges a message for deletion from the queue.
|
|
75
|
+
|
|
76
|
+
:param queue_name: Name of the queue.
|
|
77
|
+
:param receipt_handle: Receipt handle string for the message.
|
|
78
|
+
|
|
79
|
+
:raises: MessagingError
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
@abc.abstractmethod
|
|
83
|
+
def create_queue(self, queue_name: str) -> None:
|
|
84
|
+
"""
|
|
85
|
+
Creates a message queue.
|
|
86
|
+
|
|
87
|
+
:param queue_name: Name of the queue to create.
|
|
88
|
+
|
|
89
|
+
:raises: MessagingError
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
@abc.abstractmethod
|
|
93
|
+
def delete_queue(self, queue_name: str) -> None:
|
|
94
|
+
"""
|
|
95
|
+
Removes a message queue.
|
|
96
|
+
|
|
97
|
+
:param queue_name: Name of the queue to remove.
|
|
98
|
+
|
|
99
|
+
:raises: MessagingError
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
@abc.abstractmethod
|
|
103
|
+
def list_queues(self) -> list:
|
|
104
|
+
"""
|
|
105
|
+
Returns a list of queue name strings.
|
|
106
|
+
|
|
107
|
+
:returns: List of queue name strings.
|
|
108
|
+
:raises: MessagingError
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
def __repr__(self) -> str:
|
|
112
|
+
"""
|
|
113
|
+
Returns a detailed string representation including class name,
|
|
114
|
+
service name, and platform type.
|
|
115
|
+
|
|
116
|
+
:returns: A repr string for debugging.
|
|
117
|
+
"""
|
|
118
|
+
rtnval = "{}(service_name={}, platform_type={})".format(
|
|
119
|
+
self.__class__.__name__, self._service_name,
|
|
120
|
+
self._platform_type.to_string()
|
|
121
|
+
)
|
|
122
|
+
return rtnval
|
|
123
|
+
|
|
124
|
+
def __str__(self) -> str:
|
|
125
|
+
"""
|
|
126
|
+
Returns a human-readable summary including the service name
|
|
127
|
+
and platform type.
|
|
128
|
+
|
|
129
|
+
:returns: A human-readable string.
|
|
130
|
+
"""
|
|
131
|
+
rtnval = "{}: name={}, platform={}".format(
|
|
132
|
+
self.__class__.__name__, self._service_name,
|
|
133
|
+
self._platform_type.to_string()
|
|
134
|
+
)
|
|
135
|
+
return rtnval
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the PlatformService abstract base class representing a cloud
|
|
3
|
+
or local service that a platform provides. Concrete subclasses include
|
|
4
|
+
ComputeService, StorageService, and MessagingService.
|
|
5
|
+
|
|
6
|
+
.. module:: ccai.agentkit.platform.services.platformservice
|
|
7
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
8
|
+
:synopsis: Abstract base class for all platform services.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import abc
|
|
12
|
+
|
|
13
|
+
from ccai.agentkit.platform.platformtype import PlatformType
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PlatformService(abc.ABC):
|
|
17
|
+
"""
|
|
18
|
+
Abstract base class representing a cloud or local service that a
|
|
19
|
+
platform provides. Concrete subclasses include ComputeService,
|
|
20
|
+
StorageService, and MessagingService.
|
|
21
|
+
|
|
22
|
+
All platform services expose a service name, service type, and
|
|
23
|
+
platform type. Subclasses must implement the is_available and
|
|
24
|
+
health_check methods.
|
|
25
|
+
|
|
26
|
+
:param service_name: A string identifying this service instance.
|
|
27
|
+
:param service_type: The type of service (e.g. "compute", "storage", "messaging").
|
|
28
|
+
:param platform_type: The PlatformType this service targets.
|
|
29
|
+
:param configuration: An optional PlatformConfiguration for service-specific settings.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, service_name: str, service_type: str,
|
|
33
|
+
platform_type: PlatformType,
|
|
34
|
+
configuration: "PlatformConfiguration" = None) -> None:
|
|
35
|
+
self._service_name = service_name
|
|
36
|
+
self._service_type = service_type
|
|
37
|
+
self._platform_type = platform_type
|
|
38
|
+
self._configuration = configuration
|
|
39
|
+
return
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def service_name(self) -> str:
|
|
43
|
+
"""
|
|
44
|
+
The string identifying this service instance.
|
|
45
|
+
|
|
46
|
+
:returns: The service name string.
|
|
47
|
+
"""
|
|
48
|
+
rtnval = self._service_name
|
|
49
|
+
return rtnval
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def service_type(self) -> str:
|
|
53
|
+
"""
|
|
54
|
+
The type of service (e.g. "compute", "storage", "messaging").
|
|
55
|
+
|
|
56
|
+
:returns: The service type string.
|
|
57
|
+
"""
|
|
58
|
+
rtnval = self._service_type
|
|
59
|
+
return rtnval
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def platform_type(self) -> PlatformType:
|
|
63
|
+
"""
|
|
64
|
+
The PlatformType this service targets.
|
|
65
|
+
|
|
66
|
+
:returns: The PlatformType value.
|
|
67
|
+
"""
|
|
68
|
+
rtnval = self._platform_type
|
|
69
|
+
return rtnval
|
|
70
|
+
|
|
71
|
+
@abc.abstractmethod
|
|
72
|
+
def is_available(self) -> bool:
|
|
73
|
+
"""
|
|
74
|
+
Checks whether the service is available.
|
|
75
|
+
|
|
76
|
+
:returns: True if the service is available, False otherwise.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
@abc.abstractmethod
|
|
80
|
+
def health_check(self) -> bool:
|
|
81
|
+
"""
|
|
82
|
+
Returns a boolean indicating service health.
|
|
83
|
+
|
|
84
|
+
:returns: True if the service is healthy, False otherwise.
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def __repr__(self) -> str:
|
|
88
|
+
"""
|
|
89
|
+
Returns a detailed string representation including class name,
|
|
90
|
+
service name, service type, and platform type.
|
|
91
|
+
|
|
92
|
+
:returns: A repr string for debugging.
|
|
93
|
+
"""
|
|
94
|
+
rtnval = "{}(service_name={}, service_type={}, platform_type={})".format(
|
|
95
|
+
self.__class__.__name__, self._service_name,
|
|
96
|
+
self._service_type, self._platform_type.to_string()
|
|
97
|
+
)
|
|
98
|
+
return rtnval
|
|
99
|
+
|
|
100
|
+
def __str__(self) -> str:
|
|
101
|
+
"""
|
|
102
|
+
Returns a human-readable summary including the service name,
|
|
103
|
+
service type, and platform type.
|
|
104
|
+
|
|
105
|
+
:returns: A human-readable string.
|
|
106
|
+
"""
|
|
107
|
+
rtnval = "{}: name={}, type={}, platform={}".format(
|
|
108
|
+
self.__class__.__name__, self._service_name,
|
|
109
|
+
self._service_type, self._platform_type.to_string()
|
|
110
|
+
)
|
|
111
|
+
return rtnval
|