@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/LICENSE +21 -21
- package/README.md +15 -0
- package/config/network.json +10 -10
- package/dist/index.d.ts +646 -92
- package/dist/index.js +1723 -204
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +1 -1
- package/docs/client-api.md +178 -1
- package/docs/data-contracts.md +81 -6
- package/docs/integration-guide.md +141 -1
- package/docs/receipt-validation.md +63 -0
- package/examples/ai-to-objective-to-portfolio/main.ts +127 -0
- package/examples/audit-trail/main.ts +53 -0
- package/examples/drift-detect-restore/main.ts +96 -0
- package/examples/full-aureon-loop/main.ts +83 -0
- package/examples/green-vs-plan/main.ts +139 -0
- package/examples/market-event/main.ts +2 -0
- package/examples/portfolio-watch/main.ts +84 -0
- package/examples/receipt-verification/main.ts +87 -0
- package/fixtures/reference-objectives.json +18 -18
- package/fixtures/reference-portfolio.json +10 -10
- package/package.json +68 -61
|
@@ -0,0 +1,96 @@
|
|
|
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_API_URL optional (default https://api.aureonlabs.network)
|
|
9
|
+
*
|
|
10
|
+
* pnpm example:drift-detect-restore
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
createAureonClient,
|
|
15
|
+
DEFAULT_API_BASE_URL,
|
|
16
|
+
formatWeight,
|
|
17
|
+
isAureonError,
|
|
18
|
+
type DriftRestoreFlow,
|
|
19
|
+
} from "../../src/index.js";
|
|
20
|
+
|
|
21
|
+
function printPhase(label: string, healthState: string, metric?: number, target?: number): void {
|
|
22
|
+
const metricStr =
|
|
23
|
+
metric !== undefined && target !== undefined
|
|
24
|
+
? ` — ${formatWeight(metric)} vs ${formatWeight(target)} target`
|
|
25
|
+
: "";
|
|
26
|
+
console.log(` ${label}: ${healthState}${metricStr}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function printFlow(flow: DriftRestoreFlow): void {
|
|
30
|
+
console.log(`\nRule: ${flow.rule.summary}\n`);
|
|
31
|
+
|
|
32
|
+
console.log("1. Rule — aligned on policy");
|
|
33
|
+
printPhase(
|
|
34
|
+
" Health",
|
|
35
|
+
flow.phases.aligned.health.state,
|
|
36
|
+
flow.phases.aligned.health.currentMetric,
|
|
37
|
+
flow.phases.aligned.health.targetMetric
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
console.log("\n2. Drift — NVDA rally broke the stable sleeve");
|
|
41
|
+
printPhase(
|
|
42
|
+
" Health",
|
|
43
|
+
flow.phases.drift.health.state,
|
|
44
|
+
flow.phases.drift.health.currentMetric,
|
|
45
|
+
flow.phases.drift.health.targetMetric
|
|
46
|
+
);
|
|
47
|
+
if (flow.phases.drift.restorePlan) {
|
|
48
|
+
console.log(` Restore plan: ${flow.phases.drift.restorePlan.message}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (flow.phases.restored) {
|
|
52
|
+
console.log("\n3. Restore — back within policy");
|
|
53
|
+
printPhase(
|
|
54
|
+
" Health",
|
|
55
|
+
flow.phases.restored.health.state,
|
|
56
|
+
flow.phases.restored.health.currentMetric,
|
|
57
|
+
flow.phases.restored.health.targetMetric
|
|
58
|
+
);
|
|
59
|
+
if (flow.phases.restored.receipt) {
|
|
60
|
+
console.log(
|
|
61
|
+
` Receipt: ${flow.phases.restored.receipt.action} — settlement ${flow.phases.restored.receipt.settlement}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log(`\n${flow.message}`);
|
|
67
|
+
console.log(
|
|
68
|
+
"\nWe broke the rule on purpose. AUREON detected it and restored the policy.\n"
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function main(): Promise<void> {
|
|
73
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
74
|
+
if (!apiKey) {
|
|
75
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const aureon = createAureonClient({
|
|
79
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
80
|
+
apiKey,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
console.log("\n=== AUREON — Drift → detection → restore ===\n");
|
|
84
|
+
|
|
85
|
+
const flow = await aureon.runDriftRestoreDemo();
|
|
86
|
+
printFlow(flow);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main().catch((error) => {
|
|
90
|
+
if (isAureonError(error)) {
|
|
91
|
+
console.error(`${error.code}: ${error.message}`);
|
|
92
|
+
} else {
|
|
93
|
+
console.error(error);
|
|
94
|
+
}
|
|
95
|
+
process.exitCode = 1;
|
|
96
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview full AUREON loop (not a portfolio tracker).
|
|
3
|
+
*
|
|
4
|
+
* Env:
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
+
*
|
|
8
|
+
* pnpm example:full-aureon-loop
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
createAureonClient,
|
|
13
|
+
DEFAULT_API_BASE_URL,
|
|
14
|
+
formatWeight,
|
|
15
|
+
isAureonError,
|
|
16
|
+
type FullAureonLoopFlow,
|
|
17
|
+
} from "../../src/index.js";
|
|
18
|
+
|
|
19
|
+
function printFlow(flow: FullAureonLoopFlow): void {
|
|
20
|
+
console.log("\n=== AUREON — Full loop (not a portfolio tracker) ===\n");
|
|
21
|
+
|
|
22
|
+
console.log(`User brief: "${flow.userBrief}"\n`);
|
|
23
|
+
|
|
24
|
+
console.log("1. Intent → objective");
|
|
25
|
+
console.log(` Objective: ${flow.phases.intent.objectiveName}`);
|
|
26
|
+
console.log(` Policy: ${flow.phases.intent.policySummary}`);
|
|
27
|
+
console.log(` Mode: ${flow.phases.intent.automationMode}`);
|
|
28
|
+
console.log(
|
|
29
|
+
` Baseline: ${flow.phases.intent.health.state} — ${formatWeight(flow.phases.intent.health.currentMetric)} vs ${formatWeight(flow.phases.intent.health.targetMetric)}`
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
console.log("\n2. Plan check — green book can still fail the plan");
|
|
33
|
+
console.log(
|
|
34
|
+
` After shock: ${flow.phases.planCheck.afterShock.health.state} — ${formatWeight(flow.phases.planCheck.afterShock.health.currentMetric)} vs ${formatWeight(flow.phases.planCheck.afterShock.health.targetMetric)}`
|
|
35
|
+
);
|
|
36
|
+
console.log(
|
|
37
|
+
` Paradox: ${flow.phases.planCheck.afterShock.paradox.detected ? "yes" : "no"} — ${flow.phases.planCheck.afterShock.paradox.message}`
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
console.log("\n3. Drift → restore");
|
|
41
|
+
console.log(
|
|
42
|
+
` Health: ${flow.phases.driftRestore.healthBefore.state} → ${flow.phases.driftRestore.healthAfter.state}`
|
|
43
|
+
);
|
|
44
|
+
console.log(
|
|
45
|
+
` Receipt: ${flow.phases.driftRestore.settlement} — ${flow.phases.driftRestore.receipt.id}`
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
console.log("\n4. Receipt → verification");
|
|
49
|
+
console.log(
|
|
50
|
+
` Valid: ${flow.phases.verification.phases.validation.valid}`
|
|
51
|
+
);
|
|
52
|
+
console.log(` Proof tier: ${flow.phases.verification.proofTier}`);
|
|
53
|
+
console.log(` Claim: ${flow.phases.verification.phases.claimed.result}`);
|
|
54
|
+
|
|
55
|
+
console.log(`\n${flow.message}`);
|
|
56
|
+
console.log(
|
|
57
|
+
"\nWe're not building another portfolio tracker. Intent → plan → restore → verify.\n"
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main(): Promise<void> {
|
|
62
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
63
|
+
if (!apiKey) {
|
|
64
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const aureon = createAureonClient({
|
|
68
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
69
|
+
apiKey,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const flow = await aureon.runFullAureonLoopDemo();
|
|
73
|
+
printFlow(flow);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main().catch((error) => {
|
|
77
|
+
if (isAureonError(error)) {
|
|
78
|
+
console.error(`${error.code}: ${error.message}`);
|
|
79
|
+
} else {
|
|
80
|
+
console.error(error);
|
|
81
|
+
}
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Update 2 demo — green portfolio vs failing financial plan.
|
|
3
|
+
*
|
|
4
|
+
* Shows objective vs actual before and after a controlled NVDA rally with
|
|
5
|
+
* auto-restore disabled so the paradox stays visible.
|
|
6
|
+
*
|
|
7
|
+
* Env:
|
|
8
|
+
* AUREON_API_KEY issued developer key (required)
|
|
9
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
10
|
+
*
|
|
11
|
+
* pnpm example:green-vs-plan
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
createAureonClient,
|
|
16
|
+
DEFAULT_API_BASE_URL,
|
|
17
|
+
formatWeight,
|
|
18
|
+
isAureonError,
|
|
19
|
+
type AllocationComparisonRow,
|
|
20
|
+
type PortfolioPositionInput,
|
|
21
|
+
} from "../../src/index.js";
|
|
22
|
+
|
|
23
|
+
const DEMO_POSITIONS: PortfolioPositionInput[] = [
|
|
24
|
+
{
|
|
25
|
+
symbol: "USDG",
|
|
26
|
+
name: "Paxos USDG",
|
|
27
|
+
category: "stable",
|
|
28
|
+
quantity: 24_000,
|
|
29
|
+
markPriceUsd: 1,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
symbol: "NVDA",
|
|
33
|
+
name: "NVIDIA Stock Token",
|
|
34
|
+
category: "stock_token",
|
|
35
|
+
quantity: 45,
|
|
36
|
+
markPriceUsd: 920,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
symbol: "AAPL",
|
|
40
|
+
name: "Apple Stock Token",
|
|
41
|
+
category: "stock_token",
|
|
42
|
+
quantity: 80,
|
|
43
|
+
markPriceUsd: 210,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
symbol: "ETH",
|
|
47
|
+
name: "Ether",
|
|
48
|
+
category: "gas",
|
|
49
|
+
quantity: 8.5,
|
|
50
|
+
markPriceUsd: 3400,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
function printRows(rows: AllocationComparisonRow[]): void {
|
|
55
|
+
if (rows.length === 0) {
|
|
56
|
+
console.log(" (no active objectives)");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
for (const row of rows) {
|
|
60
|
+
const label = row.targetSymbol ?? row.name.slice(0, 20);
|
|
61
|
+
console.log(
|
|
62
|
+
` ${label.padEnd(16)} current ${formatWeight(row.currentMetric)} target ${formatWeight(row.targetWeight)} ${row.state}`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function main(): Promise<void> {
|
|
68
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
69
|
+
if (!apiKey) {
|
|
70
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const aureon = createAureonClient({
|
|
74
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
75
|
+
apiKey,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
console.log("\n=== AUREON Update 2 — Green vs plan ===\n");
|
|
79
|
+
|
|
80
|
+
console.log("1. Seed capital book (~20% stables)…");
|
|
81
|
+
await aureon.setPortfolio(DEMO_POSITIONS);
|
|
82
|
+
|
|
83
|
+
console.log("2. Create stable allocation objective (20% ± 2%)…");
|
|
84
|
+
const objective = await aureon.createObjective({
|
|
85
|
+
name: "Maintain 20% Stable Assets",
|
|
86
|
+
kind: "stable_allocation",
|
|
87
|
+
targetWeight: 0.2,
|
|
88
|
+
tolerance: 0.02,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
console.log("3. Baseline — objective vs actual:\n");
|
|
92
|
+
let snapshot = await aureon.getAllocationVsTarget();
|
|
93
|
+
printRows(snapshot.rows);
|
|
94
|
+
console.log(`\n Book: $${snapshot.overview.totalNotionalUsd.toLocaleString()}`);
|
|
95
|
+
console.log(` Paradox: ${snapshot.paradox.message}\n`);
|
|
96
|
+
|
|
97
|
+
console.log("4. Apply NVDA rally (+45%), autoRestore: false…");
|
|
98
|
+
const market = await aureon.applyMarketEvent({
|
|
99
|
+
name: "NVDA Stock Token Rally",
|
|
100
|
+
description: "Controlled mark move — Update 2 paradox demo",
|
|
101
|
+
symbol: "NVDA",
|
|
102
|
+
priceChangeRatio: 0.45,
|
|
103
|
+
autoRestore: false,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log("5. After shock — objective vs actual:\n");
|
|
107
|
+
snapshot = await aureon.getAllocationVsTarget();
|
|
108
|
+
printRows(snapshot.rows);
|
|
109
|
+
|
|
110
|
+
const stable = snapshot.rows.find((r) => r.objectiveId === objective.id);
|
|
111
|
+
const bookBefore = snapshot.overview.totalNotionalUsd;
|
|
112
|
+
const bookAfter = market.portfolio.totalNotionalUsd;
|
|
113
|
+
|
|
114
|
+
console.log(`\n Book before shock: $${bookBefore.toLocaleString()}`);
|
|
115
|
+
console.log(` Book after shock: $${bookAfter.toLocaleString()}`);
|
|
116
|
+
console.log(` Book moved up: ${bookAfter >= bookBefore ? "yes" : "no"}`);
|
|
117
|
+
if (stable) {
|
|
118
|
+
console.log(
|
|
119
|
+
` Stable objective: ${formatWeight(stable.currentMetric)} vs ${formatWeight(stable.targetWeight)} target — ${stable.state}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
console.log(`\n Paradox detected: ${snapshot.paradox.detected}`);
|
|
123
|
+
console.log(` ${snapshot.paradox.message}\n`);
|
|
124
|
+
|
|
125
|
+
if (!snapshot.paradox.detected && stable && stable.state !== "healthy") {
|
|
126
|
+
console.log(
|
|
127
|
+
" Note: paradox flag needs book-up signal; objective is still off-plan.\n"
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
main().catch((error) => {
|
|
133
|
+
if (isAureonError(error)) {
|
|
134
|
+
console.error(`${error.code}: ${error.message}`);
|
|
135
|
+
} else {
|
|
136
|
+
console.error(error);
|
|
137
|
+
}
|
|
138
|
+
process.exitCode = 1;
|
|
139
|
+
});
|
|
@@ -37,6 +37,8 @@ async function main(): Promise<void> {
|
|
|
37
37
|
description: "Controlled mark appreciation on NVIDIA Stock Token",
|
|
38
38
|
symbol: "NVDA",
|
|
39
39
|
priceChangeRatio: 0.45,
|
|
40
|
+
// autoRestore: true runs restorative execution when objectives breach —
|
|
41
|
+
// use autoRestore: false for the green-vs-plan paradox demo (see example:green-vs-plan).
|
|
40
42
|
autoRestore: true,
|
|
41
43
|
});
|
|
42
44
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview demo — portfolio watch while away (agent-in-host).
|
|
3
|
+
*
|
|
4
|
+
* Env:
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
+
*
|
|
8
|
+
* pnpm example:portfolio-watch
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
createAureonClient,
|
|
13
|
+
DEFAULT_API_BASE_URL,
|
|
14
|
+
formatWeight,
|
|
15
|
+
isAureonError,
|
|
16
|
+
type PortfolioWatchFlow,
|
|
17
|
+
} from "../../src/index.js";
|
|
18
|
+
|
|
19
|
+
function printFlow(flow: PortfolioWatchFlow): void {
|
|
20
|
+
console.log("\n=== AUREON — Watch while away (Cursor / Claude + MCP) ===\n");
|
|
21
|
+
|
|
22
|
+
console.log(`User brief: "${flow.userBrief}"`);
|
|
23
|
+
console.log(`Agent host: ${flow.host}\n`);
|
|
24
|
+
|
|
25
|
+
console.log("1. Register watch — intent → Automatic objective");
|
|
26
|
+
console.log(` Objective: ${flow.phases.register.objectiveName}`);
|
|
27
|
+
console.log(` Mode: ${flow.phases.register.automationMode}`);
|
|
28
|
+
console.log(` Policy: ${flow.phases.register.policySummary}`);
|
|
29
|
+
console.log(
|
|
30
|
+
` Health: ${flow.phases.register.health.state} — ${formatWeight(flow.phases.register.health.currentMetric ?? 0)} vs ${formatWeight(flow.phases.register.health.targetMetric ?? 0.2)} target`
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (flow.phases.whileAway) {
|
|
34
|
+
console.log("\n2. While away — market moved, Automatic mode acted");
|
|
35
|
+
console.log(
|
|
36
|
+
` Event: ${flow.phases.whileAway.marketEventName} (${flow.phases.whileAway.symbol} ${(flow.phases.whileAway.priceChangeRatio * 100).toFixed(0)}%)`
|
|
37
|
+
);
|
|
38
|
+
console.log(
|
|
39
|
+
` Health: ${flow.phases.whileAway.healthBefore.state} → ${flow.phases.whileAway.healthAfter.state}`
|
|
40
|
+
);
|
|
41
|
+
console.log(
|
|
42
|
+
` Auto restore: ${flow.phases.whileAway.autoRestored ? "yes" : "no"}`
|
|
43
|
+
);
|
|
44
|
+
if (flow.phases.whileAway.receipt) {
|
|
45
|
+
console.log(
|
|
46
|
+
` Receipt: ${flow.phases.whileAway.receipt.settlement} — ${flow.phases.whileAway.receipt.id}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log("\n3. Return briefing — what to tell the user");
|
|
52
|
+
for (const line of flow.phases.briefing.summaryLines) {
|
|
53
|
+
console.log(` • ${line}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log(`\n${flow.message}`);
|
|
57
|
+
console.log(
|
|
58
|
+
"\nYou don't hand the agent a blank check — you register a rule, then read the briefing when you're back.\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 aureon = createAureonClient({
|
|
69
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
70
|
+
apiKey,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const flow = await aureon.runPortfolioWatchDemo({ host: "cursor" });
|
|
74
|
+
printFlow(flow);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
main().catch((error) => {
|
|
78
|
+
if (isAureonError(error)) {
|
|
79
|
+
console.error(`${error.code}: ${error.message}`);
|
|
80
|
+
} else {
|
|
81
|
+
console.error(error);
|
|
82
|
+
}
|
|
83
|
+
process.exitCode = 1;
|
|
84
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview receipt → verification.
|
|
3
|
+
*
|
|
4
|
+
* Shows claim vs validation vs settlement proof after a restore.
|
|
5
|
+
*
|
|
6
|
+
* Env:
|
|
7
|
+
* AUREON_API_KEY issued developer key (required)
|
|
8
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
9
|
+
*
|
|
10
|
+
* pnpm example:receipt-verification
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
createAureonClient,
|
|
15
|
+
DEFAULT_API_BASE_URL,
|
|
16
|
+
isAureonError,
|
|
17
|
+
type ReceiptVerificationFlow,
|
|
18
|
+
} from "../../src/index.js";
|
|
19
|
+
|
|
20
|
+
function printFlow(flow: ReceiptVerificationFlow): void {
|
|
21
|
+
console.log("\n=== AUREON — Receipt → verification ===\n");
|
|
22
|
+
|
|
23
|
+
console.log("1. Claim — what the API/agent would call 'success'");
|
|
24
|
+
console.log(` Status: ${flow.phases.claimed.status}`);
|
|
25
|
+
console.log(` Result: ${flow.phases.claimed.result}`);
|
|
26
|
+
console.log(` Settlement: ${flow.phases.claimed.settlement}`);
|
|
27
|
+
console.log(` Summary: ${flow.phases.claimed.summary}\n`);
|
|
28
|
+
|
|
29
|
+
console.log("2. Validate — local honesty check (schema + settlement rules)");
|
|
30
|
+
console.log(` Valid: ${flow.phases.validation.valid}`);
|
|
31
|
+
if (!flow.phases.validation.valid) {
|
|
32
|
+
for (const issue of flow.phases.validation.issues) {
|
|
33
|
+
console.log(` - ${issue.code}: ${issue.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.log(` Proof tier: ${flow.proofTier}\n`);
|
|
37
|
+
|
|
38
|
+
console.log("3. Verify — independent settlement lookup (vault only)");
|
|
39
|
+
const settlement = flow.phases.settlement;
|
|
40
|
+
if (settlement) {
|
|
41
|
+
console.log(` On-chain: ${settlement.verifiedOnChain ? "yes" : "no"}`);
|
|
42
|
+
if (settlement.settlement) {
|
|
43
|
+
console.log(` Block: ${settlement.settlement.blockNumber}`);
|
|
44
|
+
console.log(` Explorer: ${settlement.settlement.explorerUrl}`);
|
|
45
|
+
} else {
|
|
46
|
+
console.log(" Record: (none yet — vault submitted but not observed)");
|
|
47
|
+
}
|
|
48
|
+
} else if (flow.receipt.settlement === "staged") {
|
|
49
|
+
console.log(" Staged receipt — schema-valid, not chain-verified by design.");
|
|
50
|
+
} else {
|
|
51
|
+
console.log(" Settlement lookup unavailable for this receipt.");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const timelineCount = flow.phases.timelineEvents?.length ?? 0;
|
|
55
|
+
if (timelineCount > 0) {
|
|
56
|
+
console.log(`\n Timeline: ${timelineCount} linked event(s)`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(`\n${flow.message}`);
|
|
60
|
+
console.log(
|
|
61
|
+
"\nSuccess text is a claim. Validation and settlement records are how you verify it.\n"
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function main(): Promise<void> {
|
|
66
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
67
|
+
if (!apiKey) {
|
|
68
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const aureon = createAureonClient({
|
|
72
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
73
|
+
apiKey,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const flow = await aureon.runReceiptVerificationDemo();
|
|
77
|
+
printFlow(flow);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
main().catch((error) => {
|
|
81
|
+
if (isAureonError(error)) {
|
|
82
|
+
console.error(`${error.code}: ${error.message}`);
|
|
83
|
+
} else {
|
|
84
|
+
console.error(error);
|
|
85
|
+
}
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"objectives": [
|
|
3
|
-
{
|
|
4
|
-
"name": "Maintain 20% Stable Assets",
|
|
5
|
-
"kind": "stable_allocation",
|
|
6
|
-
"targetWeight": 0.2,
|
|
7
|
-
"tolerance": 0.02,
|
|
8
|
-
"priority": "high"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "Balanced Stock Token Sleeve",
|
|
12
|
-
"kind": "balanced_portfolio",
|
|
13
|
-
"targetWeight": 0.55,
|
|
14
|
-
"tolerance": 0.05,
|
|
15
|
-
"priority": "medium"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"objectives": [
|
|
3
|
+
{
|
|
4
|
+
"name": "Maintain 20% Stable Assets",
|
|
5
|
+
"kind": "stable_allocation",
|
|
6
|
+
"targetWeight": 0.2,
|
|
7
|
+
"tolerance": 0.02,
|
|
8
|
+
"priority": "high"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Balanced Stock Token Sleeve",
|
|
12
|
+
"kind": "balanced_portfolio",
|
|
13
|
+
"targetWeight": 0.55,
|
|
14
|
+
"tolerance": 0.05,
|
|
15
|
+
"priority": "medium"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"portfolioId": "portfolio_operator_primary",
|
|
3
|
-
"positions": [
|
|
4
|
-
{ "symbol": "USDG", "category": "stable", "quantity": 24000, "markPriceUsd": 1 },
|
|
5
|
-
{ "symbol": "NVDA", "category": "stock_token", "quantity": 45, "markPriceUsd": 920 },
|
|
6
|
-
{ "symbol": "AAPL", "category": "stock_token", "quantity": 80, "markPriceUsd": 210 },
|
|
7
|
-
{ "symbol": "GOOGL", "category": "stock_token", "quantity": 60, "markPriceUsd": 175 },
|
|
8
|
-
{ "symbol": "ETH", "category": "gas", "quantity": 8.5, "markPriceUsd": 3400 }
|
|
9
|
-
]
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"portfolioId": "portfolio_operator_primary",
|
|
3
|
+
"positions": [
|
|
4
|
+
{ "symbol": "USDG", "category": "stable", "quantity": 24000, "markPriceUsd": 1 },
|
|
5
|
+
{ "symbol": "NVDA", "category": "stock_token", "quantity": 45, "markPriceUsd": 920 },
|
|
6
|
+
{ "symbol": "AAPL", "category": "stock_token", "quantity": 80, "markPriceUsd": 210 },
|
|
7
|
+
{ "symbol": "GOOGL", "category": "stock_token", "quantity": 60, "markPriceUsd": 175 },
|
|
8
|
+
{ "symbol": "ETH", "category": "gas", "quantity": 8.5, "markPriceUsd": 3400 }
|
|
9
|
+
]
|
|
10
|
+
}
|