@buildaureon/sdk 0.1.7 → 0.1.9
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/CHANGELOG.md +71 -0
- package/README.md +673 -655
- package/config/network.json +17 -7
- package/dist/index.d.ts +71 -14
- package/dist/index.js +109 -10
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +210 -206
- package/docs/auth.md +176 -174
- package/docs/client-api.md +788 -782
- package/docs/data-contracts.md +3 -3
- package/docs/error-model.md +217 -217
- package/docs/integration-guide.md +400 -397
- package/docs/receipt-validation.md +66 -63
- package/docs/security.md +120 -120
- package/docs/transport.md +143 -142
- package/examples/ai-to-objective-to-portfolio/main.ts +6 -3
- package/examples/audit-trail/main.ts +4 -2
- package/examples/drift-detect-restore/main.ts +6 -3
- package/examples/e2e-policy-rebalance/main.ts +431 -426
- package/examples/e2e-policy-rebalance/underrun.ts +143 -138
- package/examples/e2e-policy-rebalance/verify-sizing.ts +155 -150
- package/examples/e2e-vault-flow/main.ts +221 -216
- package/examples/full-aureon-loop/main.ts +6 -3
- package/examples/green-vs-plan/main.ts +6 -3
- package/examples/market-event/main.ts +6 -3
- package/examples/portfolio-watch/main.ts +6 -3
- package/examples/quickstart/main.ts +75 -72
- package/examples/receipt-verification/main.ts +6 -3
- package/examples/sdk-demo-terminal/main.ts +6 -4
- package/package.json +26 -23
package/config/network.json
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"defaultNetwork": "testnet",
|
|
3
|
+
"note": "Default API is https://api.aureonlabs.network. Omit network for testnet 46630. Pass network=mainnet for chain 4663 on the same official host. AUREON_API_URL overrides the host when set.",
|
|
4
|
+
"mainnet": {
|
|
5
|
+
"baseUrl": "https://api.aureonlabs.network",
|
|
6
|
+
"chainId": 4663,
|
|
7
|
+
"chain": "Robinhood Chain",
|
|
8
|
+
"explorer": "https://robinhoodchain.blockscout.com",
|
|
9
|
+
"rpcUrl": "https://rpc.mainnet.chain.robinhood.com"
|
|
10
|
+
},
|
|
11
|
+
"testnet": {
|
|
12
|
+
"baseUrl": "https://api.aureonlabs.network",
|
|
13
|
+
"appUrl": "https://app.aureonlabs.network",
|
|
14
|
+
"chainId": 46630,
|
|
15
|
+
"chain": "Robinhood Chain Testnet",
|
|
16
|
+
"explorer": "https://explorer.testnet.chain.robinhood.com"
|
|
17
|
+
},
|
|
8
18
|
"sdkPackage": "@buildaureon/sdk",
|
|
9
|
-
"sdkVersion": "0.1.
|
|
19
|
+
"sdkVersion": "0.1.9"
|
|
10
20
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Robinhood Chain network presets for the SDK and MCP.
|
|
3
|
+
*
|
|
4
|
+
* Users call the official API: https://api.aureonlabs.network
|
|
5
|
+
* `network` is a named parameter (`testnet` | `mainnet`), not a port.
|
|
6
|
+
* Set `baseUrl` / `AUREON_API_URL` only to override the official host.
|
|
7
|
+
*/
|
|
8
|
+
type AureonNetwork = "mainnet" | "testnet";
|
|
9
|
+
declare const MAINNET_CHAIN_ID = 4663;
|
|
10
|
+
declare const TESTNET_CHAIN_ID = 46630;
|
|
11
|
+
/** Official AUREON API. This is the default for integrators. */
|
|
12
|
+
declare const OFFICIAL_API_BASE_URL = "https://api.aureonlabs.network";
|
|
13
|
+
/** Same host as the official API (current public deployment). */
|
|
14
|
+
declare const TESTNET_API_BASE_URL = "https://api.aureonlabs.network";
|
|
15
|
+
/** Same official hostname. Chain id is selected with `network`, not a port. */
|
|
16
|
+
declare const MAINNET_API_BASE_URL = "https://api.aureonlabs.network";
|
|
17
|
+
type AureonNetworkPreset = {
|
|
18
|
+
network: AureonNetwork;
|
|
19
|
+
chainId: number;
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
explorer: string;
|
|
22
|
+
};
|
|
23
|
+
declare const AUREON_NETWORKS: Record<AureonNetwork, AureonNetworkPreset>;
|
|
24
|
+
type ResolveAureonNetworkInput = {
|
|
25
|
+
/** Omit for the official API (testnet 46630). Pass `mainnet` for chain 4663 on the same host. */
|
|
26
|
+
network?: string | null;
|
|
27
|
+
/** Override the official API URL. Users should leave this unset. */
|
|
28
|
+
baseUrl?: string | null;
|
|
29
|
+
};
|
|
30
|
+
/** Infer preset from a non-official host. Official API is shared — not exclusive. */
|
|
31
|
+
declare function inferAureonNetworkFromUrl(url: string): AureonNetwork | null;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve network + URL + chainId as one bundle.
|
|
34
|
+
*
|
|
35
|
+
* - Neither set → official API, testnet (46630).
|
|
36
|
+
* - Only `network` → official API + that chain.
|
|
37
|
+
* - Only `baseUrl` → that URL; official host stays testnet unless `network` is set.
|
|
38
|
+
* - Both set: official host is always allowed. Other known hosts must match.
|
|
39
|
+
*/
|
|
40
|
+
declare function resolveAureonNetwork(input?: ResolveAureonNetworkInput): AureonNetworkPreset;
|
|
41
|
+
/** MCP / CLI: `AUREON_NETWORK` optional, `AUREON_API_URL` overrides the official host. */
|
|
42
|
+
declare function resolveAureonNetworkFromEnv(env?: NodeJS.Dict<string>): AureonNetworkPreset;
|
|
43
|
+
|
|
1
44
|
/**
|
|
2
45
|
* @fileoverview Timeline event contracts for append-only operator narratives.
|
|
3
46
|
*/
|
|
@@ -778,8 +821,13 @@ declare function createConsoleLogger(prefix?: string): AureonLogger;
|
|
|
778
821
|
|
|
779
822
|
interface AureonClientOptions {
|
|
780
823
|
/**
|
|
781
|
-
*
|
|
782
|
-
*
|
|
824
|
+
* Chain selector. Omit for the official API on testnet (46630).
|
|
825
|
+
* Pass `"mainnet"` for chain 4663 on the same official host.
|
|
826
|
+
*/
|
|
827
|
+
network?: "mainnet" | "testnet";
|
|
828
|
+
/**
|
|
829
|
+
* Override the official API URL. Leave unset so clients use
|
|
830
|
+
* https://api.aureonlabs.network.
|
|
783
831
|
*/
|
|
784
832
|
baseUrl?: string;
|
|
785
833
|
/**
|
|
@@ -826,9 +874,9 @@ interface AureonClientOptions {
|
|
|
826
874
|
* @fileoverview Vault overview + prepare-tx contracts for AureonVault.
|
|
827
875
|
*
|
|
828
876
|
* Reads come from GET /vault and GET /vault/status.
|
|
829
|
-
* Writes are wallet-signed: prepareDeposit / prepareWithdraw return
|
|
830
|
-
* steps
|
|
831
|
-
* user keys.
|
|
877
|
+
* Writes are wallet-signed: prepareDeposit / prepareWithdraw return unsigned
|
|
878
|
+
* calldata steps. The host wallet or MetaMask broadcasts them. MCP agents
|
|
879
|
+
* never broadcast. The API never holds user keys.
|
|
832
880
|
*/
|
|
833
881
|
/** Allowlisted vault token metadata from GET /vault. */
|
|
834
882
|
interface VaultToken {
|
|
@@ -988,9 +1036,15 @@ interface CreatedDeveloperApiKey extends DeveloperApiKey {
|
|
|
988
1036
|
*/
|
|
989
1037
|
declare class AureonClient {
|
|
990
1038
|
private readonly transport;
|
|
1039
|
+
private readonly resolvedNetwork;
|
|
1040
|
+
private readonly resolvedChainId;
|
|
991
1041
|
constructor(options?: AureonClientOptions);
|
|
992
1042
|
/** Returns the resolved API base URL. */
|
|
993
1043
|
get baseUrl(): string;
|
|
1044
|
+
/** `mainnet` (4663) or `testnet` (46630). */
|
|
1045
|
+
get network(): AureonNetwork;
|
|
1046
|
+
/** Chain id bundled with `network`. */
|
|
1047
|
+
get chainId(): number;
|
|
994
1048
|
/** Health probe for connectivity checks. No auth required. */
|
|
995
1049
|
ping(): Promise<{
|
|
996
1050
|
ok: true;
|
|
@@ -1261,13 +1315,14 @@ declare class AureonClient {
|
|
|
1261
1315
|
*/
|
|
1262
1316
|
|
|
1263
1317
|
/**
|
|
1264
|
-
* Factory
|
|
1265
|
-
*
|
|
1318
|
+
* Factory for integrators. Omit `baseUrl` to use the official API
|
|
1319
|
+
* (https://api.aureonlabs.network). Optional `network` selects chain
|
|
1320
|
+
* (`testnet` 46630 by default, or `mainnet` 4663).
|
|
1266
1321
|
*/
|
|
1267
1322
|
declare function createAureonClient(options?: AureonClientOptions): AureonClient;
|
|
1268
1323
|
/**
|
|
1269
|
-
*
|
|
1270
|
-
*
|
|
1324
|
+
* Operator helper for a local API process. Integrators should use
|
|
1325
|
+
* createAureonClient() against the official API instead.
|
|
1271
1326
|
*/
|
|
1272
1327
|
declare function createLocalAureonClient(overrides?: Partial<AureonClientOptions>): AureonClient;
|
|
1273
1328
|
|
|
@@ -1373,17 +1428,19 @@ declare function withQuery(path: string, query: Record<string, string | undefine
|
|
|
1373
1428
|
/**
|
|
1374
1429
|
* @fileoverview Default runtime values for SDK clients and examples.
|
|
1375
1430
|
*/
|
|
1376
|
-
/**
|
|
1431
|
+
/** Official AUREON API (https://api.aureonlabs.network). */
|
|
1377
1432
|
declare const DEFAULT_API_BASE_URL = "https://api.aureonlabs.network";
|
|
1378
|
-
/**
|
|
1379
|
-
declare const LOCAL_API_BASE_URL = "http://127.0.0.1:
|
|
1433
|
+
/** Operator-only local process. Users should not set this. */
|
|
1434
|
+
declare const LOCAL_API_BASE_URL = "http://127.0.0.1:8788";
|
|
1380
1435
|
declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
1381
|
-
declare const SDK_VERSION = "0.1.
|
|
1436
|
+
declare const SDK_VERSION = "0.1.9";
|
|
1382
1437
|
declare const SDK_NAME = "@buildaureon/sdk";
|
|
1383
1438
|
declare const PRODUCT_NAME = "AUREON";
|
|
1384
1439
|
declare const PRODUCT_TAGLINE = "Financial Compass for Robinhood Chain";
|
|
1385
1440
|
/** HTTP header for product API keys. */
|
|
1386
1441
|
declare const API_KEY_HEADER = "X-Aureon-Api-Key";
|
|
1442
|
+
/** Per-request chain selector. Omit or `testnet` → 46630. `mainnet` → 4663. */
|
|
1443
|
+
declare const NETWORK_HEADER = "X-Aureon-Network";
|
|
1387
1444
|
|
|
1388
1445
|
/**
|
|
1389
1446
|
* @fileoverview API path constants for AureonClient methods.
|
|
@@ -1422,4 +1479,4 @@ declare const ENDPOINTS: {
|
|
|
1422
1479
|
type FetchLike = typeof fetch;
|
|
1423
1480
|
declare function resolveFetch(custom?: FetchLike): FetchLike;
|
|
1424
1481
|
|
|
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 };
|
|
1482
|
+
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, NETWORK_HEADER, OBJECTIVE_KINDS, OBJECTIVE_PRIORITIES, OFFICIAL_API_BASE_URL, 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 };
|
package/dist/index.js
CHANGED
|
@@ -10,15 +10,100 @@ function userAgentHeader(version) {
|
|
|
10
10
|
return { "X-Aureon-SDK": `@buildaureon/sdk/${version}` };
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// src/constants/networks.ts
|
|
14
|
+
var MAINNET_CHAIN_ID = 4663;
|
|
15
|
+
var TESTNET_CHAIN_ID = 46630;
|
|
16
|
+
var OFFICIAL_API_BASE_URL = "https://api.aureonlabs.network";
|
|
17
|
+
var TESTNET_API_BASE_URL = OFFICIAL_API_BASE_URL;
|
|
18
|
+
var MAINNET_API_BASE_URL = OFFICIAL_API_BASE_URL;
|
|
19
|
+
var MAINNET_EXPLORER = "https://robinhoodchain.blockscout.com";
|
|
20
|
+
var TESTNET_EXPLORER = "https://explorer.testnet.chain.robinhood.com";
|
|
21
|
+
var AUREON_NETWORKS = {
|
|
22
|
+
mainnet: {
|
|
23
|
+
network: "mainnet",
|
|
24
|
+
chainId: MAINNET_CHAIN_ID,
|
|
25
|
+
baseUrl: OFFICIAL_API_BASE_URL,
|
|
26
|
+
explorer: MAINNET_EXPLORER
|
|
27
|
+
},
|
|
28
|
+
testnet: {
|
|
29
|
+
network: "testnet",
|
|
30
|
+
chainId: TESTNET_CHAIN_ID,
|
|
31
|
+
baseUrl: OFFICIAL_API_BASE_URL,
|
|
32
|
+
explorer: TESTNET_EXPLORER
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function parseNetwork(raw) {
|
|
36
|
+
const n = raw.trim().toLowerCase();
|
|
37
|
+
if (n === "mainnet" || n === "testnet") return n;
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Unknown AUREON network "${raw}". Use "mainnet" or "testnet".`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
function stripSlash(url) {
|
|
43
|
+
return url.replace(/\/+$/, "");
|
|
44
|
+
}
|
|
45
|
+
function isOfficialApi(url) {
|
|
46
|
+
return stripSlash(url).toLowerCase().includes("api.aureonlabs.network");
|
|
47
|
+
}
|
|
48
|
+
function inferAureonNetworkFromUrl(url) {
|
|
49
|
+
if (isOfficialApi(url)) return null;
|
|
50
|
+
const u = stripSlash(url).toLowerCase();
|
|
51
|
+
if (/:(8787)(\/|$)/.test(u) || u.endsWith(":8787")) return "testnet";
|
|
52
|
+
if (/:(8788)(\/|$)/.test(u) || u.endsWith(":8788")) return "mainnet";
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
function mismatchMessage(network, baseUrl) {
|
|
56
|
+
return `baseUrl "${baseUrl}" does not match network "${network}". The official API is ${OFFICIAL_API_BASE_URL}. Use the network parameter for chain selection, not a port.`;
|
|
57
|
+
}
|
|
58
|
+
function resolveAureonNetwork(input = {}) {
|
|
59
|
+
const networkRaw = input.network?.trim();
|
|
60
|
+
const networkSpecified = Boolean(networkRaw);
|
|
61
|
+
const network = networkSpecified ? parseNetwork(networkRaw) : "testnet";
|
|
62
|
+
const explicitUrl = input.baseUrl?.trim();
|
|
63
|
+
if (!explicitUrl) {
|
|
64
|
+
return { ...AUREON_NETWORKS[network] };
|
|
65
|
+
}
|
|
66
|
+
const baseUrl = stripSlash(explicitUrl);
|
|
67
|
+
if (isOfficialApi(baseUrl)) {
|
|
68
|
+
const resolvedNetwork2 = networkSpecified ? network : "testnet";
|
|
69
|
+
const preset2 = AUREON_NETWORKS[resolvedNetwork2];
|
|
70
|
+
return {
|
|
71
|
+
network: resolvedNetwork2,
|
|
72
|
+
chainId: preset2.chainId,
|
|
73
|
+
baseUrl: OFFICIAL_API_BASE_URL,
|
|
74
|
+
explorer: preset2.explorer
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const inferred = inferAureonNetworkFromUrl(baseUrl);
|
|
78
|
+
if (networkSpecified && inferred && inferred !== network) {
|
|
79
|
+
throw new Error(mismatchMessage(network, baseUrl));
|
|
80
|
+
}
|
|
81
|
+
const resolvedNetwork = networkSpecified ? network : inferred ?? "testnet";
|
|
82
|
+
const preset = AUREON_NETWORKS[resolvedNetwork];
|
|
83
|
+
return {
|
|
84
|
+
network: resolvedNetwork,
|
|
85
|
+
chainId: preset.chainId,
|
|
86
|
+
baseUrl,
|
|
87
|
+
explorer: preset.explorer
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function resolveAureonNetworkFromEnv(env = process.env) {
|
|
91
|
+
return resolveAureonNetwork({
|
|
92
|
+
network: env.AUREON_NETWORK,
|
|
93
|
+
baseUrl: env.AUREON_API_URL
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
13
97
|
// src/constants/defaults.ts
|
|
14
|
-
var DEFAULT_API_BASE_URL =
|
|
15
|
-
var LOCAL_API_BASE_URL = "http://127.0.0.1:
|
|
98
|
+
var DEFAULT_API_BASE_URL = OFFICIAL_API_BASE_URL;
|
|
99
|
+
var LOCAL_API_BASE_URL = "http://127.0.0.1:8788";
|
|
16
100
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
17
|
-
var SDK_VERSION = "0.1.
|
|
101
|
+
var SDK_VERSION = "0.1.9";
|
|
18
102
|
var SDK_NAME = "@buildaureon/sdk";
|
|
19
103
|
var PRODUCT_NAME = "AUREON";
|
|
20
104
|
var PRODUCT_TAGLINE = "Financial Compass for Robinhood Chain";
|
|
21
105
|
var API_KEY_HEADER = "X-Aureon-Api-Key";
|
|
106
|
+
var NETWORK_HEADER = "X-Aureon-Network";
|
|
22
107
|
|
|
23
108
|
// src/constants/endpoints.ts
|
|
24
109
|
var ENDPOINTS = {
|
|
@@ -1539,8 +1624,16 @@ var DEMO_DRIFT_RESTORE_POSITIONS = [
|
|
|
1539
1624
|
];
|
|
1540
1625
|
var AureonClient = class {
|
|
1541
1626
|
transport;
|
|
1627
|
+
resolvedNetwork;
|
|
1628
|
+
resolvedChainId;
|
|
1542
1629
|
constructor(options = {}) {
|
|
1543
|
-
const
|
|
1630
|
+
const resolved = resolveAureonNetwork({
|
|
1631
|
+
network: options.network,
|
|
1632
|
+
baseUrl: options.baseUrl
|
|
1633
|
+
});
|
|
1634
|
+
this.resolvedNetwork = resolved.network;
|
|
1635
|
+
this.resolvedChainId = resolved.chainId;
|
|
1636
|
+
const baseUrl = resolved.baseUrl;
|
|
1544
1637
|
const staticToken = options.authToken;
|
|
1545
1638
|
const getAccessToken = options.getAccessToken ?? (staticToken ? () => staticToken : void 0);
|
|
1546
1639
|
const staticApiKey = options.apiKey;
|
|
@@ -1550,7 +1643,8 @@ var AureonClient = class {
|
|
|
1550
1643
|
fetchImpl: resolveFetch(options.fetch),
|
|
1551
1644
|
headers: {
|
|
1552
1645
|
...userAgentHeader(SDK_VERSION),
|
|
1553
|
-
...resolveHeaders({ ...options})
|
|
1646
|
+
...resolveHeaders({ ...options}),
|
|
1647
|
+
[NETWORK_HEADER]: resolved.network
|
|
1554
1648
|
},
|
|
1555
1649
|
timeoutMs: resolveTimeoutMs(options),
|
|
1556
1650
|
maxRetries: resolveMaxRetries(options),
|
|
@@ -1564,6 +1658,14 @@ var AureonClient = class {
|
|
|
1564
1658
|
get baseUrl() {
|
|
1565
1659
|
return this.transport.baseUrl;
|
|
1566
1660
|
}
|
|
1661
|
+
/** `mainnet` (4663) or `testnet` (46630). */
|
|
1662
|
+
get network() {
|
|
1663
|
+
return this.resolvedNetwork;
|
|
1664
|
+
}
|
|
1665
|
+
/** Chain id bundled with `network`. */
|
|
1666
|
+
get chainId() {
|
|
1667
|
+
return this.resolvedChainId;
|
|
1668
|
+
}
|
|
1567
1669
|
/** Health probe for connectivity checks. No auth required. */
|
|
1568
1670
|
async ping() {
|
|
1569
1671
|
return requestJson(this.transport, ENDPOINTS.healthz);
|
|
@@ -2442,10 +2544,7 @@ var AureonClient = class {
|
|
|
2442
2544
|
|
|
2443
2545
|
// src/client/factory.ts
|
|
2444
2546
|
function createAureonClient(options = {}) {
|
|
2445
|
-
return new AureonClient(
|
|
2446
|
-
baseUrl: options.baseUrl ?? DEFAULT_API_BASE_URL,
|
|
2447
|
-
...options
|
|
2448
|
-
});
|
|
2547
|
+
return new AureonClient(options);
|
|
2449
2548
|
}
|
|
2450
2549
|
function createLocalAureonClient(overrides = {}) {
|
|
2451
2550
|
return new AureonClient({
|
|
@@ -2595,6 +2694,6 @@ function createConsoleLogger(prefix = "aureon-sdk") {
|
|
|
2595
2694
|
};
|
|
2596
2695
|
}
|
|
2597
2696
|
|
|
2598
|
-
export { API_KEY_HEADER, AureonClient, AureonConflictError, AureonError, AureonNetworkError, AureonNotFoundError, AureonTimeoutError, AureonValidationError, DEFAULT_API_BASE_URL, DEFAULT_FULL_LOOP_BRIEF, DEFAULT_PORTFOLIO_WATCH_BRIEF, DEFAULT_TIMEOUT_MS, ENDPOINTS, LOCAL_API_BASE_URL, OBJECTIVE_KINDS, OBJECTIVE_PRIORITIES, PRODUCT_NAME, PRODUCT_TAGLINE, SDK_NAME, SDK_VERSION, TIMELINE_EVENT_TYPES, 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 };
|
|
2697
|
+
export { API_KEY_HEADER, AUREON_NETWORKS, AureonClient, AureonConflictError, AureonError, AureonNetworkError, AureonNotFoundError, AureonTimeoutError, AureonValidationError, DEFAULT_API_BASE_URL, DEFAULT_FULL_LOOP_BRIEF, DEFAULT_PORTFOLIO_WATCH_BRIEF, DEFAULT_TIMEOUT_MS, ENDPOINTS, LOCAL_API_BASE_URL, MAINNET_API_BASE_URL, MAINNET_CHAIN_ID, NETWORK_HEADER, OBJECTIVE_KINDS, OBJECTIVE_PRIORITIES, OFFICIAL_API_BASE_URL, PRODUCT_NAME, PRODUCT_TAGLINE, SDK_NAME, SDK_VERSION, TESTNET_API_BASE_URL, TESTNET_CHAIN_ID, TIMELINE_EVENT_TYPES, 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 };
|
|
2599
2698
|
//# sourceMappingURL=index.js.map
|
|
2600
2699
|
//# sourceMappingURL=index.js.map
|