@buildaureon/sdk 0.1.1 → 0.1.2
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 +640 -640
- package/config/network.json +10 -10
- package/dist/index.d.ts +73 -3
- package/dist/index.js +48 -3
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +206 -206
- package/docs/auth.md +174 -174
- package/docs/client-api.md +605 -605
- package/docs/data-contracts.md +635 -635
- package/docs/error-model.md +217 -217
- package/docs/integration-guide.md +257 -257
- package/docs/security.md +120 -120
- package/docs/transport.md +142 -142
- package/examples/market-event/main.ts +65 -65
- package/examples/quickstart/main.ts +72 -72
- package/examples/registry-register/main.ts +44 -0
- package/fixtures/reference-objectives.json +18 -18
- package/fixtures/reference-portfolio.json +10 -10
- package/package.json +61 -61
|
@@ -1,257 +1,257 @@
|
|
|
1
|
-
# Production Integration Guide
|
|
2
|
-
|
|
3
|
-
Integrate `@buildaureon/sdk` into server-side agents and automated rebalancing loops against the live AUREON API.
|
|
4
|
-
|
|
5
|
-
**Automation note:** SDK integrations support **Automatic mode only** (`automationMode: "auto"` — the default). Do not build Manual Approve agent loops with the SDK; use the operator utility for Manual workflows.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 1. End-to-end agent loop
|
|
10
|
-
|
|
11
|
-
```mermaid
|
|
12
|
-
flowchart TD
|
|
13
|
-
Init[1_issued_API_key_client] --> Sync[2_sync_Capital_Book]
|
|
14
|
-
Sync --> Fund[3_fund_vault_if_empty]
|
|
15
|
-
Fund --> Obj[4_create_Auto_objective]
|
|
16
|
-
Obj --> Loop[5_watchdog_heartbeat]
|
|
17
|
-
Loop -->|breach| Plan[6_restore_plan]
|
|
18
|
-
Plan --> Restore[7_restoreObjective]
|
|
19
|
-
Restore --> Loop
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Step 1 — Client
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
import { createAureonClient } from "@buildaureon/sdk";
|
|
26
|
-
|
|
27
|
-
export const aureon = createAureonClient({
|
|
28
|
-
baseUrl: process.env.AUREON_API_URL || "https://api.aureonlabs.network",
|
|
29
|
-
apiKey: process.env.AUREON_API_KEY!, // issued Developers key
|
|
30
|
-
timeoutMs: 30_000,
|
|
31
|
-
maxRetries: 2,
|
|
32
|
-
retryDelayMs: 500,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const me = await aureon.me();
|
|
36
|
-
console.log("operating as", me.walletAddress);
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Optional Bearer (usually unnecessary with an issued key):
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
import { createAureonClient, createSessionTokenProvider } from "@buildaureon/sdk";
|
|
43
|
-
|
|
44
|
-
const session = createSessionTokenProvider(process.env.AUREON_TOKEN ?? null);
|
|
45
|
-
export const aureon = createAureonClient({
|
|
46
|
-
baseUrl: process.env.AUREON_API_URL || "https://api.aureonlabs.network",
|
|
47
|
-
apiKey: process.env.AUREON_API_KEY ?? null,
|
|
48
|
-
getAccessToken: session.getAccessToken,
|
|
49
|
-
});
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Step 2 — Sync Capital Book
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
const { portfolio, chainId } = await aureon.syncPortfolio();
|
|
56
|
-
console.log({
|
|
57
|
-
chainId,
|
|
58
|
-
positions: portfolio.positions.length,
|
|
59
|
-
totalNotionalUsd: portfolio.totalNotionalUsd,
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Prefer `syncPortfolio()` over hand-seeded books in production. Use `setPortfolio` only for controlled rehearsals.
|
|
64
|
-
|
|
65
|
-
### Step 3 — Fund vault when needed
|
|
66
|
-
|
|
67
|
-
Automatic restores require vault capital. Prepare returns **unsigned** steps — your host signs and broadcasts.
|
|
68
|
-
|
|
69
|
-
```ts
|
|
70
|
-
import type { VaultPrepareResult } from "@buildaureon/sdk";
|
|
71
|
-
|
|
72
|
-
async function ensureVaultFunded(
|
|
73
|
-
symbol: string,
|
|
74
|
-
amount: string,
|
|
75
|
-
broadcast: (step: VaultPrepareResult["steps"][number]) => Promise<string>
|
|
76
|
-
) {
|
|
77
|
-
const status = await aureon.getVaultStatus();
|
|
78
|
-
if (!status.empty && status.canRestore) return status;
|
|
79
|
-
|
|
80
|
-
const prep = await aureon.prepareVaultDeposit({ symbol, amount });
|
|
81
|
-
for (const step of prep.steps) {
|
|
82
|
-
const hash = await broadcast(step);
|
|
83
|
-
console.log(step.label, hash);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return aureon.getVaultStatus();
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Typical broadcast (viem sketch):
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
// host-owned — not part of the SDK
|
|
94
|
-
await walletClient.sendTransaction({
|
|
95
|
-
to: step.to,
|
|
96
|
-
data: step.data,
|
|
97
|
-
value: step.value ? BigInt(step.value) : 0n,
|
|
98
|
-
});
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Step 4 — Create an Automatic objective
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
const objective = await aureon.createObjective({
|
|
105
|
-
name: "Maintain 20% WETH",
|
|
106
|
-
kind: "balanced_portfolio",
|
|
107
|
-
targetWeight: 0.2,
|
|
108
|
-
tolerance: 0.03,
|
|
109
|
-
targetSymbol: "WETH",
|
|
110
|
-
// automationMode defaults to "auto" — keep it that way for SDK agents
|
|
111
|
-
priority: "medium",
|
|
112
|
-
});
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**Locks:** `targetSymbol` and `automationMode` cannot change after create. Recreate the objective to change token or mode.
|
|
116
|
-
|
|
117
|
-
### Step 5 — Watchdog heartbeat
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
async function heartbeat() {
|
|
121
|
-
const refreshed = await aureon.refreshWatchdog();
|
|
122
|
-
console.log("breaches", refreshed.breaches.length);
|
|
123
|
-
|
|
124
|
-
for (const breach of refreshed.breaches) {
|
|
125
|
-
const plan = await aureon.getRestorePlan(breach.objectiveId);
|
|
126
|
-
console.log("plan", plan.kind, plan);
|
|
127
|
-
|
|
128
|
-
const receipt = await aureon.restoreObjective(breach.objectiveId);
|
|
129
|
-
console.log({
|
|
130
|
-
settlement: receipt.settlement, // "vault" | "staged"
|
|
131
|
-
status: receipt.status,
|
|
132
|
-
tx: receipt.transactionHash,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const health = await aureon.getHealth();
|
|
137
|
-
return health;
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Step 6 — Verify
|
|
142
|
-
|
|
143
|
-
```ts
|
|
144
|
-
await aureon.getHealth(objective.id);
|
|
145
|
-
await aureon.getTimeline(objective.id);
|
|
146
|
-
await aureon.listExecutions(objective.id);
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Always branch UI/agent copy on `receipt.settlement`.
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## 2. Recommended objective kinds for agents
|
|
154
|
-
|
|
155
|
-
| Kind | Typical use |
|
|
156
|
-
| --- | --- |
|
|
157
|
-
| `balanced_portfolio` | Hold `targetSymbol` near a weight band |
|
|
158
|
-
| `stable_allocation` | Keep a stable sleeve near a weight |
|
|
159
|
-
| `risk_ceiling` | Cap portfolio risk score |
|
|
160
|
-
| `reward_reinvestment` | Sweep rewards into a sleeve |
|
|
161
|
-
|
|
162
|
-
Start with one Automatic `balanced_portfolio` objective and a funded vault before adding more policies.
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## 3. Daemon runners
|
|
167
|
-
|
|
168
|
-
### PM2
|
|
169
|
-
|
|
170
|
-
```js
|
|
171
|
-
module.exports = {
|
|
172
|
-
apps: [
|
|
173
|
-
{
|
|
174
|
-
name: "aureon-agent-loop",
|
|
175
|
-
script: "./dist/index.js",
|
|
176
|
-
instances: 1,
|
|
177
|
-
autorestart: true,
|
|
178
|
-
env: {
|
|
179
|
-
NODE_ENV: "production",
|
|
180
|
-
AUREON_API_URL: "https://api.aureonlabs.network",
|
|
181
|
-
// AUREON_API_KEY from secret store / PM2 ecosystem secrets
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
};
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### systemd
|
|
189
|
-
|
|
190
|
-
```ini
|
|
191
|
-
[Unit]
|
|
192
|
-
Description=AUREON Automatic restore agent
|
|
193
|
-
After=network.target
|
|
194
|
-
|
|
195
|
-
[Service]
|
|
196
|
-
Type=simple
|
|
197
|
-
User=node
|
|
198
|
-
WorkingDirectory=/home/node/app
|
|
199
|
-
ExecStart=/usr/bin/node dist/index.js
|
|
200
|
-
Restart=on-failure
|
|
201
|
-
RestartSec=10
|
|
202
|
-
Environment=NODE_ENV=production
|
|
203
|
-
|
|
204
|
-
[Install]
|
|
205
|
-
WantedBy=multi-user.target
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### Logging
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
import { createAureonClient } from "@buildaureon/sdk";
|
|
212
|
-
|
|
213
|
-
const aureon = createAureonClient({
|
|
214
|
-
apiKey: process.env.AUREON_API_KEY!,
|
|
215
|
-
logger: {
|
|
216
|
-
debug: (msg, ctx) => console.debug(msg, ctx),
|
|
217
|
-
info: (msg, ctx) => console.info(msg, ctx),
|
|
218
|
-
warn: (msg, ctx) => console.warn(msg, ctx),
|
|
219
|
-
error: (msg, ctx) => console.error(msg, ctx),
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Never log API keys, Bearer tokens, or private keys.
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
## 4. Frontend / SPA notes
|
|
229
|
-
|
|
230
|
-
- Do not ship issued API keys in public browser bundles.
|
|
231
|
-
- Prefer a backend proxy for agent credentials.
|
|
232
|
-
- Keep `refreshWatchdog` / `restoreObjective` loops on the server.
|
|
233
|
-
- Browser operator UX is the utility app (wallet session), not the SDK agent path.
|
|
234
|
-
|
|
235
|
-
---
|
|
236
|
-
|
|
237
|
-
## 5. Troubleshooting
|
|
238
|
-
|
|
239
|
-
| Symptom | Likely cause | Fix |
|
|
240
|
-
| --- | --- | --- |
|
|
241
|
-
| 401 invalid key | Wrong / paused / revoked key | Rotate in Developers |
|
|
242
|
-
| 401 need issued key | Env bootstrap key alone | Use an issued Developers key |
|
|
243
|
-
| Vault empty / cannot restore | No vault capital | `prepareVaultDeposit` → broadcast → sync |
|
|
244
|
-
| Update rejects symbol/mode | Locked at create | Recreate objective |
|
|
245
|
-
| Restore receipt `staged` | Ledger-local path | Do not claim on-chain |
|
|
246
|
-
| Health still violated after restore | Prices / sizing / liquidity | Re-read plan, vault balances, timeline |
|
|
247
|
-
| Network / timeout | RPC or API latency | Raise `timeoutMs`, set `maxRetries` |
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## 6. Related docs
|
|
252
|
-
|
|
253
|
-
- [Auth](./auth.md)
|
|
254
|
-
- [Architecture](./architecture.md)
|
|
255
|
-
- [Client API](./client-api.md)
|
|
256
|
-
- [Error model](./error-model.md)
|
|
257
|
-
- [Security](./security.md)
|
|
1
|
+
# Production Integration Guide
|
|
2
|
+
|
|
3
|
+
Integrate `@buildaureon/sdk` into server-side agents and automated rebalancing loops against the live AUREON API.
|
|
4
|
+
|
|
5
|
+
**Automation note:** SDK integrations support **Automatic mode only** (`automationMode: "auto"` — the default). Do not build Manual Approve agent loops with the SDK; use the operator utility for Manual workflows.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. End-to-end agent loop
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
flowchart TD
|
|
13
|
+
Init[1_issued_API_key_client] --> Sync[2_sync_Capital_Book]
|
|
14
|
+
Sync --> Fund[3_fund_vault_if_empty]
|
|
15
|
+
Fund --> Obj[4_create_Auto_objective]
|
|
16
|
+
Obj --> Loop[5_watchdog_heartbeat]
|
|
17
|
+
Loop -->|breach| Plan[6_restore_plan]
|
|
18
|
+
Plan --> Restore[7_restoreObjective]
|
|
19
|
+
Restore --> Loop
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Step 1 — Client
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createAureonClient } from "@buildaureon/sdk";
|
|
26
|
+
|
|
27
|
+
export const aureon = createAureonClient({
|
|
28
|
+
baseUrl: process.env.AUREON_API_URL || "https://api.aureonlabs.network",
|
|
29
|
+
apiKey: process.env.AUREON_API_KEY!, // issued Developers key
|
|
30
|
+
timeoutMs: 30_000,
|
|
31
|
+
maxRetries: 2,
|
|
32
|
+
retryDelayMs: 500,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const me = await aureon.me();
|
|
36
|
+
console.log("operating as", me.walletAddress);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Optional Bearer (usually unnecessary with an issued key):
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createAureonClient, createSessionTokenProvider } from "@buildaureon/sdk";
|
|
43
|
+
|
|
44
|
+
const session = createSessionTokenProvider(process.env.AUREON_TOKEN ?? null);
|
|
45
|
+
export const aureon = createAureonClient({
|
|
46
|
+
baseUrl: process.env.AUREON_API_URL || "https://api.aureonlabs.network",
|
|
47
|
+
apiKey: process.env.AUREON_API_KEY ?? null,
|
|
48
|
+
getAccessToken: session.getAccessToken,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Step 2 — Sync Capital Book
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const { portfolio, chainId } = await aureon.syncPortfolio();
|
|
56
|
+
console.log({
|
|
57
|
+
chainId,
|
|
58
|
+
positions: portfolio.positions.length,
|
|
59
|
+
totalNotionalUsd: portfolio.totalNotionalUsd,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Prefer `syncPortfolio()` over hand-seeded books in production. Use `setPortfolio` only for controlled rehearsals.
|
|
64
|
+
|
|
65
|
+
### Step 3 — Fund vault when needed
|
|
66
|
+
|
|
67
|
+
Automatic restores require vault capital. Prepare returns **unsigned** steps — your host signs and broadcasts.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import type { VaultPrepareResult } from "@buildaureon/sdk";
|
|
71
|
+
|
|
72
|
+
async function ensureVaultFunded(
|
|
73
|
+
symbol: string,
|
|
74
|
+
amount: string,
|
|
75
|
+
broadcast: (step: VaultPrepareResult["steps"][number]) => Promise<string>
|
|
76
|
+
) {
|
|
77
|
+
const status = await aureon.getVaultStatus();
|
|
78
|
+
if (!status.empty && status.canRestore) return status;
|
|
79
|
+
|
|
80
|
+
const prep = await aureon.prepareVaultDeposit({ symbol, amount });
|
|
81
|
+
for (const step of prep.steps) {
|
|
82
|
+
const hash = await broadcast(step);
|
|
83
|
+
console.log(step.label, hash);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return aureon.getVaultStatus();
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Typical broadcast (viem sketch):
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
// host-owned — not part of the SDK
|
|
94
|
+
await walletClient.sendTransaction({
|
|
95
|
+
to: step.to,
|
|
96
|
+
data: step.data,
|
|
97
|
+
value: step.value ? BigInt(step.value) : 0n,
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Step 4 — Create an Automatic objective
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
const objective = await aureon.createObjective({
|
|
105
|
+
name: "Maintain 20% WETH",
|
|
106
|
+
kind: "balanced_portfolio",
|
|
107
|
+
targetWeight: 0.2,
|
|
108
|
+
tolerance: 0.03,
|
|
109
|
+
targetSymbol: "WETH",
|
|
110
|
+
// automationMode defaults to "auto" — keep it that way for SDK agents
|
|
111
|
+
priority: "medium",
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Locks:** `targetSymbol` and `automationMode` cannot change after create. Recreate the objective to change token or mode.
|
|
116
|
+
|
|
117
|
+
### Step 5 — Watchdog heartbeat
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
async function heartbeat() {
|
|
121
|
+
const refreshed = await aureon.refreshWatchdog();
|
|
122
|
+
console.log("breaches", refreshed.breaches.length);
|
|
123
|
+
|
|
124
|
+
for (const breach of refreshed.breaches) {
|
|
125
|
+
const plan = await aureon.getRestorePlan(breach.objectiveId);
|
|
126
|
+
console.log("plan", plan.kind, plan);
|
|
127
|
+
|
|
128
|
+
const receipt = await aureon.restoreObjective(breach.objectiveId);
|
|
129
|
+
console.log({
|
|
130
|
+
settlement: receipt.settlement, // "vault" | "staged"
|
|
131
|
+
status: receipt.status,
|
|
132
|
+
tx: receipt.transactionHash,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const health = await aureon.getHealth();
|
|
137
|
+
return health;
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Step 6 — Verify
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
await aureon.getHealth(objective.id);
|
|
145
|
+
await aureon.getTimeline(objective.id);
|
|
146
|
+
await aureon.listExecutions(objective.id);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Always branch UI/agent copy on `receipt.settlement`.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 2. Recommended objective kinds for agents
|
|
154
|
+
|
|
155
|
+
| Kind | Typical use |
|
|
156
|
+
| --- | --- |
|
|
157
|
+
| `balanced_portfolio` | Hold `targetSymbol` near a weight band |
|
|
158
|
+
| `stable_allocation` | Keep a stable sleeve near a weight |
|
|
159
|
+
| `risk_ceiling` | Cap portfolio risk score |
|
|
160
|
+
| `reward_reinvestment` | Sweep rewards into a sleeve |
|
|
161
|
+
|
|
162
|
+
Start with one Automatic `balanced_portfolio` objective and a funded vault before adding more policies.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 3. Daemon runners
|
|
167
|
+
|
|
168
|
+
### PM2
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
module.exports = {
|
|
172
|
+
apps: [
|
|
173
|
+
{
|
|
174
|
+
name: "aureon-agent-loop",
|
|
175
|
+
script: "./dist/index.js",
|
|
176
|
+
instances: 1,
|
|
177
|
+
autorestart: true,
|
|
178
|
+
env: {
|
|
179
|
+
NODE_ENV: "production",
|
|
180
|
+
AUREON_API_URL: "https://api.aureonlabs.network",
|
|
181
|
+
// AUREON_API_KEY from secret store / PM2 ecosystem secrets
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
};
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### systemd
|
|
189
|
+
|
|
190
|
+
```ini
|
|
191
|
+
[Unit]
|
|
192
|
+
Description=AUREON Automatic restore agent
|
|
193
|
+
After=network.target
|
|
194
|
+
|
|
195
|
+
[Service]
|
|
196
|
+
Type=simple
|
|
197
|
+
User=node
|
|
198
|
+
WorkingDirectory=/home/node/app
|
|
199
|
+
ExecStart=/usr/bin/node dist/index.js
|
|
200
|
+
Restart=on-failure
|
|
201
|
+
RestartSec=10
|
|
202
|
+
Environment=NODE_ENV=production
|
|
203
|
+
|
|
204
|
+
[Install]
|
|
205
|
+
WantedBy=multi-user.target
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Logging
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { createAureonClient } from "@buildaureon/sdk";
|
|
212
|
+
|
|
213
|
+
const aureon = createAureonClient({
|
|
214
|
+
apiKey: process.env.AUREON_API_KEY!,
|
|
215
|
+
logger: {
|
|
216
|
+
debug: (msg, ctx) => console.debug(msg, ctx),
|
|
217
|
+
info: (msg, ctx) => console.info(msg, ctx),
|
|
218
|
+
warn: (msg, ctx) => console.warn(msg, ctx),
|
|
219
|
+
error: (msg, ctx) => console.error(msg, ctx),
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Never log API keys, Bearer tokens, or private keys.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## 4. Frontend / SPA notes
|
|
229
|
+
|
|
230
|
+
- Do not ship issued API keys in public browser bundles.
|
|
231
|
+
- Prefer a backend proxy for agent credentials.
|
|
232
|
+
- Keep `refreshWatchdog` / `restoreObjective` loops on the server.
|
|
233
|
+
- Browser operator UX is the utility app (wallet session), not the SDK agent path.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 5. Troubleshooting
|
|
238
|
+
|
|
239
|
+
| Symptom | Likely cause | Fix |
|
|
240
|
+
| --- | --- | --- |
|
|
241
|
+
| 401 invalid key | Wrong / paused / revoked key | Rotate in Developers |
|
|
242
|
+
| 401 need issued key | Env bootstrap key alone | Use an issued Developers key |
|
|
243
|
+
| Vault empty / cannot restore | No vault capital | `prepareVaultDeposit` → broadcast → sync |
|
|
244
|
+
| Update rejects symbol/mode | Locked at create | Recreate objective |
|
|
245
|
+
| Restore receipt `staged` | Ledger-local path | Do not claim on-chain |
|
|
246
|
+
| Health still violated after restore | Prices / sizing / liquidity | Re-read plan, vault balances, timeline |
|
|
247
|
+
| Network / timeout | RPC or API latency | Raise `timeoutMs`, set `maxRetries` |
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 6. Related docs
|
|
252
|
+
|
|
253
|
+
- [Auth](./auth.md)
|
|
254
|
+
- [Architecture](./architecture.md)
|
|
255
|
+
- [Client API](./client-api.md)
|
|
256
|
+
- [Error model](./error-model.md)
|
|
257
|
+
- [Security](./security.md)
|