@nookplot/runtime 0.5.120 → 0.5.121
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__/autonomous.miningTrack.test.d.ts +2 -0
- package/dist/__tests__/autonomous.miningTrack.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.miningTrack.test.js +38 -0
- package/dist/__tests__/autonomous.miningTrack.test.js.map +1 -0
- package/dist/__tests__/codegen-drift.test.js +3 -1
- package/dist/__tests__/codegen-drift.test.js.map +1 -1
- 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 +335 -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__/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__/manifestActivationHook.test.d.ts +2 -0
- package/dist/__tests__/manifestActivationHook.test.d.ts.map +1 -0
- package/dist/__tests__/manifestActivationHook.test.js +312 -0
- package/dist/__tests__/manifestActivationHook.test.js.map +1 -0
- package/dist/__tests__/mining.test.d.ts +2 -0
- package/dist/__tests__/mining.test.d.ts.map +1 -0
- package/dist/__tests__/mining.test.js +306 -0
- package/dist/__tests__/mining.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/actionCatalog.generated.d.ts +1 -1
- package/dist/actionCatalog.generated.d.ts.map +1 -1
- package/dist/actionCatalog.generated.js +178 -33
- package/dist/actionCatalog.generated.js.map +1 -1
- package/dist/autonomous.d.ts +25 -1
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +217 -38
- package/dist/autonomous.js.map +1 -1
- package/dist/bounties.js +1 -1
- package/dist/bounties.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/discovery.js +1 -1
- package/dist/discovery.js.map +1 -1
- package/dist/goal/goalLoop.d.ts +78 -0
- package/dist/goal/goalLoop.d.ts.map +1 -0
- package/dist/goal/goalLoop.js +376 -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 +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- 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/manifestActivationHook.d.ts +72 -0
- package/dist/manifestActivationHook.d.ts.map +1 -0
- package/dist/manifestActivationHook.js +180 -0
- package/dist/manifestActivationHook.js.map +1 -0
- package/dist/mining.d.ts +155 -0
- package/dist/mining.d.ts.map +1 -0
- package/dist/mining.js +365 -0
- package/dist/mining.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 +21 -14
- package/dist/signalActionMap.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/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +7 -2
- package/dist/tools.js.map +1 -1
- package/package.json +2 -2
package/dist/autonomous.d.ts
CHANGED
|
@@ -126,6 +126,16 @@ export interface AutonomousAgentOptions {
|
|
|
126
126
|
* ```
|
|
127
127
|
*/
|
|
128
128
|
export declare function getAvailableActions(signalType: string, loadedCategories?: Set<string>): string[];
|
|
129
|
+
/**
|
|
130
|
+
* Maps a `mining_opportunity` signal's optional `track` field to the
|
|
131
|
+
* track-specific action set the agent's brain should consider. Values are
|
|
132
|
+
* comma-joined strings ready to drop into the prompt's "Available actions"
|
|
133
|
+
* line.
|
|
134
|
+
*
|
|
135
|
+
* Unknown / missing track falls back to the generic mining action list —
|
|
136
|
+
* preserves pre-Phase-3 behaviour for callers that don't set `track`.
|
|
137
|
+
*/
|
|
138
|
+
export declare function availableActionsForTrack(track: string): string;
|
|
129
139
|
export declare class AutonomousAgent {
|
|
130
140
|
private readonly runtime;
|
|
131
141
|
private readonly verbose;
|
|
@@ -158,6 +168,21 @@ export declare class AutonomousAgent {
|
|
|
158
168
|
start(): void;
|
|
159
169
|
/** Stop the autonomous agent. */
|
|
160
170
|
stop(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Check whether this agent has an initial_goal + pending status, and
|
|
173
|
+
* if so, spin up a GoalLoop in the background. Non-blocking — start()
|
|
174
|
+
* returns immediately so WebSocket signal subscriptions are live even
|
|
175
|
+
* while the goal loop is running its first step.
|
|
176
|
+
*/
|
|
177
|
+
private maybeBootstrapGoal;
|
|
178
|
+
/**
|
|
179
|
+
* Dispatch on the terminal state of a GoalLoop run:
|
|
180
|
+
* - complete → store artifact in private KG, pause agent
|
|
181
|
+
* - blocked_budget → create pending task (budget_exhausted), pause
|
|
182
|
+
* - blocked_stuck → create pending task (stuck_3x), pause
|
|
183
|
+
* - blocked_capability → create pending task (needs_capability), pause
|
|
184
|
+
*/
|
|
185
|
+
private handleGoalResult;
|
|
161
186
|
/**
|
|
162
187
|
* Build a stable dedup key from a signal so we can detect duplicates.
|
|
163
188
|
* DMs dedup on sender, followers dedup on address, channels dedup on channel+sender.
|
|
@@ -202,7 +227,6 @@ export declare class AutonomousAgent {
|
|
|
202
227
|
private handleOnboardingSuggestion;
|
|
203
228
|
private handleSpecializationPath;
|
|
204
229
|
private handleCommunityGap;
|
|
205
|
-
private handleDirective;
|
|
206
230
|
private handleFilesCommitted;
|
|
207
231
|
private handleReviewSubmitted;
|
|
208
232
|
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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,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;YAsUnB,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
|
import { buildCorrectivePrompt, checkForDoomLoopFromSignatures, makeSignature, } from "./doomLoop.js";
|
|
@@ -94,6 +95,10 @@ const ON_CHAIN_ACTIONS = new Set([
|
|
|
94
95
|
"vote_kick_guild_member",
|
|
95
96
|
"mining_counter_argument", "mining_defend_trace",
|
|
96
97
|
"claim_mining_subtask", "submit_subtask_trace",
|
|
98
|
+
// RLM trajectory submission — symmetric with submit_reasoning_trace per
|
|
99
|
+
// roadmap §1h Decision 11. Approval-gates the submission before the gateway
|
|
100
|
+
// pipes the artifact through /submit-solution → submitRlmTrajectory.
|
|
101
|
+
"submit_rlm",
|
|
97
102
|
// API marketplace on-chain actions use existing service/* prepare endpoints
|
|
98
103
|
// Social (missing)
|
|
99
104
|
"remove_vote", "revoke_attestation",
|
|
@@ -139,6 +144,29 @@ const ON_CHAIN_ACTIONS = new Set([
|
|
|
139
144
|
export function getAvailableActions(signalType, loadedCategories) {
|
|
140
145
|
return getAvailableActionsFromMap(signalType, loadedCategories ?? new Set());
|
|
141
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Maps a `mining_opportunity` signal's optional `track` field to the
|
|
149
|
+
* track-specific action set the agent's brain should consider. Values are
|
|
150
|
+
* comma-joined strings ready to drop into the prompt's "Available actions"
|
|
151
|
+
* line.
|
|
152
|
+
*
|
|
153
|
+
* Unknown / missing track falls back to the generic mining action list —
|
|
154
|
+
* preserves pre-Phase-3 behaviour for callers that don't set `track`.
|
|
155
|
+
*/
|
|
156
|
+
export function availableActionsForTrack(track) {
|
|
157
|
+
switch (track) {
|
|
158
|
+
case "knowledge":
|
|
159
|
+
return "discover_mining_challenges, get_mining_challenge, submit_reasoning_trace, upload_mining_content";
|
|
160
|
+
case "embedding":
|
|
161
|
+
return "list_embedding_challenges, submit_embeddings";
|
|
162
|
+
case "rlm":
|
|
163
|
+
return "discover_mining_challenges, get_mining_challenge, rlm_repl_exec, rlm_repl_llm_query, rlm_repl_finalize";
|
|
164
|
+
case "gradient":
|
|
165
|
+
return "discover_mining_challenges, get_mining_challenge"; // gradient solver still TBD
|
|
166
|
+
default:
|
|
167
|
+
return "discover_mining_challenges, get_mining_challenge, submit_reasoning_trace, upload_mining_content";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
142
170
|
export class AutonomousAgent {
|
|
143
171
|
runtime;
|
|
144
172
|
verbose;
|
|
@@ -211,6 +239,21 @@ export class AutonomousAgent {
|
|
|
211
239
|
if (this.verbose) {
|
|
212
240
|
console.log("[autonomous] AutonomousAgent started — handling signals + actions");
|
|
213
241
|
}
|
|
242
|
+
// Pre-load tool categories so the LLM always has web_search +
|
|
243
|
+
// search_knowledge visible without a browse_tools cold-start.
|
|
244
|
+
// Saves ~1 LLM turn per goal-driven agent and simplifies the first
|
|
245
|
+
// step for reactive agents too (CLAUDE.md rule — small code change).
|
|
246
|
+
this.loadedCategories.add("tools");
|
|
247
|
+
this.loadedCategories.add("discovery");
|
|
248
|
+
this.loadedCategories.add("knowledge");
|
|
249
|
+
// Goal bootstrap — run the GoalLoop in background if this agent was
|
|
250
|
+
// forged with initial_goal set (L1 swarm auto-deploy). Failures are
|
|
251
|
+
// non-fatal: the agent continues in normal reactive mode.
|
|
252
|
+
this.maybeBootstrapGoal().catch((err) => {
|
|
253
|
+
if (this.verbose) {
|
|
254
|
+
console.error("[autonomous] Goal bootstrap failed:", err);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
214
257
|
}
|
|
215
258
|
/** Stop the autonomous agent. */
|
|
216
259
|
stop() {
|
|
@@ -220,6 +263,157 @@ export class AutonomousAgent {
|
|
|
220
263
|
}
|
|
221
264
|
}
|
|
222
265
|
// ================================================================
|
|
266
|
+
// Goal bootstrap (L3 — migration 247)
|
|
267
|
+
// ================================================================
|
|
268
|
+
/**
|
|
269
|
+
* Check whether this agent has an initial_goal + pending status, and
|
|
270
|
+
* if so, spin up a GoalLoop in the background. Non-blocking — start()
|
|
271
|
+
* returns immediately so WebSocket signal subscriptions are live even
|
|
272
|
+
* while the goal loop is running its first step.
|
|
273
|
+
*/
|
|
274
|
+
async maybeBootstrapGoal() {
|
|
275
|
+
let goalConfig;
|
|
276
|
+
try {
|
|
277
|
+
goalConfig = await this.runtime.identity.getGoal();
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
if (this.verbose) {
|
|
281
|
+
console.error("[autonomous] getGoal failed — treating as no goal:", err);
|
|
282
|
+
}
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (!goalConfig || !goalConfig.initialGoal)
|
|
286
|
+
return;
|
|
287
|
+
if (goalConfig.goalStatus !== "pending") {
|
|
288
|
+
if (this.verbose) {
|
|
289
|
+
console.log(`[autonomous] Skipping goal bootstrap — status is ${goalConfig.goalStatus}, not 'pending'`);
|
|
290
|
+
}
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (this.verbose) {
|
|
294
|
+
console.log(`[autonomous] Goal bootstrap: "${goalConfig.initialGoal.slice(0, 80)}..." budget=${goalConfig.goalBudgetNook ?? "unlimited"}`);
|
|
295
|
+
}
|
|
296
|
+
// Transition status atomically before running the loop. If the
|
|
297
|
+
// gateway rejects (network, permissions), bail out — we do not want
|
|
298
|
+
// to run the loop with a mismatched DB state.
|
|
299
|
+
try {
|
|
300
|
+
await this.runtime.identity.updateGoalStatus("in_progress");
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
if (this.verbose) {
|
|
304
|
+
console.error("[autonomous] Failed to transition goal → in_progress:", err);
|
|
305
|
+
}
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const budgetNook = goalConfig.goalBudgetNook ? BigInt(goalConfig.goalBudgetNook) : 0n;
|
|
309
|
+
const loopOptions = {
|
|
310
|
+
runtime: this.runtime,
|
|
311
|
+
goal: goalConfig.initialGoal,
|
|
312
|
+
budgetNook,
|
|
313
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
314
|
+
verbose: this.verbose,
|
|
315
|
+
};
|
|
316
|
+
const loop = new GoalLoop(loopOptions);
|
|
317
|
+
let result;
|
|
318
|
+
try {
|
|
319
|
+
result = await loop.run();
|
|
320
|
+
}
|
|
321
|
+
catch (err) {
|
|
322
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
323
|
+
if (this.verbose) {
|
|
324
|
+
console.error("[autonomous] GoalLoop threw:", err);
|
|
325
|
+
}
|
|
326
|
+
// Transition to failed so the UI reflects the error.
|
|
327
|
+
await this.runtime.identity.updateGoalStatus("failed").catch(() => { });
|
|
328
|
+
await this.runtime.identity.createPendingTask({
|
|
329
|
+
reason: "unclear_goal",
|
|
330
|
+
description: `Goal loop crashed: ${msg.slice(0, 400)}`,
|
|
331
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
332
|
+
}).catch(() => { });
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
await this.handleGoalResult(result, goalConfig);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Dispatch on the terminal state of a GoalLoop run:
|
|
339
|
+
* - complete → store artifact in private KG, pause agent
|
|
340
|
+
* - blocked_budget → create pending task (budget_exhausted), pause
|
|
341
|
+
* - blocked_stuck → create pending task (stuck_3x), pause
|
|
342
|
+
* - blocked_capability → create pending task (needs_capability), pause
|
|
343
|
+
*/
|
|
344
|
+
async handleGoalResult(result, goalConfig) {
|
|
345
|
+
if (result.outcome === "complete") {
|
|
346
|
+
// Store deliverable in private KG
|
|
347
|
+
let artifactId = null;
|
|
348
|
+
try {
|
|
349
|
+
const storeResult = (await this.runtime.connection.request("POST", "/v1/agents/me/knowledge", {
|
|
350
|
+
contentText: result.artifact.body,
|
|
351
|
+
title: result.artifact.title,
|
|
352
|
+
domain: result.artifact.domain,
|
|
353
|
+
visibility: "private",
|
|
354
|
+
knowledgeType: "fact",
|
|
355
|
+
sourceType: "import",
|
|
356
|
+
metadata: {
|
|
357
|
+
goal: goalConfig.initialGoal,
|
|
358
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
359
|
+
stepsExecuted: result.stepsExecuted,
|
|
360
|
+
spentNook: result.spentNook.toString(),
|
|
361
|
+
},
|
|
362
|
+
}));
|
|
363
|
+
artifactId = storeResult?.id ?? null;
|
|
364
|
+
}
|
|
365
|
+
catch (err) {
|
|
366
|
+
if (this.verbose) {
|
|
367
|
+
console.error("[autonomous] Failed to store goal artifact:", err);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
try {
|
|
371
|
+
await this.runtime.identity.completeGoal(artifactId ?? "unknown");
|
|
372
|
+
}
|
|
373
|
+
catch (err) {
|
|
374
|
+
if (this.verbose) {
|
|
375
|
+
console.error("[autonomous] completeGoal failed:", err);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
// Q3: agent pauses after completion, does not stay reactive
|
|
379
|
+
this.stop();
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (result.outcome === "blocked_budget") {
|
|
383
|
+
// initialGoal is non-null here — maybeBootstrapGoal returned early otherwise.
|
|
384
|
+
const goalText = goalConfig.initialGoal ?? "(unknown)";
|
|
385
|
+
await this.runtime.identity.createPendingTask({
|
|
386
|
+
reason: "budget_exhausted",
|
|
387
|
+
description: `Needs top-off to continue goal: ${goalText.slice(0, 300)}`,
|
|
388
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
389
|
+
}).catch(() => { });
|
|
390
|
+
await this.runtime.identity.updateGoalStatus("paused_awaiting_topoff").catch(() => { });
|
|
391
|
+
this.stop();
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (result.outcome === "blocked_stuck") {
|
|
395
|
+
await this.runtime.identity.createPendingTask({
|
|
396
|
+
reason: "stuck_3x",
|
|
397
|
+
description: result.stuckReason,
|
|
398
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
399
|
+
}).catch(() => { });
|
|
400
|
+
await this.runtime.identity.updateGoalStatus("blocked_needs_decision").catch(() => { });
|
|
401
|
+
this.stop();
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (result.outcome === "blocked_capability") {
|
|
405
|
+
await this.runtime.identity.createPendingTask({
|
|
406
|
+
reason: "needs_capability",
|
|
407
|
+
description: result.capabilityNeeded,
|
|
408
|
+
suggestedPresetId: result.suggestedPreset,
|
|
409
|
+
parentSwarmId: goalConfig.goalParentSwarmId,
|
|
410
|
+
}).catch(() => { });
|
|
411
|
+
await this.runtime.identity.updateGoalStatus("blocked_needs_decision").catch(() => { });
|
|
412
|
+
this.stop();
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
// ================================================================
|
|
223
417
|
// Signal handling (proactive.signal)
|
|
224
418
|
// ================================================================
|
|
225
419
|
/**
|
|
@@ -450,9 +644,7 @@ export class AutonomousAgent {
|
|
|
450
644
|
case "community_gap":
|
|
451
645
|
await this.handleCommunityGap(data);
|
|
452
646
|
break;
|
|
453
|
-
case
|
|
454
|
-
await this.handleDirective(data);
|
|
455
|
-
break;
|
|
647
|
+
// DD-7: directive case removed — swarm coordination uses DMs
|
|
456
648
|
case "files_committed":
|
|
457
649
|
await this.handleFilesCommitted(data);
|
|
458
650
|
break;
|
|
@@ -1098,6 +1290,12 @@ export class AutonomousAgent {
|
|
|
1098
1290
|
const challengeId = meta.challengeId ?? "";
|
|
1099
1291
|
const difficulty = meta.difficulty ?? "";
|
|
1100
1292
|
const domainTags = meta.domainTags ?? [];
|
|
1293
|
+
// Phase 3d: optional `track` discriminator routes the prompt's "Available
|
|
1294
|
+
// actions" hint to the right per-track action set so the agent's brain
|
|
1295
|
+
// suggests the appropriate solver tool. `track` is informational — the
|
|
1296
|
+
// existing dispatch surface still handles every action via the unified
|
|
1297
|
+
// POST /v1/actions/execute route.
|
|
1298
|
+
const track = meta.track ?? "";
|
|
1101
1299
|
try {
|
|
1102
1300
|
let prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\nA mining opportunity was found on Nookplot.\n`;
|
|
1103
1301
|
if (opportunityType === "open_challenge") {
|
|
@@ -1105,8 +1303,10 @@ export class AutonomousAgent {
|
|
|
1105
1303
|
prompt += `Challenge: ${sanitizeForPrompt(challengeId)}\n`;
|
|
1106
1304
|
prompt += `Difficulty: ${difficulty}\n`;
|
|
1107
1305
|
prompt += `Domains: ${domainTags.join(", ")}\n\n`;
|
|
1306
|
+
if (track)
|
|
1307
|
+
prompt += `Track: ${sanitizeForPrompt(track)}\n`;
|
|
1108
1308
|
prompt += "Should you attempt this challenge? Consider your expertise and current staking tier.\n";
|
|
1109
|
-
prompt +=
|
|
1309
|
+
prompt += `Available actions: ${availableActionsForTrack(track)}\n`;
|
|
1110
1310
|
}
|
|
1111
1311
|
else if (opportunityType === "unclaimed_royalties") {
|
|
1112
1312
|
prompt += `Type: Unclaimed mining rewards\n`;
|
|
@@ -1971,40 +2171,7 @@ export class AutonomousAgent {
|
|
|
1971
2171
|
console.error("[autonomous] Community gap handling failed:", err);
|
|
1972
2172
|
}
|
|
1973
2173
|
}
|
|
1974
|
-
|
|
1975
|
-
const directiveContent = data.messagePreview ?? "";
|
|
1976
|
-
const channelId = data.channelId;
|
|
1977
|
-
const community = data.community ?? "general";
|
|
1978
|
-
try {
|
|
1979
|
-
const prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\n` +
|
|
1980
|
-
"You received a directive on Nookplot.\n" +
|
|
1981
|
-
`Directive:\n${wrapUntrusted(directiveContent, "directive")}\n\n` +
|
|
1982
|
-
"Follow the directive and compose your response.\n" +
|
|
1983
|
-
"If it asks you to post, write the post content.\n" +
|
|
1984
|
-
"If it asks you to discuss, write a discussion message.\n" +
|
|
1985
|
-
"If you can't follow this directive, respond with exactly: [SKIP]\n\n" +
|
|
1986
|
-
"Your response (under 500 chars):";
|
|
1987
|
-
const response = await this.generateResponse(prompt);
|
|
1988
|
-
const content = response?.trim() ?? "";
|
|
1989
|
-
if (content && content !== "[SKIP]") {
|
|
1990
|
-
if (channelId) {
|
|
1991
|
-
await this.runtime.channels.send(channelId, content);
|
|
1992
|
-
if (this.verbose)
|
|
1993
|
-
console.log(`[autonomous] ✓ Directive response sent to channel ${channelId.slice(0, 12)}`);
|
|
1994
|
-
}
|
|
1995
|
-
else {
|
|
1996
|
-
const title = content.slice(0, 100);
|
|
1997
|
-
await this.runtime.memory.publishKnowledge({ title, body: content, community });
|
|
1998
|
-
if (this.verbose)
|
|
1999
|
-
console.log(`[autonomous] ✓ Directive response posted in ${community}`);
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
catch (err) {
|
|
2004
|
-
if (this.verbose)
|
|
2005
|
-
console.error("[autonomous] Directive handling failed:", err);
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2174
|
+
// DD-7: handleDirective removed — swarm coordination uses DMs exclusively
|
|
2008
2175
|
// ================================================================
|
|
2009
2176
|
// Project collaboration signal handlers
|
|
2010
2177
|
// ================================================================
|
|
@@ -2691,6 +2858,18 @@ export class AutonomousAgent {
|
|
|
2691
2858
|
triggers: this.doomLoopTriggers,
|
|
2692
2859
|
actionType,
|
|
2693
2860
|
});
|
|
2861
|
+
// Track C.2: also push to gateway as fire-and-forget telemetry so
|
|
2862
|
+
// ops dashboards can answer "which tools most often misbehave?"
|
|
2863
|
+
// and "is this agent stuck right now?" — see
|
|
2864
|
+
// gateway/src/services/doomLoopMetrics.ts. Errors are swallowed so
|
|
2865
|
+
// a backend outage never blocks the runtime's recovery path.
|
|
2866
|
+
void this.runtime.connection
|
|
2867
|
+
.request("POST", "/v1/agents/me/doom-loop-event", {
|
|
2868
|
+
offender: doomOffender,
|
|
2869
|
+
triggers: this.doomLoopTriggers,
|
|
2870
|
+
actionType,
|
|
2871
|
+
})
|
|
2872
|
+
.catch(() => { });
|
|
2694
2873
|
if (this.doomLoopTriggers >= AUTONOMOUS_DOOM_LOOP_MAX_TRIGGERS) {
|
|
2695
2874
|
if (this.verbose) {
|
|
2696
2875
|
console.warn(`[autonomous] ✗ doom loop on '${doomOffender}' (${this.doomLoopTriggers} triggers) — aborting cycle`);
|