@buildaureon/sdk 0.1.2 → 0.1.8

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/dist/index.d.ts CHANGED
@@ -1,61 +1,57 @@
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
1
  /**
11
- * @fileoverview Client configuration types for AureonClient.
2
+ * @fileoverview Robinhood Chain network presets for the SDK and MCP.
3
+ *
4
+ * Default `network` is **mainnet** (chain 4663, local API 8788).
5
+ * Public `api.aureonlabs.network` is still testnet 46630 — opt in with
6
+ * `network: "testnet"` or `AUREON_NETWORK=testnet`. Do not map mainnet
7
+ * to that host.
12
8
  */
9
+ type AureonNetwork = "mainnet" | "testnet";
10
+ declare const MAINNET_CHAIN_ID = 4663;
11
+ declare const TESTNET_CHAIN_ID = 46630;
12
+ declare const MAINNET_API_BASE_URL = "http://127.0.0.1:8788";
13
+ declare const TESTNET_API_BASE_URL = "https://api.aureonlabs.network";
14
+ type AureonNetworkPreset = {
15
+ network: AureonNetwork;
16
+ chainId: number;
17
+ baseUrl: string;
18
+ explorer: string;
19
+ };
20
+ declare const AUREON_NETWORKS: Record<AureonNetwork, AureonNetworkPreset>;
21
+ type ResolveAureonNetworkInput = {
22
+ /** Omit to default mainnet, unless only `baseUrl` is set (then infer). */
23
+ network?: string | null;
24
+ /** Explicit API URL. Wins when set; mismatch with an explicit network throws. */
25
+ baseUrl?: string | null;
26
+ };
27
+ /** Infer preset from a known host. Custom URLs return null (allowed). */
28
+ declare function inferAureonNetworkFromUrl(url: string): AureonNetwork | null;
29
+ /**
30
+ * Resolve network + URL + chainId as one bundle.
31
+ *
32
+ * - Neither set → mainnet (8788 / 4663).
33
+ * - Only `network` → that preset's URL.
34
+ * - Only `baseUrl` → that URL; infer network from known hosts, else mainnet.
35
+ * - Both set and they disagree (known hosts) → throw.
36
+ */
37
+ declare function resolveAureonNetwork(input?: ResolveAureonNetworkInput): AureonNetworkPreset;
38
+ /** MCP / CLI: `AUREON_NETWORK` optional, `AUREON_API_URL` still overrides. */
39
+ declare function resolveAureonNetworkFromEnv(env?: NodeJS.Dict<string>): AureonNetworkPreset;
13
40
 
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
- * Operator-issued keys (from the Developers console) also identify the
23
- * bound wallet for control-plane calls — no Bearer required.
24
- * Env bootstrap keys unlock product access only; they do not set identity.
25
- * The operator utility uses wallet Bearer only.
26
- */
27
- apiKey?: string | null;
28
- /**
29
- * Called before each request to resolve the product API key.
30
- * Prefer this for automations that load keys from env or a secret store.
31
- */
32
- getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
33
- /** Optional fetch implementation for non-browser runtimes. */
34
- fetch?: typeof fetch;
35
- /** Optional default headers merged into every request. */
36
- headers?: Record<string, string>;
37
- /** Request timeout in milliseconds. Defaults to 30000. */
38
- timeoutMs?: number;
39
- /**
40
- * Static Bearer session token. Prefer `getAccessToken` for apps that refresh
41
- * or clear sessions at runtime.
42
- */
43
- authToken?: string | null;
44
- /**
45
- * Called before each request to resolve the current Bearer token.
46
- * Return null/undefined to send the request without Authorization.
47
- */
48
- getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
49
- /** Optional structured logger for request lifecycle diagnostics. */
50
- logger?: AureonLogger;
51
- /**
52
- * Extra attempts after the first failure for retryable errors
53
- * (network, timeout, 429, 5xx). Defaults to 0.
54
- */
55
- maxRetries?: number;
56
- /** Delay in ms between retries. Defaults to 250. */
57
- retryDelayMs?: number;
41
+ /**
42
+ * @fileoverview Timeline event contracts for append-only operator narratives.
43
+ */
44
+ 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" | "registry_registered" | "settlement_recorded";
45
+ interface TimelineEvent {
46
+ id: string;
47
+ objectiveId: string | null;
48
+ type: TimelineEventType;
49
+ message: string;
50
+ payload: Record<string, unknown>;
51
+ createdAt: string;
58
52
  }
53
+ declare const TIMELINE_EVENT_TYPES: readonly TimelineEventType[];
54
+ declare function isTimelineEventType(value: string): value is TimelineEventType;
59
55
 
60
56
  /**
61
57
  * @fileoverview Phase 2 ObjectiveRegistry types.
@@ -106,6 +102,39 @@ type ObjectiveRegistryLookup = {
106
102
  record: ObjectiveRegistryRecord;
107
103
  };
108
104
 
105
+ /**
106
+ * @fileoverview On-chain settlement record for vault rebalances (Day 8).
107
+ */
108
+
109
+ type SettlementStatus = "confirmed" | "orphan";
110
+ interface SettlementRecord {
111
+ id: string;
112
+ executionId: string | null;
113
+ objectiveId: string | null;
114
+ walletAddress: string;
115
+ /** Chain-verified vault settlements are always `"vault"`. */
116
+ settlement: "vault";
117
+ transactionHash: string;
118
+ blockNumber: number;
119
+ logIndex: number;
120
+ vaultAddress: string;
121
+ tokenSell: string;
122
+ tokenBuy: string;
123
+ amountIn: string;
124
+ amountOut: string;
125
+ explorerUrl: string;
126
+ verifiedAt: string;
127
+ status: SettlementStatus;
128
+ registryRef?: RegistryRef;
129
+ }
130
+ interface ExecutionSettlementLookup {
131
+ executionId: string;
132
+ verifiedOnChain: boolean;
133
+ settlement: SettlementRecord | null;
134
+ }
135
+ /** Human-readable settlement summary for agents and logs. */
136
+ declare function formatSettlementSummary(record: SettlementRecord): string;
137
+
109
138
  /**
110
139
  * @fileoverview Execution receipt + restore-plan types.
111
140
  *
@@ -128,8 +157,14 @@ interface ExecutionReceipt {
128
157
  * `"vault"`: keeper rebalance confirmed (or pending_vault_* then confirmed).
129
158
  * `"staged"`: capital-book restore only (honest non-finality label).
130
159
  */
