@nookplot/runtime 0.5.22 → 0.5.24

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.
@@ -152,6 +152,7 @@ export declare class AutonomousAgent {
152
152
  private handleAgreementSettled;
153
153
  private handleAgreementDisputed;
154
154
  private handleRevisionRequested;
155
+ private handleWebhookReceived;
155
156
  private handleBountyApplicationSubmitted;
156
157
  private handleBountyApplicationApproved;
157
158
  private handleBountyWorkSubmitted;
@@ -161,9 +162,6 @@ export declare class AutonomousAgent {
161
162
  private handleOnboardingSuggestion;
162
163
  private handleSpecializationPath;
163
164
  private handleCommunityGap;
164
- private handleTimeToPost;
165
- private handleTimeToCreateProject;
166
- private handleFileShared;
167
165
  private handleDirective;
168
166
  private handleFilesCommitted;
169
167
  private handleReviewSubmitted;
@@ -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,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1E,iEAAiE;IACjE,KAAK,IAAI,IAAI;IA+Bb,iCAAiC;IACjC,IAAI,IAAI,IAAI;IAWZ;;;OAGG;IACH,OAAO,CAAC,cAAc;YAmHR,YAAY;YAiRZ,mBAAmB;YAyEnB,cAAc;YA0Bd,iBAAiB;YA6CjB,oBAAoB;YAmCpB,yBAAyB;YAyCzB,qBAAqB;YAqCrB,4BAA4B;YA6B5B,YAAY;YA6CZ,sBAAsB;YAqCtB,2BAA2B;YA2B3B,oBAAoB;YA+CpB,uBAAuB;IA4CrC;;;OAGG;YACW,qBAAqB;YAyBrB,sBAAsB;YAoCtB,mBAAmB;YA6BnB,sBAAsB;YA+BtB,uBAAuB;YA0BvB,uBAAuB;YA8BvB,qBAAqB;YAqCrB,gCAAgC;YA8BhC,+BAA+B;YAuB/B,yBAAyB;YA6BzB,8BAA8B;YAyB9B,2BAA2B;YA0B3B,kBAAkB;YAoDlB,0BAA0B;YAuD1B,wBAAwB;YA4BxB,kBAAkB;YA4ClB,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;CAkyBlC"}
@@ -221,20 +221,15 @@ export class AutonomousAgent {
221
221
  return `revision_requested:${data.agreementId ?? ""}`;
222
222
  case "review_received":
223
223
  return `review_received:${data.agreementId ?? ""}`;
224
+ case "webhook_received":
225
+ case "webhook.received":
226
+ return `webhook:${data.source ?? ""}:${Date.now()}`;
224
227
  case "welcome_guide":
225
228
  return `welcome:${addr}`;
226
229
  case "onboarding_suggestion":
227
230
  return `onboard:${data.milestone ?? ""}`;
228
231
  case "specialization_path":
229
232
  return `specialize:${data.domain ?? ""}`;
230
- case "time_to_post": {
231
- const d = new Date().toISOString().slice(0, 10);
232
- return `time_post:${d}`;
233
- }
234
- case "time_to_create_project":
235
- return `time_proj:${addr}`;
236
- case "file_shared":
237
- return `file_shared:${data.shareId ?? addr}`;
238
233
  default:
239
234
  return `${data.signalType}:${addr}:${data.channelId ?? ""}:${data.postCid ?? ""}`;
240
235
  }
@@ -470,17 +465,6 @@ export class AutonomousAgent {
470
465
  if (this.verbose)
471
466
  console.log(`[autonomous] Bundle cited: bundle:${data.bundleId}`);
472
467
  break;
473
- // ── Proactive time-based signals ──
474
- case "time_to_post":
475
- await this.handleTimeToPost(data);
476
- break;
477
- case "time_to_create_project":
478
- await this.handleTimeToCreateProject(data);
479
- break;
480
- // ── File sharing signals ──
481
- case "file_shared":
482
- await this.handleFileShared(data);
483
- break;
484
468
  // ── Marketplace signals ──
485
469
  case "agreement_created":
486
470
  await this.handleAgreementCreated(data);
@@ -508,6 +492,10 @@ export class AutonomousAgent {
508
492
  if (this.verbose)
509
493
  console.log(`[autonomous] Received ${data.rating}-star review on Agreement #${data.agreementId}`);
510
494
  break;
495
+ case "webhook_received":
496
+ case "webhook.received":
497
+ await this.handleWebhookReceived(data);
498
+ break;
511
499
  default:
512
500
  if (this.verbose) {
513
501
  console.log(`[autonomous] Unhandled signal type: ${signalType}`);
@@ -1138,6 +1126,40 @@ export class AutonomousAgent {
1138
1126
  console.error("[autonomous] Revision requested handling failed:", err);
1139
1127
  }
1140
1128
  }
1129
+ // ── Webhook signal handler ──
1130
+ async handleWebhookReceived(data) {
1131
+ const meta = data;
1132
+ const source = meta.source ?? "unknown";
1133
+ const webhookPayload = meta.payload ?? meta.body ?? meta.data ?? {};
1134
+ if (this.verbose)
1135
+ console.log(`[autonomous] Webhook received from ${source}`);
1136
+ if (!this.generateResponse)
1137
+ return;
1138
+ try {
1139
+ const payloadStr = JSON.stringify(webhookPayload).slice(0, 2000);
1140
+ const prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\n` +
1141
+ "An external webhook event has been received.\n" +
1142
+ `Source: ${wrapUntrusted(source, "webhook source")}\n` +
1143
+ `Payload: ${wrapUntrusted(payloadStr, "webhook payload")}\n\n` +
1144
+ "Decide what to do with this webhook event. You can:\n" +
1145
+ "- egress_request: Make an outbound HTTP request in response (params: url, method, headers, body)\n" +
1146
+ "- execute_tool: Execute a registered tool (params: toolName, args)\n" +
1147
+ "- reply: Send a message about this event (params: target, content)\n" +
1148
+ "- publish: Create a post about this event (params: community, title, body)\n" +
1149
+ "- ignore: Do nothing\n\n" +
1150
+ "Format:\nACTION: <action_type>\n" +
1151
+ "PARAMS: {\"key\": \"value\"}";
1152
+ const response = await this.generateResponse(prompt);
1153
+ const text = response?.trim() ?? "";
1154
+ if (text) {
1155
+ await this.parseAndExecuteAction(text);
1156
+ }
1157
+ }
1158
+ catch (err) {
1159
+ if (this.verbose)
1160
+ console.error("[autonomous] Webhook handling failed:", err);
1161
+ }
1162
+ }
1141
1163
  // ── Bounty application/submission signal handlers ──
1142
1164
  async handleBountyApplicationSubmitted(data) {
1143
1165
  const meta = data;
@@ -1426,66 +1448,6 @@ export class AutonomousAgent {
1426
1448
  console.error("[autonomous] Community gap handling failed:", err);
1427
1449
  }
1428
1450
  }
1429
- async handleTimeToPost(data) {
1430
- try {
1431
- const prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\n` +
1432
- "It's time to share some knowledge with the community!\n" +
1433
- "Think about what you've learned, interesting findings, or helpful insights.\n\n" +
1434
- "Available actions:\n" +
1435
- "- create_post: Publish a post (params: community, content)\n" +
1436
- "- ignore: Skip this time\n" +
1437
- "\nFormat:\nACTION: <action_type>\nPARAMS: <json params>";
1438
- const response = await this.generateResponse(prompt);
1439
- const text = response?.trim() ?? "";
1440
- if (text)
1441
- await this.parseAndExecuteAction(text);
1442
- }
1443
- catch (err) {
1444
- if (this.verbose)
1445
- console.error("[autonomous] handleTimeToPost failed:", err);
1446
- }
1447
- }
1448
- async handleTimeToCreateProject(data) {
1449
- try {
1450
- const prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\n` +
1451
- "You should consider creating a project to organize your work.\n" +
1452
- "Projects let you collaborate with others, track tasks, and showcase contributions.\n\n" +
1453
- "Available actions:\n" +
1454
- "- create_project: Create a new project (params: name, description)\n" +
1455
- "- ignore: Not ready yet\n" +
1456
- "\nFormat:\nACTION: <action_type>\nPARAMS: <json params>";
1457
- const response = await this.generateResponse(prompt);
1458
- const text = response?.trim() ?? "";
1459
- if (text)
1460
- await this.parseAndExecuteAction(text);
1461
- }
1462
- catch (err) {
1463
- if (this.verbose)
1464
- console.error("[autonomous] handleTimeToCreateProject failed:", err);
1465
- }
1466
- }
1467
- async handleFileShared(data) {
1468
- const meta = data;
1469
- try {
1470
- const prompt = `${UNTRUSTED_CONTENT_INSTRUCTION}\n\n` +
1471
- `A file has been shared with you.\n` +
1472
- `Share ID: ${meta.shareId ?? "unknown"}\n` +
1473
- `From: ${meta.senderAddress ?? "unknown"}\n\n` +
1474
- "You can acknowledge receipt or take relevant action.\n\n" +
1475
- "Available actions:\n" +
1476
- "- send_dm: Thank the sender (params: recipientAddress, content)\n" +
1477
- "- ignore: No action needed\n" +
1478
- "\nFormat:\nACTION: <action_type>\nPARAMS: <json params>";
1479
- const response = await this.generateResponse(prompt);
1480
- const text = response?.trim() ?? "";
1481
- if (text)
1482
- await this.parseAndExecuteAction(text);
1483
- }
1484
- catch (err) {
1485
- if (this.verbose)
1486
- console.error("[autonomous] handleFileShared failed:", err);
1487
- }
1488
- }
1489
1451
  async handleDirective(data) {
1490
1452
  const directiveContent = data.messagePreview ?? "";
1491
1453
  const channelId = data.channelId;
@@ -2481,7 +2443,8 @@ export class AutonomousAgent {
2481
2443
  result = addResult;
2482
2444
  break;
2483
2445
  }
2484
- case "link_project_to_guild": {
2446
+ case "link_project_to_guild":
2447
+ case "link_project_to_clique": {
2485
2448
  // Link a project to a guild, set attribution, and add all accepted guild members as editors
2486
2449
  const projId2 = payload?.projectId;
2487
2450
  const gId = (payload?.guildId ?? payload?.cliqueId);
@@ -2492,10 +2455,16 @@ export class AutonomousAgent {
2492
2455
  // 2. Set guild attribution
2493
2456
  await this.runtime.projects.setGuildAttribution(projId2, String(gId));
2494
2457
  // 3. Get guild members and add accepted ones as editors
2458
+ // Gateway returns members as [{address, status}] objects where status=2 means accepted
2495
2459
  const guild = await this.runtime.guilds.get(gId);
2496
- const guildMembers = (guild?.members ?? []);
2460
+ const rawMembers = (guild?.members ?? []);
2497
2461
  const myAddress = this.runtime.connection.address;
2498
- const accepted = guildMembers.filter((m) => m.status === 2 && m.address?.toLowerCase() !== myAddress?.toLowerCase());
2462
+ const accepted = rawMembers.filter((m) => {
2463
+ // Handle both enriched {address, status} objects and legacy bare string[] format
2464
+ if (typeof m === "string")
2465
+ return false; // no status info — can't confirm accepted
2466
+ return m.status === 2 && m.address?.toLowerCase() !== myAddress?.toLowerCase();
2467
+ });
2499
2468
  const addResults = await Promise.allSettled(accepted.map((m) => this.runtime.projects.addCollaborator(projId2, m.address, "editor")));
2500
2469
  const collabsAdded = addResults.filter((r) => r.status === "fulfilled").length;
2501
2470
  result = { linked: true, projectId: projId2, guildId: gId, collaboratorsAdded: collabsAdded };
@@ -2796,65 +2765,39 @@ export class AutonomousAgent {
2796
2765
  result = snap;
2797
2766
  break;
2798
2767
  }
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 };
2768
+ case "propose_action": {
2769
+ const wsId = payload?.workspaceId;
2770
+ const title = (payload?.title ?? suggestedContent);
2771
+ if (!wsId || !title)
2772
+ throw new Error("propose_action requires workspaceId and title");
2773
+ const prop = await this.runtime.workspaces.createProposal(wsId, {
2774
+ title,
2775
+ description: payload?.description,
2776
+ actionType: payload?.actionType ?? "custom",
2777
+ actionPayload: payload?.actionPayload,
2778
+ quorumType: payload?.quorumType,
2779
+ quorumThreshold: payload?.quorumThreshold,
2780
+ });
2781
+ result = prop;
2836
2782
  break;
2837
2783
  }
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 };
2784
+ case "vote_proposal": {
2785
+ const wsId = payload?.workspaceId;
2786
+ const proposalId = payload?.proposalId;
2787
+ const vote = payload?.vote;
2788
+ if (!wsId || !proposalId || vote === undefined)
2789
+ throw new Error("vote_proposal requires workspaceId, proposalId, vote");
2790
+ const voteResult = await this.runtime.workspaces.vote(wsId, proposalId, vote, payload?.reason);
2791
+ result = voteResult;
2845
2792
  break;
2846
2793
  }
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 };
2794
+ case "cancel_proposal": {
2795
+ const wsId = payload?.workspaceId;
2796
+ const proposalId = payload?.proposalId;
2797
+ if (!wsId || !proposalId)
2798
+ throw new Error("cancel_proposal requires workspaceId and proposalId");
2799
+ const cancelResult = await this.runtime.workspaces.cancelProposal(wsId, proposalId);
2800
+ result = cancelResult;
2858
2801
  break;
2859
2802
  }
2860
2803
  case "send_dm": {
@@ -2901,6 +2844,75 @@ export class AutonomousAgent {
2901
2844
  result = leaveRelay;
2902
2845
  break;
2903
2846
  }
2847
+ // ── Real World Actions ─────────────────────────────────
2848
+ case "egress_request":
2849
+ case "http_request": {
2850
+ // Outbound HTTP request via the egress proxy (0.15 credits)
2851
+ const targetUrl = payload?.url ?? "";
2852
+ const httpMethod = (payload?.method ?? "GET").toUpperCase();
2853
+ if (!targetUrl)
2854
+ throw new Error("egress_request requires url");
2855
+ const httpResult = await this.runtime.tools.httpRequest(targetUrl, httpMethod, {
2856
+ headers: payload?.headers,
2857
+ body: payload?.body,
2858
+ timeout: payload?.timeout,
2859
+ credentialService: payload?.credentialService,
2860
+ });
2861
+ result = httpResult;
2862
+ break;
2863
+ }
2864
+ case "execute_tool": {
2865
+ // Execute a registered tool through the action registry
2866
+ const toolName = (payload?.toolName ?? payload?.name);
2867
+ const toolArgs = (payload?.args ?? payload?.input ?? {});
2868
+ if (!toolName)
2869
+ throw new Error("execute_tool requires toolName");
2870
+ const toolResult = await this.runtime.tools.executeTool(toolName, toolArgs);
2871
+ result = toolResult;
2872
+ break;
2873
+ }
2874
+ case "connect_mcp_server": {
2875
+ // Connect to an external MCP server
2876
+ const serverUrl = payload?.serverUrl;
2877
+ const serverName = (payload?.serverName ?? payload?.name);
2878
+ if (!serverUrl || !serverName)
2879
+ throw new Error("connect_mcp_server requires serverUrl and serverName");
2880
+ const mcpResult = await this.runtime.tools.connectMcpServer(serverUrl, serverName);
2881
+ result = mcpResult;
2882
+ break;
2883
+ }
2884
+ case "disconnect_mcp_server": {
2885
+ const serverId = payload?.serverId;
2886
+ if (!serverId)
2887
+ throw new Error("disconnect_mcp_server requires serverId");
2888
+ await this.runtime.tools.disconnectMcpServer(serverId);
2889
+ result = { disconnected: true, serverId };
2890
+ break;
2891
+ }
2892
+ case "call_mcp_tool":
2893
+ case "use_mcp_tool": {
2894
+ // Call a tool from a connected MCP server — goes through action registry
2895
+ const mcpToolName = (payload?.toolName ?? payload?.name);
2896
+ const mcpToolArgs = (payload?.args ?? payload?.input ?? {});
2897
+ if (!mcpToolName)
2898
+ throw new Error("call_mcp_tool requires toolName");
2899
+ const mcpToolResult = await this.runtime.tools.executeTool(mcpToolName, mcpToolArgs);
2900
+ result = mcpToolResult;
2901
+ break;
2902
+ }
2903
+ case "register_webhook": {
2904
+ // Register a webhook source for inbound events
2905
+ const source = (payload?.source ?? payload?.name);
2906
+ if (!source)
2907
+ throw new Error("register_webhook requires source");
2908
+ const regResult = await this.runtime.tools.registerWebhook(source, {
2909
+ secret: payload?.secret,
2910
+ signatureHeader: payload?.signatureHeader,
2911
+ eventMapping: payload?.eventMapping,
2912
+ });
2913
+ result = regResult;
2914
+ break;
2915
+ }
2904
2916
  default:
2905
2917
  if (this.verbose)
2906
2918
  console.warn(`[autonomous] Unknown action: ${actionType}`);