@buildaureon/sdk 0.1.2 → 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/dist/index.d.ts CHANGED
@@ -1,61 +1,17 @@
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 Timeline event contracts for append-only operator narratives.
12
3
  */
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
- * 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;
4
+ 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";
5
+ interface TimelineEvent {
6
+ id: string;
7
+ objectiveId: string | null;
8
+ type: TimelineEventType;
9
+ message: string;
10
+ payload: Record<string, unknown>;
11
+ createdAt: string;
58
12
  }
13
+ declare const TIMELINE_EVENT_TYPES: readonly TimelineEventType[];
14
+ declare function isTimelineEventType(value: string): value is TimelineEventType;
59
15
 
60
16
  /**
61
17
  * @fileoverview Phase 2 ObjectiveRegistry types.
@@ -106,6 +62,39 @@ type ObjectiveRegistryLookup = {
106
62
  record: ObjectiveRegistryRecord;
107
63
  };
108
64
 
65
+ /**
66
+ * @fileoverview On-chain settlement record for vault rebalances (Day 8).
67
+ */
68
+
69
+ type SettlementStatus = "confirmed" | "orphan";
70
+ interface SettlementRecord {
71
+ id: string;
72
+ executionId: string | null;
73
+ objectiveId: string | null;
74
+ walletAddress: string;
75
+ /** Chain-verified vault settlements are always `"vault"`. */
76
+ settlement: "vault";
77
+ transactionHash: string;
78
+ blockNumber: number;
79
+ logIndex: number;
80
+ vaultAddress: string;
81
+ tokenSell: string;
82
+ tokenBuy: string;
83
+ amountIn: string;
84
+ amountOut: string;
85
+ explorerUrl: string;
86
+ verifiedAt: string;
87
+ status: SettlementStatus;
88
+ registryRef?: RegistryRef;
89
+ }
90
+ interface ExecutionSettlementLookup {
91
+ executionId: string;
92
+ verifiedOnChain: boolean;
93
+ settlement: SettlementRecord | null;
94
+ }
95
+ /** Human-readable settlement summary for agents and logs. */
96
+ declare function formatSettlementSummary(record: SettlementRecord): string;
97
+
109
98
  /**
110
99
  * @fileoverview Execution receipt + restore-plan types.
111
100
  *
@@ -128,8 +117,14 @@ interface ExecutionReceipt {
128
117
  * `"vault"`: keeper rebalance confirmed (or pending_vault_* then confirmed).
129
118
  * `"staged"`: capital-book restore only (honest non-finality label).
130
119
  */
131
- settlement?: "staged" | "vault";
120
+ settlement: "staged" | "vault";
121
+ /** Block explorer link when vault tx is a real `0x…` hash; null for staged. */
122
+ explorerUrl?: string | null;
132
123
  registryRef?: RegistryRef;
124
+ /** True when a settlement record exists for this execution (vault only). */
125
+ verifiedOnChain?: boolean;
126
+ /** Populated when verifiedOnChain is true. */
127
+ settlementRecord?: SettlementRecord;
133
128
  }
134
129
  /** Client-side restore action: wrap/unwrap ETH↔WETH or keeper vault swap. */
135
130
  type RestorePlanKind = "wrap_eth" | "unwrap_weth" | "vault_swap";
@@ -143,38 +138,12 @@ interface RestorePlan {
143
138
  }
144
139
  /** True when the receipt claims vault (on-chain) settlement. */
145
140
  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;
141
+ /** True when the receipt has independent on-chain settlement proof. */
142
+ declare function isChainVerifiedReceipt(receipt: ExecutionReceipt): boolean;
143
+ /** Human-readable one-line receipt summary for agents and logs. */
144
+ declare function formatReceiptSummary(receipt: ExecutionReceipt): string;
145
+ /** Timeline events linked to a receipt via payload.executionId. */
146
+ declare function findTimelineEventsForReceipt(events: TimelineEvent[], receipt: ExecutionReceipt): TimelineEvent[];
178
147
 
