@nookplot/runtime 0.5.20 → 0.5.22
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 +11 -0
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +200 -17
- package/dist/autonomous.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +60 -0
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +27 -0
- package/dist/memory.js.map +1 -1
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/workspace.d.ts +208 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +154 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +1 -1
package/dist/autonomous.d.ts
CHANGED
|
@@ -76,6 +76,11 @@ export type GenerateResponseFn = (prompt: string) => Promise<string | null | und
|
|
|
76
76
|
* If provided, bypasses the built-in prompt building + action execution.
|
|
77
77
|
*/
|
|
78
78
|
export type SignalHandler = (signal: SignalEvent, runtime: NookplotRuntime) => Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Approval callback for on-chain actions. Return `true` to allow execution,
|
|
81
|
+
* `false` to reject. Called before any on-chain action when provided.
|
|
82
|
+
*/
|
|
83
|
+
export type ApprovalCallback = (actionType: string, payload: Record<string, unknown>) => Promise<boolean>;
|
|
79
84
|
/** Options for the AutonomousAgent. */
|
|
80
85
|
export interface AutonomousAgentOptions {
|
|
81
86
|
/** Log actions to console (default: true). */
|
|
@@ -94,6 +99,11 @@ export interface AutonomousAgentOptions {
|
|
|
94
99
|
generateResponse?: GenerateResponseFn;
|
|
95
100
|
/** Custom action handler — overrides default on-chain action dispatch. */
|
|
96
101
|
onAction?: (event: ActionRequestEvent) => Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Approval gate for on-chain actions. When provided, on-chain actions
|
|
104
|
+
* (create_post, vote, follow, attest, etc.) require approval before execution.
|
|
105
|
+
*/
|
|
106
|
+
onApproval?: ApprovalCallback;
|
|
97
107
|
/** Per-channel response cooldown in seconds (default: 120). */
|
|
98
108
|
responseCooldown?: number;
|
|
99
109
|
}
|
|
@@ -103,6 +113,7 @@ export declare class AutonomousAgent {
|
|
|
103
113
|
private readonly generateResponse?;
|
|
104
114
|
private readonly signalHandler?;
|
|
105
115
|
private readonly actionHandler?;
|
|
116
|
+
private readonly approvalHandler?;
|
|
106
117
|
private readonly cooldownSec;
|
|
107
118
|
private isRunning;
|
|
108
119
|
private channelCooldowns;
|
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;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;IA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AAyB;YAkBzB,gBAAgB;YAqBhB,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;CA2vBlC"}
|
package/dist/autonomous.js
CHANGED
|
@@ -44,12 +44,23 @@ import { wrapUntrusted, sanitizeForPrompt, UNTRUSTED_CONTENT_INSTRUCTION } from
|
|
|
44
44
|
// ----------------------------------------------------------------
|
|
45
45
|
// AutonomousAgent
|
|
46
46
|
// ----------------------------------------------------------------
|
|
47
|
+
/** On-chain actions that go through prepare→sign→relay and mutate state. */
|
|
48
|
+
const ON_CHAIN_ACTIONS = new Set([
|
|
49
|
+
"create_post", "post_reply", "vote", "follow_agent", "attest_agent",
|
|
50
|
+
"create_community", "propose_guild", "propose_clique", "create_project",
|
|
51
|
+
"create_bounty", "create_bundle", "claim", "claim_bounty",
|
|
52
|
+
"approve_bounty_claimer", "create_listing", "list_service", "create_agreement",
|
|
53
|
+
"deliver_work", "settle_agreement", "dispute_agreement", "cancel_agreement",
|
|
54
|
+
"expire_dispute", "expire_delivered",
|
|
55
|
+
"approve_guild", "reject_guild", "leave_guild",
|
|
56
|
+
]);
|
|
47
57
|
export class AutonomousAgent {
|
|
48
58
|
runtime;
|
|
49
59
|
verbose;
|
|
50
60
|
generateResponse;
|
|
51
61
|
signalHandler;
|
|
52
62
|
actionHandler;
|
|
63
|
+
approvalHandler;
|
|
53
64
|
cooldownSec;
|
|
54
65
|
isRunning = false;
|
|
55
66
|
channelCooldowns = new Map();
|
|
@@ -61,6 +72,7 @@ export class AutonomousAgent {
|
|
|
61
72
|
this.generateResponse = options.generateResponse;
|
|
62
73
|
this.signalHandler = options.onSignal;
|
|
63
74
|
this.actionHandler = options.onAction;
|
|
75
|
+
this.approvalHandler = options.onApproval;
|
|
64
76
|
this.cooldownSec = options.responseCooldown ?? 120;
|
|
65
77
|
}
|
|
66
78
|
/** Start listening for proactive signals and action requests. */
|
|
@@ -655,9 +667,17 @@ export class AutonomousAgent {
|
|
|
655
667
|
const response = await this.generateResponse(prompt);
|
|
656
668
|
const content = response?.trim() ?? "";
|
|
657
669
|
if (content && content !== "[SKIP]") {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
670
|
+
// Try public comment first, fall back to DM
|
|
671
|
+
try {
|
|
672
|
+
await this.runtime.memory.publishComment({ body: content, parentCid: postCid, community: data.community ?? "general" });
|
|
673
|
+
if (this.verbose)
|
|
674
|
+
console.log(`[autonomous] ✓ Public reply to ${sender.slice(0, 10)} on post ${postCid.slice(0, 12)}`);
|
|
675
|
+
}
|
|
676
|
+
catch {
|
|
677
|
+
await this.runtime.inbox.send({ to: sender, content: `Re your comment on my post: ${content}` });
|
|
678
|
+
if (this.verbose)
|
|
679
|
+
console.log(`[autonomous] ✓ DM reply (fallback) to ${sender.slice(0, 10)} on post ${postCid.slice(0, 12)}`);
|
|
680
|
+
}
|
|
661
681
|
}
|
|
662
682
|
}
|
|
663
683
|
catch (err) {
|
|
@@ -2144,6 +2164,21 @@ export class AutonomousAgent {
|
|
|
2144
2164
|
if (this.verbose) {
|
|
2145
2165
|
console.log(`[autonomous] Action request: ${actionType}${actionId ? ` (${actionId})` : ""}`);
|
|
2146
2166
|
}
|
|
2167
|
+
// Approval gate: on-chain actions require approval when handler is set
|
|
2168
|
+
if (this.approvalHandler && ON_CHAIN_ACTIONS.has(actionType)) {
|
|
2169
|
+
const approved = await this.approvalHandler(actionType, (payload ?? {}));
|
|
2170
|
+
if (!approved) {
|
|
2171
|
+
if (this.verbose)
|
|
2172
|
+
console.log(`[autonomous] Action rejected by approval handler: ${actionType}`);
|
|
2173
|
+
if (actionId) {
|
|
2174
|
+
try {
|
|
2175
|
+
await this.runtime.proactive.rejectDelegatedAction(actionId, "Rejected by approval handler");
|
|
2176
|
+
}
|
|
2177
|
+
catch { /* best-effort */ }
|
|
2178
|
+
}
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2147
2182
|
try {
|
|
2148
2183
|
let txHash;
|
|
2149
2184
|
let result;
|
|
@@ -2411,6 +2446,31 @@ export class AutonomousAgent {
|
|
|
2411
2446
|
result = bountyRelay;
|
|
2412
2447
|
break;
|
|
2413
2448
|
}
|
|
2449
|
+
case "create_bundle": {
|
|
2450
|
+
const name = (suggestedContent ?? payload?.title ?? payload?.name);
|
|
2451
|
+
if (!name)
|
|
2452
|
+
throw new Error("create_bundle requires name or title");
|
|
2453
|
+
const bundleBody = { name };
|
|
2454
|
+
const cids = payload?.cids;
|
|
2455
|
+
if (cids && Array.isArray(cids) && cids.length > 0)
|
|
2456
|
+
bundleBody.cids = cids;
|
|
2457
|
+
if (payload?.description)
|
|
2458
|
+
bundleBody.description = payload.description;
|
|
2459
|
+
if (payload?.bundleType)
|
|
2460
|
+
bundleBody.bundleType = payload.bundleType;
|
|
2461
|
+
if (payload?.tags)
|
|
2462
|
+
bundleBody.tags = payload.tags;
|
|
2463
|
+
if (payload?.domain)
|
|
2464
|
+
bundleBody.domain = payload.domain;
|
|
2465
|
+
if (payload?.summary)
|
|
2466
|
+
bundleBody.summary = payload.summary;
|
|
2467
|
+
if (payload?.contributors)
|
|
2468
|
+
bundleBody.contributors = payload.contributors;
|
|
2469
|
+
const bundleRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/bundle", bundleBody);
|
|
2470
|
+
txHash = bundleRelay.txHash;
|
|
2471
|
+
result = bundleRelay;
|
|
2472
|
+
break;
|
|
2473
|
+
}
|
|
2414
2474
|
case "add_collaborator": {
|
|
2415
2475
|
const projId = payload?.projectId;
|
|
2416
2476
|
const collabAddr = (payload?.collaboratorAddress ?? payload?.address);
|
|
@@ -2648,20 +2708,7 @@ export class AutonomousAgent {
|
|
|
2648
2708
|
result = msgResult;
|
|
2649
2709
|
break;
|
|
2650
2710
|
}
|
|
2651
|
-
|
|
2652
|
-
const title = payload?.title;
|
|
2653
|
-
const description = (suggestedContent ?? payload?.description ?? "");
|
|
2654
|
-
const domain = (payload?.domain ?? "");
|
|
2655
|
-
if (!title)
|
|
2656
|
-
throw new Error("create_bundle requires title");
|
|
2657
|
-
const bundleResult = await prepareSignRelay(this.runtime.connection, "/v1/prepare/bundle", {
|
|
2658
|
-
title,
|
|
2659
|
-
description,
|
|
2660
|
-
domain,
|
|
2661
|
-
});
|
|
2662
|
-
result = bundleResult;
|
|
2663
|
-
break;
|
|
2664
|
-
}
|
|
2711
|
+
// (create_bundle handled above — consolidated single handler)
|
|
2665
2712
|
case "update_service": {
|
|
2666
2713
|
const listingId = payload?.listingId;
|
|
2667
2714
|
if (!listingId)
|
|
@@ -2718,6 +2765,142 @@ export class AutonomousAgent {
|
|
|
2718
2765
|
result = r;
|
|
2719
2766
|
break;
|
|
2720
2767
|
}
|
|
2768
|
+
case "workspace_create": {
|
|
2769
|
+
const wsName = (payload?.name ?? suggestedContent);
|
|
2770
|
+
if (!wsName)
|
|
2771
|
+
throw new Error("workspace_create requires name");
|
|
2772
|
+
const ws = await this.runtime.workspaces.create({
|
|
2773
|
+
name: wsName,
|
|
2774
|
+
description: payload?.description,
|
|
2775
|
+
sourceType: payload?.sourceType,
|
|
2776
|
+
sourceId: payload?.sourceId,
|
|
2777
|
+
});
|
|
2778
|
+
result = ws;
|
|
2779
|
+
break;
|
|
2780
|
+
}
|
|
2781
|
+
case "workspace_set": {
|
|
2782
|
+
const wsId = payload?.workspaceId;
|
|
2783
|
+
const wsKey = payload?.key;
|
|
2784
|
+
const wsVal = payload?.value ?? suggestedContent;
|
|
2785
|
+
if (!wsId || !wsKey)
|
|
2786
|
+
throw new Error("workspace_set requires workspaceId and key");
|
|
2787
|
+
const wsResult = await this.runtime.workspaces.setState(wsId, wsKey, wsVal);
|
|
2788
|
+
result = wsResult;
|
|
2789
|
+
break;
|
|
2790
|
+
}
|
|
2791
|
+
case "workspace_snapshot": {
|
|
2792
|
+
const wsId = payload?.workspaceId;
|
|
2793
|
+
if (!wsId)
|
|
2794
|
+
throw new Error("workspace_snapshot requires workspaceId");
|
|
2795
|
+
const snap = await this.runtime.workspaces.createSnapshot(wsId, payload?.label);
|
|
2796
|
+
result = snap;
|
|
2797
|
+
break;
|
|
2798
|
+
}
|
|
2799
|
+
case "review":
|
|
2800
|
+
case "comment": {
|
|
2801
|
+
const projId = payload?.projectId;
|
|
2802
|
+
const commitId = payload?.commitId;
|
|
2803
|
+
if (!projId || !commitId)
|
|
2804
|
+
throw new Error("review requires projectId and commitId");
|
|
2805
|
+
const verdict = (payload?.verdict ?? "comment");
|
|
2806
|
+
const body = (suggestedContent ?? payload?.body ?? "");
|
|
2807
|
+
const reviewResult = await this.runtime.projects.submitReview(projId, commitId, verdict, body);
|
|
2808
|
+
result = reviewResult;
|
|
2809
|
+
break;
|
|
2810
|
+
}
|
|
2811
|
+
case "grant": {
|
|
2812
|
+
const projId = payload?.projectId;
|
|
2813
|
+
const bountyId = payload?.bountyId;
|
|
2814
|
+
const reqId = payload?.requestId;
|
|
2815
|
+
if (!projId || !bountyId || !reqId)
|
|
2816
|
+
throw new Error("grant requires projectId, bountyId, requestId");
|
|
2817
|
+
result = await this.runtime.connection.request("POST", `/v1/projects/${projId}/bounties/${bountyId}/grant-access`, { requestId: reqId });
|
|
2818
|
+
break;
|
|
2819
|
+
}
|
|
2820
|
+
case "deny": {
|
|
2821
|
+
const projId = payload?.projectId;
|
|
2822
|
+
const bountyId = payload?.bountyId;
|
|
2823
|
+
const reqId = payload?.requestId;
|
|
2824
|
+
if (!projId || !bountyId || !reqId)
|
|
2825
|
+
throw new Error("deny requires projectId, bountyId, requestId");
|
|
2826
|
+
result = await this.runtime.connection.request("POST", `/v1/projects/${projId}/bounties/${bountyId}/deny-access`, { requestId: reqId });
|
|
2827
|
+
break;
|
|
2828
|
+
}
|
|
2829
|
+
case "accept": {
|
|
2830
|
+
const ch = payload?.channelId;
|
|
2831
|
+
const msg = (suggestedContent ?? "Accepted — I'll get started.");
|
|
2832
|
+
if (ch) {
|
|
2833
|
+
await this.runtime.channels.send(ch, msg);
|
|
2834
|
+
}
|
|
2835
|
+
result = { accepted: true };
|
|
2836
|
+
break;
|
|
2837
|
+
}
|
|
2838
|
+
case "acknowledge": {
|
|
2839
|
+
const ch = payload?.channelId;
|
|
2840
|
+
const msg = (suggestedContent ?? "Got it, thanks for the mention!");
|
|
2841
|
+
if (ch) {
|
|
2842
|
+
await this.runtime.channels.send(ch, msg);
|
|
2843
|
+
}
|
|
2844
|
+
result = { acknowledged: true };
|
|
2845
|
+
break;
|
|
2846
|
+
}
|
|
2847
|
+
case "execute": {
|
|
2848
|
+
const ch = payload?.channelId;
|
|
2849
|
+
const target = payload?.recipientAddress;
|
|
2850
|
+
const msg = (suggestedContent ?? "");
|
|
2851
|
+
if (ch) {
|
|
2852
|
+
await this.runtime.channels.send(ch, msg);
|
|
2853
|
+
}
|
|
2854
|
+
else if (target) {
|
|
2855
|
+
await this.runtime.inbox.send({ to: target, content: msg });
|
|
2856
|
+
}
|
|
2857
|
+
result = { executed: true };
|
|
2858
|
+
break;
|
|
2859
|
+
}
|
|
2860
|
+
case "send_dm": {
|
|
2861
|
+
const target = payload?.recipientAddress;
|
|
2862
|
+
const content = (suggestedContent ?? payload?.content);
|
|
2863
|
+
if (!target || !content)
|
|
2864
|
+
throw new Error("send_dm requires recipientAddress and content");
|
|
2865
|
+
await this.runtime.inbox.send({ to: target, content });
|
|
2866
|
+
result = { sent: true };
|
|
2867
|
+
break;
|
|
2868
|
+
}
|
|
2869
|
+
case "create_listing": {
|
|
2870
|
+
// Alias for list_service — same prepare endpoint
|
|
2871
|
+
const listing = payload ?? {};
|
|
2872
|
+
const listRelay = await prepareSignRelay(this.runtime.connection, "/v1/prepare/service/list", listing);
|
|
2873
|
+
txHash = listRelay.txHash;
|
|
2874
|
+
result = listRelay;
|
|
2875
|
+
break;
|
|
2876
|
+
}
|
|
2877
|
+
case "approve_guild": {
|
|
2878
|
+
const guildId = payload?.guildId;
|
|
2879
|
+
if (!guildId)
|
|
2880
|
+
throw new Error("approve_guild requires guildId");
|
|
2881
|
+
const approveRelay = await prepareSignRelay(this.runtime.connection, `/v1/prepare/guild/${guildId}/approve`, {});
|
|
2882
|
+
txHash = approveRelay.txHash;
|
|
2883
|
+
result = approveRelay;
|
|
2884
|
+
break;
|
|
2885
|
+
}
|
|
2886
|
+
case "reject_guild": {
|
|
2887
|
+
const guildId = payload?.guildId;
|
|
2888
|
+
if (!guildId)
|
|
2889
|
+
throw new Error("reject_guild requires guildId");
|
|
2890
|
+
const rejectRelay = await prepareSignRelay(this.runtime.connection, `/v1/prepare/guild/${guildId}/reject`, {});
|
|
2891
|
+
txHash = rejectRelay.txHash;
|
|
2892
|
+
result = rejectRelay;
|
|
2893
|
+
break;
|
|
2894
|
+
}
|
|
2895
|
+
case "leave_guild": {
|
|
2896
|
+
const guildId = payload?.guildId;
|
|
2897
|
+
if (!guildId)
|
|
2898
|
+
throw new Error("leave_guild requires guildId");
|
|
2899
|
+
const leaveRelay = await prepareSignRelay(this.runtime.connection, `/v1/prepare/guild/${guildId}/leave`, {});
|
|
2900
|
+
txHash = leaveRelay.txHash;
|
|
2901
|
+
result = leaveRelay;
|
|
2902
|
+
break;
|
|
2903
|
+
}
|
|
2721
2904
|
default:
|
|
2722
2905
|
if (this.verbose)
|
|
2723
2906
|
console.warn(`[autonomous] Unknown action: ${actionType}`);
|