Skip to content

Commit ab5bc2b

Browse files
committed
knowledge
1 parent bceb4a1 commit ab5bc2b

6 files changed

Lines changed: 102 additions & 31 deletions

File tree

rust/haiai/docs/knowledge/haiai-guides/agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ If you add a tool to MCP but not CLI (or vice versa), you must add it to the app
130130
Each SDK pins a published JACS version for CI/release, but supports local path overrides for development:
131131

132132
- **Node:** `npm run deps:local` switches `@hai.ai/jacs` to `file:../../JACS/jacsnpm`. Use `npm run deps:prod` to switch back. The committed `package.json` must always use the published version.
133-
- **Rust:** Uncomment the `[patch.crates-io]` block in `rust/Cargo.toml` to build against `../../JACS/`. Must be commented out before publish.
133+
- **Rust:** Uncomment the `[patch.crates-io]` block in `rust/Cargo.toml` to build against `../../JACS/`. Must be commented out before publish. Building with the patch block (even temporarily) adds `[[patch.unused]]` entries to `rust/Cargo.lock` — the git clean filter in `.gitattributes` strips these automatically on staging. **First-time setup:** run `git config filter.clean-cargo-lock.clean 'sed "/^\[\[patch\.unused\]\]/,/^$/d"'` and `git config filter.clean-cargo-lock.smudge cat` to activate the filter.
134134
- **Python:** Pin in `pyproject.toml` (`jacs==X.Y.Z`). For local dev, use `pip install -e ../../JACS/jacspy` (or equivalent) to shadow the published version.
135135

136136
`make check-jacs-versions` verifies all SDKs agree on the published JACS version.

rust/haiai/docs/knowledge/haiai-sdk/hai-mcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The server adds these tools on top of the base JACS MCP tools:
7474
| Tool | Description |
7575
|------|-------------|
7676
| `hai_create_agent` | Create a new JACS agent locally |
77-
| `hai_register_agent` | Register with HAI platform (accepts registration_key) |
77+
| `hai_register_agent` | Register with HAI platform |
7878
| `hai_hello` | Authenticated handshake |
7979
| `hai_agent_status` | Agent verification status |
8080
| `hai_verify_status` | Verification status lookup |

rust/haiai/docs/knowledge/haiai-sdk/haiai-cli.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ Options:
4141
| `--key-dir` | `./jacs_keys` | Key storage directory |
4242
| `--config-path` | `./jacs.config.json` | Config file path |
4343