179
148
  /**
180
149
  * @fileoverview Controlled market event types for operator demos and rehearsals.
@@ -239,6 +208,23 @@ interface DashboardOverview {
239
208
  recentEvents: TimelineEvent[];
240
209
  }
241
210
 
211
+ /**
212
+ * @fileoverview Health Engine result types.
213
+ */
214
+ type HealthState = "healthy" | "warning" | "violation" | "paused";
215
+ interface ObjectiveHealth {
216
+ objectiveId: string;
217
+ state: HealthState;
218
+ score: number;
219
+ currentMetric: number;
220
+ targetMetric: number;
221
+ deviation: number;
222
+ message: string;
223
+ evaluatedAt: string;
224
+ }
225
+ declare function isHealthState(value: string): value is HealthState;
226
+ declare function pickWorstHealth(records: ObjectiveHealth[]): ObjectiveHealth | null;
227
+
242
228
  /**
243
229
  * @fileoverview Objective domain types for Financial Compass Objectives.
244
230
  */
@@ -333,6 +319,377 @@ declare const OBJECTIVE_PRIORITIES: readonly ObjectivePriority[];
333
319
  declare function isObjectiveKind(value: string): value is ObjectiveKind;
334
320
  declare function isObjectivePriority(value: string): value is ObjectivePriority;
335
321
 
