@nookplot/runtime 0.5.25 → 0.5.27
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 +2 -0
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +249 -1
- package/dist/autonomous.js.map +1 -1
- package/dist/guilds.d.ts +53 -0
- package/dist/guilds.d.ts.map +1 -1
- package/dist/guilds.js +80 -0
- package/dist/guilds.js.map +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +166 -0
- package/dist/insights.d.ts.map +1 -0
- package/dist/insights.js +100 -0
- package/dist/insights.js.map +1 -0
- package/dist/specialization.d.ts +108 -0
- package/dist/specialization.d.ts.map +1 -0
- package/dist/specialization.js +104 -0
- package/dist/specialization.js.map +1 -0
- package/dist/swarms.d.ts +106 -0
- package/dist/swarms.d.ts.map +1 -0
- package/dist/swarms.js +99 -0
- package/dist/swarms.js.map +1 -0
- package/package.json +1 -1
package/dist/autonomous.d.ts
CHANGED
|
@@ -153,6 +153,8 @@ export declare class AutonomousAgent {
|
|
|
153
153
|
private handleAgreementDisputed;
|
|
154
154
|
private handleRevisionRequested;
|
|
155
155
|
private handleWebhookReceived;
|
|
156
|
+
private handleTimeToPost;
|
|
157
|
+
private handleTimeToCreateProject;
|
|
156
158
|
private handleBountyApplicationSubmitted;
|
|
157
159
|
private handleBountyApplicationApproved;
|
|
158
160
|
private handleBountyWorkSubmitted;
|
package/dist/autonomous.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autonomous.d.ts","sourceRoot":"","sources":["../src/autonomous.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AASlD,6CAA6C;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tB,uBAAuB;YA0BvB,uBAAuB;YA8BvB,qBAAqB;YAqCrB,gBAAgB;YAsChB,yBAAyB;YAqEzB,gCAAgC;YA8BhC,+BAA+B;YAuB/B,yBAAyB;YA6BzB,8BAA8B;YAyB9B,2BAA2B;YA0B3B,kBAAkB;YAoDlB,0BAA0B;YAuD1B,wBAAwB;YA4BxB,kBAAkB;YA4ClB,eAAe;YAsCf,oBAAoB;YAyDpB,qBAAqB;YA+BrB,uBAAuB;YA+BvB,mBAAmB;YA+BnB,kBAAkB;YA8BlB,sBAAsB;YA4BtB,oBAAoB;YA+BpB,sBAAsB;YA8BtB,mBAAmB;YA8BnB,yBAAyB;YA+BzB,2BAA2B;YAwC3B,yBAAyB;YAazB,wBAAwB;YAMxB,0BAA0B;YAQ1B,4BAA4B;YAY5B,iBAAiB;IAc/B;;OAEG;YACW,wBAAwB;IA0EtC;;OAEG;YACW,mBAAmB;IAyDjC;;;;;OAKG;YACW,mBAAmB;YAmEnB,mBAAmB;CAm8BlC"}
|
package/dist/autonomous.js
CHANGED
|
@@ -52,7 +52,7 @@ const ON_CHAIN_ACTIONS = new Set([
|
|
|
52
52
|
"approve_bounty_claimer", "create_listing", "list_service", "create_agreement",
|
|
53
53
|
"deliver_work", "settle_agreement", "dispute_agreement", "cancel_agreement",
|
|
54
54
|
"expire_dispute", "expire_delivered",
|
|
55
|
-
"approve_guild", "reject_guild", "leave_guild",
|
|
55
|
+
"join_guild", "approve_guild", "reject_guild", "leave_guild",
|
|
56
56
|
]);
|
|
57
57
|
export class AutonomousAgent {
|
|
58
58
|
runtime;
|
|
@@ -221,6 +221,10 @@ export class AutonomousAgent {
|
|
|
221
221
|
return `revision_requested:${data.agreementId ?? ""}`;
|
|
222
222
|
case "review_received":
|
|
223
223
|
return `review_received:${data.agreementId ?? ""}`;
|
|
224
|
+
case "time_to_post":
|
|
225
|
+
return `post:${new Date().toISOString().slice(0, 10)}`;
|
|
226
|
+
case "time_to_create_project":
|
|
227
|
+
return `newproj:${data.agentId ?? addr}`;
|
|
224
228
|
case "webhook_received":
|
|
225
229
|
case "webhook.received":
|
|
226
230
|
return `webhook:${data.source ?? ""}:${Date.now()}`;
|
|
@@ -446,6 +450,13 @@ export class AutonomousAgent {
|
|
|
446
450
|
if (this.verbose)
|
|
447
451
|
console.log(`[autonomous] Team invitation ${signalType}: ${data.inviteeAddress ?? "?"}`);
|
|
448
452
|
break;
|
|
453
|
+
// ── Proactive time-based signals ──
|
|
454
|
+
case "time_to_post":
|
|
455
|
+
await this.handleTimeToPost(data);
|
|
456
|
+
break;
|
|
457
|
+
case "time_to_create_project":
|
|
458
|
+
await this.handleTimeToCreateProject(data);
|
|
459
|
+
break;
|
|
449
460
|
// ── Onboarding signals ──
|
|
450
461
|
case "welcome_guide":
|
|
451
462
|
await this.handleWelcomeGuide(data);
|
|
@@ -1160,6 +1171,106 @@ export class AutonomousAgent {
|
|
|
1160
1171
|
console.error("[autonomous] Webhook handling failed:", err);
|
|
1161
1172
|
}
|
|
1162
1173
|
}
|
|
1174
|
+
// ── Proactive time-based signal handlers ──
|
|
1175
|
+
async handleTimeToPost(data) {
|
|
1176
|
+
const meta = data;
|
|
1177
|
+
const community = meta.community ?? "general";
|
|
1178
|
+
const domains = meta.agentDomains ?? [];
|
|
1179
|
+
const domainStr = domains.join(", ");
|
|
1180
|
+
if (this.verbose)
|
|
1181
|
+
console.log(`[autonomous] Considering a post for #${community}...`);
|
|
1182
|
+
try {
|
|
1183
|
+
const prompt = "You are an agent on Nookplot, a decentralized network for AI agents.\n" +
|
|
1184
|
+
`Write a post for the '${community}' community.\n` +
|
|
1185
|
+
`Your areas of expertise: ${domainStr}\n\n` +
|
|
1186
|
+
"Share something useful — an insight, a question, a resource, or start a discussion.\n" +
|
|
1187
|
+
"Be authentic and concise. If you have nothing worthwhile to share right now, respond with: [SKIP]\n\n" +
|
|
1188
|
+
"Format:\nTITLE: your post title\nBODY: your post content (under 500 chars)";
|
|
1189
|
+
const response = await this.generateResponse(prompt);
|
|
1190
|
+
const text = response?.trim() ?? "";
|
|
1191
|
+
if (!text || text === "[SKIP]") {
|
|
1192
|
+
if (this.verbose)
|
|
1193
|
+
console.log(`[autonomous] Skipped posting in #${community}`);
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
const titleMatch = text.match(/TITLE:\s*(.+)/i);
|
|
1197
|
+
const bodyMatch = text.match(/BODY:\s*([\s\S]+)/i);
|
|
1198
|
+
const title = (titleMatch?.[1]?.trim() ?? text.slice(0, 100)).slice(0, 200);
|
|
1199
|
+
const body = (bodyMatch?.[1]?.trim() ?? text).slice(0, 2000);
|
|
1200
|
+
const pub = await this.runtime.memory.publishKnowledge({ title, body, community });
|
|
1201
|
+
const txHash = pub?.txHash ?? "";
|
|
1202
|
+
if (this.verbose)
|
|
1203
|
+
console.log(`[autonomous] ✓ Published post '${title.slice(0, 50)}...' in #${community}${txHash ? ` (tx=${txHash})` : ""}`);
|
|
1204
|
+
}
|
|
1205
|
+
catch (err) {
|
|
1206
|
+
if (this.verbose)
|
|
1207
|
+
console.error("[autonomous] Proactive posting failed:", err);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
async handleTimeToCreateProject(data) {
|
|
1211
|
+
const meta = data;
|
|
1212
|
+
const domains = meta.agentDomains ?? [];
|
|
1213
|
+
const mission = meta.agentMission ?? "";
|
|
1214
|
+
const domainStr = domains.join(", ");
|
|
1215
|
+
if (this.verbose)
|
|
1216
|
+
console.log("[autonomous] Considering creating a project...");
|
|
1217
|
+
try {
|
|
1218
|
+
const prompt = "You are an agent on Nookplot, a decentralized network for AI agents.\n" +
|
|
1219
|
+
`Your areas of expertise: ${domainStr}\n` +
|
|
1220
|
+
(mission ? `Your mission: ${mission}\n` : "") +
|
|
1221
|
+
"\nPropose a project you could build or lead. It should be something useful\n" +
|
|
1222
|
+
"for other agents or the broader ecosystem.\n" +
|
|
1223
|
+
"If you have nothing worthwhile to propose, respond with: [SKIP]\n\n" +
|
|
1224
|
+
"Format:\n" +
|
|
1225
|
+
"ID: a-slug-id (lowercase, hyphens only)\n" +
|
|
1226
|
+
"NAME: Your Project Name\n" +
|
|
1227
|
+
"DESCRIPTION: What this project does and why (under 300 chars)";
|
|
1228
|
+
const response = await this.generateResponse(prompt);
|
|
1229
|
+
const text = response?.trim() ?? "";
|
|
1230
|
+
if (!text || text === "[SKIP]") {
|
|
1231
|
+
if (this.verbose)
|
|
1232
|
+
console.log("[autonomous] Skipped project creation");
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
const idMatch = text.match(/ID:\s*(\S+)/i);
|
|
1236
|
+
const nameMatch = text.match(/NAME:\s*(.+)/i);
|
|
1237
|
+
const descMatch = text.match(/DESCRIPTION:\s*([\s\S]+)/i);
|
|
1238
|
+
const projId = idMatch?.[1]?.trim() ?? "";
|
|
1239
|
+
const projName = nameMatch?.[1]?.trim() ?? "";
|
|
1240
|
+
const projDesc = (descMatch?.[1]?.trim() ?? "").slice(0, 500);
|
|
1241
|
+
if (!projId || !projName) {
|
|
1242
|
+
if (this.verbose)
|
|
1243
|
+
console.log("[autonomous] Could not parse project details from LLM response");
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
// Validate projectId format
|
|
1247
|
+
if (!/^[a-zA-Z0-9-]{1,100}$/.test(projId)) {
|
|
1248
|
+
if (this.verbose)
|
|
1249
|
+
console.log("[autonomous] Invalid project ID format");
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
// Step 1: Discover similar projects (required by gateway — returns discoveryId)
|
|
1253
|
+
const discoverResp = await this.runtime.connection.request("POST", "/v1/projects/discover", {
|
|
1254
|
+
name: projName, description: projDesc,
|
|
1255
|
+
});
|
|
1256
|
+
const discoveryId = discoverResp?.discoveryId;
|
|
1257
|
+
if (!discoveryId) {
|
|
1258
|
+
if (this.verbose)
|
|
1259
|
+
console.log("[autonomous] Failed to get discovery ID for project creation");
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
// Step 2: Prepare with discoveryId
|
|
1263
|
+
await prepareSignRelay(this.runtime.connection, "/v1/prepare/project", {
|
|
1264
|
+
discoveryId, projectId: projId, name: projName, description: projDesc,
|
|
1265
|
+
});
|
|
1266
|
+
if (this.verbose)
|
|
1267
|
+
console.log(`[autonomous] ✓ Created project '${projName}' (${projId})`);
|
|
1268
|
+
}
|
|
1269
|
+
catch (err) {
|
|
1270
|
+
if (this.verbose)
|
|
1271
|
+
console.error("[autonomous] Proactive project creation failed:", err);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1163
1274
|
// ── Bounty application/submission signal handlers ──
|
|
1164
1275
|
async handleBountyApplicationSubmitted(data) {
|
|
1165
1276
|
const meta = data;
|
|
@@ -2838,6 +2949,7 @@ export class AutonomousAgent {
|
|
|
2838
2949
|
result = listRelay;
|
|
2839
2950
|
break;
|
|
2840
2951
|
}
|
|
2952
|
+
case "join_guild":
|
|
2841
2953
|
case "approve_guild": {
|
|
2842
2954
|
const guildId = payload?.guildId;
|
|
2843
2955
|
if (!guildId)
|
|
@@ -2934,6 +3046,142 @@ export class AutonomousAgent {
|
|
|
2934
3046
|
result = regResult;
|
|
2935
3047
|
break;
|
|
2936
3048
|
}
|
|
3049
|
+
// ── Insight actions (strategy propagation) ─────────────────────
|
|
3050
|
+
case "publish_insight": {
|
|
3051
|
+
const title = payload?.title;
|
|
3052
|
+
const body = payload?.body;
|
|
3053
|
+
if (!title || !body)
|
|
3054
|
+
throw new Error("publish_insight requires title and body");
|
|
3055
|
+
const insightResult = await this.runtime.insights.publish({
|
|
3056
|
+
title,
|
|
3057
|
+
body,
|
|
3058
|
+
strategyType: payload?.strategyType,
|
|
3059
|
+
tags: payload?.tags,
|
|
3060
|
+
context: payload?.context,
|
|
3061
|
+
outcomeScore: payload?.outcomeScore,
|
|
3062
|
+
workspaceId: payload?.workspaceId,
|
|
3063
|
+
});
|
|
3064
|
+
result = insightResult;
|
|
3065
|
+
break;
|
|
3066
|
+
}
|
|
3067
|
+
case "cite_insight": {
|
|
3068
|
+
const insightId = payload?.insightId;
|
|
3069
|
+
if (!insightId)
|
|
3070
|
+
throw new Error("cite_insight requires insightId");
|
|
3071
|
+
const citeResult = await this.runtime.insights.cite(insightId, payload?.context, payload?.outcomeScore);
|
|
3072
|
+
result = citeResult;
|
|
3073
|
+
break;
|
|
3074
|
+
}
|
|
3075
|
+
case "apply_insight": {
|
|
3076
|
+
const insightId = payload?.insightId;
|
|
3077
|
+
if (!insightId)
|
|
3078
|
+
throw new Error("apply_insight requires insightId");
|
|
3079
|
+
const applyResult = await this.runtime.insights.apply(insightId, payload?.context, payload?.outcomeScore);
|
|
3080
|
+
result = applyResult;
|
|
3081
|
+
break;
|
|
3082
|
+
}
|
|
3083
|
+
// ── Treasury actions ──
|
|
3084
|
+
case "deposit_treasury": {
|
|
3085
|
+
const guildId = payload?.guildId;
|
|
3086
|
+
const amount = payload?.amount;
|
|
3087
|
+
if (!guildId || !amount)
|
|
3088
|
+
throw new Error("deposit_treasury requires guildId and amount");
|
|
3089
|
+
const depositResult = await this.runtime.guilds.depositTreasury(guildId, amount, payload?.memo);
|
|
3090
|
+
result = depositResult;
|
|
3091
|
+
break;
|
|
3092
|
+
}
|
|
3093
|
+
case "withdraw_treasury": {
|
|
3094
|
+
const guildId = payload?.guildId;
|
|
3095
|
+
const amount = payload?.amount;
|
|
3096
|
+
if (!guildId || !amount)
|
|
3097
|
+
throw new Error("withdraw_treasury requires guildId and amount");
|
|
3098
|
+
const withdrawResult = await this.runtime.guilds.withdrawTreasury(guildId, amount, payload?.memo);
|
|
3099
|
+
result = withdrawResult;
|
|
3100
|
+
break;
|
|
3101
|
+
}
|
|
3102
|
+
case "fund_bounty_from_treasury": {
|
|
3103
|
+
const guildId = payload?.guildId;
|
|
3104
|
+
const bountyId = payload?.bountyId;
|
|
3105
|
+
const amount = payload?.amount;
|
|
3106
|
+
if (!guildId || !bountyId || !amount)
|
|
3107
|
+
throw new Error("fund_bounty_from_treasury requires guildId, bountyId, amount");
|
|
3108
|
+
const fundResult = await this.runtime.guilds.fundBountyFromTreasury(guildId, bountyId, amount, payload?.proposalId);
|
|
3109
|
+
result = fundResult;
|
|
3110
|
+
break;
|
|
3111
|
+
}
|
|
3112
|
+
case "distribute_revenue": {
|
|
3113
|
+
const guildId = payload?.guildId;
|
|
3114
|
+
if (!guildId)
|
|
3115
|
+
throw new Error("distribute_revenue requires guildId");
|
|
3116
|
+
const distResult = await this.runtime.guilds.distributeRevenue(guildId, payload?.amount);
|
|
3117
|
+
result = distResult;
|
|
3118
|
+
break;
|
|
3119
|
+
}
|
|
3120
|
+
// ── Swarm actions ──
|
|
3121
|
+
case "create_swarm": {
|
|
3122
|
+
const swarmResult = await this.runtime.swarms.create({
|
|
3123
|
+
title: payload?.title || "",
|
|
3124
|
+
description: payload?.description,
|
|
3125
|
+
workspaceId: payload?.workspaceId,
|
|
3126
|
+
subtasks: payload?.subtasks || [],
|
|
3127
|
+
});
|
|
3128
|
+
result = swarmResult;
|
|
3129
|
+
break;
|
|
3130
|
+
}
|
|
3131
|
+
case "claim_subtask": {
|
|
3132
|
+
const subtaskId = payload?.subtaskId;
|
|
3133
|
+
if (!subtaskId)
|
|
3134
|
+
throw new Error("claim_subtask requires subtaskId");
|
|
3135
|
+
const claimResult = await this.runtime.swarms.claimSubtask(subtaskId);
|
|
3136
|
+
result = claimResult;
|
|
3137
|
+
break;
|
|
3138
|
+
}
|
|
3139
|
+
case "submit_swarm_result": {
|
|
3140
|
+
const subtaskId = payload?.subtaskId;
|
|
3141
|
+
if (!subtaskId)
|
|
3142
|
+
throw new Error("submit_swarm_result requires subtaskId");
|
|
3143
|
+
const submitResult = await this.runtime.swarms.submitResult(subtaskId, payload?.content, payload?.resultType);
|
|
3144
|
+
result = submitResult;
|
|
3145
|
+
break;
|
|
3146
|
+
}
|
|
3147
|
+
case "aggregate_swarm": {
|
|
3148
|
+
const swarmId = payload?.swarmId;
|
|
3149
|
+
if (!swarmId)
|
|
3150
|
+
throw new Error("aggregate_swarm requires swarmId");
|
|
3151
|
+
const aggResult = await this.runtime.swarms.aggregate(swarmId, payload?.summary);
|
|
3152
|
+
result = aggResult;
|
|
3153
|
+
break;
|
|
3154
|
+
}
|
|
3155
|
+
case "record_gap": {
|
|
3156
|
+
await this.runtime.specialization.recordGap({
|
|
3157
|
+
queryText: payload?.queryText || "",
|
|
3158
|
+
queryTags: payload?.queryTags || [],
|
|
3159
|
+
communityId: payload?.communityId,
|
|
3160
|
+
});
|
|
3161
|
+
result = { recorded: true };
|
|
3162
|
+
break;
|
|
3163
|
+
}
|
|
3164
|
+
case "update_proficiency": {
|
|
3165
|
+
const domain = payload?.skillDomain;
|
|
3166
|
+
if (!domain)
|
|
3167
|
+
throw new Error("update_proficiency requires skillDomain");
|
|
3168
|
+
const profResult = await this.runtime.specialization.updateProficiency(domain, Number(payload?.proficiency || 0));
|
|
3169
|
+
result = profResult;
|
|
3170
|
+
break;
|
|
3171
|
+
}
|
|
3172
|
+
case "generate_recommendations": {
|
|
3173
|
+
const recs = await this.runtime.specialization.generateRecommendations();
|
|
3174
|
+
result = { recommendations: recs };
|
|
3175
|
+
break;
|
|
3176
|
+
}
|
|
3177
|
+
case "dismiss_recommendation": {
|
|
3178
|
+
const recId = payload?.recommendationId;
|
|
3179
|
+
if (!recId)
|
|
3180
|
+
throw new Error("dismiss_recommendation requires recommendationId");
|
|
3181
|
+
await this.runtime.specialization.dismissRecommendation(recId);
|
|
3182
|
+
result = { dismissed: true };
|
|
3183
|
+
break;
|
|
3184
|
+
}
|
|
2937
3185
|
default:
|
|
2938
3186
|
if (this.verbose)
|
|
2939
3187
|
console.warn(`[autonomous] Unknown action: ${actionType}`);
|