lionagi 0.13.2__py3-none-any.whl → 0.13.4__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 (50) hide show
  1. lionagi/config.py +1 -1
  2. lionagi/fields/action.py +0 -1
  3. lionagi/fields/reason.py +0 -1
  4. lionagi/libs/file/save.py +1 -1
  5. lionagi/libs/schema/as_readable.py +142 -196
  6. lionagi/libs/schema/extract_docstring.py +1 -2
  7. lionagi/libs/token_transform/synthlang_/base.py +0 -2
  8. lionagi/libs/validate/string_similarity.py +1 -2
  9. lionagi/models/hashable_model.py +0 -1
  10. lionagi/models/schema_model.py +0 -1
  11. lionagi/operations/ReAct/utils.py +0 -1
  12. lionagi/operations/__init__.py +2 -0
  13. lionagi/operations/_act/act.py +0 -1
  14. lionagi/operations/flow.py +436 -0
  15. lionagi/operations/interpret/interpret.py +1 -4
  16. lionagi/operations/manager.py +0 -1
  17. lionagi/operations/node.py +107 -0
  18. lionagi/operations/plan/plan.py +0 -1
  19. lionagi/operations/select/utils.py +0 -2
  20. lionagi/protocols/forms/flow.py +3 -1
  21. lionagi/protocols/generic/pile.py +1 -2
  22. lionagi/protocols/generic/processor.py +0 -1
  23. lionagi/protocols/graph/__init__.py +6 -0
  24. lionagi/protocols/graph/graph.py +1 -3
  25. lionagi/protocols/mail/package.py +0 -1
  26. lionagi/protocols/messages/assistant_response.py +0 -2
  27. lionagi/protocols/messages/message.py +0 -1
  28. lionagi/service/connections/endpoint_config.py +6 -0
  29. lionagi/service/connections/match_endpoint.py +26 -8
  30. lionagi/service/connections/providers/claude_code_.py +8 -9
  31. lionagi/service/connections/providers/claude_code_cli.py +411 -0
  32. lionagi/service/connections/providers/oai_.py +1 -1
  33. lionagi/service/manager.py +0 -1
  34. lionagi/service/rate_limited_processor.py +0 -2
  35. lionagi/service/token_calculator.py +0 -3
  36. lionagi/session/__init__.py +5 -0
  37. lionagi/session/branch.py +0 -2
  38. lionagi/session/session.py +47 -1
  39. lionagi/settings.py +2 -3
  40. lionagi/utils.py +6 -9
  41. lionagi/version.py +1 -1
  42. {lionagi-0.13.2.dist-info → lionagi-0.13.4.dist-info}/METADATA +15 -10
  43. {lionagi-0.13.2.dist-info → lionagi-0.13.4.dist-info}/RECORD +45 -47
  44. lionagi/traits/__init__.py +0 -58
  45. lionagi/traits/base.py +0 -216
  46. lionagi/traits/composer.py +0 -343
  47. lionagi/traits/protocols.py +0 -495
  48. lionagi/traits/registry.py +0 -1071
  49. {lionagi-0.13.2.dist-info → lionagi-0.13.4.dist-info}/WHEEL +0 -0
  50. {lionagi-0.13.2.dist-info → lionagi-0.13.4.dist-info}/licenses/LICENSE +0 -0
