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,241 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the PluginConfiguration class representing declarative plugin
|
|
3
|
+
management settings for the codecraftai-agent-kit framework.
|
|
4
|
+
|
|
5
|
+
A PluginConfiguration contains lists of enabled and disabled plugin names,
|
|
6
|
+
plugin search paths, and an automatic discovery enabled flag.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
|
|
11
|
+
from ccai.agentkit.errors import ConfigurationError
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
import yaml
|
|
15
|
+
YAML_AVAILABLE = True
|
|
16
|
+
except ImportError:
|
|
17
|
+
YAML_AVAILABLE = False
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PluginConfiguration:
|
|
21
|
+
"""
|
|
22
|
+
Configuration object defining plugin management settings including
|
|
23
|
+
enabled/disabled plugin lists, search paths, and auto-discovery.
|
|
24
|
+
|
|
25
|
+
:param enabled_plugins: An optional list of enabled plugin name strings.
|
|
26
|
+
:param disabled_plugins: An optional list of disabled plugin name strings.
|
|
27
|
+
:param search_paths: An optional list of plugin search path strings.
|
|
28
|
+
:param automatic_discovery_enabled: Whether automatic plugin discovery is enabled.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, enabled_plugins: list = None, disabled_plugins: list = None,
|
|
32
|
+
search_paths: list = None, automatic_discovery_enabled: bool = True) -> None:
|
|
33
|
+
|
|
34
|
+
if enabled_plugins is not None:
|
|
35
|
+
self._enabled_plugins = list(enabled_plugins)
|
|
36
|
+
else:
|
|
37
|
+
self._enabled_plugins = []
|
|
38
|
+
|
|
39
|
+
if disabled_plugins is not None:
|
|
40
|
+
self._disabled_plugins = list(disabled_plugins)
|
|
41
|
+
else:
|
|
42
|
+
self._disabled_plugins = []
|
|
43
|
+
|
|
44
|
+
if search_paths is not None:
|
|
45
|
+
self._search_paths = list(search_paths)
|
|
46
|
+
else:
|
|
47
|
+
self._search_paths = []
|
|
48
|
+
|
|
49
|
+
self._automatic_discovery_enabled = automatic_discovery_enabled
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def enabled_plugins(self) -> list:
|
|
54
|
+
"""
|
|
55
|
+
A defensive copy of the list of enabled plugin name strings.
|
|
56
|
+
|
|
57
|
+
:returns: A list copy of the enabled plugin names.
|
|
58
|
+
"""
|
|
59
|
+
return list(self._enabled_plugins)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def disabled_plugins(self) -> list:
|
|
63
|
+
"""
|
|
64
|
+
A defensive copy of the list of disabled plugin name strings.
|
|
65
|
+
|
|
66
|
+
:returns: A list copy of the disabled plugin names.
|
|
67
|
+
"""
|
|
68
|
+
return list(self._disabled_plugins)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def search_paths(self) -> list:
|
|
72
|
+
"""
|
|
73
|
+
A defensive copy of the list of plugin search path strings.
|
|
74
|
+
|
|
75
|
+
:returns: A list copy of the search path strings.
|
|
76
|
+
"""
|
|
77
|
+
return list(self._search_paths)
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def automatic_discovery_enabled(self) -> bool:
|
|
81
|
+
"""
|
|
82
|
+
Whether automatic plugin discovery is enabled.
|
|
83
|
+
|
|
84
|
+
:returns: True if automatic discovery is enabled, False otherwise.
|
|
85
|
+
"""
|
|
86
|
+
return self._automatic_discovery_enabled
|
|
87
|
+
|
|
88
|
+
def as_dict(self) -> dict:
|
|
89
|
+
"""
|
|
90
|
+
Returns a dictionary representation of the configuration fields.
|
|
91
|
+
|
|
92
|
+
:returns: A dictionary with enabled_plugins, disabled_plugins,
|
|
93
|
+
search_paths, and automatic_discovery_enabled.
|
|
94
|
+
"""
|
|
95
|
+
result = {
|
|
96
|
+
"enabled_plugins": list(self._enabled_plugins),
|
|
97
|
+
"disabled_plugins": list(self._disabled_plugins),
|
|
98
|
+
"search_paths": list(self._search_paths),
|
|
99
|
+
"automatic_discovery_enabled": self._automatic_discovery_enabled
|
|
100
|
+
}
|
|
101
|
+
return result
|
|
102
|
+
|
|
103
|
+
def to_json(self) -> str:
|
|
104
|
+
"""
|
|
105
|
+
Returns a JSON string representation of the configuration fields.
|
|
106
|
+
|
|
107
|
+
:returns: A JSON string containing all configuration fields.
|
|
108
|
+
"""
|
|
109
|
+
data = self.as_dict()
|
|
110
|
+
json_str = json.dumps(data)
|
|
111
|
+
return json_str
|
|
112
|
+
|
|
113
|
+
@classmethod
|
|
114
|
+
def from_dict(cls, data: dict) -> "PluginConfiguration":
|
|
115
|
+
"""
|
|
116
|
+
Constructs a PluginConfiguration from a dictionary.
|
|
117
|
+
|
|
118
|
+
:param data: A dictionary containing enabled_plugins, disabled_plugins,
|
|
119
|
+
search_paths, and automatic_discovery_enabled.
|
|
120
|
+
|
|
121
|
+
:returns: A PluginConfiguration instance reconstructed from the dictionary.
|
|
122
|
+
"""
|
|
123
|
+
enabled_plugins = data.get("enabled_plugins", None)
|
|
124
|
+
disabled_plugins = data.get("disabled_plugins", None)
|
|
125
|
+
search_paths = data.get("search_paths", None)
|
|
126
|
+
automatic_discovery_enabled = data.get("automatic_discovery_enabled", True)
|
|
127
|
+
|
|
128
|
+
config = cls(
|
|
129
|
+
enabled_plugins=enabled_plugins,
|
|
130
|
+
disabled_plugins=disabled_plugins,
|
|
131
|
+
search_paths=search_paths,
|
|
132
|
+
automatic_discovery_enabled=automatic_discovery_enabled
|
|
133
|
+
)
|
|
134
|
+
return config
|
|
135
|
+
|
|
136
|
+
@classmethod
|
|
137
|
+
def from_json(cls, json_str: str) -> "PluginConfiguration":
|
|
138
|
+
"""
|
|
139
|
+
Deserializes a JSON string into a PluginConfiguration instance.
|
|
140
|
+
|
|
141
|
+
:param json_str: A JSON string containing configuration fields.
|
|
142
|
+
|
|
143
|
+
:returns: A PluginConfiguration instance reconstructed from the JSON data.
|
|
144
|
+
"""
|
|
145
|
+
data = json.loads(json_str)
|
|
146
|
+
config = cls.from_dict(data)
|
|
147
|
+
return config
|
|
148
|
+
|
|
149
|
+
@classmethod
|
|
150
|
+
def from_json_file(cls, file_path: str) -> "PluginConfiguration":
|
|
151
|
+
"""
|
|
152
|
+
Loads a PluginConfiguration from a JSON file.
|
|
153
|
+
|
|
154
|
+
:param file_path: Path to the JSON file.
|
|
155
|
+
|
|
156
|
+
:returns: A PluginConfiguration instance loaded from the file.
|
|
157
|
+
:raises: ConfigurationError
|
|
158
|
+
"""
|
|
159
|
+
try:
|
|
160
|
+
with open(file_path, "r") as file_handle:
|
|
161
|
+
content = file_handle.read()
|
|
162
|
+
except (OSError, IOError) as err:
|
|
163
|
+
errmsg = "Failed to read plugin configuration file '{}': {}".format(
|
|
164
|
+
file_path, str(err)
|
|
165
|
+
)
|
|
166
|
+
raise ConfigurationError(errmsg, cause=err) from err
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
data = json.loads(content)
|
|
170
|
+
except json.JSONDecodeError as err:
|
|
171
|
+
errmsg = "Failed to parse JSON plugin configuration file '{}': {}".format(
|
|
172
|
+
file_path, str(err)
|
|
173
|
+
)
|
|
174
|
+
raise ConfigurationError(errmsg, cause=err) from err
|
|
175
|
+
|
|
176
|
+
config = cls.from_dict(data)
|
|
177
|
+
return config
|
|
178
|
+
|
|
179
|
+
@classmethod
|
|
180
|
+
def from_yaml_file(cls, file_path: str) -> "PluginConfiguration":
|
|
181
|
+
"""
|
|
182
|
+
Loads a PluginConfiguration from a YAML file.
|
|
183
|
+
|
|
184
|
+
:param file_path: Path to the YAML file.
|
|
185
|
+
|
|
186
|
+
:returns: A PluginConfiguration instance loaded from the file.
|
|
187
|
+
:raises: ConfigurationError
|
|
188
|
+
"""
|
|
189
|
+
if YAML_AVAILABLE is not True:
|
|
190
|
+
errmsg = "PyYAML is not available. Install PyYAML to load YAML plugin configuration."
|
|
191
|
+
raise ConfigurationError(errmsg)
|
|
192
|
+
|
|
193
|
+
try:
|
|
194
|
+
with open(file_path, "r") as file_handle:
|
|
195
|
+
content = file_handle.read()
|
|
196
|
+
except (OSError, IOError) as err:
|
|
197
|
+
errmsg = "Failed to read plugin configuration file '{}': {}".format(
|
|
198
|
+
file_path, str(err)
|
|
199
|
+
)
|
|
200
|
+
raise ConfigurationError(errmsg, cause=err) from err
|
|
201
|
+
|
|
202
|
+
try:
|
|
203
|
+
data = yaml.safe_load(content)
|
|
204
|
+
except yaml.YAMLError as err:
|
|
205
|
+
errmsg = "Failed to parse YAML plugin configuration file '{}': {}".format(
|
|
206
|
+
file_path, str(err)
|
|
207
|
+
)
|
|
208
|
+
raise ConfigurationError(errmsg, cause=err) from err
|
|
209
|
+
|
|
210
|
+
if data is None:
|
|
211
|
+
data = {}
|
|
212
|
+
|
|
213
|
+
config = cls.from_dict(data)
|
|
214
|
+
return config
|
|
215
|
+
|
|
216
|
+
def __repr__(self) -> str:
|
|
217
|
+
"""
|
|
218
|
+
Returns a detailed string representation including class name,
|
|
219
|
+
enabled plugin count, and automatic discovery enabled status.
|
|
220
|
+
|
|
221
|
+
:returns: A repr string for debugging.
|
|
222
|
+
"""
|
|
223
|
+
enabled_count = len(self._enabled_plugins)
|
|
224
|
+
repr_str = "PluginConfiguration(enabled_plugins={}, automatic_discovery_enabled={})".format(
|
|
225
|
+
enabled_count, self._automatic_discovery_enabled
|
|
226
|
+
)
|
|
227
|
+
return repr_str
|
|
228
|
+
|
|
229
|
+
def __str__(self) -> str:
|
|
230
|
+
"""
|
|
231
|
+
Returns a human-readable summary including the enabled plugin count,
|
|
232
|
+
disabled plugin count, and automatic discovery enabled status.
|
|
233
|
+
|
|
234
|
+
:returns: A human-readable string.
|
|
235
|
+
"""
|
|
236
|
+
enabled_count = len(self._enabled_plugins)
|
|
237
|
+
disabled_count = len(self._disabled_plugins)
|
|
238
|
+
str_val = "PluginConfiguration (enabled={}, disabled={}, automatic_discovery_enabled={})".format(
|
|
239
|
+
enabled_count, disabled_count, self._automatic_discovery_enabled
|
|
240
|
+
)
|
|
241
|
+
return str_val
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the PluginDependency class representing an immutable dependency
|
|
3
|
+
of a plugin on another plugin or package, with an optional version
|
|
4
|
+
constraint, in the codecraftai-agent-kit framework.
|
|
5
|
+
|
|
6
|
+
A PluginDependency contains a dependency name and an optional version
|
|
7
|
+
constraint string. The is_satisfied_by method checks whether a given
|
|
8
|
+
plugin name and version satisfy the dependency.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PluginDependency:
|
|
15
|
+
"""
|
|
16
|
+
Immutable object representing a dependency of a plugin on another
|
|
17
|
+
plugin or package, with an optional version constraint.
|
|
18
|
+
|
|
19
|
+
:param name: The dependency name string.
|
|
20
|
+
:param version_constraint: An optional version constraint string.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, name: str, version_constraint: str = None) -> None:
|
|
24
|
+
self._name = name
|
|
25
|
+
self._version_constraint = version_constraint
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def name(self) -> str:
|
|
30
|
+
"""
|
|
31
|
+
The dependency name string.
|
|
32
|
+
|
|
33
|
+
:returns: The dependency name.
|
|
34
|
+
"""
|
|
35
|
+
return self._name
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def version_constraint(self) -> str:
|
|
39
|
+
"""
|
|
40
|
+
The optional version constraint string.
|
|
41
|
+
|
|
42
|
+
:returns: The version constraint string, or None.
|
|
43
|
+
"""
|
|
44
|
+
return self._version_constraint
|
|
45
|
+
|
|
46
|
+
def is_satisfied_by(self, plugin_name: str, version: str) -> bool:
|
|
47
|
+
"""
|
|
48
|
+
Returns whether the provided plugin satisfies this dependency.
|
|
49
|
+
When no version constraint is specified, matches by name only.
|
|
50
|
+
When a version constraint is specified, performs a simple string
|
|
51
|
+
equality check against the version parameter.
|
|
52
|
+
|
|
53
|
+
:param plugin_name: The plugin name to check.
|
|
54
|
+
:param version: The plugin version to check.
|
|
55
|
+
|
|
56
|
+
:returns: True if the dependency is satisfied.
|
|
57
|
+
"""
|
|
58
|
+
if plugin_name != self._name:
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
if self._version_constraint is None:
|
|
62
|
+
return True
|
|
63
|
+
|
|
64
|
+
is_match = (version == self._version_constraint)
|
|
65
|
+
return is_match
|
|
66
|
+
|
|
67
|
+
def as_dict(self) -> dict:
|
|
68
|
+
"""
|
|
69
|
+
Returns a dictionary representation of the dependency fields.
|
|
70
|
+
|
|
71
|
+
:returns: A dictionary with name and version_constraint.
|
|
72
|
+
"""
|
|
73
|
+
result = {
|
|
74
|
+
"name": self._name,
|
|
75
|
+
"version_constraint": self._version_constraint
|
|
76
|
+
}
|
|
77
|
+
return result
|
|
78
|
+
|
|
79
|
+
def to_json(self) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Returns a JSON string representation of the dependency fields.
|
|
82
|
+
|
|
83
|
+
:returns: A JSON string containing all dependency fields.
|
|
84
|
+
"""
|
|
85
|
+
data = self.as_dict()
|
|
86
|
+
json_str = json.dumps(data)
|
|
87
|
+
return json_str
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def from_dict(cls, data: dict) -> "PluginDependency":
|
|
91
|
+
"""
|
|
92
|
+
Constructs a PluginDependency from a dictionary.
|
|
93
|
+
|
|
94
|
+
:param data: A dictionary containing name and version_constraint.
|
|
95
|
+
|
|
96
|
+
:returns: A PluginDependency instance reconstructed from the dictionary.
|
|
97
|
+
"""
|
|
98
|
+
name = data["name"]
|
|
99
|
+
version_constraint = data.get("version_constraint", None)
|
|
100
|
+
|
|
101
|
+
dependency = cls(
|
|
102
|
+
name=name,
|
|
103
|
+
version_constraint=version_constraint
|
|
104
|
+
)
|
|
105
|
+
return dependency
|
|
106
|
+
|
|
107
|
+
def __repr__(self) -> str:
|
|
108
|
+
"""
|
|
109
|
+
Returns a detailed string representation including class name,
|
|
110
|
+
dependency name, and version constraint.
|
|
111
|
+
|
|
112
|
+
:returns: A repr string for debugging.
|
|
113
|
+
"""
|
|
114
|
+
repr_str = "PluginDependency(name={!r}, version_constraint={!r})".format(
|
|
115
|
+
self._name, self._version_constraint
|
|
116
|
+
)
|
|
117
|
+
return repr_str
|
|
118
|
+
|
|
119
|
+
def __str__(self) -> str:
|
|
120
|
+
"""
|
|
121
|
+
Returns a human-readable summary including the dependency name
|
|
122
|
+
and version constraint.
|
|
123
|
+
|
|
124
|
+
:returns: A human-readable string.
|
|
125
|
+
"""
|
|
126
|
+
str_val = "PluginDependency '{}' (version_constraint={!r})".format(
|
|
127
|
+
self._name, self._version_constraint
|
|
128
|
+
)
|
|
129
|
+
return str_val
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the PluginDescriptor class representing immutable metadata
|
|
3
|
+
describing a discovered plugin in the codecraftai-agent-kit framework.
|
|
4
|
+
|
|
5
|
+
A PluginDescriptor contains a plugin name, version, description, author,
|
|
6
|
+
a list of extension point names, a list of PluginDependency objects,
|
|
7
|
+
and a PluginStatus value.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
|
|
12
|
+
from ccai.agentkit.plugindependency import PluginDependency
|
|
13
|
+
from ccai.agentkit.pluginstatus import PluginStatus
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PluginDescriptor:
|
|
17
|
+
"""
|
|
18
|
+
Immutable metadata object describing a discovered plugin.
|
|
19
|
+
Contains plugin name, version, description, author, extension points,
|
|
20
|
+
dependencies, and status.
|
|
21
|
+
|
|
22
|
+
:param name: The plugin name string.
|
|
23
|
+
:param version: The plugin version string.
|
|
24
|
+
:param description: The plugin description string.
|
|
25
|
+
:param author: The plugin author string.
|
|
26
|
+
:param extension_points: An optional list of extension point name strings.
|
|
27
|
+
:param dependencies: An optional list of PluginDependency objects.
|
|
28
|
+
:param status: The plugin lifecycle status, defaults to DISCOVERED.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, name: str, version: str, description: str, author: str,
|
|
32
|
+
extension_points: list = None, dependencies: list = None,
|
|
33
|
+
status: PluginStatus = PluginStatus.DISCOVERED) -> None:
|
|
34
|
+
self._name = name
|
|
35
|
+
self._version = version
|
|
36
|
+
self._description = description
|
|
37
|
+
self._author = author
|
|
38
|
+
|
|
39
|
+
if extension_points is not None:
|
|
40
|
+
self._extension_points = list(extension_points)
|
|
41
|
+
else:
|
|
42
|
+
self._extension_points = []
|
|
43
|
+
|
|
44
|
+
if dependencies is not None:
|
|
45
|
+
self._dependencies = list(dependencies)
|
|
46
|
+
else:
|
|
47
|
+
self._dependencies = []
|
|
48
|
+
|
|
49
|
+
self._status = status
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def name(self) -> str:
|
|
54
|
+
"""
|
|
55
|
+
The plugin name string.
|
|
56
|
+
|
|
57
|
+
:returns: The plugin name.
|
|
58
|
+
"""
|
|
59
|
+
return self._name
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def version(self) -> str:
|
|
63
|
+
"""
|
|
64
|
+
The plugin version string.
|
|
65
|
+
|
|
66
|
+
:returns: The plugin version.
|
|
67
|
+
"""
|
|
68
|
+
return self._version
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def description(self) -> str:
|
|
72
|
+
"""
|
|
73
|
+
The plugin description string.
|
|
74
|
+
|
|
75
|
+
:returns: The plugin description.
|
|
76
|
+
"""
|
|
77
|
+
return self._description
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def author(self) -> str:
|
|
81
|
+
"""
|
|
82
|
+
The plugin author string.
|
|
83
|
+
|
|
84
|
+
:returns: The plugin author.
|
|
85
|
+
"""
|
|
86
|
+
return self._author
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def extension_points(self) -> list:
|
|
90
|
+
"""
|
|
91
|
+
A defensive copy of the list of extension point name strings.
|
|
92
|
+
|
|
93
|
+
:returns: A list copy of the extension point names.
|
|
94
|
+
"""
|
|
95
|
+
return list(self._extension_points)
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def dependencies(self) -> list:
|
|
99
|
+
"""
|
|
100
|
+
A defensive copy of the list of PluginDependency objects.
|
|
101
|
+
|
|
102
|
+
:returns: A list copy of the dependencies.
|
|
103
|
+
"""
|
|
104
|
+
return list(self._dependencies)
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def status(self) -> PluginStatus:
|
|
108
|
+
"""
|
|
109
|
+
The plugin lifecycle status.
|
|
110
|
+
|
|
111
|
+
:returns: The PluginStatus value.
|
|
112
|
+
"""
|
|
113
|
+
return self._status
|
|
114
|
+
|
|
115
|
+
def as_dict(self) -> dict:
|
|
116
|
+
"""
|
|
117
|
+
Returns a dictionary representation of the descriptor fields.
|
|
118
|
+
Dependencies are serialized using their as_dict method.
|
|
119
|
+
Status is serialized as its string value.
|
|
120
|
+
|
|
121
|
+
:returns: A dictionary with all descriptor fields.
|
|
122
|
+
"""
|
|
123
|
+
dependencies_list = []
|
|
124
|
+
for dep in self._dependencies:
|
|
125
|
+
dependencies_list.append(dep.as_dict())
|
|
126
|
+
|
|
127
|
+
result = {
|
|
128
|
+
"name": self._name,
|
|
129
|
+
"version": self._version,
|
|
130
|
+
"description": self._description,
|
|
131
|
+
"author": self._author,
|
|
132
|
+
"extension_points": list(self._extension_points),
|
|
133
|
+
"dependencies": dependencies_list,
|
|
134
|
+
"status": self._status.value
|
|
135
|
+
}
|
|
136
|
+
return result
|
|
137
|
+
|
|
138
|
+
def to_json(self) -> str:
|
|
139
|
+
"""
|
|
140
|
+
Returns a JSON string representation of the descriptor fields.
|
|
141
|
+
|
|
142
|
+
:returns: A JSON string containing all descriptor fields.
|
|
143
|
+
"""
|
|
144
|
+
data = self.as_dict()
|
|
145
|
+
json_str = json.dumps(data)
|
|
146
|
+
return json_str
|
|
147
|
+
|
|
148
|
+
@classmethod
|
|
149
|
+
def from_dict(cls, data: dict) -> "PluginDescriptor":
|
|
150
|
+
"""
|
|
151
|
+
Constructs a PluginDescriptor from a dictionary.
|
|
152
|
+
Dependencies are reconstructed from their dictionary representations.
|
|
153
|
+
Status is reconstructed via PluginStatus.from_string.
|
|
154
|
+
|
|
155
|
+
:param data: A dictionary containing all descriptor fields.
|
|
156
|
+
|
|
157
|
+
:returns: A PluginDescriptor instance reconstructed from the dictionary.
|
|
158
|
+
"""
|
|
159
|
+
name = data["name"]
|
|
160
|
+
version = data["version"]
|
|
161
|
+
description = data["description"]
|
|
162
|
+
author = data["author"]
|
|
163
|
+
extension_points = data.get("extension_points", None)
|
|
164
|
+
|
|
165
|
+
raw_dependencies = data.get("dependencies", None)
|
|
166
|
+
dependencies = None
|
|
167
|
+
if raw_dependencies is not None:
|
|
168
|
+
dependencies = []
|
|
169
|
+
for dep_data in raw_dependencies:
|
|
170
|
+
dep = PluginDependency.from_dict(dep_data)
|
|
171
|
+
dependencies.append(dep)
|
|
172
|
+
|
|
173
|
+
raw_status = data.get("status", None)
|
|
174
|
+
if raw_status is not None:
|
|
175
|
+
status = PluginStatus.from_string(raw_status)
|
|
176
|
+
else:
|
|
177
|
+
status = PluginStatus.DISCOVERED
|
|
178
|
+
|
|
179
|
+
descriptor = cls(
|
|
180
|
+
name=name,
|
|
181
|
+
version=version,
|
|
182
|
+
description=description,
|
|
183
|
+
author=author,
|
|
184
|
+
extension_points=extension_points,
|
|
185
|
+
dependencies=dependencies,
|
|
186
|
+
status=status
|
|
187
|
+
)
|
|
188
|
+
return descriptor
|
|
189
|
+
|
|
190
|
+
@classmethod
|
|
191
|
+
def from_json(cls, json_str: str) -> "PluginDescriptor":
|
|
192
|
+
"""
|
|
193
|
+
Deserializes a JSON string into a PluginDescriptor instance.
|
|
194
|
+
|
|
195
|
+
:param json_str: A JSON string containing descriptor fields.
|
|
196
|
+
|
|
197
|
+
:returns: A PluginDescriptor instance reconstructed from the JSON data.
|
|
198
|
+
"""
|
|
199
|
+
data = json.loads(json_str)
|
|
200
|
+
descriptor = cls.from_dict(data)
|
|
201
|
+
return descriptor
|
|
202
|
+
|
|
203
|
+
def __repr__(self) -> str:
|
|
204
|
+
"""
|
|
205
|
+
Returns a detailed string representation including class name,
|
|
206
|
+
plugin name, version, and status.
|
|
207
|
+
|
|
208
|
+
:returns: A repr string for debugging.
|
|
209
|
+
"""
|
|
210
|
+
repr_str = "PluginDescriptor(name={!r}, version={!r}, status={!r})".format(
|
|
211
|
+
self._name, self._version, self._status.value
|
|
212
|
+
)
|
|
213
|
+
return repr_str
|
|
214
|
+
|
|
215
|
+
def __str__(self) -> str:
|
|
216
|
+
"""
|
|
217
|
+
Returns a human-readable summary including the plugin name,
|
|
218
|
+
version, description, and status.
|
|
219
|
+
|
|
220
|
+
:returns: A human-readable string.
|
|
221
|
+
"""
|
|
222
|
+
str_val = "PluginDescriptor '{}' v{} (status={}, description={!r})".format(
|
|
223
|
+
self._name, self._version, self._status.value, self._description
|
|
224
|
+
)
|
|
225
|
+
return str_val
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Defines the PluginLifecycleHook abstract base class that plugins
|
|
3
|
+
implement to receive lifecycle notifications from the PluginManager
|
|
4
|
+
in the codecraftai-agent-kit framework.
|
|
5
|
+
|
|
6
|
+
Plugins that implement this interface will be notified when they are
|
|
7
|
+
loaded, activated, deactivated, and unloaded.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import abc
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PluginLifecycleHook(abc.ABC):
|
|
14
|
+
"""
|
|
15
|
+
Abstract callback interface that plugins implement to receive
|
|
16
|
+
lifecycle notifications from the PluginManager.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
@abc.abstractmethod
|
|
20
|
+
def on_load(self) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Called when the plugin is being loaded.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
@abc.abstractmethod
|
|
26
|
+
def on_activate(self) -> None:
|
|
27
|
+
"""
|
|
28
|
+
Called when the plugin is being activated.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
@abc.abstractmethod
|
|
32
|
+
def on_deactivate(self) -> None:
|
|
33
|
+
"""
|
|
34
|
+
Called when the plugin is being deactivated.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
@abc.abstractmethod
|
|
38
|
+
def on_unload(self) -> None:
|
|
39
|
+
"""
|
|
40
|
+
Called when the plugin is being unloaded.
|
|
41
|
+
"""
|