chuk-ai-session-manager 0.7__tar.gz → 0.8__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 (65) hide show
  1. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/PKG-INFO +78 -2
  2. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/README.md +76 -0
  3. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/pyproject.toml +35 -3
  4. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/__init__.py +84 -40
  5. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/api/__init__.py +1 -0
  6. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/api/simple_api.py +53 -59
  7. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/exceptions.py +31 -17
  8. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/guards/__init__.py +118 -0
  9. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/guards/bindings.py +217 -0
  10. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/guards/cache.py +163 -0
  11. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/guards/manager.py +819 -0
  12. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/guards/models.py +498 -0
  13. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/guards/ungrounded.py +159 -0
  14. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/infinite_conversation.py +86 -79
  15. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/__init__.py +247 -0
  16. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/artifacts_bridge.py +469 -0
  17. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/context_packer.py +347 -0
  18. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/fault_handler.py +507 -0
  19. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/manifest.py +307 -0
  20. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/models.py +1084 -0
  21. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/mutation_log.py +186 -0
  22. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/pack_cache.py +206 -0
  23. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/page_table.py +275 -0
  24. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/prefetcher.py +192 -0
  25. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/tlb.py +247 -0
  26. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/vm_prompts.py +238 -0
  27. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/memory/working_set.py +574 -0
  28. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/models/__init__.py +21 -9
  29. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/models/event_source.py +3 -1
  30. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/models/event_type.py +18 -0
  31. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/models/session.py +103 -68
  32. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/models/session_event.py +69 -68
  33. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/models/session_metadata.py +9 -10
  34. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/models/session_run.py +21 -22
  35. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/models/token_usage.py +76 -76
  36. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/procedural_memory/__init__.py +70 -0
  37. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/procedural_memory/formatter.py +407 -0
  38. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/procedural_memory/manager.py +523 -0
  39. chuk_ai_session_manager-0.8/src/chuk_ai_session_manager/procedural_memory/models.py +371 -0
  40. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/sample_tools.py +79 -46
  41. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/session_aware_tool_processor.py +27 -16
  42. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/session_manager.py +238 -197
  43. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/session_prompt_builder.py +163 -111
  44. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager/session_storage.py +45 -52
  45. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager.egg-info/PKG-INFO +78 -2
  46. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager.egg-info/SOURCES.txt +24 -0
  47. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager.egg-info/requires.txt +1 -1
  48. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_basic_functionality.py +84 -104
  49. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_exceptions.py +98 -89
  50. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_infinite_conversation.py +155 -137
  51. chuk_ai_session_manager-0.8/tests/test_memory.py +1585 -0
  52. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_models.py +157 -140
  53. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_prompt_builder.py +187 -167
  54. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_session_manager.py +170 -197
  55. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_session_manager_advanced.py +138 -148
  56. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_simple.py +146 -170
  57. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_simple_api.py +430 -280
  58. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_storage.py +119 -114
  59. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_system_prompt.py +83 -86
  60. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/tests/test_tools.py +174 -201
  61. chuk_ai_session_manager-0.7/src/chuk_ai_session_manager/api/__init__.py +0 -1
  62. chuk_ai_session_manager-0.7/src/chuk_ai_session_manager/models/event_type.py +0 -9
  63. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/setup.cfg +0 -0
  64. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager.egg-info/dependency_links.txt +0 -0
  65. {chuk_ai_session_manager-0.7 → chuk_ai_session_manager-0.8}/src/chuk_ai_session_manager.egg-info/top_level.txt +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chuk-ai-session-manager
3
- Version: 0.7
3
+ Version: 0.8
4
4
  Summary: Session manager for AI applications
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
7
7
  Requires-Dist: chuk-sessions>=0.4.1
8
- Requires-Dist: chuk-tool-processor>=0.4.1
8
+ Requires-Dist: chuk-tool-processor>=0.18
9
9
  Requires-Dist: pydantic>=2.11.3
10
10
  Provides-Extra: redis
11
11
  Requires-Dist: chuk-sessions[redis]>=0.4.1; extra == "redis"
@@ -74,6 +74,35 @@ That's it! Zero configuration required.
74
74
 
75
75
  ## ⚡ Major Features
76
76
 
