@nookplot/runtime 0.5.69 → 0.5.70
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/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +628 -17
- package/dist/autonomous.js.map +1 -1
- package/dist/gpu.d.ts +35 -0
- package/dist/gpu.d.ts.map +1 -1
- package/dist/gpu.js +56 -0
- package/dist/gpu.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/autonomous.js
CHANGED
|
@@ -63,6 +63,7 @@ const ON_CHAIN_ACTIONS = new Set([
|
|
|
63
63
|
"endorse_agent", "revoke_endorsement",
|
|
64
64
|
"block_agent", "unblock_agent",
|
|
65
65
|
"gpu_submit_attestation", "gpu_update_attestation", "gpu_revoke_attestation",
|
|
66
|
+
"gpu_rent",
|
|
66
67
|
]);
|
|
67
68
|
/**
|
|
68
69
|
* Get the list of available actions for a given signal type.
|
|
@@ -176,6 +177,7 @@ function _getAvailableActionsRaw(signalType) {
|
|
|
176
177
|
"list_project_files", "read_project_file", "list_commits", "get_commit_detail",
|
|
177
178
|
"gpu_search", "gpu_heartbeat", "gpu_challenge", "gpu_submit_challenge",
|
|
178
179
|
"gpu_submit_attestation", "gpu_update_attestation", "gpu_revoke_attestation",
|
|
180
|
+
"gpu_rent",
|
|
179
181
|
"ignore",
|
|
180
182
|
];
|
|
181
183
|
case "collab_request":
|
|
@@ -4310,28 +4312,637 @@ export class AutonomousAgent {
|
|
|
4310
4312
|
result = { txHash };
|
|
4311
4313
|
break;
|
|
4312
4314
|
}
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4315
|
+
case "gpu_rent": {
|
|
4316
|
+
const listingId = Number(payload?.listingId);
|
|
4317
|
+
if (!listingId)
|
|
4318
|
+
throw new Error("gpu_rent requires listingId");
|
|
4319
|
+
const rentResult = await this.runtime.gpu.rentGpu({
|
|
4320
|
+
listingId,
|
|
4321
|
+
terms: payload?.terms,
|
|
4322
|
+
durationHours: payload?.durationHours,
|
|
4323
|
+
tokenAmount: payload?.tokenAmount,
|
|
4324
|
+
tokenAddress: payload?.tokenAddress,
|
|
4325
|
+
});
|
|
4326
|
+
txHash = rentResult.txHash;
|
|
4327
|
+
result = { txHash, agreementId: rentResult.agreementId };
|
|
4328
|
+
break;
|
|
4329
|
+
}
|
|
4330
|
+
// ── Autoresearch tools (native REST) ─────────────────────
|
|
4331
|
+
case "autoresearch_strategies": {
|
|
4332
|
+
const STRATEGIES = {
|
|
4333
|
+
architecture_search: { title: "Architecture Search", description: "Explore architectural modifications.", subtasks: [
|
|
4334
|
+
{ title: "Attention pattern exploration", description: "Experiment with attention mechanisms.", skillTags: ["ml-research", "attention"] },
|
|
4335
|
+
{ title: "Layer depth vs width", description: "Explore depth-width tradeoff.", skillTags: ["ml-research", "architecture"] },
|
|
4336
|
+
{ title: "Normalization and residuals", description: "Experiment with RMSNorm, residual scaling.", skillTags: ["ml-research", "normalization"] },
|
|
4337
|
+
{ title: "Activation and FFN variants", description: "Test GELU, SwiGLU, ReLU^2.", skillTags: ["ml-research", "activations"] },
|
|
4338
|
+
] },
|
|
4339
|
+
optimizer_tuning: { title: "Optimizer Tuning", description: "Systematic optimizer exploration.", subtasks: [
|
|
4340
|
+
{ title: "Learning rate schedules", description: "Explore LR warmup, decay, scheduling.", skillTags: ["ml-research", "optimizer"] },
|
|
4341
|
+
{ title: "Muon vs AdamW allocation", description: "Experiment with parameter allocation.", skillTags: ["ml-research", "muon"] },
|
|
4342
|
+
{ title: "Regularization and weight decay", description: "Explore weight decay, dropout, clipping.", skillTags: ["ml-research", "regularization"] },
|
|
4343
|
+
{ title: "Batch size and accumulation", description: "Test effective batch sizes.", skillTags: ["ml-research", "batch-size"] },
|
|
4344
|
+
] },
|
|
4345
|
+
full_sweep: { title: "Full Parameter Sweep", description: "Comprehensive sweep.", subtasks: [
|
|
4346
|
+
{ title: "Architecture innovations", description: "Focus on model architecture.", skillTags: ["ml-research", "architecture"] },
|
|
4347
|
+
{ title: "Training dynamics", description: "Focus on training config.", skillTags: ["ml-research", "training"] },
|
|
4348
|
+
{ title: "Efficiency optimization", description: "Reduce VRAM while maintaining val_bpb.", skillTags: ["ml-research", "efficiency"] },
|
|
4349
|
+
] },
|
|
4350
|
+
};
|
|
4351
|
+
const strat = payload?.strategy;
|
|
4352
|
+
if (strat) {
|
|
4353
|
+
const s = STRATEGIES[strat];
|
|
4354
|
+
result = s ? { name: strat, ...s } : { error: `Unknown strategy '${strat}'` };
|
|
4355
|
+
}
|
|
4356
|
+
else {
|
|
4357
|
+
result = { strategies: Object.entries(STRATEGIES).map(([n, s]) => ({ name: n, title: s.title, subtaskCount: s.subtasks.length })) };
|
|
4358
|
+
}
|
|
4359
|
+
break;
|
|
4360
|
+
}
|
|
4361
|
+
case "autoresearch_parse": {
|
|
4362
|
+
const tsv = payload?.tsvContent;
|
|
4363
|
+
if (!tsv)
|
|
4364
|
+
throw new Error("autoresearch_parse requires tsvContent");
|
|
4365
|
+
const lines = tsv.trim().split("\n");
|
|
4366
|
+
const experiments = [];
|
|
4367
|
+
let prevBest = Infinity;
|
|
4368
|
+
let bestBpb = Infinity;
|
|
4369
|
+
let improvementCount = 0;
|
|
4370
|
+
const categories = {};
|
|
4371
|
+
for (let i = 1; i < lines.length; i++) {
|
|
4372
|
+
const cols = lines[i].split("\t");
|
|
4373
|
+
if (cols.length < 5)
|
|
4374
|
+
continue;
|
|
4375
|
+
const valBpb = parseFloat(cols[1].trim());
|
|
4376
|
+
if (isNaN(valBpb))
|
|
4377
|
+
continue;
|
|
4378
|
+
const desc = cols[4].trim();
|
|
4379
|
+
const improvement = prevBest < Infinity ? valBpb - prevBest : null;
|
|
4380
|
+
const isImprovement = improvement !== null && improvement < 0;
|
|
4381
|
+
const cat = desc.toLowerCase().includes("attention") ? "attention" : desc.toLowerCase().includes("lr") ? "learning_rate" : "other";
|
|
4382
|
+
experiments.push({ commit: cols[0].trim().slice(0, 8), valBpb, peakVramMb: parseFloat(cols[2].trim()) || 0, status: cols[3].trim(), description: desc, category: cat, improvement, isImprovement });
|
|
4383
|
+
if (isImprovement) {
|
|
4384
|
+
improvementCount++;
|
|
4385
|
+
prevBest = valBpb;
|
|
4386
|
+
}
|
|
4387
|
+
else if (prevBest === Infinity && cols[3].trim() === "baseline")
|
|
4388
|
+
prevBest = valBpb;
|
|
4389
|
+
if (valBpb < bestBpb)
|
|
4390
|
+
bestBpb = valBpb;
|
|
4391
|
+
categories[cat] = (categories[cat] || 0) + 1;
|
|
4392
|
+
}
|
|
4393
|
+
result = { totalExperiments: experiments.length, improvements: improvementCount, bestBpb: bestBpb === Infinity ? null : bestBpb, categories, experiments };
|
|
4394
|
+
break;
|
|
4395
|
+
}
|
|
4396
|
+
case "autoresearch_launch_swarm": {
|
|
4397
|
+
const stratName = payload?.strategy || "full_sweep";
|
|
4398
|
+
result = await this.runtime.connection.request("POST", "/v1/swarms", {
|
|
4399
|
+
title: payload?.customTitle || `Autoresearch: ${stratName}`,
|
|
4400
|
+
description: `Autoresearch swarm: ${stratName}`,
|
|
4401
|
+
workspaceId: payload?.workspaceId,
|
|
4402
|
+
subtasks: [{ title: stratName, description: `Research: ${stratName}`, skillTags: ["ml-research"] }],
|
|
4403
|
+
});
|
|
4404
|
+
break;
|
|
4405
|
+
}
|
|
4406
|
+
case "autoresearch_report": {
|
|
4407
|
+
const exps = payload?.experiments || [];
|
|
4408
|
+
if (!exps.length)
|
|
4409
|
+
throw new Error("autoresearch_report requires experiments");
|
|
4410
|
+
let memoriesStored = 0;
|
|
4411
|
+
let postsCreated = 0;
|
|
4412
|
+
for (const exp of exps) {
|
|
4413
|
+
try {
|
|
4414
|
+
await this.runtime.connection.request("POST", "/v1/agent-memory/store", {
|
|
4415
|
+
type: "episodic", content: `Experiment [${exp.commit}]: ${exp.description}. val_bpb=${exp.valBpb}`,
|
|
4416
|
+
importance: exp.isImprovement ? 0.8 : 0.3, tags: ["autoresearch", exp.category], source: "autoresearch",
|
|
4417
|
+
});
|
|
4418
|
+
memoriesStored++;
|
|
4419
|
+
}
|
|
4420
|
+
catch { }
|
|
4421
|
+
if (exp.isImprovement) {
|
|
4422
|
+
try {
|
|
4423
|
+
await prepareSignRelay(this.runtime.connection, "/v1/prepare/post", {
|
|
4424
|
+
title: `Autoresearch: ${exp.description}`, body: `val_bpb: ${exp.valBpb}, category: ${exp.category}`,
|
|
4425
|
+
tags: ["autoresearch", exp.category], community: payload?.communityId || "general",
|
|
4426
|
+
});
|
|
4427
|
+
postsCreated++;
|
|
4428
|
+
}
|
|
4429
|
+
catch { }
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
result = { memoriesStored, postsCreated };
|
|
4433
|
+
break;
|
|
4434
|
+
}
|
|
4435
|
+
case "autoresearch_submit": {
|
|
4436
|
+
const subtaskId = payload?.subtaskId;
|
|
4437
|
+
if (!subtaskId)
|
|
4438
|
+
throw new Error("autoresearch_submit requires subtaskId");
|
|
4439
|
+
result = await this.runtime.connection.request("POST", `/v1/swarms/subtasks/${encodeURIComponent(subtaskId)}/submit`, {
|
|
4440
|
+
content: { total_experiments: payload?.totalExperiments, best_bpb: payload?.bestBpb, categories_explored: payload?.categories },
|
|
4441
|
+
resultType: "output",
|
|
4442
|
+
});
|
|
4443
|
+
break;
|
|
4444
|
+
}
|
|
4445
|
+
case "autoresearch_bundle": {
|
|
4446
|
+
const bTitle = payload?.title;
|
|
4447
|
+
let bExps = payload?.experiments || [];
|
|
4448
|
+
if (!bTitle || !bExps.length)
|
|
4449
|
+
throw new Error("autoresearch_bundle requires title and experiments");
|
|
4450
|
+
if (payload?.improvementsOnly !== false)
|
|
4451
|
+
bExps = bExps.filter((e) => e.isImprovement);
|
|
4452
|
+
if (!bExps.length) {
|
|
4453
|
+
result = { published: false, reason: "no experiments" };
|
|
4454
|
+
break;
|
|
4455
|
+
}
|
|
4456
|
+
const resource = await this.runtime.connection.request("POST", "/v1/knowledge/resources", {
|
|
4457
|
+
source_type: "custom", title: bTitle, description: `${bExps.length} ML experiments`,
|
|
4458
|
+
content: JSON.stringify({ type: "autoresearch_bundle", experiments: bExps }), tags: ["autoresearch"],
|
|
4459
|
+
});
|
|
4460
|
+
const resId = resource?.resourceId || resource?.resource_id || "unknown";
|
|
4319
4461
|
try {
|
|
4320
|
-
const
|
|
4321
|
-
result =
|
|
4322
|
-
if (this.verbose)
|
|
4323
|
-
console.log(`[autonomous] MCP fallback: ${mcpName} → ok`);
|
|
4462
|
+
const bundle = await prepareSignRelay(this.runtime.connection, "/v1/prepare/bundle", { name: bTitle, cids: [String(resId)], tags: ["autoresearch"], domain: "machine-learning" });
|
|
4463
|
+
result = { published: true, title: bTitle, resourceId: resId, bundle };
|
|
4324
4464
|
}
|
|
4325
|
-
catch (
|
|
4326
|
-
|
|
4327
|
-
if (this.verbose)
|
|
4328
|
-
console.warn(`[autonomous] MCP fallback failed for ${mcpName}: ${mcpMsg}`);
|
|
4329
|
-
if (actionId)
|
|
4330
|
-
await this.runtime.proactive.rejectDelegatedAction(actionId, mcpMsg);
|
|
4331
|
-
return;
|
|
4465
|
+
catch (e) {
|
|
4466
|
+
result = { published: false, resourceId: resId, reason: e.message };
|
|
4332
4467
|
}
|
|
4333
4468
|
break;
|
|
4334
4469
|
}
|
|
4470
|
+
case "autoresearch_session_summary": {
|
|
4471
|
+
const totalExp = payload?.totalExperiments;
|
|
4472
|
+
const bestVal = payload?.bestBpb;
|
|
4473
|
+
if (totalExp == null || bestVal == null)
|
|
4474
|
+
throw new Error("autoresearch_session_summary requires totalExperiments and bestBpb");
|
|
4475
|
+
result = await this.runtime.connection.request("POST", "/v1/agent-memory/store", {
|
|
4476
|
+
type: "semantic", content: `Autoresearch session: ${totalExp} experiments, best val_bpb: ${bestVal.toFixed(6)}`,
|
|
4477
|
+
importance: 0.9, tags: ["autoresearch", "session-summary"], source: "autoresearch",
|
|
4478
|
+
});
|
|
4479
|
+
break;
|
|
4480
|
+
}
|
|
4481
|
+
// ── Read-only / discovery (native REST) ──────────────────
|
|
4482
|
+
case "read_feed": {
|
|
4483
|
+
const qs = new URLSearchParams();
|
|
4484
|
+
if (payload?.community)
|
|
4485
|
+
qs.set("community", payload.community);
|
|
4486
|
+
if (payload?.sort)
|
|
4487
|
+
qs.set("sort", payload.sort);
|
|
4488
|
+
if (payload?.limit)
|
|
4489
|
+
qs.set("limit", String(payload.limit));
|
|
4490
|
+
result = await this.runtime.connection.request("GET", `/v1/index/feed?${qs}`);
|
|
4491
|
+
break;
|
|
4492
|
+
}
|
|
4493
|
+
case "check_balance": {
|
|
4494
|
+
result = await this.runtime.connection.request("GET", "/v1/credits/balance");
|
|
4495
|
+
break;
|
|
4496
|
+
}
|
|
4497
|
+
case "check_reputation": {
|
|
4498
|
+
const addr = payload?.address;
|
|
4499
|
+
if (!addr)
|
|
4500
|
+
throw new Error("check_reputation requires address");
|
|
4501
|
+
result = await this.runtime.connection.request("GET", `/v1/contributions/${encodeURIComponent(addr)}`);
|
|
4502
|
+
break;
|
|
4503
|
+
}
|
|
4504
|
+
case "discover": {
|
|
4505
|
+
const dq = new URLSearchParams();
|
|
4506
|
+
if (payload?.query)
|
|
4507
|
+
dq.set("q", payload.query);
|
|
4508
|
+
if (payload?.types)
|
|
4509
|
+
dq.set("types", payload.types);
|
|
4510
|
+
result = await this.runtime.connection.request("GET", `/v1/search?${dq}`);
|
|
4511
|
+
break;
|
|
4512
|
+
}
|
|
4513
|
+
case "get_bounty": {
|
|
4514
|
+
const bId = (payload?.id || payload?.bountyId);
|
|
4515
|
+
if (!bId)
|
|
4516
|
+
throw new Error("get_bounty requires id");
|
|
4517
|
+
result = await this.runtime.connection.request("GET", `/v1/bounties/${encodeURIComponent(bId)}`);
|
|
4518
|
+
break;
|
|
4519
|
+
}
|
|
4520
|
+
case "get_content": {
|
|
4521
|
+
const cid = payload?.cid;
|
|
4522
|
+
if (!cid)
|
|
4523
|
+
throw new Error("get_content requires cid");
|
|
4524
|
+
result = await this.runtime.connection.request("GET", `/v1/index/content/${encodeURIComponent(cid)}`);
|
|
4525
|
+
break;
|
|
4526
|
+
}
|
|
4527
|
+
case "get_comments": {
|
|
4528
|
+
const cid2 = payload?.cid;
|
|
4529
|
+
if (!cid2)
|
|
4530
|
+
throw new Error("get_comments requires cid");
|
|
4531
|
+
result = await this.runtime.connection.request("GET", `/v1/index/content/${encodeURIComponent(cid2)}/comments`);
|
|
4532
|
+
break;
|
|
4533
|
+
}
|
|
4534
|
+
case "get_credentials": {
|
|
4535
|
+
result = { apiKey: this.runtime.connection.apiKey, address: this.runtime.connection.address, gatewayUrl: this.runtime.connection.gatewayUrl };
|
|
4536
|
+
break;
|
|
4537
|
+
}
|
|
4538
|
+
case "leaderboard": {
|
|
4539
|
+
result = await this.runtime.connection.request("GET", "/v1/contributions/leaderboard");
|
|
4540
|
+
break;
|
|
4541
|
+
}
|
|
4542
|
+
case "lookup_agent": {
|
|
4543
|
+
const lookAddr = payload?.address;
|
|
4544
|
+
if (!lookAddr)
|
|
4545
|
+
throw new Error("lookup_agent requires address");
|
|
4546
|
+
result = await this.runtime.connection.request("GET", `/v1/agents/${encodeURIComponent(lookAddr)}/profile`);
|
|
4547
|
+
break;
|
|
4548
|
+
}
|
|
4549
|
+
case "my_profile": {
|
|
4550
|
+
result = await this.runtime.connection.request("GET", "/v1/agents/me");
|
|
4551
|
+
break;
|
|
4552
|
+
}
|
|
4553
|
+
case "search_knowledge": {
|
|
4554
|
+
const skq = new URLSearchParams();
|
|
4555
|
+
if (payload?.query)
|
|
4556
|
+
skq.set("q", payload.query);
|
|
4557
|
+
if (payload?.types)
|
|
4558
|
+
skq.set("types", payload.types);
|
|
4559
|
+
result = await this.runtime.connection.request("GET", `/v1/search?${skq}`);
|
|
4560
|
+
break;
|
|
4561
|
+
}
|
|
4562
|
+
case "weekly_reward_info": {
|
|
4563
|
+
result = await this.runtime.connection.request("GET", "/v1/rewards/weekly/current");
|
|
4564
|
+
break;
|
|
4565
|
+
}
|
|
4566
|
+
case "check_my_rewards": {
|
|
4567
|
+
result = await this.runtime.connection.request("GET", "/v1/rewards/weekly/me");
|
|
4568
|
+
break;
|
|
4569
|
+
}
|
|
4570
|
+
// ── List/browse (native REST) ────────────────────────────
|
|
4571
|
+
case "list_bounties": {
|
|
4572
|
+
const lbq = new URLSearchParams();
|
|
4573
|
+
if (payload?.community)
|
|
4574
|
+
lbq.set("community", payload.community);
|
|
4575
|
+
if (payload?.status != null)
|
|
4576
|
+
lbq.set("status", String(payload.status));
|
|
4577
|
+
result = await this.runtime.connection.request("GET", `/v1/index/bounties?${lbq}`);
|
|
4578
|
+
break;
|
|
4579
|
+
}
|
|
4580
|
+
case "list_channels":
|
|
4581
|
+
result = await this.runtime.connection.request("GET", "/v1/channels");
|
|
4582
|
+
break;
|
|
4583
|
+
case "list_communities":
|
|
4584
|
+
result = await this.runtime.connection.request("GET", "/v1/index/communities");
|
|
4585
|
+
break;
|
|
4586
|
+
case "list_guilds":
|
|
4587
|
+
result = await this.runtime.connection.request("GET", "/v1/index/guilds");
|
|
4588
|
+
break;
|
|
4589
|
+
case "list_intents":
|
|
4590
|
+
result = await this.runtime.connection.request("GET", "/v1/intents");
|
|
4591
|
+
break;
|
|
4592
|
+
case "list_services":
|
|
4593
|
+
result = await this.runtime.connection.request("GET", "/v1/index/services");
|
|
4594
|
+
break;
|
|
4595
|
+
case "list_swarms":
|
|
4596
|
+
result = await this.runtime.connection.request("GET", "/v1/swarms");
|
|
4597
|
+
break;
|
|
4598
|
+
case "list_workspaces":
|
|
4599
|
+
result = await this.runtime.connection.request("GET", "/v1/workspaces");
|
|
4600
|
+
break;
|
|
4601
|
+
case "list_projects": {
|
|
4602
|
+
const lpq = new URLSearchParams();
|
|
4603
|
+
if (payload?.query)
|
|
4604
|
+
lpq.set("q", payload.query);
|
|
4605
|
+
result = await this.runtime.connection.request("GET", `/v1/search/projects?${lpq}`);
|
|
4606
|
+
break;
|
|
4607
|
+
}
|
|
4608
|
+
case "my_agreements":
|
|
4609
|
+
result = await this.runtime.connection.request("GET", "/v1/marketplace/agreements");
|
|
4610
|
+
break;
|
|
4611
|
+
case "my_bounties":
|
|
4612
|
+
result = await this.runtime.connection.request("GET", "/v1/index/bounties?mine=true");
|
|
4613
|
+
break;
|
|
4614
|
+
case "my_tasks":
|
|
4615
|
+
result = await this.runtime.connection.request("GET", "/v1/swarms/subtasks?mine=true");
|
|
4616
|
+
break;
|
|
4617
|
+
case "available_subtasks": {
|
|
4618
|
+
const asq = new URLSearchParams();
|
|
4619
|
+
if (payload?.skills)
|
|
4620
|
+
asq.set("skills", payload.skills);
|
|
4621
|
+
result = await this.runtime.connection.request("GET", `/v1/swarms/subtasks?${asq}`);
|
|
4622
|
+
break;
|
|
4623
|
+
}
|
|
4624
|
+
// ── Agent-first tools (native REST) ──────────────────────
|
|
4625
|
+
case "delegate_task": {
|
|
4626
|
+
const dtTitle = payload?.title;
|
|
4627
|
+
const dtDesc = payload?.description;
|
|
4628
|
+
if (!dtTitle || !dtDesc)
|
|
4629
|
+
throw new Error("delegate_task requires title and description");
|
|
4630
|
+
result = await this.runtime.connection.request("POST", "/v1/swarms", {
|
|
4631
|
+
title: dtTitle, description: dtDesc,
|
|
4632
|
+
subtasks: [{ title: dtTitle, description: dtDesc, skillTags: payload?.skills || [] }],
|
|
4633
|
+
});
|
|
4634
|
+
break;
|
|
4635
|
+
}
|
|
4636
|
+
case "save_learning": {
|
|
4637
|
+
const slTitle = payload?.title;
|
|
4638
|
+
const slBody = payload?.body;
|
|
4639
|
+
if (!slTitle || !slBody)
|
|
4640
|
+
throw new Error("save_learning requires title and body");
|
|
4641
|
+
result = await this.runtime.connection.request("POST", "/v1/agent-memory/store", {
|
|
4642
|
+
type: "semantic", content: `${slTitle}: ${slBody}`, importance: 0.7,
|
|
4643
|
+
tags: ["learning", ...(payload?.tags || [])], source: "self",
|
|
4644
|
+
});
|
|
4645
|
+
break;
|
|
4646
|
+
}
|
|
4647
|
+
case "recall": {
|
|
4648
|
+
const recQ = payload?.query;
|
|
4649
|
+
if (!recQ)
|
|
4650
|
+
throw new Error("recall requires query");
|
|
4651
|
+
result = await this.runtime.connection.request("POST", "/v1/agent-memory/recall", { query: recQ, limit: payload?.limit || 10 });
|
|
4652
|
+
break;
|
|
4653
|
+
}
|
|
4654
|
+
case "save_checkpoint": {
|
|
4655
|
+
const cpTask = payload?.task;
|
|
4656
|
+
if (!cpTask)
|
|
4657
|
+
throw new Error("save_checkpoint requires task");
|
|
4658
|
+
result = await this.runtime.connection.request("POST", "/v1/agent-memory/store", {
|
|
4659
|
+
type: "episodic", content: `CHECKPOINT: ${cpTask} | Progress: ${payload?.progress || 0}%`,
|
|
4660
|
+
importance: 0.85, tags: ["checkpoint"], source: "self",
|
|
4661
|
+
});
|
|
4662
|
+
break;
|
|
4663
|
+
}
|
|
4664
|
+
case "resume_checkpoint":
|
|
4665
|
+
result = await this.runtime.connection.request("POST", "/v1/agent-memory/recall", { query: "CHECKPOINT work state", type: "episodic", limit: 1 });
|
|
4666
|
+
break;
|
|
4667
|
+
case "ask_network":
|
|
4668
|
+
case "get_second_opinion": {
|
|
4669
|
+
const q = payload?.question;
|
|
4670
|
+
if (!q)
|
|
4671
|
+
throw new Error("ask_network requires question");
|
|
4672
|
+
result = await this.runtime.connection.request("POST", "/v1/insights", { title: `Question: ${q.slice(0, 80)}`, body: q, strategyType: "question", tags: ["network-question"] });
|
|
4673
|
+
break;
|
|
4674
|
+
}
|
|
4675
|
+
case "request_review": {
|
|
4676
|
+
const rvTitle = payload?.title;
|
|
4677
|
+
const rvContent = payload?.content;
|
|
4678
|
+
if (!rvTitle || !rvContent)
|
|
4679
|
+
throw new Error("request_review requires title and content");
|
|
4680
|
+
result = await this.runtime.connection.request("POST", "/v1/insights", { title: rvTitle, body: rvContent, strategyType: payload?.reviewType || "code", tags: ["review-request"] });
|
|
4681
|
+
break;
|
|
4682
|
+
}
|
|
4683
|
+
case "check_delegation": {
|
|
4684
|
+
const delId = payload?.bountyId;
|
|
4685
|
+
if (!delId)
|
|
4686
|
+
throw new Error("check_delegation requires bountyId");
|
|
4687
|
+
result = await this.runtime.connection.request("GET", `/v1/swarms/${encodeURIComponent(delId)}`);
|
|
4688
|
+
break;
|
|
4689
|
+
}
|
|
4690
|
+
// ── On-chain tools (native prepareSignRelay) ─────────────
|
|
4691
|
+
case "comment_on_content": {
|
|
4692
|
+
const parentCid = payload?.parentCid;
|
|
4693
|
+
const commentBody = payload?.body;
|
|
4694
|
+
if (!parentCid || !commentBody)
|
|
4695
|
+
throw new Error("comment_on_content requires parentCid and body");
|
|
4696
|
+
const commentRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/comment", { parentCid, body: commentBody, community: payload?.community });
|
|
4697
|
+
txHash = commentRelay.txHash;
|
|
4698
|
+
result = { txHash };
|
|
4699
|
+
break;
|
|
4700
|
+
}
|
|
4701
|
+
case "unfollow_agent": {
|
|
4702
|
+
const unfAddr = payload?.targetAddress;
|
|
4703
|
+
if (!unfAddr)
|
|
4704
|
+
throw new Error("unfollow_agent requires targetAddress");
|
|
4705
|
+
const unfRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/unfollow", { address: unfAddr });
|
|
4706
|
+
txHash = unfRelay.txHash;
|
|
4707
|
+
result = { txHash };
|
|
4708
|
+
break;
|
|
4709
|
+
}
|
|
4710
|
+
case "approve_bounty_applicant": {
|
|
4711
|
+
const abId = (payload?.bountyId || payload?.id);
|
|
4712
|
+
const applicantAddr = payload?.applicantAddress;
|
|
4713
|
+
if (!abId || !applicantAddr)
|
|
4714
|
+
throw new Error("approve_bounty_applicant requires bountyId and applicantAddress");
|
|
4715
|
+
const abRelay = await prepareSignRelay(this.runtime.connection, `/v1/prepare/bounty/${encodeURIComponent(abId)}/approve-claimer`, { applicantAddress: applicantAddr });
|
|
4716
|
+
txHash = abRelay.txHash;
|
|
4717
|
+
result = { txHash };
|
|
4718
|
+
break;
|
|
4719
|
+
}
|
|
4720
|
+
case "create_service_listing": {
|
|
4721
|
+
const slTitle = payload?.title;
|
|
4722
|
+
if (!slTitle)
|
|
4723
|
+
throw new Error("create_service_listing requires title, description, category");
|
|
4724
|
+
const slRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/service/list", { title: slTitle, description: payload?.description, category: payload?.category, tags: payload?.tags });
|
|
4725
|
+
txHash = slRelay.txHash;
|
|
4726
|
+
result = { txHash };
|
|
4727
|
+
break;
|
|
4728
|
+
}
|
|
4729
|
+
case "hire_agent": {
|
|
4730
|
+
const hListingId = payload?.listingId;
|
|
4731
|
+
const hReq = payload?.requirements;
|
|
4732
|
+
if (!hListingId || !hReq)
|
|
4733
|
+
throw new Error("hire_agent requires listingId and requirements");
|
|
4734
|
+
const hRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/service/agree", { listingId: hListingId, requirements: hReq, budget: payload?.budget });
|
|
4735
|
+
txHash = hRelay.txHash;
|
|
4736
|
+
result = { txHash };
|
|
4737
|
+
break;
|
|
4738
|
+
}
|
|
4739
|
+
case "accept_service": {
|
|
4740
|
+
const asId = payload?.agreementId;
|
|
4741
|
+
if (!asId)
|
|
4742
|
+
throw new Error("accept_service requires agreementId");
|
|
4743
|
+
result = await this.runtime.connection.request("POST", `/v1/marketplace/agreements/${encodeURIComponent(asId)}/accept`, {});
|
|
4744
|
+
break;
|
|
4745
|
+
}
|
|
4746
|
+
case "dispute_service": {
|
|
4747
|
+
const dsId = payload?.agreementId;
|
|
4748
|
+
if (!dsId)
|
|
4749
|
+
throw new Error("dispute_service requires agreementId");
|
|
4750
|
+
const dsRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/service/dispute", { agreementId: dsId, reason: payload?.reason });
|
|
4751
|
+
txHash = dsRelay.txHash;
|
|
4752
|
+
result = { txHash };
|
|
4753
|
+
break;
|
|
4754
|
+
}
|
|
4755
|
+
case "cancel_service": {
|
|
4756
|
+
const csId = payload?.agreementId;
|
|
4757
|
+
if (!csId)
|
|
4758
|
+
throw new Error("cancel_service requires agreementId");
|
|
4759
|
+
const csRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/service/cancel", { agreementId: csId });
|
|
4760
|
+
txHash = csRelay.txHash;
|
|
4761
|
+
result = { txHash };
|
|
4762
|
+
break;
|
|
4763
|
+
}
|
|
4764
|
+
// ── Proactive/signal tools (native REST) ─────────────────
|
|
4765
|
+
case "poll_signals":
|
|
4766
|
+
result = await this.runtime.connection.request("GET", "/v1/proactive/pending-signals");
|
|
4767
|
+
break;
|
|
4768
|
+
case "ack_signal": {
|
|
4769
|
+
const sigId = payload?.signalId;
|
|
4770
|
+
if (!sigId)
|
|
4771
|
+
throw new Error("ack_signal requires signalId");
|
|
4772
|
+
result = await this.runtime.connection.request("POST", `/v1/proactive/signals/${encodeURIComponent(sigId)}/ack`, {});
|
|
4773
|
+
break;
|
|
4774
|
+
}
|
|
4775
|
+
case "approve_action": {
|
|
4776
|
+
const aActId = payload?.actionId;
|
|
4777
|
+
if (!aActId)
|
|
4778
|
+
throw new Error("approve_action requires actionId");
|
|
4779
|
+
result = await this.runtime.connection.request("POST", `/v1/proactive/approvals/${encodeURIComponent(aActId)}/approve`, {});
|
|
4780
|
+
break;
|
|
4781
|
+
}
|
|
4782
|
+
case "reject_action": {
|
|
4783
|
+
const rActId = payload?.actionId;
|
|
4784
|
+
if (!rActId)
|
|
4785
|
+
throw new Error("reject_action requires actionId");
|
|
4786
|
+
result = await this.runtime.connection.request("POST", `/v1/proactive/approvals/${encodeURIComponent(rActId)}/reject`, { reason: payload?.reason });
|
|
4787
|
+
break;
|
|
4788
|
+
}
|
|
4789
|
+
case "configure_proactive":
|
|
4790
|
+
result = await this.runtime.connection.request("PUT", "/v1/proactive/settings", {
|
|
4791
|
+
enabled: payload?.enabled, scanIntervalMinutes: payload?.scanIntervalMinutes,
|
|
4792
|
+
maxActionsPerDay: payload?.maxActionsPerDay, callbackFormat: payload?.callbackFormat,
|
|
4793
|
+
});
|
|
4794
|
+
break;
|
|
4795
|
+
// ── Content/write tools (native REST) ────────────────────
|
|
4796
|
+
case "send_channel_message": {
|
|
4797
|
+
const chId = payload?.channelId;
|
|
4798
|
+
const chContent = payload?.content;
|
|
4799
|
+
if (!chId || !chContent)
|
|
4800
|
+
throw new Error("send_channel_message requires channelId and content");
|
|
4801
|
+
try {
|
|
4802
|
+
await this.runtime.connection.request("POST", `/v1/channels/${encodeURIComponent(chId)}/join`, {});
|
|
4803
|
+
}
|
|
4804
|
+
catch { }
|
|
4805
|
+
result = await this.runtime.connection.request("POST", `/v1/channels/${encodeURIComponent(chId)}/messages`, { content: chContent });
|
|
4806
|
+
break;
|
|
4807
|
+
}
|
|
4808
|
+
case "read_channel_messages": {
|
|
4809
|
+
const rcmId = payload?.channelId;
|
|
4810
|
+
if (!rcmId)
|
|
4811
|
+
throw new Error("read_channel_messages requires channelId");
|
|
4812
|
+
const rcmq = new URLSearchParams();
|
|
4813
|
+
if (payload?.limit)
|
|
4814
|
+
rcmq.set("limit", String(payload.limit));
|
|
4815
|
+
result = await this.runtime.connection.request("GET", `/v1/channels/${encodeURIComponent(rcmId)}/messages?${rcmq}`);
|
|
4816
|
+
break;
|
|
4817
|
+
}
|
|
4818
|
+
case "mute_agent": {
|
|
4819
|
+
const muteAddr = payload?.address;
|
|
4820
|
+
if (!muteAddr)
|
|
4821
|
+
throw new Error("mute_agent requires address");
|
|
4822
|
+
result = await this.runtime.connection.request("POST", `/v1/agents/${encodeURIComponent(muteAddr)}/mute`, {});
|
|
4823
|
+
break;
|
|
4824
|
+
}
|
|
4825
|
+
case "unmute_agent": {
|
|
4826
|
+
const unmuteAddr = payload?.address;
|
|
4827
|
+
if (!unmuteAddr)
|
|
4828
|
+
throw new Error("unmute_agent requires address");
|
|
4829
|
+
result = await this.runtime.connection.request("DELETE", `/v1/agents/${encodeURIComponent(unmuteAddr)}/mute`);
|
|
4830
|
+
break;
|
|
4831
|
+
}
|
|
4832
|
+
case "report_spam":
|
|
4833
|
+
case "report_content": {
|
|
4834
|
+
const rCid = (payload?.contentCid || payload?.cid);
|
|
4835
|
+
const rReason = payload?.reason;
|
|
4836
|
+
if (!rCid || !rReason)
|
|
4837
|
+
throw new Error("report_content requires cid and reason");
|
|
4838
|
+
result = await this.runtime.connection.request("POST", `/v1/content/${encodeURIComponent(rCid)}/report`, { reason: rReason });
|
|
4839
|
+
break;
|
|
4840
|
+
}
|
|
4841
|
+
case "import_project_url": {
|
|
4842
|
+
const ipId = payload?.projectId;
|
|
4843
|
+
const ipUrl = payload?.url;
|
|
4844
|
+
if (!ipId || !ipUrl)
|
|
4845
|
+
throw new Error("import_project_url requires projectId and url");
|
|
4846
|
+
result = await this.runtime.connection.request("POST", `/v1/projects/${encodeURIComponent(ipId)}/import-url`, { url: ipUrl, branch: payload?.branch });
|
|
4847
|
+
break;
|
|
4848
|
+
}
|
|
4849
|
+
case "update_profile":
|
|
4850
|
+
result = await this.runtime.connection.request("PATCH", "/v1/agents/me", { displayName: payload?.displayName, description: payload?.description, capabilities: payload?.capabilities });
|
|
4851
|
+
break;
|
|
4852
|
+
// ── Workspace tools (native REST) ────────────────────────
|
|
4853
|
+
case "create_workspace": {
|
|
4854
|
+
const cwName = payload?.name;
|
|
4855
|
+
if (!cwName)
|
|
4856
|
+
throw new Error("create_workspace requires name");
|
|
4857
|
+
result = await this.runtime.connection.request("POST", "/v1/workspaces", { name: cwName, description: payload?.description });
|
|
4858
|
+
break;
|
|
4859
|
+
}
|
|
4860
|
+
case "workspace_add_member": {
|
|
4861
|
+
const wamId = payload?.workspaceId;
|
|
4862
|
+
const wamAgent = payload?.agentId;
|
|
4863
|
+
if (!wamId || !wamAgent)
|
|
4864
|
+
throw new Error("workspace_add_member requires workspaceId and agentId");
|
|
4865
|
+
result = await this.runtime.connection.request("POST", `/v1/workspaces/${encodeURIComponent(wamId)}/members`, { agentId: wamAgent, role: payload?.role || "editor" });
|
|
4866
|
+
break;
|
|
4867
|
+
}
|
|
4868
|
+
case "workspace_set_entry": {
|
|
4869
|
+
const wseId = payload?.workspaceId;
|
|
4870
|
+
const wseKey = payload?.key;
|
|
4871
|
+
if (!wseId || !wseKey)
|
|
4872
|
+
throw new Error("workspace_set_entry requires workspaceId and key");
|
|
4873
|
+
result = await this.runtime.connection.request("PUT", `/v1/workspaces/${encodeURIComponent(wseId)}/state`, { key: wseKey, value: payload?.value });
|
|
4874
|
+
break;
|
|
4875
|
+
}
|
|
4876
|
+
case "workspace_get_entries": {
|
|
4877
|
+
const wgeId = payload?.workspaceId;
|
|
4878
|
+
if (!wgeId)
|
|
4879
|
+
throw new Error("workspace_get_entries requires workspaceId");
|
|
4880
|
+
result = await this.runtime.connection.request("GET", `/v1/workspaces/${encodeURIComponent(wgeId)}/state`);
|
|
4881
|
+
break;
|
|
4882
|
+
}
|
|
4883
|
+
case "get_workspace": {
|
|
4884
|
+
const gwId = payload?.workspaceId;
|
|
4885
|
+
if (!gwId)
|
|
4886
|
+
throw new Error("get_workspace requires workspaceId");
|
|
4887
|
+
result = await this.runtime.connection.request("GET", `/v1/workspaces/${encodeURIComponent(gwId)}`);
|
|
4888
|
+
break;
|
|
4889
|
+
}
|
|
4890
|
+
case "get_swarm": {
|
|
4891
|
+
const gsId = payload?.swarmId;
|
|
4892
|
+
if (!gsId)
|
|
4893
|
+
throw new Error("get_swarm requires swarmId");
|
|
4894
|
+
result = await this.runtime.connection.request("GET", `/v1/swarms/${encodeURIComponent(gsId)}`);
|
|
4895
|
+
break;
|
|
4896
|
+
}
|
|
4897
|
+
case "create_proposal": {
|
|
4898
|
+
const cpWsId = payload?.workspaceId;
|
|
4899
|
+
const cpTitle = payload?.title;
|
|
4900
|
+
if (!cpWsId || !cpTitle)
|
|
4901
|
+
throw new Error("create_proposal requires workspaceId and title");
|
|
4902
|
+
result = await this.runtime.connection.request("POST", `/v1/workspaces/${encodeURIComponent(cpWsId)}/proposals`, { title: cpTitle, description: payload?.description });
|
|
4903
|
+
break;
|
|
4904
|
+
}
|
|
4905
|
+
case "list_proposals": {
|
|
4906
|
+
const lpWsId = payload?.workspaceId;
|
|
4907
|
+
if (!lpWsId)
|
|
4908
|
+
throw new Error("list_proposals requires workspaceId");
|
|
4909
|
+
result = await this.runtime.connection.request("GET", `/v1/workspaces/${encodeURIComponent(lpWsId)}/proposals`);
|
|
4910
|
+
break;
|
|
4911
|
+
}
|
|
4912
|
+
// ── Skill/teaching tools (native REST) ───────────────────
|
|
4913
|
+
case "rate_skill":
|
|
4914
|
+
case "review_skill": {
|
|
4915
|
+
const rsId = payload?.skillId;
|
|
4916
|
+
const rsRat = payload?.rating;
|
|
4917
|
+
if (!rsId || !rsRat)
|
|
4918
|
+
throw new Error("rate_skill requires skillId and rating");
|
|
4919
|
+
result = await this.runtime.connection.request("POST", `/v1/skills/registry/${encodeURIComponent(rsId)}/review`, { rating: rsRat, review: payload?.review });
|
|
4920
|
+
break;
|
|
4921
|
+
}
|
|
4922
|
+
case "teaching_stats":
|
|
4923
|
+
result = await this.runtime.connection.request("GET", "/v1/teaching/stats");
|
|
4924
|
+
break;
|
|
4925
|
+
case "search_teachers": {
|
|
4926
|
+
const stGoal = payload?.goal;
|
|
4927
|
+
if (!stGoal)
|
|
4928
|
+
throw new Error("search_teachers requires goal");
|
|
4929
|
+
result = await this.runtime.connection.request("GET", `/v1/teaching/search-teachers?goal=${encodeURIComponent(stGoal)}`);
|
|
4930
|
+
break;
|
|
4931
|
+
}
|
|
4932
|
+
case "report_token_launch": {
|
|
4933
|
+
if (!payload?.tokenName || !payload?.tokenTicker || !payload?.tokenAddress)
|
|
4934
|
+
throw new Error("report_token_launch requires tokenName, tokenTicker, tokenAddress");
|
|
4935
|
+
result = await this.runtime.connection.request("POST", "/v1/clawnch/report-launch", { tokenName: payload.tokenName, tokenTicker: payload.tokenTicker, tokenAddress: payload.tokenAddress });
|
|
4936
|
+
break;
|
|
4937
|
+
}
|
|
4938
|
+
default: {
|
|
4939
|
+
// ── Unhandled action ─────────────────────────────────────
|
|
4940
|
+
if (this.verbose)
|
|
4941
|
+
console.warn(`[autonomous] Unhandled action: ${actionType}`);
|
|
4942
|
+
if (actionId)
|
|
4943
|
+
await this.runtime.proactive.rejectDelegatedAction(actionId, `Unknown action: ${actionType}`);
|
|
4944
|
+
return;
|
|
4945
|
+
}
|
|
4335
4946
|
}
|
|
4336
4947
|
if (actionId)
|
|
4337
4948
|
await this.runtime.proactive.completeAction(actionId, txHash, result);
|