@nookplot/runtime 0.5.107 → 0.5.109
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/__tests__/autonomous.getAvailableActions.test.js +7 -4
- package/dist/__tests__/autonomous.getAvailableActions.test.js.map +1 -1
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts +2 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.js +148 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.js.map +1 -0
- package/dist/__tests__/conversation/modelThresholdsParity.test.js +6 -11
- package/dist/__tests__/conversation/modelThresholdsParity.test.js.map +1 -1
- package/dist/__tests__/goalLoop.test.d.ts +2 -0
- package/dist/__tests__/goalLoop.test.d.ts.map +1 -0
- package/dist/__tests__/goalLoop.test.js +224 -0
- package/dist/__tests__/goalLoop.test.js.map +1 -0
- package/dist/__tests__/helpers/mockRuntime.d.ts.map +1 -1
- package/dist/__tests__/helpers/mockRuntime.js +7 -0
- package/dist/__tests__/helpers/mockRuntime.js.map +1 -1
- package/dist/__tests__/lineage.test.d.ts +2 -0
- package/dist/__tests__/lineage.test.d.ts.map +1 -0
- package/dist/__tests__/lineage.test.js +131 -0
- package/dist/__tests__/lineage.test.js.map +1 -0
- package/dist/__tests__/loadProfile.test.d.ts +8 -0
- package/dist/__tests__/loadProfile.test.d.ts.map +1 -0
- package/dist/__tests__/loadProfile.test.js +134 -0
- package/dist/__tests__/loadProfile.test.js.map +1 -0
- package/dist/__tests__/presetLoader.test.d.ts +2 -0
- package/dist/__tests__/presetLoader.test.d.ts.map +1 -0
- package/dist/__tests__/presetLoader.test.js +749 -0
- package/dist/__tests__/presetLoader.test.js.map +1 -0
- package/dist/__tests__/sandbox.test.js +24 -24
- package/dist/actionCatalog.generated.d.ts +1 -1
- package/dist/actionCatalog.generated.d.ts.map +1 -1
- package/dist/actionCatalog.generated.js +138 -15
- package/dist/actionCatalog.generated.js.map +1 -1
- package/dist/autonomous.d.ts +15 -1
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +195 -37
- package/dist/autonomous.js.map +1 -1
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2 -1
- package/dist/connection.js.map +1 -1
- package/dist/contentSafety.d.ts +1 -1
- package/dist/contentSafety.d.ts.map +1 -1
- package/dist/contentSafety.js +6 -2
- package/dist/contentSafety.js.map +1 -1
- package/dist/conversation/modelLimits.js +17 -17
- package/dist/discovery.js +1 -1
- package/dist/discovery.js.map +1 -1
- package/dist/goal/goalLoop.d.ts +75 -0
- package/dist/goal/goalLoop.d.ts.map +1 -0
- package/dist/goal/goalLoop.js +347 -0
- package/dist/goal/goalLoop.js.map +1 -0
- package/dist/goal/goalPrompts.d.ts +20 -0
- package/dist/goal/goalPrompts.d.ts.map +1 -0
- package/dist/goal/goalPrompts.js +54 -0
- package/dist/goal/goalPrompts.js.map +1 -0
- package/dist/goal/types.d.ts +98 -0
- package/dist/goal/types.d.ts.map +1 -0
- package/dist/goal/types.js +7 -0
- package/dist/goal/types.js.map +1 -0
- package/dist/identity.d.ts +51 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +50 -0
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lineage.d.ts +69 -0
- package/dist/lineage.d.ts.map +1 -0
- package/dist/lineage.js +72 -0
- package/dist/lineage.js.map +1 -0
- package/dist/loadProfile.d.ts +100 -0
- package/dist/loadProfile.d.ts.map +1 -0
- package/dist/loadProfile.js +221 -0
- package/dist/loadProfile.js.map +1 -0
- package/dist/presetLoader.d.ts +130 -0
- package/dist/presetLoader.d.ts.map +1 -0
- package/dist/presetLoader.js +734 -0
- package/dist/presetLoader.js.map +1 -0
- package/dist/signalActionMap.d.ts.map +1 -1
- package/dist/signalActionMap.js +6 -12
- package/dist/signalActionMap.js.map +1 -1
- package/dist/signing.d.ts +30 -0
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +55 -0
- package/dist/signing.js.map +1 -1
- package/dist/swarms.d.ts +13 -0
- package/dist/swarms.d.ts.map +1 -1
- package/dist/swarms.js +4 -0
- package/dist/swarms.js.map +1 -1
- package/package.json +60 -60
package/dist/autonomous.d.ts
CHANGED
|
@@ -147,6 +147,21 @@ export declare class AutonomousAgent {
|
|
|
147
147
|
start(): void;
|
|
148
148
|
/** Stop the autonomous agent. */
|
|
149
149
|
stop(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Check whether this agent has an initial_goal + pending status, and
|
|
152
|
+
* if so, spin up a GoalLoop in the background. Non-blocking — start()
|
|
153
|
+
* returns immediately so WebSocket signal subscriptions are live even
|
|
154
|
+
* while the goal loop is running its first step.
|
|
155
|
+
*/
|
|
156
|
+
private maybeBootstrapGoal;
|
|
157
|
+
/**
|
|
158
|
+
* Dispatch on the terminal state of a GoalLoop run:
|
|
159
|
+
* - complete → store artifact in private KG, pause agent
|
|
160
|
+
* - blocked_budget → create pending task (budget_exhausted), pause
|
|
161
|
+
* - blocked_stuck → create pending task (stuck_3x), pause
|
|
162
|
+
* - blocked_capability → create pending task (needs_capability), pause
|
|
163
|
+
*/
|
|
164
|
+
private handleGoalResult;
|
|
150
165
|
/**
|
|
151
166
|
* Build a stable dedup key from a signal so we can detect duplicates.
|
|
152
167
|
* DMs dedup on sender, followers dedup on address, channels dedup on channel+sender.
|
|
@@ -191,7 +206,6 @@ export declare class AutonomousAgent {
|
|
|
191
206
|
private handleOnboardingSuggestion;
|
|
192
207
|
private handleSpecializationPath;
|
|
193
208
|
private handleCommunityGap;
|
|
194
|
-
private handleDirective;
|
|
195
209
|
private handleFilesCommitted;
|
|
196
210
|
private handleReviewSubmitted;
|
|
197
211
|
private handleCollaboratorAdded;
|
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;AAMlD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
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;AAMlD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAe/C,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB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BAAmB;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;YAoPnB,sBAAsB;YAuCtB,sBAAsB;YA+BtB,uBAAuB;YAgCvB,yBAAyB;YAkCzB,4BAA4B;YAuC5B,yBAAyB;YAgCzB,6BAA6B;YAkC7B,mBAAmB;YAkCnB,mBAAmB;YAoCnB,oBAAoB;YA6BpB,sBAAsB;YAsCtB,iBAAiB;YA8BjB,gBAAgB;YAgChB,2BAA2B;YA6B3B,0BAA0B;IA6BxC;;;;;OAKG;YACW,iBAAiB;CA0DhC"}
|
package/dist/autonomous.js
CHANGED
|
@@ -44,6 +44,7 @@ import { wrapUntrusted, sanitizeForPrompt, UNTRUSTED_CONTENT_INSTRUCTION } from
|
|
|
44
44
|
import { getAvailableActionsFromMap } from "./signalActionMap.js";
|
|
45
45
|
import { getCategoryListing, getToolsInCategory } from "./actionCatalog.js";
|
|
46
46
|
import { WakeUpStack } from "./wakeUpStack.js";
|
|
47
|
+
import { GoalLoop } from "./goal/goalLoop.js";
|
|
47
48
|
import { hooks as defaultHooks } from "./hooks.js";
|
|
48
49
|
import { guardrails as defaultGuardrails, GuardrailTripped, InputGuardrailTripped, } from "./guardrails.js";
|
|
49
50
|
// ----------------------------------------------------------------
|
|
@@ -112,6 +113,8 @@ const ON_CHAIN_ACTIONS = new Set([
|
|
|
112
113
|
// Mining guild treasury (on-chain)
|
|
113
114
|
"deposit_guild_mining_treasury", "claim_guild_mining_treasury",
|
|
114
115
|
"claim_pending_guild_mining_treasury",
|
|
116
|
+
// Ecosystem partner protocols (raw-tx, agent pays own gas)
|
|
117
|
+
"ecosystem_stake_tokens", "ecosystem_claim_rewards",
|
|
115
118
|
]);
|
|
116
119
|
/**
|
|
117
120
|
* Get the list of available actions for a given signal type.
|
|
@@ -194,6 +197,21 @@ export class AutonomousAgent {
|
|
|
194
197
|
if (this.verbose) {
|
|
195
198
|
console.log("[autonomous] AutonomousAgent started — handling signals + actions");
|
|
196
199
|
}
|
|
200
|
+
// Pre-load tool categories so the LLM always has web_search +
|
|
201
|
+
// search_knowledge visible without a browse_tools cold-start.
|
|
202
|
+
// Saves ~1 LLM turn per goal-driven agent and simplifies the first
|
|
203
|
+
// step for reactive agents too (CLAUDE.md rule — small code change).
|
|
204
|
+
this.loadedCategories.add("tools");
|
|
205
|
+
this.loadedCategories.add("discovery");
|
|
206
|
+
this.loadedCategories.add("knowledge");
|
|
207
|
+
// Goal bootstrap — run the GoalLoop in background if this agent was
|
|
208
|
+
// forged with initial_goal set (L1 swarm auto-deploy). Failures are
|
|
209
|
+
// non-fatal: the agent continues in normal reactive mode.
|
|
210
|
+
this.maybeBootstrapGoal().catch((err) => {
|
|
211
|
+
if (this.verbose) {
|
|
212
|
+
console.error("[autonomous] Goal bootstrap failed:", err);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
197
215
|
}
|
|
198
216
|
/** Stop the autonomous agent. */
|
|
199
217
|
stop() {
|
|
@@ -203,6 +221,157 @@ export class AutonomousAgent {
|
|
|
203
221
|
}
|
|
204
222
|
}
|
|
205
223
|
// ================================================================
|
|
224
|
+
// Goal bootstrap (L3 — migration 247)
|
|
225
|
+
// ================================================================
|
|
226
|
+
/**
|
|
227
|
+
* Check whether this agent has an initial_goal + pending status, and
|
|
228
|
+
* if so, spin up a GoalLoop in the background. Non-blocking — start()
|
|
229
|
+
* returns immediately so WebSocket signal subscriptions are live even
|
|
230
|
+
* while the goal loop is running its first step.
|
|
231
|
+
*/
|
|
232
|
+
async maybeBootstrapGoal() {
|
|
233
|
+
let goalConfig;
|
|
234
|
+
try {
|
|
235
|
+
goalConfig = await this.runtime.identity.getGoal();
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
if (this.verbose) {
|
|
239
|
+
console.error("[autonomous] getGoal failed — treating as no goal:", err);
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (!goalConfig || !goalConfig.initialGoal)
|
|
244
|
+
return;
|
|
245
|
+
if (goalConfig.goalStatus !== "pending") {
|
|
246
|
+
if (this.verbose) {
|
|
247
|
+
console.log(`[autonomous] Skipping goal bootstrap — status is ${goalConfig.goalStatus}, not 'pending'`);
|
|
248
|
+
}
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (this.verbose) {
|
|
252
|
+
console.log(`[autonomous] Goal bootstrap: "${goalConfig.initialGoal.slice(0, 80)}..." budget=${goalConfig.goalBudgetNook ?? "unlimited"}`);
|
|
253
|
+
}
|
|
254
|
+
// Transition status atomically before running the loop. If the
|
|
255
|
+
// gateway rejects (network, permissions), bail out — we do not want
|
|
256
|
+
// to run the loop with a mismatched DB state.
|
|
257
|
+
try {
|
|
258
|
+
await this.runtime.identity.updateGoalStatus("in_progress");
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
if (this.verbose) {
|
|
262
|
+
console.error("[autonomous] Failed to transition goal → in_progress:", err);
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const budgetNook = goalConfig.goalBudgetNook ? BigInt(goalConfig.goalBudgetNook) : 0n;
|
|
267
|
+
const loopOptions = {
|
|
268
|
+
runtime: this.runtime,
|
|
269
|
+
goal: goalConfig.initialGoal,
|
|
270
|
+
budgetNook,
|
|
271
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
272
|
+
verbose: this.verbose,
|
|
273
|
+
};
|
|
274
|
+
const loop = new GoalLoop(loopOptions);
|
|
275
|
+
let result;
|
|
276
|
+
try {
|
|
277
|
+
result = await loop.run();
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
281
|
+
if (this.verbose) {
|
|
282
|
+
console.error("[autonomous] GoalLoop threw:", err);
|
|
283
|
+
}
|
|
284
|
+
// Transition to failed so the UI reflects the error.
|
|
285
|
+
await this.runtime.identity.updateGoalStatus("failed").catch(() => { });
|
|
286
|
+
await this.runtime.identity.createPendingTask({
|
|
287
|
+
reason: "unclear_goal",
|
|
288
|
+
description: `Goal loop crashed: ${msg.slice(0, 400)}`,
|
|
289
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
290
|
+
}).catch(() => { });
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
await this.handleGoalResult(result, goalConfig);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Dispatch on the terminal state of a GoalLoop run:
|
|
297
|
+
* - complete → store artifact in private KG, pause agent
|
|
298
|
+
* - blocked_budget → create pending task (budget_exhausted), pause
|
|
299
|
+
* - blocked_stuck → create pending task (stuck_3x), pause
|
|
300
|
+
* - blocked_capability → create pending task (needs_capability), pause
|
|
301
|
+
*/
|
|
302
|
+
async handleGoalResult(result, goalConfig) {
|
|
303
|
+
if (result.outcome === "complete") {
|
|
304
|
+
// Store deliverable in private KG
|
|
305
|
+
let artifactId = null;
|
|
306
|
+
try {
|
|
307
|
+
const storeResult = (await this.runtime.connection.request("POST", "/v1/agents/me/knowledge", {
|
|
308
|
+
contentText: result.artifact.body,
|
|
309
|
+
title: result.artifact.title,
|
|
310
|
+
domain: result.artifact.domain,
|
|
311
|
+
visibility: "private",
|
|
312
|
+
knowledgeType: "fact",
|
|
313
|
+
sourceType: "import",
|
|
314
|
+
metadata: {
|
|
315
|
+
goal: goalConfig.initialGoal,
|
|
316
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
317
|
+
stepsExecuted: result.stepsExecuted,
|
|
318
|
+
spentNook: result.spentNook.toString(),
|
|
319
|
+
},
|
|
320
|
+
}));
|
|
321
|
+
artifactId = storeResult?.id ?? null;
|
|
322
|
+
}
|
|
323
|
+
catch (err) {
|
|
324
|
+
if (this.verbose) {
|
|
325
|
+
console.error("[autonomous] Failed to store goal artifact:", err);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
await this.runtime.identity.completeGoal(artifactId ?? "unknown");
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
if (this.verbose) {
|
|
333
|
+
console.error("[autonomous] completeGoal failed:", err);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
// Q3: agent pauses after completion, does not stay reactive
|
|
337
|
+
this.stop();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (result.outcome === "blocked_budget") {
|
|
341
|
+
// initialGoal is non-null here — maybeBootstrapGoal returned early otherwise.
|
|
342
|
+
const goalText = goalConfig.initialGoal ?? "(unknown)";
|
|
343
|
+
await this.runtime.identity.createPendingTask({
|
|
344
|
+
reason: "budget_exhausted",
|
|
345
|
+
description: `Needs top-off to continue goal: ${goalText.slice(0, 300)}`,
|
|
346
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
347
|
+
}).catch(() => { });
|
|
348
|
+
await this.runtime.identity.updateGoalStatus("paused_awaiting_topoff").catch(() => { });
|
|
349
|
+
this.stop();
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if (result.outcome === "blocked_stuck") {
|
|
353
|
+
await this.runtime.identity.createPendingTask({
|
|
354
|
+
reason: "stuck_3x",
|
|
355
|
+
description: result.stuckReason,
|
|
356
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
357
|
+
}).catch(() => { });
|
|
358
|
+
await this.runtime.identity.updateGoalStatus("blocked_needs_decision").catch(() => { });
|
|
359
|
+
this.stop();
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (result.outcome === "blocked_capability") {
|
|
363
|
+
await this.runtime.identity.createPendingTask({
|
|
364
|
+
reason: "needs_capability",
|
|
365
|
+
description: result.capabilityNeeded,
|
|
366
|
+
suggestedPresetId: result.suggestedPreset,
|
|
367
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
368
|
+
}).catch(() => { });
|
|
369
|
+
await this.runtime.identity.updateGoalStatus("blocked_needs_decision").catch(() => { });
|
|
370
|
+
this.stop();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// ================================================================
|
|
206
375
|
// Signal handling (proactive.signal)
|
|
207
376
|
// ================================================================
|
|
208
377
|
/**
|
|
@@ -433,9 +602,7 @@ export class AutonomousAgent {
|
|
|
433
602
|
case "community_gap":
|
|
434
603
|
await this.handleCommunityGap(data);
|
|
435
604
|
break;
|
|
436
|
-
case
|
|
437
|
-
await this.handleDirective(data);
|
|
438
|
-
break;
|
|
605
|
+
// DD-7: directive case removed — swarm coordination uses DMs
|
|
439
606
|
case "files_committed":
|
|
440
607
|
await this.handleFilesCommitted(data);
|
|
441
608
|
break;
|
|
@@ -1954,40 +2121,7 @@ export class AutonomousAgent {
|
|
|
1954
2121
|
console.error("[autonomous] Community gap handling failed:", err);
|
|
1955
2122
|
}
|
|
1956
2123
|
}
|
|
1957
|
-
|
|
1958
|
-
const directiveContent = data.messagePreview ?? "";
|
|
1959
|
-
const channelId = data.channelId;
|
|
1960
|
-
const community = data.community ?? "general";
|
|
1961
|
-
try {
|
|
1962
|
-
const prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\n` +
|
|
1963
|
-
"You received a directive on Nookplot.\n" +
|
|
1964
|
-
`Directive:\n${wrapUntrusted(directiveContent, "directive")}\n\n` +
|
|
1965
|
-
"Follow the directive and compose your response.\n" +
|
|
1966
|
-
"If it asks you to post, write the post content.\n" +
|
|
1967
|
-
"If it asks you to discuss, write a discussion message.\n" +
|
|
1968
|
-
"If you can't follow this directive, respond with exactly: [SKIP]\n\n" +
|
|
1969
|
-
"Your response (under 500 chars):";
|
|
1970
|
-
const response = await this.generateResponse(prompt);
|
|
1971
|
-
const content = response?.trim() ?? "";
|
|
1972
|
-
if (content && content !== "[SKIP]") {
|
|
1973
|
-
if (channelId) {
|
|
1974
|
-
await this.runtime.channels.send(channelId, content);
|
|
1975
|
-
if (this.verbose)
|
|
1976
|
-
console.log(`[autonomous] ✓ Directive response sent to channel ${channelId.slice(0, 12)}`);
|
|
1977
|
-
}
|
|
1978
|
-
else {
|
|
1979
|
-
const title = content.slice(0, 100);
|
|
1980
|
-
await this.runtime.memory.publishKnowledge({ title, body: content, community });
|
|
1981
|
-
if (this.verbose)
|
|
1982
|
-
console.log(`[autonomous] ✓ Directive response posted in ${community}`);
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
catch (err) {
|
|
1987
|
-
if (this.verbose)
|
|
1988
|
-
console.error("[autonomous] Directive handling failed:", err);
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
2124
|
+
// DD-7: handleDirective removed — swarm coordination uses DMs exclusively
|
|
1991
2125
|
// ================================================================
|
|
1992
2126
|
// Project collaboration signal handlers
|
|
1993
2127
|
// ================================================================
|
|
@@ -2715,6 +2849,30 @@ export class AutonomousAgent {
|
|
|
2715
2849
|
});
|
|
2716
2850
|
return;
|
|
2717
2851
|
}
|
|
2852
|
+
// ── Intercept ecosystem raw-tx actions ──
|
|
2853
|
+
// External partner contracts (BOTCOIN, etc.) don't trust Nookplot's
|
|
2854
|
+
// EIP-2771 forwarder. The gateway returns { txRequests, meta } instead
|
|
2855
|
+
// of a ForwardRequest, and the agent signs+submits with own wallet.
|
|
2856
|
+
if (actionType === "ecosystem_stake_tokens" || actionType === "ecosystem_claim_rewards") {
|
|
2857
|
+
const { prepareSignSend } = await import("./signing.js");
|
|
2858
|
+
const preparePath = actionType === "ecosystem_stake_tokens"
|
|
2859
|
+
? "/v1/prepare/ecosystem/stake-tokens"
|
|
2860
|
+
: "/v1/prepare/ecosystem/claim-rewards";
|
|
2861
|
+
const sendResult = await prepareSignSend(this.runtime.connection, preparePath, args);
|
|
2862
|
+
const hashes = sendResult.txHashes ?? [];
|
|
2863
|
+
txHash = hashes.length > 0 ? hashes[hashes.length - 1] : undefined;
|
|
2864
|
+
result = { txHashes: hashes, meta: sendResult.meta };
|
|
2865
|
+
result = await guardrails.runOutput(actionType, result);
|
|
2866
|
+
hooks.emitFireAndForget("tool_output", { toolName: actionType, args, result });
|
|
2867
|
+
if (actionId)
|
|
2868
|
+
await this.runtime.proactive.completeAction(actionId, txHash, result);
|
|
2869
|
+
if (this.verbose)
|
|
2870
|
+
console.log(`[autonomous] ✓ ${actionType}${txHash ? ` tx=${txHash}` : ""}`);
|
|
2871
|
+
hooks.emitFireAndForget("action_end", {
|
|
2872
|
+
actionType, args, result, durationMs: Date.now() - startTime, actionId, txHash,
|
|
2873
|
+
});
|
|
2874
|
+
return;
|
|
2875
|
+
}
|
|
2718
2876
|
// ── Unified dispatch via POST /v1/actions/execute ──
|
|
2719
2877
|
// The gateway's ToolDispatcher routes the call to the correct internal
|
|
2720
2878
|
// endpoint, replacing the 2000+ line switch statement that was here before.
|