77
+ ### 🧠 **AI Virtual Memory**
78
+ OS-style memory management for AI context windows. Pages, working sets, faults, and eviction - giving conversations the illusion of infinite memory.
79
+
80
+ ```python
81
+ from chuk_ai_session_manager.memory import (
82
+ MemoryPage, PageTable, WorkingSetManager,
83
+ ContextPacker, ManifestBuilder, PageType,
84
+ )
85
+
86
+ # Create pages with type classification
87
+ claim = MemoryPage(
88
+ page_id="claim_auth",
89
+ page_type=PageType.CLAIM, # High-value, low eviction priority
90
+ content="Decision: Use JWT for authentication",
91
+ provenance=["msg_042", "msg_043"],
92
+ )
93
+
94
+ # Track in page table and working set
95
+ table = PageTable()
96
+ table.register(claim)
97
+
98
+ # Pack context for model with manifest
99
+ packer = ContextPacker()
100
+ packed = packer.pack([claim])
101
+ # Model sees VM:CONTEXT with page citations
102
+ ```
103
+
104
+ See [AI Virtual Memory docs](docs/memory/README.md) for full documentation.
105
+
77
106
  ### 🎯 **Zero-Configuration Tracking**
78
107
  ```python
79
108
  from chuk_ai_session_manager import SessionManager
@@ -104,6 +133,51 @@ await sm.ai_responds("Computing history begins with...", model="gpt-4")
104
133
  | `pip install chuk-ai-session-manager` | Memory | Development, testing | 1.8M ops/sec |
105
134
  | `pip install chuk-ai-session-manager[redis]` | Redis | Production, persistence | 20K ops/sec |
106
135
 
136
+ ### 🛡️ **Conversation Guards and Tool State**
137
+ Runtime guardrails that prevent runaway tool loops, track value bindings, and enforce grounded tool calls.
138
+
139
+ ```python
140
+ from chuk_ai_session_manager.guards import get_tool_state, ToolStateManager
141
+
142
+ # Get the singleton tool state manager
143
+ tool_state = get_tool_state()
144
+
145
+ # Track tool calls and bind results as $v0, $v1, ...
146
+ binding = tool_state.bind_value("sqrt", {"x": 16}, 4.0)
147
+ # LLM can now reference $v0 in subsequent calls
148
+
149
+ # Check for runaway tool loops
150
+ status = tool_state.check_runaway()
151
+
152
+ # Detect ungrounded calls (missing $vN references)
153
+ check = tool_state.check_ungrounded_call("normal_cdf", {"mean": 0, "std": 1, "x": 1.5})
154
+
155
+ # Reset state for a new prompt
156
+ tool_state.reset_for_new_prompt()
157
+ ```
158
+
159
+ **Guard components:**
160
+ - `ToolStateManager` - Coordinator for all guards, bindings, and cache
161
+ - `BindingManager` - `$vN` reference system for tracking tool results
162
+ - `ResultCache` - Tool result caching for deduplication
163
+ - `UngroundedGuard` - Detects calls with missing computed-value references
164
+ - Runtime guards (budget, runaway, per-tool limits) from `chuk-tool-processor`
165
+
166
+ ### 🧩 **Procedural Memory**
167
+ Learn from tool call history to improve future tool use.
168
+
169
+ ```python
170
+ from chuk_ai_session_manager import ToolMemoryManager, ProceduralContextFormatter
171
+
172
+ # Record tool outcomes
173
+ memory = ToolMemoryManager()
174
+ await memory.record("calculator", {"op": "add", "a": 5, "b": 3}, result=8, success=True)
175
+
176
+ # Format learned patterns for the model's context
177
+ formatter = ProceduralContextFormatter()
178
+ context = formatter.format(memory.get_patterns())
179
+ ```
180
+
107
181
  ### 🛠️ **Tool Integration**
108
182
  ```python
109
183
  # Automatic tool call tracking
@@ -222,6 +296,8 @@ Session Segments: {stats.get('session_segments', 1)}
222
296
  - **Production Ready**: Built-in persistence, monitoring, and error handling
223
297
  - **Token Aware**: Automatic cost tracking across all providers
224
298
  - **Tool Friendly**: Seamless tool call logging and retry mechanisms
299
+ - **Guardrails**: Runtime guards prevent runaway tool loops and ungrounded calls
300
+ - **Procedural Memory**: Learn from tool call history to improve future use
225
301
 
226
302
  ## 🛡️ Error Handling
227
303
 
