@buildaureon/sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +532 -0
- package/config/network.json +10 -0
- package/dist/index.d.ts +792 -0
- package/dist/index.js +1030 -0
- package/dist/index.js.map +1 -0
- package/docs/architecture.md +205 -0
- package/docs/auth.md +215 -0
- package/docs/client-api.md +604 -0
- package/docs/data-contracts.md +632 -0
- package/docs/error-model.md +182 -0
- package/docs/integration-guide.md +196 -0
- package/docs/security.md +74 -0
- package/docs/transport.md +128 -0
- package/examples/e2e-policy-rebalance/main.ts +438 -0
- package/examples/e2e-policy-rebalance/underrun.ts +134 -0
- package/examples/e2e-policy-rebalance/verify-sizing.ts +147 -0
- package/examples/e2e-vault-flow/main.ts +270 -0
- package/examples/market-event/main.ts +65 -0
- package/examples/quickstart/main.ts +71 -0
- package/fixtures/reference-objectives.json +18 -0
- package/fixtures/reference-portfolio.json +10 -0
- package/package.json +64 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
interface AureonLogger {
|
|
2
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
3
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
4
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
5
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
6
|
+
}
|
|
7
|
+
declare const silentLogger: AureonLogger;
|
|
8
|
+
declare function createConsoleLogger(prefix?: string): AureonLogger;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @fileoverview Client configuration types for AureonClient.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface AureonClientOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Base URL of the AUREON API.
|
|
17
|
+
* Defaults to `https://api.aureonlabs.network`.
|
|
18
|
+
*/
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Product API key sent as `X-Aureon-Api-Key` on every request.
|
|
22
|
+
* Required for SDK / CLI / code when keys are enforced and there is no
|
|
23
|
+
* wallet Bearer yet. The operator utility uses wallet Bearer only.
|
|
24
|
+
*/
|
|
25
|
+
apiKey?: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Called before each request to resolve the product API key.
|
|
28
|
+
* Prefer this for automations that load keys from env or a secret store.
|
|
29
|
+
*/
|
|
30
|
+
getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
31
|
+
/** Optional fetch implementation for non-browser runtimes. */
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
/** Optional default headers merged into every request. */
|
|
34
|
+
headers?: Record<string, string>;
|
|
35
|
+
/** Request timeout in milliseconds. Defaults to 30000. */
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Static Bearer session token. Prefer `getAccessToken` for apps that refresh
|
|
39
|
+
* or clear sessions at runtime.
|
|
40
|
+
*/
|
|
41
|
+
authToken?: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Called before each request to resolve the current Bearer token.
|
|
44
|
+
* Return null/undefined to send the request without Authorization.
|
|
45
|
+
*/
|
|
46
|
+
getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
47
|
+
/** Optional structured logger for request lifecycle diagnostics. */
|
|
48
|
+
logger?: AureonLogger;
|
|
49
|
+
/**
|
|
50
|
+
* Extra attempts after the first failure for retryable errors
|
|
51
|
+
* (network, timeout, 429, 5xx). Defaults to 0.
|
|
52
|
+
*/
|
|
53
|
+
maxRetries?: number;
|
|
54
|
+
/** Delay in ms between retries. Defaults to 250. */
|
|
55
|
+
retryDelayMs?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @fileoverview Execution receipt + restore-plan types.
|
|
60
|
+
*
|
|
61
|
+
* Receipts may settle as vault on-chain rebalance (`settlement: "vault"`) or
|
|
62
|
+
* as a staged capital-book update (`settlement: "staged"`) when the vault
|
|
63
|
+
* path is unavailable. Wrap/unwrap ETH↔WETH is client-side via RestorePlan.
|
|
64
|
+
*/
|
|
65
|
+
interface ExecutionReceipt {
|
|
66
|
+
id: string;
|
|
67
|
+
objectiveId: string;
|
|
68
|
+
status: "pending" | "submitted" | "confirmed" | "failed";
|
|
69
|
+
transactionHash: string;
|
|
70
|
+
action: string;
|
|
71
|
+
notionalAdjustedUsd: number;
|
|
72
|
+
result: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
confirmedAt: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* `"vault"`: keeper rebalance confirmed (or pending_vault_* then confirmed).
|
|
77
|
+
* `"staged"`: capital-book restore only (honest non-finality label).
|
|
78
|
+
*/
|
|
79
|
+
settlement?: "staged" | "vault";
|
|
80
|
+
}
|
|
81
|
+
/** Client-side restore action: wrap/unwrap ETH↔WETH or keeper vault swap. */
|
|
82
|
+
type RestorePlanKind = "wrap_eth" | "unwrap_weth" | "vault_swap";
|
|
83
|
+
interface RestorePlan {
|
|
84
|
+
kind: RestorePlanKind;
|
|
85
|
+
amountHuman: string;
|
|
86
|
+
approxUsd: number;
|
|
87
|
+
message: string;
|
|
88
|
+
sellSymbol?: string;
|
|
89
|
+
buySymbol?: string;
|
|
90
|
+
}
|
|
91
|
+
/** True when the receipt claims vault (on-chain) settlement. */
|
|
92
|
+
declare function isVaultSettlement(receipt: ExecutionReceipt): boolean;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @fileoverview Health Engine result types.
|
|
96
|
+
*/
|
|
97
|
+
type HealthState = "healthy" | "warning" | "violation" | "paused";
|
|
98
|
+
interface ObjectiveHealth {
|
|
99
|
+
objectiveId: string;
|
|
100
|
+
state: HealthState;
|
|
101
|
+
score: number;
|
|
102
|
+
currentMetric: number;
|
|
103
|
+
targetMetric: number;
|
|
104
|
+
deviation: number;
|
|
105
|
+
message: string;
|
|
106
|
+
evaluatedAt: string;
|
|
107
|
+
}
|
|
108
|
+
declare function isHealthState(value: string): value is HealthState;
|
|
109
|
+
declare function pickWorstHealth(records: ObjectiveHealth[]): ObjectiveHealth | null;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @fileoverview Timeline event contracts for append-only operator narratives.
|
|
113
|
+
*/
|
|
114
|
+
type TimelineEventType = "objective_created" | "objective_updated" | "objective_paused" | "objective_resumed" | "health_changed" | "violation_detected" | "evaluation_started" | "execution_started" | "execution_completed" | "market_event_applied" | "objective_restored" | "capital_provisioned" | "capital_cleared" | "capital_synced";
|
|
115
|
+
interface TimelineEvent {
|
|
116
|
+
id: string;
|
|
117
|
+
objectiveId: string | null;
|
|
118
|
+
type: TimelineEventType;
|
|
119
|
+
message: string;
|
|
120
|
+
payload: Record<string, unknown>;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
}
|
|
123
|
+
declare const TIMELINE_EVENT_TYPES: readonly TimelineEventType[];
|
|
124
|
+
declare function isTimelineEventType(value: string): value is TimelineEventType;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @fileoverview Controlled market event types for operator demos and rehearsals.
|
|
128
|
+
*/
|
|
129
|
+
interface MarketEvent {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
description: string;
|
|
133
|
+
symbol: string;
|
|
134
|
+
priceChangeRatio: number;
|
|
135
|
+
appliedAt: string;
|
|
136
|
+
}
|
|
137
|
+
interface MarketPreset {
|
|
138
|
+
name: string;
|
|
139
|
+
description: string;
|
|
140
|
+
symbol: string;
|
|
141
|
+
priceChangeRatio: number;
|
|
142
|
+
}
|
|
143
|
+
interface ApplyMarketEventInput {
|
|
144
|
+
name?: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
symbol: string;
|
|
147
|
+
priceChangeRatio: number;
|
|
148
|
+
autoRestore?: boolean;
|
|
149
|
+
}
|
|
150
|
+
interface DashboardOverview {
|
|
151
|
+
activeObjectives: number;
|
|
152
|
+
healthyCount: number;
|
|
153
|
+
warningCount: number;
|
|
154
|
+
violationCount: number;
|
|
155
|
+
pausedCount: number;
|
|
156
|
+
totalNotionalUsd: number;
|
|
157
|
+
stableWeight: number;
|
|
158
|
+
/** Holdings count from the capital book. */
|
|
159
|
+
assetCount: number;
|
|
160
|
+
/** Absolute USD change vs prior UTC day snapshot; null when baseline only. */
|
|
161
|
+
change24hUsd: number | null;
|
|
162
|
+
/** Fractional change (0.05 = +5%); null when baseline only. */
|
|
163
|
+
change24hPct: number | null;
|
|
164
|
+
/** True when no prior-day snapshot exists yet. */
|
|
165
|
+
change24hBaselineOnly: boolean;
|
|
166
|
+
/** True when today's snapshot row exists. */
|
|
167
|
+
change24hHasSnapshot: boolean;
|
|
168
|
+
/** Average health score across non-paused objectives; null when none. */
|
|
169
|
+
globalHealthScore: number | null;
|
|
170
|
+
/** Persisted health samples (oldest → newest), up to ~90 days. */
|
|
171
|
+
healthHistory: Array<{
|
|
172
|
+
at: string;
|
|
173
|
+
score: number;
|
|
174
|
+
}>;
|
|
175
|
+
/** warning + violation count. */
|
|
176
|
+
attentionCount: number;
|
|
177
|
+
/** Last successful live-mark watchdog evaluation (not overview poll). */
|
|
178
|
+
lastEvaluationAt: string | null;
|
|
179
|
+
/** lastEvaluationAt + watchdog interval when continuous monitor is configured. */
|
|
180
|
+
nextEvaluationAt: string | null;
|
|
181
|
+
watchdogIntervalMs: number | null;
|
|
182
|
+
/** Last background/manual watchdog failure message, if any. */
|
|
183
|
+
lastWatchdogError: string | null;
|
|
184
|
+
lastSyncedAt: string | null;
|
|
185
|
+
recentExecutions: ExecutionReceipt[];
|
|
186
|
+
recentEvents: TimelineEvent[];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @fileoverview Objective domain types for Financial Compass Objectives.
|
|
191
|
+
*/
|
|
192
|
+
/** Lifecycle status for a Financial Compass Objective (FCO). */
|
|
193
|
+
type ObjectiveStatus = "draft" | "validated" | "active" | "paused" | "cancelled" | "completed";
|
|
194
|
+
/** Supported objective kinds for Phase 1 operator workflows. */
|
|
195
|
+
type ObjectiveKind = "stable_allocation" | "balanced_portfolio" | "risk_ceiling" | "reward_reinvestment";
|
|
196
|
+
/** Priority influences evaluation ordering when multiple objectives compete. */
|
|
197
|
+
type ObjectivePriority = "low" | "medium" | "high" | "critical";
|
|
198
|
+
/**
|
|
199
|
+
* Per-objective restore behaviour as stored on the API.
|
|
200
|
+
*
|
|
201
|
+
* SDK / agent integrations create objectives as **Automatic** (default).
|
|
202
|
+
* `"manual"` exists so the operator utility can require an Approve click;
|
|
203
|
+
* it is not part of the recommended SDK integration path.
|
|
204
|
+
*/
|
|
205
|
+
type ObjectiveAutomationMode = "manual" | "auto";
|
|
206
|
+
/** Policy rules attached to an objective. */
|
|
207
|
+
interface ObjectivePolicy {
|
|
208
|
+
targetWeight: number;
|
|
209
|
+
tolerance: number;
|
|
210
|
+
maxRiskScore?: number;
|
|
211
|
+
reinvestRatio?: number;
|
|
212
|
+
/** Holding symbol when the objective tracks a specific asset weight. */
|
|
213
|
+
targetSymbol?: string;
|
|
214
|
+
summary: string;
|
|
215
|
+
}
|
|
216
|
+
/** Financial Compass Objective record. */
|
|
217
|
+
interface Objective {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
kind: ObjectiveKind;
|
|
221
|
+
status: ObjectiveStatus;
|
|
222
|
+
priority: ObjectivePriority;
|
|
223
|
+
/**
|
|
224
|
+
* Restore mode for this objective.
|
|
225
|
+
* SDK creates always set `"auto"`. `"manual"` is operator-utility only.
|
|
226
|
+
*/
|
|
227
|
+
automationMode: ObjectiveAutomationMode;
|
|
228
|
+
policy: ObjectivePolicy;
|
|
229
|
+
ownerId: string;
|
|
230
|
+
createdAt: string;
|
|
231
|
+
updatedAt: string;
|
|
232
|
+
lastEvaluatedAt: string | null;
|
|
233
|
+
lastExecutionId: string | null;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Input for creating a new objective.
|
|
237
|
+
*
|
|
238
|
+
* SDK create always sends `automationMode: "auto"` (Automatic restore).
|
|
239
|
+
* Manual Approve is an operator-utility concern; do not rely on it in
|
|
240
|
+
* agent / SDK loops.
|
|
241
|
+
*/
|
|
242
|
+
interface CreateObjectiveInput {
|
|
243
|
+
name: string;
|
|
244
|
+
kind: ObjectiveKind;
|
|
245
|
+
priority?: ObjectivePriority;
|
|
246
|
+
targetWeight: number;
|
|
247
|
+
tolerance: number;
|
|
248
|
+
maxRiskScore?: number;
|
|
249
|
+
reinvestRatio?: number;
|
|
250
|
+
targetSymbol?: string | null;
|
|
251
|
+
/**
|
|
252
|
+
* @deprecated For SDK integrations omit this; create always uses Automatic.
|
|
253
|
+
* The operator utility may still pass `"manual"` for Approve UX.
|
|
254
|
+
*/
|
|
255
|
+
automationMode?: ObjectiveAutomationMode;
|
|
256
|
+
}
|
|
257
|
+
/** Partial update for an existing objective. */
|
|
258
|
+
interface UpdateObjectiveInput {
|
|
259
|
+
name?: string;
|
|
260
|
+
priority?: ObjectivePriority;
|
|
261
|
+
targetWeight?: number;
|
|
262
|
+
tolerance?: number;
|
|
263
|
+
maxRiskScore?: number;
|
|
264
|
+
reinvestRatio?: number;
|
|
265
|
+
targetSymbol?: string | null;
|
|
266
|
+
/**
|
|
267
|
+
* @deprecated Rejected on update; mode is fixed at create to avoid restore-flow issues.
|
|
268
|
+
* Recreate the objective to switch Manual ↔ Automatic.
|
|
269
|
+
*/
|
|
270
|
+
automationMode?: never;
|
|
271
|
+
}
|
|
272
|
+
declare const OBJECTIVE_KINDS: readonly ObjectiveKind[];
|
|
273
|
+
declare const OBJECTIVE_PRIORITIES: readonly ObjectivePriority[];
|
|
274
|
+
declare function isObjectiveKind(value: string): value is ObjectiveKind;
|
|
275
|
+
declare function isObjectivePriority(value: string): value is ObjectivePriority;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @fileoverview Portfolio snapshot types used by health evaluation and utility screens.
|
|
279
|
+
*/
|
|
280
|
+
interface PortfolioPosition {
|
|
281
|
+
id: string;
|
|
282
|
+
symbol: string;
|
|
283
|
+
name: string;
|
|
284
|
+
category: "stable" | "stock_token" | "gas" | "other";
|
|
285
|
+
quantity: number;
|
|
286
|
+
markPriceUsd: number;
|
|
287
|
+
notionalUsd: number;
|
|
288
|
+
weight: number;
|
|
289
|
+
updatedAt: string;
|
|
290
|
+
}
|
|
291
|
+
interface PortfolioSnapshot {
|
|
292
|
+
portfolioId: string;
|
|
293
|
+
totalNotionalUsd: number;
|
|
294
|
+
stableWeight: number;
|
|
295
|
+
stockTokenWeight: number;
|
|
296
|
+
gasWeight: number;
|
|
297
|
+
positions: PortfolioPosition[];
|
|
298
|
+
asOf: string;
|
|
299
|
+
}
|
|
300
|
+
/** Input row for replacing the capital book (no id, server assigns). */
|
|
301
|
+
interface PortfolioPositionInput {
|
|
302
|
+
symbol: string;
|
|
303
|
+
name: string;
|
|
304
|
+
category: PortfolioPosition["category"];
|
|
305
|
+
quantity: number;
|
|
306
|
+
markPriceUsd: number;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @fileoverview Vault overview + prepare-tx contracts for AureonVault.
|
|
311
|
+
*
|
|
312
|
+
* Reads come from GET /vault and GET /vault/status.
|
|
313
|
+
* Writes are wallet-signed: prepareDeposit / prepareWithdraw return calldata
|
|
314
|
+
* steps; the host (or agent signer) broadcasts them; the API never holds
|
|
315
|
+
* user keys.
|
|
316
|
+
*/
|
|
317
|
+
/** Allowlisted vault token metadata from GET /vault. */
|
|
318
|
+
interface VaultToken {
|
|
319
|
+
symbol: string;
|
|
320
|
+
name: string;
|
|
321
|
+
address: string;
|
|
322
|
+
decimals: number;
|
|
323
|
+
category?: string;
|
|
324
|
+
}
|
|
325
|
+
/** Per-token vault balance for the session wallet. */
|
|
326
|
+
interface VaultBalance {
|
|
327
|
+
symbol: string;
|
|
328
|
+
name: string;
|
|
329
|
+
/** ERC-20 token address held inside the vault accounting. */
|
|
330
|
+
token: string;
|
|
331
|
+
decimals: number;
|
|
332
|
+
category?: string;
|
|
333
|
+
/** Raw integer amount as a decimal string (wei / token base units). */
|
|
334
|
+
raw: string;
|
|
335
|
+
quantity: number;
|
|
336
|
+
markPriceUsd: number | null;
|
|
337
|
+
notionalUsd: number | null;
|
|
338
|
+
}
|
|
339
|
+
/** Full vault overview for the authenticated wallet. */
|
|
340
|
+
interface VaultOverview {
|
|
341
|
+
address: string;
|
|
342
|
+
chainId: number;
|
|
343
|
+
tokens: VaultToken[];
|
|
344
|
+
balances: VaultBalance[];
|
|
345
|
+
poolAddress: string | null;
|
|
346
|
+
explorerBase: string;
|
|
347
|
+
keeperAddress: string | null;
|
|
348
|
+
}
|
|
349
|
+
/** Compact funding signal used before restore. */
|
|
350
|
+
interface VaultStatus {
|
|
351
|
+
empty: boolean;
|
|
352
|
+
totalNotionalUsd: number;
|
|
353
|
+
canRestore: boolean;
|
|
354
|
+
}
|
|
355
|
+
/** One wallet-signed step from prepareDeposit / prepareWithdraw. */
|
|
356
|
+
interface VaultPreparedStep {
|
|
357
|
+
to: string;
|
|
358
|
+
data: string;
|
|
359
|
+
/** Native wei as a decimal string (`"0"` for ERC-20 paths). */
|
|
360
|
+
value: string;
|
|
361
|
+
functionName: "approve" | "deposit" | "depositETH" | "withdraw";
|
|
362
|
+
label: string;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Calldata plan for vault deposit or withdraw.
|
|
366
|
+
* Sign `steps` in order with the session wallet (and matching `chainId`).
|
|
367
|
+
*/
|
|
368
|
+
interface VaultPrepareResult {
|
|
369
|
+
chainId: number;
|
|
370
|
+
vaultAddress: string;
|
|
371
|
+
explorerBase: string;
|
|
372
|
+
symbol: string;
|
|
373
|
+
amountRaw: string;
|
|
374
|
+
amountHuman: string;
|
|
375
|
+
steps: VaultPreparedStep[];
|
|
376
|
+
}
|
|
377
|
+
/** Native ETH or any allowlisted vault ERC-20 symbol (WETH, stables, …). */
|
|
378
|
+
type VaultDepositSymbol = string;
|
|
379
|
+
/** Any allowlisted vault ERC-20 (not native ETH, use WETH). */
|
|
380
|
+
type VaultWithdrawSymbol = string;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* @fileoverview Watchdog contracts: live marks, breaches, restore suggestions.
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
type MarkQuoteSource = "peg" | "coingecko" | "yahoo" | "unchanged";
|
|
387
|
+
interface MarkQuote {
|
|
388
|
+
symbol: string;
|
|
389
|
+
priceUsd: number;
|
|
390
|
+
source: MarkQuoteSource;
|
|
391
|
+
}
|
|
392
|
+
interface RestoreSuggestionAction {
|
|
393
|
+
side: "buy" | "sell";
|
|
394
|
+
symbol: string;
|
|
395
|
+
quantity: number;
|
|
396
|
+
approxUsd: number;
|
|
397
|
+
}
|
|
398
|
+
interface RestoreSuggestion {
|
|
399
|
+
objectiveId: string;
|
|
400
|
+
objectiveName: string;
|
|
401
|
+
targetStableWeight: number;
|
|
402
|
+
currentStableWeight: number;
|
|
403
|
+
deltaStableUsd: number;
|
|
404
|
+
actions: RestoreSuggestionAction[];
|
|
405
|
+
note: string;
|
|
406
|
+
}
|
|
407
|
+
interface WatchdogAlertResult {
|
|
408
|
+
objectiveId: string;
|
|
409
|
+
sent: boolean;
|
|
410
|
+
reason?: string;
|
|
411
|
+
}
|
|
412
|
+
interface WatchdogRefreshResult {
|
|
413
|
+
refreshedAt: string;
|
|
414
|
+
quotes: MarkQuote[];
|
|
415
|
+
skippedSymbols: string[];
|
|
416
|
+
portfolio: PortfolioSnapshot;
|
|
417
|
+
health: ObjectiveHealth[];
|
|
418
|
+
breaches: ObjectiveHealth[];
|
|
419
|
+
suggestions: RestoreSuggestion[];
|
|
420
|
+
alerts: WatchdogAlertResult[];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @fileoverview AureonClient: primary entry point for @buildaureon/sdk.
|
|
425
|
+
*
|
|
426
|
+
* Typed HTTP client for the hosted AUREON API. Wallet Bearer sessions identify
|
|
427
|
+
* the operator; `apiKey` (`X-Aureon-Api-Key`) unlocks product access.
|
|
428
|
+
*
|
|
429
|
+
* Objectives default to Automatic automation mode. Vault deposit and withdraw
|
|
430
|
+
* are prepare-calldata steps for wallet signing; not server-side broadcasts.
|
|
431
|
+
* Restorative execution receipts may use `settlement: "vault"` or
|
|
432
|
+
* `settlement: "staged"` depending on the restore path.
|
|
433
|
+
*/
|
|
434
|
+
|
|
435
|
+
interface AuthNonceResponse {
|
|
436
|
+
walletAddress: string;
|
|
437
|
+
nonce: string;
|
|
438
|
+
message: string;
|
|
439
|
+
expiresAt: string;
|
|
440
|
+
}
|
|
441
|
+
interface AuthSessionResponse {
|
|
442
|
+
token: string;
|
|
443
|
+
walletAddress: string;
|
|
444
|
+
expiresAt: string;
|
|
445
|
+
sessionId: string;
|
|
446
|
+
mode?: string;
|
|
447
|
+
}
|
|
448
|
+
interface AuthMeResponse {
|
|
449
|
+
walletAddress: string;
|
|
450
|
+
}
|
|
451
|
+
interface SyncPortfolioResult {
|
|
452
|
+
portfolio: PortfolioSnapshot;
|
|
453
|
+
chainId: number;
|
|
454
|
+
skippedZero: string[];
|
|
455
|
+
}
|
|
456
|
+
interface DeveloperApiKey {
|
|
457
|
+
id: string;
|
|
458
|
+
name: string;
|
|
459
|
+
prefix: string;
|
|
460
|
+
status: string;
|
|
461
|
+
createdAt: string;
|
|
462
|
+
revokedAt: string | null;
|
|
463
|
+
}
|
|
464
|
+
interface CreatedDeveloperApiKey extends DeveloperApiKey {
|
|
465
|
+
/** Plaintext secret; only returned once at creation. */
|
|
466
|
+
secret: string;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* High-level SDK client for AUREON operator and developer integrations.
|
|
470
|
+
*/
|
|
471
|
+
declare class AureonClient {
|
|
472
|
+
private readonly transport;
|
|
473
|
+
constructor(options?: AureonClientOptions);
|
|
474
|
+
/** Returns the resolved API base URL. */
|
|
475
|
+
get baseUrl(): string;
|
|
476
|
+
/** Health probe for connectivity checks. No auth required. */
|
|
477
|
+
ping(): Promise<{
|
|
478
|
+
ok: true;
|
|
479
|
+
service: string;
|
|
480
|
+
version: string;
|
|
481
|
+
}>;
|
|
482
|
+
/**
|
|
483
|
+
* Requests a single-use wallet auth nonce/message for the given address.
|
|
484
|
+
* No Bearer token required.
|
|
485
|
+
*/
|
|
486
|
+
getAuthNonce(address: string): Promise<AuthNonceResponse>;
|
|
487
|
+
/**
|
|
488
|
+
* Verifies a wallet signature and returns a Bearer session.
|
|
489
|
+
* No Bearer token required on the request itself.
|
|
490
|
+
*/
|
|
491
|
+
verifyWallet(input: {
|
|
492
|
+
address: string;
|
|
493
|
+
message: string;
|
|
494
|
+
signature: string;
|
|
495
|
+
}): Promise<AuthSessionResponse>;
|
|
496
|
+
/**
|
|
497
|
+
* Local preview login without a wallet signature.
|
|
498
|
+
* Only succeeds when the backend has `AUREON_ALLOW_DEV_LOGIN=1`.
|
|
499
|
+
*/
|
|
500
|
+
devLogin(): Promise<AuthSessionResponse>;
|
|
501
|
+
/** Revokes the current Bearer session on the server. */
|
|
502
|
+
logout(): Promise<{
|
|
503
|
+
ok: true;
|
|
504
|
+
}>;
|
|
505
|
+
/** Returns the wallet bound to the current Bearer session. Auth required. */
|
|
506
|
+
me(): Promise<AuthMeResponse>;
|
|
507
|
+
/**
|
|
508
|
+
* Creates and activates a Financial Compass Objective (FCO).
|
|
509
|
+
* SDK / agent path always prefers Automatic (`automationMode` omitted → `"auto"`).
|
|
510
|
+
* Mode cannot be changed later via `updateObjective`; recreate instead.
|
|
511
|
+
* Passing `"manual"` is reserved for the operator utility Approve UX.
|
|
512
|
+
* Auth required.
|
|
513
|
+
*/
|
|
514
|
+
createObjective(input: CreateObjectiveInput): Promise<Objective>;
|
|
515
|
+
/** Lists objectives for the authenticated wallet. Auth required. */
|
|
516
|
+
listObjectives(): Promise<Objective[]>;
|
|
517
|
+
/** Fetches a single objective by id. Auth required. */
|
|
518
|
+
getObjective(id: string): Promise<Objective>;
|
|
519
|
+
/**
|
|
520
|
+
* Applies a partial update to an objective policy or metadata.
|
|
521
|
+
* Does **not** accept `automationMode` (mode is locked at create).
|
|
522
|
+
* Auth required.
|
|
523
|
+
*/
|
|
524
|
+
updateObjective(id: string, input: UpdateObjectiveInput): Promise<Objective>;
|
|
525
|
+
/** Pauses continuous evaluation for an objective. Auth required. */
|
|
526
|
+
pauseObjective(id: string): Promise<Objective>;
|
|
527
|
+
/** Resumes evaluation for a paused objective. Auth required. */
|
|
528
|
+
resumeObjective(id: string): Promise<Objective>;
|
|
529
|
+
/** Returns health for one objective or all objectives when id is omitted. Auth required. */
|
|
530
|
+
getHealth(objectiveId?: string): Promise<ObjectiveHealth[]>;
|
|
531
|
+
/** Returns timeline events, optionally filtered by objective. Auth required. */
|
|
532
|
+
getTimeline(objectiveId?: string): Promise<TimelineEvent[]>;
|
|
533
|
+
/** Returns the current portfolio snapshot for the wallet. Auth required. */
|
|
534
|
+
getPortfolio(): Promise<PortfolioSnapshot>;
|
|
535
|
+
/**
|
|
536
|
+
* Replaces the wallet capital book with the provided positions.
|
|
537
|
+
* Auth required. Does not invent holdings: every row must be supplied.
|
|
538
|
+
*/
|
|
539
|
+
setPortfolio(positions: PortfolioPositionInput[]): Promise<PortfolioSnapshot>;
|
|
540
|
+
/**
|
|
541
|
+
* Clears all capital-book positions for the authenticated wallet.
|
|
542
|
+
* Auth required. Does not invent seeded holdings.
|
|
543
|
+
*/
|
|
544
|
+
clearPortfolio(): Promise<PortfolioSnapshot>;
|
|
545
|
+
/**
|
|
546
|
+
* Replaces the capital book with on-chain balances for the session wallet
|
|
547
|
+
* (Robinhood Chain via the AUREON API). Vault balances merge into the book.
|
|
548
|
+
* Requires a wallet Bearer session; SDK clients should also send an API key
|
|
549
|
+
* when keys are enforced. Does not invent holdings; only positive balances
|
|
550
|
+
* returned by the API.
|
|
551
|
+
*/
|
|
552
|
+
syncPortfolio(): Promise<SyncPortfolioResult>;
|
|
553
|
+
/**
|
|
554
|
+
* Refreshes portfolio marks from live public market data, re-evaluates
|
|
555
|
+
* objectives, optionally fires breach webhooks, and returns restore suggestions.
|
|
556
|
+
* Auth required.
|
|
557
|
+
*/
|
|
558
|
+
refreshWatchdog(): Promise<WatchdogRefreshResult>;
|
|
559
|
+
/** Returns dashboard overview aggregates. Auth required. */
|
|
560
|
+
getOverview(): Promise<DashboardOverview>;
|
|
561
|
+
/**
|
|
562
|
+
* Applies a controlled market event to portfolio marks.
|
|
563
|
+
* When autoRestore is true, the API evaluates health and may run staged restorative execution.
|
|
564
|
+
* Auth required.
|
|
565
|
+
*/
|
|
566
|
+
applyMarketEvent(input: ApplyMarketEventInput): Promise<{
|
|
567
|
+
event: MarketEvent;
|
|
568
|
+
portfolio: PortfolioSnapshot;
|
|
569
|
+
health: ObjectiveHealth[];
|
|
570
|
+
executions: ExecutionReceipt[];
|
|
571
|
+
}>;
|
|
572
|
+
/** Lists controlled market event presets. Auth required. */
|
|
573
|
+
listMarketPresets(): Promise<MarketPreset[]>;
|
|
574
|
+
/**
|
|
575
|
+
* Returns the restore plan for an objective (wrap ETH, unwrap WETH, or vault swap).
|
|
576
|
+
* Auth required.
|
|
577
|
+
*/
|
|
578
|
+
getRestorePlan(objectiveId: string): Promise<RestorePlan>;
|
|
579
|
+
/**
|
|
580
|
+
* Runs restorative execution for an objective currently outside policy.
|
|
581
|
+
* Vault Sell A→Buy B when configured. ETH↔WETH wrap/unwrap is client-side
|
|
582
|
+
* via getRestorePlan; this endpoint rejects those with action details.
|
|
583
|
+
* Auth required.
|
|
584
|
+
*/
|
|
585
|
+
runExecution(objectiveId: string): Promise<ExecutionReceipt>;
|
|
586
|
+
/**
|
|
587
|
+
* Runs vault-backed restorative execution for an objective outside policy.
|
|
588
|
+
* Auth required.
|
|
589
|
+
*/
|
|
590
|
+
restoreObjective(objectiveId: string): Promise<ExecutionReceipt>;
|
|
591
|
+
/** Lists recent execution receipts. Auth required. */
|
|
592
|
+
listExecutions(objectiveId?: string): Promise<ExecutionReceipt[]>;
|
|
593
|
+
/** Returns the vault overview for the authenticated wallet. Auth required. */
|
|
594
|
+
getVault(): Promise<VaultOverview>;
|
|
595
|
+
/** Returns compact vault funding status before restore. Auth required. */
|
|
596
|
+
getVaultStatus(): Promise<VaultStatus>;
|
|
597
|
+
/**
|
|
598
|
+
* Prepares wallet-signed calldata steps for a vault deposit.
|
|
599
|
+
* Auth required.
|
|
600
|
+
*/
|
|
601
|
+
prepareVaultDeposit(input: {
|
|
602
|
+
symbol: VaultDepositSymbol;
|
|
603
|
+
amount: string;
|
|
604
|
+
}): Promise<VaultPrepareResult>;
|
|
605
|
+
/**
|
|
606
|
+
* Prepares wallet-signed calldata steps for a vault withdraw (any allowlisted ERC-20).
|
|
607
|
+
* Auth required.
|
|
608
|
+
*/
|
|
609
|
+
prepareVaultWithdraw(input: {
|
|
610
|
+
symbol?: string;
|
|
611
|
+
amount: string;
|
|
612
|
+
}): Promise<VaultPrepareResult>;
|
|
613
|
+
/**
|
|
614
|
+
* Lists SDK API keys for the authenticated wallet.
|
|
615
|
+
* Used by the operator utility Developer page.
|
|
616
|
+
*/
|
|
617
|
+
listApiKeys(): Promise<DeveloperApiKey[]>;
|
|
618
|
+
/**
|
|
619
|
+
* Creates an SDK API key. `secret` is returned once; store it immediately.
|
|
620
|
+
*/
|
|
621
|
+
createApiKey(name: string): Promise<CreatedDeveloperApiKey>;
|
|
622
|
+
/** Revokes (deletes) an SDK API key owned by this wallet. */
|
|
623
|
+
revokeApiKey(keyId: string): Promise<DeveloperApiKey>;
|
|
624
|
+
/** Toggles the status (active/paused) of an SDK API key owned by this wallet. */
|
|
625
|
+
toggleApiKey(keyId: string): Promise<DeveloperApiKey>;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* @fileoverview Factory helpers for constructing AureonClient instances.
|
|
630
|
+
*/
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Factory helper preferred by examples and quickstarts.
|
|
634
|
+
* Defaults to the production AUREON API URL when `baseUrl` is omitted.
|
|
635
|
+
*/
|
|
636
|
+
declare function createAureonClient(options?: AureonClientOptions): AureonClient;
|
|
637
|
+
/**
|
|
638
|
+
* Creates a client pointed at a local AUREON API process (monorepo operators).
|
|
639
|
+
* Not advertised in the public README.
|
|
640
|
+
*/
|
|
641
|
+
declare function createLocalAureonClient(overrides?: Partial<AureonClientOptions>): AureonClient;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* @fileoverview Mutable bearer token holder for scripts and apps.
|
|
645
|
+
*/
|
|
646
|
+
/** Mutable bearer token holder for scripts and apps. */
|
|
647
|
+
declare function createSessionTokenProvider(initialToken?: string | null): {
|
|
648
|
+
getAccessToken: () => string | null;
|
|
649
|
+
setToken: (next: string | null) => void;
|
|
650
|
+
clear: () => void;
|
|
651
|
+
};
|
|
652
|
+
type SessionTokenProvider = ReturnType<typeof createSessionTokenProvider>;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* @fileoverview Stable machine-readable error codes for @buildaureon/sdk.
|
|
656
|
+
*/
|
|
657
|
+
type AureonErrorCode = "NETWORK_ERROR" | "TIMEOUT" | "VALIDATION_ERROR" | "NOT_FOUND" | "CONFLICT" | "UNAUTHORIZED" | "RATE_LIMITED" | "SERVER_ERROR" | "UNEXPECTED_RESPONSE" | "ABORTED";
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* @fileoverview Base and specialized error classes for the AUREON SDK.
|
|
661
|
+
*/
|
|
662
|
+
|
|
663
|
+
declare class AureonError extends Error {
|
|
664
|
+
readonly code: AureonErrorCode;
|
|
665
|
+
readonly status: number | null;
|
|
666
|
+
readonly details: Record<string, unknown> | null;
|
|
667
|
+
constructor(message: string, code: AureonErrorCode, status?: number | null, details?: Record<string, unknown> | null);
|
|
668
|
+
get retryable(): boolean;
|
|
669
|
+
toJSON(): Record<string, unknown>;
|
|
670
|
+
}
|
|
671
|
+
declare class AureonValidationError extends AureonError {
|
|
672
|
+
constructor(message: string, details?: Record<string, unknown> | null);
|
|
673
|
+
}
|
|
674
|
+
declare class AureonNotFoundError extends AureonError {
|
|
675
|
+
constructor(message: string, details?: Record<string, unknown> | null);
|
|
676
|
+
}
|
|
677
|
+
declare class AureonConflictError extends AureonError {
|
|
678
|
+
constructor(message: string, details?: Record<string, unknown> | null);
|
|
679
|
+
}
|
|
680
|
+
declare class AureonNetworkError extends AureonError {
|
|
681
|
+
constructor(message: string, details?: Record<string, unknown> | null);
|
|
682
|
+
}
|
|
683
|
+
declare class AureonTimeoutError extends AureonError {
|
|
684
|
+
constructor(message?: string, details?: Record<string, unknown> | null);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* @fileoverview Maps HTTP responses into typed AureonError instances.
|
|
689
|
+
*/
|
|
690
|
+
|
|
691
|
+
declare function errorFromHttpStatus(status: number, body: unknown): AureonError;
|
|
692
|
+
declare function isAureonError(value: unknown): value is AureonError;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* @fileoverview Validation and normalization for objective create/update payloads.
|
|
696
|
+
*/
|
|
697
|
+
|
|
698
|
+
declare function buildPolicySummary(kind: CreateObjectiveInput["kind"], targetWeight: number, tolerance: number): string;
|
|
699
|
+
declare function normalizeCreateObjectiveInput(input: CreateObjectiveInput): CreateObjectiveInput;
|
|
700
|
+
declare function normalizeUpdateObjectiveInput(input: UpdateObjectiveInput): UpdateObjectiveInput;
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* @fileoverview Display helpers shared by utility apps and CLI output.
|
|
704
|
+
*/
|
|
705
|
+
|
|
706
|
+
declare function formatUsd(value: number): string;
|
|
707
|
+
declare function formatWeight(weight: number): string;
|
|
708
|
+
declare function healthTone(state: HealthState): "positive" | "caution" | "critical" | "neutral";
|
|
709
|
+
declare function formatSignedPercent(ratio: number): string;
|
|
710
|
+
declare function formatIsoTime(iso: string): string;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* @fileoverview JSON HTTP transport used by AureonClient.
|
|
714
|
+
*/
|
|
715
|
+
|
|
716
|
+
interface TransportOptions {
|
|
717
|
+
baseUrl: string;
|
|
718
|
+
fetchImpl: typeof fetch;
|
|
719
|
+
headers: Record<string, string>;
|
|
720
|
+
timeoutMs: number;
|
|
721
|
+
maxRetries?: number;
|
|
722
|
+
retryDelayMs?: number;
|
|
723
|
+
logger?: AureonLogger;
|
|
724
|
+
getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
725
|
+
getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
726
|
+
}
|
|
727
|
+
interface RequestOptions {
|
|
728
|
+
method?: string;
|
|
729
|
+
body?: unknown;
|
|
730
|
+
headers?: Record<string, string>;
|
|
731
|
+
signal?: AbortSignal;
|
|
732
|
+
}
|
|
733
|
+
declare function requestJson<T>(transport: TransportOptions, path: string, options?: RequestOptions): Promise<T>;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* @fileoverview URL helpers for the AUREON HTTP transport.
|
|
737
|
+
*/
|
|
738
|
+
declare function joinUrl(baseUrl: string, path: string): string;
|
|
739
|
+
declare function assertBaseUrl(baseUrl: string): string;
|
|
740
|
+
declare function withQuery(path: string, query: Record<string, string | undefined>): string;
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* @fileoverview Default runtime values for SDK clients and examples.
|
|
744
|
+
*/
|
|
745
|
+
/** Production AUREON API (public integrators). */
|
|
746
|
+
declare const DEFAULT_API_BASE_URL = "https://api.aureonlabs.network";
|
|
747
|
+
/** Local monorepo preview only; not for public docs. */
|
|
748
|
+
declare const LOCAL_API_BASE_URL = "http://127.0.0.1:8787";
|
|
749
|
+
declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
750
|
+
declare const SDK_VERSION = "0.1.0";
|
|
751
|
+
declare const SDK_NAME = "@buildaureon/sdk";
|
|
752
|
+
declare const PRODUCT_NAME = "AUREON";
|
|
753
|
+
declare const PRODUCT_TAGLINE = "Financial Compass for Robinhood Chain";
|
|
754
|
+
/** HTTP header for product API keys. */
|
|
755
|
+
declare const API_KEY_HEADER = "X-Aureon-Api-Key";
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* @fileoverview API path constants for AureonClient methods.
|
|
759
|
+
*/
|
|
760
|
+
declare const ENDPOINTS: {
|
|
761
|
+
readonly healthz: "/healthz";
|
|
762
|
+
readonly overview: "/overview";
|
|
763
|
+
readonly portfolio: "/portfolio";
|
|
764
|
+
readonly portfolioClear: "/portfolio/clear";
|
|
765
|
+
readonly portfolioSync: "/portfolio/sync";
|
|
766
|
+
readonly watchdogRefresh: "/watchdog/refresh";
|
|
767
|
+
readonly objectives: "/objectives";
|
|
768
|
+
readonly health: "/health";
|
|
769
|
+
readonly timeline: "/timeline";
|
|
770
|
+
readonly executions: "/executions";
|
|
771
|
+
readonly executionsRun: "/executions/run";
|
|
772
|
+
readonly marketEvents: "/market/events";
|
|
773
|
+
readonly marketPresets: "/market/presets";
|
|
774
|
+
readonly vault: "/vault";
|
|
775
|
+
readonly vaultStatus: "/vault/status";
|
|
776
|
+
readonly vaultPrepareDeposit: "/vault/prepare-deposit";
|
|
777
|
+
readonly vaultPrepareWithdraw: "/vault/prepare-withdraw";
|
|
778
|
+
readonly authNonce: "/auth/nonce";
|
|
779
|
+
readonly authVerify: "/auth/verify";
|
|
780
|
+
readonly authLogout: "/auth/logout";
|
|
781
|
+
readonly authDevLogin: "/auth/dev-login";
|
|
782
|
+
readonly authMe: "/auth/me";
|
|
783
|
+
readonly developerApiKeys: "/developer/api-keys";
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* @fileoverview Fetch adapter helpers for browser and Node runtimes.
|
|
788
|
+
*/
|
|
789
|
+
type FetchLike = typeof fetch;
|
|
790
|
+
declare function resolveFetch(custom?: FetchLike): FetchLike;
|
|
791
|
+
|
|
792
|
+
export { API_KEY_HEADER, type ApplyMarketEventInput, AureonClient, type AureonClientOptions, AureonConflictError, AureonError, type AureonErrorCode, AureonNetworkError, AureonNotFoundError, AureonTimeoutError, AureonValidationError, type AuthMeResponse, type AuthNonceResponse, type AuthSessionResponse, type CreateObjectiveInput, type CreatedDeveloperApiKey, DEFAULT_API_BASE_URL, DEFAULT_TIMEOUT_MS, type DashboardOverview, type DeveloperApiKey, ENDPOINTS, type ExecutionReceipt, type HealthState, LOCAL_API_BASE_URL, type MarkQuote, type MarkQuoteSource, type MarketEvent, type MarketPreset, OBJECTIVE_KINDS, OBJECTIVE_PRIORITIES, type Objective, type ObjectiveAutomationMode, type ObjectiveHealth, type ObjectiveKind, type ObjectivePolicy, type ObjectivePriority, type ObjectiveStatus, PRODUCT_NAME, PRODUCT_TAGLINE, type PortfolioPosition, type PortfolioPositionInput, type PortfolioSnapshot, type RestorePlan, type RestorePlanKind, type RestoreSuggestion, type RestoreSuggestionAction, SDK_NAME, SDK_VERSION, type SessionTokenProvider, type SyncPortfolioResult, TIMELINE_EVENT_TYPES, type TimelineEvent, type TimelineEventType, type UpdateObjectiveInput, type VaultBalance, type VaultDepositSymbol, type VaultOverview, type VaultPrepareResult, type VaultPreparedStep, type VaultStatus, type VaultToken, type VaultWithdrawSymbol, type WatchdogAlertResult, type WatchdogRefreshResult, assertBaseUrl, buildPolicySummary, createAureonClient, createConsoleLogger, createLocalAureonClient, createSessionTokenProvider, errorFromHttpStatus, formatIsoTime, formatSignedPercent, formatUsd, formatWeight, healthTone, isAureonError, isHealthState, isObjectiveKind, isObjectivePriority, isTimelineEventType, isVaultSettlement, joinUrl, normalizeCreateObjectiveInput, normalizeUpdateObjectiveInput, pickWorstHealth, requestJson, resolveFetch, silentLogger, withQuery };
|