codemie-cdk-python 0.1.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.
- codemie_cdk_python-0.1.0.dist-info/METADATA +892 -0
- codemie_cdk_python-0.1.0.dist-info/RECORD +40 -0
- codemie_cdk_python-0.1.0.dist-info/WHEEL +4 -0
- codemie_cdk_python-0.1.0.dist-info/entry_points.txt +3 -0
- codemie_iac/__init__.py +49 -0
- codemie_iac/cli/__init__.py +17 -0
- codemie_iac/cli/__main__.py +24 -0
- codemie_iac/cli/commands/__init__.py +17 -0
- codemie_iac/cli/commands/apply.py +119 -0
- codemie_iac/cli/commands/plan.py +72 -0
- codemie_iac/cli/config_model.py +136 -0
- codemie_iac/cli/documents.py +59 -0
- codemie_iac/cli/env_file.py +62 -0
- codemie_iac/cli/exit_status.py +80 -0
- codemie_iac/cli/init_command.py +101 -0
- codemie_iac/cli/main.py +152 -0
- codemie_iac/cli/render.py +206 -0
- codemie_iac/cli/target_config.py +258 -0
- codemie_iac/credentials.py +99 -0
- codemie_iac/envelope.py +188 -0
- codemie_iac/plan_apply/__init__.py +70 -0
- codemie_iac/plan_apply/bulk_create.py +561 -0
- codemie_iac/plan_apply/credentials.py +306 -0
- codemie_iac/plan_apply/errors.py +223 -0
- codemie_iac/plan_apply/field_policy.py +188 -0
- codemie_iac/plan_apply/guards.py +221 -0
- codemie_iac/plan_apply/kinds.py +815 -0
- codemie_iac/plan_apply/lookup.py +313 -0
- codemie_iac/plan_apply/ordering.py +177 -0
- codemie_iac/plan_apply/single_apply.py +751 -0
- codemie_iac/resolver.py +61 -0
- codemie_iac/schema.py +106 -0
- codemie_iac/serializer.py +64 -0
- codemie_iac/specs/__init__.py +13 -0
- codemie_iac/specs/assistant.py +509 -0
- codemie_iac/specs/category.py +36 -0
- codemie_iac/specs/datasource.py +595 -0
- codemie_iac/specs/integration.py +103 -0
- codemie_iac/specs/skill.py +51 -0
- codemie_iac/specs/workflow.py +154 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
# Copyright 2026 EPAM Systems, Inc. ("EPAM")
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Spec that narrows ``codemie_sdk.models.assistant.AssistantCreateRequest``
|
|
16
|
+
(== ``AssistantRequestBase``) for IaC documents.
|
|
17
|
+
|
|
18
|
+
Drops platform-assigned fields (``id``, ``created_by``). ``tools_tokens_size_limit``
|
|
19
|
+
(CR-009, reopened) is kept, as a plain ``int | None``, at both the top level
|
|
20
|
+
of ``AssistantSpec`` and on ``MCPServerDetailsSpec`` -- an earlier pass
|
|
21
|
+
dropped both as "platform-computed", which traced into the codemie backend
|
|
22
|
+
(``rest_api/models/assistant.py``'s ``AssistantRequest``/``MCPServerDetails``,
|
|
23
|
+
``assistant_version_service.py``, and the ``add_tools_tokens_size_limit_to_assistants``
|
|
24
|
+
migration) turned out to be wrong: it is a genuine, user-settable, persisted
|
|
25
|
+
field on both the assistant and (independently) each MCP server -- the
|
|
26
|
+
assistant-level value overrides the per-MCP-server one when set
|
|
27
|
+
(``assistant_agent.py``/``langgraph_agent.py``: "Assistant-level tool output
|
|
28
|
+
token limit overrides per-tool defaults (incl. per-MCP-server) when set"),
|
|
29
|
+
which only makes sense if both are real, independently authorable values, not
|
|
30
|
+
one computed and the other not. Dropping either loses user data on
|
|
31
|
+
round-trip -- the same bug class as CR-007/CR-011. Narrows every field that
|
|
32
|
+
can carry or reference a secret:
|
|
33
|
+
|
|
34
|
+
- ``MCPServerConfig.auth_token`` (a raw secret string in the SDK model)
|
|
35
|
+
narrows to ``CredentialRef``, so a plain string can never be embedded.
|
|
36
|
+
``from_entity`` has no natural ``credential_key`` for this one field (it
|
|
37
|
+
is not a ``{key, value}`` pair like ``Integration.credential_values``),
|
|
38
|
+
so it uses a fixed ``"auth_token"`` key scoped by *both* the owning
|
|
39
|
+
assistant's name and the MCP server's own ``name`` as the identifier
|
|
40
|
+
(CR-005, reopened): server name alone is not unique across assistants,
|
|
41
|
+
so two unrelated MCP servers that happen to share a name would otherwise
|
|
42
|
+
collide onto the identical ``CredentialRef`` -- cross-wiring their real
|
|
43
|
+
secrets at resolution time.
|
|
44
|
+
- ``MCPServerConfig.env``/``headers``/``args``/``url`` and
|
|
45
|
+
``MCPServerDetails.arguments``/``mcp_connect_url`` (CR-008, a
|
|
46
|
+
decision_needed finding resolved here, now extended to every field of
|
|
47
|
+
this shape -- a secret can land in any of them, not just ``env``/
|
|
48
|
+
``headers``): these are plain strings (or a list of them, for ``args``)
|
|
49
|
+
in the SDK and a realistic channel for passing an MCP server a secret
|
|
50
|
+
(API key, token, a signed URL). Forcing every value through
|
|
51
|
+
``CredentialRef`` would break legitimate non-secret entries (e.g.
|
|
52
|
+
``{"DEBUG": "true"}``, or a plain ``npx`` arg), so each one is typed
|
|
53
|
+
``CredentialRef | str`` with ``union_mode="left_to_right"``: a value
|
|
54
|
+
already shaped like a reference (``"env:SOME_REF"``) is parsed as a
|
|
55
|
+
``CredentialRef``; anything else stays a plain string. This reuses the
|
|
56
|
+
exact same ``<source>:<identifier>`` convention ``IntegrationSpec`` and
|
|
57
|
+
``MCPServerConfigSpec.auth_token`` already use to mean "this is a
|
|
58
|
+
credential reference, not a literal value". This is a best-effort,
|
|
59
|
+
whole-value match only -- it narrows a value that *is* a reference, it
|
|
60
|
+
does not scan free text for one, so a secret embedded inside a larger
|
|
61
|
+
string (e.g. an ``args`` entry like ``"--token=sk-live-123"``, or a
|
|
62
|
+
query parameter on ``url``) is not caught and is written to the file as
|
|
63
|
+
plain text; the module's own README section says so explicitly.
|
|
64
|
+
``from_entity`` coerces each raw ``env``/``headers`` value to ``str``
|
|
65
|
+
first (CR-004, reopened: ``env`` is typed ``dict[str, Any]`` in the SDK
|
|
66
|
+
and permits a bool/int/None that would otherwise crash the union with a
|
|
67
|
+
raw ``ValidationError``; ``headers`` is already ``dict[str, str]``
|
|
68
|
+
upstream, so the same coercion is applied for uniformity but is always a
|
|
69
|
+
no-op there) before it reaches that union.
|
|
70
|
+
- ``MCPServerDetails.mcp_connect_auth_token`` (a whole ``Integration``
|
|
71
|
+
reference in the SDK model) narrows to a plain ``str`` holding just the
|
|
72
|
+
referenced integration's name, to be resolved later by a
|
|
73
|
+
``ReferenceResolver`` against a ``Bundle``.
|
|
74
|
+
- ``ToolKitDetails``/``ToolDetails``/``MCPServerDetails.settings`` (each a
|
|
75
|
+
whole ``Integration`` reference, CR-007) narrow the same way
|
|
76
|
+
``mcp_connect_auth_token`` does: a plain ``str`` holding the referenced
|
|
77
|
+
integration's name, resolved later via ``ReferenceResolver`` -- not
|
|
78
|
+
dropped, since dropping silently loses configuration AC1 requires be
|
|
79
|
+
recoverable. All four of these narrowing sites raise (CR-003, reopened)
|
|
80
|
+
rather than silently narrowing to ``None`` when the referenced
|
|
81
|
+
``Integration`` has no ``alias`` -- an alias-less reference's ``.alias``
|
|
82
|
+
is ``None``, which would otherwise be indistinguishable from "no
|
|
83
|
+
integration configured at all", silently losing a real link.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
from typing import Annotated, Any
|
|
87
|
+
|
|
88
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
89
|
+
|
|
90
|
+
from codemie_sdk.models.assistant import (
|
|
91
|
+
AssistantCreateRequest,
|
|
92
|
+
Context,
|
|
93
|
+
HedgingConfig,
|
|
94
|
+
Integration,
|
|
95
|
+
MCPServerConfig,
|
|
96
|
+
MCPServerDetails,
|
|
97
|
+
PromptVariable,
|
|
98
|
+
ToolCallPolicy,
|
|
99
|
+
ToolDetails,
|
|
100
|
+
ToolKitDetails,
|
|
101
|
+
ToolPermissionsConfig,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
from ..credentials import CredentialRef
|
|
105
|
+
from .datasource import (
|
|
106
|
+
_is_auth_config_secret,
|
|
107
|
+
_is_env_reference,
|
|
108
|
+
_literal_secret_paths,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# CR-008: see module docstring. Declared once and reused by both `env` and
|
|
112
|
+
# `headers` below.
|
|
113
|
+
_EnvOrHeaderValue = Annotated[CredentialRef | str, Field(union_mode="left_to_right")]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _integration_reference_name(
|
|
117
|
+
integration: Integration | None, *, context: str
|
|
118
|
+
) -> str | None:
|
|
119
|
+
"""Narrow an ``Integration`` reference to its alias (CR-003).
|
|
120
|
+
|
|
121
|
+
``None`` means "no reference configured" and passes through unchanged.
|
|
122
|
+
A referenced ``Integration`` that has no alias is a different, unsafe-
|
|
123
|
+
to-narrow case -- silently returning ``None`` there would be
|
|
124
|
+
indistinguishable from no reference at all, losing the link entirely
|
|
125
|
+
rather than just the secret.
|
|
126
|
+
"""
|
|
127
|
+
if integration is None:
|
|
128
|
+
return None
|
|
129
|
+
if integration.alias is None:
|
|
130
|
+
raise ValueError(
|
|
131
|
+
f"{context} references an Integration with no alias; cannot "
|
|
132
|
+
"narrow it to a resolvable name"
|
|
133
|
+
)
|
|
134
|
+
return integration.alias
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _coerce_env_value(value: object) -> str:
|
|
138
|
+
"""Coerce a raw MCP env/header value to ``str`` (CR-004).
|
|
139
|
+
|
|
140
|
+
The SDK types this field ``dict[str, Any]`` -- permissive enough to
|
|
141
|
+
legitimately carry a bool/int/None, which would otherwise crash the
|
|
142
|
+
``CredentialRef | str`` union with a raw pydantic ``ValidationError``
|
|
143
|
+
instead of converting cleanly. Matches how a process environment
|
|
144
|
+
actually consumes a value: always a string.
|
|
145
|
+
"""
|
|
146
|
+
return "" if value is None else str(value)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _narrow_auth_config(
|
|
150
|
+
value: Any, identifier: str, key: str = "auth_config", under_secret: bool = False
|
|
151
|
+
) -> Any:
|
|
152
|
+
"""Copy ``value``, replacing each non-empty literal string under a
|
|
153
|
+
secret-looking key with an ``env:`` reference built from ``identifier``
|
|
154
|
+
and the key path (the secret itself never reaches the document)."""
|
|
155
|
+
if isinstance(value, dict):
|
|
156
|
+
return {
|
|
157
|
+
k: _narrow_auth_config(
|
|
158
|
+
v, identifier, f"{key}_{k}", under_secret or _is_auth_config_secret(k)
|
|
159
|
+
)
|
|
160
|
+
for k, v in value.items()
|
|
161
|
+
}
|
|
162
|
+
if isinstance(value, list):
|
|
163
|
+
return [
|
|
164
|
+
_narrow_auth_config(v, identifier, f"{key}_{i}", under_secret)
|
|
165
|
+
for i, v in enumerate(value)
|
|
166
|
+
]
|
|
167
|
+
if under_secret and isinstance(value, str) and value:
|
|
168
|
+
if not _is_env_reference(value):
|
|
169
|
+
return CredentialRef.from_entity(identifier, key).root
|
|
170
|
+
return value
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class ContextSpec(BaseModel):
|
|
174
|
+
"""Copies ``codemie_sdk.models.assistant.Context`` verbatim."""
|
|
175
|
+
|
|
176
|
+
model_config = ConfigDict(extra="forbid")
|
|
177
|
+
|
|
178
|
+
context_type: str
|
|
179
|
+
name: str
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def from_entity(cls, context: Context) -> "ContextSpec":
|
|
183
|
+
return cls(context_type=context.context_type, name=context.name)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class PromptVariableSpec(BaseModel):
|
|
187
|
+
"""Copies ``codemie_sdk.models.assistant.PromptVariable`` verbatim."""
|
|
188
|
+
|
|
189
|
+
model_config = ConfigDict(extra="forbid")
|
|
190
|
+
|
|
191
|
+
key: str
|
|
192
|
+
description: str | None = None
|
|
193
|
+
default_value: str
|
|
194
|
+
|
|
195
|
+
@classmethod
|
|
196
|
+
def from_entity(cls, variable: PromptVariable) -> "PromptVariableSpec":
|
|
197
|
+
return cls(
|
|
198
|
+
key=variable.key,
|
|
199
|
+
description=variable.description,
|
|
200
|
+
default_value=variable.default_value,
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class ToolPermissionsConfigSpec(BaseModel):
|
|
205
|
+
"""Copies ``codemie_sdk.models.assistant.ToolPermissionsConfig`` verbatim."""
|
|
206
|
+
|
|
207
|
+
model_config = ConfigDict(extra="forbid")
|
|
208
|
+
|
|
209
|
+
tool_call_policy: ToolCallPolicy = ToolCallPolicy.AUTO_APPROVE
|
|
210
|
+
allow_override: bool = True
|
|
211
|
+
|
|
212
|
+
@classmethod
|
|
213
|
+
def from_entity(cls, config: ToolPermissionsConfig) -> "ToolPermissionsConfigSpec":
|
|
214
|
+
return cls(
|
|
215
|
+
tool_call_policy=config.tool_call_policy,
|
|
216
|
+
allow_override=config.allow_override,
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class ToolDetailsSpec(BaseModel):
|
|
221
|
+
"""Narrows ``codemie_sdk.models.assistant.ToolDetails``.
|
|
222
|
+
|
|
223
|
+
``settings`` (a whole ``Integration`` reference) narrows to a plain
|
|
224
|
+
``str`` holding that integration's name (CR-007), resolved later by a
|
|
225
|
+
``ReferenceResolver`` -- mirroring how ``mcp_connect_auth_token`` is
|
|
226
|
+
narrowed below, rather than being dropped.
|
|
227
|
+
"""
|
|
228
|
+
|
|
229
|
+
model_config = ConfigDict(extra="forbid")
|
|
230
|
+
|
|
231
|
+
name: str
|
|
232
|
+
label: str | None = None
|
|
233
|
+
settings_config: bool = False
|
|
234
|
+
user_description: str | None = None
|
|
235
|
+
settings: str | None = None
|
|
236
|
+
auto_credentials_lookup: bool = True
|
|
237
|
+
|
|
238
|
+
@classmethod
|
|
239
|
+
def from_entity(cls, tool: ToolDetails) -> "ToolDetailsSpec":
|
|
240
|
+
return cls(
|
|
241
|
+
name=tool.name,
|
|
242
|
+
label=tool.label,
|
|
243
|
+
settings_config=tool.settings_config,
|
|
244
|
+
user_description=tool.user_description,
|
|
245
|
+
auto_credentials_lookup=tool.auto_credentials_lookup,
|
|
246
|
+
settings=_integration_reference_name(
|
|
247
|
+
tool.settings, context=f"ToolDetails {tool.name!r}.settings"
|
|
248
|
+
),
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
class ToolKitDetailsSpec(BaseModel):
|
|
253
|
+
"""Narrows ``codemie_sdk.models.assistant.ToolKitDetails``.
|
|
254
|
+
|
|
255
|
+
``settings`` narrows to the referenced integration's name (CR-007), as
|
|
256
|
+
on ``ToolDetailsSpec``.
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
model_config = ConfigDict(extra="forbid")
|
|
260
|
+
|
|
261
|
+
toolkit: str
|
|
262
|
+
tools: list[ToolDetailsSpec] = Field(default_factory=list)
|
|
263
|
+
label: str = ""
|
|
264
|
+
settings_config: bool = False
|
|
265
|
+
is_external: bool = False
|
|
266
|
+
settings: str | None = None
|
|
267
|
+
auto_credentials_lookup: bool = True
|
|
268
|
+
|
|
269
|
+
@classmethod
|
|
270
|
+
def from_entity(cls, toolkit: ToolKitDetails) -> "ToolKitDetailsSpec":
|
|
271
|
+
return cls(
|
|
272
|
+
auto_credentials_lookup=toolkit.auto_credentials_lookup,
|
|
273
|
+
toolkit=toolkit.toolkit,
|
|
274
|
+
tools=[ToolDetailsSpec.from_entity(tool) for tool in toolkit.tools],
|
|
275
|
+
label=toolkit.label,
|
|
276
|
+
settings_config=toolkit.settings_config,
|
|
277
|
+
is_external=toolkit.is_external,
|
|
278
|
+
settings=_integration_reference_name(
|
|
279
|
+
toolkit.settings,
|
|
280
|
+
context=f"ToolKitDetails {toolkit.toolkit!r}.settings",
|
|
281
|
+
),
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
class MCPServerConfigSpec(BaseModel):
|
|
286
|
+
"""Narrows ``codemie_sdk.models.assistant.MCPServerConfig``.
|
|
287
|
+
|
|
288
|
+
``auth_token`` narrows from a raw secret string to ``CredentialRef``.
|
|
289
|
+
"""
|
|
290
|
+
|
|
291
|
+
model_config = ConfigDict(extra="forbid", hide_input_in_errors=True)
|
|
292
|
+
|
|
293
|
+
command: str | None = None
|
|
294
|
+
url: _EnvOrHeaderValue | None = None
|
|
295
|
+
args: list[_EnvOrHeaderValue] = Field(default_factory=list)
|
|
296
|
+
headers: dict[str, _EnvOrHeaderValue] = Field(default_factory=dict)
|
|
297
|
+
env: dict[str, _EnvOrHeaderValue] = Field(default_factory=dict)
|
|
298
|
+
type: str | None = None
|
|
299
|
+
auth_token: CredentialRef | None = None
|
|
300
|
+
single_usage: bool = False
|
|
301
|
+
tools: list[str] | None = None
|
|
302
|
+
audience: str | None = None
|
|
303
|
+
auth_config: dict[str, Any] | None = None
|
|
304
|
+
|
|
305
|
+
@field_validator("auth_config")
|
|
306
|
+
@classmethod
|
|
307
|
+
def _no_literal_secrets_in_auth_config(
|
|
308
|
+
cls, value: dict[str, Any] | None
|
|
309
|
+
) -> dict[str, Any] | None:
|
|
310
|
+
paths = list(
|
|
311
|
+
_literal_secret_paths(
|
|
312
|
+
value or {}, "auth_config", is_secret=_is_auth_config_secret
|
|
313
|
+
)
|
|
314
|
+
)
|
|
315
|
+
if paths:
|
|
316
|
+
raise ValueError(
|
|
317
|
+
f"secret-looking setting(s) {', '.join(paths)} must be env: "
|
|
318
|
+
"references, not literal values"
|
|
319
|
+
)
|
|
320
|
+
return value
|
|
321
|
+
|
|
322
|
+
@classmethod
|
|
323
|
+
def from_entity(
|
|
324
|
+
cls, config: MCPServerConfig, *, assistant_name: str, server_name: str
|
|
325
|
+
) -> "MCPServerConfigSpec":
|
|
326
|
+
"""``assistant_name`` + ``server_name`` together identify the owning
|
|
327
|
+
MCP server for the ``CredentialRef`` built for ``auth_token`` -- the
|
|
328
|
+
one field here with no natural ``{key, value}`` pair of its own (see
|
|
329
|
+
module docstring). Server name alone is not unique across assistants
|
|
330
|
+
(CR-005): two different MCP servers that happen to share a name
|
|
331
|
+
would otherwise collide onto the same CredentialRef.
|
|
332
|
+
"""
|
|
333
|
+
return cls(
|
|
334
|
+
command=config.command,
|
|
335
|
+
url=config.url,
|
|
336
|
+
args=config.args or [],
|
|
337
|
+
headers={
|
|
338
|
+
k: _coerce_env_value(v) for k, v in (config.headers or {}).items()
|
|
339
|
+
},
|
|
340
|
+
env={k: _coerce_env_value(v) for k, v in (config.env or {}).items()},
|
|
341
|
+
type=config.type,
|
|
342
|
+
auth_token=(
|
|
343
|
+
CredentialRef.from_entity(
|
|
344
|
+
f"{assistant_name}_{server_name}", "auth_token"
|
|
345
|
+
)
|
|
346
|
+
if config.auth_token is not None
|
|
347
|
+
else None
|
|
348
|
+
),
|
|
349
|
+
single_usage=config.single_usage,
|
|
350
|
+
tools=config.tools,
|
|
351
|
+
audience=config.audience,
|
|
352
|
+
auth_config=_narrow_auth_config(
|
|
353
|
+
config.auth_config, f"{assistant_name}_{server_name}"
|
|
354
|
+
),
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class MCPServerDetailsSpec(BaseModel):
|
|
359
|
+
"""Narrows ``codemie_sdk.models.assistant.MCPServerDetails``.
|
|
360
|
+
|
|
361
|
+
``tools_tokens_size_limit`` (CR-009, reopened) is kept as a plain
|
|
362
|
+
``int | None`` -- a genuine, independently user-settable per-MCP-server
|
|
363
|
+
default token limit (see module docstring), not platform-computed.
|
|
364
|
+
Narrows ``settings`` (CR-007) and ``mcp_connect_auth_token`` -- both
|
|
365
|
+
whole ``Integration`` references in the SDK model -- to the referenced
|
|
366
|
+
integration's name (resolved later by a ``ReferenceResolver``).
|
|
367
|
+
"""
|
|
368
|
+
|
|
369
|
+
model_config = ConfigDict(extra="forbid")
|
|
370
|
+
|
|
371
|
+
name: str
|
|
372
|
+
description: str | None = None
|
|
373
|
+
enabled: bool
|
|
374
|
+
mcp_config_id: str | None = None
|
|
375
|
+
use_custom_config: bool = False
|
|
376
|
+
config: MCPServerConfigSpec | None = None
|
|
377
|
+
mcp_connect_url: _EnvOrHeaderValue | None = None
|
|
378
|
+
tools_tokens_size_limit: int | None = None
|
|
379
|
+
command: str | None = None
|
|
380
|
+
arguments: _EnvOrHeaderValue | None = None
|
|
381
|
+
settings: str | None = None
|
|
382
|
+
integration_alias: str | None = None
|
|
383
|
+
mcp_connect_auth_token: str | None = None
|
|
384
|
+
resolve_dynamic_values_in_arguments: bool = False
|
|
385
|
+
tools: list[str] | None = None
|
|
386
|
+
|
|
387
|
+
@classmethod
|
|
388
|
+
def from_entity(
|
|
389
|
+
cls, server: MCPServerDetails, *, assistant_name: str
|
|
390
|
+
) -> "MCPServerDetailsSpec":
|
|
391
|
+
"""``assistant_name`` is the owning assistant's name, threaded down
|
|
392
|
+
to ``MCPServerConfigSpec.from_entity`` to scope the ``auth_token``
|
|
393
|
+
``CredentialRef`` identifier (CR-005).
|
|
394
|
+
"""
|
|
395
|
+
return cls(
|
|
396
|
+
name=server.name,
|
|
397
|
+
description=server.description,
|
|
398
|
+
enabled=server.enabled,
|
|
399
|
+
mcp_config_id=server.mcp_config_id,
|
|
400
|
+
use_custom_config=server.use_custom_config,
|
|
401
|
+
config=(
|
|
402
|
+
MCPServerConfigSpec.from_entity(
|
|
403
|
+
server.config,
|
|
404
|
+
assistant_name=assistant_name,
|
|
405
|
+
server_name=server.name,
|
|
406
|
+
)
|
|
407
|
+
if server.config is not None
|
|
408
|
+
else None
|
|
409
|
+
),
|
|
410
|
+
mcp_connect_url=server.mcp_connect_url,
|
|
411
|
+
tools_tokens_size_limit=server.tools_tokens_size_limit,
|
|
412
|
+
command=server.command,
|
|
413
|
+
arguments=server.arguments,
|
|
414
|
+
settings=_integration_reference_name(
|
|
415
|
+
server.settings, context=f"MCPServerDetails {server.name!r}.settings"
|
|
416
|
+
),
|
|
417
|
+
integration_alias=server.integration_alias,
|
|
418
|
+
mcp_connect_auth_token=_integration_reference_name(
|
|
419
|
+
server.mcp_connect_auth_token,
|
|
420
|
+
context=f"MCPServerDetails {server.name!r}.mcp_connect_auth_token",
|
|
421
|
+
),
|
|
422
|
+
resolve_dynamic_values_in_arguments=server.resolve_dynamic_values_in_arguments,
|
|
423
|
+
tools=server.tools,
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
class AssistantSpec(BaseModel):
|
|
428
|
+
"""Narrows ``codemie_sdk.models.assistant.AssistantCreateRequest``.
|
|
429
|
+
|
|
430
|
+
Drops platform-assigned ``id``/``created_by`` from ``AssistantBase``.
|
|
431
|
+
``tools_tokens_size_limit`` (CR-009, reopened) is kept as a plain
|
|
432
|
+
``int | None`` -- confirmed against the codemie backend to be a
|
|
433
|
+
genuine, user-settable, persisted field (see module docstring), not
|
|
434
|
+
platform-computed; dropping it silently loses an assistant's configured
|
|
435
|
+
tool-output token limit on round-trip.
|
|
436
|
+
"""
|
|
437
|
+
|
|
438
|
+
model_config = ConfigDict(extra="forbid")
|
|
439
|
+
|
|
440
|
+
name: str
|
|
441
|
+
description: str
|
|
442
|
+
icon_url: str | None = None
|
|
443
|
+
system_prompt: str
|
|
444
|
+
project: str | None = None
|
|
445
|
+
context: list[ContextSpec] = Field(default_factory=list)
|
|
446
|
+
llm_model_type: str
|
|
447
|
+
toolkits: list[ToolKitDetailsSpec] = Field(default_factory=list)
|
|
448
|
+
conversation_starters: list[str] = Field(default_factory=list)
|
|
449
|
+
shared: bool = False
|
|
450
|
+
is_react: bool = False
|
|
451
|
+
is_global: bool | None = False
|
|
452
|
+
categories: list[str] = Field(default_factory=list)
|
|
453
|
+
slug: str | None = None
|
|
454
|
+
temperature: float | None = None
|
|
455
|
+
top_p: float | None = None
|
|
456
|
+
tools_tokens_size_limit: int | None = None
|
|
457
|
+
mcp_servers: list[MCPServerDetailsSpec] = Field(default_factory=list)
|
|
458
|
+
assistant_ids: list[str] = Field(default_factory=list)
|
|
459
|
+
skill_ids: list[str] | None = None
|
|
460
|
+
enabled_builtin_subagents: list[str] | None = None
|
|
461
|
+
prompt_variables: list[PromptVariableSpec] = Field(default_factory=list)
|
|
462
|
+
skip_integration_validation: bool | None = False
|
|
463
|
+
tool_permissions: ToolPermissionsConfigSpec | None = None
|
|
464
|
+
hedging_config: HedgingConfig | None = None
|
|
465
|
+
interactive_enabled: bool | None = None
|
|
466
|
+
enable_image_generation: bool | None = None
|
|
467
|
+
file_attachment_enabled: bool | None = None
|
|
468
|
+
|
|
469
|
+
@classmethod
|
|
470
|
+
def from_entity(cls, request: AssistantCreateRequest) -> "AssistantSpec":
|
|
471
|
+
return cls(
|
|
472
|
+
name=request.name,
|
|
473
|
+
description=request.description,
|
|
474
|
+
icon_url=request.icon_url,
|
|
475
|
+
system_prompt=request.system_prompt,
|
|
476
|
+
project=request.project,
|
|
477
|
+
context=[ContextSpec.from_entity(c) for c in request.context],
|
|
478
|
+
llm_model_type=request.llm_model_type,
|
|
479
|
+
toolkits=[ToolKitDetailsSpec.from_entity(t) for t in request.toolkits],
|
|
480
|
+
conversation_starters=request.conversation_starters,
|
|
481
|
+
shared=request.shared,
|
|
482
|
+
is_react=request.is_react,
|
|
483
|
+
is_global=request.is_global,
|
|
484
|
+
categories=request.categories,
|
|
485
|
+
slug=request.slug,
|
|
486
|
+
temperature=request.temperature,
|
|
487
|
+
top_p=request.top_p,
|
|
488
|
+
tools_tokens_size_limit=request.tools_tokens_size_limit,
|
|
489
|
+
mcp_servers=[
|
|
490
|
+
MCPServerDetailsSpec.from_entity(s, assistant_name=request.name)
|
|
491
|
+
for s in request.mcp_servers
|
|
492
|
+
],
|
|
493
|
+
assistant_ids=request.assistant_ids,
|
|
494
|
+
skill_ids=getattr(request, "skill_ids", None),
|
|
495
|
+
enabled_builtin_subagents=request.enabled_builtin_subagents,
|
|
496
|
+
prompt_variables=[
|
|
497
|
+
PromptVariableSpec.from_entity(p) for p in request.prompt_variables
|
|
498
|
+
],
|
|
499
|
+
skip_integration_validation=request.skip_integration_validation,
|
|
500
|
+
hedging_config=request.hedging_config,
|
|
501
|
+
interactive_enabled=request.interactive_enabled,
|
|
502
|
+
enable_image_generation=request.enable_image_generation,
|
|
503
|
+
file_attachment_enabled=request.file_attachment_enabled,
|
|
504
|
+
tool_permissions=(
|
|
505
|
+
ToolPermissionsConfigSpec.from_entity(request.tool_permissions)
|
|
506
|
+
if request.tool_permissions is not None
|
|
507
|
+
else None
|
|
508
|
+
),
|
|
509
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright 2026 EPAM Systems, Inc. ("EPAM")
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Spec that mirrors ``codemie_sdk.models.categories.CategoryCreateRequest``.
|
|
16
|
+
|
|
17
|
+
No credential-bearing fields exist on ``CategoryCreateRequest``, so this is a
|
|
18
|
+
verbatim copy of its fields plus ``extra="forbid"``.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
22
|
+
|
|
23
|
+
from codemie_sdk.models.categories import CategoryCreateRequest
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CategorySpec(BaseModel):
|
|
27
|
+
"""Narrowed view of ``CategoryCreateRequest``."""
|
|
28
|
+
|
|
29
|
+
model_config = ConfigDict(extra="forbid")
|
|
30
|
+
|
|
31
|
+
name: str = Field(..., description="Category name")
|
|
32
|
+
description: str | None = Field(None, description="Category description")
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def from_entity(cls, category: CategoryCreateRequest) -> "CategorySpec":
|
|
36
|
+
return cls(name=category.name, description=category.description)
|