131
- settlement?: "staged" | "vault";
160
+ settlement: "staged" | "vault";
161
+ /** Block explorer link when vault tx is a real `0x…` hash; null for staged. */
162
+ explorerUrl?: string | null;
132
163
  registryRef?: RegistryRef;
164
+ /** True when a settlement record exists for this execution (vault only). */
165
+ verifiedOnChain?: boolean;
166
+ /** Populated when verifiedOnChain is true. */
167
+ settlementRecord?: SettlementRecord;
133
168
  }
134
169
  /** Client-side restore action: wrap/unwrap ETH↔WETH or keeper vault swap. */
135
170
  type RestorePlanKind = "wrap_eth" | "unwrap_weth" | "vault_swap";
@@ -143,38 +178,12 @@ interface RestorePlan {
143
178
  }
144
179
  /** True when the receipt claims vault (on-chain) settlement. */
145
180
  declare function isVaultSettlement(receipt: ExecutionReceipt): boolean;
146
-
147
- /**
148
- * @fileoverview Health Engine result types.
149
- */
150
- type HealthState = "healthy" | "warning" | "violation" | "paused";
151
- interface ObjectiveHealth {
152
- objectiveId: string;
153
- state: HealthState;
154
- score: number;
155
- currentMetric: number;
156
- targetMetric: number;
157
- deviation: number;
158
- message: string;
159
- evaluatedAt: string;
160
- }
161
- declare function isHealthState(value: string): value is HealthState;
162
- declare function pickWorstHealth(records: ObjectiveHealth[]): ObjectiveHealth | null;
163
-
164
- /**
165
- * @fileoverview Timeline event contracts for append-only operator narratives.
166
- */
167
- 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" | "registry_anchored";
168
- interface TimelineEvent {
169
- id: string;
170
- objectiveId: string | null;
171
- type: TimelineEventType;
172
- message: string;
173
- payload: Record<string, unknown>;
174
- createdAt: string;
175
- }
176
- declare const TIMELINE_EVENT_TYPES: readonly TimelineEventType[];
177
- declare function isTimelineEventType(value: string): value is TimelineEventType;
181
+ /** True when the receipt has independent on-chain settlement proof. */
182
+ declare function isChainVerifiedReceipt(receipt: ExecutionReceipt): boolean;
183
+ /** Human-readable one-line receipt summary for agents and logs. */
184
+ declare function formatReceiptSummary(receipt: ExecutionReceipt): string;
185
+ /** Timeline events linked to a receipt via payload.executionId. */
186
+ declare function findTimelineEventsForReceipt(events: TimelineEvent[], receipt: ExecutionReceipt): TimelineEvent[];
178
187
 
179
188
  /**
180
189
  * @fileoverview Controlled market event types for operator demos and rehearsals.
@@ -239,6 +248,23 @@ interface DashboardOverview {
239
248
  recentEvents: TimelineEvent[];
240
249
  }
241
250
 
251
+ /**
252
+ * @fileoverview Health Engine result types.
253
+ */
254
+ type HealthState = "healthy" | "warning" | "violation" | "paused";
255
+ interface ObjectiveHealth {
256
+ objectiveId: string;
257
+ state: HealthState;
258
+ score: number;
259
+ currentMetric: number;
260
+ targetMetric: number;
261
+ deviation: number;
262
+ message: string;
263
+ evaluatedAt: string;
264
+ }
265
+ declare function isHealthState(value: string): value is HealthState;
266
+ declare function pickWorstHealth(records: ObjectiveHealth[]): ObjectiveHealth | null;
267
+
242
268
  /**
243
269
  * @fileoverview Objective domain types for Financial Compass Objectives.
244
270
  */
@@ -333,6 +359,377 @@ declare const OBJECTIVE_PRIORITIES: readonly ObjectivePriority[];
333
359
  declare function isObjectiveKind(value: string): value is ObjectiveKind;
334
360
  declare function isObjectivePriority(value: string): value is ObjectivePriority;
335
361
 
