alexein-cli 0.3.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.
Files changed (41) hide show
  1. alexein_cli-0.3.0/.gitignore +6 -0
  2. alexein_cli-0.3.0/CHANGELOG.md +28 -0
  3. alexein_cli-0.3.0/LICENSE +21 -0
  4. alexein_cli-0.3.0/PKG-INFO +208 -0
  5. alexein_cli-0.3.0/README.md +183 -0
  6. alexein_cli-0.3.0/pyproject.toml +86 -0
  7. alexein_cli-0.3.0/src/alexein_cli/__init__.py +127 -0
  8. alexein_cli-0.3.0/src/alexein_cli/_version.py +1 -0
  9. alexein_cli-0.3.0/src/alexein_cli/create.py +178 -0
  10. alexein_cli-0.3.0/src/alexein_cli/create_crewai.py +138 -0
  11. alexein_cli-0.3.0/src/alexein_cli/crews.py +120 -0
  12. alexein_cli-0.3.0/src/alexein_cli/doctor.py +182 -0
  13. alexein_cli-0.3.0/src/alexein_cli/env.py +125 -0
  14. alexein_cli-0.3.0/src/alexein_cli/project.py +312 -0
  15. alexein_cli-0.3.0/src/alexein_cli/render.py +40 -0
  16. alexein_cli-0.3.0/src/alexein_cli/scaffold.py +369 -0
  17. alexein_cli-0.3.0/src/alexein_cli/stop.py +12 -0
  18. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/memory.py.tmpl +55 -0
  19. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/README.md.tmpl +29 -0
  20. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/agents.yaml.tmpl +8 -0
  21. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/crew.py.tmpl +43 -0
  22. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/env.example.tmpl +8 -0
  23. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/gitignore.tmpl +3 -0
  24. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/main.py.tmpl +36 -0
  25. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/pyproject.toml.tmpl +20 -0
  26. alexein_cli-0.3.0/src/alexein_cli/templates/crewai/project/tasks.yaml.tmpl +6 -0
  27. alexein_cli-0.3.0/src/alexein_cli/templates/langgraph/memory.py.tmpl +45 -0
  28. alexein_cli-0.3.0/src/alexein_cli/templates/langgraph/project/README.md.tmpl +31 -0
  29. alexein_cli-0.3.0/src/alexein_cli/templates/langgraph/project/chat.py.tmpl +46 -0
  30. alexein_cli-0.3.0/src/alexein_cli/templates/langgraph/project/env.example.tmpl +8 -0
  31. alexein_cli-0.3.0/src/alexein_cli/templates/langgraph/project/graph.py.tmpl +61 -0
  32. alexein_cli-0.3.0/src/alexein_cli/templates/langgraph/project/langgraph.json.tmpl +7 -0
  33. alexein_cli-0.3.0/src/alexein_cli/templates/openai_agents/memory.py.tmpl +47 -0
  34. alexein_cli-0.3.0/src/alexein_cli/templates/openai_agents/project/README.md.tmpl +25 -0
  35. alexein_cli-0.3.0/src/alexein_cli/templates/openai_agents/project/agent.py.tmpl +43 -0
  36. alexein_cli-0.3.0/src/alexein_cli/templates/openai_agents/project/chat.py.tmpl +38 -0
  37. alexein_cli-0.3.0/src/alexein_cli/templates/openai_agents/project/env.example.tmpl +6 -0
  38. alexein_cli-0.3.0/src/alexein_cli/templates/project/gitignore.tmpl +6 -0
  39. alexein_cli-0.3.0/src/alexein_cli/templates/project/pyproject.toml.tmpl +14 -0
  40. alexein_cli-0.3.0/src/alexein_cli/ui.py +75 -0
  41. alexein_cli-0.3.0/src/alexein_cli/wiring.py +61 -0
