codemie-sdk-python 0.1.705__py3-none-any.whl → 0.1.707__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_sdk/__init__.py CHANGED
@@ -175,6 +175,16 @@ from .models.a2a import (
175
175
  AgentSkill,
176
176
  )
177
177
  from .services.a2a import A2AService
178
+ from .models.usage_attribution import (
179
+ UsageAttributionQueryParams,
180
+ UsageAttributionRange,
181
+ UsageAttributionAnalysisSettings,
182
+ UsageAttributionAnalysis,
183
+ UsageAttributionResponse,
184
+ UsageAttributionTableResponse,
185
+ UsageAttributionSettingsResponse,
186
+ )
187
+ from .services.usage_attribution import UsageAttributionService
178
188
 
179
189
  try:
180
190
  __version__ = _pkg_version("codemie-sdk-python")
@@ -311,4 +321,12 @@ __all__ = [
311
321
  "AgentCapabilities",
312
322
  "AgentSkill",
313
323
  "A2AService",
324
+ "UsageAttributionQueryParams",
325
+ "UsageAttributionRange",
326
+ "UsageAttributionAnalysisSettings",
327
+ "UsageAttributionAnalysis",
328
+ "UsageAttributionResponse",
329
+ "UsageAttributionTableResponse",
330
+ "UsageAttributionSettingsResponse",
331
+ "UsageAttributionService",
314
332
  ]
@@ -186,6 +186,7 @@ class WorkflowTool(BaseModel):
186
186
  resolve_dynamic_values_in_response: bool = False
187
187
  input_key: str | None = None
188
188
  tokens_size_limit: int | None = None
189
+ tool_access: list[WorkflowAssistantTool] | None = None
189
190
 
190
191
 
191
192
  class CustomWorkflowNode(BaseModel):
@@ -330,6 +331,12 @@ class WorkflowDefinition(BaseModel):
330
331
  tools: list[WorkflowTool] = Field(default_factory=list)
331
332
  custom_nodes: list[CustomWorkflowNode] = Field(default_factory=list)
332
333
  states: list[WorkflowState] = Field(default_factory=list)
334
+ # Engine switches read from the top level of the YAML config; unset means
335
+ # the backend default applies.
336
+ enable_summarization_node: bool | None = None
337
+ messages_limit_before_summarization: int | None = Field(None, gt=0)
338
+ tokens_limit_before_summarization: int | None = Field(None, gt=0)
339
+ max_iteration_key_output_limit: int | None = Field(None, gt=0)
333
340
 
334
341
  def to_yaml_config(
335
342
  self, resolve_assistant_name: Callable[[str], str] | None = None
@@ -351,11 +358,25 @@ class WorkflowDefinition(BaseModel):
351
358
  node.model_dump(exclude_none=True) for node in self.custom_nodes
352
359
  ],
353
360
  "states": [state.model_dump(exclude_none=True) for state in self.states],
361
+ **self._engine_switches(),
354
362
  }
355
363
  return yaml.safe_dump(
356
364
  payload, sort_keys=False, default_flow_style=False, allow_unicode=True
357
365
  )
358
366
 
367
+ def _engine_switches(self) -> dict:
368
+ names = (
369
+ "enable_summarization_node",
370
+ "messages_limit_before_summarization",
371
+ "tokens_limit_before_summarization",
372
+ "max_iteration_key_output_limit",
373
+ )
374
+ return {
375
+ name: getattr(self, name)
376
+ for name in names
377
+ if getattr(self, name) is not None
378
+ }
379
+
359
380
  @staticmethod
