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,187 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the AgentAddress class representing the network-addressable
|
|
3
|
+
identity of an Agent in the Communication & Messaging feature.
|
|
4
|
+
|
|
5
|
+
AgentAddress is an immutable object containing the agent identifier,
|
|
6
|
+
transport name, and protocol-specific endpoint information. It supports
|
|
7
|
+
serialization to and from JSON and dictionary representations, and
|
|
8
|
+
equality comparison by agent identifier and transport name.
|
|
9
|
+
|
|
10
|
+
.. module:: ccai.agentkit.agentaddress
|
|
11
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
12
|
+
:synopsis: Immutable agent endpoint address for message routing.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
|
|
17
|
+
from typing import Dict
|
|
18
|
+
from typing import Optional
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AgentAddress:
|
|
22
|
+
"""
|
|
23
|
+
Immutable object representing the network-addressable identity of an Agent.
|
|
24
|
+
|
|
25
|
+
Contains the agent identifier, transport name, and protocol-specific
|
|
26
|
+
endpoint information as a dictionary (supporting keys such as "host",
|
|
27
|
+
"port", "path", "queue_name", "topic"). Supports serialization to
|
|
28
|
+
dictionary and JSON formats, and deserialization from JSON.
|
|
29
|
+
|
|
30
|
+
Two AgentAddress instances are considered equal when they share the
|
|
31
|
+
same agent_identifier and transport_name. The hash is also based on
|
|
32
|
+
these two fields, enabling use as dictionary keys and set members.
|
|
33
|
+
|
|
34
|
+
:param agent_identifier: The unique identifier of the agent.
|
|
35
|
+
:param transport_name: The name of the transport used to reach the agent.
|
|
36
|
+
:param endpoint: Optional dictionary of protocol-specific endpoint information.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __init__(self, agent_identifier: str, transport_name: str,
|
|
40
|
+
endpoint: Optional[Dict] = None) -> None:
|
|
41
|
+
|
|
42
|
+
self._agent_identifier = agent_identifier
|
|
43
|
+
self._transport_name = transport_name
|
|
44
|
+
|
|
45
|
+
if endpoint is not None:
|
|
46
|
+
self._endpoint = dict(endpoint)
|
|
47
|
+
else:
|
|
48
|
+
self._endpoint = {}
|
|
49
|
+
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def agent_identifier(self) -> str:
|
|
54
|
+
"""
|
|
55
|
+
The unique identifier of the agent.
|
|
56
|
+
|
|
57
|
+
:returns: The agent identifier string.
|
|
58
|
+
"""
|
|
59
|
+
return self._agent_identifier
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def transport_name(self) -> str:
|
|
63
|
+
"""
|
|
64
|
+
The name of the transport used to reach the agent.
|
|
65
|
+
|
|
66
|
+
:returns: The transport name string.
|
|
67
|
+
"""
|
|
68
|
+
return self._transport_name
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def endpoint(self) -> Dict:
|
|
72
|
+
"""
|
|
73
|
+
A defensive copy of the protocol-specific endpoint information.
|
|
74
|
+
|
|
75
|
+
:returns: A dictionary copy of the endpoint information.
|
|
76
|
+
"""
|
|
77
|
+
return dict(self._endpoint)
|
|
78
|
+
|
|
79
|
+
def as_dict(self) -> dict:
|
|
80
|
+
"""
|
|
81
|
+
Returns a dictionary representation of the address fields.
|
|
82
|
+
|
|
83
|
+
:returns: A dictionary with agent_identifier, transport_name,
|
|
84
|
+
and endpoint.
|
|
85
|
+
"""
|
|
86
|
+
result = {
|
|
87
|
+
"agent_identifier": self._agent_identifier,
|
|
88
|
+
"transport_name": self._transport_name,
|
|
89
|
+
"endpoint": dict(self._endpoint)
|
|
90
|
+
}
|
|
91
|
+
return result
|
|
92
|
+
|
|
93
|
+
def to_json(self) -> str:
|
|
94
|
+
"""
|
|
95
|
+
Returns a JSON string representation of the address fields.
|
|
96
|
+
|
|
97
|
+
:returns: A JSON string containing agent_identifier, transport_name,
|
|
98
|
+
and endpoint.
|
|
99
|
+
"""
|
|
100
|
+
data = self.as_dict()
|
|
101
|
+
json_str = json.dumps(data)
|
|
102
|
+
return json_str
|
|
103
|
+
|
|
104
|
+
@classmethod
|
|
105
|
+
def from_dict(cls, data: dict) -> "AgentAddress":
|
|
106
|
+
"""
|
|
107
|
+
Constructs an AgentAddress from a dictionary.
|
|
108
|
+
|
|
109
|
+
:param data: A dictionary containing agent_identifier, transport_name,
|
|
110
|
+
and optionally endpoint.
|
|
111
|
+
|
|
112
|
+
:returns: An AgentAddress instance reconstructed from the dictionary data.
|
|
113
|
+
"""
|
|
114
|
+
agent_identifier = data["agent_identifier"]
|
|
115
|
+
transport_name = data["transport_name"]
|
|
116
|
+
endpoint = data.get("endpoint", {})
|
|
117
|
+
|
|
118
|
+
address = cls(
|
|
119
|
+
agent_identifier=agent_identifier,
|
|
120
|
+
transport_name=transport_name,
|
|
121
|
+
endpoint=endpoint
|
|
122
|
+
)
|
|
123
|
+
return address
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def from_json(cls, json_str: str) -> "AgentAddress":
|
|
127
|
+
"""
|
|
128
|
+
Deserializes a JSON string into an AgentAddress instance.
|
|
129
|
+
|
|
130
|
+
:param json_str: A JSON string containing address fields.
|
|
131
|
+
|
|
132
|
+
:returns: An AgentAddress instance reconstructed from the JSON data.
|
|
133
|
+
"""
|
|
134
|
+
data = json.loads(json_str)
|
|
135
|
+
address = cls.from_dict(data)
|
|
136
|
+
return address
|
|
137
|
+
|
|
138
|
+
def __eq__(self, other: object) -> bool:
|
|
139
|
+
"""
|
|
140
|
+
Compares two AgentAddress instances by agent_identifier and
|
|
141
|
+
transport_name.
|
|
142
|
+
|
|
143
|
+
:param other: The object to compare against.
|
|
144
|
+
|
|
145
|
+
:returns: True if both agent_identifier and transport_name match,
|
|
146
|
+
False otherwise.
|
|
147
|
+
"""
|
|
148
|
+
if not isinstance(other, AgentAddress):
|
|
149
|
+
return NotImplemented
|
|
150
|
+
|
|
151
|
+
is_equal = (self._agent_identifier == other._agent_identifier
|
|
152
|
+
and self._transport_name == other._transport_name)
|
|
153
|
+
return is_equal
|
|
154
|
+
|
|
155
|
+
def __hash__(self) -> int:
|
|
156
|
+
"""
|
|
157
|
+
Returns a hash based on agent_identifier and transport_name,
|
|
158
|
+
enabling use as a dictionary key or set member.
|
|
159
|
+
|
|
160
|
+
:returns: An integer hash value.
|
|
161
|
+
"""
|
|
162
|
+
hash_val = hash((self._agent_identifier, self._transport_name))
|
|
163
|
+
return hash_val
|
|
164
|
+
|
|
165
|
+
def __repr__(self) -> str:
|
|
166
|
+
"""
|
|
167
|
+
Returns a detailed string representation including class name,
|
|
168
|
+
agent identifier, and transport name.
|
|
169
|
+
|
|
170
|
+
:returns: A repr string for debugging.
|
|
171
|
+
"""
|
|
172
|
+
repr_str = "AgentAddress(agent_identifier={!r}, transport_name={!r})".format(
|
|
173
|
+
self._agent_identifier, self._transport_name
|
|
174
|
+
)
|
|
175
|
+
return repr_str
|
|
176
|
+
|
|
177
|
+
def __str__(self) -> str:
|
|
178
|
+
"""
|
|
179
|
+
Returns a human-readable summary including the agent identifier,
|
|
180
|
+
transport name, and endpoint information.
|
|
181
|
+
|
|
182
|
+
:returns: A human-readable string.
|
|
183
|
+
"""
|
|
184
|
+
str_val = "AgentAddress: agent={}, transport={}, endpoint={}".format(
|
|
185
|
+
self._agent_identifier, self._transport_name, self._endpoint
|
|
186
|
+
)
|
|
187
|
+
return str_val
|