@@ -0,0 +1,6 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ dist/
5
+ .pytest_cache/
6
+ .ruff_cache/
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 - 2026-11-04
4
+
5
+ Renamed from `twinmemory-cli`: the package is `alexein-cli` (`uvx alexein-cli ...`), the module
6
+ `alexein_cli`. The version follows the API's, as every Alexein package's does.
7
+
8
+ - `init langgraph | openai-agents | crewai` writes a short `memory.py` the developer owns: the
9
+ settings (`FAST`, `STRICT`, `MAX_CHARS`, `TIMEOUT`), one configured `AlexeinMemory`, and the
10
+ names the graph, agent or crew uses - everything else imported from the `alexein` client's
11
+ `alexein.langgraph`, `alexein.openai_agents` and `alexein.crewai`. Importing it needs no key.
12
+ It adds `alexein[<framework>]>=0.3` to the project, with the project's own tool, where the
13
+ project does not depend on it already.
14
+ - One file serves nodes and tools, sync and async: `--async`, `--nodes-only` and `--tools-only`
15
+ are gone. `--fast` stays.
16
+ - LangGraph 1.2 or newer is needed (its runtime carries the thread what is saved belongs to);
17
+ the OpenAI Agents SDK 0.24 or newer.
18
+ - `create langgraph | openai-agents | crewai <name>` makes the same projects as before, on the
19
+ thin file.
20
+ - `doctor` checks `ALEXEIN_API_KEY` and `ALEXEIN_API_URL` in `.env` and the environment, the key
21
+ with `memory.me()`, that the client is a dependency with the framework's extra, and that the
22
+ integration module imports in the project's own Python.
23
+
24
+ ## 0.1.0 - unreleased
25
+
26
+ First release, moved here from the client, where it was its `init` command: `init`, `create` and
27
+ `doctor` for LangGraph, CrewAI and the OpenAI Agents SDK, writing the memory code itself into
28
+ the project.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexein AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.5
2
+ Name: alexein-cli
3
+ Version: 0.3.0
4
+ Summary: Add memory from Alexein to a LangGraph project, a CrewAI crew or an OpenAI Agents SDK agent, as a short file you own: uvx alexein-cli init langgraph | crewai | openai-agents.
5
+ Project-URL: Homepage, https://alexein.ai
6
+ Project-URL: Documentation, https://docs.alexein.ai/integrations/langgraph
7
+ Project-URL: Repository, https://github.com/Alexein-AI/sdk
8
+ Project-URL: Changelog, https://github.com/Alexein-AI/sdk/blob/main/integrations/cli-python/CHANGELOG.md
9
+ Author: Alexein AI
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agents,cli,crewai,langgraph,llm,memory,openai-agents
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3
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: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: alexein>=0.3
24
+ Description-Content-Type: text/markdown
25
+
26
+ # alexein-cli
27
+
28
+ Memory from [Alexein](https://alexein.ai) in a LangGraph project, a CrewAI crew or an OpenAI
29
+ Agents SDK agent, as a short file you own: one command writes `memory.py` - your settings and one
30
+ configured `AlexeinMemory`, wired from the [`alexein`](https://docs.alexein.ai/sdks/python)
31
+ client's integration for your framework - and adds `alexein[<framework>]` to your project.
32
+
33
+ ```bash
34
+ uvx alexein-cli init langgraph # a LangGraph project you have
35
+ uvx alexein-cli init crewai # a crew you have
36
+ uvx alexein-cli init openai-agents # an OpenAI Agents SDK project you have
37
+ uvx alexein-cli create langgraph my-agent # a new one, with memory wired in
38
+ uvx alexein-cli create crewai my-crew
39
+ uvx alexein-cli create openai-agents my-agent
40
+ uvx alexein-cli doctor # is it all set up?
41
+ ```
42
+
43
+ The file is yours: edit the settings, rename things, move it. What it imports - recall, saving,
44
+ the tools, failing open - comes from `alexein.langgraph`, `alexein.openai_agents` or
45
+ `alexein.crewai`, and an upgrade of `alexein` reaches it. Importing it needs no key: the client
46
+ is made on the first call to memory, from `ALEXEIN_API_KEY` and `ALEXEIN_API_URL`.
47
+
48
+ ## `init`
49
+
50
+ Before it writes anything, `init` checks that it is in a Python project, that the project uses
51
+ the framework (it asks before going on in one that does not; `--yes` goes on without asking),
52
+ that what is installed is new enough (LangGraph 1.2, LangChain 1.0, the OpenAI Agents SDK 0.24,
53
+ CrewAI 1.15), and where the file goes: beside the graph `langgraph.json` names (asking when there
54
+ are several, or `--graph NAME`), beside the file that builds your `Agent`, or beside your crew.
55
+ Any of these can stop it, and then nothing has changed. An existing `memory.py` is replaced only
56
+ with `--force`.
57
+
58
+ Then it writes `memory.py`, adds `alexein[langgraph]>=0.3` (or `[openai-agents]`, `[crewai]`)
59
+ where the project does not depend on it with that extra yet - with the project's own tool: uv,
60
+ poetry, pdm, or a line in `requirements.txt` - and sets up the key: `--key tm_...`, or asked for
61
+ at a terminal. Enter skips it, and an empty `ALEXEIN_API_KEY=` waits in `.env`. A key it is given
62
+ is checked, and a key that only reads is called out.
63
+
64
+ | Flag | What it does |
65
+ | ---------------------------- | ------------------------------------------------------------ |
66
+ | `--fast` | `FAST = True`: searches skip the relevance check, free and quicker |
67
+ | `--key`, `--base-url` | the key and memory's address, written into `.env` |
68
+ | `--skip-key` | do not ask for a key |
69
+ | `--dir`, `--file`, `--graph` | where the file goes, and what it is called |
70
+ | `--force` | replace a file already there |
71
+ | `--no-install` | print the install command instead of running it |
72
+ | `--dry-run` | make every check, say what would happen, change nothing |
73
+ | `--yes` | ask nothing |
74
+
75
+ Every file holds the same four settings, at the top:
76
+
77
+ | Setting | Default | What it does |
78
+ | ----------- | ------- | ------------------------------------------------------------------- |
79
+ | `FAST` | `False` | `True` answers sooner and free, a little less precisely |
80
+ | `STRICT` | `False` | `True` raises when memory is down, where by default a turn goes on without it |
81
+ | `MAX_CHARS` | `4000` | how much of what memory holds goes into a prompt |
82
+ | `TIMEOUT` | `10.0` | seconds each attempt at a call may take |
83
+
84
+ A wrong key raises whatever `STRICT` says: that is a mistake to fix, not an outage to ride out.
85
+ Memory being down is logged on the `alexein` logger.
86
+
87
+ ### LangGraph
88
+
89
+ `init langgraph` writes `memory`, with `MemoryState` and `MemoryContext`:
90
+
91
+ ```python
92
+ from app.memory import MemoryContext, MemoryState, memory
93
+
94
+ builder = StateGraph(MemoryState, context_schema=MemoryContext)
95
+ builder.add_node("recall", memory.recall) # what memory holds, into state["memory"]
96
+ builder.add_node("agent", agent) # yours: memory.prompt(state) in its prompt
97
+ builder.add_node("remember", memory.remember) # save the turn
98
+ builder.add_edge(START, "recall")
99
+ builder.add_edge("recall", "agent")
100
+ builder.add_edge("agent", "remember")
101
+ graph = builder.compile()
102
+
103
+ graph.invoke(
104
+ {"messages": [HumanMessage("Where do I live?")]},
105
+ config={"configurable": {"thread_id": "t-1"}},
106
+ context={"user_id": "dana"},
107
+ )
108
+ ```
109
+
110
+ Or give the model tools to call when it decides to:
111
+ `create_agent(model, tools=memory.tools(), context_schema=MemoryContext)` offers `memory_search`
112
+ and `memory_open`; `memory.tools(write=True)` adds `memory_add`. The nodes and tools run under
113
+ `invoke` and `ainvoke`; `memory.arecall` and `memory.aremember` are the nodes' async
114
+ counterparts.
115
+
116
+ Whose memory is read comes from the run's `context`, never from the model. A LangGraph thread is
117
+ a memory session.
118
+
119
+ ### The OpenAI Agents SDK
120
+
121
+ `init openai-agents` writes `memory`, with `MemoryContext`, beside the file that builds your
122
+ `Agent` (asking when there are several, or `--dir`; with none, into the project's package):
123
+
124
+ ```python
125
+ from app.memory import MemoryContext, memory
126
+
127
+ agent = Agent(name="Assistant", tools=memory.tools())
128
+ result = await Runner.run(
129
+ agent,
130
+ "Where do I live?",
131
+ context=MemoryContext(user_id="dana", session_id="conv-7"),
132
+ run_config=RunConfig(call_model_input_filter=memory.recall),
133
+ )
134
+ await memory.remember(result) # for run_streamed, once its events are consumed
135
+ ```
136
+
137
+ `memory.recall` searches once a turn and adds what it finds to the instructions of every model
138
+ call in the turn, so it is never written into a `Session`, the Conversations API or
139
+ `to_input_list()`. Any context with a `user_id` will do.
140
+
141
+ ### CrewAI
142
+
143
+ `init crewai` writes `alexein_memory` - CrewAI's own memory, kept in Alexein - and `whose`,
144
+ beside a classic crew (`@CrewBase` in `src/<pkg>/crew.py`) or a JSON one (`crew.jsonc`). Flows
145
+ are not supported yet.
146
+
147
+ ```python
148
+ from my_crew.memory import alexein_memory, whose
149
+
150
+
151
+ @CrewBase
152
+ class MyCrew:
153
+ memory = alexein_memory
154
+
155
+ @before_kickoff
156
+ def whose_memory(self, inputs):
157
+ return whose(inputs)
158
+
159
+ @crew
160
+ def crew(self) -> Crew:
161
+ return Crew(agents=self.agents, tasks=self.tasks, memory=self.memory)
162
+
163
+
164
+ MyCrew().crew().kickoff(inputs={"user_id": "dana", "topic": "..."})
165
+ ```
166
+
167
+ A JSON crew points `crew.jsonc` at the same two names:
168
+
169
+ ```jsonc
170
+ "memory": {"python": "memory.alexein_memory"},
171
+ "before_kickoff_callbacks": [{"python": "memory.whose"}]
172
+ ```
173
+
174
+ CrewAI then recalls the user's memory before every task, saves what each task learned, and gives
175
+ every agent its memory tools. Every kickoff names its user in `inputs["user_id"]`; the key is
176
+ checked at kickoff, once per process. `whose` is a function in the file rather than
177
+ `alexein_memory.whose` because CrewAI keeps only module-level callbacks when it restores a
178
+ checkpoint. Without CrewAI's memory: `Agent(..., tools=alexein_memory.tools("dana"))`, and
179
+ `alexein_memory.save_result("dana", output)` after the run.
180
+
181
+ ## `create`
182
+
183
+ `create <framework> <name>` makes a uv project with memory wired in, and `memory.py` as `init`
184
+ writes it:
185
+
186
+ - `create langgraph` - a graph that recalls, searches and remembers, a terminal chat
187
+ (`uv run -m <package>.chat --user dana`, where `<package>` is the name in lower case with `-`
188
+ as `_`), and `langgraph.json` for `uv run langgraph dev`. `--model` names the model by
189
+ `init_chat_model`'s name (default `anthropic:claude-sonnet-5-5`), whose LangChain package it
190
+ adds.
191
+ - `create openai-agents` - an agent and a terminal chat. `--model` names the model (`MODEL` in
192
+ `.env`); without it, the SDK's default.
193
+ - `create crewai` - a classic crew with one assistant agent and `uv run run_crew --user dana
194
+ "..."`. `--model` takes CrewAI's `provider/model` name (default `anthropic/claude-sonnet-5-5`)
195
+ and adds the CrewAI extra that provider needs.
196
+
197
+ It takes `init`'s `--fast` and key flags.
198
+
199
+ ## `doctor`
200
+
201
+ Checks the memory file, that `alexein` is a dependency with the framework's extra, the installed
202
+ versions, that the integration module imports in the project's own `.venv`, `ALEXEIN_API_KEY`
203
+ and `ALEXEIN_API_URL` (in `.env` or the environment), the key (with `memory.me()`, which is free)
204
+ and that `.env` is not committed. Each failure says how to fix it.
205
+
206
+ ## License
207
+
208
+ MIT
@@ -0,0 +1,183 @@
1
+ # alexein-cli
2
+
3
+ Memory from [Alexein](https://alexein.ai) in a LangGraph project, a CrewAI crew or an OpenAI
4
+ Agents SDK agent, as a short file you own: one command writes `memory.py` - your settings and one
5
+ configured `AlexeinMemory`, wired from the [`alexein`](https://docs.alexein.ai/sdks/python)
6
+ client's integration for your framework - and adds `alexein[<framework>]` to your project.
7
+
8
+ ```bash
9
+ uvx alexein-cli init langgraph # a LangGraph project you have
10
+ uvx alexein-cli init crewai # a crew you have
11
+ uvx alexein-cli init openai-agents # an OpenAI Agents SDK project you have
12
+ uvx alexein-cli create langgraph my-agent # a new one, with memory wired in
13
+ uvx alexein-cli create crewai my-crew
14
+ uvx alexein-cli create openai-agents my-agent
15
+ uvx alexein-cli doctor # is it all set up?
16
+ ```
17
+
18
+ The file is yours: edit the settings, rename things, move it. What it imports - recall, saving,
19
+ the tools, failing open - comes from `alexein.langgraph`, `alexein.openai_agents` or
20
+ `alexein.crewai`, and an upgrade of `alexein` reaches it. Importing it needs no key: the client
21
+ is made on the first call to memory, from `ALEXEIN_API_KEY` and `ALEXEIN_API_URL`.
22
+
23
+ ## `init`
24
+
25
+ Before it writes anything, `init` checks that it is in a Python project, that the project uses
26
+ the framework (it asks before going on in one that does not; `--yes` goes on without asking),
27
+ that what is installed is new enough (LangGraph 1.2, LangChain 1.0, the OpenAI Agents SDK 0.24,
28
+ CrewAI 1.15), and where the file goes: beside the graph `langgraph.json` names (asking when there
29
+ are several, or `--graph NAME`), beside the file that builds your `Agent`, or beside your crew.
30
+ Any of these can stop it, and then nothing has changed. An existing `memory.py` is replaced only
31
+ with `--force`.
32
+
33
+ Then it writes `memory.py`, adds `alexein[langgraph]>=0.3` (or `[openai-agents]`, `[crewai]`)
34
+ where the project does not depend on it with that extra yet - with the project's own tool: uv,
35
+ poetry, pdm, or a line in `requirements.txt` - and sets up the key: `--key tm_...`, or asked for
36
+ at a terminal. Enter skips it, and an empty `ALEXEIN_API_KEY=` waits in `.env`. A key it is given
37
+ is checked, and a key that only reads is called out.
38
+
39
+ | Flag | What it does |
40
+ | ---------------------------- | ------------------------------------------------------------ |
41
+ | `--fast` | `FAST = True`: searches skip the relevance check, free and quicker |
42
+ | `--key`, `--base-url` | the key and memory's address, written into `.env` |
43
+ | `--skip-key` | do not ask for a key |
44
+ | `--dir`, `--file`, `--graph` | where the file goes, and what it is called |
45
+ | `--force` | replace a file already there |
46
+ | `--no-install` | print the install command instead of running it |
47
+ | `--dry-run` | make every check, say what would happen, change nothing |
48
+ | `--yes` | ask nothing |
49
+
50
+ Every file holds the same four settings, at the top:
51
+
52
+ | Setting | Default | What it does |
53
+ | ----------- | ------- | ------------------------------------------------------------------- |
54
+ | `FAST` | `False` | `True` answers sooner and free, a little less precisely |
55
+ | `STRICT` | `False` | `True` raises when memory is down, where by default a turn goes on without it |
56
+ | `MAX_CHARS` | `4000` | how much of what memory holds goes into a prompt |
57
+ | `TIMEOUT` | `10.0` | seconds each attempt at a call may take |
58
+
59
+ A wrong key raises whatever `STRICT` says: that is a mistake to fix, not an outage to ride out.
60
+ Memory being down is logged on the `alexein` logger.
61
+
62
+ ### LangGraph
63
+
64
+ `init langgraph` writes `memory`, with `MemoryState` and `MemoryContext`:
65
+
66
+ ```python
67
+ from app.memory import MemoryContext, MemoryState, memory
68
+
69
+ builder = StateGraph(MemoryState, context_schema=MemoryContext)
70
+ builder.add_node("recall", memory.recall) # what memory holds, into state["memory"]
71
+ builder.add_node("agent", agent) # yours: memory.prompt(state) in its prompt
72
+ builder.add_node("remember", memory.remember) # save the turn
73
+ builder.add_edge(START, "recall")
74
+ builder.add_edge("recall", "agent")
75
+ builder.add_edge("agent", "remember")
76
+ graph = builder.compile()
77
+
78
+ graph.invoke(
79
+ {"messages": [HumanMessage("Where do I live?")]},
80
+ config={"configurable": {"thread_id": "t-1"}},
81
+ context={"user_id": "dana"},
82
+ )
83
+ ```
84
+
85
+ Or give the model tools to call when it decides to:
86
+ `create_agent(model, tools=memory.tools(), context_schema=MemoryContext)` offers `memory_search`
87
+ and `memory_open`; `memory.tools(write=True)` adds `memory_add`. The nodes and tools run under
88
+ `invoke` and `ainvoke`; `memory.arecall` and `memory.aremember` are the nodes' async
89
+ counterparts.
90
+
91
+ Whose memory is read comes from the run's `context`, never from the model. A LangGraph thread is
92
+ a memory session.
93
+
94
+ ### The OpenAI Agents SDK
95
+
96
+ `init openai-agents` writes `memory`, with `MemoryContext`, beside the file that builds your
97
+ `Agent` (asking when there are several, or `--dir`; with none, into the project's package):
98
+
99
+ ```python
100
+ from app.memory import MemoryContext, memory
101
+
102
+ agent = Agent(name="Assistant", tools=memory.tools())
103
+ result = await Runner.run(
104
+ agent,
105
+ "Where do I live?",
106
+ context=MemoryContext(user_id="dana", session_id="conv-7"),
107
+ run_config=RunConfig(call_model_input_filter=memory.recall),
108
+ )
109
+ await memory.remember(result) # for run_streamed, once its events are consumed
110
+ ```
111
+
112
+ `memory.recall` searches once a turn and adds what it finds to the instructions of every model
113
+ call in the turn, so it is never written into a `Session`, the Conversations API or
114
+ `to_input_list()`. Any context with a `user_id` will do.
115
+
116
+ ### CrewAI
117
+
118
+ `init crewai` writes `alexein_memory` - CrewAI's own memory, kept in Alexein - and `whose`,
119
+ beside a classic crew (`@CrewBase` in `src/<pkg>/crew.py`) or a JSON one (`crew.jsonc`). Flows
120
+ are not supported yet.
121
+
122
+ ```python
123
+ from my_crew.memory import alexein_memory, whose
124
+
125
+
126
+ @CrewBase
127
+ class MyCrew:
128
+ memory = alexein_memory
129
+
130
+ @before_kickoff
131
+ def whose_memory(self, inputs):
132
+ return whose(inputs)
133
+
134
+ @crew
135
+ def crew(self) -> Crew:
136
+ return Crew(agents=self.agents, tasks=self.tasks, memory=self.memory)
137
+
138
+
139
+ MyCrew().crew().kickoff(inputs={"user_id": "dana", "topic": "..."})
140
+ ```
141
+
142
+ A JSON crew points `crew.jsonc` at the same two names:
143
+
144
+ ```jsonc
145
+ "memory": {"python": "memory.alexein_memory"},
146
+ "before_kickoff_callbacks": [{"python": "memory.whose"}]
147
+ ```
148
+
149
+ CrewAI then recalls the user's memory before every task, saves what each task learned, and gives
150
+ every agent its memory tools. Every kickoff names its user in `inputs["user_id"]`; the key is
151
+ checked at kickoff, once per process. `whose` is a function in the file rather than
152
+ `alexein_memory.whose` because CrewAI keeps only module-level callbacks when it restores a
153
+ checkpoint. Without CrewAI's memory: `Agent(..., tools=alexein_memory.tools("dana"))`, and
154
+ `alexein_memory.save_result("dana", output)` after the run.
155
+
156
+ ## `create`
157
+
158
+ `create <framework> <name>` makes a uv project with memory wired in, and `memory.py` as `init`
159
+ writes it:
160
+
161
+ - `create langgraph` - a graph that recalls, searches and remembers, a terminal chat
162
+ (`uv run -m <package>.chat --user dana`, where `<package>` is the name in lower case with `-`
163
+ as `_`), and `langgraph.json` for `uv run langgraph dev`. `--model` names the model by
164
+ `init_chat_model`'s name (default `anthropic:claude-sonnet-5-5`), whose LangChain package it
165
+ adds.
166
+ - `create openai-agents` - an agent and a terminal chat. `--model` names the model (`MODEL` in
167
+ `.env`); without it, the SDK's default.
168
+ - `create crewai` - a classic crew with one assistant agent and `uv run run_crew --user dana
169
+ "..."`. `--model` takes CrewAI's `provider/model` name (default `anthropic/claude-sonnet-5-5`)
170
+ and adds the CrewAI extra that provider needs.
171
+
172
+ It takes `init`'s `--fast` and key flags.
173
+
174
+ ## `doctor`
175
+
176
+ Checks the memory file, that `alexein` is a dependency with the framework's extra, the installed
177
+ versions, that the integration module imports in the project's own `.venv`, `ALEXEIN_API_KEY`
178
+ and `ALEXEIN_API_URL` (in `.env` or the environment), the key (with `memory.me()`, which is free)
179
+ and that `.env` is not committed. Each failure says how to fix it.
180
+
181
+ ## License
182
+
183
+ MIT
@@ -0,0 +1,86 @@
1
+ [project]
2
+ name = "alexein-cli"
3
+ version = "0.3.0"
4
+ description = "Add memory from Alexein to a LangGraph project, a CrewAI crew or an OpenAI Agents SDK agent, as a short file you own: uvx alexein-cli init langgraph | crewai | openai-agents."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ authors = [{ name = "Alexein AI" }]
10
+ keywords = ["memory", "llm", "agents", "langgraph", "crewai", "openai-agents", "cli"]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Environment :: Console",
14
+ "Intended Audience :: Developers",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Typing :: Typed",
21
+ ]
22
+ # The client, for the key's check; everything else is the standard library. The CLI never
23
+ # imports a framework: the files it writes do, through the client's extras.
24
+ dependencies = ["alexein>=0.3"]
25
+
26
+ [project.scripts]
27
+ alexein-cli = "alexein_cli:main"
28
+
29
+ [project.urls]
30
+ Homepage = "https://alexein.ai"
31
+ Documentation = "https://docs.alexein.ai/integrations/langgraph"
32
+ Repository = "https://github.com/Alexein-AI/sdk"
33
+ Changelog = "https://github.com/Alexein-AI/sdk/blob/main/integrations/cli-python/CHANGELOG.md"
34
+
35
+ [dependency-groups]
36
+ # The frameworks only to run the written files in tests; the CLI never imports them. CrewAI 1.15
37
+ # needs openai<3 and the OpenAI Agents SDK since 0.21 needs openai>=3, so the two are groups that
38
+ # never share an environment: CI runs the tests once with each (`--group crewai`, `--group
39
+ # openai-agents`). The SDK's 0.24 for its scripted model, `agents.testing`.
40
+ dev = ["pytest>=8", "anyio>=4", "ruff>=0.6", "pyright>=1.1.380", "langgraph>=1", "langchain>=1"]
41
+ crewai = ["crewai>=1.15,<1.16"]
42
+ openai-agents = ["openai-agents>=0.24"]
43
+
44
+ [tool.uv]
45
+ default-groups = ["dev", "crewai"]
46
+ conflicts = [[{ group = "crewai" }, { group = "openai-agents" }]]
47
+ # CrewAI (a dev dependency, for the tests) pulls in onnxruntime, whose releases after
48
+ # 1.23 have no wheel for Python 3.10 on Linux, so CI's 3.10 job could not install.
49
+ constraint-dependencies = ["onnxruntime<1.24; python_version < '3.11'"]
50
+
51
+ # The client from this repository while developing, so the CLI is tested against the alexein
52
+ # it ships beside. A published build depends on alexein from PyPI, as `dependencies` says.
53
+ [tool.uv.sources]
54
+ alexein = { path = "../../python", editable = true }
55
+
56
+ [build-system]
57
+ requires = ["hatchling>=1.26"]
58
+ build-backend = "hatchling.build"
59
+
60
+ [tool.hatch.build.targets.wheel]
61
+ packages = ["src/alexein_cli"]
62
+
63
+ # The source distribution holds what the wheel is built from and the pages a user reads: no
64
+ # tests, lock file or CONTRIBUTING.md. pyproject.toml and PKG-INFO are always added.
65
+ [tool.hatch.build.targets.sdist]
66
+ include = ["/src/alexein_cli", "/README.md", "/CHANGELOG.md", "/LICENSE"]
67
+
68
+ [tool.ruff]
69
+ line-length = 100
70
+ target-version = "py310"
71
+
72
+ [tool.ruff.lint]
73
+ select = ["E", "F", "I", "B", "UP", "SIM", "RUF"]
74
+
75
+ [tool.ruff.lint.isort]
76
+ known-first-party = ["alexein_cli"]
77
+
78
+ [tool.pyright]
79
+ include = ["src", "tests"]
80
+ pythonVersion = "3.10"
81
+ strict = ["src"]
82
+
83
+ [tool.pytest.ini_options]
84
+ testpaths = ["tests"]
85
+ # The frameworks' own deprecations are theirs, not this package's.
86
+ filterwarnings = ["ignore::DeprecationWarning"]
@@ -0,0 +1,127 @@
1
+ """`alexein-cli`, in the manner of shadcn: what it writes is the developer's own code from
2
+ then on - a short `memory.py` with their settings and one configured `AlexeinMemory`, wired
3
+ from the `alexein` client's integration modules - and nothing in this package reaches back
4
+ into it.
5
+
6
+ alexein-cli init langgraph memory for a LangGraph project you have
7
+ alexein-cli init openai-agents ... or an OpenAI Agents SDK one
8
+ alexein-cli init crewai ... or a CrewAI crew
9
+ alexein-cli create <framework> X a new project with memory wired in
10
+ alexein-cli doctor whether a project is set up for memory
11
+
12
+ The standard library and the `alexein` client only; it never imports a framework. Never an
13
+ installer of anything but the package the written files import, and never a writer of a key it
14
+ was not given.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import argparse
20
+ import sys
21
+ from collections.abc import Sequence
22
+ from pathlib import Path
23
+
24
+ # The modules, not their functions: `create` and `doctor` are names of both, and binding the
25
+ # function here would hide the module of the same name from `alexein_cli.create`.
26
+ from alexein_cli import create as creating
27
+ from alexein_cli import create_crewai
28
+ from alexein_cli import doctor as checking
29
+ from alexein_cli._version import __version__
30
+ from alexein_cli.scaffold import MINIMUMS, Options, init
31
+ from alexein_cli.ui import Console
32
+
33
+
34
+ def _setup_flags(parser: argparse.ArgumentParser) -> None:
35
+ """What `init` and `create` share: the one preset, the key, and how far to go unasked."""
36
+ parser.add_argument(
37
+ "--fast",
38
+ action="store_true",
39
+ help="FAST = True: searches skip the relevance check, free and quicker",
40
+ )
41
+ key = parser.add_argument_group("the key (all of it can be skipped, and done later)")
42
+ key.add_argument("--key", help="your API key, written into .env and checked")
43
+ key.add_argument("--base-url", help="memory's address, written into .env")
44
+ key.add_argument("--skip-key", action="store_true", help="do not ask for a key")
45
+ parser.add_argument("--yes", "-y", action="store_true", help="answer yes; ask nothing")
46
+ parser.add_argument(
47
+ "--dry-run",
48
+ action="store_true",
49
+ help="check everything, say what would happen, change nothing",
50
+ )
51
+ parser.add_argument(
52
+ "--no-install", action="store_true", help="print install commands instead of running them"
53
+ )
54
+ # Installs the client from a checkout's path or a URL instead of PyPI.
55
+ parser.add_argument("--sdk", help=argparse.SUPPRESS)
56
+
57
+
58
+ def _parser() -> argparse.ArgumentParser:
59
+ parser = argparse.ArgumentParser(
60
+ prog="alexein-cli",
61
+ description="Memory from Alexein for LangGraph, CrewAI and the OpenAI Agents SDK, "
62
+ "as code you own.",
63
+ )
64
+ parser.add_argument("--version", action="version", version=f"alexein-cli {__version__}")
65
+ commands = parser.add_subparsers(dest="command", required=True)
66
+
67
+ start = commands.add_parser("init", help="write memory into this project, as code you own")
68
+ start.add_argument("framework", help="langgraph, openai-agents or crewai")
69
+ start.add_argument("--dir", type=Path, help="where to write the file (default: found)")
70
+ start.add_argument("--file", default="memory.py", help="the file's name (default: memory.py)")
71
+ start.add_argument("--graph", help="which graph in langgraph.json it is for (langgraph)")
72
+ start.add_argument("--force", action="store_true", help="replace a file already there")
73
+ _setup_flags(start)
74
+
75
+ new = commands.add_parser("create", help="a new project with memory wired in")
76
+ new.add_argument("framework", help="langgraph, openai-agents or crewai")
77
+ new.add_argument("name", help="the project's directory and name")
78
+ new.add_argument(
79
+ "--model",
80
+ help=(
81
+ f"the model, as the framework names it (LangGraph: {creating.DEFAULT_MODEL}; "
82
+ f"CrewAI: {create_crewai.DEFAULT_MODEL}; the OpenAI Agents SDK: its own default)"
83
+ ),
84
+ )
85
+ _setup_flags(new)
86
+
87
+ commands.add_parser("doctor", help="check that this project is set up for memory")
88
+ return parser
89
+
90
+
91
+ def _options(args: argparse.Namespace) -> Options:
92
+ return Options(
93
+ framework=args.framework,
94
+ directory=getattr(args, "dir", None),
95
+ filename=getattr(args, "file", "memory.py"),
96
+ graph=getattr(args, "graph", None),
97
+ force=getattr(args, "force", False),
98
+ install=not args.no_install,
99
+ fast=args.fast,
100
+ key=args.key,
101
+ base_url=args.base_url,
102
+ skip_key=args.skip_key or args.yes,
103
+ sdk=args.sdk,
104
+ dry_run=args.dry_run,
105
+ )
106
+
107
+
108
+ def main(argv: Sequence[str] | None = None, console: Console | None = None) -> int:
109
+ args = _parser().parse_args(argv)
110
+ cwd = Path.cwd()
111
+ if args.command == "doctor":
112
+ return checking.doctor(cwd, console or Console.for_terminal(yes=True))
113
+ console = console or Console.for_terminal(yes=args.yes)
114
+ if args.command == "create":
115
+ if args.framework not in MINIMUMS:
116
+ console.fail(f"no template for {args.framework!r}; there is: {', '.join(MINIMUMS)}")
117
+ return 2
118
+ if args.framework == "crewai":
119
+ model = args.model or create_crewai.DEFAULT_MODEL
120
+ return create_crewai.create(args.name, cwd, model, _options(args), console)
121
+ model = args.model or (creating.DEFAULT_MODEL if args.framework == "langgraph" else "")
122
+ return creating.create(args.name, cwd, model, _options(args), console)
123
+ return init(cwd, _options(args), console)
124
+
125
+
126
+ if __name__ == "__main__":
127
+ sys.exit(main())
@@ -0,0 +1 @@
1
+ __version__ = "0.3.0"