@@ -48,6 +48,35 @@ That's it! Zero configuration required.
48
48
 
49
49
  ## ⚡ Major Features
50
50
 
51
+ ### 🧠 **AI Virtual Memory**
52
+ OS-style memory management for AI context windows. Pages, working sets, faults, and eviction - giving conversations the illusion of infinite memory.
53
+
54
+ ```python
55
+ from chuk_ai_session_manager.memory import (
56
+ MemoryPage, PageTable, WorkingSetManager,
57
+ ContextPacker, ManifestBuilder, PageType,
58
+ )
59
+
60
+ # Create pages with type classification
61
+ claim = MemoryPage(
62
+ page_id="claim_auth",
63
+ page_type=PageType.CLAIM, # High-value, low eviction priority
64
+ content="Decision: Use JWT for authentication",
65
+ provenance=["msg_042", "msg_043"],
66
+ )
67
+
68
+ # Track in page table and working set
69
+ table = PageTable()
70
+ table.register(claim)
71
+
72
+ # Pack context for model with manifest
73
+ packer = ContextPacker()
74
+ packed = packer.pack([claim])
75
+ # Model sees VM:CONTEXT with page citations
76
+ ```
77
+
78
+ See [AI Virtual Memory docs](docs/memory/README.md) for full documentation.
79
+
51
80
  ### 🎯 **Zero-Configuration Tracking**
52
81
  ```python
53
82
  from chuk_ai_session_manager import SessionManager
@@ -78,6 +107,51 @@ await sm.ai_responds("Computing history begins with...", model="gpt-4")
78
107
  | `pip install chuk-ai-session-manager` | Memory | Development, testing | 1.8M ops/sec |
79
108
  | `pip install chuk-ai-session-manager[redis]` | Redis | Production, persistence | 20K ops/sec |
80
109
 
110
+ ### 🛡️ **Conversation Guards and Tool State**
111
+ Runtime guardrails that prevent runaway tool loops, track value bindings, and enforce grounded tool calls.
112
+
113
+ ```python
114
+ from chuk_ai_session_manager.guards import get_tool_state, ToolStateManager
115
+
116
+ # Get the singleton tool state manager
117
+ tool_state = get_tool_state()
118
+
119
+ # Track tool calls and bind results as $v0, $v1, ...
120
+ binding = tool_state.bind_value("sqrt", {"x": 16}, 4.0)
121
+ # LLM can now reference $v0 in subsequent calls
122
+
123
+ # Check for runaway tool loops
124
+ status = tool_state.check_runaway()
125
+
126
+ # Detect ungrounded calls (missing $vN references)
127
+ check = tool_state.check_ungrounded_call("normal_cdf", {"mean": 0, "std": 1, "x": 1.5})
128
+
129
+ # Reset state for a new prompt
130
+ tool_state.reset_for_new_prompt()
131
+ ```
132
+
133
+ **Guard components:**
134
+ - `ToolStateManager` - Coordinator for all guards, bindings, and cache
135
+ - `BindingManager` - `$vN` reference system for tracking tool results
136
+ - `ResultCache` - Tool result caching for deduplication
137
+ - `UngroundedGuard` - Detects calls with missing computed-value references
138
+ - Runtime guards (budget, runaway, per-tool limits) from `chuk-tool-processor`
139
+
140
+ ### 🧩 **Procedural Memory**
141
+ Learn from tool call history to improve future tool use.
142
+
143
+ ```python
144
+ from chuk_ai_session_manager import ToolMemoryManager, ProceduralContextFormatter
145
+
146
+ # Record tool outcomes
147
+ memory = ToolMemoryManager()
148
+ await memory.record("calculator", {"op": "add", "a": 5, "b": 3}, result=8, success=True)
149
+
150
+ # Format learned patterns for the model's context
151
+ formatter = ProceduralContextFormatter()
152
+ context = formatter.format(memory.get_patterns())
153
+ ```
154
+
81
155
  ### 🛠️ **Tool Integration**
82
156
  ```python
83
157
  # Automatic tool call tracking
@@ -196,6 +270,8 @@ Session Segments: {stats.get('session_segments', 1)}
196
270
  - **Production Ready**: Built-in persistence, monitoring, and error handling
197
271
  - **Token Aware**: Automatic cost tracking across all providers
198
272
  - **Tool Friendly**: Seamless tool call logging and retry mechanisms