322
+ /**
323
+ * @fileoverview Objective vs actual allocation comparison and plan paradox detection.
324
+ */
325
+
326
+ interface AllocationComparisonRow {
327
+ objectiveId: string;
328
+ name: string;
329
+ kind: ObjectiveKind;
330
+ targetSymbol?: string;
331
+ targetWeight: number;
332
+ currentMetric: number;
333
+ deviation: number;
334
+ state: HealthState;
335
+ }
336
+ interface PlanParadoxResult {
337
+ detected: boolean;
338
+ bookUp: boolean;
339
+ offPlanCount: number;
340
+ message: string;
341
+ }
342
+ /**
343
+ * Joins active objectives with health records into target vs current rows.
344
+ */
345
+ declare function buildAllocationComparison(objectives: Objective[], health: ObjectiveHealth[]): AllocationComparisonRow[];
346
+ /**
347
+ * Detects when book performance looks fine but objectives are off-plan.
348
+ */
349
+ declare function detectPlanParadox(overview: DashboardOverview, health: ObjectiveHealth[]): PlanParadoxResult;
350
+
351
+ /**
352
+ * @fileoverview Drift → detection → restore teaching flow helpers.
353
+ */
354
+
355
+ type DriftRestorePhase = "aligned" | "drift_detected" | "restored";
356
+ interface DriftRestoreFlow {
357
+ objectiveId: string;
358
+ rule: {
359
+ summary: string;
360
+ targetWeight: number;
361
+ tolerance: number;
362
+ };
363
+ phases: {
364
+ aligned: {
365
+ health: ObjectiveHealth;
366
+ allocationRow?: AllocationComparisonRow;
367
+ };
368
+ drift: {
369
+ health: ObjectiveHealth;
370
+ allocationRow?: AllocationComparisonRow;
371
+ restorePlan?: RestorePlan;
372
+ };
373
+ restored?: {
374
+ health: ObjectiveHealth;
375
+ receipt?: ExecutionReceipt;
376
+ settlement?: string;
377
+ };
378
+ };
379
+ currentPhase: DriftRestorePhase;
380
+ message: string;
381
+ }
382
+ /**
383
+ * Infers drift-restore phase from a single health snapshot.
384
+ */
385
+ declare function inferDriftPhase(health: ObjectiveHealth): DriftRestorePhase;
386
+ /**
387
+ * Builds the drift → detection → restore teaching shape.
388
+ */
389
+ declare function buildDriftRestoreFlow(input: {
390
+ objective: Objective;
391
+ alignedHealth: ObjectiveHealth;
392
+ driftHealth: ObjectiveHealth;
393
+ driftPlan?: RestorePlan;
394
+ restoredHealth?: ObjectiveHealth;
395
+ receipt?: ExecutionReceipt;
396
+ alignedRow?: AllocationComparisonRow;
397
+ driftRow?: AllocationComparisonRow;
398
+ }): DriftRestoreFlow;
399
+ /**
400
+ * Read-only flow from current objective state + optional latest receipt.
401
+ */
402
+ declare function buildDriftRestoreFlowFromSnapshot(input: {
403
+ objective: Objective;
404
+ health: ObjectiveHealth;
405
+ allocationRow?: AllocationComparisonRow;
406
+ restorePlan?: RestorePlan;
407
+ latestReceipt?: ExecutionReceipt;
408
+ }): DriftRestoreFlow;
409
+
410
+ /**
411
+ * @fileoverview Phase 2 execution receipt validator — schema + honesty rules.
412
+ */
413
+
414
+ 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";
415
+ type ReceiptValidationIssue = {
416
+ code: ReceiptValidationCode;
417
+ message: string;
418
+ path?: string;
419
+ };
420
+ type ReceiptValidationResult = {
421
+ valid: boolean;
422
+ issues: ReceiptValidationIssue[];
423
+ };
424
+ /** Validates a settlement record nested on a receipt. */
425
+ declare function validateSettlementRecord(input: unknown, options?: {
426
+ executionId?: string;
427
+ }): ReceiptValidationResult;
428
+ /**
429
+ * Validates an execution receipt against the Phase 2 contract + honesty rules.
430
+ * Never throws — inspect `valid` and `issues`.
431
+ */
432
+ declare function validateExecutionReceipt(input: unknown): ReceiptValidationResult;
433
+ /** Type guard: true when input passes validateExecutionReceipt. */
434
+ declare function isValidExecutionReceipt(input: unknown): input is ExecutionReceipt;
435
+ /** Throws AureonValidationError when the receipt fails validation. */
436
+ declare function assertValidExecutionReceipt(receipt: unknown): asserts receipt is ExecutionReceipt;
437
+
438
+ /**
439
+ * @fileoverview Receipt → verification teaching flow helpers.
440
+ */
441
+
442
+ type ReceiptVerificationPhase = "claimed" | "validated" | "validation_failed" | "chain_verified";
443
+ type ReceiptProofTier = "claim_only" | "schema_valid" | "chain_verified";
444
+ interface ReceiptVerificationFlow {
445
+ executionId: string;
446
+ receipt: ExecutionReceipt;
447
+ phases: {
448
+ claimed: {
449
+ summary: string;
450
+ status: string;
451
+ settlement: string;
452
+ result: string;
453
+ };
454
+ validation: ReceiptValidationResult;
455
+ settlement?: ExecutionSettlementLookup;
456
+ timelineEvents?: TimelineEvent[];
457
+ };
458
+ proofTier: ReceiptProofTier;
459
+ currentPhase: ReceiptVerificationPhase;
460
+ message: string;
461
+ }
462
+ /**
463
+ * Infers proof tier from receipt, validation, and optional settlement lookup.
464
+ */
465
+ declare function inferProofTier(receipt: ExecutionReceipt, validation: ReceiptValidationResult, settlement?: ExecutionSettlementLookup): ReceiptProofTier;
466
+ /**
467
+ * Builds the receipt → verification teaching shape.
468
+ */
469
+ declare function buildReceiptVerificationFlow(input: {
470
+ receipt: ExecutionReceipt;
471
+ validation?: ReceiptValidationResult;
472
+ settlement?: ExecutionSettlementLookup;
473
+ timelineEvents?: TimelineEvent[];
474
+ }): ReceiptVerificationFlow;
475
+
476
+ /**
477
+ * @fileoverview Portfolio watch while away — agent-in-host teaching flow (Update 6).
478
+ */
479
+
480
+ type AgentHost = "cursor" | "claude" | "mcp";
481
+ type PortfolioWatchPhase = "watch_registered" | "while_away" | "return_briefing";
482
+ /** Default consumer brief for Update 6 demos. */
483
+ declare const DEFAULT_PORTFOLIO_WATCH_BRIEF = "Watch my portfolio while I'm away \u2014 keep about 20% in stable assets.";
484
+ interface PortfolioWatchFlow {
485
+ objectiveId: string;
486
+ userBrief: string;
487
+ host: AgentHost;
488
+ phases: {
489
+ register: {
490
+ objectiveName: string;
491
+ automationMode: string;
492
+ policySummary: string;
493
+ health: ObjectiveHealth;
494
+ allocationRow?: AllocationComparisonRow;
495
+ };
496
+ whileAway?: {
497
+ marketEventName: string;
498
+ symbol: string;
499
+ priceChangeRatio: number;
500
+ healthBefore: ObjectiveHealth;
501
+ healthAfter: ObjectiveHealth;
502
+ autoRestored: boolean;
503
+ receipt?: ExecutionReceipt;
504
+ };
505
+ briefing: {
506
+ health: ObjectiveHealth;
507
+ timelineEventCount: number;
508
+ timelineEvents: TimelineEvent[];
509
+ summaryLines: string[];
510
+ };
511
+ };
512
+ currentPhase: PortfolioWatchPhase;
513
+ message: string;
514
+ }
515
+ /**
516
+ * Infers portfolio-watch phase from register + optional while-away data.
517
+ */
518
+ declare function inferPortfolioWatchPhase(input: {
519
+ registerHealth: ObjectiveHealth;
520
+ whileAway?: PortfolioWatchFlow["phases"]["whileAway"];
521
+ }): PortfolioWatchPhase;
522
+ /**
523
+ * Builds human-readable briefing lines for agent hosts (Cursor / Claude).
524
+ */
525
+ declare function buildPortfolioWatchBriefingLines(input: {
526
+ userBrief: string;
527
+ host: AgentHost;
528
+ objective: Objective;
529
+ registerHealth: ObjectiveHealth;
530
+ briefingHealth: ObjectiveHealth;
531
+ whileAway?: PortfolioWatchFlow["phases"]["whileAway"];
532
+ timelineEvents: TimelineEvent[];
533
+ }): string[];
534
+ /**
535
+ * Builds the portfolio watch teaching shape for agent-in-host demos.
536
+ */
537
+ declare function buildPortfolioWatchFlow(input: {
538
+ userBrief: string;
539
+ host: AgentHost;
540
+ objective: Objective;
541
+ registerHealth: ObjectiveHealth;
542
+ registerRow?: AllocationComparisonRow;
543
+ whileAway?: {
544
+ marketEvent: MarketEvent;
545
+ healthBefore: ObjectiveHealth;
546
+ healthAfter: ObjectiveHealth;
547
+ autoRestored: boolean;
548
+ receipt?: ExecutionReceipt;
549
+ };
550
+ briefingHealth: ObjectiveHealth;
551
+ timelineEvents: TimelineEvent[];
552
+ }): PortfolioWatchFlow;
553
+ /**
554
+ * Read-only portfolio watch snapshot from current objective state.
555
+ */
556
+ declare function buildPortfolioWatchFlowFromSnapshot(input: {
557
+ userBrief: string;
558
+ host: AgentHost;
559
+ objective: Objective;
560
+ health: ObjectiveHealth;
561
+ allocationRow?: AllocationComparisonRow;
562
+ latestReceipt?: ExecutionReceipt;
563
+ timelineEvents: TimelineEvent[];
564
+ }): PortfolioWatchFlow;
565
+
566
+ /**
567
+ * @fileoverview Full AUREON loop teaching flow helpers.
568
+ */
569
+
570
+ type FullAureonLoopPhase = "intent" | "plan_check" | "restored" | "verified";
571
+ /** Default brief for full-loop demos. */
572
+ declare const DEFAULT_FULL_LOOP_BRIEF = "Keep about 20% in stable assets \u2014 grow the book without abandoning the plan.";
573
+ interface FullAureonLoopFlow {
574
+ objectiveId: string;
575
+ userBrief: string;
576
+ phases: {
577
+ intent: {
578
+ objectiveName: string;
579
+ policySummary: string;
580
+ automationMode: string;
581
+ health: ObjectiveHealth;
582
+ };
583
+ planCheck: {
584
+ baselineAligned: boolean;
585
+ afterShock: {
586
+ health: ObjectiveHealth;
587
+ allocationRow?: AllocationComparisonRow;
588
+ paradox: PlanParadoxResult;
589
+ };
590
+ };
591
+ driftRestore: {
592
+ healthBefore: ObjectiveHealth;
593
+ healthAfter: ObjectiveHealth;
594
+ receipt: ExecutionReceipt;
595
+ settlement: string;
596
+ };
597
+ verification: ReceiptVerificationFlow;
598
+ };
599
+ currentPhase: FullAureonLoopPhase;
600
+ message: string;
601
+ }
602
+ /**
603
+ * Infers loop phase from which stages are present.
604
+ */
605
+ declare function inferFullAureonLoopPhase(input: {
606
+ hasRestore: boolean;
607
+ verificationValid: boolean;
608
+ }): FullAureonLoopPhase;
609
+ /**
610
+ * Builds the full AUREON loop teaching shape.
611
+ */
612
+ declare function buildFullAureonLoopFlow(input: {
613
+ userBrief: string;
614
+ objective: Objective;
615
+ baselineHealth: ObjectiveHealth;
616
+ afterShockHealth: ObjectiveHealth;
617
+ afterShockRow?: AllocationComparisonRow;
618
+ paradox: PlanParadoxResult;
619
+ restoredHealth: ObjectiveHealth;
620
+ receipt: ExecutionReceipt;
621
+ verification?: ReceiptVerificationFlow;
622
+ }): FullAureonLoopFlow;
623
+ /**
624
+ * Read-only full-loop snapshot from current objective state + latest receipt.
625
+ */
626
+ declare function buildFullAureonLoopFlowFromSnapshot(input: {
627
+ userBrief: string;
628
+ objective: Objective;
629
+ health: ObjectiveHealth;
630
+ allocationRow?: AllocationComparisonRow;
631
+ paradox: PlanParadoxResult;
632
+ latestReceipt?: ExecutionReceipt;
633
+ verification?: ReceiptVerificationFlow;
634
+ }): FullAureonLoopFlow | null;
635
+
636
+ /**
637
+ * @fileoverview Financial audit trail — objective → registry → receipt → settlement.
638
+ *
639
+ * Joins what already exists. Never invents missing proof. Gaps stay labeled.
640
+ */
641
+
642
+ type AuditTrailGapCode = "not_registered" | "no_executions" | "no_settlements" | "staged_only" | "vault_unverified" | "invalid_receipt" | "no_timeline" | "lookup_failed";
643
+ interface AuditTrailGap {
644
+ code: AuditTrailGapCode;
645
+ message: string;
646
+ }
647
+ interface AuditTrailReceiptRow {
648
+ id: string;
649
+ action: string;
650
+ settlement: "vault" | "staged";
651
+ status: string;
652
+ valid: boolean;
653
+ verifiedOnChain: boolean;
654
+ explorerUrl: string | null;
655
+ summary: string;
656
+ validation: ReceiptValidationResult;
657
+ }
658
+ interface FinancialAuditTrail {
659
+ objectiveId: string;
660
+ objectiveName: string;
661
+ policySummary: string;
662
+ healthState: string | null;
663
+ generatedAt: string;
664
+ registry: {
665
+ present: boolean;
666
+ record?: ObjectiveRegistryRecord;
667
+ };
668
+ receipts: AuditTrailReceiptRow[];
669
+ settlements: SettlementRecord[];
670
+ timeline: Array<{
671
+ id: string;
672
+ type: string;
673
+ message: string;
674
+ createdAt: string;
675
+ executionId: string | null;
676
+ }>;
677
+ gaps: AuditTrailGap[];
678
+ message: string;
679
+ }
680
+ declare function buildFinancialAuditTrail(input: {
681
+ objective: Objective;
682
+ health?: ObjectiveHealth;
683
+ registry?: ObjectiveRegistryLookup;
684
+ receipts: ExecutionReceipt[];
685
+ settlements: SettlementRecord[];
686
+ timeline: TimelineEvent[];
687
+ generatedAt?: string;
688
+ registryLookupFailed?: boolean;
689
+ settlementsLookupFailed?: boolean;
690
+ }): FinancialAuditTrail;
691
+ declare function formatAuditTrailLines(trail: FinancialAuditTrail): string[];
692
+
336
693
  /**
337
694
  * @fileoverview Portfolio snapshot types used by health evaluation and utility screens.
338
695
  */
