hippocortex 1.0.0__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.
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: hippocortex
3
+ Version: 1.0.0
4
+ Summary: Official Hippocortex Python SDK — AI agent memory that learns from experience
5
+ Author-email: Hippocortex <dev@hippocortex.dev>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://hippocortex.dev
8
+ Project-URL: Documentation, https://docs.hippocortex.dev
9
+ Project-URL: Repository, https://github.com/hippocortex/hippocortex-os
10
+ Project-URL: Bug Tracker, https://github.com/hippocortex/hippocortex-os/issues
11
+ Project-URL: Changelog, https://github.com/hippocortex/hippocortex-os/blob/main/CHANGELOG.md
12
+ Keywords: hippocortex,ai,memory,agents,llm,rag
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: httpx>=0.24.0
25
+ Provides-Extra: openai-agents
26
+ Requires-Dist: openai-agents>=0.1.0; extra == "openai-agents"
27
+ Provides-Extra: langgraph
28
+ Requires-Dist: langgraph>=0.2.0; extra == "langgraph"
29
+ Provides-Extra: crewai
30
+ Requires-Dist: crewai>=0.50.0; extra == "crewai"
31
+ Provides-Extra: autogen
32
+ Requires-Dist: pyautogen>=0.2.0; extra == "autogen"
33
+ Provides-Extra: all
34
+ Requires-Dist: openai-agents>=0.1.0; extra == "all"
35
+ Requires-Dist: langgraph>=0.2.0; extra == "all"
36
+ Requires-Dist: crewai>=0.50.0; extra == "all"
37
+ Requires-Dist: pyautogen>=0.2.0; extra == "all"
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=7.0; extra == "dev"
40
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
41
+ Requires-Dist: respx>=0.21; extra == "dev"
42
+
43
+ # hippocortex
44
+
45
+ Official Python SDK for [Hippocortex](https://hippocortex.dev) — AI agent memory that learns from experience.
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pip install hippocortex
51
+
52
+ # With adapter support:
53
+ pip install hippocortex[openai-agents] # OpenAI Agents SDK
54
+ pip install hippocortex[langgraph] # LangGraph
55
+ pip install hippocortex[crewai] # CrewAI
56
+ pip install hippocortex[autogen] # AutoGen
57
+ pip install hippocortex[all] # All adapters
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ### Direct Client Usage
63
+
64
+ ```python
65
+ import asyncio
66
+ from hippocortex import Hippocortex
67
+ from hippocortex.types import CaptureEvent
68
+
69
+ async def main():
70
+ hx = Hippocortex(api_key="hx_live_...")
71
+
72
+ # 1. Capture agent events
73
+ await hx.capture(CaptureEvent(
74
+ type="message",
75
+ session_id="sess-1",
76
+ payload={"role": "user", "content": "Deploy payment service to staging"}
77
+ ))
78
+
79
+ # 2. Learn from experience
80
+ await hx.learn()
81
+
82
+ # 3. Synthesize context for decisions
83
+ ctx = await hx.synthesize("deploy payment service")
84
+ for entry in ctx.entries:
85
+ print(f"[{entry.section}] {entry.content}")
86
+
87
+ asyncio.run(main())
88
+ ```
89
+
90
+ ### Synchronous Client
91
+
92
+ ```python
93
+ from hippocortex import SyncHippocortex
94
+ from hippocortex.types import CaptureEvent
95
+
96
+ hx = SyncHippocortex(api_key="hx_live_...")
97
+
98
+ result = hx.capture(CaptureEvent(
99
+ type="message",
100
+ session_id="sess-1",
101
+ payload={"role": "user", "content": "Hello"}
102
+ ))
103
+ print(result.event_id)
104
+ ```
105
+
106
+ ## Auto-Memory Adapters
107
+
108
+ Wrap your agents with **one line** to get automatic memory capture and context injection.
109
+
110
+ ### OpenAI Agents SDK
111
+
112
+ ```python
113
+ from agents import Agent, Runner
114
+ from hippocortex import auto_memory
115
+
116
+ agent = Agent(name="assistant", instructions="You are helpful.")
117
+ agent = auto_memory(agent, api_key="hx_live_...")
118
+
119
+ # Or with env var HIPPOCORTEX_API_KEY:
120
+ agent = auto_memory(agent)
121
+
122
+ result = await Runner.run(agent, "Deploy to staging")
123
+ ```
124
+
125
+ The adapter automatically:
126
+ - Synthesizes past context before each run (injected into instructions)
127
+ - Captures user messages, assistant responses, and tool calls
128
+ - Gracefully degrades if the server is unreachable
129
+
130
+ ### LangGraph
131
+
132
+ ```python
133
+ from hippocortex.adapters import langgraph as hx_langgraph
134
+
135
+ # Wrap a compiled LangGraph
136
+ graph = builder.compile()
137
+ graph = hx_langgraph.wrap(graph, api_key="hx_live_...")
138
+
139
+ # Use normally — memory is automatic
140
+ result = await graph.ainvoke({"messages": [{"role": "user", "content": "deploy"}]})
141
+ ```
142
+
143
+ Supports `ainvoke`, `invoke`, and `astream`.
144
+
145
+ ### CrewAI (Beta)
146
+
147
+ ```python
148
+ from hippocortex.adapters import crewai as hx_crewai
149
+
150
+ crew = hx_crewai.wrap(crew, api_key="hx_live_...")
151
+ result = crew.kickoff()
152
+ ```
153
+
154
+ Injects memory context into agent backstories and captures task results.
155
+
156
+ ### AutoGen (Beta)
157
+
158
+ ```python
159
+ from hippocortex.adapters import autogen as hx_autogen
160
+
161
+ agent = hx_autogen.wrap(agent, api_key="hx_live_...")
162
+ agent.initiate_chat(other_agent, message="Hello")
163
+ ```
164
+
165
+ Captures messages and injects synthesized context via reply hooks.
166
+
167
+ ### OpenClaw
168
+
169
+ ```python
170
+ from hippocortex.adapters import openclaw as hx_openclaw
171
+
172
+ middleware = hx_openclaw.create_middleware(api_key="hx_live_...")
173
+
174
+ # On incoming message:
175
+ context = await middleware.on_message("Deploy the service")
176
+ # context = "# Hippocortex Memory Context\n..."
177
+
178
+ # After generating response:
179
+ await middleware.on_response("Deployment complete!")
180
+ ```
181
+
182
+ ## Configuration
183
+
184
+ All adapters support:
185
+
186
+ | Option | Env Var | Default | Description |
187
+ |--------|---------|---------|-------------|
188
+ | `api_key` | `HIPPOCORTEX_API_KEY` | (required) | API key |
189
+ | `base_url` | `HIPPOCORTEX_BASE_URL` | `https://api.hippocortex.dev/v1` | API URL |
190
+ | `session_id` | — | auto-generated | Session ID |
191
+
192
+ ## Key Behaviors
193
+
194
+ - **Fire-and-forget capture**: Capture calls never block the agent
195
+ - **Error swallowing**: All Hippocortex errors are logged and swallowed — your agent never crashes because of memory
196
+ - **Graceful degradation**: If the server is unreachable, adapters return empty context and continue
197
+ - **Session tracking**: Auto-generated session IDs link related events
198
+
199
+ ## API Reference
200
+
201
+ ### `Hippocortex(api_key, base_url?, timeout?)`
202
+
203
+ Async client. Use with `await`.
204
+
205
+ - `capture(event)` → `CaptureResult`
206
+ - `capture_batch(events)` → `BatchCaptureResult`
207
+ - `learn(options?)` → `LearnResult`
208
+ - `synthesize(query, options?)` → `SynthesizeResult`
209
+ - `list_artifacts(...)` → `ArtifactListResult`
210
+ - `get_artifact(id)` → `Artifact`
211
+ - `get_metrics(...)` → `MetricsResult`
212
+
213
+ ### `SyncHippocortex(api_key, base_url?, timeout?)`
214
+
215
+ Synchronous client. Same methods, no `await` needed.
216
+
217
+ ## License
218
+
219
+ MIT
@@ -0,0 +1,177 @@
1
+ # hippocortex
2
+
3
+ Official Python SDK for [Hippocortex](https://hippocortex.dev) — AI agent memory that learns from experience.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install hippocortex
9
+
10
+ # With adapter support:
11
+ pip install hippocortex[openai-agents] # OpenAI Agents SDK
12
+ pip install hippocortex[langgraph] # LangGraph
13
+ pip install hippocortex[crewai] # CrewAI
14
+ pip install hippocortex[autogen] # AutoGen
15
+ pip install hippocortex[all] # All adapters
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ### Direct Client Usage
21
+
22
+ ```python
23
+ import asyncio
24
+ from hippocortex import Hippocortex
25
+ from hippocortex.types import CaptureEvent
26
+
27
+ async def main():
28
+ hx = Hippocortex(api_key="hx_live_...")
29
+
30
+ # 1. Capture agent events
31
+ await hx.capture(CaptureEvent(
32
+ type="message",
33
+ session_id="sess-1",
34
+ payload={"role": "user", "content": "Deploy payment service to staging"}
35
+ ))
36
+
37
+ # 2. Learn from experience
38
+ await hx.learn()
39
+
40
+ # 3. Synthesize context for decisions
41
+ ctx = await hx.synthesize("deploy payment service")
42
+ for entry in ctx.entries:
43
+ print(f"[{entry.section}] {entry.content}")
44
+
45
+ asyncio.run(main())
46
+ ```
47
+
48
+ ### Synchronous Client
49
+
50
+ ```python
51
+ from hippocortex import SyncHippocortex
52
+ from hippocortex.types import CaptureEvent
53
+
54
+ hx = SyncHippocortex(api_key="hx_live_...")
55
+
56
+ result = hx.capture(CaptureEvent(
57
+ type="message",
58
+ session_id="sess-1",
59
+ payload={"role": "user", "content": "Hello"}
60
+ ))
61
+ print(result.event_id)
62
+ ```
63
+
64
+ ## Auto-Memory Adapters
65
+
66
+ Wrap your agents with **one line** to get automatic memory capture and context injection.
67
+
68
+ ### OpenAI Agents SDK
69
+
70
+ ```python
71
+ from agents import Agent, Runner
72
+ from hippocortex import auto_memory
73
+
74
+ agent = Agent(name="assistant", instructions="You are helpful.")
75
+ agent = auto_memory(agent, api_key="hx_live_...")
76
+
77
+ # Or with env var HIPPOCORTEX_API_KEY:
78
+ agent = auto_memory(agent)
79
+
80
+ result = await Runner.run(agent, "Deploy to staging")
81
+ ```
82
+
83
+ The adapter automatically:
84
+ - Synthesizes past context before each run (injected into instructions)
85
+ - Captures user messages, assistant responses, and tool calls
86
+ - Gracefully degrades if the server is unreachable
87
+
88
+ ### LangGraph
89
+
90
+ ```python
91
+ from hippocortex.adapters import langgraph as hx_langgraph
92
+
93
+ # Wrap a compiled LangGraph
94
+ graph = builder.compile()
95
+ graph = hx_langgraph.wrap(graph, api_key="hx_live_...")
96
+
97
+ # Use normally — memory is automatic
98
+ result = await graph.ainvoke({"messages": [{"role": "user", "content": "deploy"}]})
99
+ ```
100
+
101
+ Supports `ainvoke`, `invoke`, and `astream`.
102
+
103
+ ### CrewAI (Beta)
104
+
105
+ ```python
106
+ from hippocortex.adapters import crewai as hx_crewai
107
+
108
+ crew = hx_crewai.wrap(crew, api_key="hx_live_...")
109
+ result = crew.kickoff()
110
+ ```
111
+
112
+ Injects memory context into agent backstories and captures task results.
113
+
114
+ ### AutoGen (Beta)
115
+
116
+ ```python
117
+ from hippocortex.adapters import autogen as hx_autogen
118
+
119
+ agent = hx_autogen.wrap(agent, api_key="hx_live_...")
120
+ agent.initiate_chat(other_agent, message="Hello")
121
+ ```
122
+
123
+ Captures messages and injects synthesized context via reply hooks.
124
+
125
+ ### OpenClaw
126
+
127
+ ```python
128
+ from hippocortex.adapters import openclaw as hx_openclaw
129
+
130
+ middleware = hx_openclaw.create_middleware(api_key="hx_live_...")
131
+
132
+ # On incoming message:
133
+ context = await middleware.on_message("Deploy the service")
134
+ # context = "# Hippocortex Memory Context\n..."
135
+
136
+ # After generating response:
137
+ await middleware.on_response("Deployment complete!")
138
+ ```
139
+
140
+ ## Configuration
141
+
142
+ All adapters support:
143
+
144
+ | Option | Env Var | Default | Description |
145
+ |--------|---------|---------|-------------|
146
+ | `api_key` | `HIPPOCORTEX_API_KEY` | (required) | API key |
147
+ | `base_url` | `HIPPOCORTEX_BASE_URL` | `https://api.hippocortex.dev/v1` | API URL |
148
+ | `session_id` | — | auto-generated | Session ID |
149
+
150
+ ## Key Behaviors
151
+
152
+ - **Fire-and-forget capture**: Capture calls never block the agent
153
+ - **Error swallowing**: All Hippocortex errors are logged and swallowed — your agent never crashes because of memory
154
+ - **Graceful degradation**: If the server is unreachable, adapters return empty context and continue
155
+ - **Session tracking**: Auto-generated session IDs link related events
156
+
157
+ ## API Reference
158
+
159
+ ### `Hippocortex(api_key, base_url?, timeout?)`
160
+
161
+ Async client. Use with `await`.
162
+
163
+ - `capture(event)` → `CaptureResult`
164
+ - `capture_batch(events)` → `BatchCaptureResult`
165
+ - `learn(options?)` → `LearnResult`
166
+ - `synthesize(query, options?)` → `SynthesizeResult`
167
+ - `list_artifacts(...)` → `ArtifactListResult`
168
+ - `get_artifact(id)` → `Artifact`
169
+ - `get_metrics(...)` → `MetricsResult`
170
+
171
+ ### `SyncHippocortex(api_key, base_url?, timeout?)`
172
+
173
+ Synchronous client. Same methods, no `await` needed.
174
+
175
+ ## License
176
+
177
+ MIT
@@ -0,0 +1,79 @@
1
+ """Hippocortex — AI agent memory that learns from experience.
2
+
3
+ Usage::
4
+
5
+ from hippocortex import Hippocortex, auto_memory
6
+
7
+ # Direct client usage
8
+ hx = Hippocortex(api_key="hx_live_...")
9
+
10
+ # One-line auto-memory for OpenAI Agents
11
+ agent = auto_memory(agent, api_key="hx_live_...")
12
+ """
13
+
14
+ from .client import Hippocortex, HippocortexError, SyncHippocortex
15
+ from .types import (
16
+ Artifact,
17
+ ArtifactListResult,
18
+ ArtifactStatus,
19
+ ArtifactType,
20
+ BatchCaptureResult,
21
+ CaptureEvent,
22
+ CaptureEventType,
23
+ CaptureResult,
24
+ LearnOptions,
25
+ LearnResult,
26
+ MetricsResult,
27
+ ProvenanceRef,
28
+ ReasoningSection,
29
+ SynthesisEntry,
30
+ SynthesizeBudget,
31
+ SynthesizeOptions,
32
+ SynthesizeResult,
33
+ )
34
+
35
+
36
+ def auto_memory(agent, api_key=None, base_url=None, session_id=None, **kwargs):
37
+ """One-line auto-memory wrapper for OpenAI Agents SDK.
38
+
39
+ Wraps an agent to automatically capture events and inject synthesized
40
+ context from Hippocortex memory.
41
+
42
+ Args:
43
+ agent: An OpenAI Agents SDK ``Agent`` instance.
44
+ api_key: Hippocortex API key. Falls back to ``HIPPOCORTEX_API_KEY`` env var.
45
+ base_url: API base URL override.
46
+ session_id: Explicit session ID (auto-generated if omitted).
47
+ **kwargs: Passed to the OpenAI adapter.
48
+
49
+ Returns:
50
+ The wrapped agent (same type, with memory hooks attached).
51
+ """
52
+ from .adapters.openai_agents import wrap
53
+
54
+ return wrap(agent, api_key=api_key, base_url=base_url, session_id=session_id, **kwargs)
55
+
56
+
57
+ __all__ = [
58
+ "Hippocortex",
59
+ "HippocortexError",
60
+ "SyncHippocortex",
61
+ "auto_memory",
62
+ "Artifact",
63
+ "ArtifactListResult",
64
+ "ArtifactStatus",
65
+ "ArtifactType",
66
+ "BatchCaptureResult",
67
+ "CaptureEvent",
68
+ "CaptureEventType",
69
+ "CaptureResult",
70
+ "LearnOptions",
71
+ "LearnResult",
72
+ "MetricsResult",
73
+ "ProvenanceRef",
74
+ "ReasoningSection",
75
+ "SynthesisEntry",
76
+ "SynthesizeBudget",
77
+ "SynthesizeOptions",
78
+ "SynthesizeResult",
79
+ ]
@@ -0,0 +1,17 @@
1
+ """Hippocortex adapters — auto-memory for popular agent frameworks.
2
+
3
+ Available adapters:
4
+ - ``openai_agents`` — OpenAI Agents SDK
5
+ - ``langgraph`` — LangGraph
6
+ - ``crewai`` — CrewAI
7
+ - ``autogen`` — AutoGen
8
+ - ``openclaw`` — OpenClaw
9
+ """
10
+
11
+ __all__ = [
12
+ "openai_agents",
13
+ "langgraph",
14
+ "crewai",
15
+ "autogen",
16
+ "openclaw",
17
+ ]