273
+ - **Guardrails**: Runtime guards prevent runaway tool loops and ungrounded calls
274
+ - **Procedural Memory**: Learn from tool call history to improve future use
199
275
 
200
276
  ## 🛡️ Error Handling
201
277
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chuk-ai-session-manager"
7
- version = "0.7"
7
+ version = "0.8"
8
8
  description = "Session manager for AI applications"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -12,7 +12,7 @@ requires-python = ">=3.11"
12
12
  # Core dependencies - only what's absolutely required
13
13
  dependencies = [
14
14
  "chuk-sessions>=0.4.1",
15
- "chuk-tool-processor>=0.4.1",
15
+ "chuk-tool-processor>=0.18",
16
16
  "pydantic>=2.11.3",
17
17
  ]
18
18
 
@@ -90,6 +90,37 @@ include = '\.pyi?$'
90
90
  profile = "black"
91
91
  multi_line_output = 3
92
92
 
93
+ [tool.ruff]
94
+ line-length = 88
95
+ target-version = "py311"
96
+
97
+ [tool.ruff.lint]
98
+ select = ["E", "F", "W"]
99
+ ignore = ["E501"] # Line too long - handled by formatter
100
+
101
+ [tool.ruff.lint.per-file-ignores]
102
+ # Allow imports after module-level code in __init__.py files
103
+ "__init__.py" = ["E402", "F401"]
104
+ # Allow sys.path modification before imports in examples
105
+ "examples/**/*.py" = ["E402"]
106
+
107
+ [tool.mypy]
108
+ python_version = "3.11"
109
+ # Relaxed settings - enable stricter checking incrementally
110
+ warn_return_any = false
111
+ warn_unused_configs = true
112
+ ignore_missing_imports = true
113
+ check_untyped_defs = false
114
+ disallow_untyped_defs = false
115
+ # Ignore errors in all modules for now (pre-existing issues)
116
+ # TODO: Enable strict checking and fix type errors
117
+ ignore_errors = true
118
+ exclude = [
119
+ "examples/",
120
+ "tests/",
121
+ ".*/site-packages/.*",
122
+ ]
123
+
93
124
  [dependency-groups]
94
125
  dev = [
95
126
  "bs4>=0.0.2",
@@ -98,6 +129,7 @@ dev = [
98
129
  "geopy>=2.4.1",
99
130
  "openai>=1.88.0",
100
131
  "pytest-asyncio>=1.0.0",
132
+ "pytest-cov>=7.0.0",
101
133
  "tiktoken>=0.9.0",
102
134
  "uvicorn>=0.34.2",
103
- ]
135
+ ]
@@ -4,7 +4,7 @@ CHUK AI Session Manager - Simple Developer API
4
4
 
5
5
  A powerful session management system for AI applications that provides:
6
6
  - Automatic conversation tracking
7
- - Token usage monitoring
7
+ - Token usage monitoring
8
8
  - Tool call logging
9
9
  - Infinite context support with automatic summarization
10
10
  - Hierarchical session relationships
@@ -32,12 +32,12 @@ Infinite Context Example:
32
32
  Storage Configuration:
33
33
  # Default: Memory storage (no Redis required)
34
34
  pip install chuk-ai-session-manager
35
-
35
+
36
36
  # Redis: For production persistence
37
37
  pip install chuk-ai-session-manager[redis]
38
38
  export SESSION_PROVIDER=redis
39
39
  export SESSION_REDIS_URL=redis://localhost:6379/0
40
-
40
+
41
41
  # Environment variables:
42
42
  SESSION_PROVIDER=memory (default - fast, no persistence)
43
43
  SESSION_PROVIDER=redis (persistent - requires [redis] extra)
@@ -46,7 +46,7 @@ Storage Configuration:
46
46
  import logging
47
47
 
48
48
  # Package version
49
- __version__ = "0.5"
49
+ __version__ = "0.8"
50
50
 
51
51
  # Set up package-level logger
52
52
  logger = logging.getLogger(__name__)
@@ -63,7 +63,7 @@ from chuk_ai_session_manager.exceptions import (
63
63
  InvalidSessionOperation,
64
64
  TokenLimitExceeded,
65
65
  StorageError,
66
- ToolProcessingError
66
+ ToolProcessingError,
67
67
  )
68
68
 
69
69
  # Core models
