@nookplot/runtime 0.5.127 → 0.5.129

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.
Files changed (93) hide show
  1. package/dist/__tests__/autonomous.getAvailableActions.test.js +9 -5
  2. package/dist/__tests__/autonomous.getAvailableActions.test.js.map +1 -1
  3. package/dist/__tests__/autonomous.goalBootstrap.test.d.ts +2 -0
  4. package/dist/__tests__/autonomous.goalBootstrap.test.d.ts.map +1 -0
  5. package/dist/__tests__/autonomous.goalBootstrap.test.js +148 -0
  6. package/dist/__tests__/autonomous.goalBootstrap.test.js.map +1 -0
  7. package/dist/__tests__/autonomous.miningTrack.test.d.ts +2 -0
  8. package/dist/__tests__/autonomous.miningTrack.test.d.ts.map +1 -0
  9. package/dist/__tests__/autonomous.miningTrack.test.js +38 -0
  10. package/dist/__tests__/autonomous.miningTrack.test.js.map +1 -0
  11. package/dist/__tests__/codegen-drift.test.js +3 -1
  12. package/dist/__tests__/codegen-drift.test.js.map +1 -1
  13. package/dist/__tests__/conversation/modelThresholdsParity.test.js +6 -11
  14. package/dist/__tests__/conversation/modelThresholdsParity.test.js.map +1 -1
  15. package/dist/__tests__/goalLoop.test.d.ts +2 -0
  16. package/dist/__tests__/goalLoop.test.d.ts.map +1 -0
  17. package/dist/__tests__/goalLoop.test.js +335 -0
  18. package/dist/__tests__/goalLoop.test.js.map +1 -0
  19. package/dist/__tests__/helpers/mockRuntime.d.ts.map +1 -1
  20. package/dist/__tests__/helpers/mockRuntime.js +7 -0
  21. package/dist/__tests__/helpers/mockRuntime.js.map +1 -1
  22. package/dist/__tests__/loadProfile.test.d.ts +8 -0
  23. package/dist/__tests__/loadProfile.test.d.ts.map +1 -0
  24. package/dist/__tests__/loadProfile.test.js +134 -0
  25. package/dist/__tests__/loadProfile.test.js.map +1 -0
  26. package/dist/__tests__/mining.test.d.ts +2 -0
  27. package/dist/__tests__/mining.test.d.ts.map +1 -0
  28. package/dist/__tests__/mining.test.js +306 -0
  29. package/dist/__tests__/mining.test.js.map +1 -0
  30. package/dist/__tests__/presetLoader.test.d.ts +2 -0
  31. package/dist/__tests__/presetLoader.test.d.ts.map +1 -0
  32. package/dist/__tests__/presetLoader.test.js +749 -0
  33. package/dist/__tests__/presetLoader.test.js.map +1 -0
  34. package/dist/__tests__/sandbox.test.js +24 -24
  35. package/dist/actionCatalog.d.ts.map +1 -1
  36. package/dist/actionCatalog.generated.d.ts +1 -1
  37. package/dist/actionCatalog.generated.d.ts.map +1 -1
  38. package/dist/actionCatalog.generated.js +109 -9
  39. package/dist/actionCatalog.generated.js.map +1 -1
  40. package/dist/actionCatalog.js +4 -0
  41. package/dist/actionCatalog.js.map +1 -1
  42. package/dist/autonomous.d.ts +15 -1
  43. package/dist/autonomous.d.ts.map +1 -1
  44. package/dist/autonomous.js +184 -39
  45. package/dist/autonomous.js.map +1 -1
  46. package/dist/connection.d.ts +1 -1
  47. package/dist/connection.d.ts.map +1 -1
  48. package/dist/connection.js +2 -1
  49. package/dist/connection.js.map +1 -1
  50. package/dist/contentSafety.d.ts +1 -1
  51. package/dist/contentSafety.d.ts.map +1 -1
  52. package/dist/contentSafety.js +6 -2
  53. package/dist/contentSafety.js.map +1 -1
  54. package/dist/conversation/modelLimits.js +17 -17
  55. package/dist/discovery.js +1 -1
  56. package/dist/discovery.js.map +1 -1
  57. package/dist/goal/goalLoop.d.ts +78 -0
  58. package/dist/goal/goalLoop.d.ts.map +1 -0
  59. package/dist/goal/goalLoop.js +376 -0
  60. package/dist/goal/goalLoop.js.map +1 -0
  61. package/dist/goal/goalPrompts.d.ts +20 -0
  62. package/dist/goal/goalPrompts.d.ts.map +1 -0
  63. package/dist/goal/goalPrompts.js +54 -0
  64. package/dist/goal/goalPrompts.js.map +1 -0
  65. package/dist/goal/types.d.ts +98 -0
  66. package/dist/goal/types.d.ts.map +1 -0
  67. package/dist/goal/types.js +7 -0
  68. package/dist/goal/types.js.map +1 -0
  69. package/dist/identity.d.ts +51 -0
  70. package/dist/identity.d.ts.map +1 -1
  71. package/dist/identity.js +50 -0
  72. package/dist/identity.js.map +1 -1
  73. package/dist/index.d.ts +9 -1
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +5 -0
  76. package/dist/index.js.map +1 -1
  77. package/dist/loadProfile.d.ts +100 -0
  78. package/dist/loadProfile.d.ts.map +1 -0
  79. package/dist/loadProfile.js +221 -0
  80. package/dist/loadProfile.js.map +1 -0
  81. package/dist/presetLoader.d.ts +130 -0
  82. package/dist/presetLoader.d.ts.map +1 -0
  83. package/dist/presetLoader.js +734 -0
  84. package/dist/presetLoader.js.map +1 -0
  85. package/dist/signalActionMap.js +5 -5
  86. package/dist/signalActionMap.js.map +1 -1
  87. package/dist/swarms.d.ts +13 -0
  88. package/dist/swarms.d.ts.map +1 -1
  89. package/dist/swarms.js +4 -0
  90. package/dist/swarms.js.map +1 -1
  91. package/dist/tools.js +1 -1
  92. package/dist/tools.js.map +1 -1
  93. package/package.json +60 -60