362
+ /**
363
+ * @fileoverview Objective vs actual allocation comparison and plan paradox detection.
364
+ */
365
+
366
+ interface AllocationComparisonRow {
367
+ objectiveId: string;
368
+ name: string;
369
+ kind: ObjectiveKind;
370
+ targetSymbol?: string;
371
+ targetWeight: number;
372
+ currentMetric: number;
373
+ deviation: number;
374
+ state: HealthState;
375
+ }
376
+ interface PlanParadoxResult {
377
+ detected: boolean;
378
+ bookUp: boolean;
379
+ offPlanCount: number;
380
+ message: string;
381
+ }
382
+ /**
383
+ * Joins active objectives with health records into target vs current rows.
384
+ */
385
+ declare function buildAllocationComparison(objectives: Objective[], health: ObjectiveHealth[]): AllocationComparisonRow[];
386
+ /**
387
+ * Detects when book performance looks fine but objectives are off-plan.
388
+ */
389
+ declare function detectPlanParadox(overview: DashboardOverview, health: ObjectiveHealth[]): PlanParadoxResult;
390
+
391
+ /**
392
+ * @fileoverview Drift → detection → restore teaching flow helpers.
393
+ */
394
+
395
+ type DriftRestorePhase = "aligned" | "drift_detected" | "restored";
396
+ interface DriftRestoreFlow {
397
+ objectiveId: string;
398
+ rule: {
399
+ summary: string;
400
+ targetWeight: number;
401
+ tolerance: number;
402
+ };
403
+ phases: {
404
+ aligned: {
405
+ health: ObjectiveHealth;
406
+ allocationRow?: AllocationComparisonRow;
407
+ };
408
+ drift: {
409
+ health: ObjectiveHealth;
410
+ allocationRow?: AllocationComparisonRow;
411
+ restorePlan?: RestorePlan;
412
+ };
413
+ restored?: {
414
+ health: ObjectiveHealth;
415
+ receipt?: ExecutionReceipt;
416
+ settlement?: string;
417
+ };
418
+ };
419
+ currentPhase: DriftRestorePhase;
420
+ message: string;
421
+ }
422
+ /**
423
+ * Infers drift-restore phase from a single health snapshot.
424
+ */
425
+ declare function inferDriftPhase(health: ObjectiveHealth): DriftRestorePhase;
426
+ /**
427
+ * Builds the drift → detection → restore teaching shape.
428
+ */
429
+ declare function buildDriftRestoreFlow(input: {
430
+ objective: Objective;
431
+ alignedHealth: ObjectiveHealth;
432
+ driftHealth: ObjectiveHealth;
433
+ driftPlan?: RestorePlan;
434
+ restoredHealth?: ObjectiveHealth;
435
+ receipt?: ExecutionReceipt;
436
+ alignedRow?: AllocationComparisonRow;
437
+ driftRow?: AllocationComparisonRow;
438
+ }): DriftRestoreFlow;
439
+ /**
440
+ * Read-only flow from current objective state + optional latest receipt.
441
+ */
442
+ declare function buildDriftRestoreFlowFromSnapshot(input: {
443
+ objective: Objective;
444
+ health: ObjectiveHealth;
445
+ allocationRow?: AllocationComparisonRow;
446
+ restorePlan?: RestorePlan;
447
+ latestReceipt?: ExecutionReceipt;
448
+ }): DriftRestoreFlow;
449
+
450
+ /**
451
+ * @fileoverview Phase 2 execution receipt validator — schema + honesty rules.
452
+ */
453
+
454
+ type ReceiptValidationCode = "INVALID_INPUT" | "MISSING_FIELD" | "INVALID_SETTLEMENT" | "INVALID_STATUS" | "MISSING_CONFIRMED_AT" | "STAGED_WITH_EXPLORER" | "STAGED_VERIFIED_ON_CHAIN" | "STAGED_WITH_SETTLEMENT_RECORD" | "INVALID_VAULT_HASH" | "VAULT_MISSING_EXPLORER" | "VERIFIED_WITHOUT_RECORD" | "VERIFIED_RECORD_MISMATCH" | "INVALID_REGISTRY_REF" | "INVALID_SETTLEMENT_RECORD";
455
+ type ReceiptValidationIssue = {
456
+ code: ReceiptValidationCode;
457
+ message: string;
458
+ path?: string;
459
+ };
460
+ type ReceiptValidationResult = {
461
+ valid: boolean;
462
+ issues: ReceiptValidationIssue[];
463
+ };
464
+ /** Validates a settlement record nested on a receipt. */
465
+ declare function validateSettlementRecord(input: unknown, options?: {
466
+ executionId?: string;
467
+ }): ReceiptValidationResult;
468
+ /**
469
+ * Validates an execution receipt against the Phase 2 contract + honesty rules.
470
+ * Never throws — inspect `valid` and `issues`.
471
+ */
472
+ declare function validateExecutionReceipt(input: unknown): ReceiptValidationResult;
473
+ /** Type guard: true when input passes validateExecutionReceipt. */
474
+ declare function isValidExecutionReceipt(input: unknown): input is ExecutionReceipt;
475
+ /** Throws AureonValidationError when the receipt fails validation. */
476
+ declare function assertValidExecutionReceipt(receipt: unknown): asserts receipt is ExecutionReceipt;
477
+
478
+ /**
479
+ * @fileoverview Receipt → verification teaching flow helpers.
480
+ */
481
+
482
+ type ReceiptVerificationPhase = "claimed" | "validated" | "validation_failed" | "chain_verified";
483
+ type ReceiptProofTier = "claim_only" | "schema_valid" | "chain_verified";
484
+ interface ReceiptVerificationFlow {
485
+ executionId: string;
486
+ receipt: ExecutionReceipt;
487
+ phases: {
488
+ claimed: {
489
+ summary: string;
490
+ status: string;
491
+ settlement: string;
492
+ result: string;
493
+ };
494
+ validation: ReceiptValidationResult;
495
+ settlement?: ExecutionSettlementLookup;
496
+ timelineEvents?: TimelineEvent[];
497
+ };
498
+ proofTier: ReceiptProofTier;
499
+ currentPhase: ReceiptVerificationPhase;
500
+ message: string;
501
+ }
502
+ /**
503
+ * Infers proof tier from receipt, validation, and optional settlement lookup.
504
+ */
505
+ declare function inferProofTier(receipt: ExecutionReceipt, validation: ReceiptValidationResult, settlement?: ExecutionSettlementLookup): ReceiptProofTier;
506
+ /**
507
+ * Builds the receipt → verification teaching shape.
508
+ */
509
+ declare function buildReceiptVerificationFlow(input: {
510
+ receipt: ExecutionReceipt;
511
+ validation?: ReceiptValidationResult;
512
+ settlement?: ExecutionSettlementLookup;
513
+ timelineEvents?: TimelineEvent[];
514
+ }): ReceiptVerificationFlow;
515
+
516
+ /**
517
+ * @fileoverview Portfolio watch while away — agent-in-host teaching flow (Update 6).
518
+ */
519
+
520
+ type AgentHost = "cursor" | "claude" | "mcp";
521
+ type PortfolioWatchPhase = "watch_registered" | "while_away" | "return_briefing";
522
+ /** Default consumer brief for Update 6 demos. */
523
+ declare const DEFAULT_PORTFOLIO_WATCH_BRIEF = "Watch my portfolio while I'm away \u2014 keep about 20% in stable assets.";
524
+ interface PortfolioWatchFlow {
525
+ objectiveId: string;
526
+ userBrief: string;
527
+ host: AgentHost;
528
+ phases: {
529
+ register: {
530
+ objectiveName: string;
531
+ automationMode: string;
532
+ policySummary: string;
533
+ health: ObjectiveHealth;
534
+ allocationRow?: AllocationComparisonRow;
535
+ };
536
+ whileAway?: {
537
+ marketEventName: string;
538
+ symbol: string;
539
+ priceChangeRatio: number;
540
+ healthBefore: ObjectiveHealth;
541
+ healthAfter: ObjectiveHealth;
542
+ autoRestored: boolean;
543
+ receipt?: ExecutionReceipt;
544
+ };
545
+ briefing: {
546
+ health: ObjectiveHealth;
547
+ timelineEventCount: number;
548
+ timelineEvents: TimelineEvent[];
549
+ summaryLines: string[];
550
+ };
551
+ };
552
+ currentPhase: PortfolioWatchPhase;
553
+ message: string;
554
+ }
555
+ /**
556
+ * Infers portfolio-watch phase from register + optional while-away data.
557
+ */
558
+ declare function inferPortfolioWatchPhase(input: {
559
+ registerHealth: ObjectiveHealth;
560
+ whileAway?: PortfolioWatchFlow["phases"]["whileAway"];
561
+ }): PortfolioWatchPhase;
562
+ /**
563
+ * Builds human-readable briefing lines for agent hosts (Cursor / Claude).
564
+ */
565
+ declare function buildPortfolioWatchBriefingLines(input: {
566
+ userBrief: string;
567
+ host: AgentHost;
568
+ objective: Objective;
569
+ registerHealth: ObjectiveHealth;
570
+ briefingHealth: ObjectiveHealth;
571
+ whileAway?: PortfolioWatchFlow["phases"]["whileAway"];
572
+ timelineEvents: TimelineEvent[];
573
+ }): string[];
574
+ /**
575
+ * Builds the portfolio watch teaching shape for agent-in-host demos.
576
+ */
577
+ declare function buildPortfolioWatchFlow(input: {
578
+ userBrief: string;
579
+ host: AgentHost;
580
+ objective: Objective;
581
+ registerHealth: ObjectiveHealth;
582
+ registerRow?: AllocationComparisonRow;
583
+ whileAway?: {
584
+ marketEvent: MarketEvent;
585
+ healthBefore: ObjectiveHealth;
586
+ healthAfter: ObjectiveHealth;
587
+ autoRestored: boolean;
588
+ receipt?: ExecutionReceipt;
589
+ };
590
+ briefingHealth: ObjectiveHealth;
591
+ timelineEvents: TimelineEvent[];
592
+ }): PortfolioWatchFlow;
593
+ /**
594
+ * Read-only portfolio watch snapshot from current objective state.
595
+ */
596
+ declare function buildPortfolioWatchFlowFromSnapshot(input: {
597
+ userBrief: string;
598
+ host: AgentHost;
599
+ objective: Objective;
600
+ health: ObjectiveHealth;
601
+ allocationRow?: AllocationComparisonRow;
602
+ latestReceipt?: ExecutionReceipt;
603
+ timelineEvents: TimelineEvent[];
604
+ }): PortfolioWatchFlow;
605
+
606
+ /**
607
+ * @fileoverview Full AUREON loop teaching flow helpers.
608
+ */
609
+
610
+ type FullAureonLoopPhase = "intent" | "plan_check" | "restored" | "verified";
611
+ /** Default brief for full-loop demos. */
612
+ declare const DEFAULT_FULL_LOOP_BRIEF = "Keep about 20% in stable assets \u2014 grow the book without abandoning the plan.";
613
+ interface FullAureonLoopFlow {
614
+ objectiveId: string;
615
+ userBrief: string;
616
+ phases: {
617
+ intent: {
618
+ objectiveName: string;
619
+ policySummary: string;
620
+ automationMode: string;
621
+ health: ObjectiveHealth;
622
+ };
623
+ planCheck: {
624
+ baselineAligned: boolean;
625
+ afterShock: {
626
+ health: ObjectiveHealth;
627
+ allocationRow?: AllocationComparisonRow;
628
+ paradox: PlanParadoxResult;
629
+ };
630
+ };
631
+ driftRestore: {
632
+ healthBefore: ObjectiveHealth;
633
+ healthAfter: ObjectiveHealth;
634
+ receipt: ExecutionReceipt;
635
+ settlement: string;
636
+ };
637
+ verification: ReceiptVerificationFlow;
638
+ };
639
+ currentPhase: FullAureonLoopPhase;
640
+ message: string;
641
+ }
642
+ /**
643
+ * Infers loop phase from which stages are present.
644
+ */
645
+ declare function inferFullAureonLoopPhase(input: {
646
+ hasRestore: boolean;
647
+ verificationValid: boolean;
648
+ }): FullAureonLoopPhase;
649
+ /**
650
+ * Builds the full AUREON loop teaching shape.
651
+ */
652
+ declare function buildFullAureonLoopFlow(input: {
653
+ userBrief: string;
654
+ objective: Objective;
655
+ baselineHealth: ObjectiveHealth;
656
+ afterShockHealth: ObjectiveHealth;
657
+ afterShockRow?: AllocationComparisonRow;
658
+ paradox: PlanParadoxResult;
659
+ restoredHealth: ObjectiveHealth;
660
+ receipt: ExecutionReceipt;
661
+ verification?: ReceiptVerificationFlow;
662
+ }): FullAureonLoopFlow;
663
+ /**
664
+ * Read-only full-loop snapshot from current objective state + latest receipt.
665
+ */
666
+ declare function buildFullAureonLoopFlowFromSnapshot(input: {
667
+ userBrief: string;
668
+ objective: Objective;
669
+ health: ObjectiveHealth;
670
+ allocationRow?: AllocationComparisonRow;
671
+ paradox: PlanParadoxResult;
672
+ latestReceipt?: ExecutionReceipt;
673
+ verification?: ReceiptVerificationFlow;
674
+ }): FullAureonLoopFlow | null;
675
+
676
+ /**
677
+ * @fileoverview Financial audit trail — objective → registry → receipt → settlement.
678
+ *
679
+ * Joins what already exists. Never invents missing proof. Gaps stay labeled.
680
+ */
681
+
682
+ type AuditTrailGapCode = "not_registered" | "no_executions" | "no_settlements" | "staged_only" | "vault_unverified" | "invalid_receipt" | "no_timeline" | "lookup_failed";
683
+ interface AuditTrailGap {
684
+ code: AuditTrailGapCode;
685
+ message: string;
686
+ }
687
+ interface AuditTrailReceiptRow {
688
+ id: string;
689
+ action: string;
690
+ settlement: "vault" | "staged";
691
+ status: string;
692
+ valid: boolean;
693
+ verifiedOnChain: boolean;
694
+ explorerUrl: string | null;
695
+ summary: string;
696
+ validation: ReceiptValidationResult;
697
+ }
698
+ interface FinancialAuditTrail {
699
+ objectiveId: string;
700
+ objectiveName: string;
701
+ policySummary: string;
702
+ healthState: string | null;
703
+ generatedAt: string;
704
+ registry: {
705
+ present: boolean;
706
+ record?: ObjectiveRegistryRecord;
707
+ };
708
+ receipts: AuditTrailReceiptRow[];
709
+ settlements: SettlementRecord[];
710
+ timeline: Array<{
711
+ id: string;
712
+ type: string;
713
+ message: string;
714
+ createdAt: string;
715
+ executionId: string | null;
716
+ }>;
717
+ gaps: AuditTrailGap[];
718
+ message: string;
719
+ }
720
+ declare function buildFinancialAuditTrail(input: {
721
+ objective: Objective;
722
+ health?: ObjectiveHealth;
723
+ registry?: ObjectiveRegistryLookup;
724
+ receipts: ExecutionReceipt[];
725
+ settlements: SettlementRecord[];
726
+ timeline: TimelineEvent[];
727
+ generatedAt?: string;
728
+ registryLookupFailed?: boolean;
729
+ settlementsLookupFailed?: boolean;
730
+ }): FinancialAuditTrail;
731
+ declare function formatAuditTrailLines(trail: FinancialAuditTrail): string[];
732
+
336
733
  /**
337
734
  * @fileoverview Portfolio snapshot types used by health evaluation and utility screens.
338
735
  */
