@buildaureon/sdk 0.1.1 → 0.1.7

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
@@ -1,640 +1,655 @@
1
- <div align="center">
2
-
3
- # Aureon
4
-
5
- **Financial Intelligence Layer for Onchain AI Agents**
6
-
7
- The official TypeScript HTTP client for the AUREON API.
8
- Financial Compass, capital health, and verified restore plans: one typed integration surface.
9
-
10
- **Contract Address (CA):** `0xd293291060334d42e5dbea6fb854c231af527777`
11
-
12
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
13
- [![ESM](https://img.shields.io/badge/Module-ESM-f7df1e?style=flat-square)](#requirements)
14
- [![Version](https://img.shields.io/badge/version-0.1.1-a8e00d?style=flat-square)](https://github.com/buildaureon)
15
- [![License: MIT](https://img.shields.io/badge/license-MIT-0b0e0d?style=flat-square)](LICENSE)
16
- [![Node](https://img.shields.io/badge/node-%3E%3D20-339933?style=flat-square&logo=nodejs&logoColor=white)](#requirements)
17
-
18
- <br />
19
-
20
- ```bash
21
- pnpm add @buildaureon/sdk
22
- ```
23
-
24
- [Quickstart](#quickstart) · [Authentication](#authentication) · [API Surface](#api-surface) · [Docs](#documentation)
25
-
26
- </div>
27
-
28
- ---
29
-
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/`.
60
-
61
- ---
62
-
63
- ## What is AUREON?
64
-
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:
66
-
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.
72
-
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.
76
-
77
- ```mermaid
78
- flowchart LR
79
- subgraph intent["Intent"]
80
- FCO[Financial Compass Objective]
81
- end
82
- subgraph engine["Policy engine"]
83
- Health[Health + Watchdog]
84
- Plan[Restore planner]
85
- end
86
- subgraph settle["Settlement"]
87
- Staged[staged receipt]
88
- Vault[vault / on-chain]
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
129
-
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
151
- API --> Watchdog
152
- API --> Ledger
153
- Watchdog --> Keeper
154
- Agent -->|sign + broadcast steps| Vault
155
- Keeper --> Vault
156
- ```
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
-
166
- ---
167
-
168
- ## Full system architecture
169
-
170
- Complete AUREON topology: SDK client, hosted policy engines, ledger, vault settlement, and local signing.
171
-
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
184
-
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
199
-
200
- subgraph EVM["ROBINHOOD CHAIN L2"]
201
- direction TB
202
- VAULT["AUREON Smart Vault"]
203
- KEEPER["Keeper rebalance adapter"]
204
- KEEPER --> VAULT
205
- end
206
-
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
216
- ```
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
-
228
- ---
229
-
230
- ## End-to-end flows
231
-
232
- ### Client–API trust boundary
233
-
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.
235
-
236
- | Layer | Responsibility |
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 |
241
-
242
- ### Session authentication flow
243
-
244
- Authentication is a challenge–response handshake that binds a wallet address to a temporary JWT.
245
-
246
- ```mermaid
247
- sequenceDiagram
248
- autonumber
249
- participant App as Client Operator
250
- participant SDK as SDK Client
251
- participant API as AUREON API Gateway
252
-
253
- App->>SDK: aureon.getAuthNonce(address)
254
- SDK->>API: GET /auth/nonce?address=0x...
255
- API-->>SDK: { message, nonce, expiresAt }
256
- SDK-->>App: { message, nonce }
257
- Note over App: Operator signs message<br/>using private key
258
- App->>SDK: aureon.verifyWallet({ address, message, signature })
259
- SDK->>API: POST /auth/verify { address, message, signature }
260
- API->>API: Verify EIP-191 Signature
261
- API-->>SDK: { token, expiresAt, sessionId }
262
- SDK-->>App: Return JWT Token
263
- ```
264
-
265
- ### Watchdog and restore flow
266
-
267
- When portfolio weights drift past tolerance, health flips to violation and a restore plan becomes available.
268
-
269
- ```mermaid
270
- sequenceDiagram
271
- autonumber
272
- participant Client as Client Application
273
- participant API as AUREON API Gateway
274
- participant DB as Ledger Store
275
- participant Engine as Health Engine
276
- participant Keeper as Keeper Service
277
-
278
- Client->>API: aureon.refreshWatchdog()
279
- API->>DB: Pull price marks and positions
280
- API->>Engine: Recompute objective deviations
281
- alt Drift exceeds tolerance
282
- Engine->>DB: Write health state: violation
283
- Engine->>DB: Write event: violation_detected
284
- Engine->>Keeper: Request restoration plan
285
- Keeper-->>API: Return plan (e.g. vault_swap)
286
- else Within bands
287
- Engine->>DB: Write health state: healthy
288
- end
289
- API-->>Client: Watchdog status and breach reports
290
- ```
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
-
300
- ---
301
-
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
310
-
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.
328
-
329
- ```ts
330
- import { createAureonClient } from "@buildaureon/sdk";
331
-
332
- async function run() {
333
- const aureon = createAureonClient({
334
- baseUrl: "https://api.aureonlabs.network",
335
- apiKey: process.env.AUREON_API_KEY!, // issued key from Developers console
336
- });
337
-
338
- const me = await aureon.me();
339
- console.log("wallet", me.walletAddress);
340
-
341
- const synced = await aureon.syncPortfolio();
342
- console.log("Portfolio Value USD:", synced.portfolio.totalNotionalUsd);
343
- }
344
- ```
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
-
353
- ---
354
-
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
364
-
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.
368
-
369
- ### Wallet bearer handshake (optional)
370
-
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
376
-
377
- ```ts
378
- import { createSessionTokenProvider } from "@buildaureon/sdk";
379
-
380
- const session = createSessionTokenProvider(process.env.AUREON_TOKEN ?? null);
381
-
382
- await aureon.logout();
383
- session.clear();
384
- ```
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
-
389
- ---
390
-
391
- ## API surface reference & code walkthroughs
392
-
393
- ### Connection smoke tests
394
-
395
- ```ts
396
- const ping = await aureon.ping();
397
- console.log(`Connected. Backend version: ${ping.version}`);
398
- ```
399
-
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.
403
-
404
- ```ts
405
- const syncResult = await aureon.syncPortfolio();
406
- console.log("Current stable coin weight:", syncResult.portfolio.stableWeight);
407
-
408
- const updatedBook = await aureon.setPortfolio([
409
- { symbol: "WETH", quantity: 2.5, category: "gas" },
410
- { symbol: "USDG", quantity: 2500, category: "stable" },
411
- ]);
412
-
413
- await aureon.clearPortfolio();
414
- ```
415
-
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.
419
-
420
- ```ts
421
- const stableObj = await aureon.createObjective({
422
- name: "Stable Core Reserve",
423
- kind: "stable_allocation",
424
- targetWeight: 0.3,
425
- tolerance: 0.03,
426
- priority: "high",
427
- });
428
-
429
- const stockObj = await aureon.createObjective({
430
- name: "Tesla Sleeve Allocation",
431
- kind: "balanced_portfolio",
432
- targetSymbol: "TSLA",
433
- targetWeight: 0.2,
434
- tolerance: 0.05,
435
- });
436
-
437
- const objectives = await aureon.listObjectives();
438
- ```
439
-
440
- ### Health, timeline, and overview
441
-
442
- ```ts
443
- const healthRecords = await aureon.getHealth();
444
- for (const health of healthRecords) {
445
- console.log(`Objective ${health.objectiveId}: State: ${health.state}`);
446
- }
447
-
448
- const timeline = await aureon.getTimeline();
449
- timeline.forEach((event) => console.log(`[${event.type}]: ${event.message}`));
450
-
451
- const overview = await aureon.getOverview();
452
- console.log("Global health score:", overview.globalHealthScore);
453
- ```
454
-
455
- ### Non-custodial vault operations
456
-
457
- Vault helpers prepare unsigned steps. The host signs and broadcasts; AUREON never receives the private key.
458
-
459
- ```ts
460
- import type { Hex } from "viem";
461
-
462
- const depositData = await aureon.prepareVaultDeposit({
463
- symbol: "ETH",
464
- amount: "0.5",
465
- });
466
-
467
- for (const step of depositData.steps) {
468
- const hash = await walletClient.sendTransaction({
469
- account,
470
- to: step.to as `0x${string}`,
471
- data: step.data as Hex,
472
- value: BigInt(step.value),
473
- });
474
- await publicClient.waitForTransactionReceipt({ hash });
475
- }
476
- ```
477
-
478
- ### Restore plans and rebalances
479
-
480
- When health is in violation, fetch the plan and execute. Always read `settlement` on the receipt.
481
-
482
- ```ts
483
- const plan = await aureon.getRestorePlan(objective.id);
484
- console.log(`Plan requires action: ${plan.kind} for ${plan.amountHuman} tokens.`);
485
-
486
- if (plan.kind === "vault_swap") {
487
- const receipt = await aureon.restoreObjective(objective.id);
488
- console.log("Rebalance transaction hash:", receipt.transactionHash);
489
- console.log("Settlement environment:", receipt.settlement); // "vault" | "staged"
490
- } else {
491
- console.warn("Execute wrap_eth or unwrap_weth with your wallet provider.");
492
- }
493
- ```
494
-
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.
498
-
499
- ```ts
500
- const shockResult = await aureon.applyMarketEvent({
501
- symbol: "NVDA",
502
- priceChangeRatio: -0.15,
503
- autoRestore: true,
504
- });
505
- ```
506
-
507
- ### Developer API key management
508
-
509
- ```ts
510
- const newKey = await aureon.createApiKey("Secondary Bot Ingress");
511
- console.log(`Plaintext secret: ${newKey.secret}`);
512
-
513
- const keys = await aureon.listApiKeys();
514
- await aureon.toggleApiKey(newKey.id);
515
- await aureon.revokeApiKey(newKey.id);
516
- ```
517
-
518
- ---
519
-
520
- ## Client configuration & transport engine
521
-
522
- ### Configuration reference
523
-
524
- | Parameter | Type | Default | Description |
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 |
535
-
536
- ### Retries and failover
537
-
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.
539
-
540
- ---
541
-
542
- ## Error model and code handling
543
-
544
- ### Error code reference
545
-
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 |
556
-
557
- ### Narrowing errors in practice
558
-
559
- ```ts
560
- import { isAureonError } from "@buildaureon/sdk";
561
-
562
- try {
563
- await aureon.getObjective("missing_id");
564
- } catch (error) {
565
- if (isAureonError(error)) {
566
- switch (error.code) {
567
- case "NOT_FOUND":
568
- console.error("The specified objective does not exist.");
569
- break;
570
- case "UNAUTHORIZED":
571
- console.error("Check API key and wallet session configuration.");
572
- break;
573
- default:
574
- console.error(`Aureon error: ${error.message}`);
575
- }
576
- } else {
577
- console.error("Generic execution failure:", error);
578
- }
579
- }
580
- ```
581
-
582
- Full matrix: [docs/error-model.md](docs/error-model.md).
583
-
584
- ---
585
-
586
- ## CLI command-line guide
587
-
588
- The package ships a developer CLI. Configure credentials via environment variables:
589
-
590
- ```bash
591
- # Issued developer key (recommended) — identifies wallet;
592
- export AUREON_API_KEY=aureon_....
593
-
594
- pnpm --filter @buildaureon/sdk cli ping
595
- pnpm --filter @buildaureon/sdk cli me
596
- pnpm --filter @buildaureon/sdk cli sync
597
- pnpm --filter @buildaureon/sdk cli portfolio
598
- pnpm --filter @buildaureon/sdk cli objectives
599
- ```
600
-
601
- ---
602
-
603
- ## Design principles & settlement honesty
604
-
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.
609
-
610
- ---
611
-
612
- ## Documentation registry
613
-
614
- Long-form technical docs live under `docs/`:
615
-
616
- | Document | Focus |
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 |
626
-
627
- ---
628
-
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
- ---
637
-
638
- ## License
639
-
640
- MIT — see [LICENSE](LICENSE).
1
+ <div align="center">
2
+
3
+ # Aureon
4
+
5
+ **Financial Intelligence Layer for Onchain AI Agents**
6
+
7
+ The official TypeScript HTTP client for the AUREON API.
8
+ Financial Compass, capital health, and verified restore plans: one typed integration surface.
9
+
10
+ **Contract Address (CA):** `0xd293291060334d42e5dbea6fb854c231af527777`
11
+
12
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
13
+ [![ESM](https://img.shields.io/badge/Module-ESM-f7df1e?style=flat-square)](#requirements)
14
+ [![Version](https://img.shields.io/badge/version-0.1.1-a8e00d?style=flat-square)](https://github.com/buildaureon)
15
+ [![License: MIT](https://img.shields.io/badge/license-MIT-0b0e0d?style=flat-square)](LICENSE)
16
+ [![Node](https://img.shields.io/badge/node-%3E%3D20-339933?style=flat-square&logo=nodejs&logoColor=white)](#requirements)
17
+
18
+ <br />
19
+
20
+ ```bash
21
+ pnpm add @buildaureon/sdk
22
+ ```
23
+
24
+ [Quickstart](#quickstart) · [Authentication](#authentication) · [API Surface](#api-surface) · [Docs](#documentation)
25
+
26
+ </div>
27
+
28
+ ---
29
+
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/`.
60
+
61
+ ---
62
+
63
+ ## What is AUREON?
64
+
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:
66
+
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.
72
+
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.
76
+
77
+ ```mermaid
78
+ flowchart LR
79
+ subgraph intent["Intent"]
80
+ FCO[Financial Compass Objective]
81
+ end
82
+ subgraph engine["Policy engine"]
83
+ Health[Health + Watchdog]
84
+ Plan[Restore planner]
85
+ end
86
+ subgraph settle["Settlement"]
87
+ Staged[staged receipt]
88
+ Vault[vault / on-chain]
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
+ | Register agent intent as objective + portfolio flow | `applyFinancialIntent`, `getObjectivePortfolioFlow` |
118
+ | Compare objective vs actual allocation | `getAllocationVsTarget` |
119
+ | Manage developer API keys | `createApiKey`, `listApiKeys`, `toggleApiKey`, `revokeApiKey` |
120
+
121
+ **This package alone does not:**
122
+
123
+ - Hold or rotate private keys.
124
+ - Broadcast transactions (your viem / wallet client does).
125
+ - Deploy Smart Vault contracts.
126
+ - Replace the hosted Health Watchdog — it calls it.
127
+
128
+ ---
129
+
130
+ ## Ecosystem
131
+
132
+ ```mermaid
133
+ flowchart TB
134
+ subgraph clients["Integrators"]
135
+ Agent[AI agent / operator script]
136
+ Utility[Operator utility]
137
+ end
138
+ subgraph npm_pkg["npm: @buildaureon/sdk"]
139
+ SDK[TypeScript client + CLI]
140
+ end
141
+ subgraph hosted["AUREON hosted layer"]
142
+ API[API gateway]
143
+ Watchdog[Health Watchdog]
144
+ Ledger[(Ledger store)]
145
+ end
146
+ subgraph chain["Robinhood Chain L2"]
147
+ Vault[Smart Vault]
148
+ Keeper[Keeper rebalance path]
149
+ end
150
+ Agent --> SDK
151
+ Utility --> SDK
152
+ SDK -->|HTTPS + API key + JWT| API
153
+ API --> Watchdog
154
+ API --> Ledger
155
+ Watchdog --> Keeper
156
+ Agent -->|sign + broadcast steps| Vault
157
+ Keeper --> Vault
158
+ ```
159
+
160
+ | Component | Surface | Role |
161
+ | --- | --- | --- |
162
+ | **@buildaureon/sdk** (this repo) | TypeScript / CLI | Typed client, session helpers, vault step prep |
163
+ | **AUREON API** | Hosted HTTPS | Objectives, health, timeline, restore coordination |
164
+ | **Operator utility** | [app.aureonlabs.network](https://app.aureonlabs.network) | Human console for keys, capital, and policy |
165
+ | **Smart Vaults** | Robinhood Chain | Non-custodial on-chain capital path |
166
+ | **Website** | [aureonlabs.network](https://www.aureonlabs.network/) | Product narrative and entry points |
167
+
168
+ ---
169
+
170
+ ## Full system architecture
171
+
172
+ Complete AUREON topology: SDK client, hosted policy engines, ledger, vault settlement, and local signing.
173
+
174
+ ```mermaid
175
+ flowchart TB
176
+ subgraph CLIENT["CLIENT LAYER — Operator / Agent"]
177
+ direction TB
178
+ APP["Host application"]
179
+ SDK["@buildaureon/sdk"]
180
+ SESSION["Session token provider"]
181
+ SIGNER["Wallet signer · Viem"]
182
+ APP --> SDK
183
+ APP --> SESSION
184
+ APP --> SIGNER
185
+ end
186
+
187
+ subgraph CLOUD["HOSTED INGRESS — AUREON API"]
188
+ direction TB
189
+ API["API gateway"]
190
+ DB[("Ledger store")]
191
+ ORACLE["Public price marks"]
192
+ HEALTH["Health evaluation"]
193
+ WATCH["Watchdog heartbeat"]
194
+ PLANNER["Restore planner"]
195
+ API --> DB
196
+ API --> HEALTH
197
+ API --> WATCH
198
+ ORACLE --> HEALTH
199
+ WATCH --> PLANNER
200
+ end
201
+
202
+ subgraph EVM["ROBINHOOD CHAIN L2"]
203
+ direction TB
204
+ VAULT["AUREON Smart Vault"]
205
+ KEEPER["Keeper rebalance adapter"]
206
+ KEEPER --> VAULT
207
+ end
208
+
209
+ SDK -->|"1 HTTPS · API key · JWT"| API
210
+ API -->|"2 health / plans / steps"| SDK
211
+ SIGNER -->|"3 sign + broadcast"| VAULT
212
+ WATCH -->|"4 violation → plan"| PLANNER
213
+ PLANNER -->|"5 vault_swap path"| KEEPER
214
+
215
+ style CLIENT fill:#f9faf3,stroke:#0b0e0d,color:#0b0e0d
216
+ style CLOUD fill:#f9faf3,stroke:#a8e00d,color:#0b0e0d
217
+ style EVM fill:#f9faf3,stroke:#0b0e0d,color:#0b0e0d
218
+ ```
219
+
220
+ ### Architecture at a glance
221
+
222
+ | Layer | Components | Trust boundary |
223
+ | --- | --- | --- |
224
+ | **Client** | Host app, `@buildaureon/sdk`, session provider, local signer | Keys and broadcast stay here |
225
+ | **Hosted** | API, ledger, oracles, health, watchdog, planner | Policy, pricing, coordination — no private keys |
226
+ | **Chain** | Smart Vault, keeper path | Settlement when `settlement: "vault"` |
227
+
228
+ Deep dive: [docs/architecture.md](docs/architecture.md) · [docs/security.md](docs/security.md) · [docs/integration-guide.md](docs/integration-guide.md)
229
+
230
+ ---
231
+
232
+ ## End-to-end flows
233
+
234
+ ### Client–API trust boundary
235
+
236
+ 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.
237
+
238
+ | Layer | Responsibility |
239
+ | --- | --- |
240
+ | **SDK** | Transport, validation, retries, EIP-712 helpers, vault step construction |
241
+ | **AUREON API** | Ledger sync, objective logic, price marks, timeline, staged or vault restore coordination |
242
+ | **Host application** | Key storage, wallet UX, signing, broadcasting |
243
+
244
+ ### Session authentication flow
245
+
246
+ Authentication is a challenge–response handshake that binds a wallet address to a temporary JWT.
247
+
248
+ ```mermaid
249
+ sequenceDiagram
250
+ autonumber
251
+ participant App as Client Operator
252
+ participant SDK as SDK Client
253
+ participant API as AUREON API Gateway
254
+
255
+ App->>SDK: aureon.getAuthNonce(address)
256
+ SDK->>API: GET /auth/nonce?address=0x...
257
+ API-->>SDK: { message, nonce, expiresAt }
258
+ SDK-->>App: { message, nonce }
259
+ Note over App: Operator signs message<br/>using private key
260
+ App->>SDK: aureon.verifyWallet({ address, message, signature })
261
+ SDK->>API: POST /auth/verify { address, message, signature }
262
+ API->>API: Verify EIP-191 Signature
263
+ API-->>SDK: { token, expiresAt, sessionId }
264
+ SDK-->>App: Return JWT Token
265
+ ```
266
+
267
+ ### Watchdog and restore flow
268
+
269
+ When portfolio weights drift past tolerance, health flips to violation and a restore plan becomes available.
270
+
271
+ ```mermaid
272
+ sequenceDiagram
273
+ autonumber
274
+ participant Client as Client Application
275
+ participant API as AUREON API Gateway
276
+ participant DB as Ledger Store
277
+ participant Engine as Health Engine
278
+ participant Keeper as Keeper Service
279
+
280
+ Client->>API: aureon.refreshWatchdog()
281
+ API->>DB: Pull price marks and positions
282
+ API->>Engine: Recompute objective deviations
283
+ alt Drift exceeds tolerance
284
+ Engine->>DB: Write health state: violation
285
+ Engine->>DB: Write event: violation_detected
286
+ Engine->>Keeper: Request restoration plan
287
+ Keeper-->>API: Return plan (e.g. vault_swap)
288
+ else Within bands
289
+ Engine->>DB: Write health state: healthy
290
+ end
291
+ API-->>Client: Watchdog status and breach reports
292
+ ```
293
+
294
+ Typical operator loop in prose:
295
+
296
+ 1. **Define capital** — sync the Capital Book from chain or seed an explicit book for rehearsal.
297
+ 2. **Register policy** — create a Financial Compass objective with target weight and tolerance.
298
+ 3. **Observe** — poll health and timeline; refresh the watchdog after market moves.
299
+ 4. **Restore** — fetch the plan, execute restore, read `settlement` on the receipt.
300
+ 5. **Verify** — confirm health returns to healthy and the timeline shows the restore event.
301
+
302
+ ---
303
+
304
+ ## Requirements & installation
305
+
306
+ ### Requirements
307
+
308
+ - **Node.js** 20 or higher (ESM).
309
+ - **Viem** 2.x when you sign and broadcast vault steps.
310
+
311
+ ### Installation
312
+
313
+ ```bash
314
+ pnpm add @buildaureon/sdk
315
+ # or
316
+ npm install @buildaureon/sdk
317
+ # or
318
+ yarn add @buildaureon/sdk
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Quick start
324
+
325
+ Initialize the client with an **issued** developer API key (Developers page in the utility).
326
+ That key identifies your wallet for control-plane calls — sync, objectives, health, restore plans.
327
+ A private key is only needed later to **broadcast** on-chain deposit/withdraw txs.
328
+
329
+ **SDK supports Automatic objectives only** (`automationMode: "auto"`, the default). Manual Approve workflows stay in the operator utility.
330
+
331
+ ```ts
332
+ import { createAureonClient } from "@buildaureon/sdk";
333
+
334
+ async function run() {
335
+ const aureon = createAureonClient({
336
+ baseUrl: "https://api.aureonlabs.network",
337
+ apiKey: process.env.AUREON_API_KEY!, // issued key from Developers console
338
+ });
339
+
340
+ const me = await aureon.me();
341
+ console.log("wallet", me.walletAddress);
342
+
343
+ const synced = await aureon.syncPortfolio();
344
+ console.log("Portfolio Value USD:", synced.portfolio.totalNotionalUsd);
345
+ }
346
+ ```
347
+
348
+ Optional wallet Bearer (nonce sign `verifyWallet`) still works and **wins** when both
349
+ are sent. Env bootstrap keys (`AUREON_API_KEYS` on the server) unlock product access only —
350
+ they do not identify a wallet; use an issued key or a Bearer session with those.
351
+
352
+ From here, create an objective, read health, and restore when the watchdog reports a violation.
353
+ Full walkthroughs live in [docs/integration-guide.md](docs/integration-guide.md).
354
+
355
+ ---
356
+
357
+ ## Detailed authentication guide
358
+
359
+ ### Issued API keys (recommended for SDK / agents)
360
+
361
+ Create a key in the operator utility **Developers** console. The plaintext secret is shown once.
362
+ Send it as `X-Aureon-Api-Key`. The gateway resolves the bound wallet and scopes ledger operations
363
+ to that address. Treat issued keys like passwords: pause, revoke, rotate; never commit them.
364
+
365
+ ### Private key / on-chain signing
366
+
367
+ `prepareVaultDeposit` / `prepareVaultWithdraw` return **unsigned** calldata. Broadcasting those
368
+ transactions (and any other signed chain steps) requires the wallet private key or a browser
369
+ wallet not the API key.
370
+
371
+ ### Wallet bearer handshake (optional)
372
+
373
+ Bearer sessions also scope ledger operations to a wallet. The SDK fetches a nonce message, the
374
+ host signs it with an EVM signer, and `/auth/verify` returns a session token for `getAccessToken`.
375
+ Use this for the browser utility, or when you only have an env bootstrap key (no issued key).
376
+
377
+ ### Token provider lifecycle
378
+
379
+ ```ts
380
+ import { createSessionTokenProvider } from "@buildaureon/sdk";
381
+
382
+ const session = createSessionTokenProvider(process.env.AUREON_TOKEN ?? null);
383
+
384
+ await aureon.logout();
385
+ session.clear();
386
+ ```
387
+
388
+ `createSessionTokenProvider` is a small stateful container: set after verify, clear on logout,
389
+ inject via `getAccessToken` so the client stays free of global mutable auth state.
390
+
391
+ ---
392
+
393
+ ## API surface reference & code walkthroughs
394
+
395
+ ### Connection smoke tests
396
+
397
+ ```ts
398
+ const ping = await aureon.ping();
399
+ console.log(`Connected. Backend version: ${ping.version}`);
400
+ ```
401
+
402
+ ### Managing the Capital Book
403
+
404
+ 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.
405
+
406
+ ```ts
407
+ const syncResult = await aureon.syncPortfolio();
408
+ console.log("Current stable coin weight:", syncResult.portfolio.stableWeight);
409
+
410
+ const updatedBook = await aureon.setPortfolio([
411
+ { symbol: "WETH", quantity: 2.5, category: "gas" },
412
+ { symbol: "USDG", quantity: 2500, category: "stable" },
413
+ ]);
414
+
415
+ await aureon.clearPortfolio();
416
+ ```
417
+
418
+ ### Defining and querying objectives
419
+
420
+ Objectives are the Financial Compass primitives: target weights, tolerance bands, and priority. SDK-created objectives participate in automatic restore coordination when health enters violation.
421
+
422
+ ```ts
423
+ const stableObj = await aureon.createObjective({
424
+ name: "Stable Core Reserve",
425
+ kind: "stable_allocation",
426
+ targetWeight: 0.3,
427
+ tolerance: 0.03,
428
+ priority: "high",
429
+ });
430
+
431
+ const stockObj = await aureon.createObjective({
432
+ name: "Tesla Sleeve Allocation",
433
+ kind: "balanced_portfolio",
434
+ targetSymbol: "TSLA",
435
+ targetWeight: 0.2,
436
+ tolerance: 0.05,
437
+ });
438
+
439
+ const objectives = await aureon.listObjectives();
440
+ ```
441
+
442
+ ### Health, timeline, and overview
443
+
444
+ ```ts
445
+ const healthRecords = await aureon.getHealth();
446
+ for (const health of healthRecords) {
447
+ console.log(`Objective ${health.objectiveId}: State: ${health.state}`);
448
+ }
449
+
450
+ const timeline = await aureon.getTimeline();
451
+ timeline.forEach((event) => console.log(`[${event.type}]: ${event.message}`));
452
+
453
+ const overview = await aureon.getOverview();
454
+ console.log("Global health score:", overview.globalHealthScore);
455
+ ```
456
+
457
+ ### Non-custodial vault operations
458
+
459
+ Vault helpers prepare unsigned steps. The host signs and broadcasts; AUREON never receives the private key.
460
+
461
+ ```ts
462
+ import type { Hex } from "viem";
463
+
464
+ const depositData = await aureon.prepareVaultDeposit({
465
+ symbol: "ETH",
466
+ amount: "0.5",
467
+ });
468
+
469
+ for (const step of depositData.steps) {
470
+ const hash = await walletClient.sendTransaction({
471
+ account,
472
+ to: step.to as `0x${string}`,
473
+ data: step.data as Hex,
474
+ value: BigInt(step.value),
475
+ });
476
+ await publicClient.waitForTransactionReceipt({ hash });
477
+ }
478
+ ```
479
+
480
+ ### Restore plans and rebalances
481
+
482
+ When health is in violation, fetch the plan and execute. Always read `settlement` on the receipt.
483
+
484
+ ```ts
485
+ const plan = await aureon.getRestorePlan(objective.id);
486
+ console.log(`Plan requires action: ${plan.kind} for ${plan.amountHuman} tokens.`);
487
+
488
+ if (plan.kind === "vault_swap") {
489
+ const receipt = await aureon.restoreObjective(objective.id);
490
+ console.log("Rebalance transaction hash:", receipt.transactionHash);
491
+ console.log("Settlement environment:", receipt.settlement); // "vault" | "staged"
492
+ } else {
493
+ console.warn("Execute wrap_eth or unwrap_weth with your wallet provider.");
494
+ }
495
+ ```
496
+
497
+ ### Controlled market events
498
+
499
+ 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.
500
+
501
+ ```ts
502
+ const shockResult = await aureon.applyMarketEvent({
503
+ symbol: "NVDA",
504
+ priceChangeRatio: -0.15,
505
+ autoRestore: true,
506
+ });
507
+ ```
508
+
509
+ ### Developer API key management
510
+
511
+ ```ts
512
+ const newKey = await aureon.createApiKey("Secondary Bot Ingress");
513
+ console.log(`Plaintext secret: ${newKey.secret}`);
514
+
515
+ const keys = await aureon.listApiKeys();
516
+ await aureon.toggleApiKey(newKey.id);
517
+ await aureon.revokeApiKey(newKey.id);
518
+ ```
519
+
520
+ ---
521
+
522
+ ## Client configuration & transport engine
523
+
524
+ ### Configuration reference
525
+
526
+ | Parameter | Type | Default | Description |
527
+ | --- | --- | --- | --- |
528
+ | `baseUrl` | `string` | `"https://api.aureonlabs.network"` | API ingress |
529
+ | `apiKey` | `string` | `undefined` | Sent as `X-Aureon-Api-Key` |
530
+ | `authToken` | `string` | `undefined` | Static JWT bearer |
531
+ | `getAccessToken` | `() => string \| null` | `undefined` | Dynamic bearer resolver |
532
+ | `timeoutMs` | `number` | `30000` | Per-call abort threshold |
533
+ | `maxRetries` | `number` | `0` | Transient failure retries |
534
+ | `retryDelayMs` | `number` | `250` | Delay between retries |
535
+ | `headers` | `Record<string, string>` | `{}` | Extra headers |
536
+ | `fetch` | `typeof fetch` | `globalThis.fetch` | Custom fetch override |
537
+
538
+ ### Retries and failover
539
+
540
+ 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.
541
+
542
+ ---
543
+
544
+ ## Error model and code handling
545
+
546
+ ### Error code reference
547
+
548
+ | Code | HTTP | Description |
549
+ | --- | --- | --- |
550
+ | `UNAUTHORIZED` | 401 | Missing or invalid API key or bearer |
551
+ | `VALIDATION_ERROR` | 400 | Payload failed validation |
552
+ | `NOT_FOUND` | 404 | Objective, key, or resource missing |
553
+ | `CONFLICT` | 409 | Request conflicts with current ledger state |
554
+ | `RATE_LIMITED` | 429 | Request volume exceeded |
555
+ | `SERVER_ERROR` | 500 / 503 | Hosted execution failure |
556
+ | `TIMEOUT` | — | Exceeded `timeoutMs` |
557
+ | `NETWORK_ERROR` | | Endpoint unreachable |
558
+
559
+ ### Narrowing errors in practice
560
+
561
+ ```ts
562
+ import { isAureonError } from "@buildaureon/sdk";
563
+
564
+ try {
565
+ await aureon.getObjective("missing_id");
566
+ } catch (error) {
567
+ if (isAureonError(error)) {
568
+ switch (error.code) {
569
+ case "NOT_FOUND":
570
+ console.error("The specified objective does not exist.");
571
+ break;
572
+ case "UNAUTHORIZED":
573
+ console.error("Check API key and wallet session configuration.");
574
+ break;
575
+ default:
576
+ console.error(`Aureon error: ${error.message}`);
577
+ }
578
+ } else {
579
+ console.error("Generic execution failure:", error);
580
+ }
581
+ }
582
+ ```
583
+
584
+ Full matrix: [docs/error-model.md](docs/error-model.md).
585
+
586
+ ---
587
+
588
+ ## CLI command-line guide
589
+
590
+ The package ships a developer CLI. Configure credentials via environment variables:
591
+
592
+ ```bash
593
+ # Issued developer key (recommended) — identifies wallet;
594
+ export AUREON_API_KEY=aureon_....
595
+
596
+ pnpm --filter @buildaureon/sdk cli ping
597
+ pnpm --filter @buildaureon/sdk cli me
598
+ pnpm --filter @buildaureon/sdk cli sync
599
+ pnpm --filter @buildaureon/sdk cli portfolio
600
+ pnpm --filter @buildaureon/sdk cli objectives
601
+ ```
602
+
603
+ ### Runnable examples (live API)
604
+
605
+ Requires `AUREON_API_KEY`:
606
+
607
+ ```bash
608
+ pnpm example:ai-to-objective-to-portfolio
609
+ pnpm example:drift-detect-restore
610
+ pnpm example:receipt-verification
611
+ pnpm example:portfolio-watch
612
+ pnpm example:full-aureon-loop
613
+ pnpm example:green-vs-plan
614
+ ```
615
+
616
+ ---
617
+
618
+ ## Design principles & settlement honesty
619
+
620
+ 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.
621
+ 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.
622
+ 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.
623
+ 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.
624
+
625
+ ---
626
+
627
+ ## Documentation registry
628
+
629
+ Long-form technical docs live under `docs/`:
630
+
631
+ | Document | Focus |
632
+ | --- | --- |
633
+ | [docs/architecture.md](docs/architecture.md) | Client vs API boundary, system maps |
634
+ | [docs/auth.md](docs/auth.md) | Wallet handshake and JWT lifecycle |
635
+ | [docs/client-api.md](docs/client-api.md) | Method and parameter index |
636
+ | [docs/data-contracts.md](docs/data-contracts.md) | Types aligned to hosted JSON |
637
+ | [docs/error-model.md](docs/error-model.md) | Full error code mapping |
638
+ | [docs/integration-guide.md](docs/integration-guide.md) | End-to-end integrator walkthrough |
639
+ | [docs/security.md](docs/security.md) | API key and token guidance |
640
+ | [docs/transport.md](docs/transport.md) | Retries, headers, transport edge cases |
641
+
642
+ ---
643
+
644
+ ## Community & resources
645
+
646
+ - **Website:** [aureonlabs.network](https://www.aureonlabs.network/)
647
+ - **Operator utility:** [app.aureonlabs.network](https://app.aureonlabs.network)
648
+ - **X:** [@buildaureon](https://x.com/buildaureon)
649
+ - **GitHub:** [github.com/buildaureon](https://github.com/buildaureon)
650
+
651
+ ---
652
+
653
+ ## License
654
+
655
+ MIT — see [LICENSE](LICENSE).