@@ -365,6 +722,106 @@ interface PortfolioPositionInput {
365
722
  markPriceUsd: number;
366
723
  }
367
724
 
725
+ /**
726
+ * @fileoverview Financial intent → objective → portfolio flow helpers.
727
+ */
728
+
729
+ interface FinancialIntent {
730
+ /** User or agent wording — what they want money to do. */
731
+ brief: string;
732
+ kind: ObjectiveKind;
733
+ targetWeight: number;
734
+ tolerance: number;
735
+ targetSymbol?: string;
736
+ name?: string;
737
+ priority?: ObjectivePriority;
738
+ }
739
+ interface ObjectivePortfolioFlow {
740
+ intent: {
741
+ brief: string;
742
+ policySummary: string;
743
+ };
744
+ objective: Objective;
745
+ health: ObjectiveHealth | null;
746
+ portfolio: {
747
+ totalNotionalUsd: number;
748
+ stableWeight: number;
749
+ positions: PortfolioPosition[];
750
+ };
751
+ message: string;
752
+ }
753
+ /**
754
+ * Maps agent-extracted intent into a create-objective payload.
755
+ */
756
+ declare function resolveObjectiveFromIntent(intent: FinancialIntent): CreateObjectiveInput;
757
+ /**
758
+ * Builds the AI → objective → portfolio teaching shape after create + read.
759
+ */
760
+ declare function buildObjectivePortfolioFlow(intent: FinancialIntent, objective: Objective, health: ObjectiveHealth | null, portfolio: PortfolioSnapshot): ObjectivePortfolioFlow;
761
+ /**
762
+ * Lightweight rule-based parser for demo scripts.
763
+ */
764
+ declare function parseFinancialIntent(brief: string): FinancialIntent;
765
+
766
+ interface AureonLogger {
767
+ debug(message: string, context?: Record<string, unknown>): void;
768
+ info(message: string, context?: Record<string, unknown>): void;
769
+ warn(message: string, context?: Record<string, unknown>): void;
770
+ error(message: string, context?: Record<string, unknown>): void;
771
+ }
772
+ declare const silentLogger: AureonLogger;
773
+ declare function createConsoleLogger(prefix?: string): AureonLogger;
774
+
775
+ /**
776
+ * @fileoverview Client configuration types for AureonClient.
777
+ */
778
+
779
+ interface AureonClientOptions {
780
+ /**
781
+ * Base URL of the AUREON API.
782
+ * Defaults to `https://api.aureonlabs.network`.
783
+ */
784
+ baseUrl?: string;
785
+ /**
786
+ * Product API key sent as `X-Aureon-Api-Key` on every request.
787
+ * Operator-issued keys (from the Developers console) also identify the
788
+ * bound wallet for control-plane calls — no Bearer required.
789
+ * Env bootstrap keys unlock product access only; they do not set identity.
790
+ * The operator utility uses wallet Bearer only.
791
+ */
792
+ apiKey?: string | null;
793
+ /**
794
+ * Called before each request to resolve the product API key.
795
+ * Prefer this for automations that load keys from env or a secret store.
796
+ */
797
+ getApiKey?: () => string | null | undefined | Promise<string | null | undefined>;
798
+ /** Optional fetch implementation for non-browser runtimes. */
799
+ fetch?: typeof fetch;
800
+ /** Optional default headers merged into every request. */
801
+ headers?: Record<string, string>;
802
+ /** Request timeout in milliseconds. Defaults to 30000. */
803
+ timeoutMs?: number;
804
+ /**
805
+ * Static Bearer session token. Prefer `getAccessToken` for apps that refresh
806
+ * or clear sessions at runtime.
807
+ */
808
+ authToken?: string | null;
809
+ /**
810
+ * Called before each request to resolve the current Bearer token.
811
+ * Return null/undefined to send the request without Authorization.
812
+ */
813
+ getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
814
+ /** Optional structured logger for request lifecycle diagnostics. */
815
+ logger?: AureonLogger;
816
+ /**
817
+ * Extra attempts after the first failure for retryable errors
818
+ * (network, timeout, 429, 5xx). Defaults to 0.
819
+ */
820
+ maxRetries?: number;
821
+ /** Delay in ms between retries. Defaults to 250. */
822
+ retryDelayMs?: number;
823
+ }
824
+
368
825
  /**
369
826
  * @fileoverview Vault overview + prepare-tx contracts for AureonVault.
370
827
  *
@@ -620,9 +1077,88 @@ declare class AureonClient {
620
1077
  refreshWatchdog(): Promise<WatchdogRefreshResult>;
621
1078
  /** Returns dashboard overview aggregates. Auth required. */