@@ -365,13 +762,119 @@ interface PortfolioPositionInput {
365
762
  markPriceUsd: number;
366
763
  }
367
764
 
765
+ /**
766
+ * @fileoverview Financial intent → objective → portfolio flow helpers.
767
+ */
768
+
769
+ interface FinancialIntent {
770
+ /** User or agent wording — what they want money to do. */
771
+ brief: string;
772
+ kind: ObjectiveKind;
773
+ targetWeight: number;
774
+ tolerance: number;
775
+ targetSymbol?: string;
776
+ name?: string;
777
+ priority?: ObjectivePriority;
778
+ }
779
+ interface ObjectivePortfolioFlow {
780
+ intent: {
781
+ brief: string;
782
+ policySummary: string;
783
+ };
784
+ objective: Objective;
785
+ health: ObjectiveHealth | null;
786
+ portfolio: {
787
+ totalNotionalUsd: number;
788
+ stableWeight: number;
789
+ positions: PortfolioPosition[];
790
+ };
791
+ message: string;
792
+ }
793
+ /**
794
+ * Maps agent-extracted intent into a create-objective payload.
795
+ */
796
+ declare function resolveObjectiveFromIntent(intent: FinancialIntent): CreateObjectiveInput;
797
+ /**
798
+ * Builds the AI → objective → portfolio teaching shape after create + read.
799
+ */
800
+ declare function buildObjectivePortfolioFlow(intent: FinancialIntent, objective: Objective, health: ObjectiveHealth | null, portfolio: PortfolioSnapshot): ObjectivePortfolioFlow;
801
+ /**
802
+ * Lightweight rule-based parser for demo scripts.
803
+ */
804
+ declare function parseFinancialIntent(brief: string): FinancialIntent;
805
+
806
+ interface AureonLogger {
807
+ debug(message: string, context?: Record<string, unknown>): void;
808
+ info(message: string, context?: Record<string, unknown>): void;
809
+ warn(message: string, context?: Record<string, unknown>): void;
810
+ error(message: string, context?: Record<string, unknown>): void;
811
+ }
812
+ declare const silentLogger: AureonLogger;
813
+ declare function createConsoleLogger(prefix?: string): AureonLogger;
814
+
815
+ /**
816
+ * @fileoverview Client configuration types for AureonClient.
817
+ */
818
+
819
+ interface AureonClientOptions {
820
+ /**
821
+ * Robinhood network bundle. Omit for **mainnet** (4663, local 8788).
822
+ * Pass `"testnet"` for the public host (still chain 46630).
823
+ */
824
+ network?: "mainnet" | "testnet";
825
+ /**
826
+ * Base URL of the AUREON API. Wins when set.
827
+ * Omit together with `network` to use the mainnet local API.
828
+ * Must not disagree with an explicit `network` (fail closed).
829
+ */
830
+ baseUrl?: string;
831
+ /**
832
+ * Product API key sent as `X-Aureon-Api-Key` on every request.
833
+ * Operator-issued keys (from the Developers console) also identify the
834
+ * bound wallet for control-plane calls — no Bearer required.
835
+ * Env bootstrap keys unlock product access only; they do not set identity.
836
+ * The operator utility uses wallet Bearer only.
837
+ */
838
+ apiKey?: string | null;
839
+ /**
840
+ * Called before each request to resolve the product API key.
841
+ * Prefer this for automations that load keys from env or a secret store.
842
+ */
843
+ getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
844
+ /** Optional fetch implementation for non-browser runtimes. */
845
+ fetch?: typeof fetch;
846
+ /** Optional default headers merged into every request. */
847
+ headers?: Record<string, string>;
848
+ /** Request timeout in milliseconds. Defaults to 30000. */
849
+ timeoutMs?: number;
850
+ /**
851
+ * Static Bearer session token. Prefer `getAccessToken` for apps that refresh
852
+ * or clear sessions at runtime.
853
+ */
854
+ authToken?: string | null;
855
+ /**
856
+ * Called before each request to resolve the current Bearer token.
857
+ * Return null/undefined to send the request without Authorization.
858
+ */
859
+ getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
860
+ /** Optional structured logger for request lifecycle diagnostics. */
861
+ logger?: AureonLogger;
862
+ /**
863
+ * Extra attempts after the first failure for retryable errors
864
+ * (network, timeout, 429, 5xx). Defaults to 0.
865
+ */
866
+ maxRetries?: number;
867
+ /** Delay in ms between retries. Defaults to 250. */
868
+ retryDelayMs?: number;
869
+ }
870
+
368
871
  /**
369
872
  * @fileoverview Vault overview + prepare-tx contracts for AureonVault.
370
873
  *
371
874
  * Reads come from GET /vault and GET /vault/status.
372
- * Writes are wallet-signed: prepareDeposit / prepareWithdraw return calldata
373
- * steps; the host (or agent signer) broadcasts them; the API never holds
374
- * user keys.
875
+ * Writes are wallet-signed: prepareDeposit / prepareWithdraw return unsigned
876
+ * calldata steps. The host wallet or MetaMask broadcasts them. MCP agents
877
+ * never broadcast. The API never holds user keys.
375
878
  */