@@ -87,36 +87,66 @@ from chuk_ai_session_manager.api.simple_api import (
87
87
  track_infinite_conversation,
88
88
  track_tool_use,
89
89
  get_session_stats,
90
- get_conversation_history
90
+ get_conversation_history,
91
91
  )
92
92
 
93
93
  # Advanced components
94
94
  from chuk_ai_session_manager.infinite_conversation import (
95
95
  InfiniteConversationManager,
96
- SummarizationStrategy
96
+ SummarizationStrategy,
97
97
  )
98
98
 
99
- from chuk_ai_session_manager.session_aware_tool_processor import SessionAwareToolProcessor
99
+ from chuk_ai_session_manager.session_aware_tool_processor import (
100
+ SessionAwareToolProcessor,
101
+ )
100
102
 
101
103
  from chuk_ai_session_manager.session_prompt_builder import (
102
104
  build_prompt_from_session,
103
105
  PromptStrategy,
104
- truncate_prompt_to_token_limit
106
+ truncate_prompt_to_token_limit,
105
107
  )
106
108
 
109
+ # Procedural memory
110
+ from chuk_ai_session_manager.procedural_memory import (
111
+ ToolMemoryManager,
112
+ ToolOutcome,
113
+ ToolLogEntry,
114
+ ToolPattern,
115
+ ProceduralMemory,
116
+ ProceduralContextFormatter,
117
+ FormatterConfig,
118
+ )
119
+
120
+ # Guards and state management
121
+ from chuk_ai_session_manager.guards import (
122
+ ToolStateManager,
123
+ get_tool_state,
124
+ reset_tool_state,
125
+ BindingManager,
126
+ ResultCache,
127
+ UngroundedGuard,
128
+ UngroundedGuardConfig,
129
+ RuntimeLimits,
130
+ RuntimeMode,
131
+ ValueBinding,
132
+ ToolClassification,
133
+ )
134
+
135
+
107
136
  # Configuration functions
108
- def configure_storage(sandbox_id: str = "chuk-ai-session-manager",
109
- default_ttl_hours: int = 24) -> bool:
137
+ def configure_storage(
138
+ sandbox_id: str = "chuk-ai-session-manager", default_ttl_hours: int = 24
139
+ ) -> bool:
110
140
  """
111
141
  Configure the storage backend.
112
-
142
+
113
143
  Args:
114
144
  sandbox_id: CHUK Sessions sandbox ID to use
115
145
  default_ttl_hours: Default TTL for sessions
116
-
146
+
117
147
  Returns:
118
148
  True if configuration was successful, False otherwise
119
-
149
+
120
150
  Note:
121
151
  Storage provider is controlled by SESSION_PROVIDER environment variable:
122
152
  - memory (default): Fast, no persistence, no extra dependencies
@@ -124,8 +154,7 @@ def configure_storage(sandbox_id: str = "chuk-ai-session-manager",
124
154
  """
125
155
  try:
126
156
  setup_chuk_sessions_storage(
127
- sandbox_id=sandbox_id,
128
- default_ttl_hours=default_ttl_hours
157
+ sandbox_id=sandbox_id, default_ttl_hours=default_ttl_hours
129
158
  )
130
159
  logger.info(f"Storage configured with sandbox_id='{sandbox_id}'")
131
160
  return True
@@ -142,26 +171,28 @@ def get_version() -> str:
142
171
  def is_available() -> dict:
143
172
  """
144
173
  Check which components are available.
145
-
174
+
146
175
  Returns:
147
176
  Dictionary showing availability of each component
148
177
  """
149
178
  # Check if Redis is available
150
179
  redis_available = False
151
180
  try:
152
- import redis
181
+ import redis # noqa: F401
182
+
153
183
  redis_available = True
154
184
  except ImportError:
155
185
  pass
156
-
186
+
157
187
  # Check if tiktoken is available for enhanced token counting
158
188
  tiktoken_available = False
159
189
  try:
160
- import tiktoken
190
+ import tiktoken # noqa: F401
191
+
161
192
  tiktoken_available = True
162
193
  except ImportError:
163
194
  pass
