@buildaureon/sdk 0.1.2 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +21 -3
- package/config/network.json +20 -10
- package/dist/index.d.ts +706 -100
- package/dist/index.js +1813 -205
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +11 -9
- package/docs/auth.md +5 -3
- package/docs/client-api.md +187 -4
- package/docs/data-contracts.md +81 -6
- package/docs/error-model.md +2 -2
- package/docs/integration-guide.md +169 -26
- package/docs/receipt-validation.md +66 -0
- package/docs/security.md +1 -1
- package/docs/transport.md +2 -1
- package/examples/ai-to-objective-to-portfolio/main.ts +130 -0
- package/examples/audit-trail/main.ts +55 -0
- package/examples/drift-detect-restore/main.ts +99 -0
- 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 +86 -0
- package/examples/green-vs-plan/main.ts +142 -0
- package/examples/market-event/main.ts +8 -3
- package/examples/portfolio-watch/main.ts +87 -0
- package/examples/quickstart/main.ts +8 -5
- package/examples/receipt-verification/main.ts +90 -0
- package/examples/sdk-demo-terminal/main.ts +6 -4
- package/fixtures/reference-objectives.json +18 -18
- package/fixtures/reference-portfolio.json +10 -10
- package/package.json +70 -61
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Receipt validation
|
|
2
|
+
|
|
3
|
+
Phase 2 receipts must follow honest settlement rules. Use the SDK validator after every restore or when ingesting receipts from logs.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Quick example
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import {
|
|
11
|
+
createAureonClient,
|
|
12
|
+
resolveAureonNetworkFromEnv,
|
|
13
|
+
validateExecutionReceipt,
|
|
14
|
+
assertValidExecutionReceipt,
|
|
15
|
+
} from "@buildaureon/sdk";
|
|
16
|
+
|
|
17
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
18
|
+
const client = createAureonClient({
|
|
19
|
+
network: resolved.network,
|
|
20
|
+
baseUrl: resolved.baseUrl,
|
|
21
|
+
apiKey: process.env.AUREON_API_KEY!,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const receipt = await client.restoreObjective("obj_abc123");
|
|
25
|
+
|
|
26
|
+
const check = validateExecutionReceipt(receipt);
|
|
27
|
+
if (!check.valid) {
|
|
28
|
+
for (const issue of check.issues) {
|
|
29
|
+
console.error(issue.code, issue.path, issue.message);
|
|
30
|
+
}
|
|
31
|
+
throw new Error("Receipt failed validation");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Or throw in one step:
|
|
35
|
+
assertValidExecutionReceipt(receipt);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
List recent receipts and validate each:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
for (const receipt of await client.listExecutions()) {
|
|
42
|
+
assertValidExecutionReceipt(receipt);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## What gets checked
|
|
49
|
+
|
|
50
|
+
| Rule | Fail code (examples) |
|
|
51
|
+
|------|----------------------|
|
|
52
|
+
| Required fields present | `MISSING_FIELD` |
|
|
53
|
+
| `settlement` is `vault` or `staged` | `INVALID_SETTLEMENT` |
|
|
54
|
+
| Staged: no explorer, not verified | `STAGED_WITH_EXPLORER`, `STAGED_VERIFIED_ON_CHAIN` |
|
|
55
|
+
| Vault with real `0x` tx: explorer required | `VAULT_MISSING_EXPLORER` |
|
|
56
|
+
| `verifiedOnChain: true` needs matching record | `VERIFIED_WITHOUT_RECORD` |
|
|
57
|
+
| Registry ref hex shape | `INVALID_REGISTRY_REF` |
|
|
58
|
+
|
|
59
|
+
The validator does **not** re-query the chain — it checks shape and honesty only.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Related
|
|
64
|
+
|
|
65
|
+
- [Data contracts](./data-contracts.md) — receipt and settlement fields
|
|
66
|
+
- [Integration guide](./integration-guide.md) — agent restore loop
|
package/docs/security.md
CHANGED
|
@@ -82,7 +82,7 @@ Never collapse staged into “confirmed on Robinhood Chain.”
|
|
|
82
82
|
|
|
83
83
|
## 5. Transport and logging hygiene
|
|
84
84
|
|
|
85
|
-
-
|
|
85
|
+
- Default omitted client is local mainnet `http://127.0.0.1:8788` (4663). Use `network: "testnet"` for the public host (still 46630). Do not call that host production.
|
|
86
86
|
- Do not log raw `Authorization` or `X-Aureon-Api-Key`.
|
|
87
87
|
- Redact prepare step calldata in public logs if it includes sensitive amounts in your threat model.
|
|
88
88
|
- Set `timeoutMs` / `maxRetries` deliberately for agent loops (see [transport.md](./transport.md)).
|
package/docs/transport.md
CHANGED
|
@@ -48,7 +48,8 @@ Issued developer keys in `X-Aureon-Api-Key` are enough for control-plane identit
|
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
50
|
createAureonClient({
|
|
51
|
-
|
|
51
|
+
// omit network → local mainnet 8788 / 4663
|
|
52
|
+
// network: "testnet" → public host (still 46630)
|
|
52
53
|
apiKey: process.env.AUREON_API_KEY!,
|
|
53
54
|
timeoutMs: 30_000, // per attempt
|
|
54
55
|
maxRetries: 2, // extra attempts after first failure
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Update 3 demo — AI → objective → portfolio.
|
|
3
|
+
*
|
|
4
|
+
* Env:
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_NETWORK optional; omit for mainnet (4663 / 8788); set testnet for public host (still 46630)
|
|
7
|
+
* AUREON_API_URL optional override (must match network if both set)
|
|
8
|
+
*
|
|
9
|
+
* pnpm example:ai-to-objective-to-portfolio
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createAureonClient,
|
|
14
|
+
resolveAureonNetworkFromEnv,
|
|
15
|
+
formatWeight,
|
|
16
|
+
isAureonError,
|
|
17
|
+
parseFinancialIntent,
|
|
18
|
+
type PortfolioPositionInput,
|
|
19
|
+
} from "../../src/index.js";
|
|
20
|
+
|
|
21
|
+
const DEMO_POSITIONS: PortfolioPositionInput[] = [
|
|
22
|
+
{
|
|
23
|
+
symbol: "USDG",
|
|
24
|
+
name: "Paxos USDG",
|
|
25
|
+
category: "stable",
|
|
26
|
+
quantity: 24_000,
|
|
27
|
+
markPriceUsd: 1,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
symbol: "NVDA",
|
|
31
|
+
name: "NVIDIA Stock Token",
|
|
32
|
+
category: "stock_token",
|
|
33
|
+
quantity: 45,
|
|
34
|
+
markPriceUsd: 920,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
symbol: "AAPL",
|
|
38
|
+
name: "Apple Stock Token",
|
|
39
|
+
category: "stock_token",
|
|
40
|
+
quantity: 80,
|
|
41
|
+
markPriceUsd: 210,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
symbol: "ETH",
|
|
45
|
+
name: "Ether",
|
|
46
|
+
category: "gas",
|
|
47
|
+
quantity: 8.5,
|
|
48
|
+
markPriceUsd: 3400,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
async function main(): Promise<void> {
|
|
53
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
54
|
+
if (!apiKey) {
|
|
55
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
59
|
+
const aureon = createAureonClient({
|
|
60
|
+
network: resolved.network,
|
|
61
|
+
baseUrl: resolved.baseUrl,
|
|
62
|
+
apiKey,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const userBrief =
|
|
66
|
+
"I want to keep about 20% of my portfolio in stable assets.";
|
|
67
|
+
|
|
68
|
+
console.log("\n=== AUREON Update 3 — AI → objective → portfolio ===\n");
|
|
69
|
+
console.log("USER (simulated agent input):");
|
|
70
|
+
console.log(` "${userBrief}"\n`);
|
|
71
|
+
|
|
72
|
+
console.log("AI — structured intent:");
|
|
73
|
+
const intent = parseFinancialIntent(userBrief);
|
|
74
|
+
console.log(
|
|
75
|
+
JSON.stringify(
|
|
76
|
+
{
|
|
77
|
+
kind: intent.kind,
|
|
78
|
+
targetWeight: intent.targetWeight,
|
|
79
|
+
tolerance: intent.tolerance,
|
|
80
|
+
},
|
|
81
|
+
null,
|
|
82
|
+
2
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
console.log("\n1. Seed capital book…");
|
|
87
|
+
await aureon.setPortfolio(DEMO_POSITIONS);
|
|
88
|
+
|
|
89
|
+
console.log("2. Apply financial intent → create objective…");
|
|
90
|
+
const flow = await aureon.applyFinancialIntent(intent);
|
|
91
|
+
|
|
92
|
+
console.log("\n--- Intent ---");
|
|
93
|
+
console.log(` Brief: ${flow.intent.brief}`);
|
|
94
|
+
console.log(` Policy: ${flow.intent.policySummary}`);
|
|
95
|
+
|
|
96
|
+
console.log("\n--- Objective ---");
|
|
97
|
+
console.log(` ID: ${flow.objective.id}`);
|
|
98
|
+
console.log(` Kind: ${flow.objective.kind}`);
|
|
99
|
+
console.log(` Mode: ${flow.objective.automationMode}`);
|
|
100
|
+
console.log(
|
|
101
|
+
` Target: ${formatWeight(flow.objective.policy.targetWeight)}`
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
console.log("\n--- Portfolio ---");
|
|
105
|
+
console.log(
|
|
106
|
+
` Book: $${flow.portfolio.totalNotionalUsd.toLocaleString()}`
|
|
107
|
+
);
|
|
108
|
+
console.log(
|
|
109
|
+
` Stables: ${formatWeight(flow.portfolio.stableWeight)}`
|
|
110
|
+
);
|
|
111
|
+
if (flow.health) {
|
|
112
|
+
console.log(
|
|
113
|
+
` Health: ${flow.health.state} — current ${formatWeight(flow.health.currentMetric)} vs target ${formatWeight(flow.health.targetMetric)}`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log(`\n${flow.message}`);
|
|
118
|
+
console.log(
|
|
119
|
+
"\nThe portfolio now has a reason — not just positions.\n"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
main().catch((error) => {
|
|
124
|
+
if (isAureonError(error)) {
|
|
125
|
+
console.error(`${error.code}: ${error.message}`);
|
|
126
|
+
} else {
|
|
127
|
+
console.error(error);
|
|
128
|
+
}
|
|
129
|
+
process.exitCode = 1;
|
|
130
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Phase 2 audit trail export — objective → proof.
|
|
3
|
+
*
|
|
4
|
+
* Env:
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_API_URL optional
|
|
7
|
+
* AUREON_OBJECTIVE_ID optional (defaults to first objective)
|
|
8
|
+
*
|
|
9
|
+
* pnpm example:audit-trail
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createAureonClient,
|
|
14
|
+
resolveAureonNetworkFromEnv,
|
|
15
|
+
formatAuditTrailLines,
|
|
16
|
+
isAureonError,
|
|
17
|
+
} from "../../src/index.js";
|
|
18
|
+
|
|
19
|
+
async function main(): Promise<void> {
|
|
20
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
21
|
+
if (!apiKey) {
|
|
22
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
26
|
+
const aureon = createAureonClient({
|
|
27
|
+
network: resolved.network,
|
|
28
|
+
baseUrl: resolved.baseUrl,
|
|
29
|
+
apiKey,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const requested = process.env.AUREON_OBJECTIVE_ID?.trim();
|
|
33
|
+
const objectiveId =
|
|
34
|
+
requested || (await aureon.listObjectives())[0]?.id;
|
|
35
|
+
if (!objectiveId) {
|
|
36
|
+
throw new Error("No objectives on this wallet. Create one first.");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const trail = await aureon.getAuditTrail(objectiveId);
|
|
40
|
+
|
|
41
|
+
console.log("\n=== AUREON Phase 2 — Financial audit trail ===\n");
|
|
42
|
+
for (const line of formatAuditTrailLines(trail)) {
|
|
43
|
+
console.log(line);
|
|
44
|
+
}
|
|
45
|
+
console.log("");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
main().catch((error) => {
|
|
49
|
+
if (isAureonError(error)) {
|
|
50
|
+
console.error(`${error.code}: ${error.message}`);
|
|
51
|
+
} else {
|
|
52
|
+
console.error(error);
|
|
53
|
+
}
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview demo — drift → detection → restore.
|
|
3
|
+
*
|
|
4
|
+
* Shows the full loop: rule set, controlled drift, restore plan, receipt, health.
|
|
5
|
+
*
|
|
6
|
+
* Env:
|
|
7
|
+
* AUREON_API_KEY issued developer key (required)
|
|
8
|
+
* AUREON_NETWORK optional; omit for mainnet (4663 / 8788); set testnet for public host (still 46630)
|
|
9
|
+
* AUREON_API_URL optional override (must match network if both set)
|
|
10
|
+
*
|
|
11
|
+
* pnpm example:drift-detect-restore
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
createAureonClient,
|
|
16
|
+
resolveAureonNetworkFromEnv,
|
|
17
|
+
formatWeight,
|
|
18
|
+
isAureonError,
|
|
19
|
+
type DriftRestoreFlow,
|
|
20
|
+
} from "../../src/index.js";
|
|
21
|
+
|
|
22
|
+
function printPhase(label: string, healthState: string, metric?: number, target?: number): void {
|
|
23
|
+
const metricStr =
|
|
24
|
+
metric !== undefined && target !== undefined
|
|
25
|
+
? ` — ${formatWeight(metric)} vs ${formatWeight(target)} target`
|
|
26
|
+
: "";
|
|
27
|
+
console.log(` ${label}: ${healthState}${metricStr}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function printFlow(flow: DriftRestoreFlow): void {
|
|
31
|
+
console.log(`\nRule: ${flow.rule.summary}\n`);
|
|
32
|
+
|
|
33
|
+
console.log("1. Rule — aligned on policy");
|
|
34
|
+
printPhase(
|
|
35
|
+
" Health",
|
|
36
|
+
flow.phases.aligned.health.state,
|
|
37
|
+
flow.phases.aligned.health.currentMetric,
|
|
38
|
+
flow.phases.aligned.health.targetMetric
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
console.log("\n2. Drift — NVDA rally broke the stable sleeve");
|
|
42
|
+
printPhase(
|
|
43
|
+
" Health",
|
|
44
|
+
flow.phases.drift.health.state,
|
|
45
|
+
flow.phases.drift.health.currentMetric,
|
|
46
|
+
flow.phases.drift.health.targetMetric
|
|
47
|
+
);
|
|
48
|
+
if (flow.phases.drift.restorePlan) {
|
|
49
|
+
console.log(` Restore plan: ${flow.phases.drift.restorePlan.message}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (flow.phases.restored) {
|
|
53
|
+
console.log("\n3. Restore — back within policy");
|
|
54
|
+
printPhase(
|
|
55
|
+
" Health",
|
|
56
|
+
flow.phases.restored.health.state,
|
|
57
|
+
flow.phases.restored.health.currentMetric,
|
|
58
|
+
flow.phases.restored.health.targetMetric
|
|
59
|
+
);
|
|
60
|
+
if (flow.phases.restored.receipt) {
|
|
61
|
+
console.log(
|
|
62
|
+
` Receipt: ${flow.phases.restored.receipt.action} — settlement ${flow.phases.restored.receipt.settlement}`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(`\n${flow.message}`);
|
|
68
|
+
console.log(
|
|
69
|
+
"\nWe broke the rule on purpose. AUREON detected it and restored the policy.\n"
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function main(): Promise<void> {
|
|
74
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
75
|
+
if (!apiKey) {
|
|
76
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
80
|
+
const aureon = createAureonClient({
|
|
81
|
+
network: resolved.network,
|
|
82
|
+
baseUrl: resolved.baseUrl,
|
|
83
|
+
apiKey,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
console.log("\n=== AUREON — Drift → detection → restore ===\n");
|
|
87
|
+
|
|
88
|
+
const flow = await aureon.runDriftRestoreDemo();
|
|
89
|
+
printFlow(flow);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main().catch((error) => {
|
|
93
|
+
if (isAureonError(error)) {
|
|
94
|
+
console.error(`${error.code}: ${error.message}`);
|
|
95
|
+
} else {
|
|
96
|
+
console.error(error);
|
|
97
|
+
}
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
});
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Env:
|
|
5
5
|
* AUREON_API_KEY issued developer key (required)
|
|
6
6
|
* AUREON_WALLET_PRIVATE_KEY 0x… signing key (required)
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* AUREON_NETWORK optional; omit for mainnet 8788 / 4663; testnet = public host (still 46630)
|
|
8
|
+
* AUREON_API_URL optional override
|
|
9
|
+
* AUREON_RPC_URL optional (defaults from resolved chain)
|
|
10
|
+
* AUREON_CHAIN_ID optional (defaults from resolved network)
|
|
10
11
|
*
|
|
11
12
|
* pnpm --filter @buildaureon/sdk example:e2e-policy
|
|
12
13
|
*/
|
|
@@ -25,7 +26,7 @@ import { privateKeyToAccount } from "viem/accounts";
|
|
|
25
26
|
import {
|
|
26
27
|
createAureonClient,
|
|
27
28
|
createSessionTokenProvider,
|
|
28
|
-
|
|
29
|
+
resolveAureonNetworkFromEnv,
|
|
29
30
|
isAureonError,
|
|
30
31
|
} from "../../src/index.js";
|
|
31
32
|
|
|
@@ -61,11 +62,14 @@ function log(step: string, data?: unknown) {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
async function main() {
|
|
64
|
-
const
|
|
65
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
66
|
+
const baseUrl = resolved.baseUrl;
|
|
67
|
+
const chainId = Number(process.env.AUREON_CHAIN_ID ?? resolved.chainId);
|
|
65
68
|
const rpcUrl =
|
|
66
69
|
process.env.AUREON_RPC_URL?.trim() ||
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
(chainId === 4663
|
|
71
|
+
? "https://rpc.mainnet.chain.robinhood.com"
|
|
72
|
+
: "https://rpc.testnet.chain.robinhood.com");
|
|
69
73
|
const apiKey = requireEnv("AUREON_API_KEY");
|
|
70
74
|
|
|
71
75
|
const account = privateKeyToAccount(loadKey());
|
|
@@ -73,7 +77,7 @@ async function main() {
|
|
|
73
77
|
const walletClient = createWalletClient({ account, transport: http(rpcUrl) });
|
|
74
78
|
const chain = {
|
|
75
79
|
id: chainId,
|
|
76
|
-
name: "Robinhood Chain Testnet",
|
|
80
|
+
name: chainId === 4663 ? "Robinhood Chain" : "Robinhood Chain Testnet",
|
|
77
81
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
78
82
|
rpcUrls: { default: { http: [rpcUrl] } },
|
|
79
83
|
} as const;
|
|
@@ -82,6 +86,7 @@ async function main() {
|
|
|
82
86
|
|
|
83
87
|
const session = createSessionTokenProvider(null);
|
|
84
88
|
const aureon = createAureonClient({
|
|
89
|
+
network: resolved.network,
|
|
85
90
|
baseUrl,
|
|
86
91
|
apiKey,
|
|
87
92
|
getAccessToken: session.getAccessToken,
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Env:
|
|
5
5
|
* AUREON_API_KEY issued developer key
|
|
6
6
|
* AUREON_WALLET_PRIVATE_KEY 0x… signing key
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* AUREON_NETWORK optional; omit for mainnet 8788 / 4663; testnet = public host (still 46630)
|
|
8
|
+
* AUREON_API_URL optional override
|
|
9
|
+
* AUREON_RPC_URL optional (defaults from resolved chain)
|
|
10
|
+
* AUREON_CHAIN_ID optional (defaults from resolved network)
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import {
|
|
@@ -20,7 +21,7 @@ import { privateKeyToAccount } from "viem/accounts";
|
|
|
20
21
|
import {
|
|
21
22
|
createAureonClient,
|
|
22
23
|
createSessionTokenProvider,
|
|
23
|
-
|
|
24
|
+
resolveAureonNetworkFromEnv,
|
|
24
25
|
isAureonError,
|
|
25
26
|
} from "../../src/index.js";
|
|
26
27
|
|
|
@@ -36,22 +37,26 @@ if (!/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
const account = privateKeyToAccount(key);
|
|
40
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
41
|
+
const chainId = Number(process.env.AUREON_CHAIN_ID || resolved.chainId);
|
|
39
42
|
const rpc =
|
|
40
43
|
process.env.AUREON_RPC_URL?.trim() ||
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
(chainId === 4663
|
|
45
|
+
? "https://rpc.mainnet.chain.robinhood.com"
|
|
46
|
+
: "https://rpc.testnet.chain.robinhood.com");
|
|
43
47
|
const publicClient = createPublicClient({ transport: http(rpc) });
|
|
44
48
|
const walletClient = createWalletClient({ account, transport: http(rpc) });
|
|
45
49
|
const chain = {
|
|
46
50
|
id: chainId,
|
|
47
|
-
name: "Robinhood Chain Testnet",
|
|
51
|
+
name: chainId === 4663 ? "Robinhood Chain" : "Robinhood Chain Testnet",
|
|
48
52
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
49
53
|
rpcUrls: { default: { http: [rpc] } },
|
|
50
54
|
} as const;
|
|
51
55
|
|
|
52
56
|
const session = createSessionTokenProvider(null);
|
|
53
57
|
const aureon = createAureonClient({
|
|
54
|
-
|
|
58
|
+
network: resolved.network,
|
|
59
|
+
baseUrl: resolved.baseUrl,
|
|
55
60
|
apiKey: requireEnv("AUREON_API_KEY"),
|
|
56
61
|
getAccessToken: session.getAccessToken,
|
|
57
62
|
});
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Env:
|
|
5
5
|
* AUREON_API_KEY issued developer key
|
|
6
6
|
* AUREON_WALLET_PRIVATE_KEY 0x… signing key
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* AUREON_NETWORK optional; omit for mainnet 8788 / 4663; testnet = public host (still 46630)
|
|
8
|
+
* AUREON_API_URL optional override
|
|
9
|
+
* AUREON_RPC_URL optional (defaults from resolved chain)
|
|
10
|
+
* AUREON_CHAIN_ID optional (defaults from resolved network)
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import {
|
|
@@ -20,7 +21,7 @@ import { privateKeyToAccount } from "viem/accounts";
|
|
|
20
21
|
import {
|
|
21
22
|
createAureonClient,
|
|
22
23
|
createSessionTokenProvider,
|
|
23
|
-
|
|
24
|
+
resolveAureonNetworkFromEnv,
|
|
24
25
|
} from "../../src/index.js";
|
|
25
26
|
|
|
26
27
|
function requireEnv(name: string): string {
|
|
@@ -35,22 +36,26 @@ if (!/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const account = privateKeyToAccount(key);
|
|
39
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
40
|
+
const chainId = Number(process.env.AUREON_CHAIN_ID || resolved.chainId);
|
|
38
41
|
const rpc =
|
|
39
42
|
process.env.AUREON_RPC_URL?.trim() ||
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
(chainId === 4663
|
|
44
|
+
? "https://rpc.mainnet.chain.robinhood.com"
|
|
45
|
+
: "https://rpc.testnet.chain.robinhood.com");
|
|
42
46
|
const publicClient = createPublicClient({ transport: http(rpc) });
|
|
43
47
|
const walletClient = createWalletClient({ account, transport: http(rpc) });
|
|
44
48
|
const chain = {
|
|
45
49
|
id: chainId,
|
|
46
|
-
name: "Robinhood Chain Testnet",
|
|
50
|
+
name: chainId === 4663 ? "Robinhood Chain" : "Robinhood Chain Testnet",
|
|
47
51
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
48
52
|
rpcUrls: { default: { http: [rpc] } },
|
|
49
53
|
} as const;
|
|
50
54
|
|
|
51
55
|
const session = createSessionTokenProvider(null);
|
|
52
56
|
const aureon = createAureonClient({
|
|
53
|
-
|
|
57
|
+
network: resolved.network,
|
|
58
|
+
baseUrl: resolved.baseUrl,
|
|
54
59
|
apiKey: requireEnv("AUREON_API_KEY"),
|
|
55
60
|
getAccessToken: session.getAccessToken,
|
|
56
61
|
});
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Env (integrators only — no local repo files):
|
|
5
5
|
* AUREON_API_KEY issued developer key (required)
|
|
6
|
-
*
|
|
6
|
+
* AUREON_NETWORK optional; omit for mainnet 8788 / 4663; testnet = public host (still 46630)
|
|
7
|
+
* AUREON_API_URL optional override
|
|
7
8
|
* AUREON_WALLET_PRIVATE_KEY 0x… key used to sign auth + broadcast vault txs (required)
|
|
8
|
-
* AUREON_RPC_URL optional (
|
|
9
|
-
* AUREON_CHAIN_ID optional (
|
|
9
|
+
* AUREON_RPC_URL optional (defaults from resolved chain)
|
|
10
|
+
* AUREON_CHAIN_ID optional (defaults from resolved network)
|
|
10
11
|
*
|
|
11
12
|
* pnpm --filter @buildaureon/sdk example:e2e
|
|
12
13
|
*/
|
|
@@ -21,7 +22,7 @@ import { privateKeyToAccount } from "viem/accounts";
|
|
|
21
22
|
import {
|
|
22
23
|
createAureonClient,
|
|
23
24
|
createSessionTokenProvider,
|
|
24
|
-
|
|
25
|
+
resolveAureonNetworkFromEnv,
|
|
25
26
|
isAureonError,
|
|
26
27
|
} from "../../src/index.js";
|
|
27
28
|
|
|
@@ -48,12 +49,15 @@ function log(step: string, data?: unknown): void {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
async function main(): Promise<void> {
|
|
51
|
-
const
|
|
52
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
53
|
+
const baseUrl = resolved.baseUrl;
|
|
52
54
|
const apiKey = requireEnv("AUREON_API_KEY");
|
|
55
|
+
const chainId = Number(process.env.AUREON_CHAIN_ID ?? resolved.chainId);
|
|
53
56
|
const rpcUrl =
|
|
54
57
|
process.env.AUREON_RPC_URL?.trim() ||
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
(chainId === 4663
|
|
59
|
+
? "https://rpc.mainnet.chain.robinhood.com"
|
|
60
|
+
: "https://rpc.testnet.chain.robinhood.com");
|
|
57
61
|
|
|
58
62
|
const account = privateKeyToAccount(loadPrivateKey());
|
|
59
63
|
const publicClient = createPublicClient({ transport: http(rpcUrl) });
|
|
@@ -63,13 +67,14 @@ async function main(): Promise<void> {
|
|
|
63
67
|
});
|
|
64
68
|
const chain = {
|
|
65
69
|
id: chainId,
|
|
66
|
-
name: "Robinhood Chain Testnet",
|
|
70
|
+
name: chainId === 4663 ? "Robinhood Chain" : "Robinhood Chain Testnet",
|
|
67
71
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
68
72
|
rpcUrls: { default: { http: [rpcUrl] } },
|
|
69
73
|
} as const;
|
|
70
74
|
|
|
71
75
|
const session = createSessionTokenProvider(null);
|
|
72
76
|
const aureon = createAureonClient({
|
|
77
|
+
network: resolved.network,
|
|
73
78
|
baseUrl,
|
|
74
79
|
apiKey,
|
|
75
80
|
getAccessToken: session.getAccessToken,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview full AUREON loop (not a portfolio tracker).
|
|
3
|
+
*
|
|
4
|
+
* Env:
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_NETWORK optional; omit for mainnet (4663 / 8788); set testnet for public host (still 46630)
|
|
7
|
+
* AUREON_API_URL optional override (must match network if both set)
|
|
8
|
+
*
|
|
9
|
+
* pnpm example:full-aureon-loop
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createAureonClient,
|
|
14
|
+
resolveAureonNetworkFromEnv,
|
|
15
|
+
formatWeight,
|
|
16
|
+
isAureonError,
|
|
17
|
+
type FullAureonLoopFlow,
|
|
18
|
+
} from "../../src/index.js";
|
|
19
|
+
|
|
20
|
+
function printFlow(flow: FullAureonLoopFlow): void {
|
|
21
|
+
console.log("\n=== AUREON — Full loop (not a portfolio tracker) ===\n");
|
|
22
|
+
|
|
23
|
+
console.log(`User brief: "${flow.userBrief}"\n`);
|
|
24
|
+
|
|
25
|
+
console.log("1. Intent → objective");
|
|
26
|
+
console.log(` Objective: ${flow.phases.intent.objectiveName}`);
|
|
27
|
+
console.log(` Policy: ${flow.phases.intent.policySummary}`);
|
|
28
|
+
console.log(` Mode: ${flow.phases.intent.automationMode}`);
|
|
29
|
+
console.log(
|
|
30
|
+
` Baseline: ${flow.phases.intent.health.state} — ${formatWeight(flow.phases.intent.health.currentMetric)} vs ${formatWeight(flow.phases.intent.health.targetMetric)}`
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
console.log("\n2. Plan check — green book can still fail the plan");
|
|
34
|
+
console.log(
|
|
35
|
+
` After shock: ${flow.phases.planCheck.afterShock.health.state} — ${formatWeight(flow.phases.planCheck.afterShock.health.currentMetric)} vs ${formatWeight(flow.phases.planCheck.afterShock.health.targetMetric)}`
|
|
36
|
+
);
|
|
37
|
+
console.log(
|
|
38
|
+
` Paradox: ${flow.phases.planCheck.afterShock.paradox.detected ? "yes" : "no"} — ${flow.phases.planCheck.afterShock.paradox.message}`
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
console.log("\n3. Drift → restore");
|
|
42
|
+
console.log(
|
|
43
|
+
` Health: ${flow.phases.driftRestore.healthBefore.state} → ${flow.phases.driftRestore.healthAfter.state}`
|
|
44
|
+
);
|
|
45
|
+
console.log(
|
|
46
|
+
` Receipt: ${flow.phases.driftRestore.settlement} — ${flow.phases.driftRestore.receipt.id}`
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
console.log("\n4. Receipt → verification");
|
|
50
|
+
console.log(
|
|
51
|
+
` Valid: ${flow.phases.verification.phases.validation.valid}`
|
|
52
|
+
);
|
|
53
|
+
console.log(` Proof tier: ${flow.phases.verification.proofTier}`);
|
|
54
|
+
console.log(` Claim: ${flow.phases.verification.phases.claimed.result}`);
|
|
55
|
+
|
|
56
|
+
console.log(`\n${flow.message}`);
|
|
57
|
+
console.log(
|
|
58
|
+
"\nWe're not building another portfolio tracker. Intent → plan → restore → verify.\n"
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function main(): Promise<void> {
|
|
63
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
64
|
+
if (!apiKey) {
|
|
65
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const resolved = resolveAureonNetworkFromEnv();
|
|
69
|
+
const aureon = createAureonClient({
|
|
70
|
+
network: resolved.network,
|
|
71
|
+
baseUrl: resolved.baseUrl,
|
|
72
|
+
apiKey,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const flow = await aureon.runFullAureonLoopDemo();
|
|
76
|
+
printFlow(flow);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
main().catch((error) => {
|
|
80
|
+
if (isAureonError(error)) {
|
|
81
|
+
console.error(`${error.code}: ${error.message}`);
|
|
82
|
+
} else {
|
|
83
|
+
console.error(error);
|
|
84
|
+
}
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
});
|