iranti 0.3.3 → 0.3.5
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.
- package/README.md +877 -877
- package/bin/iranti.js +1 -1
- package/dist/scripts/claude-code-memory-hook.js +11 -1
- package/dist/scripts/iranti-cli.js +453 -0
- package/dist/scripts/iranti-mcp.js +74 -74
- package/dist/src/api/server.js +1 -1
- package/dist/src/archivist/index.js +9 -9
- package/dist/src/attendant/AttendantInstance.d.ts.map +1 -1
- package/dist/src/attendant/AttendantInstance.js +56 -55
- package/dist/src/attendant/AttendantInstance.js.map +1 -1
- package/dist/src/lib/protocolEnforcement.d.ts +1 -0
- package/dist/src/lib/protocolEnforcement.d.ts.map +1 -1
- package/dist/src/lib/protocolEnforcement.js +9 -0
- package/dist/src/lib/protocolEnforcement.js.map +1 -1
- package/dist/src/librarian/index.js +51 -51
- package/dist/src/library/queries.js +56 -56
- package/dist/src/sdk/index.d.ts.map +1 -1
- package/dist/src/sdk/index.js +1 -0
- package/dist/src/sdk/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,880 +1,880 @@
|
|
|
1
|
-
# Iranti
|
|
2
|
-
|
|
3
|
-
[](https://www.gnu.org/licenses/agpl-3.0.en.html)
|
|
4
|
-
[](https://www.python.org/downloads/)
|
|
5
|
-
[](https://www.typescriptlang.org/)
|
|
6
|
-
[](https://www.crewai.com/)
|
|
7
|
-
|
|
8
|
-
**Memory infrastructure for multi-agent AI systems.**
|
|
9
|
-
|
|
10
|
-
Iranti gives agents persistent, identity-based memory. Facts written by one agent are retrievable by any other agent through exact entity+key lookup. Iranti also supports hybrid search (lexical + vector) when exact keys are unknown. Memory persists across sessions and survives context window limits.
|
|
11
|
-
|
|
12
|
-
**Repo version:** `0.3.
|
|
1
|
+
# Iranti
|
|
2
|
+
|
|
3
|
+
[](https://www.gnu.org/licenses/agpl-3.0.en.html)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://www.crewai.com/)
|
|
7
|
+
|
|
8
|
+
**Memory infrastructure for multi-agent AI systems.**
|
|
9
|
+
|
|
10
|
+
Iranti gives agents persistent, identity-based memory. Facts written by one agent are retrievable by any other agent through exact entity+key lookup. Iranti also supports hybrid search (lexical + vector) when exact keys are unknown. Memory persists across sessions and survives context window limits.
|
|
11
|
+
|
|
12
|
+
**Repo version:** `0.3.4`
|
|
13
13
|
Published packages:
|
|
14
|
-
- npm `iranti@0.3.
|
|
15
|
-
- npm `@iranti/sdk@0.3.
|
|
16
|
-
- PyPI `iranti==0.3.
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## What is Iranti?
|
|
21
|
-
|
|
22
|
-
Iranti is a knowledge base for multi-agent systems. The primary read path is identity retrieval — this specific entity (`project/nexus_prime`), this specific key (`deadline`), with confidence attached. When Agent A writes a fact, Agent B can retrieve it by exact lookup without being told it exists. Facts persist in PostgreSQL and survive context window boundaries through the `observe()` API. For discovery workflows, Iranti supports hybrid search (full-text + vector similarity).
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Runtime Roles
|
|
27
|
-
|
|
28
|
-
- **User**: Person who interacts with an app or chatbot built on Iranti.
|
|
29
|
-
- **Agent**: External AI worker that writes/reads facts through Iranti APIs.
|
|
30
|
-
- **Attendant**: Per-agent memory manager that decides what to inject for each turn.
|
|
31
|
-
- **Librarian**: Conflict-aware writer that owns all KB writes.
|
|
32
|
-
- **Library**: Active truth store (`knowledge_base`) in PostgreSQL.
|
|
33
|
-
- **Archive**: Historical/superseded truth store (`archive`) in PostgreSQL.
|
|
34
|
-
- **Archivist**: Maintenance worker that archives stale/low-confidence facts and processes resolved escalations.
|
|
35
|
-
- **Resolutionist**: Interactive CLI reviewer that guides humans through pending escalation files and writes valid authoritative resolutions.
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Why Not a Vector Database?
|
|
40
|
-
|
|
41
|
-
| Feature | Vector DB | Iranti |
|
|
42
|
-
|---|---|---|
|
|
43
|
-
| **Retrieval** | Similarity (nearest neighbor) | Identity-first + optional hybrid search |
|
|
44
|
-
| **Storage** | Embeddings in vector space | Structured facts with keys |
|
|
45
|
-
| **Persistence** | Stateless between calls | Persistent across sessions |
|
|
46
|
-
| **Confidence** | No confidence tracking | Per-fact confidence scores |
|
|
47
|
-
| **Conflicts** | No conflict resolution | Automatic resolution + escalation |
|
|
48
|
-
| **Context** | No context awareness | `observe()` injects missing facts |
|
|
49
|
-
|
|
50
|
-
Vector databases answer "what's similar to X?" Iranti answers "what do we know about X?" and can run hybrid search when exact keys are unknown.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Benchmark Summary
|
|
55
|
-
|
|
56
|
-
Iranti now has current rerun evidence across exact retrieval, process continuity, upgrade durability, relationships, bounded conflict handling, and bounded recovery behavior. The current picture is stronger and narrower than the early validation story: exact, durable, shared memory is validated; broad semantic-memory and autonomous-recovery claims still need explicit limits.
|
|
57
|
-
|
|
58
|
-
### Confirmed Strengths
|
|
59
|
-
|
|
14
|
+
- npm `iranti@0.3.4`
|
|
15
|
+
- npm `@iranti/sdk@0.3.4`
|
|
16
|
+
- PyPI `iranti==0.3.4`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What is Iranti?
|
|
21
|
+
|
|
22
|
+
Iranti is a knowledge base for multi-agent systems. The primary read path is identity retrieval — this specific entity (`project/nexus_prime`), this specific key (`deadline`), with confidence attached. When Agent A writes a fact, Agent B can retrieve it by exact lookup without being told it exists. Facts persist in PostgreSQL and survive context window boundaries through the `observe()` API. For discovery workflows, Iranti supports hybrid search (full-text + vector similarity).
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Runtime Roles
|
|
27
|
+
|
|
28
|
+
- **User**: Person who interacts with an app or chatbot built on Iranti.
|
|
29
|
+
- **Agent**: External AI worker that writes/reads facts through Iranti APIs.
|
|
30
|
+
- **Attendant**: Per-agent memory manager that decides what to inject for each turn.
|
|
31
|
+
- **Librarian**: Conflict-aware writer that owns all KB writes.
|
|
32
|
+
- **Library**: Active truth store (`knowledge_base`) in PostgreSQL.
|
|
33
|
+
- **Archive**: Historical/superseded truth store (`archive`) in PostgreSQL.
|
|
34
|
+
- **Archivist**: Maintenance worker that archives stale/low-confidence facts and processes resolved escalations.
|
|
35
|
+
- **Resolutionist**: Interactive CLI reviewer that guides humans through pending escalation files and writes valid authoritative resolutions.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Why Not a Vector Database?
|
|
40
|
+
|
|
41
|
+
| Feature | Vector DB | Iranti |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| **Retrieval** | Similarity (nearest neighbor) | Identity-first + optional hybrid search |
|
|
44
|
+
| **Storage** | Embeddings in vector space | Structured facts with keys |
|
|
45
|
+
| **Persistence** | Stateless between calls | Persistent across sessions |
|
|
46
|
+
| **Confidence** | No confidence tracking | Per-fact confidence scores |
|
|
47
|
+
| **Conflicts** | No conflict resolution | Automatic resolution + escalation |
|
|
48
|
+
| **Context** | No context awareness | `observe()` injects missing facts |
|
|
49
|
+
|
|
50
|
+
Vector databases answer "what's similar to X?" Iranti answers "what do we know about X?" and can run hybrid search when exact keys are unknown.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Benchmark Summary
|
|
55
|
+
|
|
56
|
+
Iranti now has current rerun evidence across exact retrieval, process continuity, upgrade durability, relationships, bounded conflict handling, and bounded recovery behavior. The current picture is stronger and narrower than the early validation story: exact, durable, shared memory is validated; broad semantic-memory and autonomous-recovery claims still need explicit limits.
|
|
57
|
+
|
|
58
|
+
### Confirmed Strengths
|
|
59
|
+
|
|
60
60
|
- **Exact lookup (`iranti_query`)**: The prepublish candidate for the current `0.3.0` line still scored `10/10` on the canonical B1 exact-retrieval arm.
|
|
61
|
-
- **Persistence across sessions and processes**: Facts survive context-window loss and genuine process boundaries, with current reruns and validation passes covering process-isolated reads plus cross-process invalidation.
|
|
61
|
+
- **Persistence across sessions and processes**: Facts survive context-window loss and genuine process boundaries, with current reruns and validation passes covering process-isolated reads plus cross-process invalidation.
|
|
62
62
|
- **Upgrade durability**: A fresh continuity chain now passes across public npm `0.2.49 -> 0.2.50 -> 0.2.51` plus a final prepublish candidate hop on the `0.3.0` line.
|
|
63
|
-
- **Conflict handling**: Reliable when confidence differentials are large and explicit.
|
|
64
|
-
- **Relationship traversal and multi-agent coordination**: Relationship writes plus one-hop/deep traversal work, and agents can share memory across genuine subprocess boundaries with zero shared conversational context.
|
|
65
|
-
- **Provenance on writes**: Write-side attribution through stored source metadata is working and benchmark-confirmed.
|
|
66
|
-
- **Ingest**: Prose extraction is accurate on clean entities in the bounded rerun surfaces already documented.
|
|
67
|
-
- **Observe with hints / explicit recovery**: `iranti_observe` with hints and explicit query-based recovery are meaningfully useful today.
|
|
68
|
-
- **Protocol enforcement turn-gate**: Strict turn-cycle enforcement (handshake → attend → discover → post-response) is validated by focused route and MCP regression tests. In `strict` mode, KB discovery routes return HTTP 428 with a structured violation payload before an agent that skipped attend can silently read stale memory. Injected facts now include a `lastUpdated` timestamp so the calling agent can judge freshness at the point of injection.
|
|
69
|
-
|
|
70
|
-
Recent fixes since the last rerun:
|
|
71
|
-
- **Search now bridges semantic hits across relationships for filtered retrieval.** A strong incident or issue hit can now propagate back onto the owning filtered entity over up to two hops, so filtered project search no longer depends on direct lexical overlap alone.
|
|
72
|
-
- **`iranti_attend` now safe-defaults parse failures toward memory on non-greeting turns.** Terse prompts such as `help`, `why?`, or `how?` no longer silently fall through to `classification_parse_failed_default_false`.
|
|
73
|
-
- **Hybrid search now indexes entity addresses directly.** Addressed queries such as `project/<id> status` no longer rely on value-summary overlap alone.
|
|
74
|
-
|
|
75
|
-
### Current Limits
|
|
76
|
-
|
|
77
|
-
- **Upgrade durability is now test-covered.** The `v0.2.21` upgrade reinitialized the instance under test — a one-time operator incident, not a systemic design flaw. All Prisma migrations are additive (no DROP or TRUNCATE); Staff Namespace seeding is guarded by `isSeeded()`; `seed-codebase.ts` upserts to `codebase/*` entities only. A KB preservation test in `tests/runtime-lifecycle/run_setup_upgrade_tests.ts` now confirms user KB data written before a `setup` re-run survives intact.
|
|
78
|
-
- **Project learning is now only a bounded bind-time snapshot.** When you bind a project, Iranti derives a stable `IRANTI_CODEBASE_ENTITY` and writes a small snapshot from authoritative files such as `package.json`, `README.md`, `tsconfig.json`, `pyproject.toml`, `prisma/schema.prisma`, and common source directories. It does not yet crawl the repo continuously or build autonomous whole-project understanding.
|
|
79
|
-
- **Relationship and provenance reflection surfaces remain partially permission-gated in benchmark sessions.** The rerun did not prove `iranti_relate`, `iranti_related`, `iranti_related_deep`, or `iranti_who_knows` end-to-end under the benchmark session policy.
|
|
80
|
-
|
|
81
|
-
### Practical Position
|
|
82
|
-
|
|
83
|
-
Iranti is strongest today as **structured memory infrastructure for multi-agent systems**:
|
|
84
|
-
- exact entity/key lookup
|
|
85
|
-
- durable shared memory
|
|
86
|
-
- provenance-aware writes with source attribution and freshness timestamps
|
|
87
|
-
- conflict-aware storage
|
|
88
|
-
- session-aware recovery
|
|
89
|
-
- protocol-enforced turn discipline for trustworthy injection (opt-in strict mode)
|
|
90
|
-
|
|
91
|
-
It should not yet be described as a fully general semantic-memory, semantic-search, or autonomous-memory-injection system.
|
|
92
|
-
|
|
93
|
-
Historical benchmark material remains available here:
|
|
94
|
-
- [`docs/internal/validation_results.md`](docs/internal/validation_results.md)
|
|
95
|
-
- [`docs/internal/MULTI_FRAMEWORK_VALIDATION.md`](docs/internal/MULTI_FRAMEWORK_VALIDATION.md)
|
|
96
|
-
- [`docs/internal/conflict_benchmark.md`](docs/internal/conflict_benchmark.md)
|
|
97
|
-
- [`docs/internal/consistency_model.md`](docs/internal/consistency_model.md)
|
|
98
|
-
|
|
99
|
-
## Gap Analysis
|
|
100
|
-
|
|
101
|
-
Iranti targets a specific gap in the agent infrastructure stack: most competing systems give you semantic retrieval, framework-specific memory, or raw vector storage, but not the same combination of structured fact storage, cross-agent sharing, identity-based lookup, explicit confidence, and developer-visible conflict handling in one self-hostable package.
|
|
102
|
-
|
|
103
|
-
The current competitive case for Iranti is strongest when a team needs memory that behaves more like shared infrastructure than a chat transcript: facts are attached to entities, retrieved deterministically by `entityType/entityId + key`, versioned over time, and made available across agents without framework lock-in.
|
|
104
|
-
|
|
105
|
-
### Where Iranti Is Differentiated
|
|
106
|
-
|
|
107
|
-
- Identity-first fact retrieval through `entityType/entityId + key`
|
|
108
|
-
- Cross-agent fact sharing as a first-class model
|
|
109
|
-
- Conflict-aware writes through the Librarian
|
|
110
|
-
- Explicit per-fact confidence scores
|
|
111
|
-
- Per-agent memory injection through the Attendant
|
|
112
|
-
- Temporal exact lookup with `asOf` and ordered `history()`
|
|
113
|
-
- Relationship primitives through `relate()`, `getRelated()`, and `getRelatedDeep()` at the product surface, with benchmark confirmation for those MCP-accessible paths still pending
|
|
114
|
-
- Hybrid retrieval when exact keys are unknown
|
|
115
|
-
- Local install + project binding flow for Claude Code and Codex
|
|
116
|
-
- Published npm / PyPI surfaces with machine-level CLI setup
|
|
117
|
-
|
|
118
|
-
### Why That Gap Exists
|
|
119
|
-
|
|
120
|
-
The current landscape splits into three buckets:
|
|
121
|
-
|
|
122
|
-
1. **Memory libraries**
|
|
123
|
-
- Systems like Mem0, Zep, Letta, and framework-native memory layers solve parts of the problem.
|
|
124
|
-
- They usually optimize for semantic retrieval, agent-local memory, or framework integration.
|
|
125
|
-
- They rarely expose deterministic `entity + key` lookup, explicit confidence surfaces, and developer-controlled conflict handling together.
|
|
126
|
-
|
|
127
|
-
2. **Vector databases**
|
|
128
|
-
- Pinecone, Weaviate, Qdrant, Chroma, Milvus, LanceDB, and `pgvector` solve storage and retrieval infrastructure.
|
|
129
|
-
- They do not, by themselves, solve memory semantics such as conflict resolution, context injection, fact lifecycle, or shared agent-facing state.
|
|
130
|
-
|
|
131
|
-
3. **Multi-agent frameworks**
|
|
132
|
-
- CrewAI, LangGraph, AutoGen, CAMEL, MetaGPT, and similar frameworks often include some memory support.
|
|
133
|
-
- In practice, that memory is usually framework-coupled, shallow on conflict semantics, and difficult to reuse outside the framework that created it.
|
|
134
|
-
|
|
135
|
-
### Main Gaps
|
|
136
|
-
|
|
137
|
-
1. **Operational maturity**
|
|
138
|
-
- Local PostgreSQL setup is still a real source of friction.
|
|
139
|
-
- The product needs stronger diagnostics, connection recovery, and less dependence on users debugging local database state by hand.
|
|
140
|
-
|
|
141
|
-
2. **Onboarding still has sharp edges**
|
|
142
|
-
- `iranti setup` is materially better than before, but first-run still assumes too much infrastructure literacy.
|
|
143
|
-
- Managed Postgres paths, cleaner bootstrap verification, and fewer environment-level surprises are still needed.
|
|
144
|
-
|
|
145
|
-
3. **No operator UI yet**
|
|
146
|
-
- Iranti is still CLI-first.
|
|
147
|
-
- There is no control plane yet for provider keys, project bindings, integrations, memory inspection, and escalation review.
|
|
148
|
-
|
|
149
|
-
4. **Adoption proof is still early**
|
|
150
|
-
- The repo has validation experiments and real local end-to-end usage, but broad production adoption is still limited.
|
|
151
|
-
- The next product truth has to come from external users and real workloads, not more speculative architecture alone.
|
|
152
|
-
|
|
153
|
-
5. **Hosted product is not built**
|
|
154
|
-
- Open-source/local infrastructure is the active surface today.
|
|
155
|
-
- Hosted deployment, multi-tenant operations, billing, and cloud onboarding remain future work.
|
|
156
|
-
|
|
157
|
-
6. **Graph-native reasoning is still limited**
|
|
158
|
-
- Iranti supports explicit entity relationships today.
|
|
159
|
-
- It does not yet compete with graph-first systems on temporal graph traversal or graph-native reasoning depth.
|
|
160
|
-
|
|
161
|
-
7. **Memory extraction is not the main model**
|
|
162
|
-
- Iranti supports structured writes and ingest/chunking, but it is not primarily a "dump arbitrary conversations in and auto-magically derive perfect memory" system.
|
|
163
|
-
- That is a deliberate tradeoff in favor of explicit, inspectable facts, but it increases integration work.
|
|
164
|
-
|
|
165
|
-
### Current Position
|
|
166
|
-
|
|
167
|
-
Iranti is strongest today as infrastructure for developers building multi-agent systems who need shared, structured, queryable memory rather than pure semantic recall. The current benchmark base now supports a more concrete product claim:
|
|
168
|
-
|
|
169
|
-
- exact cross-agent fact transfer works at meaningful context scales
|
|
170
|
-
- facts survive session loss and genuine process breaks
|
|
171
|
-
- same-key conflicting writes are serialized and observable
|
|
172
|
-
- prose ingest is accurate on clean entities
|
|
173
|
-
- attended recovery works with explicit hints, while autonomous attend classification remains a known defect
|
|
174
|
-
|
|
175
|
-
That is still not a claim that multi-agent memory is solved. It is a claim that Iranti now has broader evidence for durable, structured, attribution-aware memory with exact retrieval and bounded recovery behavior.
|
|
176
|
-
|
|
177
|
-
The next leverage is still product simplicity: setup, operations, and day-to-day inspection need to be simple enough that real users keep Iranti in the loop.
|
|
178
|
-
|
|
179
|
-
## Quickstart
|
|
180
|
-
|
|
181
|
-
**Requirements**: Node.js 18+, PostgreSQL with pgvector support, Python 3.8+
|
|
182
|
-
|
|
183
|
-
Docker is optional. It is one local way to run PostgreSQL if you do not already have a database. Iranti still requires PostgreSQL; the setup improvement is smarter bootstrap and clearer guidance, not a second storage backend.
|
|
184
|
-
|
|
185
|
-
```bash
|
|
186
|
-
# 1. Install the CLI
|
|
187
|
-
npm install -g iranti
|
|
188
|
-
|
|
189
|
-
# 2. Run the guided setup
|
|
190
|
-
iranti setup
|
|
191
|
-
|
|
192
|
-
# 3. Start the instance
|
|
193
|
-
iranti run --instance local
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
`iranti setup` now defaults to an isolated per-project runtime. Shared machine-level instances are still supported, but they are now an explicit choice rather than the default.
|
|
197
|
-
|
|
198
|
-
If local PostgreSQL is available and pgvector-capable, setup can bootstrap a localhost database for you. If Docker is available, setup now prefers the Docker path over a plain local listener because it guarantees pgvector. If local PostgreSQL is reachable but does not provide pgvector, setup now fails early with a direct action path instead of a late Prisma migration error.
|
|
199
|
-
|
|
200
|
-
Long-running agents can now checkpoint and recover interrupted work. Programmatic session lifecycle methods are available through the SDK and REST API:
|
|
201
|
-
- `checkpoint()`
|
|
202
|
-
- `inspectSession()`
|
|
203
|
-
- `listSessions()`
|
|
204
|
-
- `resumeSession()`
|
|
205
|
-
- `completeSession()`
|
|
206
|
-
- `abandonSession()`
|
|
207
|
-
|
|
208
|
-
Running instances now publish runtime metadata in `/health`, and the CLI can see that state through `iranti status`, `iranti instance show`, and `iranti upgrade --check`. When you want an installed upgrade to immediately take effect on an instance-backed API server, use:
|
|
209
|
-
|
|
210
|
-
```bash
|
|
211
|
-
iranti upgrade --restart --instance local
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
If something still fails and you need more detail, use:
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
iranti doctor --debug
|
|
218
|
-
iranti run --instance local --debug
|
|
219
|
-
iranti upgrade --verbose
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
If you want to remove Iranti cleanly:
|
|
223
|
-
|
|
224
|
-
```bash
|
|
225
|
-
iranti uninstall --dry-run
|
|
226
|
-
iranti uninstall --all --yes
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
Default uninstall keeps runtime data and project bindings. `--all` removes discovered runtime roots plus project-local Iranti integrations.
|
|
230
|
-
|
|
231
|
-
Advanced/manual path:
|
|
232
|
-
|
|
233
|
-
```bash
|
|
234
|
-
# 1. Clone and configure
|
|
235
|
-
git clone https://github.com/nfemmanuel/iranti
|
|
236
|
-
cd iranti
|
|
237
|
-
cp .env.example .env # Set DATABASE_URL and IRANTI_API_KEY
|
|
238
|
-
|
|
239
|
-
# Optional runtime hygiene
|
|
240
|
-
# IRANTI_ESCALATION_DIR=C:/Users/<you>/.iranti/escalation
|
|
241
|
-
# IRANTI_ARCHIVIST_WATCH=true
|
|
242
|
-
# IRANTI_ARCHIVIST_DEBOUNCE_MS=60000
|
|
243
|
-
# IRANTI_ARCHIVIST_INTERVAL_MS=21600000
|
|
244
|
-
|
|
245
|
-
# 2. Start PostgreSQL
|
|
246
|
-
docker-compose up -d
|
|
247
|
-
|
|
248
|
-
# 3. Install and initialize
|
|
249
|
-
npm install
|
|
250
|
-
npm run setup # Runs migrations
|
|
251
|
-
|
|
252
|
-
# 4. Start API server
|
|
253
|
-
npm run api # Runs on port 3001
|
|
254
|
-
|
|
255
|
-
# 5. Install Python client
|
|
256
|
-
pip install iranti
|
|
257
|
-
|
|
258
|
-
# Optional: install the TypeScript client
|
|
259
|
-
npm install @iranti/sdk
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### Archivist Scheduling Knobs
|
|
263
|
-
|
|
264
|
-
- `IRANTI_ARCHIVIST_WATCH=true` enables file-change watching on escalation `active/`.
|
|
265
|
-
- `IRANTI_ARCHIVIST_DEBOUNCE_MS=60000` runs maintenance 60s after the latest file change.
|
|
266
|
-
- `IRANTI_ARCHIVIST_INTERVAL_MS=21600000` runs maintenance every 6 hours (set `0` to disable).
|
|
267
|
-
- `IRANTI_ESCALATION_DIR` sets escalation storage root. Default is `~/.iranti/escalation`, keeping escalation files out of the repo by default.
|
|
268
|
-
|
|
269
|
-
### Per-User API Keys (Recommended)
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
# Create a key for one user/app (prints token once)
|
|
273
|
-
npm run api-key:create -- --key-id chatbot_alice --owner "Alice chatbot" --scopes "kb:read,kb:write,memory:read,memory:write,agents:read,agents:write"
|
|
274
|
-
|
|
275
|
-
# List keys
|
|
276
|
-
npm run api-key:list
|
|
277
|
-
|
|
278
|
-
# Revoke a key
|
|
279
|
-
npm run api-key:revoke -- --key-id chatbot_alice
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
Use the printed token (`keyId.secret`) as `X-Iranti-Key`.
|
|
283
|
-
Scopes use `resource:action` format (for example `kb:read`, `memory:write`, `metrics:read`, `proxy:chat`).
|
|
284
|
-
|
|
285
|
-
### Security Baseline
|
|
286
|
-
|
|
287
|
-
- Use one scoped key per app/service identity.
|
|
288
|
-
- Rotate any key that is exposed in logs, screenshots, or chat.
|
|
289
|
-
- Keep escalation/log paths outside the repo working tree.
|
|
290
|
-
- Use TLS/reverse proxy for non-local deployments.
|
|
291
|
-
|
|
292
|
-
Security quickstart: [`docs/guides/security-quickstart.md`](docs/guides/security-quickstart.md)
|
|
293
|
-
Operator manual: [`docs/guides/manual.md`](docs/guides/manual.md)
|
|
294
|
-
Claude Code guide: [`docs/guides/claude-code.md`](docs/guides/claude-code.md)
|
|
295
|
-
Codex guide: [`docs/guides/codex.md`](docs/guides/codex.md)
|
|
296
|
-
Release guide: [`docs/guides/releasing.md`](docs/guides/releasing.md)
|
|
297
|
-
Vector backend guide: [`docs/guides/vector-backends.md`](docs/guides/vector-backends.md)
|
|
298
|
-
|
|
299
|
-
### Claude Code via MCP
|
|
300
|
-
|
|
301
|
-
Iranti ships a local stdio MCP server for Claude Code and other MCP clients:
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
iranti mcp
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
Use it with a project-local `.mcp.json`, and optionally add `iranti claude-hook` for `SessionStart` and `UserPromptSubmit`.
|
|
308
|
-
|
|
309
|
-
Fast path:
|
|
310
|
-
|
|
311
|
-
```bash
|
|
312
|
-
iranti claude-setup
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Guide: [`docs/guides/claude-code.md`](docs/guides/claude-code.md)
|
|
316
|
-
|
|
317
|
-
### Codex via MCP
|
|
318
|
-
|
|
319
|
-
Codex uses a global MCP registry rather than a project-local `.mcp.json`. Register Iranti once, then launch Codex in the bound project so `.env.iranti` is in scope:
|
|
320
|
-
|
|
321
|
-
```bash
|
|
322
|
-
iranti codex-setup
|
|
323
|
-
codex -C /path/to/your/project
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
By default, `iranti codex-setup` does not pin a project binding globally. `iranti mcp` resolves `.env.iranti` from the active project/workspace at runtime. Use `--project-env` only if you deliberately want to pin Codex globally to one project binding.
|
|
327
|
-
|
|
328
|
-
Alias:
|
|
329
|
-
|
|
330
|
-
```bash
|
|
331
|
-
iranti integrate codex
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
Guide: [`docs/guides/codex.md`](docs/guides/codex.md)
|
|
335
|
-
|
|
336
|
-
### Resolve Pending Escalations
|
|
337
|
-
|
|
338
|
-
Review unresolved human-escalation files from the CLI:
|
|
339
|
-
|
|
340
|
-
```bash
|
|
341
|
-
iranti resolve
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
Use `--dir` to point at a non-default escalation root. Guide: [`docs/guides/conflict-resolution.md`](docs/guides/conflict-resolution.md)
|
|
345
|
-
|
|
346
|
-
### Native Chat
|
|
347
|
-
|
|
348
|
-
Start a CLI chat session against the configured Iranti instance:
|
|
349
|
-
|
|
350
|
-
```bash
|
|
351
|
-
iranti chat
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
Use `--agent`, `--provider`, and `--model` to pin the session identity and model routing.
|
|
355
|
-
The chat surface now includes slash commands for fact history, relationships, conflict-resolution handoff, and confidence updates in addition to memory search/write operations.
|
|
356
|
-
Guide: [`docs/guides/chat.md`](docs/guides/chat.md)
|
|
357
|
-
|
|
358
|
-
### Manual Attendant Inspection
|
|
359
|
-
|
|
360
|
-
For debugging and operator visibility, Iranti also exposes manual Attendant commands:
|
|
361
|
-
|
|
362
|
-
```bash
|
|
363
|
-
iranti handshake --task "Working on ProofScript repo"
|
|
364
|
-
iranti attend "What did we decide about the parser?" --context-file transcript.txt
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
Both commands accept `--json`.
|
|
368
|
-
They are useful for verifying what the Attendant would load or inject for a given agent and project binding.
|
|
369
|
-
They are not a replacement for Claude Code hooks or MCP tools in normal use.
|
|
370
|
-
|
|
371
|
-
---
|
|
372
|
-
|
|
373
|
-
## Install Strategy (Double Layer)
|
|
374
|
-
|
|
375
|
-
Iranti now supports a two-layer install flow:
|
|
376
|
-
|
|
377
|
-
1. **Machine/runtime layer**: one local runtime root with one or more named Iranti instances.
|
|
378
|
-
2. **Project layer**: each chatbot/app binds to one instance with a local `.env.iranti`.
|
|
379
|
-
|
|
380
|
-
### 1) Install CLI
|
|
381
|
-
|
|
382
|
-
```bash
|
|
383
|
-
# If published package is available
|
|
384
|
-
npm install -g iranti
|
|
385
|
-
|
|
386
|
-
# Or from this repo (local simulation)
|
|
387
|
-
npm install -g .
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
### 2) Initialize machine runtime root
|
|
391
|
-
|
|
392
|
-
```bash
|
|
393
|
-
iranti setup
|
|
394
|
-
|
|
395
|
-
# non-interactive automation
|
|
396
|
-
iranti setup --defaults --db-url "postgresql://postgres:realpassword@localhost:5432/iranti_local"
|
|
397
|
-
iranti setup --config ./iranti.setup.json
|
|
398
|
-
|
|
399
|
-
# or, if you want the lower-level manual path:
|
|
400
|
-
iranti install --scope user
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
`iranti setup` is the recommended first-run path. It walks through:
|
|
404
|
-
- shared vs isolated runtime setup
|
|
405
|
-
- instance creation or update
|
|
406
|
-
- API port selection with conflict detection and next-free suggestions
|
|
407
|
-
- database onboarding:
|
|
408
|
-
- existing Postgres
|
|
409
|
-
- managed Postgres
|
|
410
|
-
- optional Docker-hosted Postgres for local development
|
|
411
|
-
- provider API keys
|
|
412
|
-
- Iranti client API key generation
|
|
413
|
-
- one or more project bindings
|
|
414
|
-
- optional Claude Code / Codex integration scaffolding
|
|
415
|
-
|
|
416
|
-
Operator-facing CLI help now includes short "what it does" and "use this when" guidance, so `iranti <command> --help` is the quickest way to choose the right entry point.
|
|
417
|
-
|
|
418
|
-
For automation:
|
|
419
|
-
- `iranti setup --defaults` uses sensible defaults plus environment/flag input, but still requires a real `DATABASE_URL`.
|
|
420
|
-
- `iranti setup --config <file>` reads a JSON setup plan for repeatable bootstrap.
|
|
421
|
-
- `--bootstrap-db` runs migrations and seeding during automated setup when the database is reachable.
|
|
422
|
-
- Example config: [docs/guides/iranti.setup.example.json](docs/guides/iranti.setup.example.json)
|
|
423
|
-
|
|
424
|
-
Default API port remains `3001`. The setup wizard now warns when that port is already in use and suggests the next free port instead of forcing users to debug the collision manually.
|
|
425
|
-
|
|
426
|
-
Defaults:
|
|
427
|
-
- Windows user scope: `%USERPROFILE%\\.iranti`
|
|
428
|
-
- Windows system scope: `%ProgramData%\\Iranti`
|
|
429
|
-
- Linux system scope: `/var/lib/iranti`
|
|
430
|
-
- macOS system scope: `/Library/Application Support/Iranti`
|
|
431
|
-
|
|
432
|
-
### 3) Create a named instance
|
|
433
|
-
|
|
434
|
-
```bash
|
|
435
|
-
iranti instance create local --port 3001 --db-url "postgresql://postgres:yourpassword@localhost:5432/iranti_local" --provider mock
|
|
436
|
-
iranti instance show local
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
Finish onboarding or change settings later with:
|
|
440
|
-
|
|
441
|
-
```bash
|
|
442
|
-
# Provider/db updates
|
|
443
|
-
iranti configure instance local --provider openai --provider-key replace-with-real-openai-key --db-url "postgresql://postgres:realpassword@localhost:5432/iranti_local"
|
|
444
|
-
iranti configure instance local --interactive
|
|
445
|
-
|
|
446
|
-
# Provider key shortcuts
|
|
447
|
-
iranti list api-keys --instance local
|
|
448
|
-
iranti add api-key openai --instance local
|
|
449
|
-
iranti update api-key claude --instance local
|
|
450
|
-
iranti remove api-key gemini --instance local
|
|
451
|
-
|
|
452
|
-
# Create a registry-backed API key and sync it into the instance env
|
|
453
|
-
iranti auth create-key --instance local --key-id local_admin --owner "Local Admin" --scopes "kb:read,kb:write,memory:read,memory:write,agents:read,agents:write" --write-instance
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
`iranti add|update|remove api-key` updates the stored upstream provider credentials in the instance env without hand-editing `.env` files. `iranti list api-keys` shows which provider keys are currently stored. Supported remote providers are OpenAI, Claude, Gemini, Groq, and Mistral. `mock` and `ollama` do not require remote API keys, and Perplexity is not yet supported.
|
|
457
|
-
|
|
458
|
-
### 4) Run Iranti from that instance
|
|
459
|
-
|
|
460
|
-
```bash
|
|
461
|
-
iranti run --instance local
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
If a provider rejects requests because credits are exhausted, billing is disabled, or the account is quota-limited, Iranti now surfaces a direct message such as `OpenAI quota or billing limit reached. Add credits, update the API key, or switch providers.`
|
|
465
|
-
|
|
466
|
-
### 5) Bind any chatbot/app project to that instance
|
|
467
|
-
|
|
468
|
-
```bash
|
|
469
|
-
cd /path/to/your/chatbot
|
|
470
|
-
iranti project init . --instance local --agent-id chatbot_main
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
This writes `.env.iranti` in the project with the correct `IRANTI_URL`, `IRANTI_API_KEY`, and default agent identity.
|
|
474
|
-
It also writes a derived `IRANTI_CODEBASE_ENTITY` and a bounded initial project snapshot for that bound repo.
|
|
475
|
-
|
|
476
|
-
Later changes use the same surface:
|
|
477
|
-
|
|
478
|
-
```bash
|
|
479
|
-
iranti configure project . --instance local --agent-id chatbot_worker
|
|
480
|
-
iranti configure project . --interactive
|
|
481
|
-
iranti project unbind .
|
|
482
|
-
iranti auth create-key --instance local --key-id chatbot_worker --owner "Chatbot Worker" --scopes "kb:read,memory:read,memory:write" --project .
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
For multi-agent systems, bind once per project and set unique agent IDs per worker (for example `planner_agent`, `research_agent`, `critic_agent`).
|
|
486
|
-
|
|
487
|
-
### Installation Diagnostics
|
|
488
|
-
|
|
489
|
-
Use the CLI doctor command before first run or before a release check:
|
|
490
|
-
|
|
491
|
-
```bash
|
|
492
|
-
iranti doctor
|
|
493
|
-
iranti doctor --instance local
|
|
494
|
-
iranti status
|
|
495
|
-
iranti upgrade --check
|
|
496
|
-
iranti upgrade --dry-run
|
|
497
|
-
iranti upgrade --yes
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
This validates the active env file, database URL, API key presence, provider selection, and provider-specific credentials.
|
|
501
|
-
`iranti status` shows the current runtime root, known instances, and local binding files.
|
|
502
|
-
`iranti upgrade` detects repo/global/Python install paths, compares current vs latest published versions, prints the exact plan, and executes the selected upgrade path when you pass `--yes`.
|
|
503
|
-
On Windows, if the currently running CLI is itself the global npm install being upgraded, Iranti now hands that npm-global step off to a detached updater process instead of trying to replace the live binary in place.
|
|
504
|
-
`iranti configure ...` updates instance/project credentials without manual env editing.
|
|
505
|
-
`iranti auth ...` manages registry-backed API keys and can sync them into instance or project bindings.
|
|
506
|
-
When you pass `--root` in Windows `cmd.exe`, use no quotes or double quotes. Single quotes are treated literally there.
|
|
507
|
-
|
|
508
|
-
---
|
|
509
|
-
|
|
510
|
-
## Core API
|
|
511
|
-
|
|
512
|
-
### Write a Fact
|
|
513
|
-
|
|
514
|
-
```python
|
|
515
|
-
from clients.python.iranti import IrantiClient
|
|
516
|
-
|
|
517
|
-
client = IrantiClient(
|
|
518
|
-
base_url="http://localhost:3001",
|
|
519
|
-
api_key="your_api_key_here"
|
|
520
|
-
)
|
|
521
|
-
|
|
522
|
-
result = client.write(
|
|
523
|
-
entity="researcher/jane_smith", # Format: entityType/entityId
|
|
524
|
-
key="affiliation",
|
|
525
|
-
value={"institution": "MIT", "department": "CSAIL"},
|
|
526
|
-
summary="Affiliated with MIT CSAIL", # Compressed for working memory
|
|
527
|
-
confidence=85, # 0-100
|
|
528
|
-
source="OpenAlex",
|
|
529
|
-
agent="research_agent_001"
|
|
530
|
-
)
|
|
531
|
-
|
|
532
|
-
print(result.action) # 'created', 'updated', 'escalated', or 'rejected'
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
### Query a Fact
|
|
536
|
-
|
|
537
|
-
```python
|
|
538
|
-
result = client.query("researcher/jane_smith", "affiliation")
|
|
539
|
-
|
|
540
|
-
if result.found:
|
|
541
|
-
print(result.value) # {"institution": "MIT", "department": "CSAIL"}
|
|
542
|
-
print(result.confidence) # 85
|
|
543
|
-
print(result.source) # "OpenAlex"
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
### Query All Facts for an Entity
|
|
547
|
-
|
|
548
|
-
```python
|
|
549
|
-
facts = client.query_all("researcher/jane_smith")
|
|
550
|
-
|
|
551
|
-
for fact in facts:
|
|
552
|
-
print(f"[{fact['key']}] {fact['summary']} (confidence: {fact['confidence']})")
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
### Graph Traversal
|
|
556
|
-
|
|
557
|
-
```python
|
|
558
|
-
from clients.python.iranti import IrantiClient
|
|
559
|
-
|
|
560
|
-
client = IrantiClient(base_url="http://localhost:3001", api_key="your_api_key_here")
|
|
561
|
-
|
|
562
|
-
# Agent 1 writes facts and links them into a graph.
|
|
563
|
-
client.write("researcher/jane_smith", "affiliation", {"lab": "CSAIL"}, "Jane Smith is affiliated with CSAIL", 90, "OpenAlex", "research_agent")
|
|
564
|
-
client.write("project/quantum_bridge", "status", {"phase": "active"}, "Quantum Bridge is active", 88, "project_brief", "research_agent")
|
|
565
|
-
|
|
566
|
-
client.relate("researcher/jane_smith", "MEMBER_OF", "lab/csail", created_by="research_agent")
|
|
567
|
-
client.relate("lab/csail", "LEADS", "project/quantum_bridge", created_by="research_agent")
|
|
568
|
-
|
|
569
|
-
# Agent 2 starts cold and traverses outward from Jane Smith.
|
|
570
|
-
one_hop = client.related("researcher/jane_smith")
|
|
571
|
-
labs = [f"{r['toType']}/{r['toId']}" for r in one_hop if r["relationshipType"] == "MEMBER_OF"]
|
|
572
|
-
|
|
573
|
-
projects = []
|
|
574
|
-
for lab in labs:
|
|
575
|
-
for rel in client.related(lab):
|
|
576
|
-
if rel["relationshipType"] == "LEADS":
|
|
577
|
-
project = f"{rel['toType']}/{rel['toId']}"
|
|
578
|
-
status = client.query(project, "status")
|
|
579
|
-
projects.append((project, status.value["phase"]))
|
|
580
|
-
|
|
581
|
-
print(projects)
|
|
582
|
-
# Agent 2 learned which project Jane Smith is connected to without being told the project directly.
|
|
583
|
-
```
|
|
584
|
-
|
|
585
|
-
### Relationship Types
|
|
586
|
-
|
|
587
|
-
Relationship types are caller-defined strings. Common conventions:
|
|
588
|
-
|
|
589
|
-
| Relationship Type | Meaning |
|
|
590
|
-
|---|---|
|
|
591
|
-
| `MEMBER_OF` | Entity belongs to a team, lab, org, or group |
|
|
592
|
-
| `PART_OF` | Entity is a component or sub-unit of another entity |
|
|
593
|
-
| `AUTHORED` | Person or agent created a document, paper, or artifact |
|
|
594
|
-
| `LEADS` | Person, team, or org leads a project or effort |
|
|
595
|
-
| `DEPENDS_ON` | Project, service, or task depends on another entity |
|
|
596
|
-
| `REPORTS_TO` | Directed reporting relationship between people or agents |
|
|
597
|
-
|
|
598
|
-
Use uppercase snake case for consistency. Iranti does not enforce a fixed ontology here; the calling application owns the relationship vocabulary.
|
|
599
|
-
|
|
600
|
-
### Hybrid Search
|
|
601
|
-
|
|
602
|
-
```python
|
|
603
|
-
matches = client.search(
|
|
604
|
-
query="current blocker launch readiness",
|
|
605
|
-
entity_type="project",
|
|
606
|
-
limit=5,
|
|
607
|
-
lexical_weight=0.45,
|
|
608
|
-
vector_weight=0.55,
|
|
609
|
-
)
|
|
610
|
-
|
|
611
|
-
for item in matches:
|
|
612
|
-
print(item["entity"], item["key"], item["score"])
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
### Context Persistence (attend)
|
|
616
|
-
|
|
617
|
-
`handshake()` establishes the session contract. Discovery surfaces such as `query`, `search`, `get_related`, and `who_knows` are now fail-closed until the host has run `handshake()` for the session and `attend()` for the current turn. Starting a new `attend(phase="pre-response")` turn without first closing the previous one with `attend(phase="post-response")` is now blocked as a protocol violation, and `inspectSession()` / `listSessions()` expose structured lifecycle compliance state (`healthy`, `degraded`, `non_compliant`) so hosts and operators can see when breadcrumb discipline is slipping.
|
|
618
|
-
|
|
619
|
-
```python
|
|
620
|
-
# Before each LLM call, let Attendant decide if memory is needed
|
|
621
|
-
result = client.attend(
|
|
622
|
-
agent_id="research_agent_001",
|
|
623
|
-
latest_message="What's Jane Smith's current affiliation?",
|
|
624
|
-
current_context="User: What's Jane Smith's current affiliation?\nAssistant: Let me check...",
|
|
625
|
-
max_facts=5,
|
|
626
|
-
phase="pre-response"
|
|
627
|
-
)
|
|
628
|
-
|
|
629
|
-
if result["shouldInject"]:
|
|
630
|
-
for fact in result['facts']:
|
|
631
|
-
print(f"Inject: [{fact['entityKey']}] {fact['summary']}")
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
### Working Memory (handshake)
|
|
635
|
-
|
|
636
|
-
```python
|
|
637
|
-
# At session start, get personalized brief for agent's current task
|
|
638
|
-
brief = client.handshake(
|
|
639
|
-
agent_id="research_agent_001",
|
|
640
|
-
task="Research publication history for Dr. Jane Smith",
|
|
641
|
-
recent_messages=["Starting literature review..."]
|
|
642
|
-
)
|
|
643
|
-
|
|
644
|
-
print(brief.operating_rules) # Staff namespace rules for this agent
|
|
645
|
-
print(brief.inferred_task_type) # e.g. "research", "verification"
|
|
646
|
-
|
|
647
|
-
for entry in brief.working_memory:
|
|
648
|
-
print(f"{entry.entity_key}: {entry.summary}")
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
---
|
|
652
|
-
|
|
653
|
-
## CrewAI Integration
|
|
654
|
-
|
|
655
|
-
Minimal working example based on validated experiments:
|
|
656
|
-
|
|
657
|
-
```python
|
|
658
|
-
from crewai import Agent, Task, Crew, LLM
|
|
659
|
-
from crewai.tools import tool
|
|
660
|
-
from clients.python.iranti import IrantiClient
|
|
661
|
-
|
|
662
|
-
iranti = IrantiClient(base_url="http://localhost:3001", api_key="your_key")
|
|
663
|
-
ENTITY = "project/my_project"
|
|
664
|
-
|
|
665
|
-
@tool("Write finding to shared memory")
|
|
666
|
-
def write_finding(key: str, value: str, summary: str, confidence: int) -> str:
|
|
667
|
-
"""Write a fact to Iranti so other agents can access it."""
|
|
668
|
-
result = iranti.write(
|
|
669
|
-
entity=ENTITY,
|
|
670
|
-
key=key,
|
|
671
|
-
value={"data": value},
|
|
672
|
-
summary=summary,
|
|
673
|
-
confidence=confidence,
|
|
674
|
-
source="briefing_doc",
|
|
675
|
-
agent="researcher_agent"
|
|
676
|
-
)
|
|
677
|
-
return f"Saved '{key}': {result.action}"
|
|
678
|
-
|
|
679
|
-
@tool("Get all findings")
|
|
680
|
-
def get_all_findings() -> str:
|
|
681
|
-
"""Load all facts from Iranti."""
|
|
682
|
-
facts = iranti.query_all(ENTITY)
|
|
683
|
-
if not facts:
|
|
684
|
-
return "No findings in shared memory."
|
|
685
|
-
lines = [f"[{f['key']}] {f['summary']} (confidence: {f['confidence']})" for f in facts]
|
|
686
|
-
return "\n".join(lines)
|
|
687
|
-
|
|
688
|
-
# Researcher agent: writes to Iranti
|
|
689
|
-
researcher = Agent(
|
|
690
|
-
role="Research Analyst",
|
|
691
|
-
goal="Extract facts from documents and save to shared memory",
|
|
692
|
-
tools=[write_finding],
|
|
693
|
-
llm=LLM(model="gpt-4o-mini")
|
|
694
|
-
)
|
|
695
|
-
|
|
696
|
-
# Analyst agent: reads from Iranti
|
|
697
|
-
analyst = Agent(
|
|
698
|
-
role="Project Analyst",
|
|
699
|
-
goal="Summarize projects using shared memory",
|
|
700
|
-
tools=[get_all_findings],
|
|
701
|
-
llm=LLM(model="gpt-4o-mini")
|
|
702
|
-
)
|
|
703
|
-
|
|
704
|
-
# Researcher extracts facts, analyst loads them — no direct communication needed
|
|
705
|
-
crew = Crew(agents=[researcher, analyst], tasks=[...])
|
|
706
|
-
crew.kickoff()
|
|
707
|
-
```
|
|
708
|
-
|
|
709
|
-
**Result**: Analyst successfully loads all facts written by researcher (validated 6/6 transfer rate).
|
|
710
|
-
|
|
711
|
-
---
|
|
712
|
-
|
|
713
|
-
## Middleware for Any LLM
|
|
714
|
-
|
|
715
|
-
Add Iranti memory to Claude, ChatGPT, or any LLM via API wrapper:
|
|
716
|
-
|
|
717
|
-
```python
|
|
718
|
-
from clients.middleware.iranti_middleware import IrantiMiddleware
|
|
719
|
-
|
|
720
|
-
middleware = IrantiMiddleware(
|
|
721
|
-
agent_id="my_agent",
|
|
722
|
-
iranti_url="http://localhost:3001"
|
|
723
|
-
)
|
|
724
|
-
|
|
725
|
-
# Before sending to LLM
|
|
726
|
-
augmented = middleware.before_send(
|
|
727
|
-
user_message="What was the blocker?",
|
|
728
|
-
conversation_history=[...]
|
|
729
|
-
)
|
|
730
|
-
|
|
731
|
-
# After receiving response
|
|
732
|
-
middleware.after_receive(
|
|
733
|
-
response="The blocker is...",
|
|
734
|
-
conversation_history=[...]
|
|
735
|
-
)
|
|
736
|
-
```
|
|
737
|
-
|
|
738
|
-
**How it works**:
|
|
739
|
-
1. `before_send()` calls `attend()` with conversation context
|
|
740
|
-
2. Forgotten facts are prepended as `[MEMORY: ...]`
|
|
741
|
-
3. `after_receive()` extracts new facts and saves them (best-effort)
|
|
742
|
-
4. If the host skips `handshake()` or `attend()`, discovery calls block instead of returning warn-only metadata
|
|
743
|
-
|
|
744
|
-
**Note**: Browser extensions are blocked by ChatGPT and Claude's Content Security Policy. Use API-based middleware instead.
|
|
745
|
-
|
|
746
|
-
**Examples**: [`clients/middleware/claude_example.py`](clients/middleware/claude_example.py)
|
|
747
|
-
|
|
748
|
-
---
|
|
749
|
-
|
|
750
|
-
## Architecture
|
|
751
|
-
|
|
752
|
-
Iranti has five internal components:
|
|
753
|
-
|
|
754
|
-
| Component | Role |
|
|
755
|
-
|---|---|
|
|
756
|
-
| **Library** | PostgreSQL knowledge base. Current truth lives in `knowledge_base`; closed and contested intervals live in `archive`. |
|
|
757
|
-
| **Librarian** | Manages all writes. Detects conflicts, reasons about resolution, escalates when uncertain. |
|
|
758
|
-
| **Attendant** | Per-agent working memory manager. Implements `attend()`, `observe()`, and `handshake()` APIs. |
|
|
759
|
-
| **Archivist** | Periodic cleanup. Archives expired and low-confidence entries. Processes human-resolved conflicts. |
|
|
760
|
-
| **Resolutionist** | Interactive CLI helper that walks pending escalation files, writes `AUTHORITATIVE_JSON`, and marks them resolved for the Archivist. |
|
|
761
|
-
|
|
762
|
-
### REST API
|
|
763
|
-
|
|
764
|
-
Express server on port 3001 with endpoints:
|
|
765
|
-
|
|
766
|
-
- `POST /kb/write` - Write atomic fact
|
|
767
|
-
- `POST /kb/ingest` - Ingest raw text for one entity, auto-chunk into facts with per-fact confidence and per-fact write outcomes
|
|
768
|
-
- `GET /kb/query/:entityType/:entityId/:key` - Query specific fact
|
|
769
|
-
- `GET /kb/query/:entityType/:entityId` - Query all facts for entity
|
|
770
|
-
- `GET /kb/search` - Hybrid search across facts
|
|
771
|
-
- `POST /memory/attend` - Decide whether to inject memory for this turn and unlock one discovery step for the current turn
|
|
772
|
-
- `POST /memory/observe` - Context persistence (inject missing facts)
|
|
773
|
-
- `POST /memory/handshake` - Working memory brief for agent session
|
|
774
|
-
- `GET /memory/ledger` - Read structured session ledger events from `staff_events`
|
|
775
|
-
- `GET /memory/sessions` - List persisted operator-visible session checkpoints across agents, with optional operator filters/sorting
|
|
776
|
-
- `GET /memory/session/:agentId` - Inspect the current persisted session checkpoint/recovery state
|
|
777
|
-
- `POST /kb/relate` - Create entity relationship
|
|
778
|
-
- `GET /kb/related/:entityType/:entityId` - Get related entities
|
|
779
|
-
- `POST /agents/register` - Register agent in registry
|
|
780
|
-
|
|
781
|
-
All endpoints require `X-Iranti-Key` header for authentication.
|
|
782
|
-
Discovery endpoints return `428 Precondition Required` when a host skips the required session `handshake` or current-turn `attend`.
|
|
783
|
-
|
|
784
|
-
---
|
|
785
|
-
|
|
786
|
-
## Schema
|
|
787
|
-
|
|
788
|
-
Six PostgreSQL tables:
|
|
789
|
-
|
|
790
|
-
```
|
|
791
|
-
knowledge_base - current truth (one live row per entity/key)
|
|
792
|
-
archive - temporal and provenance history for superseded, contradicted, escalated, and expired rows
|
|
793
|
-
entity_relationships - directional graph: MEMBER_OF, PART_OF, AUTHORED, etc.
|
|
794
|
-
entities - canonical entity identity registry
|
|
795
|
-
entity_aliases - normalized aliases mapped to canonical entities
|
|
796
|
-
write_receipts - idempotency receipts for requestId replay safety
|
|
797
|
-
```
|
|
798
|
-
|
|
799
|
-
New entity types, relationship types, and fact keys do not require migrations; they are caller-defined strings.
|
|
800
|
-
|
|
801
|
-
**Archive semantics**: When a current fact is superseded or contested, the current row is removed from `knowledge_base` and a closed historical interval is written to `archive`. Temporal queries use `validFrom` / `validUntil` plus archive metadata to answer point-in-time reads.
|
|
802
|
-
|
|
803
|
-
---
|
|
804
|
-
|
|
805
|
-
## Running Tests
|
|
806
|
-
|
|
807
|
-
```bash
|
|
808
|
-
npm run test:integration # Full end-to-end
|
|
809
|
-
npm run test:librarian # Conflict resolution
|
|
810
|
-
npm run test:attendant # Working memory
|
|
811
|
-
npm run test:reliability # Source scoring
|
|
812
|
-
|
|
813
|
-
# Python validation experiments
|
|
814
|
-
cd clients/experiments
|
|
815
|
-
python validate_nexus_observe.py # Context persistence
|
|
816
|
-
python validate_nexus_treatment.py # Cross-agent transfer
|
|
817
|
-
```
|
|
818
|
-
|
|
819
|
-
---
|
|
820
|
-
|
|
821
|
-
## Contributing
|
|
822
|
-
|
|
823
|
-
Contributions welcome! Please:
|
|
824
|
-
|
|
825
|
-
1. Fork the repository
|
|
826
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
827
|
-
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
828
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
829
|
-
5. Open a Pull Request
|
|
830
|
-
|
|
831
|
-
---
|
|
832
|
-
|
|
833
|
-
## License
|
|
834
|
-
|
|
835
|
-
GNU Affero General Public License v3.0 (AGPL-3.0) - see [LICENSE](LICENSE) file for details.
|
|
836
|
-
|
|
837
|
-
Free to use, modify, and distribute under AGPL terms. If you offer Iranti as a hosted service and modify it, AGPL requires publishing those modifications.
|
|
838
|
-
|
|
839
|
-
---
|
|
840
|
-
|
|
841
|
-
## Name
|
|
842
|
-
|
|
843
|
-
Iranti is the Yoruba word for memory and remembrance.
|
|
844
|
-
|
|
845
|
-
---
|
|
846
|
-
|
|
847
|
-
## Project Structure
|
|
848
|
-
|
|
849
|
-
```
|
|
850
|
-
src/
|
|
851
|
-
├── library/ — DB client, queries, relationships, agent registry
|
|
852
|
-
├── librarian/ — Write logic, conflict resolution, reliability
|
|
853
|
-
├── attendant/ — Per-agent working memory, observe() implementation
|
|
854
|
-
├── archivist/ — Periodic cleanup, escalation processing
|
|
855
|
-
├── lib/ — LLM abstraction, model router, providers
|
|
856
|
-
├── sdk/ — Public TypeScript API
|
|
857
|
-
└── api/ — REST API server
|
|
858
|
-
|
|
859
|
-
clients/
|
|
860
|
-
├── python/ — Python client (IrantiClient)
|
|
861
|
-
├── middleware/ — LLM conversation wrappers (Claude, ChatGPT, etc.)
|
|
862
|
-
└── experiments/ — Validated experiments with real results
|
|
863
|
-
|
|
864
|
-
docs/
|
|
865
|
-
└── internal/validation_results.md — Full experiment outputs and analysis
|
|
866
|
-
```
|
|
867
|
-
|
|
868
|
-
---
|
|
869
|
-
|
|
870
|
-
## Support
|
|
871
|
-
|
|
872
|
-
- **Issues**: [GitHub Issues](https://github.com/nfemmanuel/iranti/issues)
|
|
873
|
-
- **Discussions**: [GitHub Discussions](https://github.com/nfemmanuel/iranti/discussions)
|
|
874
|
-
- **Email**: oluwaniifemi.emmanuel@uni.minerva.edu
|
|
875
|
-
- **Changelog**: [`CHANGELOG.md`](CHANGELOG.md)
|
|
876
|
-
|
|
877
|
-
---
|
|
878
|
-
|
|
879
|
-
**Built with ❤️ for the multi-agent AI community.**
|
|
880
|
-
|
|
63
|
+
- **Conflict handling**: Reliable when confidence differentials are large and explicit.
|
|
64
|
+
- **Relationship traversal and multi-agent coordination**: Relationship writes plus one-hop/deep traversal work, and agents can share memory across genuine subprocess boundaries with zero shared conversational context.
|
|
65
|
+
- **Provenance on writes**: Write-side attribution through stored source metadata is working and benchmark-confirmed.
|
|
66
|
+
- **Ingest**: Prose extraction is accurate on clean entities in the bounded rerun surfaces already documented.
|
|
67
|
+
- **Observe with hints / explicit recovery**: `iranti_observe` with hints and explicit query-based recovery are meaningfully useful today.
|
|
68
|
+
- **Protocol enforcement turn-gate**: Strict turn-cycle enforcement (handshake → attend → discover → post-response) is validated by focused route and MCP regression tests. In `strict` mode, KB discovery routes return HTTP 428 with a structured violation payload before an agent that skipped attend can silently read stale memory. Injected facts now include a `lastUpdated` timestamp so the calling agent can judge freshness at the point of injection.
|
|
69
|
+
|
|
70
|
+
Recent fixes since the last rerun:
|
|
71
|
+
- **Search now bridges semantic hits across relationships for filtered retrieval.** A strong incident or issue hit can now propagate back onto the owning filtered entity over up to two hops, so filtered project search no longer depends on direct lexical overlap alone.
|
|
72
|
+
- **`iranti_attend` now safe-defaults parse failures toward memory on non-greeting turns.** Terse prompts such as `help`, `why?`, or `how?` no longer silently fall through to `classification_parse_failed_default_false`.
|
|
73
|
+
- **Hybrid search now indexes entity addresses directly.** Addressed queries such as `project/<id> status` no longer rely on value-summary overlap alone.
|
|
74
|
+
|
|
75
|
+
### Current Limits
|
|
76
|
+
|
|
77
|
+
- **Upgrade durability is now test-covered.** The `v0.2.21` upgrade reinitialized the instance under test — a one-time operator incident, not a systemic design flaw. All Prisma migrations are additive (no DROP or TRUNCATE); Staff Namespace seeding is guarded by `isSeeded()`; `seed-codebase.ts` upserts to `codebase/*` entities only. A KB preservation test in `tests/runtime-lifecycle/run_setup_upgrade_tests.ts` now confirms user KB data written before a `setup` re-run survives intact.
|
|
78
|
+
- **Project learning is now only a bounded bind-time snapshot.** When you bind a project, Iranti derives a stable `IRANTI_CODEBASE_ENTITY` and writes a small snapshot from authoritative files such as `package.json`, `README.md`, `tsconfig.json`, `pyproject.toml`, `prisma/schema.prisma`, and common source directories. It does not yet crawl the repo continuously or build autonomous whole-project understanding.
|
|
79
|
+
- **Relationship and provenance reflection surfaces remain partially permission-gated in benchmark sessions.** The rerun did not prove `iranti_relate`, `iranti_related`, `iranti_related_deep`, or `iranti_who_knows` end-to-end under the benchmark session policy.
|
|
80
|
+
|
|
81
|
+
### Practical Position
|
|
82
|
+
|
|
83
|
+
Iranti is strongest today as **structured memory infrastructure for multi-agent systems**:
|
|
84
|
+
- exact entity/key lookup
|
|
85
|
+
- durable shared memory
|
|
86
|
+
- provenance-aware writes with source attribution and freshness timestamps
|
|
87
|
+
- conflict-aware storage
|
|
88
|
+
- session-aware recovery
|
|
89
|
+
- protocol-enforced turn discipline for trustworthy injection (opt-in strict mode)
|
|
90
|
+
|
|
91
|
+
It should not yet be described as a fully general semantic-memory, semantic-search, or autonomous-memory-injection system.
|
|
92
|
+
|
|
93
|
+
Historical benchmark material remains available here:
|
|
94
|
+
- [`docs/internal/validation_results.md`](docs/internal/validation_results.md)
|
|
95
|
+
- [`docs/internal/MULTI_FRAMEWORK_VALIDATION.md`](docs/internal/MULTI_FRAMEWORK_VALIDATION.md)
|
|
96
|
+
- [`docs/internal/conflict_benchmark.md`](docs/internal/conflict_benchmark.md)
|
|
97
|
+
- [`docs/internal/consistency_model.md`](docs/internal/consistency_model.md)
|
|
98
|
+
|
|
99
|
+
## Gap Analysis
|
|
100
|
+
|
|
101
|
+
Iranti targets a specific gap in the agent infrastructure stack: most competing systems give you semantic retrieval, framework-specific memory, or raw vector storage, but not the same combination of structured fact storage, cross-agent sharing, identity-based lookup, explicit confidence, and developer-visible conflict handling in one self-hostable package.
|
|
102
|
+
|
|
103
|
+
The current competitive case for Iranti is strongest when a team needs memory that behaves more like shared infrastructure than a chat transcript: facts are attached to entities, retrieved deterministically by `entityType/entityId + key`, versioned over time, and made available across agents without framework lock-in.
|
|
104
|
+
|
|
105
|
+
### Where Iranti Is Differentiated
|
|
106
|
+
|
|
107
|
+
- Identity-first fact retrieval through `entityType/entityId + key`
|
|
108
|
+
- Cross-agent fact sharing as a first-class model
|
|
109
|
+
- Conflict-aware writes through the Librarian
|
|
110
|
+
- Explicit per-fact confidence scores
|
|
111
|
+
- Per-agent memory injection through the Attendant
|
|
112
|
+
- Temporal exact lookup with `asOf` and ordered `history()`
|
|
113
|
+
- Relationship primitives through `relate()`, `getRelated()`, and `getRelatedDeep()` at the product surface, with benchmark confirmation for those MCP-accessible paths still pending
|
|
114
|
+
- Hybrid retrieval when exact keys are unknown
|
|
115
|
+
- Local install + project binding flow for Claude Code and Codex
|
|
116
|
+
- Published npm / PyPI surfaces with machine-level CLI setup
|
|
117
|
+
|
|
118
|
+
### Why That Gap Exists
|
|
119
|
+
|
|
120
|
+
The current landscape splits into three buckets:
|
|
121
|
+
|
|
122
|
+
1. **Memory libraries**
|
|
123
|
+
- Systems like Mem0, Zep, Letta, and framework-native memory layers solve parts of the problem.
|
|
124
|
+
- They usually optimize for semantic retrieval, agent-local memory, or framework integration.
|
|
125
|
+
- They rarely expose deterministic `entity + key` lookup, explicit confidence surfaces, and developer-controlled conflict handling together.
|
|
126
|
+
|
|
127
|
+
2. **Vector databases**
|
|
128
|
+
- Pinecone, Weaviate, Qdrant, Chroma, Milvus, LanceDB, and `pgvector` solve storage and retrieval infrastructure.
|
|
129
|
+
- They do not, by themselves, solve memory semantics such as conflict resolution, context injection, fact lifecycle, or shared agent-facing state.
|
|
130
|
+
|
|
131
|
+
3. **Multi-agent frameworks**
|
|
132
|
+
- CrewAI, LangGraph, AutoGen, CAMEL, MetaGPT, and similar frameworks often include some memory support.
|
|
133
|
+
- In practice, that memory is usually framework-coupled, shallow on conflict semantics, and difficult to reuse outside the framework that created it.
|
|
134
|
+
|
|
135
|
+
### Main Gaps
|
|
136
|
+
|
|
137
|
+
1. **Operational maturity**
|
|
138
|
+
- Local PostgreSQL setup is still a real source of friction.
|
|
139
|
+
- The product needs stronger diagnostics, connection recovery, and less dependence on users debugging local database state by hand.
|
|
140
|
+
|
|
141
|
+
2. **Onboarding still has sharp edges**
|
|
142
|
+
- `iranti setup` is materially better than before, but first-run still assumes too much infrastructure literacy.
|
|
143
|
+
- Managed Postgres paths, cleaner bootstrap verification, and fewer environment-level surprises are still needed.
|
|
144
|
+
|
|
145
|
+
3. **No operator UI yet**
|
|
146
|
+
- Iranti is still CLI-first.
|
|
147
|
+
- There is no control plane yet for provider keys, project bindings, integrations, memory inspection, and escalation review.
|
|
148
|
+
|
|
149
|
+
4. **Adoption proof is still early**
|
|
150
|
+
- The repo has validation experiments and real local end-to-end usage, but broad production adoption is still limited.
|
|
151
|
+
- The next product truth has to come from external users and real workloads, not more speculative architecture alone.
|
|
152
|
+
|
|
153
|
+
5. **Hosted product is not built**
|
|
154
|
+
- Open-source/local infrastructure is the active surface today.
|
|
155
|
+
- Hosted deployment, multi-tenant operations, billing, and cloud onboarding remain future work.
|
|
156
|
+
|
|
157
|
+
6. **Graph-native reasoning is still limited**
|
|
158
|
+
- Iranti supports explicit entity relationships today.
|
|
159
|
+
- It does not yet compete with graph-first systems on temporal graph traversal or graph-native reasoning depth.
|
|
160
|
+
|
|
161
|
+
7. **Memory extraction is not the main model**
|
|
162
|
+
- Iranti supports structured writes and ingest/chunking, but it is not primarily a "dump arbitrary conversations in and auto-magically derive perfect memory" system.
|
|
163
|
+
- That is a deliberate tradeoff in favor of explicit, inspectable facts, but it increases integration work.
|
|
164
|
+
|
|
165
|
+
### Current Position
|
|
166
|
+
|
|
167
|
+
Iranti is strongest today as infrastructure for developers building multi-agent systems who need shared, structured, queryable memory rather than pure semantic recall. The current benchmark base now supports a more concrete product claim:
|
|
168
|
+
|
|
169
|
+
- exact cross-agent fact transfer works at meaningful context scales
|
|
170
|
+
- facts survive session loss and genuine process breaks
|
|
171
|
+
- same-key conflicting writes are serialized and observable
|
|
172
|
+
- prose ingest is accurate on clean entities
|
|
173
|
+
- attended recovery works with explicit hints, while autonomous attend classification remains a known defect
|
|
174
|
+
|
|
175
|
+
That is still not a claim that multi-agent memory is solved. It is a claim that Iranti now has broader evidence for durable, structured, attribution-aware memory with exact retrieval and bounded recovery behavior.
|
|
176
|
+
|
|
177
|
+
The next leverage is still product simplicity: setup, operations, and day-to-day inspection need to be simple enough that real users keep Iranti in the loop.
|
|
178
|
+
|
|
179
|
+
## Quickstart
|
|
180
|
+
|
|
181
|
+
**Requirements**: Node.js 18+, PostgreSQL with pgvector support, Python 3.8+
|
|
182
|
+
|
|
183
|
+
Docker is optional. It is one local way to run PostgreSQL if you do not already have a database. Iranti still requires PostgreSQL; the setup improvement is smarter bootstrap and clearer guidance, not a second storage backend.
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# 1. Install the CLI
|
|
187
|
+
npm install -g iranti
|
|
188
|
+
|
|
189
|
+
# 2. Run the guided setup
|
|
190
|
+
iranti setup
|
|
191
|
+
|
|
192
|
+
# 3. Start the instance
|
|
193
|
+
iranti run --instance local
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
`iranti setup` now defaults to an isolated per-project runtime. Shared machine-level instances are still supported, but they are now an explicit choice rather than the default.
|
|
197
|
+
|
|
198
|
+
If local PostgreSQL is available and pgvector-capable, setup can bootstrap a localhost database for you. If Docker is available, setup now prefers the Docker path over a plain local listener because it guarantees pgvector. If local PostgreSQL is reachable but does not provide pgvector, setup now fails early with a direct action path instead of a late Prisma migration error.
|
|
199
|
+
|
|
200
|
+
Long-running agents can now checkpoint and recover interrupted work. Programmatic session lifecycle methods are available through the SDK and REST API:
|
|
201
|
+
- `checkpoint()`
|
|
202
|
+
- `inspectSession()`
|
|
203
|
+
- `listSessions()`
|
|
204
|
+
- `resumeSession()`
|
|
205
|
+
- `completeSession()`
|
|
206
|
+
- `abandonSession()`
|
|
207
|
+
|
|
208
|
+
Running instances now publish runtime metadata in `/health`, and the CLI can see that state through `iranti status`, `iranti instance show`, and `iranti upgrade --check`. When you want an installed upgrade to immediately take effect on an instance-backed API server, use:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
iranti upgrade --restart --instance local
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
If something still fails and you need more detail, use:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
iranti doctor --debug
|
|
218
|
+
iranti run --instance local --debug
|
|
219
|
+
iranti upgrade --verbose
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
If you want to remove Iranti cleanly:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
iranti uninstall --dry-run
|
|
226
|
+
iranti uninstall --all --yes
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Default uninstall keeps runtime data and project bindings. `--all` removes discovered runtime roots plus project-local Iranti integrations.
|
|
230
|
+
|
|
231
|
+
Advanced/manual path:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# 1. Clone and configure
|
|
235
|
+
git clone https://github.com/nfemmanuel/iranti
|
|
236
|
+
cd iranti
|
|
237
|
+
cp .env.example .env # Set DATABASE_URL and IRANTI_API_KEY
|
|
238
|
+
|
|
239
|
+
# Optional runtime hygiene
|
|
240
|
+
# IRANTI_ESCALATION_DIR=C:/Users/<you>/.iranti/escalation
|
|
241
|
+
# IRANTI_ARCHIVIST_WATCH=true
|
|
242
|
+
# IRANTI_ARCHIVIST_DEBOUNCE_MS=60000
|
|
243
|
+
# IRANTI_ARCHIVIST_INTERVAL_MS=21600000
|
|
244
|
+
|
|
245
|
+
# 2. Start PostgreSQL
|
|
246
|
+
docker-compose up -d
|
|
247
|
+
|
|
248
|
+
# 3. Install and initialize
|
|
249
|
+
npm install
|
|
250
|
+
npm run setup # Runs migrations
|
|
251
|
+
|
|
252
|
+
# 4. Start API server
|
|
253
|
+
npm run api # Runs on port 3001
|
|
254
|
+
|
|
255
|
+
# 5. Install Python client
|
|
256
|
+
pip install iranti
|
|
257
|
+
|
|
258
|
+
# Optional: install the TypeScript client
|
|
259
|
+
npm install @iranti/sdk
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Archivist Scheduling Knobs
|
|
263
|
+
|
|
264
|
+
- `IRANTI_ARCHIVIST_WATCH=true` enables file-change watching on escalation `active/`.
|
|
265
|
+
- `IRANTI_ARCHIVIST_DEBOUNCE_MS=60000` runs maintenance 60s after the latest file change.
|
|
266
|
+
- `IRANTI_ARCHIVIST_INTERVAL_MS=21600000` runs maintenance every 6 hours (set `0` to disable).
|
|
267
|
+
- `IRANTI_ESCALATION_DIR` sets escalation storage root. Default is `~/.iranti/escalation`, keeping escalation files out of the repo by default.
|
|
268
|
+
|
|
269
|
+
### Per-User API Keys (Recommended)
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Create a key for one user/app (prints token once)
|
|
273
|
+
npm run api-key:create -- --key-id chatbot_alice --owner "Alice chatbot" --scopes "kb:read,kb:write,memory:read,memory:write,agents:read,agents:write"
|
|
274
|
+
|
|
275
|
+
# List keys
|
|
276
|
+
npm run api-key:list
|
|
277
|
+
|
|
278
|
+
# Revoke a key
|
|
279
|
+
npm run api-key:revoke -- --key-id chatbot_alice
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Use the printed token (`keyId.secret`) as `X-Iranti-Key`.
|
|
283
|
+
Scopes use `resource:action` format (for example `kb:read`, `memory:write`, `metrics:read`, `proxy:chat`).
|
|
284
|
+
|
|
285
|
+
### Security Baseline
|
|
286
|
+
|
|
287
|
+
- Use one scoped key per app/service identity.
|
|
288
|
+
- Rotate any key that is exposed in logs, screenshots, or chat.
|
|
289
|
+
- Keep escalation/log paths outside the repo working tree.
|
|
290
|
+
- Use TLS/reverse proxy for non-local deployments.
|
|
291
|
+
|
|
292
|
+
Security quickstart: [`docs/guides/security-quickstart.md`](docs/guides/security-quickstart.md)
|
|
293
|
+
Operator manual: [`docs/guides/manual.md`](docs/guides/manual.md)
|
|
294
|
+
Claude Code guide: [`docs/guides/claude-code.md`](docs/guides/claude-code.md)
|
|
295
|
+
Codex guide: [`docs/guides/codex.md`](docs/guides/codex.md)
|
|
296
|
+
Release guide: [`docs/guides/releasing.md`](docs/guides/releasing.md)
|
|
297
|
+
Vector backend guide: [`docs/guides/vector-backends.md`](docs/guides/vector-backends.md)
|
|
298
|
+
|
|
299
|
+
### Claude Code via MCP
|
|
300
|
+
|
|
301
|
+
Iranti ships a local stdio MCP server for Claude Code and other MCP clients:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
iranti mcp
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Use it with a project-local `.mcp.json`, and optionally add `iranti claude-hook` for `SessionStart` and `UserPromptSubmit`.
|
|
308
|
+
|
|
309
|
+
Fast path:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
iranti claude-setup
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Guide: [`docs/guides/claude-code.md`](docs/guides/claude-code.md)
|
|
316
|
+
|
|
317
|
+
### Codex via MCP
|
|
318
|
+
|
|
319
|
+
Codex uses a global MCP registry rather than a project-local `.mcp.json`. Register Iranti once, then launch Codex in the bound project so `.env.iranti` is in scope:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
iranti codex-setup
|
|
323
|
+
codex -C /path/to/your/project
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
By default, `iranti codex-setup` does not pin a project binding globally. `iranti mcp` resolves `.env.iranti` from the active project/workspace at runtime. Use `--project-env` only if you deliberately want to pin Codex globally to one project binding.
|
|
327
|
+
|
|
328
|
+
Alias:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
iranti integrate codex
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Guide: [`docs/guides/codex.md`](docs/guides/codex.md)
|
|
335
|
+
|
|
336
|
+
### Resolve Pending Escalations
|
|
337
|
+
|
|
338
|
+
Review unresolved human-escalation files from the CLI:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
iranti resolve
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Use `--dir` to point at a non-default escalation root. Guide: [`docs/guides/conflict-resolution.md`](docs/guides/conflict-resolution.md)
|
|
345
|
+
|
|
346
|
+
### Native Chat
|
|
347
|
+
|
|
348
|
+
Start a CLI chat session against the configured Iranti instance:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
iranti chat
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Use `--agent`, `--provider`, and `--model` to pin the session identity and model routing.
|
|
355
|
+
The chat surface now includes slash commands for fact history, relationships, conflict-resolution handoff, and confidence updates in addition to memory search/write operations.
|
|
356
|
+
Guide: [`docs/guides/chat.md`](docs/guides/chat.md)
|
|
357
|
+
|
|
358
|
+
### Manual Attendant Inspection
|
|
359
|
+
|
|
360
|
+
For debugging and operator visibility, Iranti also exposes manual Attendant commands:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
iranti handshake --task "Working on ProofScript repo"
|
|
364
|
+
iranti attend "What did we decide about the parser?" --context-file transcript.txt
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Both commands accept `--json`.
|
|
368
|
+
They are useful for verifying what the Attendant would load or inject for a given agent and project binding.
|
|
369
|
+
They are not a replacement for Claude Code hooks or MCP tools in normal use.
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## Install Strategy (Double Layer)
|
|
374
|
+
|
|
375
|
+
Iranti now supports a two-layer install flow:
|
|
376
|
+
|
|
377
|
+
1. **Machine/runtime layer**: one local runtime root with one or more named Iranti instances.
|
|
378
|
+
2. **Project layer**: each chatbot/app binds to one instance with a local `.env.iranti`.
|
|
379
|
+
|
|
380
|
+
### 1) Install CLI
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# If published package is available
|
|
384
|
+
npm install -g iranti
|
|
385
|
+
|
|
386
|
+
# Or from this repo (local simulation)
|
|
387
|
+
npm install -g .
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### 2) Initialize machine runtime root
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
iranti setup
|
|
394
|
+
|
|
395
|
+
# non-interactive automation
|
|
396
|
+
iranti setup --defaults --db-url "postgresql://postgres:realpassword@localhost:5432/iranti_local"
|
|
397
|
+
iranti setup --config ./iranti.setup.json
|
|
398
|
+
|
|
399
|
+
# or, if you want the lower-level manual path:
|
|
400
|
+
iranti install --scope user
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
`iranti setup` is the recommended first-run path. It walks through:
|
|
404
|
+
- shared vs isolated runtime setup
|
|
405
|
+
- instance creation or update
|
|
406
|
+
- API port selection with conflict detection and next-free suggestions
|
|
407
|
+
- database onboarding:
|
|
408
|
+
- existing Postgres
|
|
409
|
+
- managed Postgres
|
|
410
|
+
- optional Docker-hosted Postgres for local development
|
|
411
|
+
- provider API keys
|
|
412
|
+
- Iranti client API key generation
|
|
413
|
+
- one or more project bindings
|
|
414
|
+
- optional Claude Code / Codex integration scaffolding
|
|
415
|
+
|
|
416
|
+
Operator-facing CLI help now includes short "what it does" and "use this when" guidance, so `iranti <command> --help` is the quickest way to choose the right entry point.
|
|
417
|
+
|
|
418
|
+
For automation:
|
|
419
|
+
- `iranti setup --defaults` uses sensible defaults plus environment/flag input, but still requires a real `DATABASE_URL`.
|
|
420
|
+
- `iranti setup --config <file>` reads a JSON setup plan for repeatable bootstrap.
|
|
421
|
+
- `--bootstrap-db` runs migrations and seeding during automated setup when the database is reachable.
|
|
422
|
+
- Example config: [docs/guides/iranti.setup.example.json](docs/guides/iranti.setup.example.json)
|
|
423
|
+
|
|
424
|
+
Default API port remains `3001`. The setup wizard now warns when that port is already in use and suggests the next free port instead of forcing users to debug the collision manually.
|
|
425
|
+
|
|
426
|
+
Defaults:
|
|
427
|
+
- Windows user scope: `%USERPROFILE%\\.iranti`
|
|
428
|
+
- Windows system scope: `%ProgramData%\\Iranti`
|
|
429
|
+
- Linux system scope: `/var/lib/iranti`
|
|
430
|
+
- macOS system scope: `/Library/Application Support/Iranti`
|
|
431
|
+
|
|
432
|
+
### 3) Create a named instance
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
iranti instance create local --port 3001 --db-url "postgresql://postgres:yourpassword@localhost:5432/iranti_local" --provider mock
|
|
436
|
+
iranti instance show local
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Finish onboarding or change settings later with:
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
# Provider/db updates
|
|
443
|
+
iranti configure instance local --provider openai --provider-key replace-with-real-openai-key --db-url "postgresql://postgres:realpassword@localhost:5432/iranti_local"
|
|
444
|
+
iranti configure instance local --interactive
|
|
445
|
+
|
|
446
|
+
# Provider key shortcuts
|
|
447
|
+
iranti list api-keys --instance local
|
|
448
|
+
iranti add api-key openai --instance local
|
|
449
|
+
iranti update api-key claude --instance local
|
|
450
|
+
iranti remove api-key gemini --instance local
|
|
451
|
+
|
|
452
|
+
# Create a registry-backed API key and sync it into the instance env
|
|
453
|
+
iranti auth create-key --instance local --key-id local_admin --owner "Local Admin" --scopes "kb:read,kb:write,memory:read,memory:write,agents:read,agents:write" --write-instance
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
`iranti add|update|remove api-key` updates the stored upstream provider credentials in the instance env without hand-editing `.env` files. `iranti list api-keys` shows which provider keys are currently stored. Supported remote providers are OpenAI, Claude, Gemini, Groq, and Mistral. `mock` and `ollama` do not require remote API keys, and Perplexity is not yet supported.
|
|
457
|
+
|
|
458
|
+
### 4) Run Iranti from that instance
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
iranti run --instance local
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
If a provider rejects requests because credits are exhausted, billing is disabled, or the account is quota-limited, Iranti now surfaces a direct message such as `OpenAI quota or billing limit reached. Add credits, update the API key, or switch providers.`
|
|
465
|
+
|
|
466
|
+
### 5) Bind any chatbot/app project to that instance
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
cd /path/to/your/chatbot
|
|
470
|
+
iranti project init . --instance local --agent-id chatbot_main
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
This writes `.env.iranti` in the project with the correct `IRANTI_URL`, `IRANTI_API_KEY`, and default agent identity.
|
|
474
|
+
It also writes a derived `IRANTI_CODEBASE_ENTITY` and a bounded initial project snapshot for that bound repo.
|
|
475
|
+
|
|
476
|
+
Later changes use the same surface:
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
iranti configure project . --instance local --agent-id chatbot_worker
|
|
480
|
+
iranti configure project . --interactive
|
|
481
|
+
iranti project unbind .
|
|
482
|
+
iranti auth create-key --instance local --key-id chatbot_worker --owner "Chatbot Worker" --scopes "kb:read,memory:read,memory:write" --project .
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
For multi-agent systems, bind once per project and set unique agent IDs per worker (for example `planner_agent`, `research_agent`, `critic_agent`).
|
|
486
|
+
|
|
487
|
+
### Installation Diagnostics
|
|
488
|
+
|
|
489
|
+
Use the CLI doctor command before first run or before a release check:
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
iranti doctor
|
|
493
|
+
iranti doctor --instance local
|
|
494
|
+
iranti status
|
|
495
|
+
iranti upgrade --check
|
|
496
|
+
iranti upgrade --dry-run
|
|
497
|
+
iranti upgrade --yes
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
This validates the active env file, database URL, API key presence, provider selection, and provider-specific credentials.
|
|
501
|
+
`iranti status` shows the current runtime root, known instances, and local binding files.
|
|
502
|
+
`iranti upgrade` detects repo/global/Python install paths, compares current vs latest published versions, prints the exact plan, and executes the selected upgrade path when you pass `--yes`.
|
|
503
|
+
On Windows, if the currently running CLI is itself the global npm install being upgraded, Iranti now hands that npm-global step off to a detached updater process instead of trying to replace the live binary in place.
|
|
504
|
+
`iranti configure ...` updates instance/project credentials without manual env editing.
|
|
505
|
+
`iranti auth ...` manages registry-backed API keys and can sync them into instance or project bindings.
|
|
506
|
+
When you pass `--root` in Windows `cmd.exe`, use no quotes or double quotes. Single quotes are treated literally there.
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## Core API
|
|
511
|
+
|
|
512
|
+
### Write a Fact
|
|
513
|
+
|
|
514
|
+
```python
|
|
515
|
+
from clients.python.iranti import IrantiClient
|
|
516
|
+
|
|
517
|
+
client = IrantiClient(
|
|
518
|
+
base_url="http://localhost:3001",
|
|
519
|
+
api_key="your_api_key_here"
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
result = client.write(
|
|
523
|
+
entity="researcher/jane_smith", # Format: entityType/entityId
|
|
524
|
+
key="affiliation",
|
|
525
|
+
value={"institution": "MIT", "department": "CSAIL"},
|
|
526
|
+
summary="Affiliated with MIT CSAIL", # Compressed for working memory
|
|
527
|
+
confidence=85, # 0-100
|
|
528
|
+
source="OpenAlex",
|
|
529
|
+
agent="research_agent_001"
|
|
530
|
+
)
|
|
531
|
+
|
|
532
|
+
print(result.action) # 'created', 'updated', 'escalated', or 'rejected'
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### Query a Fact
|
|
536
|
+
|
|
537
|
+
```python
|
|
538
|
+
result = client.query("researcher/jane_smith", "affiliation")
|
|
539
|
+
|
|
540
|
+
if result.found:
|
|
541
|
+
print(result.value) # {"institution": "MIT", "department": "CSAIL"}
|
|
542
|
+
print(result.confidence) # 85
|
|
543
|
+
print(result.source) # "OpenAlex"
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### Query All Facts for an Entity
|
|
547
|
+
|
|
548
|
+
```python
|
|
549
|
+
facts = client.query_all("researcher/jane_smith")
|
|
550
|
+
|
|
551
|
+
for fact in facts:
|
|
552
|
+
print(f"[{fact['key']}] {fact['summary']} (confidence: {fact['confidence']})")
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Graph Traversal
|
|
556
|
+
|
|
557
|
+
```python
|
|
558
|
+
from clients.python.iranti import IrantiClient
|
|
559
|
+
|
|
560
|
+
client = IrantiClient(base_url="http://localhost:3001", api_key="your_api_key_here")
|
|
561
|
+
|
|
562
|
+
# Agent 1 writes facts and links them into a graph.
|
|
563
|
+
client.write("researcher/jane_smith", "affiliation", {"lab": "CSAIL"}, "Jane Smith is affiliated with CSAIL", 90, "OpenAlex", "research_agent")
|
|
564
|
+
client.write("project/quantum_bridge", "status", {"phase": "active"}, "Quantum Bridge is active", 88, "project_brief", "research_agent")
|
|
565
|
+
|
|
566
|
+
client.relate("researcher/jane_smith", "MEMBER_OF", "lab/csail", created_by="research_agent")
|
|
567
|
+
client.relate("lab/csail", "LEADS", "project/quantum_bridge", created_by="research_agent")
|
|
568
|
+
|
|
569
|
+
# Agent 2 starts cold and traverses outward from Jane Smith.
|
|
570
|
+
one_hop = client.related("researcher/jane_smith")
|
|
571
|
+
labs = [f"{r['toType']}/{r['toId']}" for r in one_hop if r["relationshipType"] == "MEMBER_OF"]
|
|
572
|
+
|
|
573
|
+
projects = []
|
|
574
|
+
for lab in labs:
|
|
575
|
+
for rel in client.related(lab):
|
|
576
|
+
if rel["relationshipType"] == "LEADS":
|
|
577
|
+
project = f"{rel['toType']}/{rel['toId']}"
|
|
578
|
+
status = client.query(project, "status")
|
|
579
|
+
projects.append((project, status.value["phase"]))
|
|
580
|
+
|
|
581
|
+
print(projects)
|
|
582
|
+
# Agent 2 learned which project Jane Smith is connected to without being told the project directly.
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### Relationship Types
|
|
586
|
+
|
|
587
|
+
Relationship types are caller-defined strings. Common conventions:
|
|
588
|
+
|
|
589
|
+
| Relationship Type | Meaning |
|
|
590
|
+
|---|---|
|
|
591
|
+
| `MEMBER_OF` | Entity belongs to a team, lab, org, or group |
|
|
592
|
+
| `PART_OF` | Entity is a component or sub-unit of another entity |
|
|
593
|
+
| `AUTHORED` | Person or agent created a document, paper, or artifact |
|
|
594
|
+
| `LEADS` | Person, team, or org leads a project or effort |
|
|
595
|
+
| `DEPENDS_ON` | Project, service, or task depends on another entity |
|
|
596
|
+
| `REPORTS_TO` | Directed reporting relationship between people or agents |
|
|
597
|
+
|
|
598
|
+
Use uppercase snake case for consistency. Iranti does not enforce a fixed ontology here; the calling application owns the relationship vocabulary.
|
|
599
|
+
|
|
600
|
+
### Hybrid Search
|
|
601
|
+
|
|
602
|
+
```python
|
|
603
|
+
matches = client.search(
|
|
604
|
+
query="current blocker launch readiness",
|
|
605
|
+
entity_type="project",
|
|
606
|
+
limit=5,
|
|
607
|
+
lexical_weight=0.45,
|
|
608
|
+
vector_weight=0.55,
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
for item in matches:
|
|
612
|
+
print(item["entity"], item["key"], item["score"])
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
### Context Persistence (attend)
|
|
616
|
+
|
|
617
|
+
`handshake()` establishes the session contract. Discovery surfaces such as `query`, `search`, `get_related`, and `who_knows` are now fail-closed until the host has run `handshake()` for the session and `attend()` for the current turn. Starting a new `attend(phase="pre-response")` turn without first closing the previous one with `attend(phase="post-response")` is now blocked as a protocol violation, and `inspectSession()` / `listSessions()` expose structured lifecycle compliance state (`healthy`, `degraded`, `non_compliant`) so hosts and operators can see when breadcrumb discipline is slipping.
|
|
618
|
+
|
|
619
|
+
```python
|
|
620
|
+
# Before each LLM call, let Attendant decide if memory is needed
|
|
621
|
+
result = client.attend(
|
|
622
|
+
agent_id="research_agent_001",
|
|
623
|
+
latest_message="What's Jane Smith's current affiliation?",
|
|
624
|
+
current_context="User: What's Jane Smith's current affiliation?\nAssistant: Let me check...",
|
|
625
|
+
max_facts=5,
|
|
626
|
+
phase="pre-response"
|
|
627
|
+
)
|
|
628
|
+
|
|
629
|
+
if result["shouldInject"]:
|
|
630
|
+
for fact in result['facts']:
|
|
631
|
+
print(f"Inject: [{fact['entityKey']}] {fact['summary']}")
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
### Working Memory (handshake)
|
|
635
|
+
|
|
636
|
+
```python
|
|
637
|
+
# At session start, get personalized brief for agent's current task
|
|
638
|
+
brief = client.handshake(
|
|
639
|
+
agent_id="research_agent_001",
|
|
640
|
+
task="Research publication history for Dr. Jane Smith",
|
|
641
|
+
recent_messages=["Starting literature review..."]
|
|
642
|
+
)
|
|
643
|
+
|
|
644
|
+
print(brief.operating_rules) # Staff namespace rules for this agent
|
|
645
|
+
print(brief.inferred_task_type) # e.g. "research", "verification"
|
|
646
|
+
|
|
647
|
+
for entry in brief.working_memory:
|
|
648
|
+
print(f"{entry.entity_key}: {entry.summary}")
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
## CrewAI Integration
|
|
654
|
+
|
|
655
|
+
Minimal working example based on validated experiments:
|
|
656
|
+
|
|
657
|
+
```python
|
|
658
|
+
from crewai import Agent, Task, Crew, LLM
|
|
659
|
+
from crewai.tools import tool
|
|
660
|
+
from clients.python.iranti import IrantiClient
|
|
661
|
+
|
|
662
|
+
iranti = IrantiClient(base_url="http://localhost:3001", api_key="your_key")
|
|
663
|
+
ENTITY = "project/my_project"
|
|
664
|
+
|
|
665
|
+
@tool("Write finding to shared memory")
|
|
666
|
+
def write_finding(key: str, value: str, summary: str, confidence: int) -> str:
|
|
667
|
+
"""Write a fact to Iranti so other agents can access it."""
|
|
668
|
+
result = iranti.write(
|
|
669
|
+
entity=ENTITY,
|
|
670
|
+
key=key,
|
|
671
|
+
value={"data": value},
|
|
672
|
+
summary=summary,
|
|
673
|
+
confidence=confidence,
|
|
674
|
+
source="briefing_doc",
|
|
675
|
+
agent="researcher_agent"
|
|
676
|
+
)
|
|
677
|
+
return f"Saved '{key}': {result.action}"
|
|
678
|
+
|
|
679
|
+
@tool("Get all findings")
|
|
680
|
+
def get_all_findings() -> str:
|
|
681
|
+
"""Load all facts from Iranti."""
|
|
682
|
+
facts = iranti.query_all(ENTITY)
|
|
683
|
+
if not facts:
|
|
684
|
+
return "No findings in shared memory."
|
|
685
|
+
lines = [f"[{f['key']}] {f['summary']} (confidence: {f['confidence']})" for f in facts]
|
|
686
|
+
return "\n".join(lines)
|
|
687
|
+
|
|
688
|
+
# Researcher agent: writes to Iranti
|
|
689
|
+
researcher = Agent(
|
|
690
|
+
role="Research Analyst",
|
|
691
|
+
goal="Extract facts from documents and save to shared memory",
|
|
692
|
+
tools=[write_finding],
|
|
693
|
+
llm=LLM(model="gpt-4o-mini")
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
# Analyst agent: reads from Iranti
|
|
697
|
+
analyst = Agent(
|
|
698
|
+
role="Project Analyst",
|
|
699
|
+
goal="Summarize projects using shared memory",
|
|
700
|
+
tools=[get_all_findings],
|
|
701
|
+
llm=LLM(model="gpt-4o-mini")
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
# Researcher extracts facts, analyst loads them — no direct communication needed
|
|
705
|
+
crew = Crew(agents=[researcher, analyst], tasks=[...])
|
|
706
|
+
crew.kickoff()
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
**Result**: Analyst successfully loads all facts written by researcher (validated 6/6 transfer rate).
|
|
710
|
+
|
|
711
|
+
---
|
|
712
|
+
|
|
713
|
+
## Middleware for Any LLM
|
|
714
|
+
|
|
715
|
+
Add Iranti memory to Claude, ChatGPT, or any LLM via API wrapper:
|
|
716
|
+
|
|
717
|
+
```python
|
|
718
|
+
from clients.middleware.iranti_middleware import IrantiMiddleware
|
|
719
|
+
|
|
720
|
+
middleware = IrantiMiddleware(
|
|
721
|
+
agent_id="my_agent",
|
|
722
|
+
iranti_url="http://localhost:3001"
|
|
723
|
+
)
|
|
724
|
+
|
|
725
|
+
# Before sending to LLM
|
|
726
|
+
augmented = middleware.before_send(
|
|
727
|
+
user_message="What was the blocker?",
|
|
728
|
+
conversation_history=[...]
|
|
729
|
+
)
|
|
730
|
+
|
|
731
|
+
# After receiving response
|
|
732
|
+
middleware.after_receive(
|
|
733
|
+
response="The blocker is...",
|
|
734
|
+
conversation_history=[...]
|
|
735
|
+
)
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
**How it works**:
|
|
739
|
+
1. `before_send()` calls `attend()` with conversation context
|
|
740
|
+
2. Forgotten facts are prepended as `[MEMORY: ...]`
|
|
741
|
+
3. `after_receive()` extracts new facts and saves them (best-effort)
|
|
742
|
+
4. If the host skips `handshake()` or `attend()`, discovery calls block instead of returning warn-only metadata
|
|
743
|
+
|
|
744
|
+
**Note**: Browser extensions are blocked by ChatGPT and Claude's Content Security Policy. Use API-based middleware instead.
|
|
745
|
+
|
|
746
|
+
**Examples**: [`clients/middleware/claude_example.py`](clients/middleware/claude_example.py)
|
|
747
|
+
|
|
748
|
+
---
|
|
749
|
+
|
|
750
|
+
## Architecture
|
|
751
|
+
|
|
752
|
+
Iranti has five internal components:
|
|
753
|
+
|
|
754
|
+
| Component | Role |
|
|
755
|
+
|---|---|
|
|
756
|
+
| **Library** | PostgreSQL knowledge base. Current truth lives in `knowledge_base`; closed and contested intervals live in `archive`. |
|
|
757
|
+
| **Librarian** | Manages all writes. Detects conflicts, reasons about resolution, escalates when uncertain. |
|
|
758
|
+
| **Attendant** | Per-agent working memory manager. Implements `attend()`, `observe()`, and `handshake()` APIs. |
|
|
759
|
+
| **Archivist** | Periodic cleanup. Archives expired and low-confidence entries. Processes human-resolved conflicts. |
|
|
760
|
+
| **Resolutionist** | Interactive CLI helper that walks pending escalation files, writes `AUTHORITATIVE_JSON`, and marks them resolved for the Archivist. |
|
|
761
|
+
|
|
762
|
+
### REST API
|
|
763
|
+
|
|
764
|
+
Express server on port 3001 with endpoints:
|
|
765
|
+
|
|
766
|
+
- `POST /kb/write` - Write atomic fact
|
|
767
|
+
- `POST /kb/ingest` - Ingest raw text for one entity, auto-chunk into facts with per-fact confidence and per-fact write outcomes
|
|
768
|
+
- `GET /kb/query/:entityType/:entityId/:key` - Query specific fact
|
|
769
|
+
- `GET /kb/query/:entityType/:entityId` - Query all facts for entity
|
|
770
|
+
- `GET /kb/search` - Hybrid search across facts
|
|
771
|
+
- `POST /memory/attend` - Decide whether to inject memory for this turn and unlock one discovery step for the current turn
|
|
772
|
+
- `POST /memory/observe` - Context persistence (inject missing facts)
|
|
773
|
+
- `POST /memory/handshake` - Working memory brief for agent session
|
|
774
|
+
- `GET /memory/ledger` - Read structured session ledger events from `staff_events`
|
|
775
|
+
- `GET /memory/sessions` - List persisted operator-visible session checkpoints across agents, with optional operator filters/sorting
|
|
776
|
+
- `GET /memory/session/:agentId` - Inspect the current persisted session checkpoint/recovery state
|
|
777
|
+
- `POST /kb/relate` - Create entity relationship
|
|
778
|
+
- `GET /kb/related/:entityType/:entityId` - Get related entities
|
|
779
|
+
- `POST /agents/register` - Register agent in registry
|
|
780
|
+
|
|
781
|
+
All endpoints require `X-Iranti-Key` header for authentication.
|
|
782
|
+
Discovery endpoints return `428 Precondition Required` when a host skips the required session `handshake` or current-turn `attend`.
|
|
783
|
+
|
|
784
|
+
---
|
|
785
|
+
|
|
786
|
+
## Schema
|
|
787
|
+
|
|
788
|
+
Six PostgreSQL tables:
|
|
789
|
+
|
|
790
|
+
```
|
|
791
|
+
knowledge_base - current truth (one live row per entity/key)
|
|
792
|
+
archive - temporal and provenance history for superseded, contradicted, escalated, and expired rows
|
|
793
|
+
entity_relationships - directional graph: MEMBER_OF, PART_OF, AUTHORED, etc.
|
|
794
|
+
entities - canonical entity identity registry
|
|
795
|
+
entity_aliases - normalized aliases mapped to canonical entities
|
|
796
|
+
write_receipts - idempotency receipts for requestId replay safety
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
New entity types, relationship types, and fact keys do not require migrations; they are caller-defined strings.
|
|
800
|
+
|
|
801
|
+
**Archive semantics**: When a current fact is superseded or contested, the current row is removed from `knowledge_base` and a closed historical interval is written to `archive`. Temporal queries use `validFrom` / `validUntil` plus archive metadata to answer point-in-time reads.
|
|
802
|
+
|
|
803
|
+
---
|
|
804
|
+
|
|
805
|
+
## Running Tests
|
|
806
|
+
|
|
807
|
+
```bash
|
|
808
|
+
npm run test:integration # Full end-to-end
|
|
809
|
+
npm run test:librarian # Conflict resolution
|
|
810
|
+
npm run test:attendant # Working memory
|
|
811
|
+
npm run test:reliability # Source scoring
|
|
812
|
+
|
|
813
|
+
# Python validation experiments
|
|
814
|
+
cd clients/experiments
|
|
815
|
+
python validate_nexus_observe.py # Context persistence
|
|
816
|
+
python validate_nexus_treatment.py # Cross-agent transfer
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
## Contributing
|
|
822
|
+
|
|
823
|
+
Contributions welcome! Please:
|
|
824
|
+
|
|
825
|
+
1. Fork the repository
|
|
826
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
827
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
828
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
829
|
+
5. Open a Pull Request
|
|
830
|
+
|
|
831
|
+
---
|
|
832
|
+
|
|
833
|
+
## License
|
|
834
|
+
|
|
835
|
+
GNU Affero General Public License v3.0 (AGPL-3.0) - see [LICENSE](LICENSE) file for details.
|
|
836
|
+
|
|
837
|
+
Free to use, modify, and distribute under AGPL terms. If you offer Iranti as a hosted service and modify it, AGPL requires publishing those modifications.
|
|
838
|
+
|
|
839
|
+
---
|
|
840
|
+
|
|
841
|
+
## Name
|
|
842
|
+
|
|
843
|
+
Iranti is the Yoruba word for memory and remembrance.
|
|
844
|
+
|
|
845
|
+
---
|
|
846
|
+
|
|
847
|
+
## Project Structure
|
|
848
|
+
|
|
849
|
+
```
|
|
850
|
+
src/
|
|
851
|
+
├── library/ — DB client, queries, relationships, agent registry
|
|
852
|
+
├── librarian/ — Write logic, conflict resolution, reliability
|
|
853
|
+
├── attendant/ — Per-agent working memory, observe() implementation
|
|
854
|
+
├── archivist/ — Periodic cleanup, escalation processing
|
|
855
|
+
├── lib/ — LLM abstraction, model router, providers
|
|
856
|
+
├── sdk/ — Public TypeScript API
|
|
857
|
+
└── api/ — REST API server
|
|
858
|
+
|
|
859
|
+
clients/
|
|
860
|
+
├── python/ — Python client (IrantiClient)
|
|
861
|
+
├── middleware/ — LLM conversation wrappers (Claude, ChatGPT, etc.)
|
|
862
|
+
└── experiments/ — Validated experiments with real results
|
|
863
|
+
|
|
864
|
+
docs/
|
|
865
|
+
└── internal/validation_results.md — Full experiment outputs and analysis
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
---
|
|
869
|
+
|
|
870
|
+
## Support
|
|
871
|
+
|
|
872
|
+
- **Issues**: [GitHub Issues](https://github.com/nfemmanuel/iranti/issues)
|
|
873
|
+
- **Discussions**: [GitHub Discussions](https://github.com/nfemmanuel/iranti/discussions)
|
|
874
|
+
- **Email**: oluwaniifemi.emmanuel@uni.minerva.edu
|
|
875
|
+
- **Changelog**: [`CHANGELOG.md`](CHANGELOG.md)
|
|
876
|
+
|
|
877
|
+
---
|
|
878
|
+
|
|
879
|
+
**Built with ❤️ for the multi-agent AI community.**
|
|
880
|
+
|