lionagi 0.13.2__py3-none-any.whl → 0.13.3__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 (44) hide show
  1. lionagi/fields/action.py +0 -1
  2. lionagi/fields/reason.py +0 -1
  3. lionagi/libs/file/save.py +1 -1
  4. lionagi/libs/schema/as_readable.py +142 -196
  5. lionagi/libs/schema/extract_docstring.py +1 -2
  6. lionagi/libs/token_transform/synthlang_/base.py +0 -2
  7. lionagi/libs/validate/string_similarity.py +1 -2
  8. lionagi/models/hashable_model.py +0 -1
  9. lionagi/models/schema_model.py +0 -1
  10. lionagi/operations/ReAct/utils.py +0 -1
  11. lionagi/operations/_act/act.py +0 -1
  12. lionagi/operations/interpret/interpret.py +1 -4
  13. lionagi/operations/manager.py +0 -1
  14. lionagi/operations/plan/plan.py +0 -1
  15. lionagi/operations/select/utils.py +0 -2
  16. lionagi/protocols/forms/flow.py +3 -1
  17. lionagi/protocols/generic/pile.py +1 -2
  18. lionagi/protocols/generic/processor.py +0 -1
  19. lionagi/protocols/graph/graph.py +1 -3
  20. lionagi/protocols/mail/package.py +0 -1
  21. lionagi/protocols/messages/assistant_response.py +0 -2
  22. lionagi/protocols/messages/message.py +0 -1
  23. lionagi/service/connections/endpoint_config.py +6 -0
  24. lionagi/service/connections/match_endpoint.py +26 -8
  25. lionagi/service/connections/providers/claude_code_.py +8 -9
  26. lionagi/service/connections/providers/claude_code_cli.py +414 -0
  27. lionagi/service/connections/providers/oai_.py +1 -1
  28. lionagi/service/manager.py +0 -1
  29. lionagi/service/rate_limited_processor.py +0 -2
  30. lionagi/service/token_calculator.py +0 -3
  31. lionagi/session/branch.py +0 -2
  32. lionagi/session/session.py +0 -1
  33. lionagi/settings.py +0 -1
  34. lionagi/utils.py +6 -9
  35. lionagi/version.py +1 -1
  36. {lionagi-0.13.2.dist-info → lionagi-0.13.3.dist-info}/METADATA +5 -3
  37. {lionagi-0.13.2.dist-info → lionagi-0.13.3.dist-info}/RECORD +39 -43
  38. lionagi/traits/__init__.py +0 -58
  39. lionagi/traits/base.py +0 -216
  40. lionagi/traits/composer.py +0 -343
  41. lionagi/traits/protocols.py +0 -495
  42. lionagi/traits/registry.py +0 -1071
  43. {lionagi-0.13.2.dist-info → lionagi-0.13.3.dist-info}/WHEEL +0 -0
  44. {lionagi-0.13.2.dist-info → lionagi-0.13.3.dist-info}/licenses/LICENSE +0 -0
lionagi/utils.py CHANGED
@@ -5,6 +5,7 @@
5
5
  import asyncio
6
6
  import contextlib
7
7
  import copy as _copy
8
+ import dataclasses
8
9
  import functools
9
10
  import importlib.metadata
10
11
  import importlib.util
@@ -134,7 +135,6 @@ def hash_dict(data) -> int:
134
135
 
135
136
 
136
137
  class Params(BaseModel):
137
-
138
138
  def keys(self):
139
139
  return self.model_fields.keys()
140
140
 
@@ -900,7 +900,6 @@ async def bcall(
900
900
  flatten_tuple_set: bool = False,
901
901
  **kwargs: Any,
902
902
  ) -> AsyncGenerator[list[T | tuple[T, float]], None]:
903
-
904
903
  input_ = to_list(input_, flatten=True, dropna=True)
905
904
 
906
905
  for i in range(0, len(input_), batch_size):