44-
### 2. Register and get your email address
45-
46-
```bash
47-
haiai init --name myagent --key YOUR_REGISTRATION_KEY
48-
```
49-
50-
Get your registration key from the [dashboard](https://hai.ai/dashboard). Your agent now has the address `myagent@hai.ai`.
44+
Registration happens during `init` (see step 1). Your agent gets `myagent@hai.ai` automatically.
5145

5246
### 3. Send and receive email
5347

@@ -112,6 +106,11 @@ Connect it to any MCP client (Claude Desktop, Cursor, Claude Code, etc.):
112106
| `list-contacts` | List contacts from email history |
113107
| `email-status` | Account status and limits |
114108

109+
**Username**
110+
111+
| Command | Description |
112+
|---------|-------------|
113+
115114
**Benchmarking**
116115

117116
| Command | Description |

rust/haiai/docs/knowledge/haiai-sdk/root.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,37 @@ brew install haiai
2121
cargo install haiai-cli
2222
```
2323

24-
This gives you the `haiai` binary — CLI and MCP server in one.
25-
26-
## Quickstart
24+
### Shell script
2725

28-
### 1. Create an agent identity
26+
No package manager? The install script detects your platform, downloads the latest release from GitHub, verifies the SHA256 checksum, and installs to `~/.haiai/bin`. Handles upgrades and downgrades.
2927

3028
```bash
31-
export JACS_PRIVATE_KEY_PASSWORD='your-password'
29+
curl -fsSL https://raw.githubusercontent.com/HumanAssisted/haiai/main/install.sh | sh
30+
```
3231

33-
haiai init \
34-
--name my-agent \
35-
--domain example.com
32+
Pin a version or change the install directory:
33+
34+
```bash
35+
curl -fsSL https://raw.githubusercontent.com/HumanAssisted/haiai/main/install.sh | sh -s -- --version 0.2.1
36+
curl -fsSL https://raw.githubusercontent.com/HumanAssisted/haiai/main/install.sh | sh -s -- --dir /usr/local/bin
3637
```
3738

38-
This generates a JACS keypair and config. No separate install needed.
39+
Works on macOS (Intel & Apple Silicon) and Linux (x64 & ARM64).
3940

40-
### 2. Register and get your email address
41+
This gives you the `haiai` binary — CLI and MCP server in one.
42+
43+
## Quickstart
44+
45+
### 1. Create an agent identity
4146

4247
```bash
48+
export JACS_PRIVATE_KEY_PASSWORD='your-password'
49+
4350
haiai init --name myagent --key YOUR_REGISTRATION_KEY
4451
```
4552

46-
Get your registration key from the [dashboard](https://hai.ai/dashboard) after reserving your username. Your agent now has the address `myagent@hai.ai`.
53+
This generates a JACS keypair, registers with HAI, and assigns `myagent@hai.ai`.
54+
Get your registration key from the [dashboard](https://hai.ai/dashboard) after reserving a username.
4755

4856
### 3. Send and receive email
4957

@@ -80,7 +88,7 @@ Your AI agent now has access to all HAI tools — identity, email, signing, and
8088
| Category | Tools |
8189
|----------|-------|
8290
| **Email** | Send, reply, forward, search, list, read/unread, delete, contacts, quota status |
83-
| **Identity** | Create agent, register, claim username, check status, verify |
91+
| **Identity** | Create agent, register, check status, verify |
8492
| **Signing** | Sign and verify any JSON document or file with JACS |
8593
| **Documents** | Store, retrieve, search, and manage signed documents |
8694

@@ -106,9 +114,9 @@ export JACS_KEYCHAIN_BACKEND=disabled
106114
haiai mcp
107115
```
108116

109-
## Native language bindings (pre-alpha)
117+
## Native language bindings (beta)
110118

111-
Native SDKs for Python, Node.js, and Go are available on npm, pypi, and here but are **pre-alpha** — APIs may change. The MCP server is the recommended integration path.
119+
Native SDKs for Python, Node.js, and Go are available on npm, pypi, and here and are in **beta** — APIs may change. The MCP server is the recommended integration path.
112120

113121
```bash
114122
pip install haiai # Python

rust/haiai/docs/knowledge/jacs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@ Report vulnerabilities to security@hai.ai. Do not open public issues for securit
136136

137137
---
138138

139-
v0.9.7 | [Apache-2.0 OR MIT](./LICENSE-APACHE) | [Third-Party Notices](./THIRD-PARTY-NOTICES)
139+
v0.9.7 | [Apache-2.0](./LICENSE-APACHE) | [Third-Party Notices](./THIRD-PARTY-NOTICES)

rust/haiai/docs/knowledge/jacsbook/advanced/key-rotation.md

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,88 @@ This signed message:
136136
- Provides an audit trail
137137
- Binds old and new keys together cryptographically
138138

139-
### CLI Commands (Planned)
140-
141-
> **Note**: These CLI commands are planned for a future release. Currently, key rotation must be performed programmatically using the Rust API.
139+
### CLI Commands
142140

143141
```bash
144-
# Rotate keys with default algorithm (Coming Soon)
142+
# Rotate keys with default algorithm
145143
jacs agent rotate-keys
146144

147-
# Rotate to post-quantum algorithm (Coming Soon)
145+
# Rotate to post-quantum algorithm
148146
jacs agent rotate-keys --algorithm pq2025
149147

150-
# List key history (Coming Soon)
151-
jacs agent keys list
148+
# List key history (active and archived keys)
149+
jacs agent keys-list
150+
151+
# Repair config after a crash during rotation
152+
jacs agent repair
152153

153154
# Revoke a compromised key (Coming Soon)
154155
jacs agent keys revoke <key-hash>
155156
```
156157

158+
### Transition Signature
159+
160+
During key rotation, JACS produces a cryptographic transition proof that binds the old key to the new key. This proof is embedded in the agent document as `jacsKeyRotationProof`:
161+
162+
```json
163+
{
164+
"jacsKeyRotationProof": {
165+
"transitionMessage": "JACS_KEY_ROTATION:{agent_id}:{old_key_hash}:{new_key_hash}:{timestamp}",
166+
"signature": "base64-encoded-signature-with-old-key",
167+
"signingAlgorithm": "ring-Ed25519",
168+
"oldPublicKeyHash": "sha256-of-old-key",
169+
"newPublicKeyHash": "sha256-of-new-key",
170+
"timestamp": "2026-04-07T10:00:00Z"
171+
}
172+
}
173+
```
174+
175+
The transition message is signed with the **old** private key before it is archived. This proves:
176+
- The rotation was authorized by the holder of the previous key
177+
- The old and new keys are cryptographically linked
178+
- An attacker cannot forge a rotation without the old private key
179+
180+
You can verify a transition proof programmatically using `Agent::verify_transition_proof()`.
181+
182+
### Crash Recovery
183+
184+
JACS uses a write-ahead journal to recover from crashes during key rotation. Before rotation begins, a journal file is written to `{key_directory}/.jacs_rotation_journal.json`. The journal tracks the rotation stage:
185+
186+
1. `started` - Rotation initiated
187+
2. `keys_rotated` - New keys generated, old keys archived
188+
3. `agent_saved` - New agent version saved to disk
189+
4. `config_signed` - Config re-signed with new key (journal deleted on success)
190+
191+
If the process crashes mid-rotation, the next agent load detects the journal and automatically repairs the config by re-signing it with the current key. No manual intervention is required for the common case.
192+
193+
For manual recovery: `jacs agent repair`
194+
195+
### Cross-Algorithm Rotation
196+
197+
You can change the signing algorithm during rotation:
198+
199+
```bash
200+
# Rotate from Ed25519 to post-quantum
201+
jacs agent rotate-keys --algorithm pq2025
202+
```
203+
204+
```rust
205+
// Rust API
206+
let result = advanced::rotate(&agent, Some("pq2025"))?;
207+
```
208+
209+
```python
210+
# Python
211+
result = client.rotate_keys(algorithm="pq2025")
212+
```
213+
214+
```typescript
215+
// Node.js
216+
const result = await client.rotateKeys({ algorithm: 'pq2025' });
217+
```
218+
219+
After cross-algorithm rotation, the config file's `jacs_agent_key_algorithm` field is updated atomically. Documents signed before the rotation remain verifiable using the archived old key.
220+
157221
### Example Rotation Flow
158222

159223
```

0 commit comments

Comments
 (0)