@buildaureon/sdk 0.1.0 → 0.1.1

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 CHANGED
@@ -7,11 +7,11 @@
7
7
  The official TypeScript HTTP client for the AUREON API.
8
8
  Financial Compass, capital health, and verified restore plans: one typed integration surface.
9
9
 
10
- <br />
10
+ **Contract Address (CA):** `0xd293291060334d42e5dbea6fb854c231af527777`
11
11
 
12
12
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
13
13
  [![ESM](https://img.shields.io/badge/Module-ESM-f7df1e?style=flat-square)](#requirements)
14
- [![Version](https://img.shields.io/badge/version-0.1.0-a8e00d?style=flat-square)](https://github.com/buildaureon)
14
+ [![Version](https://img.shields.io/badge/version-0.1.1-a8e00d?style=flat-square)](https://github.com/buildaureon)
15
15
  [![License: MIT](https://img.shields.io/badge/license-MIT-0b0e0d?style=flat-square)](LICENSE)
16
16
  [![Node](https://img.shields.io/badge/node-%3E%3D20-339933?style=flat-square&logo=nodejs&logoColor=white)](#requirements)
17
17
 
@@ -21,124 +21,227 @@ Financial Compass, capital health, and verified restore plans: one typed integra
21
21
  pnpm add @buildaureon/sdk
22
22
  ```
23
23
 
24
- **CA (Robinhood Chain):** `0xd293291060334d42e5dbea6fb854c231af527777`
25
-
26
24
  [Quickstart](#quickstart) · [Authentication](#authentication) · [API Surface](#api-surface) · [Docs](#documentation)
27
25
 
28
26
  </div>
29
27
 
30
28
  ---
31
29
 
32
- ## Table of Contents
33
-
34
- 1. [What is AUREON?](#what-is-aureon)
35
- 2. [Requirements & Installation](#requirements--installation)
36
- 3. [Architecture & System Flow](#architecture--system-flow)
37
- - [3.1 Client-API Trust Boundary](#31-client-api-trust-boundary)
38
- - [3.2 Session Authentication Flow](#32-session-authentication-flow)
39
- - [3.3 Rebalancing & Watchdog Execution Flow](#33-rebalancing--watchdog-execution-flow)
40
- 4. [Quickstart](#quickstart-1)
41
- 5. [Detailed Authentication Guide](#detailed-authentication-guide)
42
- - [5.1 API Keys](#51-api-keys)
43
- - [5.2 Wallet Bearer Handshake](#52-wallet-bearer-handshake)
44
- - [5.3 Token Provider Lifecycle](#53-token-provider-lifecycle)
45
- 6. [API Surface Reference & Code Walkthroughs](#api-surface-reference--code-walkthroughs)
46
- - [6.1 Connection Smoke Tests](#61-connection-smoke-tests)
47
- - [6.2 Managing the Capital Book](#62-managing-the-capital-book)
48
- - [6.3 Defining and Querying Objectives](#63-defining-and-querying-objectives)
49
- - [6.4 Evaluating Compliance, Health, and Timeline Logs](#64-evaluating-compliance-health-and-timeline-logs)
50
- - [6.5 Non-Custodial Vault Operations](#65-non-custodial-vault-operations)
51
- - [6.6 Executing Restore Plans & Rebalances](#66-executing-restore-plans--rebalances)
52
- - [6.7 Simulating Market Events](#67-simulating-market-events)
53
- - [6.8 Developer API Key Management](#68-developer-api-key-management)
54
- 7. [Client Configuration & Transport Engine](#client-configuration--transport-engine)
55
- - [7.1 Configuration Reference Table](#71-configuration-reference-table)
56
- - [7.2 Retries and Network Failover](#72-retries-and-network-failover)
57
- 8. [Error Model and Code Handling](#error-model-and-code-handling)
58
- - [8.1 Error Code Reference Matrix](#81-error-code-reference-matrix)
59
- - [8.2 Narrowing Errors in Practice](#82-narrowing-errors-in-practice)
60
- 9. [CLI Command-Line Guide](#cli-command-line-guide)
61
- 10. [Design Principles & Settlement Honesty](#design-principles--settlement-honesty)
62
- 11. [Documentation Registry Map](#documentation-registry-map)
30
+ ## Table of contents
31
+
32
+ 1. [Overview](#overview)
33
+ 2. [What is AUREON?](#what-is-aureon)
34
+ 3. [What this SDK is](#what-this-sdk-is)
35
+ 4. [Ecosystem](#ecosystem)
36
+ 5. [Full system architecture](#full-system-architecture)
37
+ 6. [End-to-end flows](#end-to-end-flows)
38
+ 7. [Requirements & installation](#requirements--installation)
39
+ 8. [Quick start](#quick-start)
40
+ 9. [Authentication](#detailed-authentication-guide)
41
+ 10. [API surface reference](#api-surface-reference--code-walkthroughs)
42
+ 11. [Client configuration](#client-configuration--transport-engine)
43
+ 12. [Error model](#error-model-and-code-handling)
44
+ 13. [CLI](#cli-command-line-guide)
45
+ 14. [Design principles](#design-principles--settlement-honesty)
46
+ 15. [Documentation registry](#documentation-registry)
47
+ 16. [Community](#community--resources)
48
+
49
+ ---
50
+
51
+ ## Overview
52
+
53
+ **AUREON** is the financial intelligence layer for onchain AI agents on **Robinhood Chain**. Agents and operators do not live on one-off swaps. They need continuous policy: keep a stable sleeve near a target weight, hold exposure bands on equity tokens, and restore capital when markets move. AUREON turns those rules into first-class **Financial Compass Objectives** — registered policies the system monitors, scores for health, and restores with explicit settlement receipts.
54
+
55
+ Traditional web3 tooling is transactional. An operator submits a deposit or a swap, the chain settles once, and the broader intent disappears. Markets then move. Allocations drift. The agent either wakes up late or fires uncontrolled rebalances with no shared memory of why capital was supposed to look a certain way. AUREON closes that gap with a hosted policy and health engine, a non-custodial vault path on Robinhood Chain, and a typed TypeScript client so integrators never hand-roll the trust boundary between monitoring and signing.
56
+
57
+ **`@buildaureon/sdk`** is the official TypeScript HTTP client in this repository. It is how agent runtimes, operator scripts, and product surfaces talk to the AUREON API: wallet session handshake, Capital Book sync, objective CRUD, health and timeline queries, vault deposit and withdraw step preparation, restore plan execution, and controlled market-event rehearsal for integration tests. Private keys stay with the host application. The API never holds custody. Receipts are honest about whether settlement was **vault** (on-chain) or **staged** (ledger-local, labeled for UI transparency).
58
+
59
+ The broader product stack includes the hosted AUREON API and Health Watchdog, the operator utility at [app.aureonlabs.network](https://app.aureonlabs.network), Smart Vault contracts on Robinhood Chain, and the public site at [aureonlabs.network](https://www.aureonlabs.network/). This README is the integrator front door — dense enough to understand the system, practical enough to ship a first session, and linked into the long-form docs under `docs/`.
63
60
 
64
61
  ---
65
62
 
66
63
  ## What is AUREON?
67
64
 
68
- **AUREON** is a policy and execution layer for capital on **Robinhood Chain**. Traditional web3 interactions are transactional: an operator submits a single swap or deposit instruction, and once settled, the system forgets the broader goal.
65
+ AUREON treats capital as a living policy surface rather than a sequence of forgotten transactions. Developers register continuous financial rules for example, “maintain a stablecoin buffer at 25% of total portfolio value with a three-point tolerance.” The system then:
69
66
 
70
- AUREON introduces **Financial Compass Objectives (FCOs)** as execution primitives. Instead of sending raw transactions, developers register continuous financial rules (e.g., "maintain a stable coin buffer at 25% of total portfolio value"). The AUREON system:
67
+ - Monitors holdings across active addresses and smart vault contracts.
68
+ - Marks portfolio value with public market data.
69
+ - Detects allocation breaches against registered objective bands.
70
+ - Produces recovery instructions (wrap or unwrap paths, keeper-driven vault swaps).
71
+ - Appends an auditable timeline of compliance events and restore receipts.
71
72
 
72
- * Monitors capital holdings across active addresses and smart vault contracts.
73
- * Computes live portfolio value using public market data.
74
- * Detects allocation breaches against registered objective bands.
75
- * Produces recovery instructions (e.g., wrap/unwrap transactions or keeper-driven vault swaps).
76
- * Maintains a cryptographic, append-only timeline of compliance audits.
73
+ ### The concept: persistent objectives, honest settlement
74
+
75
+ Unlike a one-shot rebalancer bot that fires and forgets, AUREON keeps the objective as the primitive. Health state, timeline events, and restore plans all hang off that policy object. When drift exceeds tolerance, the watchdog records a violation, a restore plan is available, and execution returns a receipt whose `settlement` field tells the truth about where capital actually moved.
77
76
 
78
77
  ```mermaid
79
- flowchart TD
80
- subgraph Public [Public Node / Operator App]
81
- SDK["@buildaureon/sdk (TypeScript)"]
82
- Signer[Wallet Signer / Viem]
78
+ flowchart LR
79
+ subgraph intent["Intent"]
80
+ FCO[Financial Compass Objective]
83
81
  end
84
- subgraph Cloud [Hosted Ingress]
85
- API[AUREON API Gateway]
86
- Watchdog[Health Watchdog Engine]
87
- DB[(SQLite Ledger)]
82
+ subgraph engine["Policy engine"]
83
+ Health[Health + Watchdog]
84
+ Plan[Restore planner]
88
85
  end
89
- subgraph EVM [Robinhood Chain L2]
90
- Vault[AUREON Smart Vault]
91
- Keeper[Keeper Rebalance Adapter]
86
+ subgraph settle["Settlement"]
87
+ Staged[staged receipt]
88
+ Vault[vault / on-chain]
92
89
  end
90
+ FCO --> Health --> Plan
91
+ Plan --> Staged
92
+ Plan --> Vault
93
+ ```
94
+
95
+ ### What AUREON is not
96
+
97
+ - Not a custodian. Private keys never leave the client.
98
+ - Not a silent black-box trader. Restores are plan-driven and receipted.
99
+ - Not a claim that every restore is on-chain. `settlement: "staged"` means ledger-local and must be labeled as such in product UI.
100
+
101
+ ---
102
+
103
+ ## What this SDK is
104
+
105
+ **`@buildaureon/sdk`** is the npm-facing TypeScript package for application developers and agent authors.
106
+
107
+ | You can | Through |
108
+ | --- | --- |
109
+ | Authenticate with an issued API key (wallet identity) | `apiKey` on `createAureonClient` |
110
+ | Authenticate a wallet session (optional nonce → sign) | `getAuthNonce`, `verifyWallet`, `createSessionTokenProvider` |
111
+ | Sync and manage the Capital Book | `syncPortfolio`, `setPortfolio`, `clearPortfolio` |
112
+ | Create and query Financial Compass objectives | `createObjective`, `listObjectives`, `getObjective` |
113
+ | Read health, timeline, and overview | `getHealth`, `getTimeline`, `getOverview`, `refreshWatchdog` |
114
+ | Prepare non-custodial vault deposit / withdraw steps | `prepareVaultDeposit`, related vault helpers |
115
+ | Fetch and execute restore plans | `getRestorePlan`, `restoreObjective` |
116
+ | Apply controlled market events for integration rehearsal | `applyMarketEvent` |
117
+ | Manage developer API keys | `createApiKey`, `listApiKeys`, `toggleApiKey`, `revokeApiKey` |
118
+
119
+ **This package alone does not:**
120
+
121
+ - Hold or rotate private keys.
122
+ - Broadcast transactions (your viem / wallet client does).
123
+ - Deploy Smart Vault contracts.
124
+ - Replace the hosted Health Watchdog — it calls it.
125
+
126
+ ---
127
+
128
+ ## Ecosystem
93
129
 
94
- SDK -->|"HTTPS request with Key + JWT"| API
130
+ ```mermaid
131
+ flowchart TB
132
+ subgraph clients["Integrators"]
133
+ Agent[AI agent / operator script]
134
+ Utility[Operator utility]
135
+ end
136
+ subgraph npm_pkg["npm: @buildaureon/sdk"]
137
+ SDK[TypeScript client + CLI]
138
+ end
139
+ subgraph hosted["AUREON hosted layer"]
140
+ API[API gateway]
141
+ Watchdog[Health Watchdog]
142
+ Ledger[(Ledger store)]
143
+ end
144
+ subgraph chain["Robinhood Chain L2"]
145
+ Vault[Smart Vault]
146
+ Keeper[Keeper rebalance path]
147
+ end
148
+ Agent --> SDK
149
+ Utility --> SDK
150
+ SDK -->|HTTPS + API key + JWT| API
95
151
  API --> Watchdog
96
- API --> DB
97
- Watchdog -->|"Identify violation"| Keeper
98
- Signer -->|"1. Request Calldata Steps"| API
99
- API --x|"2. Returns steps (no keys held)"| Signer
100
- Signer -->|"3. Signs & broadcasts transactions"| EVM
152
+ API --> Ledger
153
+ Watchdog --> Keeper
154
+ Agent -->|sign + broadcast steps| Vault
155
+ Keeper --> Vault
101
156
  ```
102
157
 
158
+ | Component | Surface | Role |
159
+ | --- | --- | --- |
160
+ | **@buildaureon/sdk** (this repo) | TypeScript / CLI | Typed client, session helpers, vault step prep |
161
+ | **AUREON API** | Hosted HTTPS | Objectives, health, timeline, restore coordination |
162
+ | **Operator utility** | [app.aureonlabs.network](https://app.aureonlabs.network) | Human console for keys, capital, and policy |
163
+ | **Smart Vaults** | Robinhood Chain | Non-custodial on-chain capital path |
164
+ | **Website** | [aureonlabs.network](https://www.aureonlabs.network/) | Product narrative and entry points |
165
+
103
166
  ---
104
167
 
105
- ## Requirements & Installation
168
+ ## Full system architecture
106
169
 
107
- ### Requirements
108
- * **Node.js** version 20 or higher (ESM environment).
109
- * **Viem** (version 2.x) if signing and broadcasting transaction steps is required.
170
+ Complete AUREON topology: SDK client, hosted policy engines, ledger, vault settlement, and local signing.
110
171
 
111
- ### Installation
112
- Add the package to your project using a package manager:
172
+ ```mermaid
173
+ flowchart TB
174
+ subgraph CLIENT["CLIENT LAYER — Operator / Agent"]
175
+ direction TB
176
+ APP["Host application"]
177
+ SDK["@buildaureon/sdk"]
178
+ SESSION["Session token provider"]
179
+ SIGNER["Wallet signer · Viem"]
180
+ APP --> SDK
181
+ APP --> SESSION
182
+ APP --> SIGNER
183
+ end
113
184
 
114
- ```bash
115
- # Using pnpm
116
- pnpm add @buildaureon/sdk
185
+ subgraph CLOUD["HOSTED INGRESS — AUREON API"]
186
+ direction TB
187
+ API["API gateway"]
188
+ DB[("Ledger store")]
189
+ ORACLE["Public price marks"]
190
+ HEALTH["Health evaluation"]
191
+ WATCH["Watchdog heartbeat"]
192
+ PLANNER["Restore planner"]
193
+ API --> DB
194
+ API --> HEALTH
195
+ API --> WATCH
196
+ ORACLE --> HEALTH
197
+ WATCH --> PLANNER
198
+ end
117
199
 
118
- # Using npm
119
- npm install @buildaureon/sdk
200
+ subgraph EVM["ROBINHOOD CHAIN L2"]
201
+ direction TB
202
+ VAULT["AUREON Smart Vault"]
203
+ KEEPER["Keeper rebalance adapter"]
204
+ KEEPER --> VAULT
205
+ end
120
206
 
121
- # Using yarn
122
- yarn add @buildaureon/sdk
207
+ SDK -->|"1 HTTPS · API key · JWT"| API
208
+ API -->|"2 health / plans / steps"| SDK
209
+ SIGNER -->|"3 sign + broadcast"| VAULT
210
+ WATCH -->|"4 violation → plan"| PLANNER
211
+ PLANNER -->|"5 vault_swap path"| KEEPER
212
+
213
+ style CLIENT fill:#f9faf3,stroke:#0b0e0d,color:#0b0e0d
214
+ style CLOUD fill:#f9faf3,stroke:#a8e00d,color:#0b0e0d
215
+ style EVM fill:#f9faf3,stroke:#0b0e0d,color:#0b0e0d
123
216
  ```
124
217
 
218
+ ### Architecture at a glance
219
+
220
+ | Layer | Components | Trust boundary |
221
+ | --- | --- | --- |
222
+ | **Client** | Host app, `@buildaureon/sdk`, session provider, local signer | Keys and broadcast stay here |
223
+ | **Hosted** | API, ledger, oracles, health, watchdog, planner | Policy, pricing, coordination — no private keys |
224
+ | **Chain** | Smart Vault, keeper path | Settlement when `settlement: "vault"` |
225
+
226
+ Deep dive: [docs/architecture.md](docs/architecture.md) · [docs/security.md](docs/security.md) · [docs/integration-guide.md](docs/integration-guide.md)
227
+
125
228
  ---
126
229
 
127
- ## Architecture & System Flow
230
+ ## End-to-end flows
231
+
232
+ ### Client–API trust boundary
128
233
 
129
- ### 3.1 Client-API Trust Boundary
130
- To protect user funds, AUREON uses a decoupled trust boundary. The hosted API handles monitoring, calculations, public oracle pricing, and rebalance coordination, while private keys remain with the client.
234
+ To protect user funds, AUREON splits responsibility. The hosted API monitors capital, marks prices, evaluates objectives, and coordinates restore plans. The host application alone stores keys and signs transactions. The SDK sits on that boundary: it validates inputs, transports requests, prepares unsigned vault calldata, and never asks for a private key.
131
235
 
132
236
  | Layer | Responsibility |
133
- |---|---|
134
- | **SDK** | Request transport, EIP-712 hashing utilities, parameter validation, retry backing, and vault deposit/withdrawal calldata construction. |
135
- | **AUREON API** | Ledger syncing, objective validation logic, public price marks tracking, execution timeline compilation, and stage rebalance management. |
136
- | **Host Application** | Private key storage, MetaMask/signer integrations, and transaction signing & broadcasting. |
237
+ | --- | --- |
238
+ | **SDK** | Transport, validation, retries, EIP-712 helpers, vault step construction |
239
+ | **AUREON API** | Ledger sync, objective logic, price marks, timeline, staged or vault restore coordination |
240
+ | **Host application** | Key storage, wallet UX, signing, broadcasting |
137
241
 
138
- ---
242
+ ### Session authentication flow
139
243
 
140
- ### 3.2 Session Authentication Flow
141
- Authentication requires a challenge-response signature verification to link a wallet address with a temporary JWT session.
244
+ Authentication is a challenge–response handshake that binds a wallet address to a temporary JWT.
142
245
 
143
246
  ```mermaid
144
247
  sequenceDiagram
@@ -159,185 +262,208 @@ sequenceDiagram
159
262
  SDK-->>App: Return JWT Token
160
263
  ```
161
264
 
162
- ---
265
+ ### Watchdog and restore flow
163
266
 
164
- ### 3.3 Rebalancing & Watchdog Execution Flow
165
- When portfolio weights drift, the system triggers a rebalance using the execution flow:
267
+ When portfolio weights drift past tolerance, health flips to violation and a restore plan becomes available.
166
268
 
167
269
  ```mermaid
168
270
  sequenceDiagram
169
271
  autonumber
170
272
  participant Client as Client Application
171
273
  participant API as AUREON API Gateway
172
- participant DB as SQLite DB
274
+ participant DB as Ledger Store
173
275
  participant Engine as Health Engine
174
276
  participant Keeper as Keeper Service
175
277
 
176
278
  Client->>API: aureon.refreshWatchdog()
177
- API->>DB: Pull current price marks & positions
279
+ API->>DB: Pull price marks and positions
178
280
  API->>Engine: Recompute objective deviations
179
- alt Drift Exceeds Tolerance Limit
180
- Engine->>DB: Write health state: "violation"
181
- Engine->>DB: Write event: "violation_detected"
281
+ alt Drift exceeds tolerance
282
+ Engine->>DB: Write health state: violation
283
+ Engine->>DB: Write event: violation_detected
182
284
  Engine->>Keeper: Request restoration plan
183
285
  Keeper-->>API: Return plan (e.g. vault_swap)
184
- else Within Bands
185
- Engine->>DB: Write health state: "healthy"
286
+ else Within bands
287
+ Engine->>DB: Write health state: healthy
186
288
  end
187
- API-->>Client: Returns watchdog status and breach reports
289
+ API-->>Client: Watchdog status and breach reports
188
290
  ```
189
291
 
292
+ Typical operator loop in prose:
293
+
294
+ 1. **Define capital** — sync the Capital Book from chain or seed an explicit book for rehearsal.
295
+ 2. **Register policy** — create a Financial Compass objective with target weight and tolerance.
296
+ 3. **Observe** — poll health and timeline; refresh the watchdog after market moves.
297
+ 4. **Restore** — fetch the plan, execute restore, read `settlement` on the receipt.
298
+ 5. **Verify** — confirm health returns to healthy and the timeline shows the restore event.
299
+
190
300
  ---
191
301
 
192
- ## Quickstart
302
+ ## Requirements & installation
303
+
304
+ ### Requirements
305
+
306
+ - **Node.js** 20 or higher (ESM).
307
+ - **Viem** 2.x when you sign and broadcast vault steps.
308
+
309
+ ### Installation
193
310
 
194
- Initialize the SDK, retrieve a signing nonce, verify the signature, and sync wallet positions:
311
+ ```bash
312
+ pnpm add @buildaureon/sdk
313
+ # or
314
+ npm install @buildaureon/sdk
315
+ # or
316
+ yarn add @buildaureon/sdk
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Quick start
322
+
323
+ Initialize the client with an **issued** developer API key (Developers page in the utility).
324
+ That key identifies your wallet for control-plane calls — sync, objectives, health, restore plans.
325
+ A private key is only needed later to **broadcast** on-chain deposit/withdraw txs.
326
+
327
+ **SDK supports Automatic objectives only** (`automationMode: "auto"`, the default). Manual Approve workflows stay in the operator utility.
195
328
 
196
329
  ```ts
197
- import { createAureonClient, createSessionTokenProvider } from "@buildaureon/sdk";
198
- import { privateKeyToAccount } from "viem/accounts";
199
- import { createWalletClient, http } from "viem";
330
+ import { createAureonClient } from "@buildaureon/sdk";
200
331
 
201
332
  async function run() {
202
- // 1. Setup session token container
203
- const session = createSessionTokenProvider(null);
204
-
205
- // 2. Initialize the client
206
333
  const aureon = createAureonClient({
207
334
  baseUrl: "https://api.aureonlabs.network",
208
- apiKey: process.env.AUREON_API_KEY!,
209
- getAccessToken: session.getAccessToken,
335
+ apiKey: process.env.AUREON_API_KEY!, // issued key from Developers console
210
336
  });
211
337
 
212
- // 3. Perform a handshake to authenticate
213
- const account = privateKeyToAccount("0x..."); // Operator private key
214
- const { message } = await aureon.getAuthNonce(account.address);
215
-
216
- const walletClient = createWalletClient({ account, transport: http() });
217
- const signature = await walletClient.signMessage({ message, account });
218
-
219
- const login = await aureon.verifyWallet({
220
- address: account.address,
221
- message,
222
- signature,
223
- });
224
-
225
- // 4. Save credentials
226
- session.setToken(login.token);
338
+ const me = await aureon.me();
339
+ console.log("wallet", me.walletAddress);
227
340
 
228
- // 5. Query portfolio status
229
341
  const synced = await aureon.syncPortfolio();
230
342
  console.log("Portfolio Value USD:", synced.portfolio.totalNotionalUsd);
231
343
  }
232
344
  ```
233
345
 
346
+ Optional wallet Bearer (nonce → sign → `verifyWallet`) still works and **wins** when both
347
+ are sent. Env bootstrap keys (`AUREON_API_KEYS` on the server) unlock product access only —
348
+ they do not identify a wallet; use an issued key or a Bearer session with those.
349
+
350
+ From here, create an objective, read health, and restore when the watchdog reports a violation.
351
+ Full walkthroughs live in [docs/integration-guide.md](docs/integration-guide.md).
352
+
234
353
  ---
235
354
 
236
- ## Detailed Authentication Guide
355
+ ## Detailed authentication guide
356
+
357
+ ### Issued API keys (recommended for SDK / agents)
358
+
359
+ Create a key in the operator utility **Developers** console. The plaintext secret is shown once.
360
+ Send it as `X-Aureon-Api-Key`. The gateway resolves the bound wallet and scopes ledger operations
361
+ to that address. Treat issued keys like passwords: pause, revoke, rotate; never commit them.
362
+
363
+ ### Private key / on-chain signing
237
364
 
238
- ### 5.1 API Keys
239
- API keys regulate product access at the gateway level. They must be sent with all client requests via the `X-Aureon-Api-Key` header. Generate new API keys inside the operator utility developer console.
365
+ `prepareVaultDeposit` / `prepareVaultWithdraw` return **unsigned** calldata. Broadcasting those
366
+ transactions (and any other signed chain steps) requires the wallet private key or a browser
367
+ wallet — not the API key.
240
368
 
241
- ### 5.2 Wallet Bearer Handshake
242
- Bearer sessions scope data operations to a specific wallet. The SDK client obtains a nonce, signs it using an EVM signer, and posts the signature back to `/auth/verify` to receive a JWT session token.
369
+ ### Wallet bearer handshake (optional)
243
370
 
244
- ### 5.3 Token Provider Lifecycle
245
- The `createSessionTokenProvider` manager handles token resolution and injection. It can be passed directly as a resolver function:
371
+ Bearer sessions also scope ledger operations to a wallet. The SDK fetches a nonce message, the
372
+ host signs it with an EVM signer, and `/auth/verify` returns a session token for `getAccessToken`.
373
+ Use this for the browser utility, or when you only have an env bootstrap key (no issued key).
374
+
375
+ ### Token provider lifecycle
246
376
 
247
377
  ```ts
248
378
  import { createSessionTokenProvider } from "@buildaureon/sdk";
249
379
 
250
380
  const session = createSessionTokenProvider(process.env.AUREON_TOKEN ?? null);
251
381
 
252
- // Clear tokens on logout
253
382
  await aureon.logout();
254
383
  session.clear();
255
384
  ```
256
385
 
386
+ `createSessionTokenProvider` is a small stateful container: set after verify, clear on logout,
387
+ inject via `getAccessToken` so the client stays free of global mutable auth state.
388
+
257
389
  ---
258
390
 
259
- ## API Surface Reference & Code Walkthroughs
391
+ ## API surface reference & code walkthroughs
392
+
393
+ ### Connection smoke tests
260
394
 
261
- ### 6.1 Connection Smoke Tests
262
395
  ```ts
263
396
  const ping = await aureon.ping();
264
397
  console.log(`Connected. Backend version: ${ping.version}`);
265
398
  ```
266
399
 
267
- ### 6.2 Managing the Capital Book
268
- The Capital Book defines the assets tracked by AUREON. Sync positions from the chain or modify them directly:
400
+ ### Managing the Capital Book
401
+
402
+ The Capital Book is the set of positions AUREON tracks for weight and health math. Sync from Robinhood Chain and vaults, or set an explicit book for controlled rehearsal environments.
269
403
 
270
404
  ```ts
271
- // Sync active balances from Robinhood Chain L2 and smart vaults
272
405
  const syncResult = await aureon.syncPortfolio();
273
406
  console.log("Current stable coin weight:", syncResult.portfolio.stableWeight);
274
407
 
275
- // Manually define positions (useful for simulation environments)
276
408
  const updatedBook = await aureon.setPortfolio([
277
409
  { symbol: "WETH", quantity: 2.5, category: "gas" },
278
- { symbol: "USDG", quantity: 2500, category: "stable" }
410
+ { symbol: "USDG", quantity: 2500, category: "stable" },
279
411
  ]);
280
412
 
281
- // Clear all active ledger tracking rows
282
413
  await aureon.clearPortfolio();
283
414
  ```
284
415
 
285
- ### 6.3 Defining and Querying Objectives
286
- Objectives dictate the target weights and tolerance buffers. All SDK objectives are initialized with automatic rebalancing:
416
+ ### Defining and querying objectives
417
+
418
+ Objectives are the Financial Compass primitives: target weights, tolerance bands, and priority. SDK-created objectives participate in automatic restore coordination when health enters violation.
287
419
 
288
420
  ```ts
289
- // Create a stable coin allocation objective
290
421
  const stableObj = await aureon.createObjective({
291
422
  name: "Stable Core Reserve",
292
423
  kind: "stable_allocation",
293
- targetWeight: 0.30, // Keep 30% of portfolio value in stables
294
- tolerance: 0.03, // Rebalance if drift exceeds +/- 3%
295
- priority: "high"
424
+ targetWeight: 0.3,
425
+ tolerance: 0.03,
426
+ priority: "high",
296
427
  });
297
428
 
298
- // Create a stock token tracking objective
299
429
  const stockObj = await aureon.createObjective({
300
430
  name: "Tesla Sleeve Allocation",
301
431
  kind: "balanced_portfolio",
302
432
  targetSymbol: "TSLA",
303
- targetWeight: 0.20,
304
- tolerance: 0.05
433
+ targetWeight: 0.2,
434
+ tolerance: 0.05,
305
435
  });
306
436
 
307
- // List objectives registered to the authenticated wallet
308
437
  const objectives = await aureon.listObjectives();
309
438
  ```
310
439
 
311
- ### 6.4 Evaluating Compliance, Health, and Timeline Logs
440
+ ### Health, timeline, and overview
441
+
312
442
  ```ts
313
- // Get active health states for all objectives
314
443
  const healthRecords = await aureon.getHealth();
315
444
  for (const health of healthRecords) {
316
445
  console.log(`Objective ${health.objectiveId}: State: ${health.state}`);
317
446
  }
318
447
 
319
- // Fetch timeline events (logs objective updates, breaches, and rebalances)
320
448
  const timeline = await aureon.getTimeline();
321
- timeline.forEach(event => console.log(`[${event.type}]: ${event.message}`));
449
+ timeline.forEach((event) => console.log(`[${event.type}]: ${event.message}`));
322
450
 
323
- // Fetch general dashboard overview metrics
324
451
  const overview = await aureon.getOverview();
325
452
  console.log("Global health score:", overview.globalHealthScore);
326
453
  ```
327
454
 
328
- ### 6.5 Non-Custodial Vault Operations
329
- Vault interactions construct raw transactions (calldatas) locally. The host application signs and broadcasts these to execute actions:
455
+ ### Non-custodial vault operations
456
+
457
+ Vault helpers prepare unsigned steps. The host signs and broadcasts; AUREON never receives the private key.
330
458
 
331
459
  ```ts
332
- import { Hex } from "viem";
460
+ import type { Hex } from "viem";
333
461
 
334
- // 1. Prepare vault deposit parameters
335
462
  const depositData = await aureon.prepareVaultDeposit({
336
463
  symbol: "ETH",
337
464
  amount: "0.5",
338
465
  });
339
466
 
340
- // 2. Iterate and sign calldata steps
341
467
  for (const step of depositData.steps) {
342
468
  const hash = await walletClient.sendTransaction({
343
469
  account,
@@ -349,107 +475,92 @@ for (const step of depositData.steps) {
349
475
  }
350
476
  ```
351
477
 
352
- ### 6.6 Executing Restore Plans & Rebalances
353
- If a deviation triggers a breach, fetch the restore instructions:
478
+ ### Restore plans and rebalances
479
+
480
+ When health is in violation, fetch the plan and execute. Always read `settlement` on the receipt.
354
481
 
355
482
  ```ts
356
- // 1. Fetch recovery plan details
357
483
  const plan = await aureon.getRestorePlan(objective.id);
358
484
  console.log(`Plan requires action: ${plan.kind} for ${plan.amountHuman} tokens.`);
359
485
 
360
- // 2. Perform restoration
361
486
  if (plan.kind === "vault_swap") {
362
- // Vault swaps are handled directly on the backend
363
487
  const receipt = await aureon.restoreObjective(objective.id);
364
488
  console.log("Rebalance transaction hash:", receipt.transactionHash);
365
- console.log("Settlement environment:", receipt.settlement); // "vault" or "staged"
489
+ console.log("Settlement environment:", receipt.settlement); // "vault" | "staged"
366
490
  } else {
367
- // ETH wraps or WETH unwraps are executed client-side
368
- console.warn("Execute wrap_eth or unwrap_weth using your wallet provider.");
491
+ console.warn("Execute wrap_eth or unwrap_weth with your wallet provider.");
369
492
  }
370
493
  ```
371
494
 
372
- ### 6.7 Simulating Market Events
373
- Trigger price changes to test rebalancing routines:
495
+ ### Controlled market events
496
+
497
+ Apply a deterministic price mark change to rehearse breach and restore paths in integration environments. This is a controlled market event against the ledger marks — not a claim of live exchange execution.
374
498
 
375
499
  ```ts
376
- // Trigger a mock 15% drop in NVDA's price mark
377
500
  const shockResult = await aureon.applyMarketEvent({
378
501
  symbol: "NVDA",
379
502
  priceChangeRatio: -0.15,
380
- autoRestore: true, // Trigger staged/vault restorations automatically if a breach occurs
503
+ autoRestore: true,
381
504
  });
382
505
  ```
383
506
 
384
- ### 6.8 Developer API Key Management
385
- Generate, toggle, and revoke keys:
507
+ ### Developer API key management
386
508
 
387
509
  ```ts
388
- // Generate a new key (Store the returned plain-text 'secret' immediately)
389
510
  const newKey = await aureon.createApiKey("Secondary Bot Ingress");
390
511
  console.log(`Plaintext secret: ${newKey.secret}`);
391
512
 
392
- // List active keys
393
513
  const keys = await aureon.listApiKeys();
394
-
395
- // Toggle active/inactive state
396
514
  await aureon.toggleApiKey(newKey.id);
397
-
398
- // Revoke a key
399
515
  await aureon.revokeApiKey(newKey.id);
400
516
  ```
401
517
 
402
518
  ---
403
519
 
404
- ## Client Configuration & Transport Engine
520
+ ## Client configuration & transport engine
405
521
 
406
- ### 7.1 Configuration Reference Table
407
- Pass these parameters inside the `AureonClientOptions` constructor payload:
522
+ ### Configuration reference
408
523
 
409
524
  | Parameter | Type | Default | Description |
410
- |---|---|---|---|
411
- | `baseUrl` | `string` | `"https://api.aureonlabs.network"` | Target API ingress endpoint |
412
- | `apiKey` | `string` | `undefined` | Key sent with `X-Aureon-Api-Key` headers |
413
- | `authToken` | `string` | `undefined` | Static JWT bearer token |
414
- | `getAccessToken` | `() => string \| null` | `undefined` | Dynamic getter function resolving bearer tokens |
415
- | `timeoutMs` | `number` | `30000` | Abort threshold per network call |
416
- | `maxRetries` | `number` | `0` | Re-attempt counts for transport failures |
417
- | `retryDelayMs` | `number` | `250` | Wait delay between retry loops |
418
- | `headers` | `Record<string, string>` | `{}` | Key-value headers appended to requests |
419
- | `fetch` | `typeof fetch` | `globalThis.fetch` | Custom fetch wrapper engine overrides |
525
+ | --- | --- | --- | --- |
526
+ | `baseUrl` | `string` | `"https://api.aureonlabs.network"` | API ingress |
527
+ | `apiKey` | `string` | `undefined` | Sent as `X-Aureon-Api-Key` |
528
+ | `authToken` | `string` | `undefined` | Static JWT bearer |
529
+ | `getAccessToken` | `() => string \| null` | `undefined` | Dynamic bearer resolver |
530
+ | `timeoutMs` | `number` | `30000` | Per-call abort threshold |
531
+ | `maxRetries` | `number` | `0` | Transient failure retries |
532
+ | `retryDelayMs` | `number` | `250` | Delay between retries |
533
+ | `headers` | `Record<string, string>` | `{}` | Extra headers |
534
+ | `fetch` | `typeof fetch` | `globalThis.fetch` | Custom fetch override |
420
535
 
421
- ---
536
+ ### Retries and failover
422
537
 
423
- ### 7.2 Retries and Network Failover
424
- When `maxRetries` is greater than `0`, the client retries failed requests if it encounters a transient error (such as a timeout or a 503 HTTP status code). Retries use a fixed delay (`retryDelayMs`).
538
+ When `maxRetries` is greater than zero, the client retries timeouts and selected transient HTTP failures with a fixed `retryDelayMs`. Prefer raising retries for long-running agent loops; keep them low for interactive UI paths where fail-fast is better.
425
539
 
426
540
  ---
427
541
 
428
- ## Error Model and Code Handling
429
-
430
- ### 8.1 Error Code Reference Matrix
542
+ ## Error model and code handling
431
543
 
432
- | Code | HTTP Status | Description |
433
- |---|---|---|
434
- | `UNAUTHORIZED` | 401 | Missing or invalid API key or Bearer token |
435
- | `VALIDATION_ERROR`| 400 | Payload fails validation (e.g. name length or targetWeight bounds) |
436
- | `NOT_FOUND` | 404 | Target object (objective, key, etc.) does not exist |
437
- | `CONFLICT` | 409 | Request conflicts with current database state |
438
- | `RATE_LIMITED` | 429 | Request count exceeds API limits |
439
- | `SERVER_ERROR` | 500 / 503 | Server-side execution failure |
440
- | `TIMEOUT` | N/A | Call exceeded client-configured `timeoutMs` |
441
- | `NETWORK_ERROR` | N/A | Endpoint unreachable or client is offline |
544
+ ### Error code reference
442
545
 
443
- ---
546
+ | Code | HTTP | Description |
547
+ | --- | --- | --- |
548
+ | `UNAUTHORIZED` | 401 | Missing or invalid API key or bearer |
549
+ | `VALIDATION_ERROR` | 400 | Payload failed validation |
550
+ | `NOT_FOUND` | 404 | Objective, key, or resource missing |
551
+ | `CONFLICT` | 409 | Request conflicts with current ledger state |
552
+ | `RATE_LIMITED` | 429 | Request volume exceeded |
553
+ | `SERVER_ERROR` | 500 / 503 | Hosted execution failure |
554
+ | `TIMEOUT` | — | Exceeded `timeoutMs` |
555
+ | `NETWORK_ERROR` | — | Endpoint unreachable |
444
556
 
445
- ### 8.2 Narrowing Errors in Practice
446
- AUREON methods throw custom error instances. Wrap calls in a try/catch block and use `isAureonError` to handle them:
557
+ ### Narrowing errors in practice
447
558
 
448
559
  ```ts
449
560
  import { isAureonError } from "@buildaureon/sdk";
450
561
 
451
562
  try {
452
- const objective = await aureon.getObjective("missing_id");
563
+ await aureon.getObjective("missing_id");
453
564
  } catch (error) {
454
565
  if (isAureonError(error)) {
455
566
  switch (error.code) {
@@ -457,7 +568,7 @@ try {
457
568
  console.error("The specified objective does not exist.");
458
569
  break;
459
570
  case "UNAUTHORIZED":
460
- console.error("Check your API key and wallet session configuration.");
571
+ console.error("Check API key and wallet session configuration.");
461
572
  break;
462
573
  default:
463
574
  console.error(`Aureon error: ${error.message}`);
@@ -468,65 +579,62 @@ try {
468
579
  }
469
580
  ```
470
581
 
582
+ Full matrix: [docs/error-model.md](docs/error-model.md).
583
+
471
584
  ---
472
585
 
473
- ## CLI Command-Line Guide
586
+ ## CLI command-line guide
474
587
 
475
- The SDK package includes a developer CLI utility. Provide configuration values using environment variables:
588
+ The package ships a developer CLI. Configure credentials via environment variables:
476
589
 
477
590
  ```bash
478
- export AUREON_API_KEY=your_key
479
- export AUREON_TOKEN=your_bearer_token
591
+ # Issued developer key (recommended) — identifies wallet;
592
+ export AUREON_API_KEY=aureon_....
480
593
 
481
- # Verify connection
482
594
  pnpm --filter @buildaureon/sdk cli ping
483
-
484
- # Fetch current account metadata
485
595
  pnpm --filter @buildaureon/sdk cli me
486
-
487
- # Synchronize current on-chain balances
488
596
  pnpm --filter @buildaureon/sdk cli sync
489
-
490
- # Print Capital Book portfolio weights
491
597
  pnpm --filter @buildaureon/sdk cli portfolio
492
-
493
- # List all registered objectives
494
598
  pnpm --filter @buildaureon/sdk cli objectives
495
599
  ```
496
600
 
497
601
  ---
498
602
 
499
- ## Design Principles & Settlement Honesty
603
+ ## Design principles & settlement honesty
500
604
 
501
- 1. **Non-Custodial Design**: Private keys never leave the client application. The AUREON API gateway only receives signature verification requests and constructs unsigned transaction payloads.
502
- 2. **Settlement Transparency**: Execution receipts include a `settlement` attribute (`"staged"` or `"vault"`).
503
- * `"vault"` indicates the transaction settled on-chain on Robinhood Chain L2.
504
- * `"staged"` indicates a local ledger update only. Staged transactions must be labeled transparently in user interfaces.
505
- 3. **Seeded Ledger Capital**: Position data comes from synchronized block queries or explicit operator inputs. The SDK does not fabricate capital balances.
605
+ 1. **Non-custodial by construction.** Private keys never leave the client. The API verifies signatures and returns unsigned steps; it does not sign for you.
606
+ 2. **Settlement transparency.** Every execution receipt includes `settlement`: `"vault"` means Robinhood Chain settlement; `"staged"` means ledger-local and must be labeled clearly in any user-facing surface.
607
+ 3. **Seeded capital, not invented capital.** Positions come from chain sync or explicit operator input. The SDK does not invent balances to make demos look healthy.
608
+ 4. **Objectives as primitives.** Health, timeline, and restores hang off Financial Compass objectives so agents can reason about policy, not only about the last transaction hash.
506
609
 
507
610
  ---
508
611
 
509
- ## Documentation Registry Map
612
+ ## Documentation registry
510
613
 
511
- For more detail, refer to the documents inside the `sdk/docs/` directory:
614
+ Long-form technical docs live under `docs/`:
512
615
 
513
616
  | Document | Focus |
514
- |---|---|
515
- | [docs/architecture.md](docs/architecture.md) | Client vs API boundary lines and system maps |
516
- | [docs/auth.md](docs/auth.md) | Wallet handshake, signature verifications, and JWT lifecycles |
517
- | [docs/client-api.md](docs/client-api.md) | Detailed parameter index for all client methods |
518
- | [docs/data-contracts.md](docs/data-contracts.md) | Type index matching hosted JSON endpoints |
519
- | [docs/error-model.md](docs/error-model.md) | Complete error code listing and code mappings |
520
- | [docs/integration-guide.md](docs/integration-guide.md) | End-to-end integration walkthroughs |
521
- | [docs/security.md](docs/security.md) | API key and token security guidelines |
522
- | [docs/transport.md](docs/transport.md) | Transport configurations, retry loops, and error-handling |
617
+ | --- | --- |
618
+ | [docs/architecture.md](docs/architecture.md) | Client vs API boundary, system maps |
619
+ | [docs/auth.md](docs/auth.md) | Wallet handshake and JWT lifecycle |
620
+ | [docs/client-api.md](docs/client-api.md) | Method and parameter index |
621
+ | [docs/data-contracts.md](docs/data-contracts.md) | Types aligned to hosted JSON |
622
+ | [docs/error-model.md](docs/error-model.md) | Full error code mapping |
623
+ | [docs/integration-guide.md](docs/integration-guide.md) | End-to-end integrator walkthrough |
624
+ | [docs/security.md](docs/security.md) | API key and token guidance |
625
+ | [docs/transport.md](docs/transport.md) | Retries, headers, transport edge cases |
523
626
 
524
627
  ---
525
628
 
526
- ## Community & Resources
629
+ ## Community & resources
630
+
631
+ - **Website:** [aureonlabs.network](https://www.aureonlabs.network/)
632
+ - **Operator utility:** [app.aureonlabs.network](https://app.aureonlabs.network)
633
+ - **X:** [@buildaureon](https://x.com/buildaureon)
634
+ - **GitHub:** [github.com/buildaureon](https://github.com/buildaureon)
635
+
636
+ ---
527
637
 
528
- * **Official Website**: [aureonlabs.network](https://aureonlabs.network)
529
- * **Operator Utility Platform**: [app.aureonlabs.network](https://app.aureonlabs.network)
530
- * **Twitter / X**: [@buildaureon](https://x.com/buildaureon)
531
- * **GitHub Repository**: [github.com/buildaureon](https://github.com/buildaureon)
638
+ ## License
532
639
 
640
+ MIT — see [LICENSE](LICENSE).