164
-
195
+
165
196
  return {
166
197
  "core_enums": True,
167
198
  "core_models": True,
@@ -181,53 +212,47 @@ def is_available() -> dict:
181
212
  def get_storage_info() -> dict:
182
213
  """
183
214
  Get information about the current storage configuration.
184
-
215
+
185
216
  Returns:
186
217
  Dictionary with storage configuration details
187
218
  """
188
219
  import os
189
220
  from chuk_ai_session_manager.session_storage import get_backend
190
-
221
+
191
222
  try:
192
223
  backend = get_backend()
193
224
  stats = backend.get_stats()
194
-
225
+
195
226
  return {
196
227
  "provider": os.getenv("SESSION_PROVIDER", "memory"),
197
228
  "backend": stats.get("backend", "unknown"),
198
229
  "sandbox_id": stats.get("sandbox_id", "unknown"),
199
230
  "redis_url": os.getenv("SESSION_REDIS_URL", "not_set"),
200
- "stats": stats
231
+ "stats": stats,
201
232
  }
202
233
  except Exception as e:
203
- return {
204
- "provider": os.getenv("SESSION_PROVIDER", "memory"),
205
- "error": str(e)
206
- }
234
+ return {"provider": os.getenv("SESSION_PROVIDER", "memory"), "error": str(e)}
207
235
 
208
236
 
209
237
  # Main exports - everything should be available
210
238
  __all__ = [
211
239
  # Version and utilities
212
240
  "__version__",
213
- "get_version",
241
+ "get_version",
214
242
  "is_available",
215
243
  "configure_storage",
216
244
  "get_storage_info",
217
-
218
245
  # Core enums
219
246
  "EventSource",
220
247
  "EventType",
221
-
222
248
  # Exception classes
223
249
  "SessionManagerError",
224
- "SessionNotFound",
250
+ "SessionNotFound",
225
251
  "SessionAlreadyExists",
226
252
  "InvalidSessionOperation",
227
253
  "TokenLimitExceeded",
228
254
  "StorageError",
229
255
  "ToolProcessingError",
230
-
231
256
  # Core models
232
257
  "Session",
233
258
  "SessionEvent",
@@ -236,20 +261,17 @@ __all__ = [
236
261
  "RunStatus",
237
262
  "TokenUsage",
238
263
  "TokenSummary",
239
-
240
264
  # Storage
241
265
  "setup_chuk_sessions_storage",
242
-
243
266
  # Primary interfaces - what most users will use
244
267
  "SessionManager",
245
- "track_conversation",
268
+ "track_conversation",
246
269
  "track_llm_call",
247
270
  "quick_conversation",
248
271
  "track_infinite_conversation",
249
272
  "track_tool_use",
250
273
  "get_session_stats",
251
274
  "get_conversation_history",
252
-
253
275
  # Advanced components
254
276
  "InfiniteConversationManager",
255
277
  "SummarizationStrategy",
@@ -257,6 +279,26 @@ __all__ = [
257
279
  "build_prompt_from_session",
258
280
  "PromptStrategy",
259
281
  "truncate_prompt_to_token_limit",
282
+ # Procedural memory
283
+ "ToolMemoryManager",
284
+ "ToolOutcome",
285
+ "ToolLogEntry",
286
+ "ToolPattern",
287
+ "ProceduralMemory",
288
+ "ProceduralContextFormatter",
289
+ "FormatterConfig",
290
+ # Guards and state management
291
+ "ToolStateManager",
292
+ "get_tool_state",
293
+ "reset_tool_state",
294
+ "BindingManager",
295
+ "ResultCache",
296
+ "UngroundedGuard",
297
+ "UngroundedGuardConfig",
298
+ "RuntimeLimits",
299
+ "RuntimeMode",
300
+ "ValueBinding",
301
+ "ToolClassification",
260
302
  ]
261
303
 
262
304
  # Auto-setup storage on import
@@ -270,6 +312,8 @@ except Exception as e:
270
312
  try:
271
313
  storage_info = get_storage_info()
272
314
  provider = storage_info.get("provider", "unknown")
273
- logger.debug(f"CHUK AI Session Manager v{__version__} imported successfully (storage: {provider})")
315
+ logger.debug(
316
+ f"CHUK AI Session Manager v{__version__} imported successfully (storage: {provider})"
317
+ )
274
318
  except Exception:
275
- logger.debug(f"CHUK AI Session Manager v{__version__} imported successfully")
319
+ logger.debug(f"CHUK AI Session Manager v{__version__} imported successfully")
@@ -0,0 +1 @@
1
+ # chuk_ai_session_manager/api/__init__.py