@wzrd_sol/sdk 0.1.1 → 0.2.0
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 +2 -0
- package/dist/accounts.d.ts +13 -0
- package/dist/accounts.js +42 -1
- package/dist/accounts.test.d.ts +1 -0
- package/dist/accounts.test.js +47 -0
- package/dist/agent-auth.d.ts +89 -0
- package/dist/agent-auth.js +147 -0
- package/dist/agent-loop.d.ts +87 -0
- package/dist/agent-loop.js +388 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.js +13 -5
- package/dist/instructions.d.ts +551 -5
- package/dist/instructions.js +1466 -24
- package/dist/instructions.test.d.ts +7 -0
- package/dist/instructions.test.js +318 -0
- package/dist/model-selector.d.ts +141 -0
- package/dist/model-selector.js +247 -0
- package/dist/nav.d.ts +40 -0
- package/dist/nav.js +39 -0
- package/dist/nav.test.d.ts +4 -0
- package/dist/nav.test.js +98 -0
- package/dist/pda.d.ts +4 -0
- package/dist/pda.js +10 -1
- package/dist/stream.d.ts +88 -0
- package/dist/stream.js +220 -0
- package/dist/stream.test.d.ts +7 -0
- package/dist/stream.test.js +296 -0
- package/package.json +9 -3
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentLoop — turn any TypeScript agent into a WZRD earning agent.
|
|
3
|
+
*
|
|
4
|
+
* Ports the core earn loop from Python `wzrd.run_loop()` to TypeScript:
|
|
5
|
+
* 1. Auth via Ed25519 challenge/verify
|
|
6
|
+
* 2. Per task: fetchPick() (momentum API) -> agentInfer() -> agentReport()
|
|
7
|
+
* 3. Check earned -> relay claim if available
|
|
8
|
+
* 4. Sleep -> repeat
|
|
9
|
+
*
|
|
10
|
+
* Scoring parity with Python: confidence × action × trend × task-platform × quality.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { AgentLoop } from '@wzrd_sol/sdk';
|
|
15
|
+
* import { Keypair } from '@solana/web3.js';
|
|
16
|
+
*
|
|
17
|
+
* const loop = new AgentLoop({
|
|
18
|
+
* keypair: Keypair.fromSecretKey(secretKey),
|
|
19
|
+
* tasks: ['code', 'chat', 'reasoning'],
|
|
20
|
+
* cycleSeconds: 300,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* loop.start(); // runs forever, handles auth + infer + report + claim
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @module agent-loop
|
|
27
|
+
*/
|
|
28
|
+
import { agentAuth, agentInfer, agentReport, agentEarned, } from './agent-auth.js';
|
|
29
|
+
// ── Constants ────────────────────────────────────────────────────
|
|
30
|
+
const DEFAULT_TASKS = ['code', 'chat', 'reasoning'];
|
|
31
|
+
const DEFAULT_CYCLE_SECONDS = 300;
|
|
32
|
+
const MIN_CYCLE_SECONDS = 30;
|
|
33
|
+
const SESSION_REFRESH_CYCLES = 100;
|
|
34
|
+
// ── Helpers ──────────────────────────────────────────────────────
|
|
35
|
+
function timestamp() {
|
|
36
|
+
return new Date().toISOString().substring(11, 19);
|
|
37
|
+
}
|
|
38
|
+
function log(msg) {
|
|
39
|
+
console.log(`${timestamp()} [wzrd] ${msg}`);
|
|
40
|
+
}
|
|
41
|
+
function fmtCcm(raw) {
|
|
42
|
+
if (!raw)
|
|
43
|
+
return '0 CCM';
|
|
44
|
+
const human = Math.floor(raw / 1e9).toLocaleString();
|
|
45
|
+
return `${human} CCM`;
|
|
46
|
+
}
|
|
47
|
+
function sleep(ms) {
|
|
48
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
49
|
+
}
|
|
50
|
+
// Scoring weights — exact parity with Python client._TREND_WEIGHTS etc.
|
|
51
|
+
const TREND_WEIGHTS = {
|
|
52
|
+
surging: 3.0, accelerating: 2.0, stable: 1.0, onchain: 1.0,
|
|
53
|
+
insufficient_history: 0.8, decelerating: 0.5, cooling: 0.25,
|
|
54
|
+
};
|
|
55
|
+
const CONFIDENCE_WEIGHTS = {
|
|
56
|
+
normal: 1.0, high: 1.0, low: 0.6, insufficient: 0.35, unknown: 0.75,
|
|
57
|
+
};
|
|
58
|
+
const ACTION_WEIGHTS = {
|
|
59
|
+
pre_warm_urgent: 1.2, pre_warm: 1.1, candidate: 1.0, recommend: 1.0,
|
|
60
|
+
onchain: 1.0, route: 1.0, maintain: 0.9, prewarm: 0.95,
|
|
61
|
+
evaluate: 0.9, watch: 0.6, consider_deprovision: 0.3, observe: 0.25,
|
|
62
|
+
};
|
|
63
|
+
const TASK_PLATFORM_WEIGHTS = {
|
|
64
|
+
code: { github: 1.5, openrouter: 1.2, artificial_analysis: 1.1, huggingface: 1.0 },
|
|
65
|
+
coding: { github: 1.5, openrouter: 1.2, artificial_analysis: 1.1, huggingface: 1.0 },
|
|
66
|
+
chat: { openrouter: 1.5, artificial_analysis: 1.1, github: 0.8, huggingface: 1.0 },
|
|
67
|
+
conversation: { openrouter: 1.5, artificial_analysis: 1.1, github: 0.8, huggingface: 1.0 },
|
|
68
|
+
reasoning: { artificial_analysis: 1.5, openrouter: 1.2, github: 0.8, huggingface: 1.0 },
|
|
69
|
+
math: { artificial_analysis: 1.5, openrouter: 1.2, github: 0.8, huggingface: 1.0 },
|
|
70
|
+
};
|
|
71
|
+
const TRUSTED_CONFIDENCE = new Set(['normal', 'high']);
|
|
72
|
+
const RELAXED_CONFIDENCE = new Set(['normal', 'high', 'low']);
|
|
73
|
+
const CAP_MAP = {
|
|
74
|
+
code: 'code', coding: 'code', chat: 'chat', conversation: 'chat',
|
|
75
|
+
reasoning: 'reasoning', math: 'reasoning', vision: 'vision',
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Pick the top model for a task from the momentum API.
|
|
79
|
+
* Full parity with Python client._rank_signals() scoring:
|
|
80
|
+
* score × trend × confidence × action × task-platform × quality
|
|
81
|
+
*/
|
|
82
|
+
async function fetchPick(task, apiBase) {
|
|
83
|
+
try {
|
|
84
|
+
const resp = await fetch(`${apiBase}/v1/signals/momentum`);
|
|
85
|
+
if (!resp.ok)
|
|
86
|
+
return null;
|
|
87
|
+
const data = await resp.json();
|
|
88
|
+
const models = data.models ?? [];
|
|
89
|
+
if (models.length === 0)
|
|
90
|
+
return null;
|
|
91
|
+
// Step 1: Filter by capability
|
|
92
|
+
const requiredCap = CAP_MAP[task];
|
|
93
|
+
const capFiltered = requiredCap
|
|
94
|
+
? models.filter((m) => m.capabilities?.includes(requiredCap))
|
|
95
|
+
: models;
|
|
96
|
+
const afterCap = capFiltered.length > 0 ? capFiltered : models;
|
|
97
|
+
// Step 2: Filter by confidence + action (trusted → relaxed → all)
|
|
98
|
+
const trusted = afterCap.filter((m) => TRUSTED_CONFIDENCE.has(m.confidence) && m.action !== 'observe');
|
|
99
|
+
const relaxed = afterCap.filter((m) => RELAXED_CONFIDENCE.has(m.confidence) && m.action !== 'observe');
|
|
100
|
+
const pool = trusted.length > 0 ? trusted : relaxed.length > 0 ? relaxed : afterCap;
|
|
101
|
+
// Step 3: Score with full 5-layer weighting
|
|
102
|
+
const taskKey = task.toLowerCase().trim();
|
|
103
|
+
const platformWeights = TASK_PLATFORM_WEIGHTS[taskKey] ?? {};
|
|
104
|
+
const scored = pool.map((m) => {
|
|
105
|
+
const rawScore = m.score ?? 0;
|
|
106
|
+
let s = rawScore;
|
|
107
|
+
s *= TREND_WEIGHTS[m.trend] ?? 1.0;
|
|
108
|
+
s *= CONFIDENCE_WEIGHTS[m.confidence] ?? CONFIDENCE_WEIGHTS.unknown;
|
|
109
|
+
s *= ACTION_WEIGHTS[m.action] ?? 1.0;
|
|
110
|
+
s *= platformWeights[m.platform?.toLowerCase()] ?? 1.0;
|
|
111
|
+
if (m.quality_index != null && m.quality_index > 0) {
|
|
112
|
+
s *= 1.0 + (m.quality_index / 100.0) * 0.15;
|
|
113
|
+
}
|
|
114
|
+
const policy = TRUSTED_CONFIDENCE.has(m.confidence) && m.action !== 'observe'
|
|
115
|
+
? 'strict'
|
|
116
|
+
: RELAXED_CONFIDENCE.has(m.confidence) && m.action !== 'observe'
|
|
117
|
+
? 'relaxed'
|
|
118
|
+
: 'fallback';
|
|
119
|
+
return {
|
|
120
|
+
...m,
|
|
121
|
+
finalScore: s,
|
|
122
|
+
rawScore,
|
|
123
|
+
policy,
|
|
124
|
+
reason: `${policy} signal from ${m.platform || 'unknown'}${m.trend === 'surging' || m.trend === 'accelerating' ? ', ' + m.trend : ''}`,
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
scored.sort((a, b) => b.finalScore - a.finalScore);
|
|
128
|
+
return scored[0] ?? null;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// ── AgentLoop ────────────────────────────────────────────────────
|
|
135
|
+
/**
|
|
136
|
+
* Runs the WZRD earn loop: authenticate, pick models, infer, report, claim.
|
|
137
|
+
*
|
|
138
|
+
* Create one instance and call `start()`. The loop runs until `maxCycles`
|
|
139
|
+
* is reached or `stop()` is called. Handles SIGINT/SIGTERM for graceful
|
|
140
|
+
* shutdown.
|
|
141
|
+
*/
|
|
142
|
+
export class AgentLoop {
|
|
143
|
+
constructor(options) {
|
|
144
|
+
this.running = false;
|
|
145
|
+
this.token = null;
|
|
146
|
+
this.sleepResolve = null;
|
|
147
|
+
this.keypair = options.keypair;
|
|
148
|
+
this.tasks = options.tasks ?? DEFAULT_TASKS;
|
|
149
|
+
const cs = options.cycleSeconds ?? DEFAULT_CYCLE_SECONDS;
|
|
150
|
+
if (!Number.isFinite(cs))
|
|
151
|
+
throw new Error('cycleSeconds must be a finite number');
|
|
152
|
+
this.cycleSeconds = Math.max(cs, MIN_CYCLE_SECONDS);
|
|
153
|
+
this.maxCycles = options.maxCycles ?? 0;
|
|
154
|
+
this.claim = options.claim ?? true;
|
|
155
|
+
this.apiBase = options.apiBase ?? 'https://api.twzrd.xyz';
|
|
156
|
+
this.onCycle = options.onCycle;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Start the earn loop. Blocks until maxCycles is reached or stop() is called.
|
|
160
|
+
*/
|
|
161
|
+
async start() {
|
|
162
|
+
if (this.running)
|
|
163
|
+
throw new Error('AgentLoop is already running');
|
|
164
|
+
this.running = true;
|
|
165
|
+
const pubkey = this.keypair.publicKey.toBase58();
|
|
166
|
+
// Graceful shutdown on SIGINT/SIGTERM
|
|
167
|
+
const handleSignal = () => {
|
|
168
|
+
log('shutting down...');
|
|
169
|
+
this.stop();
|
|
170
|
+
};
|
|
171
|
+
if (typeof process !== 'undefined') {
|
|
172
|
+
process.on('SIGINT', handleSignal);
|
|
173
|
+
process.on('SIGTERM', handleSignal);
|
|
174
|
+
}
|
|
175
|
+
log(`agent: ${pubkey}`);
|
|
176
|
+
log(`tasks: ${this.tasks.join(', ')} | cycle: ${this.cycleSeconds}s`);
|
|
177
|
+
let cycle = 0;
|
|
178
|
+
let totalReports = 0;
|
|
179
|
+
let verifiedReports = 0;
|
|
180
|
+
let claimsMade = 0;
|
|
181
|
+
try {
|
|
182
|
+
while (this.running) {
|
|
183
|
+
if (this.maxCycles > 0 && cycle >= this.maxCycles) {
|
|
184
|
+
log(`max_cycles reached (${this.maxCycles}), stopping`);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
cycle++;
|
|
188
|
+
const cycleStart = Date.now();
|
|
189
|
+
const cycleResult = { cycle, tasks: [], earned: null, error: null };
|
|
190
|
+
try {
|
|
191
|
+
// Re-auth on first cycle and every SESSION_REFRESH_CYCLES
|
|
192
|
+
if (cycle === 1 || cycle % SESSION_REFRESH_CYCLES === 0) {
|
|
193
|
+
this.token = await agentAuth(this.keypair, this.apiBase);
|
|
194
|
+
log(`authenticated (session ${SESSION_REFRESH_CYCLES} cycles)`);
|
|
195
|
+
}
|
|
196
|
+
// Pick + infer + report per task
|
|
197
|
+
for (const task of this.tasks) {
|
|
198
|
+
if (!this.running)
|
|
199
|
+
break;
|
|
200
|
+
const taskResult = {
|
|
201
|
+
task,
|
|
202
|
+
model: null,
|
|
203
|
+
qualityScore: null,
|
|
204
|
+
executionId: null,
|
|
205
|
+
pendingCcm: 0,
|
|
206
|
+
};
|
|
207
|
+
try {
|
|
208
|
+
const pick = await fetchPick(task, this.apiBase);
|
|
209
|
+
if (!pick) {
|
|
210
|
+
log(`cycle ${cycle} | ${task} | no models available`);
|
|
211
|
+
cycleResult.tasks.push(taskResult);
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const model = pick.model;
|
|
215
|
+
taskResult.model = model;
|
|
216
|
+
// Server-witnessed inference
|
|
217
|
+
let infer = null;
|
|
218
|
+
try {
|
|
219
|
+
infer = await agentInfer(this.token, model, task, this.apiBase);
|
|
220
|
+
taskResult.executionId = infer.execution_id;
|
|
221
|
+
taskResult.qualityScore = infer.quality_score;
|
|
222
|
+
if (infer.execution_id) {
|
|
223
|
+
const costStr = infer.cost_usd ? `, $${infer.cost_usd.toFixed(4)}` : '';
|
|
224
|
+
log(`cycle ${cycle} | ${task} | infer via ${infer.provider ?? '?'} -> ` +
|
|
225
|
+
`${infer.executed_model ?? '?'} (q=${(infer.quality_score ?? 0).toFixed(2)}, ` +
|
|
226
|
+
`${infer.latency_ms ?? 0}ms${costStr})`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
log(`cycle ${cycle} | ${task} | infer failed (reporting without): ${e}`);
|
|
231
|
+
}
|
|
232
|
+
// Report the pick (with full metadata.wzrd block — parity with Python report_pick)
|
|
233
|
+
const reportResp = await agentReport(this.token, model, {
|
|
234
|
+
taskType: task,
|
|
235
|
+
executionId: infer?.execution_id,
|
|
236
|
+
qualityScore: infer?.quality_score,
|
|
237
|
+
latencyMs: infer?.latency_ms,
|
|
238
|
+
costUsd: infer?.cost_usd,
|
|
239
|
+
metadata: {
|
|
240
|
+
wzrd: {
|
|
241
|
+
source: 'wzrd-sdk',
|
|
242
|
+
model: pick.model,
|
|
243
|
+
signal_model: pick.model,
|
|
244
|
+
selected_model: pick.model,
|
|
245
|
+
score: pick.finalScore,
|
|
246
|
+
raw_score: pick.rawScore,
|
|
247
|
+
trend: pick.trend,
|
|
248
|
+
confidence: pick.confidence,
|
|
249
|
+
action: pick.action,
|
|
250
|
+
platform: pick.platform,
|
|
251
|
+
policy: pick.policy,
|
|
252
|
+
policy_version: '1.0',
|
|
253
|
+
reason: pick.reason,
|
|
254
|
+
candidate_rank: 0,
|
|
255
|
+
exploration: false,
|
|
256
|
+
run_id: pubkey.substring(0, 12),
|
|
257
|
+
cycle_id: cycle,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
}, this.apiBase);
|
|
261
|
+
totalReports++;
|
|
262
|
+
if (infer?.execution_id)
|
|
263
|
+
verifiedReports++;
|
|
264
|
+
const tag = infer?.execution_id ? 'V' : 'o';
|
|
265
|
+
taskResult.pendingCcm = reportResp.pending_ccm ?? 0;
|
|
266
|
+
log(`cycle ${cycle} | ${tag} ${task} -> ${model} | pending: ${fmtCcm(taskResult.pendingCcm)}`);
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
log(`cycle ${cycle} | ${task} | error: ${e}`);
|
|
270
|
+
}
|
|
271
|
+
cycleResult.tasks.push(taskResult);
|
|
272
|
+
}
|
|
273
|
+
// Check earned + claim
|
|
274
|
+
if (this.claim && this.running && this.token) {
|
|
275
|
+
try {
|
|
276
|
+
const earned = await agentEarned(this.token, this.apiBase);
|
|
277
|
+
cycleResult.earned = earned;
|
|
278
|
+
const pending = earned.pending_ccm ?? 0;
|
|
279
|
+
if (pending > 0) {
|
|
280
|
+
try {
|
|
281
|
+
const claimResp = await fetch(`${this.apiBase}/v1/claims/${pubkey}/relay`, {
|
|
282
|
+
method: 'POST',
|
|
283
|
+
headers: {
|
|
284
|
+
Authorization: `Bearer ${this.token}`,
|
|
285
|
+
'Content-Type': 'application/json',
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
if (claimResp.ok) {
|
|
289
|
+
const data = await claimResp.json();
|
|
290
|
+
if (data.tx_sig) {
|
|
291
|
+
claimsMade++;
|
|
292
|
+
const txShort = data.tx_sig.length > 20
|
|
293
|
+
? data.tx_sig.substring(0, 20) + '...'
|
|
294
|
+
: data.tx_sig;
|
|
295
|
+
log(`claimed ${fmtCcm(pending)} | tx: ${txShort}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
// relay unavailable or rate limited — try next cycle
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
// earned check failed — try next cycle
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
catch (e) {
|
|
310
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
311
|
+
cycleResult.error = msg;
|
|
312
|
+
log(`cycle ${cycle} failed: ${msg}`);
|
|
313
|
+
}
|
|
314
|
+
// Notify callback
|
|
315
|
+
if (this.onCycle) {
|
|
316
|
+
try {
|
|
317
|
+
this.onCycle(cycleResult);
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
// callback errors should not break the loop
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// Sleep until next cycle (cancellable via stop())
|
|
324
|
+
const elapsed = Date.now() - cycleStart;
|
|
325
|
+
const sleepMs = Math.max(0, this.cycleSeconds * 1000 - elapsed);
|
|
326
|
+
if (sleepMs > 0 && this.running) {
|
|
327
|
+
await new Promise((resolve) => {
|
|
328
|
+
this.sleepResolve = resolve;
|
|
329
|
+
const timer = setTimeout(() => { this.sleepResolve = null; resolve(); }, sleepMs);
|
|
330
|
+
// If stop() was called during setup, resolve immediately
|
|
331
|
+
if (!this.running) {
|
|
332
|
+
clearTimeout(timer);
|
|
333
|
+
this.sleepResolve = null;
|
|
334
|
+
resolve();
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
finally {
|
|
341
|
+
// Clean up signal handlers
|
|
342
|
+
if (typeof process !== 'undefined') {
|
|
343
|
+
process.removeListener('SIGINT', handleSignal);
|
|
344
|
+
process.removeListener('SIGTERM', handleSignal);
|
|
345
|
+
}
|
|
346
|
+
this.running = false;
|
|
347
|
+
}
|
|
348
|
+
// Session summary
|
|
349
|
+
log('------------------------------------------------');
|
|
350
|
+
log(`session complete: ${cycle} cycles`);
|
|
351
|
+
log(`reports: ${totalReports} total (${verifiedReports} verified, ${totalReports - verifiedReports} unverified)`);
|
|
352
|
+
if (claimsMade > 0) {
|
|
353
|
+
log(`claims: ${claimsMade}`);
|
|
354
|
+
}
|
|
355
|
+
// Final earned status
|
|
356
|
+
if (this.token) {
|
|
357
|
+
try {
|
|
358
|
+
const final_ = await agentEarned(this.token, this.apiBase);
|
|
359
|
+
const total = final_.total_earned_ccm ?? 0;
|
|
360
|
+
const pending = final_.pending_ccm ?? 0;
|
|
361
|
+
const parts = [];
|
|
362
|
+
parts.push(`${fmtCcm(total)} lifetime`);
|
|
363
|
+
if (pending > 0)
|
|
364
|
+
parts.push(`${fmtCcm(pending)} pending`);
|
|
365
|
+
if (final_.rank)
|
|
366
|
+
parts.push(`rank #${final_.rank}`);
|
|
367
|
+
if (final_.contribution_streak_days > 1) {
|
|
368
|
+
parts.push(`${final_.contribution_streak_days}-day streak`);
|
|
369
|
+
}
|
|
370
|
+
log(parts.join(' | '));
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
// best effort
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Signal the loop to stop after the current cycle completes.
|
|
379
|
+
*/
|
|
380
|
+
stop() {
|
|
381
|
+
this.running = false;
|
|
382
|
+
// Cancel any pending sleep so shutdown is immediate
|
|
383
|
+
if (this.sleepResolve) {
|
|
384
|
+
this.sleepResolve();
|
|
385
|
+
this.sleepResolve = null;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -14,3 +14,5 @@ export declare const MARKET_POSITION_SEED = "market_position";
|
|
|
14
14
|
export declare const GLOBAL_ROOT_SEED = "global_root";
|
|
15
15
|
export declare const CLAIM_STATE_GLOBAL_SEED = "claim_global";
|
|
16
16
|
export declare const CHANNEL_CONFIG_V2_SEED = "channel_cfg_v2";
|
|
17
|
+
export declare const STREAM_ROOT_SEED = "stream_root";
|
|
18
|
+
export declare const CLAIM_STATE_STREAM_SEED = "claim_stream";
|
package/dist/constants.js
CHANGED
|
@@ -17,3 +17,6 @@ export const MARKET_POSITION_SEED = 'market_position';
|
|
|
17
17
|
export const GLOBAL_ROOT_SEED = 'global_root';
|
|
18
18
|
export const CLAIM_STATE_GLOBAL_SEED = 'claim_global';
|
|
19
19
|
export const CHANNEL_CONFIG_V2_SEED = 'channel_cfg_v2';
|
|
20
|
+
// ── Stream (vLOFI distribution) PDA Seeds ────────────────
|
|
21
|
+
export const STREAM_ROOT_SEED = 'stream_root';
|
|
22
|
+
export const CLAIM_STATE_STREAM_SEED = 'claim_stream';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,18 @@
|
|
|
4
4
|
* PDA derivation, instruction builders, and account parsers for
|
|
5
5
|
* deposit_market, settle_market, and claim_global.
|
|
6
6
|
*/
|
|
7
|
-
export declare const VERSION = "0.1.
|
|
8
|
-
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants.js';
|
|
9
|
-
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda.js';
|
|
10
|
-
export type { MarketVaultData, MarketVaultFull, ProtocolStateData, OnChainPosition, } from './accounts.js';
|
|
11
|
-
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts.js';
|
|
12
|
-
export {
|
|
7
|
+
export declare const VERSION = "0.1.2";
|
|
8
|
+
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, STREAM_ROOT_SEED, CLAIM_STATE_STREAM_SEED, } from './constants.js';
|
|
9
|
+
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getStreamRootConfigPDA, getClaimStateStreamPDA, getAta, } from './pda.js';
|
|
10
|
+
export type { LifecyclePhase, LifecyclePhaseInput, MarketVaultData, MarketVaultFull, ProtocolStateData, OnChainPosition, } from './accounts.js';
|
|
11
|
+
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, deriveLifecyclePhase, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts.js';
|
|
12
|
+
export type { NavInfo } from './nav.js';
|
|
13
|
+
export { computeSharesForDeposit, computePrincipalForSettle, } from './nav.js';
|
|
14
|
+
export { anchorDisc, createAtaIdempotentIx, createDepositMarketIx, createMintSharesIx, createRedeemSharesIx, createSettlePredictionIx, createSettleMarketIx, createInitializeMarketVaultIx, createClaimGlobalV2Ix, createChannelConfigV2Ix, } from './instructions.js';
|
|
15
|
+
export { createPublishStreamRootIx, createClaimStreamIx, createClaimStreamSponsoredIx, } from './stream.js';
|
|
16
|
+
export type { BudgetTier, TaskType, VelocityTrend, Confidence, ModelRecommendation, ModelSelectorOptions, ModelSelectorConfig, } from './model-selector.js';
|
|
17
|
+
export { ModelSelector, bestModel } from './model-selector.js';
|
|
18
|
+
export type { ChallengeResponse, VerifyResponse, InferResponse, ReportResponse, EarnedResponse, } from './agent-auth.js';
|
|
19
|
+
export { agentAuth, agentChallenge, agentVerify, agentInfer, agentReport, agentEarned, } from './agent-auth.js';
|
|
20
|
+
export type { AgentLoopOptions, CycleResult } from './agent-loop.js';
|
|
21
|
+
export { AgentLoop } from './agent-loop.js';
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,19 @@
|
|
|
4
4
|
* PDA derivation, instruction builders, and account parsers for
|
|
5
5
|
* deposit_market, settle_market, and claim_global.
|
|
6
6
|
*/
|
|
7
|
-
export const VERSION = '0.1.
|
|
7
|
+
export const VERSION = '0.1.2';
|
|
8
8
|
// ── Constants ──────────────────────────────────────────
|
|
9
|
-
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants.js';
|
|
9
|
+
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, STREAM_ROOT_SEED, CLAIM_STATE_STREAM_SEED, } from './constants.js';
|
|
10
10
|
// ── PDA Derivation ─────────────────────────────────────
|
|
11
|
-
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda.js';
|
|
12
|
-
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts.js';
|
|
11
|
+
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getStreamRootConfigPDA, getClaimStateStreamPDA, getAta, } from './pda.js';
|
|
12
|
+
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, deriveLifecyclePhase, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts.js';
|
|
13
|
+
export { computeSharesForDeposit, computePrincipalForSettle, } from './nav.js';
|
|
13
14
|
// ── Instruction Builders ───────────────────────────────
|
|
14
|
-
export { anchorDisc, createAtaIdempotentIx, createDepositMarketIx,
|
|
15
|
+
export { anchorDisc, createAtaIdempotentIx, createDepositMarketIx, createMintSharesIx, createRedeemSharesIx, createSettlePredictionIx, createSettleMarketIx, createInitializeMarketVaultIx,
|
|
16
|
+
// V1 createClaimGlobalIx removed — all agents/consumers use V2 since root_seq 1707
|
|
17
|
+
createClaimGlobalV2Ix, createChannelConfigV2Ix, } from './instructions.js';
|
|
18
|
+
// ── Stream (vLOFI) Instruction Builders ──────────────────
|
|
19
|
+
export { createPublishStreamRootIx, createClaimStreamIx, createClaimStreamSponsoredIx, } from './stream.js';
|
|
20
|
+
export { ModelSelector, bestModel } from './model-selector.js';
|
|
21
|
+
export { agentAuth, agentChallenge, agentVerify, agentInfer, agentReport, agentEarned, } from './agent-auth.js';
|
|
22
|
+
export { AgentLoop } from './agent-loop.js';
|