@nookplot/runtime 0.5.110 → 0.5.117
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.doomLoop.test.d.ts +2 -0
- package/dist/__tests__/autonomous.doomLoop.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.doomLoop.test.js +126 -0
- package/dist/__tests__/autonomous.doomLoop.test.js.map +1 -0
- package/dist/__tests__/autonomous.getAvailableActions.test.js +41 -0
- package/dist/__tests__/autonomous.getAvailableActions.test.js.map +1 -1
- package/dist/__tests__/autonomous.loadedSkillRefs.test.d.ts +2 -0
- package/dist/__tests__/autonomous.loadedSkillRefs.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.loadedSkillRefs.test.js +150 -0
- package/dist/__tests__/autonomous.loadedSkillRefs.test.js.map +1 -0
- package/dist/__tests__/codegen-drift.test.d.ts +23 -0
- package/dist/__tests__/codegen-drift.test.d.ts.map +1 -0
- package/dist/__tests__/codegen-drift.test.js +187 -0
- package/dist/__tests__/codegen-drift.test.js.map +1 -0
- package/dist/__tests__/doomLoop.test.d.ts +6 -0
- package/dist/__tests__/doomLoop.test.d.ts.map +1 -0
- package/dist/__tests__/doomLoop.test.js +144 -0
- package/dist/__tests__/doomLoop.test.js.map +1 -0
- package/dist/__tests__/goalLoop.test.js +111 -0
- package/dist/__tests__/goalLoop.test.js.map +1 -1
- package/dist/__tests__/hooks.test.js +4 -0
- package/dist/__tests__/hooks.test.js.map +1 -1
- package/dist/__tests__/onChainActions.parity.test.d.ts +12 -0
- package/dist/__tests__/onChainActions.parity.test.d.ts.map +1 -0
- package/dist/__tests__/onChainActions.parity.test.js +104 -0
- package/dist/__tests__/onChainActions.parity.test.js.map +1 -0
- package/dist/__tests__/signing.test.d.ts +2 -0
- package/dist/__tests__/signing.test.d.ts.map +1 -0
- package/dist/__tests__/signing.test.js +260 -0
- package/dist/__tests__/signing.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 +152 -22
- package/dist/actionCatalog.generated.js.map +1 -1
- package/dist/actionCatalog.js +1 -1
- package/dist/actionCatalog.js.map +1 -1
- package/dist/autonomous.d.ts +11 -0
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +98 -0
- package/dist/autonomous.js.map +1 -1
- package/dist/bounties.js +1 -1
- package/dist/bounties.js.map +1 -1
- package/dist/doomLoop.d.ts +52 -0
- package/dist/doomLoop.d.ts.map +1 -0
- package/dist/doomLoop.js +173 -0
- package/dist/doomLoop.js.map +1 -0
- package/dist/goal/goalLoop.d.ts +3 -0
- package/dist/goal/goalLoop.d.ts.map +1 -1
- package/dist/goal/goalLoop.js +30 -1
- package/dist/goal/goalLoop.js.map +1 -1
- package/dist/hooks.d.ts +10 -0
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/signalActionMap.d.ts +13 -1
- package/dist/signalActionMap.d.ts.map +1 -1
- package/dist/signalActionMap.js +43 -5
- package/dist/signalActionMap.js.map +1 -1
- package/dist/signing.js +2 -2
- package/dist/signing.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.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;;;;;;;;;;;;;;;;;;;;;;;;;;;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A0EtC;;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
|
@@ -47,6 +47,9 @@ import { WakeUpStack } from "./wakeUpStack.js";
|
|
|
47
47
|
import { GoalLoop } from "./goal/goalLoop.js";
|
|
48
48
|
import { hooks as defaultHooks } from "./hooks.js";
|
|
49
49
|
import { guardrails as defaultGuardrails, GuardrailTripped, InputGuardrailTripped, } from "./guardrails.js";
|
|
50
|
+
import { buildCorrectivePrompt, checkForDoomLoopFromSignatures, makeSignature, } from "./doomLoop.js";
|
|
51
|
+
const AUTONOMOUS_DOOM_LOOP_MAX_TRIGGERS = 3;
|
|
52
|
+
const AUTONOMOUS_DOOM_LOOP_SIGNATURE_WINDOW = 30;
|
|
50
53
|
// ----------------------------------------------------------------
|
|
51
54
|
// AutonomousAgent
|
|
52
55
|
// ----------------------------------------------------------------
|
|
@@ -57,6 +60,7 @@ const ON_CHAIN_ACTIONS = new Set([
|
|
|
57
60
|
"create_bounty", "create_bundle", "claim", "claim_bounty",
|
|
58
61
|
"approve_bounty_claimer", "approve_bounty_work", "dispute_bounty_work",
|
|
59
62
|
"cancel_bounty", "unclaim_bounty",
|
|
63
|
+
"expire_disputed_bounty", "sweep_treasury_fees", // V8
|
|
60
64
|
"create_listing", "list_service", "update_service", "create_agreement",
|
|
61
65
|
"deliver_work", "settle_agreement", "dispute_agreement", "cancel_agreement",
|
|
62
66
|
"expire_dispute", "expire_delivered",
|
|
@@ -91,6 +95,10 @@ const ON_CHAIN_ACTIONS = new Set([
|
|
|
91
95
|
"vote_kick_guild_member",
|
|
92
96
|
"mining_counter_argument", "mining_defend_trace",
|
|
93
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",
|
|
94
102
|
// API marketplace on-chain actions use existing service/* prepare endpoints
|
|
95
103
|
// Social (missing)
|
|
96
104
|
"remove_vote", "revoke_attestation",
|
|
@@ -150,6 +158,17 @@ export class AutonomousAgent {
|
|
|
150
158
|
processedSignals = new Map();
|
|
151
159
|
/** Dynamic tool browsing: categories loaded via browse_tools. */
|
|
152
160
|
loadedCategories = new Set();
|
|
161
|
+
/** Doom-loop detector state: ring buffer of recent action signatures + trigger counter. */
|
|
162
|
+
toolSignatures = [];
|
|
163
|
+
doomLoopTriggers = 0;
|
|
164
|
+
/**
|
|
165
|
+
* SRA Phase 4b — rolling buffer of skills loaded via nookplot_load_skill.
|
|
166
|
+
* Captured post-dispatch; flushed into args.loadedSkillRefs pre-dispatch on
|
|
167
|
+
* submit_reasoning_trace / submit_subtask_trace. Cap 64 (drop oldest); the
|
|
168
|
+
* gateway intersects against (agent, used=true, last 24h) signals so stale
|
|
169
|
+
* or unauthorized refs are dropped silently. Format on the wire: `${kind}:${ref}`.
|
|
170
|
+
*/
|
|
171
|
+
loadedSkillRefs = [];
|
|
153
172
|
/** Tiered knowledge context: L0 identity + L1 essentials (session-cached) + L2 on-demand. */
|
|
154
173
|
wakeUpStack;
|
|
155
174
|
constructor(runtime, options = {}) {
|
|
@@ -2790,6 +2809,58 @@ export class AutonomousAgent {
|
|
|
2790
2809
|
}
|
|
2791
2810
|
const startTime = Date.now();
|
|
2792
2811
|
hooks.emitFireAndForget("action_start", { actionType, args, actionId, agentAddress });
|
|
2812
|
+
// ── Doom-loop detection (parity with goal_loop.ts) ──
|
|
2813
|
+
// Push the action signature into a 30-slot ring; if the recent tail
|
|
2814
|
+
// shows 3+ identical calls or an A,B,A,B-style cycle, increment the
|
|
2815
|
+
// trigger counter. After 3 triggers in this agent's lifetime, abort
|
|
2816
|
+
// the current cycle so the outer proactive scheduler can re-route —
|
|
2817
|
+
// keeping the autonomous loop from spending NOOK on a stuck bug.
|
|
2818
|
+
this.toolSignatures.push(makeSignature(actionType, args));
|
|
2819
|
+
if (this.toolSignatures.length > AUTONOMOUS_DOOM_LOOP_SIGNATURE_WINDOW) {
|
|
2820
|
+
this.toolSignatures = this.toolSignatures.slice(-AUTONOMOUS_DOOM_LOOP_SIGNATURE_WINDOW);
|
|
2821
|
+
}
|
|
2822
|
+
const doomOffender = checkForDoomLoopFromSignatures(this.toolSignatures);
|
|
2823
|
+
if (doomOffender) {
|
|
2824
|
+
this.doomLoopTriggers++;
|
|
2825
|
+
hooks.emitFireAndForget("doom_loop_detected", {
|
|
2826
|
+
offender: doomOffender,
|
|
2827
|
+
triggers: this.doomLoopTriggers,
|
|
2828
|
+
actionType,
|
|
2829
|
+
});
|
|
2830
|
+
// Track C.2: also push to gateway as fire-and-forget telemetry so
|
|
2831
|
+
// ops dashboards can answer "which tools most often misbehave?"
|
|
2832
|
+
// and "is this agent stuck right now?" — see
|
|
2833
|
+
// gateway/src/services/doomLoopMetrics.ts. Errors are swallowed so
|
|
2834
|
+
// a backend outage never blocks the runtime's recovery path.
|
|
2835
|
+
void this.runtime.connection
|
|
2836
|
+
.request("POST", "/v1/agents/me/doom-loop-event", {
|
|
2837
|
+
offender: doomOffender,
|
|
2838
|
+
triggers: this.doomLoopTriggers,
|
|
2839
|
+
actionType,
|
|
2840
|
+
})
|
|
2841
|
+
.catch(() => { });
|
|
2842
|
+
if (this.doomLoopTriggers >= AUTONOMOUS_DOOM_LOOP_MAX_TRIGGERS) {
|
|
2843
|
+
if (this.verbose) {
|
|
2844
|
+
console.warn(`[autonomous] ✗ doom loop on '${doomOffender}' (${this.doomLoopTriggers} triggers) — aborting cycle`);
|
|
2845
|
+
}
|
|
2846
|
+
const reason = buildCorrectivePrompt(doomOffender);
|
|
2847
|
+
hooks.emitFireAndForget("action_error", {
|
|
2848
|
+
actionType, args, error: new Error(reason),
|
|
2849
|
+
durationMs: Date.now() - startTime, actionId,
|
|
2850
|
+
});
|
|
2851
|
+
if (actionId) {
|
|
2852
|
+
try {
|
|
2853
|
+
await this.runtime.proactive.rejectDelegatedAction(actionId, reason);
|
|
2854
|
+
}
|
|
2855
|
+
catch { /* best-effort */ }
|
|
2856
|
+
}
|
|
2857
|
+
// Reset trigger counter so the agent can recover after the outer
|
|
2858
|
+
// scheduler reroutes — but keep the signature ring so a doom loop
|
|
2859
|
+
// resurfacing on the next action still trips the detector.
|
|
2860
|
+
this.doomLoopTriggers = 0;
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2793
2864
|
// ── Input guardrails (Phase 3) ──
|
|
2794
2865
|
// Run BEFORE the action body so a tripped guardrail prevents dispatch.
|
|
2795
2866
|
// `tool_input` fires regardless so observability sees the call attempt;
|
|
@@ -2885,10 +2956,37 @@ export class AutonomousAgent {
|
|
|
2885
2956
|
...args,
|
|
2886
2957
|
...(suggestedContent ? { suggestedContent } : {}),
|
|
2887
2958
|
};
|
|
2959
|
+
// SRA Phase 4b — flush loaded-skill buffer into submit traces. If the
|
|
2960
|
+
// caller already set loadedSkillRefs explicitly, respect it; otherwise
|
|
2961
|
+
// populate from the buffer. Drop entries older than 24h client-side
|
|
2962
|
+
// (server enforces the same window via intersection, but this keeps the
|
|
2963
|
+
// payload small).
|
|
2964
|
+
if ((actionType === "submit_reasoning_trace" || actionType === "submit_subtask_trace") &&
|
|
2965
|
+
dispatchPayload.loadedSkillRefs == null &&
|
|
2966
|
+
this.loadedSkillRefs.length > 0) {
|
|
2967
|
+
const cutoff = Date.now() - 24 * 60 * 60 * 1000;
|
|
2968
|
+
this.loadedSkillRefs = this.loadedSkillRefs.filter(e => e.loadedAt >= cutoff);
|
|
2969
|
+
if (this.loadedSkillRefs.length > 0) {
|
|
2970
|
+
dispatchPayload.loadedSkillRefs = this.loadedSkillRefs.map(e => `${e.kind}:${e.ref}`);
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2888
2973
|
const dispatchResult = await this.runtime.connection.request("POST", "/v1/actions/execute", { toolName, payload: dispatchPayload });
|
|
2889
2974
|
switch (dispatchResult.status) {
|
|
2890
2975
|
case "completed": {
|
|
2891
2976
|
result = (dispatchResult.result ?? {});
|
|
2977
|
+
// SRA Phase 4b — capture canonical_ref from load_skill responses so
|
|
2978
|
+
// the next submit_reasoning_trace can declare them. The gateway's
|
|
2979
|
+
// recordLoad() already flips used=true on its skill_utility_signals
|
|
2980
|
+
// row; we just need to remember the ref for the trace-linkage step.
|
|
2981
|
+
if (actionType === "load_skill" && typeof result.canonical_ref === "string") {
|
|
2982
|
+
const kind = args.kind;
|
|
2983
|
+
if (typeof kind === "string") {
|
|
2984
|
+
this.loadedSkillRefs.push({ kind, ref: result.canonical_ref, loadedAt: Date.now() });
|
|
2985
|
+
if (this.loadedSkillRefs.length > 64) {
|
|
2986
|
+
this.loadedSkillRefs = this.loadedSkillRefs.slice(-64);
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2892
2990
|
break;
|
|
2893
2991
|
}
|
|
2894
2992
|
case "sign_required": {
|