dasein-core 0.2.20__tar.gz → 0.2.21__tar.gz

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 (67) hide show
  1. {dasein_core-0.2.20/src/dasein_core.egg-info → dasein_core-0.2.21}/PKG-INFO +1 -1
  2. {dasein_core-0.2.20 → dasein_core-0.2.21}/pyproject.toml +1 -1
  3. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/api.py +179 -0
  4. {dasein_core-0.2.20 → dasein_core-0.2.21/src/dasein_core.egg-info}/PKG-INFO +1 -1
  5. {dasein_core-0.2.20 → dasein_core-0.2.21}/LICENSE +0 -0
  6. {dasein_core-0.2.20 → dasein_core-0.2.21}/MANIFEST.in +0 -0
  7. {dasein_core-0.2.20 → dasein_core-0.2.21}/README.md +0 -0
  8. {dasein_core-0.2.20 → dasein_core-0.2.21}/examples/dasein_examples.ipynb +0 -0
  9. {dasein_core-0.2.20 → dasein_core-0.2.21}/setup.cfg +0 -0
  10. {dasein_core-0.2.20 → dasein_core-0.2.21}/setup.py +0 -0
  11. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/__init__.py +0 -0
  12. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/advice_format.py +0 -0
  13. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/capture.py +0 -0
  14. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/config.py +0 -0
  15. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/events.py +0 -0
  16. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/extractors.py +0 -0
  17. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/injection_strategies.py +0 -0
  18. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/injector.py +0 -0
  19. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/microturn.py +0 -0
  20. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/__init__.py +0 -0
  21. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/LICENSE +0 -0
  22. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/LICENSES_SOURCES +0 -0
  23. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/README.md +0 -0
  24. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/accuracy.json +0 -0
  25. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/attribute_ruler/patterns +0 -0
  26. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/config.cfg +0 -0
  27. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/lemmatizer/lookups/lookups.bin +0 -0
  28. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/meta.json +0 -0
  29. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/ner/cfg +0 -0
  30. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/ner/model +0 -0
  31. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/ner/moves +0 -0
  32. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/parser/cfg +0 -0
  33. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/parser/model +0 -0
  34. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/parser/moves +0 -0
  35. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/senter/cfg +0 -0
  36. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/senter/model +0 -0
  37. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tagger/cfg +0 -0
  38. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tagger/model +0 -0
  39. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tok2vec/cfg +0 -0
  40. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tok2vec/model +0 -0
  41. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tokenizer +0 -0
  42. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/key2row +0 -0
  43. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/lookups.bin +0 -0
  44. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/strings.json +0 -0
  45. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/vectors +0 -0
  46. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/vectors.cfg +0 -0
  47. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/meta.json +0 -0
  48. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/LICENSE +0 -0
  49. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/LICENSES_SOURCES +0 -0
  50. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/METADATA +0 -0
  51. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/RECORD +0 -0
  52. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/WHEEL +0 -0
  53. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/entry_points.txt +0 -0
  54. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/top_level.txt +0 -0
  55. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/pipecleaner.py +0 -0
  56. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/__init__.py +0 -0
  57. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/post_run_client.py +0 -0
  58. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/pre_run_client.py +0 -0
  59. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/service_adapter.py +0 -0
  60. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/service_config.py +0 -0
  61. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/trace_buffer.py +0 -0
  62. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/types.py +0 -0
  63. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/wrappers.py +0 -0
  64. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/SOURCES.txt +0 -0
  65. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/dependency_links.txt +0 -0
  66. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/requires.txt +0 -0
  67. {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dasein-core
3
- Version: 0.2.20
3
+ Version: 0.2.21
4
4
  Summary: Universal memory for agentic AI. Attach a brain to any LangChain/LangGraph agent in a single line.
5
5
  Author-email: Dasein Team <support@dasein.ai>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dasein-core"
7
- version = "0.2.20"
7
+ version = "0.2.21"
8
8
  description = "Universal memory for agentic AI. Attach a brain to any LangChain/LangGraph agent in a single line."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -2804,6 +2804,157 @@ Follow these rules when planning your actions."""
2804
2804
 
2805
2805
  return result
2806
2806
 
2807
+ def _create_synthetic_tool_messages(self, selected_rules):
2808
+ """
2809
+ Convert selected rules into synthetic ToolMessage objects.
2810
+
2811
+ Each rule becomes a tool call/response pair from Dasein, making rules
2812
+ appear as data already retrieved from the environment rather than instructions.
2813
+
2814
+ Args:
2815
+ selected_rules: List of rule objects or (rule, metadata) tuples
2816
+
2817
+ Returns:
2818
+ List of ToolMessage objects
2819
+ """
2820
+ try:
2821
+ from langchain_core.messages import ToolMessage
2822
+ import uuid
2823
+
2824
+ tool_messages = []
2825
+
2826
+ for i, rule_meta in enumerate(selected_rules):
2827
+ # Unwrap tuple format if present
2828
+ if isinstance(rule_meta, tuple) and len(rule_meta) == 2:
2829
+ rule, metadata = rule_meta
2830
+ else:
2831
+ rule = rule_meta
2832
+ metadata = {}
2833
+
2834
+ # Extract rule ID and advice text
2835
+ if isinstance(rule, dict):
2836
+ rule_id = rule.get('id', rule.get('rule_id', f'rule_{i}'))
2837
+ advice_text = rule.get('advice_text', rule.get('advice', ''))
2838
+ else:
2839
+ rule_id = getattr(rule, 'id', getattr(rule, 'rule_id', f'rule_{i}'))
2840
+ advice_text = getattr(rule, 'advice_text', getattr(rule, 'advice', ''))
2841
+
2842
+ # Skip if no advice text
2843
+ if not advice_text:
2844
+ continue
2845
+
2846
+ # Create ToolMessage with rule content
2847
+ # Note: tool_call_id is required for ToolMessage
2848
+ tool_msg = ToolMessage(
2849
+ content=advice_text, # Rule advice as tool output
2850
+ tool_call_id=f"dasein_{rule_id}",
2851
+ name="Dasein"
2852
+ )
2853
+
2854
+ tool_messages.append(tool_msg)
2855
+
2856
+ if tool_messages:
2857
+ self._vprint(f"[DASEIN][TOOL_MSG] Created {len(tool_messages)} synthetic tool messages from rules")
2858
+
2859
+ return tool_messages
2860
+
2861
+ except Exception as e:
2862
+ print(f"[DASEIN][TOOL_MSG] ERROR creating synthetic tool messages: {e}")
2863
+ import traceback
2864
+ traceback.print_exc()
2865
+ return []
2866
+
2867
+ def _inject_tool_messages_into_input(self, args, tool_messages):
2868
+ """
2869
+ Inject synthetic tool messages into agent input at step -1.
2870
+
2871
+ Handles both LangChain (dict with 'input' field) and LangGraph
2872
+ (dict with 'messages' field) input formats.
2873
+
2874
+ Args:
2875
+ args: Original args tuple passed to agent.invoke()
2876
+ tool_messages: List of ToolMessage objects to inject
2877
+
2878
+ Returns:
2879
+ Modified args tuple with tool messages injected
2880
+ """
2881
+ if not tool_messages or not args:
2882
+ return args
2883
+
2884
+ try:
2885
+ original_input = args[0]
2886
+
2887
+ # LangGraph format: {"messages": [...]}
2888
+ if isinstance(original_input, dict) and "messages" in original_input:
2889
+ self._vprint(f"[DASEIN][TOOL_MSG] Detected LangGraph input format")
2890
+ modified_input = original_input.copy()
2891
+ existing_messages = modified_input.get("messages", [])
2892
+
2893
+ # Prepend tool messages BEFORE user message
2894
+ modified_input["messages"] = tool_messages + list(existing_messages)
2895
+
2896
+ self._vprint(f"[DASEIN][TOOL_MSG] Injected {len(tool_messages)} tool messages before {len(existing_messages)} existing messages")
2897
+
2898
+ # Return modified args
2899
+ modified_args = list(args)
2900
+ modified_args[0] = modified_input
2901
+ return tuple(modified_args)
2902
+
2903
+ # LangChain format: {"input": "query"} or just "query"
2904
+ else:
2905
+ self._vprint(f"[DASEIN][TOOL_MSG] Detected LangChain input format")
2906
+
2907
+ # For LangChain, we need to convert to message format
2908
+ # LangChain expects {"input": str}, so we wrap in messages format
2909
+ from langchain_core.messages import HumanMessage
2910
+
2911
+ if isinstance(original_input, dict) and "input" in original_input:
2912
+ # Dict with input field
2913
+ user_message = HumanMessage(content=original_input["input"])
2914
+ elif isinstance(original_input, str):
2915
+ # String input
2916
+ user_message = HumanMessage(content=original_input)
2917
+ else:
2918
+ # Unknown format, skip injection
2919
+ self._vprint(f"[DASEIN][TOOL_MSG] Unknown input format, skipping injection")
2920
+ return args
2921
+
2922
+ # Create new input with messages
2923
+ # CRITICAL: For LangChain SQL agents, we need to preserve the {"input": ...} format
2924
+ # but some agents can handle {"messages": [...]} format
2925
+ # Let's try both approaches based on agent type
2926
+
2927
+ if self._is_langgraph:
2928
+ # LangGraph always uses messages format
2929
+ modified_input = {
2930
+ "messages": tool_messages + [user_message]
2931
+ }
2932
+ else:
2933
+ # LangChain: Keep original format but add messages field
2934
+ # Some agents support both input and messages
2935
+ if isinstance(original_input, dict):
2936
+ modified_input = original_input.copy()
2937
+ modified_input["messages"] = tool_messages + [user_message]
2938
+ else:
2939
+ # String input: convert to messages format
2940
+ modified_input = {
2941
+ "input": original_input,
2942
+ "messages": tool_messages + [user_message]
2943
+ }
2944
+
2945
+ self._vprint(f"[DASEIN][TOOL_MSG] Injected {len(tool_messages)} tool messages into LangChain input")
2946
+
2947
+ # Return modified args
2948
+ modified_args = list(args)
2949
+ modified_args[0] = modified_input
2950
+ return tuple(modified_args)
2951
+
2952
+ except Exception as e:
2953
+ print(f"[DASEIN][TOOL_MSG] ERROR injecting tool messages: {e}")
2954
+ import traceback
2955
+ traceback.print_exc()
2956
+ return args
2957
+
2807
2958
  def invoke(self, *args, **kwargs):
2808
2959
  """
2809
2960
  Invoke the agent with complete Dasein pipeline.
@@ -2877,6 +3028,13 @@ Follow these rules when planning your actions."""
2877
3028
  kwargs['callbacks'] = callbacks
2878
3029
  self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
2879
3030
 
3031
+ # STEP -1: Inject synthetic tool messages BEFORE agent execution
3032
+ # Convert rules to tool messages so they appear as data already retrieved
3033
+ tool_messages = self._create_synthetic_tool_messages(selected_rules)
3034
+ if tool_messages:
3035
+ args = self._inject_tool_messages_into_input(args, tool_messages)
3036
+ print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
3037
+
2880
3038
  # Run the agent
2881
3039
  result = self._agent.invoke(*args, **kwargs)
2882
3040
 
@@ -2959,6 +3117,13 @@ Follow these rules when planning your actions."""
2959
3117
  kwargs['callbacks'] = callbacks
2960
3118
  self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
2961
3119
 
3120
+ # STEP -1: Inject synthetic tool messages BEFORE agent execution
3121
+ # Convert rules to tool messages so they appear as data already retrieved
3122
+ tool_messages = self._create_synthetic_tool_messages(selected_rules)
3123
+ if tool_messages:
3124
+ args = self._inject_tool_messages_into_input(args, tool_messages)
3125
+ print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
3126
+
2962
3127
  # Run the agent asynchronously
2963
3128
  result = await self._agent.ainvoke(*args, **kwargs)
2964
3129
 
@@ -3173,6 +3338,13 @@ Follow these rules when planning your actions."""
3173
3338
  kwargs['callbacks'] = callbacks
3174
3339
  self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
3175
3340
 
3341
+ # STEP -1: Inject synthetic tool messages BEFORE agent execution
3342
+ # Convert rules to tool messages so they appear as data already retrieved
3343
+ tool_messages = self._create_synthetic_tool_messages(selected_rules)
3344
+ if tool_messages:
3345
+ args = self._inject_tool_messages_into_input(args, tool_messages)
3346
+ print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
3347
+
3176
3348
  # Run the agent
3177
3349
  result = self._agent.invoke(*args, **kwargs)
3178
3350
 
@@ -3246,6 +3418,13 @@ Follow these rules when planning your actions."""
3246
3418
  kwargs['callbacks'] = callbacks
3247
3419
  self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
3248
3420
 
3421
+ # STEP -1: Inject synthetic tool messages BEFORE agent execution
3422
+ # Convert rules to tool messages so they appear as data already retrieved
3423
+ tool_messages = self._create_synthetic_tool_messages(selected_rules)
3424
+ if tool_messages:
3425
+ args = self._inject_tool_messages_into_input(args, tool_messages)
3426
+ print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
3427
+
3249
3428
  # Run the agent asynchronously
3250
3429
  result = await self._agent.ainvoke(*args, **kwargs)
3251
3430
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dasein-core
3
- Version: 0.2.20
3
+ Version: 0.2.21
4
4
  Summary: Universal memory for agentic AI. Attach a brain to any LangChain/LangGraph agent in a single line.
5
5
  Author-email: Dasein Team <support@dasein.ai>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes