glaip-sdk 0.6.15b2__py3-none-any.whl → 0.6.16__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.
Files changed (154) hide show
  1. glaip_sdk/agents/__init__.py +27 -0
  2. glaip_sdk/agents/base.py +1196 -0
  3. glaip_sdk/cli/__init__.py +9 -0
  4. glaip_sdk/cli/account_store.py +540 -0
  5. glaip_sdk/cli/agent_config.py +78 -0
  6. glaip_sdk/cli/auth.py +699 -0
  7. glaip_sdk/cli/commands/__init__.py +5 -0
  8. glaip_sdk/cli/commands/accounts.py +746 -0
  9. glaip_sdk/cli/commands/agents.py +1509 -0
  10. glaip_sdk/cli/commands/common_config.py +104 -0
  11. glaip_sdk/cli/commands/configure.py +896 -0
  12. glaip_sdk/cli/commands/mcps.py +1356 -0
  13. glaip_sdk/cli/commands/models.py +69 -0
  14. glaip_sdk/cli/commands/tools.py +576 -0
  15. glaip_sdk/cli/commands/transcripts.py +755 -0
  16. glaip_sdk/cli/commands/update.py +61 -0
  17. glaip_sdk/cli/config.py +95 -0
  18. glaip_sdk/cli/constants.py +38 -0
  19. glaip_sdk/cli/context.py +150 -0
  20. glaip_sdk/cli/core/__init__.py +79 -0
  21. glaip_sdk/cli/core/context.py +124 -0
  22. glaip_sdk/cli/core/output.py +851 -0
  23. glaip_sdk/cli/core/prompting.py +649 -0
  24. glaip_sdk/cli/core/rendering.py +187 -0
  25. glaip_sdk/cli/display.py +355 -0
  26. glaip_sdk/cli/hints.py +57 -0
  27. glaip_sdk/cli/io.py +112 -0
  28. glaip_sdk/cli/main.py +615 -0
  29. glaip_sdk/cli/masking.py +136 -0
  30. glaip_sdk/cli/mcp_validators.py +287 -0
  31. glaip_sdk/cli/pager.py +266 -0
  32. glaip_sdk/cli/parsers/__init__.py +7 -0
  33. glaip_sdk/cli/parsers/json_input.py +177 -0
  34. glaip_sdk/cli/resolution.py +67 -0
  35. glaip_sdk/cli/rich_helpers.py +27 -0
  36. glaip_sdk/cli/slash/__init__.py +15 -0
  37. glaip_sdk/cli/slash/accounts_controller.py +578 -0
  38. glaip_sdk/cli/slash/accounts_shared.py +75 -0
  39. glaip_sdk/cli/slash/agent_session.py +285 -0
  40. glaip_sdk/cli/slash/prompt.py +256 -0
  41. glaip_sdk/cli/slash/remote_runs_controller.py +566 -0
  42. glaip_sdk/cli/slash/session.py +1708 -0
  43. glaip_sdk/cli/slash/tui/__init__.py +9 -0
  44. glaip_sdk/cli/slash/tui/accounts_app.py +876 -0
  45. glaip_sdk/cli/slash/tui/background_tasks.py +72 -0
  46. glaip_sdk/cli/slash/tui/loading.py +58 -0
  47. glaip_sdk/cli/slash/tui/remote_runs_app.py +628 -0
  48. glaip_sdk/cli/transcript/__init__.py +31 -0
  49. glaip_sdk/cli/transcript/cache.py +536 -0
  50. glaip_sdk/cli/transcript/capture.py +329 -0
  51. glaip_sdk/cli/transcript/export.py +38 -0
  52. glaip_sdk/cli/transcript/history.py +815 -0
  53. glaip_sdk/cli/transcript/launcher.py +77 -0
  54. glaip_sdk/cli/transcript/viewer.py +374 -0
  55. glaip_sdk/cli/update_notifier.py +290 -0
  56. glaip_sdk/cli/utils.py +263 -0
  57. glaip_sdk/cli/validators.py +238 -0
  58. glaip_sdk/client/__init__.py +11 -0
  59. glaip_sdk/client/_agent_payloads.py +520 -0
  60. glaip_sdk/client/agent_runs.py +147 -0
  61. glaip_sdk/client/agents.py +1335 -0
  62. glaip_sdk/client/base.py +502 -0
  63. glaip_sdk/client/main.py +249 -0
  64. glaip_sdk/client/mcps.py +370 -0
  65. glaip_sdk/client/run_rendering.py +700 -0
  66. glaip_sdk/client/shared.py +21 -0
  67. glaip_sdk/client/tools.py +661 -0
  68. glaip_sdk/client/validators.py +198 -0
  69. glaip_sdk/config/constants.py +52 -0
  70. glaip_sdk/mcps/__init__.py +21 -0
  71. glaip_sdk/mcps/base.py +345 -0
  72. glaip_sdk/models/__init__.py +90 -0
  73. glaip_sdk/models/agent.py +47 -0
  74. glaip_sdk/models/agent_runs.py +116 -0
  75. glaip_sdk/models/common.py +42 -0
  76. glaip_sdk/models/mcp.py +33 -0
  77. glaip_sdk/models/tool.py +33 -0
  78. glaip_sdk/payload_schemas/__init__.py +7 -0
  79. glaip_sdk/payload_schemas/agent.py +85 -0
  80. glaip_sdk/registry/__init__.py +55 -0
  81. glaip_sdk/registry/agent.py +164 -0
  82. glaip_sdk/registry/base.py +139 -0
  83. glaip_sdk/registry/mcp.py +253 -0
  84. glaip_sdk/registry/tool.py +232 -0
  85. glaip_sdk/runner/__init__.py +59 -0
  86. glaip_sdk/runner/base.py +84 -0
  87. glaip_sdk/runner/deps.py +112 -0
  88. glaip_sdk/runner/langgraph.py +782 -0
  89. glaip_sdk/runner/mcp_adapter/__init__.py +13 -0
  90. glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +43 -0
  91. glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +257 -0
  92. glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +95 -0
  93. glaip_sdk/runner/tool_adapter/__init__.py +18 -0
  94. glaip_sdk/runner/tool_adapter/base_tool_adapter.py +44 -0
  95. glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +219 -0
  96. glaip_sdk/tools/__init__.py +22 -0
  97. glaip_sdk/tools/base.py +435 -0
  98. glaip_sdk/utils/__init__.py +86 -0
  99. glaip_sdk/utils/a2a/__init__.py +34 -0
  100. glaip_sdk/utils/a2a/event_processor.py +188 -0
  101. glaip_sdk/utils/agent_config.py +194 -0
  102. glaip_sdk/utils/bundler.py +267 -0
  103. glaip_sdk/utils/client.py +111 -0
  104. glaip_sdk/utils/client_utils.py +486 -0
  105. glaip_sdk/utils/datetime_helpers.py +58 -0
  106. glaip_sdk/utils/discovery.py +78 -0
  107. glaip_sdk/utils/display.py +135 -0
  108. glaip_sdk/utils/export.py +143 -0
  109. glaip_sdk/utils/general.py +61 -0
  110. glaip_sdk/utils/import_export.py +168 -0
  111. glaip_sdk/utils/import_resolver.py +492 -0
  112. glaip_sdk/utils/instructions.py +101 -0
  113. glaip_sdk/utils/rendering/__init__.py +115 -0
  114. glaip_sdk/utils/rendering/formatting.py +264 -0
  115. glaip_sdk/utils/rendering/layout/__init__.py +64 -0
  116. glaip_sdk/utils/rendering/layout/panels.py +156 -0
  117. glaip_sdk/utils/rendering/layout/progress.py +202 -0
  118. glaip_sdk/utils/rendering/layout/summary.py +74 -0
  119. glaip_sdk/utils/rendering/layout/transcript.py +606 -0
  120. glaip_sdk/utils/rendering/models.py +85 -0
  121. glaip_sdk/utils/rendering/renderer/__init__.py +55 -0
  122. glaip_sdk/utils/rendering/renderer/base.py +1024 -0
  123. glaip_sdk/utils/rendering/renderer/config.py +27 -0
  124. glaip_sdk/utils/rendering/renderer/console.py +55 -0
  125. glaip_sdk/utils/rendering/renderer/debug.py +178 -0
  126. glaip_sdk/utils/rendering/renderer/factory.py +138 -0
  127. glaip_sdk/utils/rendering/renderer/stream.py +202 -0
  128. glaip_sdk/utils/rendering/renderer/summary_window.py +79 -0
  129. glaip_sdk/utils/rendering/renderer/thinking.py +273 -0
  130. glaip_sdk/utils/rendering/renderer/toggle.py +182 -0
  131. glaip_sdk/utils/rendering/renderer/tool_panels.py +442 -0
  132. glaip_sdk/utils/rendering/renderer/transcript_mode.py +162 -0
  133. glaip_sdk/utils/rendering/state.py +204 -0
  134. glaip_sdk/utils/rendering/step_tree_state.py +100 -0
  135. glaip_sdk/utils/rendering/steps/__init__.py +34 -0
  136. glaip_sdk/utils/rendering/steps/event_processor.py +778 -0
  137. glaip_sdk/utils/rendering/steps/format.py +176 -0
  138. glaip_sdk/utils/rendering/steps/manager.py +387 -0
  139. glaip_sdk/utils/rendering/timing.py +36 -0
  140. glaip_sdk/utils/rendering/viewer/__init__.py +21 -0
  141. glaip_sdk/utils/rendering/viewer/presenter.py +184 -0
  142. glaip_sdk/utils/resource_refs.py +195 -0
  143. glaip_sdk/utils/run_renderer.py +41 -0
  144. glaip_sdk/utils/runtime_config.py +425 -0
  145. glaip_sdk/utils/serialization.py +424 -0
  146. glaip_sdk/utils/sync.py +142 -0
  147. glaip_sdk/utils/tool_detection.py +33 -0
  148. glaip_sdk/utils/validation.py +264 -0
  149. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/METADATA +4 -5
  150. glaip_sdk-0.6.16.dist-info/RECORD +160 -0
  151. glaip_sdk-0.6.15b2.dist-info/RECORD +0 -12
  152. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/WHEEL +0 -0
  153. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/entry_points.txt +0 -0
  154. {glaip_sdk-0.6.15b2.dist-info → glaip_sdk-0.6.16.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,425 @@
1
+ """Runtime configuration helpers for agent execution.
2
+
3
+ Provides utilities for normalizing runtime_config keys from various input types
4
+ (SDK objects, UUIDs, names) to stable platform IDs.
5
+
6
+ Authors:
7
+ Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from typing import TYPE_CHECKING
13
+
14
+ from glaip_sdk.utils.resource_refs import is_uuid
15
+ from gllm_core.utils import LoggerManager
16
+
17
+ if TYPE_CHECKING:
18
+ from glaip_sdk.agents import Agent
19
+ from glaip_sdk.mcps import MCP
20
+ from glaip_sdk.registry import AgentRegistry, MCPRegistry, ToolRegistry
21
+ from glaip_sdk.tools import Tool
22
+
23
+ # Type alias for config key inputs (only used in type hints)
24
+ ConfigKeyInput = str | Agent | Tool | MCP | type[Agent] | type[Tool] | type[MCP]
25
+
26
+ # Type alias for registry types
27
+ Registry = ToolRegistry | MCPRegistry | AgentRegistry
28
+
29
+ # Type alias for runtime config dict shape after normalization
30
+ # Top-level keys include:
31
+ # - "tool_configs", "mcp_configs", "agent_config"
32
+ # - Agent IDs for agent-specific overrides
33
+ # Values are nested dictionaries whose contents depend on the section.
34
+ RuntimeConfigDict = dict[str, dict[str, object]]
35
+
36
+ logger = LoggerManager().get_logger(__name__)
37
+
38
+ # Config fields that need key normalization (maps field name to registry type)
39
+ _NORMALIZABLE_FIELDS = {
40
+ "tool_configs": "tool",
41
+ "mcp_configs": "mcp",
42
+ }
43
+
44
+ # Config fields that are preserved as-is (no normalization needed)
45
+ _PASSTHROUGH_FIELDS = {"agent_config"}
46
+
47
+
48
+ def _extract_id_from_key(key: ConfigKeyInput) -> str | None:
49
+ """Extract ID directly from key if available.
50
+
51
+ Args:
52
+ key: The config key to extract ID from.
53
+
54
+ Returns:
55
+ The ID string if available, None otherwise.
56
+ """
57
+ if isinstance(key, str) and is_uuid(key):
58
+ return key
59
+ if hasattr(key, "id") and key.id is not None:
60
+ return key.id
61
+ return None
62
+
63
+
64
+ def _resolve_via_registry(key: ConfigKeyInput, registry: Registry | None) -> str | None:
65
+ """Attempt to resolve key via registry.
66
+
67
+ Args:
68
+ key: The config key to resolve.
69
+ registry: Registry to use for resolution.
70
+
71
+ Returns:
72
+ The resolved ID string if successful, None otherwise.
73
+ """
74
+ if registry is None:
75
+ return None
76
+
77
+ try:
78
+ return registry.resolve(key).id
79
+ except (KeyError, ValueError, AttributeError) as exc:
80
+ logger.debug("Failed to resolve key via registry: %r", key, exc_info=exc)
81
+ return None
82
+ except Exception as exc: # pragma: no cover - unexpected failures
83
+ logger.warning(
84
+ "Unexpected error resolving key via registry for %r: %s",
85
+ key,
86
+ exc,
87
+ exc_info=True,
88
+ )
89
+ return None
90
+
91
+
92
+ def _resolve_config_key(
93
+ key: ConfigKeyInput,
94
+ registry: Registry | None,
95
+ *,
96
+ missing_registry_message: str,
97
+ unresolved_message: str,
98
+ ) -> str:
99
+ """Resolve a config key using a registry when needed.
100
+
101
+ For non-ID keys this always requires a registry; callers customize the
102
+ error messages for missing registries vs unresolved keys.
103
+ """
104
+ # Allow direct UUID / object.id without needing a registry
105
+ if (extracted_id := _extract_id_from_key(key)) is not None:
106
+ return extracted_id
107
+
108
+ # For non-ID keys we always require a registry
109
+ if registry is None:
110
+ raise ValueError(missing_registry_message.format(key=key))
111
+
112
+ if (resolved_id := _resolve_via_registry(key, registry)) is not None:
113
+ return resolved_id
114
+
115
+ raise ValueError(unresolved_message.format(key=key))
116
+
117
+
118
+ def _normalize_section_keys(
119
+ config_section: dict[ConfigKeyInput, dict[str, object]],
120
+ registry: Registry | None,
121
+ ) -> dict[str, dict[str, object]]:
122
+ """Normalize keys in a single config section (e.g. tool_configs).
123
+
124
+ Converts ConfigKeyInput keys (SDK objects, names, classes) to stable IDs
125
+ using the provided registry.
126
+
127
+ Example:
128
+ Input: {ToolClass: {"param": "value"}, "tool-name": {"x": 1}}
129
+ Output: {"uuid-1": {"param": "value"}, "uuid-2": {"x": 1}}
130
+
131
+ Args:
132
+ config_section: The config section dict to normalize.
133
+ registry: Registry to use for resolving keys.
134
+
135
+ Returns:
136
+ Normalized config section with all keys converted to IDs.
137
+ """
138
+ normalized: dict[str, dict[str, object]] = {}
139
+ for key, value in config_section.items():
140
+ resolved_id = _resolve_config_key(
141
+ key,
142
+ registry,
143
+ missing_registry_message="Unable to resolve runtime_config key via registry: {key!r}",
144
+ unresolved_message="Unable to resolve runtime_config key via registry: {key!r}",
145
+ )
146
+ normalized[resolved_id] = value
147
+ return normalized
148
+
149
+
150
+ def _is_agent_specific_key(key: object) -> bool:
151
+ """Check if a key represents an agent-specific override.
152
+
153
+ Agent-specific keys are:
154
+ - Agent instances (from glaip_sdk.agents.Agent)
155
+ - UUID strings (agent IDs)
156
+ - Non-reserved string names (resolved via agent_registry)
157
+
158
+ NOT agent-specific:
159
+ - Known config field names (tool_configs, mcp_configs, agent_config)
160
+ - Tool or MCP objects (these are only valid inside *_configs sections)
161
+
162
+ Args:
163
+ key: The key to check.
164
+
165
+ Returns:
166
+ True if the key could be an agent-specific override.
167
+ """
168
+ from glaip_sdk.agents import Agent # noqa: PLC0415
169
+
170
+ # Agent instance
171
+ if isinstance(key, Agent):
172
+ return True
173
+
174
+ # Non-string keys that are not Agent instances are not agent-specific
175
+ if not isinstance(key, str):
176
+ return False
177
+
178
+ # Known config field names are not agent-specific
179
+ if key in _NORMALIZABLE_FIELDS or key in _PASSTHROUGH_FIELDS:
180
+ return False
181
+
182
+ # Any other string key is treated as an agent reference (ID or name)
183
+ return True
184
+
185
+
186
+ def _normalize_standard_config(
187
+ config: dict[str, object],
188
+ tool_registry: ToolRegistry | None,
189
+ mcp_registry: MCPRegistry | None,
190
+ context: str = "",
191
+ ) -> dict[str, object]:
192
+ """Normalize a standard config dict with tool_configs, mcp_configs, agent_config sections.
193
+
194
+ Used for both global runtime_config and agent-specific nested configs.
195
+ Delegates key normalization to _normalize_section_keys for each section.
196
+
197
+ Example:
198
+ Input: {"tool_configs": {ToolClass: {...}}, "agent_config": {...}}
199
+ Output: {"tool_configs": {"tool-uuid": {...}}, "agent_config": {...}}
200
+
201
+ Args:
202
+ config: The config dict to normalize.
203
+ tool_registry: Registry for resolving tool keys.
204
+ mcp_registry: Registry for resolving MCP keys.
205
+ context: Context string for warning messages.
206
+
207
+ Returns:
208
+ Normalized config dict.
209
+ """
210
+ registries: dict[str, Registry | None] = {
211
+ "tool": tool_registry,
212
+ "mcp": mcp_registry,
213
+ }
214
+
215
+ result: dict[str, object] = {}
216
+
217
+ for field, value in config.items():
218
+ if field in _NORMALIZABLE_FIELDS and isinstance(value, dict):
219
+ registry_type = _NORMALIZABLE_FIELDS[field]
220
+ result[field] = _normalize_section_keys(value, registries.get(registry_type))
221
+ elif field in _PASSTHROUGH_FIELDS:
222
+ result[field] = value
223
+ else:
224
+ logger.warning("Unknown field '%s' in %s, ignoring", field, context or "config")
225
+
226
+ return result
227
+
228
+
229
+ def normalize_runtime_config_keys(
230
+ runtime_config: RuntimeConfigDict | None,
231
+ tool_registry: ToolRegistry | None,
232
+ mcp_registry: MCPRegistry | None,
233
+ agent_registry: AgentRegistry | None,
234
+ ) -> RuntimeConfigDict | None:
235
+ """Normalize runtime_config keys from various input types to stable IDs.
236
+
237
+ Handles both global configs and agent-specific overrides:
238
+ - Global: tool_configs, mcp_configs, agent_config
239
+ - Agent-specific: keyed by Agent object, agent UUID, or agent name string
240
+
241
+ Example:
242
+ Input:
243
+ {
244
+ "tool_configs": {ToolClass: {"param": "val"}},
245
+ "agent_config": {"planning": True},
246
+ AgentClass: {"mcp_configs": {MCPClass: {...}}}
247
+ }
248
+ Output:
249
+ {
250
+ "tool_configs": {"tool-uuid": {"param": "val"}},
251
+ "agent_config": {"planning": True},
252
+ "agent-uuid": {"mcp_configs": {"mcp-uuid": {...}}}
253
+ }
254
+
255
+ Converts keys from:
256
+ - SDK objects → their .id attribute
257
+ - UUID strings → passed through
258
+ - Names → resolved via appropriate registry
259
+
260
+ Args:
261
+ runtime_config: The runtime configuration dict to normalize.
262
+ tool_registry: Registry for resolving tool keys.
263
+ mcp_registry: Registry for resolving MCP keys.
264
+ agent_registry: Registry for resolving agent keys.
265
+
266
+ Returns:
267
+ Normalized runtime_config with all keys converted to IDs, or None if input is None.
268
+ """
269
+ if runtime_config is None:
270
+ return None
271
+
272
+ if not runtime_config:
273
+ return {}
274
+
275
+ registries: dict[str, Registry | None] = {
276
+ "tool": tool_registry,
277
+ "mcp": mcp_registry,
278
+ }
279
+
280
+ result: dict[str, object] = {}
281
+
282
+ for field, value in runtime_config.items():
283
+ if field in _NORMALIZABLE_FIELDS and isinstance(value, dict):
284
+ registry_type = _NORMALIZABLE_FIELDS[field]
285
+ result[field] = _normalize_section_keys(value, registries.get(registry_type))
286
+ elif field in _PASSTHROUGH_FIELDS:
287
+ result[field] = value
288
+ elif _is_agent_specific_key(field) and isinstance(value, dict):
289
+ agent_id = _resolve_config_key(
290
+ field,
291
+ agent_registry,
292
+ missing_registry_message=(
293
+ "Agent-specific runtime_config provided but no agent_registry is available to resolve key: {key!r}"
294
+ ),
295
+ unresolved_message="Unable to resolve agent-specific runtime_config key: {key!r}",
296
+ )
297
+ result[agent_id] = _normalize_standard_config(
298
+ value,
299
+ tool_registry,
300
+ mcp_registry,
301
+ context=f"agent '{agent_id}'",
302
+ )
303
+ else:
304
+ logger.warning("Unknown field '%s' in runtime_config, ignoring", field)
305
+
306
+ return result
307
+
308
+
309
+ # =============================================================================
310
+ # LOCAL MODE UTILITIES
311
+ # =============================================================================
312
+ # The functions below are for local execution mode where resources are NOT
313
+ # deployed and have no UUIDs. They resolve keys to names (not IDs).
314
+ # =============================================================================
315
+
316
+
317
+ def _get_name_from_class(cls: type) -> str:
318
+ """Extract name from a class, handling Pydantic models and @property descriptors.
319
+
320
+ Args:
321
+ cls: The class to extract name from.
322
+
323
+ Returns:
324
+ The resolved name string.
325
+ """
326
+ # Try class-level name attribute first, but guard against @property descriptors
327
+ # When a class has @property name, getattr returns the property object, not a string
328
+ class_name = getattr(cls, "name", None)
329
+ if isinstance(class_name, str) and class_name:
330
+ return class_name
331
+
332
+ # For Pydantic models, check model_fields for default value
333
+ model_fields = getattr(cls, "model_fields", None)
334
+ if model_fields and "name" in model_fields:
335
+ field_info = model_fields["name"]
336
+ default = getattr(field_info, "default", None)
337
+ if default and isinstance(default, str):
338
+ return default
339
+
340
+ # Fallback to class __name__
341
+ return cls.__name__
342
+
343
+
344
+ def get_name_from_key(key: object) -> str | None:
345
+ """Resolve config key to name for local mode (no registry needed).
346
+
347
+ Supports instances, classes, and string names. UUID strings are not
348
+ supported in local mode and return None with a warning.
349
+
350
+ Args:
351
+ key: Tool, MCP, or Agent instance/class/string.
352
+
353
+ Returns:
354
+ The resolved name string, or None if UUID (not applicable locally).
355
+
356
+ Raises:
357
+ ValueError: If the key cannot be resolved to a valid name.
358
+ """
359
+ # Class type (not instance) - must check BEFORE hasattr("name")
360
+ # because classes with @property name will have hasattr return True
361
+ # but getattr returns the property descriptor, not a string
362
+ if isinstance(key, type):
363
+ return _get_name_from_class(key)
364
+
365
+ # String key - check early to avoid attribute access
366
+ if isinstance(key, str):
367
+ if is_uuid(key):
368
+ logger.warning("UUID '%s' not supported in local mode, skipping", key)
369
+ return None
370
+ return key
371
+
372
+ # Instance with name attribute
373
+ if hasattr(key, "name"):
374
+ name = getattr(key, "name", None)
375
+ # Guard against @property that returns non-string (e.g., descriptor)
376
+ if isinstance(name, str) and name:
377
+ return name
378
+
379
+ raise ValueError(f"Unable to resolve config key: {key!r}")
380
+
381
+
382
+ def normalize_local_config_keys(config: dict[object, object]) -> dict[str, object]:
383
+ """Normalize all keys in a config dict to names for local mode.
384
+
385
+ Converts instance/class/string keys to string names without using
386
+ registry. UUID keys are skipped with a warning.
387
+
388
+ Args:
389
+ config: Dict with instance/class/string keys and any values.
390
+
391
+ Returns:
392
+ Dict with string name keys only. UUID keys are omitted.
393
+ """
394
+ if not config:
395
+ return {}
396
+
397
+ result: dict[str, object] = {}
398
+ for key, value in config.items():
399
+ name = get_name_from_key(key)
400
+ if name is not None:
401
+ result[name] = value
402
+ return result
403
+
404
+
405
+ def merge_configs(*configs: dict | None) -> dict:
406
+ """Merge multiple config dicts with priority ordering.
407
+
408
+ Later configs override earlier ones for the same key. None configs
409
+ are skipped gracefully.
410
+
411
+ Args:
412
+ *configs: Config dicts in priority order (lowest priority first).
413
+
414
+ Returns:
415
+ Merged config dict with later values overriding earlier ones.
416
+
417
+ Example:
418
+ >>> merge_configs({"a": 1}, {"a": 2, "b": 3})
419
+ {"a": 2, "b": 3}
420
+ """
421
+ result: dict = {}
422
+ for config in configs:
423
+ if config:
424
+ result.update(config)
425
+ return result