360
381
  def _resolve_assistant(
361
382
  key: str,
@@ -33,6 +33,7 @@ from ..services.mcp_configs import MCPConfigsService
33
33
  from ..services.cost_center import CostCenterService
34
34
  from ..services.customer_config_service import CustomerConfigService
35
35
  from ..services.project_budget_groups import ProjectBudgetGroupsService
36
+ from ..services.usage_attribution import UsageAttributionService
36
37
  from ..services.servicenow_integration import ServiceNowIntegrationService
37
38
 
38
39
 
@@ -193,6 +194,9 @@ class CodeMieClient:
193
194
  self.workspaces = WorkspaceService(
194
195
  self._api_domain, _token_source, verify_ssl=self._verify_ssl
195
196
  )
197
+ self.usage_attribution = UsageAttributionService(
198
+ self._api_domain, _token_source, verify_ssl=self._verify_ssl
199
+ )
196
200
 
197
201
  @property
198
202
  def token(self) -> str:
@@ -23,6 +23,10 @@ class ToolDetails(BaseModel):
23
23
  settings_config: bool = False
24
24
  user_description: str | None = None
25
25
  settings: Integration | None = None
26
+ auto_credentials_lookup: bool = Field(
27
+ True,
28
+ description="When no integration is pinned, fall back to the consuming user's own integration",
29
+ )
26
30
 
27
31
 
28
32
  class ToolKitDetails(BaseModel):
@@ -36,6 +40,10 @@ class ToolKitDetails(BaseModel):
36
40
  settings_config: bool = False
37
41
  is_external: bool = False
38
42
  settings: Integration | None = None
43
+ auto_credentials_lookup: bool = Field(
44
+ True,
45
+ description="Toolkit-level counterpart of ToolDetails.auto_credentials_lookup",
46
+ )
39
47
 
40
48
 
41
49
  class ContextType(str, Enum):
@@ -114,6 +122,15 @@ class MCPServerConfig(BaseModel):
114
122
  tools: list[str] | None = Field(
115
123
  None, description="List of tool names available in this MCP server"
116
124
  )
125
+ audience: str | None = Field(
126
+ None,
127
+ description="OAuth2 audience for OIDC token exchange (RFC 8693)",
128
+ )
129
+ auth_config: dict[str, Any] | None = Field(
130
+ None,
131
+ repr=False,
132
+ description="Authentication configuration for this MCP server, stored as a raw dict",
133
+ )
117
134
 
118
135
 
119
136
  class MCPServerDetails(BaseModel):
@@ -155,6 +172,46 @@ class BuiltinSubagent(BaseModel):
155
172
  display_name: str | None = None
156
173
 
157
174
 
175
+ class HedgingToolDetails(BaseModel):
176
+ """Internal tool used as the hedging fast path."""
177
+
178
+ model_config = ConfigDict(extra="ignore")
179
+
180
+ name: str
181
+
182
+
183
+ class HedgingProviderToolDetails(BaseModel):
184
+ """External provider tool used as the hedging fast path."""
185
+
186
+ model_config = ConfigDict(extra="ignore")
187
+
188
+ provider_name: str
189
+ toolkit_name: str
190
+ tool_name: str
191
+ datasource_name: str | None = None
192
+ result_condition: str | None = None
193
+
194
+
195
+ class HedgingConfig(BaseModel):
196
+ """Hedging (fast path) configuration: exactly one of tool or provider_tool."""
197
+
198
+ model_config = ConfigDict(extra="ignore")
199
+
200
+ tool: HedgingToolDetails | None = None
201
+ provider_tool: HedgingProviderToolDetails | None = None
202
+ timeout_ms: int = Field(200, gt=0)
203
+ input_mapping: dict[str, str] = Field(default_factory=dict)
204
+ output_field: str | None = None
205
+
206
+ @model_validator(mode="after")
207
+ def validate_tool_or_provider(self) -> "HedgingConfig":
208
+ if (self.tool is None) == (self.provider_tool is None):
209
+ raise ValueError(
210
+ "Exactly one of 'tool' or 'provider_tool' must be specified"
211
+ )
212
+ return self
213
+
214
+
158
215
  class AssistantBase(BaseModel):
159
216
  """Base model for assistant with common fields."""
160
217
 
@@ -272,6 +329,10 @@ class Assistant(AssistantBase):
272
329
  description="Number of times this assistant has been cloned in the Marketplace",
273
330
  )
274
331
  tool_permissions: ToolPermissionsConfig | None = None
332
+ hedging_config: HedgingConfig | None = None
333
+ interactive_enabled: bool = False
334
+ enable_image_generation: bool | None = False
335
+ file_attachment_enabled: bool | None = None
275
336
 
276
337
 
277
338
  class AssistantRequestBase(AssistantBase):
@@ -308,6 +369,11 @@ class AssistantRequestBase(AssistantBase):
308
369
  prompt_variables: list[PromptVariable] = Field(default_factory=list)
309
370
  skip_integration_validation: bool | None = Field(default=False)
310
371
  tool_permissions: ToolPermissionsConfig | None = None
372
+ hedging_config: HedgingConfig | None = None
373
+ # None (not sent) on requests so an update never resets the stored flag.
374
+ interactive_enabled: bool | None = None
375
+ enable_image_generation: bool | None = None
376
+ file_attachment_enabled: bool | None = None
311
377
 
312
378
 
313
379
  class AssistantCreateRequest(AssistantRequestBase):