@buildaureon/sdk 0.1.7 → 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/README.md +6 -3
- package/config/network.json +17 -7
- package/dist/index.d.ts +64 -12
- package/dist/index.js +98 -9
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +10 -8
- package/docs/auth.md +5 -3
- package/docs/client-api.md +9 -3
- package/docs/error-model.md +2 -2
- package/docs/integration-guide.md +28 -25
- package/docs/receipt-validation.md +4 -1
- package/docs/security.md +1 -1
- package/docs/transport.md +2 -1
- 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 +13 -8
- package/examples/e2e-policy-rebalance/underrun.ts +13 -8
- package/examples/e2e-policy-rebalance/verify-sizing.ts +13 -8
- package/examples/e2e-vault-flow/main.ts +13 -8
- 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 +8 -5
- package/examples/receipt-verification/main.ts +6 -3
- package/examples/sdk-demo-terminal/main.ts +6 -4
- package/package.json +25 -23
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Financial Compass, capital health, and verified restore plans: one typed integra
|
|
|
11
11
|
|
|
12
12
|
[](https://www.typescriptlang.org/)
|
|
13
13
|
[](#requirements)
|
|
14
|
-
[](https://github.com/buildaureon)
|
|
15
15
|
[](LICENSE)
|
|
16
16
|
[](#requirements)
|
|
17
17
|
|
|
@@ -333,9 +333,11 @@ import { createAureonClient } from "@buildaureon/sdk";
|
|
|
333
333
|
|
|
334
334
|
async function run() {
|
|
335
335
|
const aureon = createAureonClient({
|
|
336
|
-
baseUrl: "https://api.aureonlabs.network",
|
|
337
336
|
apiKey: process.env.AUREON_API_KEY!, // issued key from Developers console
|
|
338
337
|
});
|
|
338
|
+
// Default network is mainnet (4663 / http://127.0.0.1:8788).
|
|
339
|
+
// Opt in to testnet: createAureonClient({ network: "testnet", apiKey })
|
|
340
|
+
// Public api.aureonlabs.network is still chain 46630.
|
|
339
341
|
|
|
340
342
|
const me = await aureon.me();
|
|
341
343
|
console.log("wallet", me.walletAddress);
|
|
@@ -525,7 +527,8 @@ await aureon.revokeApiKey(newKey.id);
|
|
|
525
527
|
|
|
526
528
|
| Parameter | Type | Default | Description |
|
|
527
529
|
| --- | --- | --- | --- |
|
|
528
|
-
| `
|
|
530
|
+
| `network` | `"mainnet" \| "testnet"` | `"mainnet"` | Bundles chain + API. Mainnet is 4663 / local 8788. Testnet is optional (public host, still 46630). |
|
|
531
|
+
| `baseUrl` | `string` | mainnet `http://127.0.0.1:8788` | Explicit URL still wins. Must not disagree with `network`. |
|
|
529
532
|
| `apiKey` | `string` | `undefined` | Sent as `X-Aureon-Api-Key` |
|
|
530
533
|
| `authToken` | `string` | `undefined` | Static JWT bearer |
|
|
531
534
|
| `getAccessToken` | `() => string \| null` | `undefined` | Dynamic bearer resolver |
|
package/config/network.json
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"defaultNetwork": "mainnet",
|
|
3
|
+
"note": "Omitted network is local mainnet 4663 / 8788. Public api.aureonlabs.network is still testnet 46630.",
|
|
4
|
+
"mainnet": {
|
|
5
|
+
"baseUrl": "http://127.0.0.1:8788",
|
|
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
|
+
"localBaseUrl": "http://127.0.0.1:8787",
|
|
14
|
+
"appUrl": "https://app.aureonlabs.network",
|
|
15
|
+
"chainId": 46630,
|
|
16
|
+
"chain": "Robinhood Chain Testnet"
|
|
17
|
+
},
|
|
8
18
|
"sdkPackage": "@buildaureon/sdk",
|
|
9
|
-
"sdkVersion": "0.1.
|
|
19
|
+
"sdkVersion": "0.1.8"
|
|
10
20
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
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;
|
|
40
|
+
|
|
1
41
|
/**
|
|
2
42
|
* @fileoverview Timeline event contracts for append-only operator narratives.
|
|
3
43
|
*/
|
|
@@ -778,8 +818,14 @@ declare function createConsoleLogger(prefix?: string): AureonLogger;
|
|
|
778
818
|
|
|
779
819
|
interface AureonClientOptions {
|
|
780
820
|
/**
|
|
781
|
-
*
|
|
782
|
-
*
|
|
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).
|
|
783
829
|
*/
|
|
784
830
|
baseUrl?: string;
|
|
785
831
|
/**
|
|
@@ -826,9 +872,9 @@ interface AureonClientOptions {
|
|
|
826
872
|
* @fileoverview Vault overview + prepare-tx contracts for AureonVault.
|
|
827
873
|
*
|
|
828
874
|
* Reads come from GET /vault and GET /vault/status.
|
|
829
|
-
* Writes are wallet-signed: prepareDeposit / prepareWithdraw return
|
|
830
|
-
* steps
|
|
831
|
-
* 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.
|
|
832
878
|
*/
|
|
833
879
|
/** Allowlisted vault token metadata from GET /vault. */
|
|
834
880
|
interface VaultToken {
|
|
@@ -988,9 +1034,15 @@ interface CreatedDeveloperApiKey extends DeveloperApiKey {
|
|
|
988
1034
|
*/
|
|
989
1035
|
declare class AureonClient {
|
|
990
1036
|
private readonly transport;
|
|
1037
|
+
private readonly resolvedNetwork;
|
|
1038
|
+
private readonly resolvedChainId;
|
|
991
1039
|
constructor(options?: AureonClientOptions);
|
|
992
1040
|
/** Returns the resolved API base URL. */
|
|
993
1041
|
get baseUrl(): string;
|
|
1042
|
+
/** `mainnet` (4663) or `testnet` (46630). */
|
|
1043
|
+
get network(): AureonNetwork;
|
|
1044
|
+
/** Chain id bundled with `network`. */
|
|
1045
|
+
get chainId(): number;
|
|
994
1046
|
/** Health probe for connectivity checks. No auth required. */
|
|
995
1047
|
ping(): Promise<{
|
|
996
1048
|
ok: true;
|
|
@@ -1262,12 +1314,12 @@ declare class AureonClient {
|
|
|
1262
1314
|
|
|
1263
1315
|
/**
|
|
1264
1316
|
* Factory helper preferred by examples and quickstarts.
|
|
1265
|
-
*
|
|
1317
|
+
* Omit `network` and `baseUrl` for local mainnet (4663 / 8788).
|
|
1318
|
+
* Pass `network: "testnet"` for the public host (still 46630).
|
|
1266
1319
|
*/
|
|
1267
1320
|
declare function createAureonClient(options?: AureonClientOptions): AureonClient;
|
|
1268
1321
|
/**
|
|
1269
|
-
* Creates a client pointed at
|
|
1270
|
-
* Not advertised in the public README.
|
|
1322
|
+
* Creates a client pointed at the local mainnet API (8788 / 4663).
|
|
1271
1323
|
*/
|
|
1272
1324
|
declare function createLocalAureonClient(overrides?: Partial<AureonClientOptions>): AureonClient;
|
|
1273
1325
|
|
|
@@ -1373,10 +1425,10 @@ declare function withQuery(path: string, query: Record<string, string | undefine
|
|
|
1373
1425
|
/**
|
|
1374
1426
|
* @fileoverview Default runtime values for SDK clients and examples.
|
|
1375
1427
|
*/
|
|
1376
|
-
/**
|
|
1428
|
+
/** Testnet public host (chain 46630). Not the omitted-options client default. */
|
|
1377
1429
|
declare const DEFAULT_API_BASE_URL = "https://api.aureonlabs.network";
|
|
1378
|
-
/** Local
|
|
1379
|
-
declare const LOCAL_API_BASE_URL = "http://127.0.0.1:
|
|
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";
|
|
1380
1432
|
declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
1381
1433
|
declare const SDK_VERSION = "0.1.7";
|
|
1382
1434
|
declare const SDK_NAME = "@buildaureon/sdk";
|
|
@@ -1422,4 +1474,4 @@ declare const ENDPOINTS: {
|
|
|
1422
1474
|
type FetchLike = typeof fetch;
|
|
1423
1475
|
declare function resolveFetch(custom?: FetchLike): FetchLike;
|
|
1424
1476
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,79 @@ 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 MAINNET_API_BASE_URL = "http://127.0.0.1:8788";
|
|
17
|
+
var TESTNET_API_BASE_URL = "https://api.aureonlabs.network";
|
|
18
|
+
var MAINNET_EXPLORER = "https://robinhoodchain.blockscout.com";
|
|
19
|
+
var TESTNET_EXPLORER = "https://explorer.testnet.chain.robinhood.com";
|
|
20
|
+
var AUREON_NETWORKS = {
|
|
21
|
+
mainnet: {
|
|
22
|
+
network: "mainnet",
|
|
23
|
+
chainId: MAINNET_CHAIN_ID,
|
|
24
|
+
baseUrl: MAINNET_API_BASE_URL,
|
|
25
|
+
explorer: MAINNET_EXPLORER
|
|
26
|
+
},
|
|
27
|
+
testnet: {
|
|
28
|
+
network: "testnet",
|
|
29
|
+
chainId: TESTNET_CHAIN_ID,
|
|
30
|
+
baseUrl: TESTNET_API_BASE_URL,
|
|
31
|
+
explorer: TESTNET_EXPLORER
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function parseNetwork(raw) {
|
|
35
|
+
const n = raw.trim().toLowerCase();
|
|
36
|
+
if (n === "mainnet" || n === "testnet") return n;
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Unknown AUREON network "${raw}". Use "mainnet" or "testnet".`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function stripSlash(url) {
|
|
42
|
+
return url.replace(/\/+$/, "");
|
|
43
|
+
}
|
|
44
|
+
function inferAureonNetworkFromUrl(url) {
|
|
45
|
+
const u = stripSlash(url).toLowerCase();
|
|
46
|
+
if (u.includes("api.aureonlabs.network")) return "testnet";
|
|
47
|
+
if (/:(8787)(\/|$)/.test(u) || u.endsWith(":8787")) return "testnet";
|
|
48
|
+
if (/:(8788)(\/|$)/.test(u) || u.endsWith(":8788")) return "mainnet";
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
function mismatchMessage(network, baseUrl) {
|
|
52
|
+
return `baseUrl "${baseUrl}" does not match network "${network}". mainnet is ${MAINNET_API_BASE_URL} (4663). testnet is ${TESTNET_API_BASE_URL} (46630; public host is still testnet).`;
|
|
53
|
+
}
|
|
54
|
+
function resolveAureonNetwork(input = {}) {
|
|
55
|
+
const networkRaw = input.network?.trim();
|
|
56
|
+
const networkSpecified = Boolean(networkRaw);
|
|
57
|
+
const network = networkSpecified ? parseNetwork(networkRaw) : "mainnet";
|
|
58
|
+
const explicitUrl = input.baseUrl?.trim();
|
|
59
|
+
if (!explicitUrl) {
|
|
60
|
+
return { ...AUREON_NETWORKS[network] };
|
|
61
|
+
}
|
|
62
|
+
const baseUrl = stripSlash(explicitUrl);
|
|
63
|
+
const inferred = inferAureonNetworkFromUrl(baseUrl);
|
|
64
|
+
if (networkSpecified && inferred && inferred !== network) {
|
|
65
|
+
throw new Error(mismatchMessage(network, baseUrl));
|
|
66
|
+
}
|
|
67
|
+
const resolvedNetwork = networkSpecified ? network : inferred ?? "mainnet";
|
|
68
|
+
const preset = AUREON_NETWORKS[resolvedNetwork];
|
|
69
|
+
return {
|
|
70
|
+
network: resolvedNetwork,
|
|
71
|
+
chainId: preset.chainId,
|
|
72
|
+
baseUrl,
|
|
73
|
+
explorer: preset.explorer
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function resolveAureonNetworkFromEnv(env = process.env) {
|
|
77
|
+
return resolveAureonNetwork({
|
|
78
|
+
network: env.AUREON_NETWORK,
|
|
79
|
+
baseUrl: env.AUREON_API_URL
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
13
83
|
// src/constants/defaults.ts
|
|
14
|
-
var DEFAULT_API_BASE_URL =
|
|
15
|
-
var LOCAL_API_BASE_URL =
|
|
84
|
+
var DEFAULT_API_BASE_URL = TESTNET_API_BASE_URL;
|
|
85
|
+
var LOCAL_API_BASE_URL = MAINNET_API_BASE_URL;
|
|
16
86
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
17
87
|
var SDK_VERSION = "0.1.7";
|
|
18
88
|
var SDK_NAME = "@buildaureon/sdk";
|
|
@@ -1539,8 +1609,16 @@ var DEMO_DRIFT_RESTORE_POSITIONS = [
|
|
|
1539
1609
|
];
|
|
1540
1610
|
var AureonClient = class {
|
|
1541
1611
|
transport;
|
|
1612
|
+
resolvedNetwork;
|
|
1613
|
+
resolvedChainId;
|
|
1542
1614
|
constructor(options = {}) {
|
|
1543
|
-
const
|
|
1615
|
+
const resolved = resolveAureonNetwork({
|
|
1616
|
+
network: options.network,
|
|
1617
|
+
baseUrl: options.baseUrl
|
|
1618
|
+
});
|
|
1619
|
+
this.resolvedNetwork = resolved.network;
|
|
1620
|
+
this.resolvedChainId = resolved.chainId;
|
|
1621
|
+
const baseUrl = resolved.baseUrl;
|
|
1544
1622
|
const staticToken = options.authToken;
|
|
1545
1623
|
const getAccessToken = options.getAccessToken ?? (staticToken ? () => staticToken : void 0);
|
|
1546
1624
|
const staticApiKey = options.apiKey;
|
|
@@ -1564,6 +1642,14 @@ var AureonClient = class {
|
|
|
1564
1642
|
get baseUrl() {
|
|
1565
1643
|
return this.transport.baseUrl;
|
|
1566
1644
|
}
|
|
1645
|
+
/** `mainnet` (4663) or `testnet` (46630). */
|
|
1646
|
+
get network() {
|
|
1647
|
+
return this.resolvedNetwork;
|
|
1648
|
+
}
|
|
1649
|
+
/** Chain id bundled with `network`. */
|
|
1650
|
+
get chainId() {
|
|
1651
|
+
return this.resolvedChainId;
|
|
1652
|
+
}
|
|
1567
1653
|
/** Health probe for connectivity checks. No auth required. */
|
|
1568
1654
|
async ping() {
|
|
1569
1655
|
return requestJson(this.transport, ENDPOINTS.healthz);
|
|
@@ -2442,15 +2528,18 @@ var AureonClient = class {
|
|
|
2442
2528
|
|
|
2443
2529
|
// src/client/factory.ts
|
|
2444
2530
|
function createAureonClient(options = {}) {
|
|
2445
|
-
return new AureonClient(
|
|
2446
|
-
baseUrl: options.baseUrl ?? DEFAULT_API_BASE_URL,
|
|
2447
|
-
...options
|
|
2448
|
-
});
|
|
2531
|
+
return new AureonClient(options);
|
|
2449
2532
|
}
|
|
2450
2533
|
function createLocalAureonClient(overrides = {}) {
|
|
2534
|
+
if (overrides.network && overrides.network !== "mainnet") {
|
|
2535
|
+
throw new Error(
|
|
2536
|
+
'createLocalAureonClient is mainnet-only (8788 / 4663). Use createAureonClient({ network: "testnet" }) for the public host.'
|
|
2537
|
+
);
|
|
2538
|
+
}
|
|
2451
2539
|
return new AureonClient({
|
|
2452
2540
|
...overrides,
|
|
2453
|
-
|
|
2541
|
+
network: "mainnet",
|
|
2542
|
+
baseUrl: overrides.baseUrl ?? MAINNET_API_BASE_URL
|
|
2454
2543
|
});
|
|
2455
2544
|
}
|
|
2456
2545
|
|
|
@@ -2595,6 +2684,6 @@ function createConsoleLogger(prefix = "aureon-sdk") {
|
|
|
2595
2684
|
};
|
|
2596
2685
|
}
|
|
2597
2686
|
|
|
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 };
|
|
2687
|
+
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, OBJECTIVE_KINDS, OBJECTIVE_PRIORITIES, 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
2688
|
//# sourceMappingURL=index.js.map
|
|
2600
2689
|
//# sourceMappingURL=index.js.map
|