622
1079
  getOverview(): Promise<DashboardOverview>;
1080
+ /**
1081
+ * Objective vs actual portfolio — joins objectives, health, and overview
1082
+ * into comparison rows plus a green-book/off-plan paradox flag.
1083
+ * Auth required.
1084
+ */
1085
+ getAllocationVsTarget(): Promise<{
1086
+ rows: AllocationComparisonRow[];
1087
+ paradox: PlanParadoxResult;
1088
+ overview: DashboardOverview;
1089
+ }>;
1090
+ /**
1091
+ * Registers agent/user intent as an Automatic objective and returns the
1092
+ * AI → objective → portfolio flow snapshot.
1093
+ * Auth required.
1094
+ */
1095
+ applyFinancialIntent(intent: FinancialIntent): Promise<ObjectivePortfolioFlow>;
1096
+ /**
1097
+ * Read-only AI → objective → portfolio flow for existing objectives.
1098
+ * Auth required.
1099
+ */
1100
+ getObjectivePortfolioFlow(objectiveId?: string): Promise<ObjectivePortfolioFlow[]>;
1101
+ /**
1102
+ * Controlled drift → detection → restore demo
1103
+ * Seeds book, creates stable objective, applies NVDA rally with auto-restore
1104
+ * disabled, then runs manual restore and returns the three-beat flow.
1105
+ * Auth required.
1106
+ */
1107
+ runDriftRestoreDemo(): Promise<DriftRestoreFlow>;
1108
+ /**
1109
+ * Read-only drift → detection → restore flow for active objectives.
1110
+ * Auth required.
1111
+ */
1112
+ getDriftRestoreFlow(objectiveId?: string): Promise<DriftRestoreFlow[]>;
1113
+ private buildReceiptVerificationFlowForReceipt;
1114
+ /**
1115
+ * Controlled receipt → verification demo.
1116
+ * Runs drift-restore, then validates receipt and looks up settlement.
1117
+ * Auth required.
1118
+ */
1119
+ runReceiptVerificationDemo(): Promise<ReceiptVerificationFlow>;
1120
+ /**
1121
+ * Read-only receipt → verification flow for execution receipts.
1122
+ * Auth required.
1123
+ */
1124
+ getReceiptVerificationFlow(executionId?: string): Promise<ReceiptVerificationFlow[]>;
1125
+ /**
1126
+ * Controlled portfolio watch demo.
1127
+ * User brief → Automatic objective → market move while away → auto restore → return briefing.
1128
+ * Auth required.
1129
+ */
1130
+ runPortfolioWatchDemo(input?: {
1131
+ brief?: string;
1132
+ host?: AgentHost;
1133
+ }): Promise<PortfolioWatchFlow>;
1134
+ /**
1135
+ * Read-only portfolio watch briefing for Automatic objectives.
1136
+ * Auth required.
1137
+ */
1138
+ getPortfolioWatchFlow(input?: {
1139
+ objectiveId?: string;
1140
+ brief?: string;
1141
+ host?: AgentHost;
1142
+ }): Promise<PortfolioWatchFlow[]>;
1143
+ /**
1144
+ * Controlled full AUREON loop demo (Content Arc).
1145
+ * Intent → plan check (green vs plan with autoRestore false) → restore → receipt verification.
1146
+ * Auth required.
1147
+ */
1148
+ runFullAureonLoopDemo(input?: {
1149
+ brief?: string;
1150
+ }): Promise<FullAureonLoopFlow>;
1151
+ /**
1152
+ * Read-only full AUREON loop for active objectives with a latest receipt.
1153
+ * Auth required.
1154
+ */
1155
+ getFullAureonLoopFlow(input?: {
1156
+ objectiveId?: string;
1157
+ brief?: string;
1158
+ }): Promise<FullAureonLoopFlow[]>;
623
1159
  /**
624
1160
  * Applies a controlled market event to portfolio marks.
625
- * When autoRestore is true, the API evaluates health and may run staged restorative execution.
1161
+ * 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
1162
  * Auth required.
627
1163
  */
