@buildaureon/sdk 0.1.1 → 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/README.md +655 -640
- package/dist/index.d.ts +713 -89
- package/dist/index.js +1754 -190
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +206 -206
- package/docs/auth.md +174 -174
- package/docs/client-api.md +782 -605
- package/docs/data-contracts.md +710 -635
- package/docs/error-model.md +217 -217
- package/docs/integration-guide.md +397 -257
- package/docs/receipt-validation.md +63 -0
- package/docs/security.md +120 -120
- package/docs/transport.md +142 -142
- 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 +67 -65
- package/examples/portfolio-watch/main.ts +84 -0
- package/examples/quickstart/main.ts +72 -72
- package/examples/receipt-verification/main.ts +87 -0
- package/examples/registry-register/main.ts +44 -0
- package/package.json +8 -1
|
@@ -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
|
+
});
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Quickstart — control-plane calls with an issued developer API key.
|
|
3
|
-
*
|
|
4
|
-
* Env (required for integrators — nothing else):
|
|
5
|
-
* AUREON_API_KEY issued key from https://app.aureonlabs.network → Developers
|
|
6
|
-
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
-
*
|
|
8
|
-
* pnpm --filter @buildaureon/sdk example:quickstart
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
createAureonClient,
|
|
13
|
-
DEFAULT_API_BASE_URL,
|
|
14
|
-
formatWeight,
|
|
15
|
-
isAureonError,
|
|
16
|
-
} from "../../src/index.js";
|
|
17
|
-
|
|
18
|
-
async function main(): Promise<void> {
|
|
19
|
-
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
20
|
-
if (!apiKey) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
"Set AUREON_API_KEY to an issued developer key from the AUREON Developers page."
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const aureon = createAureonClient({
|
|
27
|
-
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
28
|
-
apiKey,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const ping = await aureon.ping();
|
|
32
|
-
console.log("connected", ping);
|
|
33
|
-
|
|
34
|
-
const me = await aureon.me();
|
|
35
|
-
console.log("wallet", me.walletAddress);
|
|
36
|
-
|
|
37
|
-
const synced = await aureon.syncPortfolio();
|
|
38
|
-
console.log("synced", {
|
|
39
|
-
chainId: synced.chainId,
|
|
40
|
-
positions: synced.portfolio.positions.length,
|
|
41
|
-
stableWeight: formatWeight(synced.portfolio.stableWeight),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const vault = await aureon.getVaultStatus();
|
|
45
|
-
console.log("vault", {
|
|
46
|
-
empty: vault.empty,
|
|
47
|
-
canRestore: vault.canRestore,
|
|
48
|
-
totalNotionalUsd: vault.totalNotionalUsd,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const objectives = await aureon.listObjectives();
|
|
52
|
-
console.log(
|
|
53
|
-
"objectives",
|
|
54
|
-
objectives.map((o) => ({
|
|
55
|
-
name: o.name,
|
|
56
|
-
automationMode: o.automationMode,
|
|
57
|
-
}))
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
console.log(
|
|
61
|
-
"hint: private key is only needed later to broadcast prepare-deposit / prepare-withdraw steps"
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
main().catch((error) => {
|
|
66
|
-
if (isAureonError(error)) {
|
|
67
|
-
console.error(`${error.code}: ${error.message}`);
|
|
68
|
-
} else {
|
|
69
|
-
console.error(error instanceof Error ? error.message : error);
|
|
70
|
-
}
|
|
71
|
-
process.exitCode = 1;
|
|
72
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Quickstart — control-plane calls with an issued developer API key.
|
|
3
|
+
*
|
|
4
|
+
* Env (required for integrators — nothing else):
|
|
5
|
+
* AUREON_API_KEY issued key from https://app.aureonlabs.network → Developers
|
|
6
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
+
*
|
|
8
|
+
* pnpm --filter @buildaureon/sdk example:quickstart
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
createAureonClient,
|
|
13
|
+
DEFAULT_API_BASE_URL,
|
|
14
|
+
formatWeight,
|
|
15
|
+
isAureonError,
|
|
16
|
+
} from "../../src/index.js";
|
|
17
|
+
|
|
18
|
+
async function main(): Promise<void> {
|
|
19
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
20
|
+
if (!apiKey) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
"Set AUREON_API_KEY to an issued developer key from the AUREON Developers page."
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const aureon = createAureonClient({
|
|
27
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
28
|
+
apiKey,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const ping = await aureon.ping();
|
|
32
|
+
console.log("connected", ping);
|
|
33
|
+
|
|
34
|
+
const me = await aureon.me();
|
|
35
|
+
console.log("wallet", me.walletAddress);
|
|
36
|
+
|
|
37
|
+
const synced = await aureon.syncPortfolio();
|
|
38
|
+
console.log("synced", {
|
|
39
|
+
chainId: synced.chainId,
|
|
40
|
+
positions: synced.portfolio.positions.length,
|
|
41
|
+
stableWeight: formatWeight(synced.portfolio.stableWeight),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const vault = await aureon.getVaultStatus();
|
|
45
|
+
console.log("vault", {
|
|
46
|
+
empty: vault.empty,
|
|
47
|
+
canRestore: vault.canRestore,
|
|
48
|
+
totalNotionalUsd: vault.totalNotionalUsd,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const objectives = await aureon.listObjectives();
|
|
52
|
+
console.log(
|
|
53
|
+
"objectives",
|
|
54
|
+
objectives.map((o) => ({
|
|
55
|
+
name: o.name,
|
|
56
|
+
automationMode: o.automationMode,
|
|
57
|
+
}))
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
console.log(
|
|
61
|
+
"hint: private key is only needed later to broadcast prepare-deposit / prepare-withdraw steps"
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main().catch((error) => {
|
|
66
|
+
if (isAureonError(error)) {
|
|
67
|
+
console.error(`${error.code}: ${error.message}`);
|
|
68
|
+
} else {
|
|
69
|
+
console.error(error instanceof Error ? error.message : error);
|
|
70
|
+
}
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
});
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 2 — prepare on-chain objective registration (wallet signs broadcast).
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* AUREON_API_KEY=aur_... npx tsx examples/registry-register/main.ts
|
|
6
|
+
*/
|
|
7
|
+
import { createAureonClient } from "../../src/client/factory.js";
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
console.error("Set AUREON_API_KEY");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const client = createAureonClient({ apiKey });
|
|
17
|
+
const status = await client.getRegistryStatus();
|
|
18
|
+
console.log("registry status", status);
|
|
19
|
+
|
|
20
|
+
const { objectives } = await client.listObjectives();
|
|
21
|
+
const target = objectives[0];
|
|
22
|
+
if (!target) {
|
|
23
|
+
console.error("Create an objective first");
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const lookup = await client.getObjectiveRegistry(target.id);
|
|
28
|
+
if (lookup.registered) {
|
|
29
|
+
console.log("already registered", lookup.record);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const prepared = await client.prepareObjectiveRegistry(target.id);
|
|
34
|
+
console.log("Sign and broadcast this tx from your wallet:");
|
|
35
|
+
console.log(JSON.stringify(prepared, null, 2));
|
|
36
|
+
console.log(
|
|
37
|
+
"Then: client.confirmObjectiveRegistry(objectiveId, transactionHash)"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main().catch((err) => {
|
|
42
|
+
console.error(err);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildaureon/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Official TypeScript SDK for AUREON Financial Compass on Robinhood Chain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,6 +29,13 @@
|
|
|
29
29
|
"bench": "tsx benchmarks/client-throughput.ts",
|
|
30
30
|
"example:quickstart": "tsx examples/quickstart/main.ts",
|
|
31
31
|
"example:market": "tsx examples/market-event/main.ts",
|
|
32
|
+
"example:green-vs-plan": "tsx examples/green-vs-plan/main.ts",
|
|
33
|
+
"example:ai-to-objective-to-portfolio": "tsx examples/ai-to-objective-to-portfolio/main.ts",
|
|
34
|
+
"example:drift-detect-restore": "tsx examples/drift-detect-restore/main.ts",
|
|
35
|
+
"example:receipt-verification": "tsx examples/receipt-verification/main.ts",
|
|
36
|
+
"example:portfolio-watch": "tsx examples/portfolio-watch/main.ts",
|
|
37
|
+
"example:full-aureon-loop": "tsx examples/full-aureon-loop/main.ts",
|
|
38
|
+
"example:audit-trail": "tsx examples/audit-trail/main.ts",
|
|
32
39
|
"example:sdk-demo-terminal": "tsx examples/sdk-demo-terminal/main.ts",
|
|
33
40
|
"example:e2e": "tsx examples/e2e-vault-flow/main.ts",
|
|
34
41
|
"example:e2e-policy": "tsx examples/e2e-policy-rebalance/main.ts",
|