376
879
  /** Allowlisted vault token metadata from GET /vault. */
377
880
  interface VaultToken {
@@ -531,9 +1034,15 @@ interface CreatedDeveloperApiKey extends DeveloperApiKey {
531
1034
  */
532
1035
  declare class AureonClient {
533
1036
  private readonly transport;
1037
+ private readonly resolvedNetwork;
1038
+ private readonly resolvedChainId;
534
1039
  constructor(options?: AureonClientOptions);
535
1040
  /** Returns the resolved API base URL. */
536
1041
  get baseUrl(): string;
1042
+ /** `mainnet` (4663) or `testnet` (46630). */
1043
+ get network(): AureonNetwork;
1044
+ /** Chain id bundled with `network`. */
1045
+ get chainId(): number;
537
1046
  /** Health probe for connectivity checks. No auth required. */
538
1047
  ping(): Promise<{
539
1048
  ok: true;
@@ -620,9 +1129,88 @@ declare class AureonClient {
620
1129
  refreshWatchdog(): Promise<WatchdogRefreshResult>;
621
1130
  /** Returns dashboard overview aggregates. Auth required. */
622
1131
  getOverview(): Promise<DashboardOverview>;
1132
+ /**
1133
+ * Objective vs actual portfolio — joins objectives, health, and overview
1134
+ * into comparison rows plus a green-book/off-plan paradox flag.
1135
+ * Auth required.
1136
+ */
1137
+ getAllocationVsTarget(): Promise<{
1138
+ rows: AllocationComparisonRow[];
1139
+ paradox: PlanParadoxResult;
1140
+ overview: DashboardOverview;
1141
+ }>;
1142
+ /**
1143
+ * Registers agent/user intent as an Automatic objective and returns the
1144
+ * AI → objective → portfolio flow snapshot.
1145
+ * Auth required.
1146
+ */
1147
+ applyFinancialIntent(intent: FinancialIntent): Promise<ObjectivePortfolioFlow>;
1148
+ /**
1149
+ * Read-only AI → objective → portfolio flow for existing objectives.
1150
+ * Auth required.
1151
+ */
1152
+ getObjectivePortfolioFlow(objectiveId?: string): Promise<ObjectivePortfolioFlow[]>;
1153
+ /**
1154
+ * Controlled drift → detection → restore demo
1155
+ * Seeds book, creates stable objective, applies NVDA rally with auto-restore
1156
+ * disabled, then runs manual restore and returns the three-beat flow.
1157
+ * Auth required.
1158
+ */
1159
+ runDriftRestoreDemo(): Promise<DriftRestoreFlow>;
1160
+ /**
1161
+ * Read-only drift → detection → restore flow for active objectives.
1162
+ * Auth required.
1163
+ */
1164
+ getDriftRestoreFlow(objectiveId?: string): Promise<DriftRestoreFlow[]>;
1165
+ private buildReceiptVerificationFlowForReceipt;
1166
+ /**
1167
+ * Controlled receipt → verification demo.
1168
+ * Runs drift-restore, then validates receipt and looks up settlement.
1169
+ * Auth required.
1170
+ */
1171
+ runReceiptVerificationDemo(): Promise<ReceiptVerificationFlow>;
1172
+ /**
1173
+ * Read-only receipt → verification flow for execution receipts.
1174
+ * Auth required.
1175
+ */
1176
+ getReceiptVerificationFlow(executionId?: string): Promise<ReceiptVerificationFlow[]>;
1177
+ /**
1178
+ * Controlled portfolio watch demo.
1179
+ * User brief → Automatic objective → market move while away → auto restore → return briefing.
1180
+ * Auth required.
1181
+ */
1182
+ runPortfolioWatchDemo(input?: {
1183
+ brief?: string;
1184
+ host?: AgentHost;
1185
+ }): Promise<PortfolioWatchFlow>;
1186
+ /**
1187
+ * Read-only portfolio watch briefing for Automatic objectives.
1188
+ * Auth required.
1189
+ */
1190
+ getPortfolioWatchFlow(input?: {
1191
+ objectiveId?: string;
1192
+ brief?: string;
1193
+ host?: AgentHost;
1194
+ }): Promise<PortfolioWatchFlow[]>;
1195
+ /**
1196
+ * Controlled full AUREON loop demo (Content Arc).
1197
+ * Intent → plan check (green vs plan with autoRestore false) → restore → receipt verification.
1198
+ * Auth required.
1199
+ */
1200
+ runFullAureonLoopDemo(input?: {
1201
+ brief?: string;
1202
+ }): Promise<FullAureonLoopFlow>;
1203
+ /**
1204
+ * Read-only full AUREON loop for active objectives with a latest receipt.
1205
+ * Auth required.
1206
+ */
1207
+ getFullAureonLoopFlow(input?: {
1208
+ objectiveId?: string;
1209
+ brief?: string;
1210
+ }): Promise<FullAureonLoopFlow[]>;
623
1211
  /**
624
1212
  * Applies a controlled market event to portfolio marks.
625
- * When autoRestore is true, the API evaluates health and may run staged restorative execution.
1213
+ * When autoRestore is true, the API may run restore. Omit or false = drift only, no restore. Automatic still 409s if the vault cannot execute.
626
1214
  * Auth required.
627
1215
  */
628
1216
  applyMarketEvent(input: ApplyMarketEventInput): Promise<{
@@ -646,12 +1234,24 @@ declare class AureonClient {
646
1234
  */
647
1235
  runExecution(objectiveId: string): Promise<ExecutionReceipt>;
648
1236
  /**
649
- * Runs vault-backed restorative execution for an objective outside policy.
1237
+ * Runs restorative execution for an objective outside policy.
1238
+ * Receipt.settlement may be vault or staged. Only verifiedOnChain is proof.
650
1239
  * Auth required.
651
1240
  */
652
1241
  restoreObjective(objectiveId: string): Promise<ExecutionReceipt>;
653
1242
  /** Lists recent execution receipts. Auth required. */
654
1243
  listExecutions(objectiveId?: string): Promise<ExecutionReceipt[]>;
1244
+ /** Returns chain-verified settlement record for an execution when present. Auth required. */
1245
+ getExecutionSettlement(executionId: string): Promise<ExecutionSettlementLookup>;
1246
+ /** Lists chain-verified settlement records for the authenticated wallet. Auth required. */
1247
+ listSettlements(objectiveId?: string): Promise<SettlementRecord[]>;
1248
+ /**
1249
+ * Manual backfill: verify a vault tx on-chain and attach settlement proof.
1250
+ * Auth required.
1251
+ */
1252
+ confirmExecutionSettlement(executionId: string, transactionHash: string): Promise<{
1253
+ settlement: SettlementRecord;
1254
+ }>;
655
1255
  /** Returns Phase 2 ObjectiveRegistry deployment status. Auth required. */
656
1256
  getRegistryStatus(): Promise<RegistryStatus>;
657
1257
  /** Returns on-chain registry record for an objective when registered. Auth required. */
@@ -701,6 +1301,11 @@ declare class AureonClient {
701
1301
  revokeApiKey(keyId: string): Promise<DeveloperApiKey>;
702
1302
  /** Toggles the status (active/paused) of an SDK API key owned by this wallet. */
703
1303
  toggleApiKey(keyId: string): Promise<DeveloperApiKey>;
1304
+ /**
1305
+ * Joins objective → registry → receipts → settlements → timeline.
1306
+ * Missing proof is labeled as a gap. Nothing is invented. Auth required.
1307
+ */
1308
+ getAuditTrail(objectiveId: string): Promise<FinancialAuditTrail>;
704
1309
  }
705
1310
 
706
1311
  /**
@@ -709,12 +1314,12 @@ declare class AureonClient {
709
1314
 
710
1315
  /**
711
1316
  * Factory helper preferred by examples and quickstarts.
712
- * Defaults to the production AUREON API URL when `baseUrl` is omitted.
1317
+ * Omit `network` and `baseUrl` for local mainnet (4663 / 8788).
1318
+ * Pass `network: "testnet"` for the public host (still 46630).
713
1319
  */
714
1320
  declare function createAureonClient(options?: AureonClientOptions): AureonClient;
715
1321
  /**
716
- * Creates a client pointed at a local AUREON API process (monorepo operators).
717
- * Not advertised in the public README.
1322
+ * Creates a client pointed at the local mainnet API (8788 / 4663).
718
1323
  */
719
1324
  declare function createLocalAureonClient(overrides?: Partial<AureonClientOptions>): AureonClient;
720
1325
 
@@ -820,12 +1425,12 @@ declare function withQuery(path: string, query: Record<string, string | undefine
820
1425
  /**
821
1426
  * @fileoverview Default runtime values for SDK clients and examples.
822
1427
  */
823
- /** Production AUREON API (public integrators). */
1428
+ /** Testnet public host (chain 46630). Not the omitted-options client default. */
824
1429
  declare const DEFAULT_API_BASE_URL = "https://api.aureonlabs.network";
825
- /** Local monorepo preview only; not for public docs. */
826
- declare const LOCAL_API_BASE_URL = "http://127.0.0.1:8787";
1430
+ /** Local mainnet API (chain 4663). Same as MAINNET_API_BASE_URL. */
1431
+ declare const LOCAL_API_BASE_URL = "http://127.0.0.1:8788";
827
1432
  declare const DEFAULT_TIMEOUT_MS = 30000;
828
- declare const SDK_VERSION = "0.1.2";
1433
+ declare const SDK_VERSION = "0.1.7";
829
1434
  declare const SDK_NAME = "@buildaureon/sdk";
830
1435
  declare const PRODUCT_NAME = "AUREON";
831
1436
  declare const PRODUCT_TAGLINE = "Financial Compass for Robinhood Chain";
@@ -860,6 +1465,7 @@ declare const ENDPOINTS: {
860
1465
  readonly authMe: "/auth/me";
861
1466
  readonly developerApiKeys: "/developer/api-keys";
862
1467
  readonly registryStatus: "/registry/status";
1468
+ readonly settlements: "/settlements";
863
1469
  };
864
1470
 
865
1471
  /**
@@ -868,4 +1474,4 @@ declare const ENDPOINTS: {
868
1474
  type FetchLike = typeof fetch;
869
1475
  declare function resolveFetch(custom?: FetchLike): FetchLike;
870
1476
 
871
- 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 ObjectiveRegistryLookup, type ObjectiveRegistryRecord, type ObjectiveStatus, PRODUCT_NAME, PRODUCT_TAGLINE, type PortfolioPosition, type PortfolioPositionInput, type PortfolioSnapshot, type PrepareRegistryResult, type RegistryRef, type RegistryStatus, 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 };
1477
+ export { API_KEY_HEADER, AUREON_NETWORKS, type AgentHost, type AllocationComparisonRow, type ApplyMarketEventInput, type AuditTrailGap, type AuditTrailGapCode, type AuditTrailReceiptRow, AureonClient, type AureonClientOptions, AureonConflictError, AureonError, type AureonErrorCode, type AureonNetwork, AureonNetworkError, type AureonNetworkPreset, AureonNotFoundError, AureonTimeoutError, AureonValidationError, type AuthMeResponse, type AuthNonceResponse, type AuthSessionResponse, type CreateObjectiveInput, type CreatedDeveloperApiKey, DEFAULT_API_BASE_URL, DEFAULT_FULL_LOOP_BRIEF, DEFAULT_PORTFOLIO_WATCH_BRIEF, DEFAULT_TIMEOUT_MS, type DashboardOverview, type DeveloperApiKey, type DriftRestoreFlow, type DriftRestorePhase, ENDPOINTS, type ExecutionReceipt, type ExecutionSettlementLookup, type FinancialAuditTrail, type FinancialIntent, type FullAureonLoopFlow, type FullAureonLoopPhase, type HealthState, LOCAL_API_BASE_URL, MAINNET_API_BASE_URL, MAINNET_CHAIN_ID, type MarkQuote, type MarkQuoteSource, type MarketEvent, type MarketPreset, OBJECTIVE_KINDS, OBJECTIVE_PRIORITIES, type Objective, type ObjectiveAutomationMode, type ObjectiveHealth, type ObjectiveKind, type ObjectivePolicy, type ObjectivePortfolioFlow, type ObjectivePriority, type ObjectiveRegistryLookup, type ObjectiveRegistryRecord, type ObjectiveStatus, PRODUCT_NAME, PRODUCT_TAGLINE, type PlanParadoxResult, type PortfolioPosition, type PortfolioPositionInput, type PortfolioSnapshot, type PortfolioWatchFlow, type PortfolioWatchPhase, type PrepareRegistryResult, type ReceiptProofTier, type ReceiptValidationCode, type ReceiptValidationIssue, type ReceiptValidationResult, type ReceiptVerificationFlow, type ReceiptVerificationPhase, type RegistryRef, type RegistryStatus, type ResolveAureonNetworkInput, type RestorePlan, type RestorePlanKind, type RestoreSuggestion, type RestoreSuggestionAction, SDK_NAME, SDK_VERSION, type SessionTokenProvider, type SettlementRecord, type SettlementStatus, type SyncPortfolioResult, TESTNET_API_BASE_URL, TESTNET_CHAIN_ID, 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, assertValidExecutionReceipt, buildAllocationComparison, buildDriftRestoreFlow, buildDriftRestoreFlowFromSnapshot, buildFinancialAuditTrail, buildFullAureonLoopFlow, buildFullAureonLoopFlowFromSnapshot, buildObjectivePortfolioFlow, buildPolicySummary, buildPortfolioWatchBriefingLines, buildPortfolioWatchFlow, buildPortfolioWatchFlowFromSnapshot, buildReceiptVerificationFlow, createAureonClient, createConsoleLogger, createLocalAureonClient, createSessionTokenProvider, detectPlanParadox, errorFromHttpStatus, findTimelineEventsForReceipt, formatAuditTrailLines, formatIsoTime, formatReceiptSummary, formatSettlementSummary, formatSignedPercent, formatUsd, formatWeight, healthTone, inferAureonNetworkFromUrl, inferDriftPhase, inferFullAureonLoopPhase, inferPortfolioWatchPhase, inferProofTier, isAureonError, isChainVerifiedReceipt, isHealthState, isObjectiveKind, isObjectivePriority, isTimelineEventType, isValidExecutionReceipt, isVaultSettlement, joinUrl, normalizeCreateObjectiveInput, normalizeUpdateObjectiveInput, parseFinancialIntent, pickWorstHealth, requestJson, resolveAureonNetwork, resolveAureonNetworkFromEnv, resolveFetch, resolveObjectiveFromIntent, silentLogger, validateExecutionReceipt, validateSettlementRecord, withQuery };