628
1164
  applyMarketEvent(input: ApplyMarketEventInput): Promise<{
@@ -646,12 +1182,24 @@ declare class AureonClient {
646
1182
  */
647
1183
  runExecution(objectiveId: string): Promise<ExecutionReceipt>;
648
1184
  /**
649
- * Runs vault-backed restorative execution for an objective outside policy.
1185
+ * Runs restorative execution for an objective outside policy.
1186
+ * Receipt.settlement may be vault or staged. Only verifiedOnChain is proof.
650
1187
  * Auth required.
651
1188
  */
652
1189
  restoreObjective(objectiveId: string): Promise<ExecutionReceipt>;
653
1190
  /** Lists recent execution receipts. Auth required. */
654
1191
  listExecutions(objectiveId?: string): Promise<ExecutionReceipt[]>;
1192
+ /** Returns chain-verified settlement record for an execution when present. Auth required. */
1193
+ getExecutionSettlement(executionId: string): Promise<ExecutionSettlementLookup>;
1194
+ /** Lists chain-verified settlement records for the authenticated wallet. Auth required. */
1195
+ listSettlements(objectiveId?: string): Promise<SettlementRecord[]>;
1196
+ /**
1197
+ * Manual backfill: verify a vault tx on-chain and attach settlement proof.
1198
+ * Auth required.
1199
+ */
1200
+ confirmExecutionSettlement(executionId: string, transactionHash: string): Promise<{
1201
+ settlement: SettlementRecord;
1202
+ }>;
655
1203
  /** Returns Phase 2 ObjectiveRegistry deployment status. Auth required. */
656
1204
  getRegistryStatus(): Promise<RegistryStatus>;
657
1205
  /** Returns on-chain registry record for an objective when registered. Auth required. */
@@ -701,6 +1249,11 @@ declare class AureonClient {
701
1249
  revokeApiKey(keyId: string): Promise<DeveloperApiKey>;
702
1250
  /** Toggles the status (active/paused) of an SDK API key owned by this wallet. */
703
1251
  toggleApiKey(keyId: string): Promise<DeveloperApiKey>;
1252
+ /**
1253
+ * Joins objective → registry → receipts → settlements → timeline.
1254
+ * Missing proof is labeled as a gap. Nothing is invented. Auth required.
1255
+ */
1256
+ getAuditTrail(objectiveId: string): Promise<FinancialAuditTrail>;
704
1257
  }
705
1258
 
706
1259
  /**
@@ -825,7 +1378,7 @@ declare const DEFAULT_API_BASE_URL = "https://api.aureonlabs.network";
825
1378
  /** Local monorepo preview only; not for public docs. */
826
1379
  declare const LOCAL_API_BASE_URL = "http://127.0.0.1:8787";
827
1380
  declare const DEFAULT_TIMEOUT_MS = 30000;
828
- declare const SDK_VERSION = "0.1.2";
1381
+ declare const SDK_VERSION = "0.1.7";
829
1382
  declare const SDK_NAME = "@buildaureon/sdk";
830
1383
  declare const PRODUCT_NAME = "AUREON";
831
1384
  declare const PRODUCT_TAGLINE = "Financial Compass for Robinhood Chain";
@@ -860,6 +1413,7 @@ declare const ENDPOINTS: {
860
1413
  readonly authMe: "/auth/me";
861
1414
  readonly developerApiKeys: "/developer/api-keys";
862
1415
  readonly registryStatus: "/registry/status";
1416
+ readonly settlements: "/settlements";
863
1417
  };
864
1418
 
865
1419
  /**
@@ -868,4 +1422,4 @@ declare const ENDPOINTS: {
868
1422
  type FetchLike = typeof fetch;
869
1423
  declare function resolveFetch(custom?: FetchLike): FetchLike;
870
1424
 
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 };
1425
+ export { API_KEY_HEADER, type AgentHost, type AllocationComparisonRow, type ApplyMarketEventInput, type AuditTrailGap, type AuditTrailGapCode, type AuditTrailReceiptRow, 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_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, 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 RestorePlan, type RestorePlanKind, type RestoreSuggestion, type RestoreSuggestionAction, SDK_NAME, SDK_VERSION, type SessionTokenProvider, type SettlementRecord, type SettlementStatus, 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, 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, inferDriftPhase, inferFullAureonLoopPhase, inferPortfolioWatchPhase, inferProofTier, isAureonError, isChainVerifiedReceipt, isHealthState, isObjectiveKind, isObjectivePriority, isTimelineEventType, isValidExecutionReceipt, isVaultSettlement, joinUrl, normalizeCreateObjectiveInput, normalizeUpdateObjectiveInput, parseFinancialIntent, pickWorstHealth, requestJson, resolveFetch, resolveObjectiveFromIntent, silentLogger, validateExecutionReceipt, validateSettlementRecord, withQuery };