@@ -1,495 +0,0 @@
1
- """
2
- Protocol definitions for all LionAGI traits.
3
-
4
- This module contains the Protocol interfaces that define the contract
5
- for each trait. Protocols provide:
6
-
7
- - Compile-time type checking with mypy
8
- - Runtime type checking with isinstance()
9
- - Zero overhead at runtime (145ns isinstance checks)
10
- - Excellent IDE integration and autocomplete
11
-
12
- Each Protocol defines the minimal interface required to satisfy
13
- the corresponding trait.
14
- """
15
-
16
- from __future__ import annotations
17
-
18
- from abc import abstractmethod
19
- from collections.abc import AsyncIterator
20
- from typing import Any, Protocol, runtime_checkable
21
-
22
- __all__ = [
23
- "Auditable",
24
- "Cacheable",
25
- "CapabilityAware",
26
- "Composable",
27
- "Extensible",
28
- "Hashable",
29
- "Identifiable",
30
- "Indexable",
31
- "Lazy",
32
- "Observable",
33
- "Operable",
34
- "Partial",
35
- "Secured",
36
- "Serializable",
37
- "Streaming",
38
- "Temporal",
39
- "Validatable",
40
- ]
41
-
42
-
43
- @runtime_checkable
44
- class Identifiable(Protocol):
45
- """
46
- Protocol for entities that have a unique identity.
47
-
48
- This is the most fundamental trait, providing stable identity
49
- across the system. All identified entities can be compared,
50
- referenced, and tracked.
51
- """
52
-
53
- @property
54
- @abstractmethod
55
- def id(self) -> str:
56
- """Unique identifier for this entity."""
57
- ...
58
-
59
- @property
60
- @abstractmethod
61
- def id_type(self) -> str:
62
- """Type/namespace of the identifier (e.g., 'uuid', 'snowflake')."""
63
- ...
64
-
65
- def same_identity(self, other: Any) -> bool:
66
- """Check if this entity has the same identity as another."""
67
- if not hasattr(other, "id") or not hasattr(other, "id_type"):
68
- return False
69
- return bool(self.id == other.id and self.id_type == other.id_type)
70
-
71
-
72
- @runtime_checkable
73
- class Temporal(Protocol):
74
- """
75
- Protocol for entities that track temporal information.
76
-
77
- Provides creation and modification timestamps with
78
- timezone awareness.
79
- """
80
-
81
- @property
82
- @abstractmethod
83
- def created_at(self) -> float:
84
- """Unix timestamp when entity was created."""
85
- ...
86
-
87
- @property
88
- @abstractmethod
89
- def updated_at(self) -> float:
90
- """Unix timestamp when entity was last updated."""
91
- ...
92
-
93
- def age_seconds(self) -> float:
94
- """Get age of entity in seconds."""
95
- import time
96
-
97
- return time.time() - self.created_at
98
-
99
- def is_modified(self) -> bool:
100
- """Check if entity has been modified since creation."""
101
- return self.updated_at > self.created_at
102
-
103
-
104
- @runtime_checkable
105
- class Auditable(Protocol):
106
- """
107
- Protocol for entities that emit audit events.
108
-
109
- Extends Temporal with comprehensive change tracking
110
- and event emission capabilities.
111
- """
112
-
113
- @property
114
- @abstractmethod
115
- def version(self) -> int:
116
- """Version number, incremented on each change."""
117
- ...
118
-
119
- @property
120
- @abstractmethod
121
- def audit_log(self) -> list[dict[str, Any]]:
122
- """Audit log entries for this entity."""
123
- ...
124
-
125
- @abstractmethod
126
- def emit_audit_event(self, event_type: str, **kwargs: Any) -> None:
127
- """Emit an audit event for tracking changes."""
128
- ...
129
-
130
-
131
- @runtime_checkable
132
- class Hashable(Protocol):
133
- """
134
- Protocol for entities that provide stable hashing.
135
-
136
- Ensures hash stability across sessions and processes
137
- for use in sets, dictionaries, and caching.
138
- """
139
-
140
- @abstractmethod
141
- def __hash__(self) -> int: # type: ignore[explicit-override]
142
- """Stable hash value for this entity."""
143
- ...
144
-
145
- @property
146
- @abstractmethod
147
- def hash_fields(self) -> tuple[str, ...]:
148
- """Fields used in hash computation."""
149
- ...
150
-
151
- def verify_hash_stability(self) -> bool:
152
- """Verify that hash is stable across multiple calls."""
153
- hash1 = hash(self)
154
- hash2 = hash(self)
155
- return hash1 == hash2
156
-
157
-
158
- @runtime_checkable
159
- class Operable(Protocol):
160
- """
161
- Protocol for entities that support operations and transformations.
162
-
163
- Provides a framework for applying operations while
164
- maintaining type safety and error handling.
165
- """
166
-
167
- @abstractmethod
168
- def apply_operation(self, operation: str, **kwargs: Any) -> Any:
169
- """Apply a named operation to this entity."""
170
- ...
171
-
172
- @abstractmethod
173
- def get_supported_operations(self) -> list[str]:
174
- """Get list of supported operation names."""
175
- ...
176
-
177
- def supports_operation(self, operation: str) -> bool:
178
- """Check if entity supports a specific operation."""
179
- return operation in self.get_supported_operations()
180
-
181
-
182
- @runtime_checkable
183
- class Observable(Protocol):
184
- """
185
- Protocol for entities that emit events for state changes.
186
-
187
- Provides observer pattern implementation with
188
- type-safe event handling.
189
- """
190
-
191
- @abstractmethod
192
- def subscribe(
193
- self, observer: Any, event_types: list[str] | None = None
194
- ) -> str:
195
- """Subscribe to events. Returns subscription ID."""
196
- ...
197
-
198
- @abstractmethod
199
- def unsubscribe(self, subscription_id: str) -> bool:
200
- """Unsubscribe from events."""
201
- ...
202
-
203
- @abstractmethod
204
- def emit_event(self, event_type: str, **data: Any) -> None:
205
- """Emit an event to all subscribers."""
206
- ...
207
-
208
-
209
- @runtime_checkable
210
- class Validatable(Protocol):
211
- """
212
- Protocol for entities that support validation.
213
-
214
- Provides comprehensive validation with detailed
215
- error reporting and constraint checking.
216
- """
217
-
218
- @abstractmethod
219
- def is_valid(self) -> bool:
220
- """Check if entity is currently valid."""
221
- ...
222
-
223
- @abstractmethod
224
- def validate(self) -> list[str]:
225
- """Validate entity and return list of error messages."""
226
- ...
227
-
228
- @abstractmethod
229
- def get_validation_constraints(self) -> dict[str, Any]:
230
- """Get validation constraints for this entity."""
231
- ...
232
-
233
-
234
- @runtime_checkable
235
- class Serializable(Protocol):
236
- """
237
- Protocol for entities that can be serialized and deserialized.
238
-
239
- Supports multiple serialization formats with
240
- version compatibility.
241
- """
242
-
243
- @abstractmethod
244
- def to_dict(self) -> dict[str, Any]:
245
- """Serialize to dictionary."""
246
- ...
247
-
248
- @classmethod
249
- @abstractmethod
250
- def from_dict(cls, data: dict[str, Any]) -> Any:
251
- """Deserialize from dictionary."""
252
- ...
253
-
254
- @property
255
- @abstractmethod
256
- def serialization_version(self) -> str:
257
- """Version string for serialization compatibility."""
258
- ...
259
-
260
-
261
- @runtime_checkable
262
- class Composable(Protocol):
263
- """
264
- Protocol for entities that can be composed with others.
265
-
266
- Enables trait composition and model merging with
267
- conflict resolution.
268
- """
269
-
270
- @abstractmethod
271
- def compose_with(self, other: Any) -> Any:
272
- """Compose this entity with another."""
273
- ...
274
-
275
- @abstractmethod
276
- def get_composition_conflicts(self, other: Any) -> list[str]:
277
- """Get list of conflicts when composing with another entity."""
278
- ...
279
-
280
- @property
281
- @abstractmethod
282
- def composition_priority(self) -> int:
283
- """Priority for conflict resolution (higher wins)."""
284
- ...
285
-
286
-
287
- @runtime_checkable
288
- class Extensible(Protocol):
289
- """
290
- Protocol for entities that support dynamic extension.
291
-
292
- Allows runtime addition of behaviors and capabilities
293
- through a plugin system.
294
- """
295
-
296
- @abstractmethod
297
- def add_extension(self, name: str, extension: Any) -> bool:
298
- """Add a named extension."""
299
- ...
300
-
301
- @abstractmethod
302
- def get_extension(self, name: str) -> Any:
303
- """Get extension by name."""
304
- ...
305
-
306
- @abstractmethod
307
- def list_extensions(self) -> list[str]:
308
- """List all extension names."""
309
- ...
310
-
311
-
312
- @runtime_checkable
313
- class Cacheable(Protocol):
314
- """
315
- Protocol for entities that support caching and memoization.
316
-
317
- Provides cache management with invalidation
318
- and performance optimization.
319
- """
320
-
321
- @abstractmethod
322
- def get_cache_key(self) -> str:
323
- """Get unique cache key for this entity."""
324
- ...
325
-
326
- @abstractmethod
327
- def invalidate_cache(self) -> None:
328
- """Invalidate cached data for this entity."""
329
- ...
330
-
331
- @property
332
- @abstractmethod
333
- def cache_ttl(self) -> int:
334
- """Cache time-to-live in seconds."""
335
- ...
336
-
337
-
338
- @runtime_checkable
339
- class Indexable(Protocol):
340
- """
341
- Protocol for entities that can be indexed and searched.
342
-
343
- Provides search capabilities with field-based
344
- indexing and querying.
345
- """
346
-
347
- @abstractmethod
348
- def get_search_fields(self) -> dict[str, Any]:
349
- """Get fields available for searching."""
350
- ...
351
-
352
- @abstractmethod
353
- def matches_query(self, query: dict[str, Any]) -> bool:
354
- """Check if entity matches search query."""
355
- ...
356
-
357
- @property
358
- @abstractmethod
359
- def search_priority(self) -> float:
360
- """Priority for search result ranking."""
361
- ...
362
-
363
-
364
- @runtime_checkable
365
- class Lazy(Protocol):
366
- """
367
- Protocol for entities that support lazy loading.
368
-
369
- Enables deferred loading of expensive attributes
370
- and dependencies.
371
- """
372
-
373
- @abstractmethod
374
- def load_lazy_attributes(self) -> None:
375
- """Load all lazy attributes."""
376
- ...
377
-
378
- @abstractmethod
379
- def is_fully_loaded(self) -> bool:
380
- """Check if all lazy attributes are loaded."""
381
- ...
382
-
383
- @property
384
- @abstractmethod
385
- def lazy_fields(self) -> list[str]:
386
- """List of field names that are lazily loaded."""
387
- ...
388
-
389
-
390
- @runtime_checkable
391
- class Streaming(Protocol):
392
- """
393
- Protocol for entities that support streaming updates.
394
-
395
- Enables incremental updates and real-time
396
- data processing.
397
- """
398
-
399
- @abstractmethod
400
- async def stream_updates(self) -> AsyncIterator[dict[str, Any]]:
401
- """Stream incremental updates."""
402
- ...
403
-
404
- @abstractmethod
405
- def apply_stream_update(self, update: dict[str, Any]) -> bool:
406
- """Apply a streaming update."""
407
- ...
408
-
409
- @property
410
- @abstractmethod
411
- def supports_streaming(self) -> bool:
412
- """Check if streaming is currently supported."""
413
- ...
414
-
415
-
416
- @runtime_checkable
417
- class Partial(Protocol):
418
- """
419
- Protocol for entities that support partial construction.
420
-
421
- Allows incremental building of complex entities
422
- with validation at each step.
423
- """
424
-
425
- @abstractmethod
426
- def is_complete(self) -> bool:
427
- """Check if entity is fully constructed."""
428
- ...
429
-
430
- @abstractmethod
431
- def get_missing_fields(self) -> list[str]:
432
- """Get list of required fields that are missing."""
433
- ...
434
-
435
- @abstractmethod
436
- def finalize(self) -> Any:
437
- """Finalize partial entity into complete form."""
438
- ...
439
-
440
-
441
- @runtime_checkable
442
- class Secured(Protocol):
443
- """
444
- Protocol for entities with security policies.
445
-
446
- Provides access control and security policy
447
- enforcement.
448
- """
449
-
450
- @abstractmethod
451
- def check_access(self, operation: str, context: dict[str, Any]) -> bool:
452
- """Check if operation is allowed in given context."""
453
- ...
454
-
455
- @abstractmethod
456
- def get_security_policy(self) -> dict[str, Any]:
457
- """Get security policy for this entity."""
458
- ...
459
-
460
- @property
461
- @abstractmethod
462
- def security_level(self) -> str:
463
- """Security level (e.g., 'public', 'restricted', 'confidential')."""
464
- ...
465
-
466
-
467
- @runtime_checkable
468
- class CapabilityAware(Protocol):
469
- """
470
- Protocol for entities that participate in capability-based security.
471
-
472
- Integrates with the capability system for fine-grained
473
- access control.
474
- """
475
-
476
- @abstractmethod
477
- def grant_capability(self, capability: str, target: Any) -> bool:
478
- """Grant a capability to a target entity."""
479
- ...
480
-
481
- @abstractmethod
482
- def revoke_capability(self, capability: str, target: Any) -> bool:
483
- """Revoke a capability from a target entity."""
484
- ...
485
-
486
- @abstractmethod
487
- def has_capability(self, capability: str) -> bool:
488
- """Check if entity has a specific capability."""
489
- ...
490
-
491
- @property
492
- @abstractmethod
493
- def granted_capabilities(self) -> set[str]:
494
- """Set of capabilities granted to this entity."""
495
- ...