@@ -1372,7 +1371,6 @@ def xml_to_dict(
1372
1371
 
1373
1372
 
1374
1373
  def dict_to_xml(data: dict, /, root_tag: str = "root") -> str:
1375
-
1376
1374
  root = ET.Element(root_tag)
1377
1375
 
1378
1376
  def convert(dict_obj: dict, parent: Any) -> None:
@@ -1471,7 +1469,6 @@ def recursive_to_dict(
1471
1469
  recursive_custom_types: bool = False,
1472
1470
  **kwargs: Any,
1473
1471
  ) -> Any:
1474
-
1475
1472
  if not isinstance(max_recursive_depth, int):
1476
1473
  max_recursive_depth = 5
1477
1474
  else:
@@ -1504,7 +1501,6 @@ def _recur_to_dict(
1504
1501
  recursive_custom_types: bool = False,
1505
1502
  **kwargs: Any,
1506
1503
  ) -> Any:
1507
-
1508
1504
  if current_depth >= max_recursive_depth:
1509
1505
  return input_
1510
1506
 
@@ -1675,7 +1671,6 @@ def _to_dict(
1675
1671
  use_enum_values: bool = True,
1676
1672
  **kwargs: Any,
1677
1673
  ) -> dict[str, Any]:
1678
-
1679
1674
  if isinstance(input_, set):
1680
1675
  return _set_to_dict(input_)
1681
1676
 
@@ -1705,6 +1700,9 @@ def _to_dict(
1705
1700
  if isinstance(input_, Iterable):
1706
1701
  return _iterable_to_dict(input_)
1707
1702
 
1703
+ with contextlib.suppress(Exception):
1704
+ return dataclasses.asdict(input_)
1705
+
1708
1706
  return dict(input_)
1709
1707
 
1710
1708
 
@@ -2307,7 +2305,6 @@ def parse_number(type_and_value: tuple[str, str]) -> float | complex:
2307
2305
  def breakdown_pydantic_annotation(
2308
2306
  model: type[B], max_depth: int | None = None, current_depth: int = 0
2309
2307
  ) -> dict[str, Any]:
2310
-
2311
2308
  if not _is_pydantic_model(model):
2312
2309
  raise TypeError("Input must be a Pydantic model")
2313
2310
 
@@ -2397,7 +2394,7 @@ def check_import(
2397
2394
  if not is_import_installed(package_name):
2398
2395
  if attempt_install:
2399
2396
  logging.info(
2400
- f"Package {package_name} not found. Attempting " "to install.",
2397
+ f"Package {package_name} not found. Attempting to install.",
2401
2398
  )
2402
2399
  try:
2403
2400
  return install_import(
@@ -2576,7 +2573,7 @@ def pdf_to_images(
2576
2573
  saved_paths = []
2577
2574
  for i, image in enumerate(images):
2578
2575
  # Construct the output file name
2579
- image_file = os.path.join(output_folder, f"page_{i+1}.{fmt}")
2576
+ image_file = os.path.join(output_folder, f"page_{i + 1}.{fmt}")
2580
2577
  image.save(image_file, fmt.upper())
2581
2578
  saved_paths.append(image_file)
2582
2579
 
lionagi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.13.2"
1
+ __version__ = "0.13.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lionagi
3
- Version: 0.13.2
3
+ Version: 0.13.3
4
4
  Summary: An Intelligence Operating System.
5
5
  Author-email: HaiyangLi <quantocean.li@gmail.com>, Liangbingyan Luo <llby_luo@outlook.com>
6
6
  License: Apache License
@@ -221,8 +221,10 @@ Classifier: Programming Language :: Python :: 3.13
221
221
  Requires-Python: >=3.10
222
222
  Requires-Dist: aiocache>=0.12.0
223
223
  Requires-Dist: aiohttp>=3.12.0
224
+ Requires-Dist: anyio>=4.8.0
224
225
  Requires-Dist: backoff>=2.2.1
225
226
  Requires-Dist: jinja2>=3.1.0
227
+ Requires-Dist: json-repair>=0.47.8
226
228
  Requires-Dist: pillow>=11.0.0
227
229
  Requires-Dist: psutil>=7.0.0
228
230
  Requires-Dist: pydantic-settings>=2.8.0
@@ -234,7 +236,7 @@ Provides-Extra: all
234
236
  Requires-Dist: claude-code-sdk>=0.0.14; extra == 'all'
235
237
  Requires-Dist: docling>=2.15.1; extra == 'all'
236
238
  Requires-Dist: fastmcp>=2.10.5; extra == 'all'
237
- Requires-Dist: ollama>=0.5.0; extra == 'all'
239
+ Requires-Dist: ollama>=0.4.0; extra == 'all'
238
240
  Requires-Dist: rich>=13.0.0; extra == 'all'
239
241
  Provides-Extra: claude-code
240
242
  Requires-Dist: claude-code-sdk>=0.0.14; extra == 'claude-code'
@@ -249,7 +251,7 @@ Requires-Dist: pre-commit>=4.0.1; extra == 'lint'
249
251
  Provides-Extra: mcp
250
252
  Requires-Dist: fastmcp>=2.10.5; extra == 'mcp'
251
253
  Provides-Extra: ollama
252
- Requires-Dist: ollama>=0.5.0; extra == 'ollama'
254
+ Requires-Dist: ollama>=0.4.0; extra == 'ollama'
253
255
  Provides-Extra: reader
254
256
  Requires-Dist: docling>=2.15.1; extra == 'reader'
255
257
  Provides-Extra: rich
@@ -4,16 +4,16 @@ lionagi/_errors.py,sha256=S02keQTY2IMkTvpLe00v7P7b8QNJ0PrZ1KWmQWCEQAA,500
4
4
  lionagi/_types.py,sha256=iDdYewsP9rDrM7QY19_NDTcWUk7swp8vnGCrloHMtUM,53
5
5
  lionagi/config.py,sha256=dAhDFKtaaSfn6WT9dwX9Vd4TWWs6-Su1FgYIrFgYcgc,3709
6
6
  lionagi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- lionagi/settings.py,sha256=W52mM34E6jXF3GyqCFzVREKZrmnUqtZm_BVDsUiDI_s,1627
8
- lionagi/utils.py,sha256=uLTJKl7aTnFXV6ehA6zwiwEB7G2nQYKsO2pZ6mqFzUk,78908
9
- lionagi/version.py,sha256=blu6md2c3Nnj5gDBi8U36sYO3k8HcND8s7UoQBjfn3g,23
7
+ lionagi/settings.py,sha256=74IgATy0-LIuj6pWf2b-eB0ZpnWFt9OcLNifU97HDX8,1626
8
+ lionagi/utils.py,sha256=8zCdJHKbDJv2WSzAAiFnMSpvfyZb9RnmfSNaMEqdTJE,79003
9
+ lionagi/version.py,sha256=aiCDTKDs80gZjvqiXYkxhq_MLi4Du0L9OByDr6ZEVV4,23
10
10
  lionagi/fields/__init__.py,sha256=8oU7Vfk-fKiULFKqhM6VpJMqdZcVXPTM7twVfNDN_SQ,603
11
- lionagi/fields/action.py,sha256=iWSApCM77jS0Oc28lb7G601Etkp-yjx5U1hfI_FQgfA,5792
11
+ lionagi/fields/action.py,sha256=OziEpbaUeEVo34KdtbzDxXJBgkf3QLxlcKIQAfHe4O0,5791
12
12
  lionagi/fields/base.py,sha256=5CJc7j8kTTWzXwpYzkSAFzx4BglABfx3AElIATKB7bg,3857
13
13
  lionagi/fields/code.py,sha256=TFym51obzaSfCmeRoHZJyBtjfDI4tvl9F-1sjFc9rMw,7713
14
14
  lionagi/fields/file.py,sha256=DhQ_HE0RvTNzkvBGQHRgbMYSokDkzE8GEu814i6jw5Q,7297
15
15
  lionagi/fields/instruct.py,sha256=sMbCxEv0HQLa31JkJDmdrWWEzIfeKbcmN2hYOehz3Q0,4773
16
- lionagi/fields/reason.py,sha256=3Ksz9_40dI-oQ9VtmpnYAmJdeDDIO-TwLDrf1ijbXGM,1438
16
+ lionagi/fields/reason.py,sha256=eTGI9jDaaZJInUjCR9lEpYvw2_1UUF-xzCVCFP3-JRI,1437
17
17
  lionagi/fields/research.py,sha256=eEPKocx8eQy2E9FExRWVIo6MK_xvmwBAoRZciBY3RG0,1421
18
18
  lionagi/libs/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
19
19
  lionagi/libs/parse.py,sha256=JRS3bql0InHJqATnAatl-hQv4N--XXw4P77JHhTFnrc,1011
@@ -24,7 +24,7 @@ lionagi/libs/file/concat_files.py,sha256=FoI983oWFzp9VfFDP7kmbRb3t1CPe5F5LCtsux0
24
24
  lionagi/libs/file/file_ops.py,sha256=HBiIh1EljIJ5VTIXuyvJM0ppSs0YYOPUWmgDMJT634U,3430
25
25
  lionagi/libs/file/params.py,sha256=SZ5DkoffWfxWudOAYCfCxpL8UIm-1UjeyTtploo-Lqs,5824
26
26
  lionagi/libs/file/process.py,sha256=EsnEJcQUm4ReP7qkCeMvL4Qe6fLRcENVWZndh9TSUsc,8692
27
- lionagi/libs/file/save.py,sha256=TCxVlKxFFnr3xZ-HAXPpTomQoyiVrp6nKRoj-bcQt4k,2863
27
+ lionagi/libs/file/save.py,sha256=5PvX1o1danZEq6S7V-GHIbZ6n-m-1IDdWhXPRbUXSVE,2865
28
28
  lionagi/libs/nested/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
29
29
  lionagi/libs/nested/flatten.py,sha256=sB4jxZRoaUbjak9RbIWVWNKz2hzkhQJPFffV_Ws1GA0,5479
30
30
  lionagi/libs/nested/nfilter.py,sha256=kF7AWjLFHr22SOjRBSTx-7iRPaR7gs0FY5Y4XF2sWJ8,1768
@@ -41,9 +41,9 @@ lionagi/libs/package/management.py,sha256=zgzZ1lNpUhunu_QExiobSYWlvBbR0EORXW4jrt
41
41
  lionagi/libs/package/params.py,sha256=4dJiuaTlnhho6OHmBv-02cHx89XRCjnKqpMhVRvTse8,1056
42
42
  lionagi/libs/package/system.py,sha256=UW8Y6tEPRCy_pBv_Q8CXJAIbuo7CJDDoWEDdnP0ixp4,564
43
43
  lionagi/libs/schema/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
44
- lionagi/libs/schema/as_readable.py,sha256=Sd-SBxOwHaEPw2fBuY0vpAoYqUvatDYnoPWsJO6S8BE,14160
44
+ lionagi/libs/schema/as_readable.py,sha256=p8ke8ZxLwLQxmsJWD_N7Q_AYDYK60nuHztUREbTa5sk,12027
45
45
  lionagi/libs/schema/extract_code_block.py,sha256=PuJbJj1JnqR5fSZudowPcVPpEoKISLr0MjTOOVXSzwY,2394
46
- lionagi/libs/schema/extract_docstring.py,sha256=aYyLSRlB8lTH9QF9-6a56uph3AAkNuTyZ0S_duf5-fw,5729
46
+ lionagi/libs/schema/extract_docstring.py,sha256=uWyUevXS4JSN60tfouoBBAyE4_jyE-fz45CiS-fvKeI,5714
47
47
  lionagi/libs/schema/function_to_schema.py,sha256=XAB031WbYu3a7eFJyYjXVMAjmtWYSYr5kC_DYgjiuyM,5604
48
48
  lionagi/libs/schema/json_schema.py,sha256=cuHcaMr748O9g6suNGmRx4tRXcidd5-c7AMGjTIZyHM,7670
49
49
  lionagi/libs/schema/load_pydantic_model_from_schema.py,sha256=VGrmnMb26JNcB9LaQcqTwW--sUljqqlqqsPD69zjcEc,10183
@@ -54,7 +54,7 @@ lionagi/libs/token_transform/perplexity.py,sha256=EcINACZyMZfWyU9ESS0eBaFby9y44Y
54
54
  lionagi/libs/token_transform/symbolic_compress_context.py,sha256=J8UleoCRDBvbFvmss2JjOvJfuBT7LXUW7AsRB-oQq7c,4598
55
55
  lionagi/libs/token_transform/synthlang.py,sha256=W6e-_265UXqVosM9X0TLKW53rNHvWCKhsWbVAop49Ac,259
56
56
  lionagi/libs/token_transform/types.py,sha256=4HgAfNDlJ_Hu18kLt59GHr_76eF3xLpNCTbOXlAYVlA,491
57
- lionagi/libs/token_transform/synthlang_/base.py,sha256=GDle72c8EjFz_3hg_k-y0YmksBsn5TSRVTw5_cwfWTo,4109
57
+ lionagi/libs/token_transform/synthlang_/base.py,sha256=djsR3Lc0UH1PYy2q4fpqL9tp-ZNKOYbmVTDP-_d1Poo,4107
58
58
  lionagi/libs/token_transform/synthlang_/translate_to_synthlang.py,sha256=guA5v8CQRdAOsznsUSoK_x2JFzGbHE079AijDqqPPOw,4946
59
59
  lionagi/libs/token_transform/synthlang_/resources/frameworks/abstract_algebra.toml,sha256=2TuOAo97g8mNhdPH96HP8vYZpnC8neiP-KlhVqbp1Us,970
60
60
  lionagi/libs/token_transform/synthlang_/resources/frameworks/category_theory.toml,sha256=Stg9W3h8o7VkQ9tdAfSZmR3LctFqcH6OhOPdaw9BlIg,1064
@@ -73,24 +73,24 @@ lionagi/libs/validate/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZU
73
73
  lionagi/libs/validate/common_field_validators.py,sha256=1BHznXnJYcLQrHqvHKUnP6aqCptuQ0qN7KJRCExcJBU,4778
74
74
  lionagi/libs/validate/fuzzy_match_keys.py,sha256=M4EfpeWKE1eACLxeC4K-VDmHZXMRHeGUkDFbfny80AM,6255
75
75
  lionagi/libs/validate/fuzzy_validate_mapping.py,sha256=MZpRop3whCQQtgYwJgg66nbN0KxNuKXqulaAgA0Y1_g,4935
76
- lionagi/libs/validate/string_similarity.py,sha256=pXhsBrOs8cJjvjIuuTEDzP3j0V56gfd1J74qszMQ8i8,8733
76
+ lionagi/libs/validate/string_similarity.py,sha256=ymuqTKd95_h8ywD9VTzf24gIPyMz1Mm6Lve350yJ_NY,8718
77
77
  lionagi/libs/validate/validate_boolean.py,sha256=bjiX_WZ3Bg8XcqoWLzE1G9BpO0AisrlZUxrpye_mlGk,3614
78
78
  lionagi/models/__init__.py,sha256=R7DEGWuhH-izP7eN6SOw24-I4Mr2IVPXF4gNysmF2zQ,457
79
79
  lionagi/models/field_model.py,sha256=pRFUYs72BRB6jo4NkgeqslCp0xwqzvh00ibh8uaMAws,23674
80
- lionagi/models/hashable_model.py,sha256=IDj6ZnpdPMtvpoazZHLvIIgIw6u-sJ_UUiCEyRdKoGc,830
80
+ lionagi/models/hashable_model.py,sha256=oOqR3OJCU9cJfWHiG0WaEw0GMqfE2WTt4cy7WsAsiRg,829
81
81
  lionagi/models/model_params.py,sha256=zVU-PHp3skjK5ZVjpsPs1k_VJiS8X0hgct0xs6Z6W_Y,10955
82
82
  lionagi/models/note.py,sha256=okWJL4mGqt0bUVxHRyqsfJr7tEh6wwgYhF1CegxudIA,12202
83
83
  lionagi/models/operable_model.py,sha256=fXbcpBjO-SoaeF8fn-F1_KIcYw9_L73VIUM1BDg5hj4,19905
84
- lionagi/models/schema_model.py,sha256=ng4uxMameETlqdS2OInb2LpxTiynzmLL36gfHIzlwpU,668
84
+ lionagi/models/schema_model.py,sha256=ghRIM8aBNaToAknwNlhQKpuKXcwzyCw5pDE31bVKxs0,667
85
85
  lionagi/operations/__init__.py,sha256=2HExKTx2J3iKWsvS9YaF6i5SZgqcpAJkVmWbi2H5A5U,134
86
- lionagi/operations/manager.py,sha256=H7UY86PIxvxKdzJY9YVsWyJcqlwLWhVyvm4sYePH_uY,565
86
+ lionagi/operations/manager.py,sha256=7KD6NMWqYJHCPI2LumDRwGinF8WYKFjrr3bsNUi9xzI,564
87
87
  lionagi/operations/types.py,sha256=fM8HphnbBifMzhoKKvdl3JxGCBHlEGPJEYkLWj9b7vE,704
88
88
  lionagi/operations/utils.py,sha256=Cl4HuWQ1nCGkTexwOtDx7fpEWMc2L3ZQMCqylRBDy74,1219
89
89
  lionagi/operations/ReAct/ReAct.py,sha256=uoJnFMoPP1kzzmgLDFNBwEbWdfGNfG37IT22N1AM-hE,13504
90
90
  lionagi/operations/ReAct/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
91
- lionagi/operations/ReAct/utils.py,sha256=w8hf8-L1VCV5ZF8gjeFBfR81tmO9u2Ud2Wz3VlUn7AU,4437
91
+ lionagi/operations/ReAct/utils.py,sha256=FKb0v-1tboN17imxef9jLKWhet0Iz049eqvZCcJKNX8,4436
92
92
  lionagi/operations/_act/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
93
- lionagi/operations/_act/act.py,sha256=l1-mrOoWLP0reATBD4PTqGyuSUSH41sL6YbfzzFfJMk,2811
93
+ lionagi/operations/_act/act.py,sha256=LfN4UqTTHVvO1h9tqmDhVfVafVUOry4YGEivIZbmLqc,2810
94
94
  lionagi/operations/brainstorm/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
95
95
  lionagi/operations/brainstorm/brainstorm.py,sha256=N9LpFZCdYn8L8AnTFOoMnjK7nkFrjgrfj2Vhz759dXM,18701
96
96
  lionagi/operations/brainstorm/prompt.py,sha256=Dqi4NNeztdI4iutggRqjnOrG4a4E2JtwIAtRnjZ_ghQ,610
@@ -101,17 +101,17 @@ lionagi/operations/communicate/communicate.py,sha256=J23XkCk_oUD-cGYOuy4stwrwbei
101
101
  lionagi/operations/instruct/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
102
102
  lionagi/operations/instruct/instruct.py,sha256=7pxhyP5jxwpgqjmQNb1rnGF4QAVlbMENpsyl22mbKRM,794
103
103
  lionagi/operations/interpret/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
104
- lionagi/operations/interpret/interpret.py,sha256=8_F3oYaoYK8MDcK4iCwksBP7sI0UlgBiZSrUusdlKNo,1528
104
+ lionagi/operations/interpret/interpret.py,sha256=yl1NSp2iOm3dbycVLEcnV3absnqKoubfH15v6lQgySU,1500
105
105
  lionagi/operations/operate/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
106
106
  lionagi/operations/operate/operate.py,sha256=cMc-n_uBPC8L8URIHHdR9N2LiwFlOiVv8yazmrFxX8g,7358
107
107
  lionagi/operations/parse/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
108
108
  lionagi/operations/parse/parse.py,sha256=xS9uIxBzHLGD-1VpBVgGUhxF-tQDkF2KLmIpErM47RQ,6661
109
109
  lionagi/operations/plan/__init__.py,sha256=yGBPll6lOqVjadbTvDLGrTlMx3FfBW-e00z7AMvg7Uo,156
110
- lionagi/operations/plan/plan.py,sha256=ndExZm_kE04i6npJq1rhyRdKaoXWpVk3F-dEN59I_94,15305
110
+ lionagi/operations/plan/plan.py,sha256=s1XagpAA9ke71W0rJE23rERV4sixOGxS3lJtz3BL_XY,15304
111
111
  lionagi/operations/plan/prompt.py,sha256=GUNZ8RpHIa89D-_y7GK--Spg0JADI3K13sjf_w3a2mI,993
112
112
  lionagi/operations/select/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
113
113
  lionagi/operations/select/select.py,sha256=2l16ySPiqp5vyAMYm0CNBpNRVB0zvS76QwNAyFQ7tB4,2491
114
- lionagi/operations/select/utils.py,sha256=Lh7oERHgdkNawG07BhvPcoi0fsdnQUDaz114iH7xzWE,3713
114
+ lionagi/operations/select/utils.py,sha256=1S4Wo59hr0rbZG72EPnVExfx4G72sIeUh2vlqVtslqE,3711
115
115
  lionagi/operations/translate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
116
116
  lionagi/operations/translate/translate.py,sha256=6eBVoQRarGEJ8Tfcl6Z__PLHQTTIbM5MaPVYNeKHRIs,1397
117
117
  lionagi/protocols/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
@@ -123,34 +123,34 @@ lionagi/protocols/action/manager.py,sha256=XmdQIaVgSpmFBFW9kbW_rdwdQmlBteP4VRanx
123
123
  lionagi/protocols/action/tool.py,sha256=h2FAY1b8y3LXrvAtfFhvdv1nu8cwz2knUeRCi2G9k1E,5243
124
124
  lionagi/protocols/forms/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
125
125
  lionagi/protocols/forms/base.py,sha256=1J8UU2LXm1Lax5McJos0xjZTzMVLYQWd_hwtxI2wSuM,2838
126
- lionagi/protocols/forms/flow.py,sha256=olWUrQdn270hzhTw8xgMgXzhgZ82DmP_ggepjaH6OOU,2670
126
+ lionagi/protocols/forms/flow.py,sha256=t9Ycvmb-stj0rCyvXXwd7WBcDtuCCTEKYst2aqFDVag,2702
127
127
  lionagi/protocols/forms/form.py,sha256=B4903km_Ljz-OxYkb1ZT_cpHZSaAYYJpZMsffWlooo8,3062
128
128
  lionagi/protocols/forms/report.py,sha256=SvJJjOSCTfVuqK7AKaY8ldQIGJeSK2zoyPWUV41ge2c,1609
129
129
  lionagi/protocols/generic/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
130
130
  lionagi/protocols/generic/element.py,sha256=Eaij2YpTWsGk28Tqjazmjmc_tOnalH7_iGFZrL6QJb4,14420
131
131
  lionagi/protocols/generic/event.py,sha256=InjBd2K9aSYxgai1c20d4jaJOkEx5VGFfb7iZbiMiNA,5200
132
132
  lionagi/protocols/generic/log.py,sha256=vepclOaY3fdR1QgFDj9usOffsx9T-9PbgwXjTvm6twQ,7441
133
- lionagi/protocols/generic/pile.py,sha256=L965LgVKhaxpEe_5dOwjYFZ1UAGeWmUtZ4Tf0MRznHw,33562
134
- lionagi/protocols/generic/processor.py,sha256=LTF9Enb-9jj5Wuy_jLanAhiesc5-Gm6WiSntZoAAm8w,10382
133
+ lionagi/protocols/generic/pile.py,sha256=SVy4fk4pVDv3jS1GiLZo9fO_Nk53_ojfsQbUzM_Bkao,33531
134
+ lionagi/protocols/generic/processor.py,sha256=GQ_j_5f4UE-jJeqIJ9L2NdicpZnu50DSP1mvxlc7O_4,10381
135
135
  lionagi/protocols/generic/progression.py,sha256=qlITq1qzV119iR5qR__fBAzV489S7d4t20E8uDRicEw,15189
136
136
  lionagi/protocols/graph/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
137
137
  lionagi/protocols/graph/edge.py,sha256=lgxeceoazM4Jl2Un_owLpJOanqw2m4XPk3-dXGp1u8g,5229
138
- lionagi/protocols/graph/graph.py,sha256=ks3zJWdwycUW_3Q4dz3f_ZLYhOALpg76t5J3HEzDcy4,10237
138
+ lionagi/protocols/graph/graph.py,sha256=fhPc_ogXkxbBrM0_En9QTDVM7fHA_LzURCdmDRuBlHE,10217
139
139
  lionagi/protocols/graph/node.py,sha256=_bQ9h_s_X6dVyV4pueEfiKiFapOkDL-HuH2MboUekYI,4250
140
140
  lionagi/protocols/mail/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
141
141
  lionagi/protocols/mail/exchange.py,sha256=P1PcrFylIBeiQa8kox9H1qyJ4kjhUlbLiTUT8rs1OXg,7041
142
142
  lionagi/protocols/mail/mail.py,sha256=RB5CUft_4J85H9nM9g6aRXomTaqKwF5xVjJacPAhoa8,1356
143
143
  lionagi/protocols/mail/mailbox.py,sha256=RFQ3oi7n0ufRgeUoXwOC2Upvagf7vUspC7rTpASXNyA,2733
144
144
  lionagi/protocols/mail/manager.py,sha256=Ldk2Kj3Z_N1__q0xUXWshw31pVT9s4mNndoHYM_3dSU,6964
145
- lionagi/protocols/mail/package.py,sha256=DyedMJaCRp4kf9MJtprcrN55rPoSR_v6MXdbINopGvM,2662
145
+ lionagi/protocols/mail/package.py,sha256=qcKRWP5Lk3wTK_rJhRsXFQhWz0pb2Clcs7vJcMwgzzI,2661
146
146
  lionagi/protocols/messages/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
147
147
  lionagi/protocols/messages/action_request.py,sha256=-tG9ViTSiZ2beM0onE6C552H5oth-sHLHP6KsBV8OMk,6868
148
148
  lionagi/protocols/messages/action_response.py,sha256=SM3_vA9QPXz3Gc9uPhXm3zOXYheHZZGtl67Yff48Vu8,5272
149
- lionagi/protocols/messages/assistant_response.py,sha256=Hm3yKT82DJvFlR3GI49_PyjFPgPK37LDBatJiGLv_Bc,6914
149
+ lionagi/protocols/messages/assistant_response.py,sha256=jrzRPVHHDnPw86Xp0IHnPy0tOZdsk7rBwhG5xnBXAjs,6912
150
150
  lionagi/protocols/messages/base.py,sha256=Ng1Q8yIIIFauUv53LnwDeyOrM-cSCfsHM1GwkxChf2o,2317
151
151
  lionagi/protocols/messages/instruction.py,sha256=0dUsUYd6xYsbOHU7GafvqBkpDQQoFOXJXT-UoJArYWU,21146
152
152
  lionagi/protocols/messages/manager.py,sha256=e1jW5JH_3jZpZbFCvWZX0TG0DCgzANRUejW_6NqbtDc,17182
153
- lionagi/protocols/messages/message.py,sha256=rrGbya6rF86UB8xZcRP1YjgfJIFCxEWPQfHDcMuyBnM,7724
153
+ lionagi/protocols/messages/message.py,sha256=GJLDgluTc_dBikTjGM3Im73kQQaCGsvSoJcaxAJwtFo,7723
154
154
  lionagi/protocols/messages/system.py,sha256=x0F1C57SFHaO2-Z9cy1QshYlxv8wjl7VppooaGKbMIg,4658
155
155
  lionagi/protocols/messages/templates/README.md,sha256=Ch4JrKSjd85fLitAYO1OhZjNOGKHoEwaKQlcV16jiUI,1286
156
156
  lionagi/protocols/messages/templates/action_request.jinja2,sha256=d6OmxHKyvvNDSK4bnBM3TGSUk_HeE_Q2EtLAQ0ZBEJg,120
@@ -164,22 +164,23 @@ lionagi/protocols/operatives/operative.py,sha256=l417XukoI_ZRyVqjHy8q1BtTKBvlFxf
164
164
  lionagi/protocols/operatives/step.py,sha256=PHKehsJESx0I2PnWQG8lHgX7mPp3jX1eiLAQ22FUV3w,9835
165
165
  lionagi/service/__init__.py,sha256=DMGXIqPsmut9H5GT0ZeSzQIzYzzPwI-2gLXydpbwiV8,21
166
166
  lionagi/service/imodel.py,sha256=jE1Y3JzGwJZesHQtRSadVTAHA2TGdBAwfmzQoOA5Meg,12651
167
- lionagi/service/manager.py,sha256=9-dIE4ZftI94RLLLPXH-yB4E3zfnbTs3yppdFDPNchM,1165
168
- lionagi/service/rate_limited_processor.py,sha256=PnO0rBf9ObKhD3vtl6pYZX3nHVDvMPdOww59zCWgslQ,5230
167
+ lionagi/service/manager.py,sha256=tN3p0kM7pg_CEs6wXK62_B_h49Q3nrU-9qniFhw2ABE,1164
168
+ lionagi/service/rate_limited_processor.py,sha256=MUgMgcOXFbzLmQmDyKxnvQv0M06kzJI9rJXwf5WLVDU,5228
169
169
  lionagi/service/resilience.py,sha256=uYJYZQ9M-tje8ME3vJmYabXwKHF1c3Ij4-WrdCwogcs,18742
170
- lionagi/service/token_calculator.py,sha256=FysR31hpv4QPVsbZBVPR60LSW_xCQpwXx89zOJJ73LQ,6460
170
+ lionagi/service/token_calculator.py,sha256=piTidArzUkIMCtOLC_HBLoZNYZcENQywgeKM31bxezM,6457
171
171
  lionagi/service/types.py,sha256=6zavqBxK1Fj0nB9eZgJn3JICxmdT-n0nn8YWZFzM5LU,508
172
172
  lionagi/service/connections/__init__.py,sha256=yHQZ7OJpCftd6CStYR8inbxjJydYdmv9kCvbUBhJ2zU,362
173
173
  lionagi/service/connections/api_calling.py,sha256=XetCrjMhOHNKGGv-NzHhBhVS7XjKPalrS_iExzU-4S4,8005
174
174
  lionagi/service/connections/endpoint.py,sha256=yNIjq9wETMnytynGbq3qY_dkyaMlaHrcfiZjS-tnmLg,14756
175
- lionagi/service/connections/endpoint_config.py,sha256=QMfxqwvHhNjFSZupJ8oDCMlZK_uQkjGC145w6ETxnB8,4558
175
+ lionagi/service/connections/endpoint_config.py,sha256=mu-5KoETd4Y2RcRmc6MWJ2-FJyxYLjJhebBGYfWgjRs,4758
176
176
  lionagi/service/connections/header_factory.py,sha256=22sG4ian3MiNklF6SdQqkEYgtWKOZik_yDE0Lna6BiE,1754
177
- lionagi/service/connections/match_endpoint.py,sha256=mEZPDkK1qtvjTGN9-PZsK7w_yB7642nZiJsb0l5QUx4,1827
177
+ lionagi/service/connections/match_endpoint.py,sha256=K3I4vU6GH6utlEArlyDFUmNdnp94CEPxqKrehAx29J4,2410
178
178
  lionagi/service/connections/providers/__init__.py,sha256=3lzOakDoBWmMaNnT2g-YwktPKa_Wme4lnPRSmOQfayY,105
179
179
  lionagi/service/connections/providers/anthropic_.py,sha256=SUPnw2UqjY5wuHXLHas6snMTzhQ-UuixvPYbkVnXn34,3083
180
- lionagi/service/connections/providers/claude_code_.py,sha256=pqi_CfWdAnDnKt2ktTMn_62TZ0vgXv6ey4wxbGh-jjU,17393
180
+ lionagi/service/connections/providers/claude_code_.py,sha256=KAx7zK_mUwroPHwB5NfkHl0VYOxarM_LOOJUyD4NBQQ,17437
181
+ lionagi/service/connections/providers/claude_code_cli.py,sha256=U9JtP6kdL-lkw9IIwF-Z8QIrbLWLjVInRI53ZfQulkQ,14610
181
182
  lionagi/service/connections/providers/exa_.py,sha256=GGWaD9jd5gKM257OfUaIBBKIqR1NrNcBE67p_7JbK7g,938
182
- lionagi/service/connections/providers/oai_.py,sha256=cUI5En8irtKnEbwApgkyg2cPReS8c4Gxtcv65WnGhas,4776
183
+ lionagi/service/connections/providers/oai_.py,sha256=FmQMEmOY7H7dZd4og-_cdd1Unzy4lkIzMsTtEsm-yVE,4782
183
184
  lionagi/service/connections/providers/ollama_.py,sha256=jdx6dGeChwVk5TFfFRbpnrpKzj8YQZw6D5iWJ6zYmfk,4096
184
185
  lionagi/service/connections/providers/perplexity_.py,sha256=9MH9YmMy9Jg7JDMJHQxxMYHyjJ4NP0OlN7sCuhla85I,917
185
186
  lionagi/service/third_party/README.md,sha256=qFjWnI8rmLivIyr6Tc-hRZh-rQwntROp76af4MBNJJc,2214
@@ -189,21 +190,16 @@ lionagi/service/third_party/exa_models.py,sha256=G_hnekcy-DillPLzMoDQ8ZisVAL8Mp7
189
190
  lionagi/service/third_party/openai_models.py,sha256=sF-fQ726CnaDBgLY_r2NdPqc3GicPKhZjh5F8IfjBO0,501904
190
191
  lionagi/service/third_party/pplx_models.py,sha256=Nkm1ftESBa_NwP9ITBUNqLmAZ3Jh92aL732g_i6T8LQ,5947
191
192
  lionagi/session/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
192
- lionagi/session/branch.py,sha256=APvq4vQvlk6nPOWezL7sY59h2T-ndxONuBwYvu5ZcsA,69942
193
+ lionagi/session/branch.py,sha256=OzF8lftHXuI8ovS8I4iWet96XKHmJ0tA0rh7qvimw-0,69940
193
194
  lionagi/session/prompts.py,sha256=vLoodSB1vosCTujtU1hUWrm_OgsBAR_QZmru0yTIQ5A,3236
194
- lionagi/session/session.py,sha256=4Rk5_DB9y-yaqyfQ9tHYOMUy_0HCgCoGqeSc2Y5riu0,9172
195
+ lionagi/session/session.py,sha256=pLgNKE1eZBQ9LTPQRYKbteA86ebEKnA7Q-zaoKGpc1s,9171
195
196
  lionagi/tools/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
196
197
  lionagi/tools/base.py,sha256=cld32pyjaTUdyiqZ8hNyJjWKAhcJ8RQNhgImI7R8b-E,1940
197
198
  lionagi/tools/types.py,sha256=XtJLY0m-Yi_ZLWhm0KycayvqMCZd--HxfQ0x9vFUYDE,230
198
199
  lionagi/tools/file/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
199
200
  lionagi/tools/file/reader.py,sha256=0TdnfVGVCKuM58MmGM-NyVjhU9BFoitkNYEepdc0z_Y,9529
200
201
  lionagi/tools/memory/tools.py,sha256=zTGBenVsF8Wuh303kWntmQSGlAFKonHNdh5ePuQ26KE,15948
201
- lionagi/traits/__init__.py,sha256=2ZDhkp9SIAD7J36p7-6KE2ac2Alf_GQmlGGpeyxoQsw,1461
202
- lionagi/traits/base.py,sha256=ww1qOTrKz6p0rf52OFSWluUNldhs8_S2O-ers4KEUqQ,7114
203
- lionagi/traits/composer.py,sha256=7qqISOhN3ZhtL0J6fvU3Ic1vHXS2-SSI6kuwQn2tF3E,12780
204
- lionagi/traits/protocols.py,sha256=S4-EwTjpQwAZJcBbROn9QtJyXw4srnyMGOfabzqMh34,12210
205
- lionagi/traits/registry.py,sha256=hsQaDE4INsHTwD2ZvYpmPZ92k0i-grgC6PQXbscF5Qc,38465
206
- lionagi-0.13.2.dist-info/METADATA,sha256=OSa_9xutEW5Eb8UhrMmMoV247VDjVtJHX2ay0QJI4VA,20457
207
- lionagi-0.13.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
208
- lionagi-0.13.2.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
209
- lionagi-0.13.2.dist-info/RECORD,,
202
+ lionagi-0.13.3.dist-info/METADATA,sha256=OWMWwGTjG1vBa1S2tel3RF_DoZdSOi-URz24Vle_YRY,20520
203
+ lionagi-0.13.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
204
+ lionagi-0.13.3.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
205
+ lionagi-0.13.3.dist-info/RECORD,,
@@ -1,58 +0,0 @@
1
- """
2
- LionAGI v2 Trait System
3
-
4
- Protocol-based trait composition system for creating composable, type-safe behaviors.
5
-
6
- Research-validated approach:
7
- - Protocol-based traits: 9.25/10 weighted score vs alternatives
8
- - Performance: 145ns isinstance checks (fastest available)
9
- - Debugging: 8/10 debugging experience score
10
- - Type safety: Excellent IDE/mypy integration
11
-
12
- Core Components:
13
- - Trait: Enum of available trait types
14
- - TraitDefinition: Metadata for trait definitions
15
- - TraitRegistry: Global trait tracking and dependency resolution
16
- - Protocols: Type-safe interfaces for each trait
17
-
18
- Usage:
19
- >>> from lionagi.traits import Trait, TraitRegistry
20
- >>> from lionagi.traits.protocols import Identifiable
21
- >>>
22
- >>> # Register a trait implementation
23
- >>> TraitRegistry.register_trait(MyClass, Trait.IDENTIFIABLE)
24
- >>>
25
- >>> # Check trait support
26
- >>> assert isinstance(instance, Identifiable)
27
- """
28
-
29
- from .base import Trait, TraitDefinition
30
- from .composer import (
31
- TraitComposer,
32
- TraitComposition,
33
- compose,
34
- create_trait_composition,
35
- generate_model,
36
- )
37
- from .registry import (
38
- TraitRegistry,
39
- as_trait,
40
- get_global_registry,
41
- implement,
42
- seal_trait,
43
- )
44
-
45
- __all__ = [
46
- "Trait",
47
- "TraitComposer",
48
- "TraitComposition",
49
- "TraitDefinition",
50
- "TraitRegistry",
51
- "as_trait",
52
- "compose",
53
- "create_trait_composition",
54
- "generate_model",
55
- "get_global_registry",
56
- "implement",
57
- "seal_trait",
58
- ]
lionagi/traits/base.py DELETED
@@ -1,216 +0,0 @@
1
- """
2
- Core trait definitions and enumerations.
3
-
4
- This module defines the foundational types for the trait system:
5
- - Trait enum with all available traits
6
- - TraitDefinition for trait metadata
7
- - Core interfaces and type aliases
8
- """
9
-
10
- from __future__ import annotations
11
-
12
- import weakref
13
- from collections.abc import Callable
14
- from dataclasses import dataclass, field
15
- from enum import Enum
16
- from typing import TYPE_CHECKING, Any, TypeVar
17
-
18
- if TYPE_CHECKING:
19
- pass
20
-
21
- __all__ = ["Trait", "TraitDefinition", "TraitImpl", "TraitValidator"]
22
-
23
- # Type variables for trait system
24
- T = TypeVar("T")
25
- TraitValidator = Callable[[Any], bool]
26
- TraitImpl = type[T]
27
-
28
-
29
- class Trait(str, Enum):
30
- """
31
- Enumeration of all available traits in the LionAGI system.
32
-
33
- Each trait represents a specific behavior or capability that can be
34
- composed into domain models. Traits are implemented as Protocols
35
- for optimal type safety and performance.
36
- """
37
-
38
- # Core identity and lifecycle traits
39
- IDENTIFIABLE = "identifiable" # Has unique ID and identity methods
40
- TEMPORAL = "temporal" # Has creation/modification timestamps
41
- AUDITABLE = "auditable" # Tracks changes and emits audit events
42
- HASHABLE = "hashable" # Provides stable hashing behavior
43
-
44
- # Behavior and operation traits
45
- OPERABLE = "operable" # Supports operations and transformations
46
- OBSERVABLE = "observable" # Emits events for state changes
47
- VALIDATABLE = "validatable" # Supports validation and constraint checking
48
- SERIALIZABLE = "serializable" # Can be serialized/deserialized
49
-
50
- # Advanced composition traits
51
- COMPOSABLE = "composable" # Can be composed with other models
52
- EXTENSIBLE = "extensible" # Supports dynamic extension/plugins
53
- CACHEABLE = "cacheable" # Provides caching and memoization
54
- INDEXABLE = "indexable" # Can be indexed and searched
55
-
56
- # Performance and optimization traits
57
- LAZY = "lazy" # Supports lazy loading and evaluation
58
- STREAMING = "streaming" # Supports streaming updates
59
- PARTIAL = "partial" # Supports partial/incremental construction
60
-
61
- # Security and capability traits
62
- SECURED = "secured" # Has security policies and access control
63
- CAPABILITY_AWARE = (
64
- "capability_aware" # Participates in capability-based security
65
- )
66
-
67
-
68
- @dataclass(frozen=True, slots=True)
69
- class TraitDefinition:
70
- """
71
- Metadata definition for a specific trait implementation.
72
-
73
- This immutable dataclass captures all metadata needed to track
74
- and manage trait implementations within the system.
75
- """
76
-
77
- trait: Trait
78
- protocol_type: type[Any] # Protocol type
79
- implementation_type: type[Any]
80
- dependencies: frozenset[Trait] = field(default_factory=frozenset)
81
- version: str = "1.0.0"
82
- description: str = ""
83
-
84
- # Performance tracking
85
- registration_time: float = field(default=0.0)
86
- validation_checks: int = field(default=0)
87
-
88
- # Weak reference to avoid circular dependencies
89
- _weak_impl_ref: weakref.ReferenceType[type[Any]] = field(
90
- init=False, repr=False
91
- )
92
-
93
- def __post_init__(self) -> None:
94
- """Initialize weak reference to implementation."""
95
-
96
- def cleanup_callback(ref: weakref.ReferenceType[type[Any]]) -> None:
97
- pass
98
-
99
- object.__setattr__(
100
- self,
101
- "_weak_impl_ref",
102
- weakref.ref(self.implementation_type, cleanup_callback),
103
- )
104
-
105
- @property
106
- def is_alive(self) -> bool:
107
- """Check if the implementation type is still alive."""
108
- return self._weak_impl_ref() is not None
109
-
110
- def validate_dependencies(self, available_traits: set[Trait]) -> bool:
111
- """
112
- Validate that all trait dependencies are satisfied.
113
-
114
- Args:
115
- available_traits: Set of traits available on the target type
116
-
117
- Returns:
118
- True if all dependencies are satisfied
119
- """
120
- return self.dependencies.issubset(available_traits)
121
-
122
- def get_dependency_graph(self) -> dict[Trait, set[Trait]]:
123
- """
124
- Get the dependency graph for this trait.
125
-
126
- Returns:
127
- Mapping of trait to its direct dependencies
128
- """
129
- return {self.trait: set(self.dependencies)}
130
-
131
-
132
- # Default trait definitions with zero dependencies
133
- DEFAULT_TRAIT_DEFINITIONS: dict[Trait, TraitDefinition] = {}
134
-
135
-
136
- def _initialize_default_definitions() -> None:
137
- """Initialize default trait definitions (called at module load)."""
138
-
139
- from .protocols import (
140
- Auditable,
141
- Cacheable,
142
- CapabilityAware,
143
- Composable,
144
- Extensible,
145
- Hashable,
146
- Identifiable,
147
- Indexable,
148
- Lazy,
149
- Observable,
150
- Operable,
151
- Partial,
152
- Secured,
153
- Serializable,
154
- Streaming,
155
- Temporal,
156
- Validatable,
157
- )
158
-
159
- # Map traits to their protocol types
160
- _protocol_mapping = {
161
- Trait.IDENTIFIABLE: Identifiable,
162
- Trait.TEMPORAL: Temporal,
163
- Trait.AUDITABLE: Auditable,
164
- Trait.HASHABLE: Hashable,
165
- Trait.OPERABLE: Operable,
166
- Trait.OBSERVABLE: Observable,
167
- Trait.VALIDATABLE: Validatable,
168
- Trait.SERIALIZABLE: Serializable,
169
- Trait.COMPOSABLE: Composable,
170
- Trait.EXTENSIBLE: Extensible,
171
- Trait.CACHEABLE: Cacheable,
172
- Trait.INDEXABLE: Indexable,
173
- Trait.LAZY: Lazy,
174
- Trait.STREAMING: Streaming,
175
- Trait.PARTIAL: Partial,
176
- Trait.SECURED: Secured,
177
- Trait.CAPABILITY_AWARE: CapabilityAware,
178
- }
179
-
180
- _trait_dependencies = {
181
- # Core traits - no dependencies
182
- Trait.IDENTIFIABLE: frozenset(),
183
- Trait.TEMPORAL: frozenset(),
184
- Trait.HASHABLE: frozenset(),
185
- # Behavioral traits
186
- Trait.AUDITABLE: frozenset({Trait.IDENTIFIABLE, Trait.TEMPORAL}),
187
- Trait.OPERABLE: frozenset({Trait.IDENTIFIABLE}),
188
- Trait.OBSERVABLE: frozenset({Trait.IDENTIFIABLE}),
189
- Trait.VALIDATABLE: frozenset(),
190
- Trait.SERIALIZABLE: frozenset({Trait.IDENTIFIABLE}),
191
- # Advanced composition traits
192
- Trait.COMPOSABLE: frozenset({Trait.IDENTIFIABLE}),
193
- Trait.EXTENSIBLE: frozenset({Trait.IDENTIFIABLE}),
194
- Trait.CACHEABLE: frozenset({Trait.HASHABLE}),
195
- Trait.INDEXABLE: frozenset({Trait.IDENTIFIABLE, Trait.HASHABLE}),
196
- # Performance traits
197
- Trait.LAZY: frozenset({Trait.IDENTIFIABLE}),
198
- Trait.STREAMING: frozenset({Trait.OBSERVABLE}),
199
- Trait.PARTIAL: frozenset({Trait.VALIDATABLE}),
200
- # Security traits
201
- Trait.SECURED: frozenset({Trait.IDENTIFIABLE}),
202
- Trait.CAPABILITY_AWARE: frozenset({Trait.SECURED, Trait.IDENTIFIABLE}),
203
- }
204
-
205
- # Create default definitions with dependencies
206
- for trait, protocol_type in _protocol_mapping.items():
207
- DEFAULT_TRAIT_DEFINITIONS[trait] = TraitDefinition(
208
- trait=trait,
209
- protocol_type=protocol_type,
210
- implementation_type=object, # Placeholder
211
- dependencies=_trait_dependencies.get(trait, frozenset()),
212
- description=f"Default definition for {trait.name} trait",
213
- )
214
-
215
-
216
- _initialize_default_definitions()