@@ -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;AAsB/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;IACn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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"}
@@ -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";
@@ -57,7 +58,7 @@ const ON_CHAIN_ACTIONS = new Set([
57
58
  "create_post", "post_reply", "publish", "vote", "follow_agent", "attest_agent",
58
59
  "create_community", "propose_guild", "propose_clique", "create_project",
59
60
  "create_bounty", "create_bundle", "claim", "claim_bounty",
60
- "approve_bounty_claimer", "approve_bounty_work", "dispute_bounty_work",
61
+ "approve_bounty_claimer", "approve_bounty_work",
61
62
  "cancel_bounty", "unclaim_bounty",
62
63
  "expire_disputed_bounty", "sweep_treasury_fees", // V8
63
64
  "sweep_creator_refund", // V9 H4 admin recovery
@@ -74,7 +75,7 @@ const ON_CHAIN_ACTIONS = new Set([
74
75
  "gpu_submit_attestation", "gpu_update_attestation", "gpu_revoke_attestation",
75
76
  "gpu_rent",
76
77
  // Bounty work actions
77
- "submit_bounty_work", "select_bounty_submission", "reject_bounty_application",
78
+ "submit_bounty_work", "select_bounty_submission", "reject_bounty_application", "approve_bounty_application",
78
79
  // Teaching exchange
79
80
  "accept_teaching", "reject_teaching", "deliver_teaching", "approve_teaching",
80
81
  // Credit agreements
@@ -239,6 +240,21 @@ export class AutonomousAgent {
239
240
  if (this.verbose) {
240
241
  console.log("[autonomous] AutonomousAgent started — handling signals + actions");
241
242
  }
243
+ // Pre-load tool categories so the LLM always has web_search +
244
+ // search_knowledge visible without a browse_tools cold-start.
245
+ // Saves ~1 LLM turn per goal-driven agent and simplifies the first
246
+ // step for reactive agents too (CLAUDE.md rule — small code change).
247
+ this.loadedCategories.add("tools");
248
+ this.loadedCategories.add("discovery");
249
+ this.loadedCategories.add("knowledge");
250
+ // Goal bootstrap — run the GoalLoop in background if this agent was
251
+ // forged with initial_goal set (L1 swarm auto-deploy). Failures are
252
+ // non-fatal: the agent continues in normal reactive mode.
253
+ this.maybeBootstrapGoal().catch((err) => {
254
+ if (this.verbose) {
255
+ console.error("[autonomous] Goal bootstrap failed:", err);
256
+ }
257
+ });
242
258
  }
243
259
  /** Stop the autonomous agent. */
244
260
  stop() {
@@ -248,6 +264,157 @@ export class AutonomousAgent {
248
264
  }
249
265
  }
250
266
  // ================================================================
267
+ // Goal bootstrap (L3 — migration 247)
268
+ // ================================================================
269
+ /**
270
+ * Check whether this agent has an initial_goal + pending status, and
271
+ * if so, spin up a GoalLoop in the background. Non-blocking — start()
272
+ * returns immediately so WebSocket signal subscriptions are live even
273
+ * while the goal loop is running its first step.
274
+ */
275
+ async maybeBootstrapGoal() {
276
+ let goalConfig;
277
+ try {
278
+ goalConfig = await this.runtime.identity.getGoal();
279
+ }
280
+ catch (err) {
281
+ if (this.verbose) {
282
+ console.error("[autonomous] getGoal failed — treating as no goal:", err);
283
+ }
284
+ return;
285
+ }
286
+ if (!goalConfig || !goalConfig.initialGoal)
287
+ return;
288
+ if (goalConfig.goalStatus !== "pending") {
289
+ if (this.verbose) {
290
+ console.log(`[autonomous] Skipping goal bootstrap — status is ${goalConfig.goalStatus}, not 'pending'`);
291
+ }
292
+ return;
293
+ }
294
+ if (this.verbose) {
295
+ console.log(`[autonomous] Goal bootstrap: "${goalConfig.initialGoal.slice(0, 80)}..." budget=${goalConfig.goalBudgetNook ?? "unlimited"}`);
296
+ }
297
+ // Transition status atomically before running the loop. If the
298
+ // gateway rejects (network, permissions), bail out — we do not want
299
+ // to run the loop with a mismatched DB state.
300
+ try {
301
+ await this.runtime.identity.updateGoalStatus("in_progress");
302
+ }
303
+ catch (err) {
304
+ if (this.verbose) {
305
+ console.error("[autonomous] Failed to transition goal → in_progress:", err);
306
+ }
307
+ return;
308
+ }
309
+ const budgetNook = goalConfig.goalBudgetNook ? BigInt(goalConfig.goalBudgetNook) : 0n;
310
+ const loopOptions = {
311
+ runtime: this.runtime,
312
+ goal: goalConfig.initialGoal,
313
+ budgetNook,
314
+ parentSwarmId: goalConfig.goalParentSwarmId,
315
+ verbose: this.verbose,
316
+ };
317
+ const loop = new GoalLoop(loopOptions);
318
+ let result;
319
+ try {
320
+ result = await loop.run();
321
+ }
322
+ catch (err) {
323
+ const msg = err instanceof Error ? err.message : String(err);
324
+ if (this.verbose) {
325
+ console.error("[autonomous] GoalLoop threw:", err);
326
+ }
327
+ // Transition to failed so the UI reflects the error.
328
+ await this.runtime.identity.updateGoalStatus("failed").catch(() => { });
329
+ await this.runtime.identity.createPendingTask({
330
+ reason: "unclear_goal",
331
+ description: `Goal loop crashed: ${msg.slice(0, 400)}`,
332
+ parentSwarmId: goalConfig.goalParentSwarmId,
333
+ }).catch(() => { });
334
+ return;
335
+ }
336
+ await this.handleGoalResult(result, goalConfig);
337
+ }
338
+ /**
339
+ * Dispatch on the terminal state of a GoalLoop run:
340
+ * - complete → store artifact in private KG, pause agent
341
+ * - blocked_budget → create pending task (budget_exhausted), pause
342
+ * - blocked_stuck → create pending task (stuck_3x), pause
343
+ * - blocked_capability → create pending task (needs_capability), pause
344
+ */
345
+ async handleGoalResult(result, goalConfig) {
346
+ if (result.outcome === "complete") {
347
+ // Store deliverable in private KG
348
+ let artifactId = null;
349
+ try {
350
+ const storeResult = (await this.runtime.connection.request("POST", "/v1/agents/me/knowledge", {
351
+ contentText: result.artifact.body,
352
+ title: result.artifact.title,
353
+ domain: result.artifact.domain,
354
+ visibility: "private",
355
+ knowledgeType: "fact",
356
+ sourceType: "import",
357
+ metadata: {
358
+ goal: goalConfig.initialGoal,
359
+ parentSwarmId: goalConfig.goalParentSwarmId,
360
+ stepsExecuted: result.stepsExecuted,
361
+ spentNook: result.spentNook.toString(),
362
+ },
363
+ }));
364
+ artifactId = storeResult?.id ?? null;
365
+ }
366
+ catch (err) {
367
+ if (this.verbose) {
368
+ console.error("[autonomous] Failed to store goal artifact:", err);
369
+ }
370
+ }
371
+ try {
372
+ await this.runtime.identity.completeGoal(artifactId ?? "unknown");
373
+ }
374
+ catch (err) {
375
+ if (this.verbose) {
376
+ console.error("[autonomous] completeGoal failed:", err);
377
+ }
378
+ }
379
+ // Q3: agent pauses after completion, does not stay reactive
380
+ this.stop();
381
+ return;
382
+ }
383
+ if (result.outcome === "blocked_budget") {
384
+ // initialGoal is non-null here — maybeBootstrapGoal returned early otherwise.
385
+ const goalText = goalConfig.initialGoal ?? "(unknown)";
386
+ await this.runtime.identity.createPendingTask({
387
+ reason: "budget_exhausted",
388
+ description: `Needs top-off to continue goal: ${goalText.slice(0, 300)}`,
389
+ parentSwarmId: goalConfig.goalParentSwarmId,
390
+ }).catch(() => { });
391
+ await this.runtime.identity.updateGoalStatus("paused_awaiting_topoff").catch(() => { });
392
+ this.stop();
393
+ return;
394
+ }
395
+ if (result.outcome === "blocked_stuck") {
396
+ await this.runtime.identity.createPendingTask({
397
+ reason: "stuck_3x",
398
+ description: result.stuckReason,
399
+ parentSwarmId: goalConfig.goalParentSwarmId,
400
+ }).catch(() => { });
401
+ await this.runtime.identity.updateGoalStatus("blocked_needs_decision").catch(() => { });
402
+ this.stop();
403
+ return;
404
+ }
405
+ if (result.outcome === "blocked_capability") {
406
+ await this.runtime.identity.createPendingTask({
407
+ reason: "needs_capability",
408
+ description: result.capabilityNeeded,
409
+ suggestedPresetId: result.suggestedPreset,
410
+ parentSwarmId: goalConfig.goalParentSwarmId,
411
+ }).catch(() => { });
412
+ await this.runtime.identity.updateGoalStatus("blocked_needs_decision").catch(() => { });
413
+ this.stop();
414
+ return;
415
+ }
416
+ }
417
+ // ================================================================
251
418
  // Signal handling (proactive.signal)
252
419
  // ================================================================
253
420
  /**
@@ -478,9 +645,7 @@ export class AutonomousAgent {
478
645
  case "community_gap":
479
646
  await this.handleCommunityGap(data);
480
647
  break;
481
- case "directive":
482
- await this.handleDirective(data);
483
- break;
648
+ // DD-7: directive case removed — swarm coordination uses DMs
484
649
  case "files_committed":
485
650
  await this.handleFilesCommitted(data);
486
651
  break;
@@ -1726,6 +1891,7 @@ export class AutonomousAgent {
1726
1891
  "Review the submitted work. If this is the best submission, select them as the winner.\n" +
1727
1892
  "Selecting a winner approves them on-chain — they can then claim the bounty for instant payout.\n\n" +
1728
1893
  "Available actions:\n" +
1894
+ "- approve_bounty_application: Allow this applicant to submit work (params: bountyId, applicationId). Use early in the lifecycle, before any work has been submitted.\n" +
1729
1895
  "- approve_bounty_claimer: Select this agent as the winner and approve on-chain (params: bountyId, claimer — use the applicant address)\n" +
1730
1896
  "- reject_bounty_application: Reject this submission (params: bountyId, applicationId)\n" +
1731
1897
  "- ignore: Wait for more submissions before deciding\n" +
@@ -2007,40 +2173,7 @@ export class AutonomousAgent {
2007
2173
  console.error("[autonomous] Community gap handling failed:", err);
2008
2174
  }
2009
2175
  }
2010
- async handleDirective(data) {
2011
- const directiveContent = data.messagePreview ?? "";
2012
- const channelId = data.channelId;
2013
- const community = data.community ?? "general";
2014
- try {
2015
- const prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\n` +
2016
- "You received a directive on Nookplot.\n" +
2017
- `Directive:\n${wrapUntrusted(directiveContent, "directive")}\n\n` +
2018
- "Follow the directive and compose your response.\n" +
2019
- "If it asks you to post, write the post content.\n" +
2020
- "If it asks you to discuss, write a discussion message.\n" +
2021
- "If you can't follow this directive, respond with exactly: [SKIP]\n\n" +
2022
- "Your response (under 500 chars):";
2023
- const response = await this.generateResponse(prompt);
2024
- const content = response?.trim() ?? "";
2025
- if (content && content !== "[SKIP]") {
2026
- if (channelId) {
2027
- await this.runtime.channels.send(channelId, content);
2028
- if (this.verbose)
2029
- console.log(`[autonomous] ✓ Directive response sent to channel ${channelId.slice(0, 12)}`);
2030
- }
2031
- else {
2032
- const title = content.slice(0, 100);
2033
- await this.runtime.memory.publishKnowledge({ title, body: content, community });
2034
- if (this.verbose)
2035
- console.log(`[autonomous] ✓ Directive response posted in ${community}`);
2036
- }
2037
- }
2038
- }
2039
- catch (err) {
2040
- if (this.verbose)
2041
- console.error("[autonomous] Directive handling failed:", err);
2042
- }
2043
- }
2176
+ // DD-7: handleDirective removed — swarm coordination uses DMs exclusively
2044
2177
  // ================================================================
2045
2178
  // Project collaboration signal handlers
2046
2179
  // ================================================================
@@ -2727,6 +2860,18 @@ export class AutonomousAgent {
2727
2860
  triggers: this.doomLoopTriggers,
2728
2861
  actionType,
2729
2862
  });
2863
+ // Track C.2: also push to gateway as fire-and-forget telemetry so
2864
+ // ops dashboards can answer "which tools most often misbehave?"
2865
+ // and "is this agent stuck right now?" — see
2866
+ // gateway/src/services/doomLoopMetrics.ts. Errors are swallowed so
2867
+ // a backend outage never blocks the runtime's recovery path.
2868
+ void this.runtime.connection
2869
+ .request("POST", "/v1/agents/me/doom-loop-event", {
2870
+ offender: doomOffender,
2871
+ triggers: this.doomLoopTriggers,
2872
+ actionType,
2873
+ })
2874
+ .catch(() => { });
2730
2875
  if (this.doomLoopTriggers >= AUTONOMOUS_DOOM_LOOP_MAX_TRIGGERS) {
2731
2876
  if (this.verbose) {
2732
2877
  console.warn(`[autonomous] ✗ doom loop on '${doomOffender}' (${this.doomLoopTriggers} triggers) — aborting cycle`);