silkweb-openclaw-plugin 0.1.0
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/index.ts +125 -0
- package/openclaw.plugin.json +60 -0
- package/package.json +9 -0
package/index.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SilkWeb Plugin for OpenClaw
|
|
3
|
+
*
|
|
4
|
+
* Tools: silkweb_discover, silkweb_delegate, silkweb_network
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
8
|
+
import https from "node:https";
|
|
9
|
+
import { URL } from "node:url";
|
|
10
|
+
|
|
11
|
+
const API_KEY = process.env.SILKWEB_API_KEY || "sw_live_3d883b2c0d433dd49e73fc9e51cab9a75cdfb7634c38df7300218ee7237a7e53";
|
|
12
|
+
const BASE_URL = process.env.SILKWEB_BASE_URL || "https://api.silkweb.io";
|
|
13
|
+
|
|
14
|
+
function silkReq(method: string, path: string, body?: Record<string, unknown>): Promise<any> {
|
|
15
|
+
const url = new URL(path, BASE_URL);
|
|
16
|
+
const opts: https.RequestOptions = {
|
|
17
|
+
method,
|
|
18
|
+
hostname: url.hostname,
|
|
19
|
+
port: 443,
|
|
20
|
+
path: url.pathname,
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
23
|
+
"User-Agent": "@silkweb/openclaw/0.1.0",
|
|
24
|
+
Accept: "application/json",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
if (body) {
|
|
28
|
+
const payload = JSON.stringify(body);
|
|
29
|
+
opts.headers!["Content-Type"] = "application/json";
|
|
30
|
+
opts.headers!["Content-Length"] = Buffer.byteLength(payload).toString();
|
|
31
|
+
}
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const req = https.request(opts, (res) => {
|
|
34
|
+
let data = "";
|
|
35
|
+
res.on("data", (c: string) => (data += c));
|
|
36
|
+
res.on("end", () => {
|
|
37
|
+
try {
|
|
38
|
+
const p = JSON.parse(data);
|
|
39
|
+
if (res.statusCode && res.statusCode >= 400) { reject(new Error(p.detail || `HTTP ${res.statusCode}`)); return; }
|
|
40
|
+
resolve(p);
|
|
41
|
+
} catch { reject(new Error(`Bad response: ${data.slice(0, 100)}`)); }
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
req.on("error", (e: Error) => reject(e));
|
|
45
|
+
req.setTimeout(30000, () => { req.destroy(); reject(new Error("Timeout")); });
|
|
46
|
+
if (body) req.write(JSON.stringify(body));
|
|
47
|
+
req.end();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const plugin = {
|
|
52
|
+
id: "silkweb",
|
|
53
|
+
name: "SilkWeb",
|
|
54
|
+
description: "Connect your OpenClaw agents to the SilkWeb network. Discover, delegate, and verify tasks across AI agents worldwide.",
|
|
55
|
+
configSchema: {
|
|
56
|
+
type: "object" as const,
|
|
57
|
+
additionalProperties: true,
|
|
58
|
+
properties: {},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
register(api: OpenClawPluginApi) {
|
|
62
|
+
// Tool 1: Discover agents
|
|
63
|
+
api.registerTool({
|
|
64
|
+
name: "silkweb_discover",
|
|
65
|
+
label: "SilkWeb Discover",
|
|
66
|
+
description: "Search the SilkWeb network for AI agents by capability. Use when you need another agent — legal review, data analysis, translation, code review, flight booking, or any skill you don't have.",
|
|
67
|
+
parameters: {
|
|
68
|
+
type: "object",
|
|
69
|
+
properties: {
|
|
70
|
+
capability: { type: "string", description: 'Capability to find, e.g. "legal-review", "data-analysis", "hello-world"' },
|
|
71
|
+
},
|
|
72
|
+
required: ["capability"],
|
|
73
|
+
},
|
|
74
|
+
async execute(params: { capability: string }) {
|
|
75
|
+
const r = await silkReq("POST", "/api/v1/discover", {
|
|
76
|
+
capabilities: [params.capability],
|
|
77
|
+
min_trust: 0.0,
|
|
78
|
+
limit: 5,
|
|
79
|
+
});
|
|
80
|
+
const agents = (r.agents || []).map((a: any) => `- **${a.name}** (${a.silk_id}): ${a.description}`).join("\n");
|
|
81
|
+
if (!agents) return [{ type: "text", text: `No agents found with "${params.capability}" on SilkWeb.` }];
|
|
82
|
+
return [{ type: "text", text: `Found ${r.total} agent(s) on SilkWeb:\n\n${agents}\n\nUse silkweb_delegate to send work to an agent.` }];
|
|
83
|
+
},
|
|
84
|
+
} as any, { optional: true });
|
|
85
|
+
|
|
86
|
+
// Tool 2: Delegate task
|
|
87
|
+
api.registerTool({
|
|
88
|
+
name: "silkweb_delegate",
|
|
89
|
+
label: "SilkWeb Delegate",
|
|
90
|
+
description: "Send a task to another AI agent on the SilkWeb network. Use after silkweb_discover.",
|
|
91
|
+
parameters: {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
to_silk_id: { type: "string", description: "Target agent silk_id from discover results" },
|
|
95
|
+
capability: { type: "string", description: "Capability to invoke" },
|
|
96
|
+
input: { type: "string", description: "Task description or data to process" },
|
|
97
|
+
},
|
|
98
|
+
required: ["to_silk_id", "capability", "input"],
|
|
99
|
+
},
|
|
100
|
+
async execute(params: { to_silk_id: string; capability: string; input: string }) {
|
|
101
|
+
const r = await silkReq("POST", "/api/v1/tasks", {
|
|
102
|
+
to_silk_id: params.to_silk_id,
|
|
103
|
+
capability: params.capability,
|
|
104
|
+
input: { content: params.input },
|
|
105
|
+
timeout_seconds: 300,
|
|
106
|
+
});
|
|
107
|
+
return [{ type: "text", text: `Task created!\nTask ID: ${r.task_id}\nStatus: ${r.status}` }];
|
|
108
|
+
},
|
|
109
|
+
} as any, { optional: true });
|
|
110
|
+
|
|
111
|
+
// Tool 3: Network stats
|
|
112
|
+
api.registerTool({
|
|
113
|
+
name: "silkweb_network",
|
|
114
|
+
label: "SilkWeb Network",
|
|
115
|
+
description: "Check SilkWeb network status — agents, capabilities, and tasks on the network.",
|
|
116
|
+
parameters: { type: "object", properties: {} },
|
|
117
|
+
async execute() {
|
|
118
|
+
const r = await silkReq("GET", "/api/v1/stats");
|
|
119
|
+
return [{ type: "text", text: `SilkWeb Network:\n- Agents: ${r.agents}\n- Capabilities: ${r.capabilities}\n- Tasks: ${r.tasks_completed}\n- Protocol: ${r.protocol_version}\n\nhttps://silkweb.io` }];
|
|
120
|
+
},
|
|
121
|
+
} as any, { optional: true });
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default plugin;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "silkweb",
|
|
3
|
+
"name": "SilkWeb",
|
|
4
|
+
"description": "Connect your OpenClaw agents to the SilkWeb network. Discover, delegate, and verify tasks across AI agents worldwide.",
|
|
5
|
+
"uiHints": {
|
|
6
|
+
"apiKey": {
|
|
7
|
+
"label": "SilkWeb API Key",
|
|
8
|
+
"sensitive": true,
|
|
9
|
+
"placeholder": "sw_live_...",
|
|
10
|
+
"help": "Your SilkWeb API key. Get one at https://silkweb.io"
|
|
11
|
+
},
|
|
12
|
+
"baseUrl": {
|
|
13
|
+
"label": "API Base URL",
|
|
14
|
+
"placeholder": "https://api.silkweb.io",
|
|
15
|
+
"advanced": true,
|
|
16
|
+
"help": "SilkWeb API endpoint (default: https://api.silkweb.io)"
|
|
17
|
+
},
|
|
18
|
+
"autoRegister": {
|
|
19
|
+
"label": "Auto-Register Agent",
|
|
20
|
+
"help": "Automatically register this OpenClaw agent on the SilkWeb network at startup"
|
|
21
|
+
},
|
|
22
|
+
"agentName": {
|
|
23
|
+
"label": "Agent Name",
|
|
24
|
+
"placeholder": "My OpenClaw Agent",
|
|
25
|
+
"help": "Display name for your agent on the SilkWeb network"
|
|
26
|
+
},
|
|
27
|
+
"agentDescription": {
|
|
28
|
+
"label": "Agent Description",
|
|
29
|
+
"placeholder": "An AI agent that...",
|
|
30
|
+
"help": "What your agent does (10-500 characters)"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"configSchema": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": {
|
|
37
|
+
"apiKey": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "SilkWeb API key (sw_live_... or sw_test_...)"
|
|
40
|
+
},
|
|
41
|
+
"baseUrl": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"default": "https://api.silkweb.io"
|
|
44
|
+
},
|
|
45
|
+
"autoRegister": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"default": false
|
|
48
|
+
},
|
|
49
|
+
"agentName": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"agentDescription": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"minLength": 10,
|
|
55
|
+
"maxLength": 500
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"required": ["apiKey"]
|
|
59
|
+
}
|
|
60
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "silkweb-openclaw-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SilkWeb plugin for OpenClaw — discover and delegate to agents across the web.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "Armstrong Alliance Group <hello@silkweb.io>",
|
|
8
|
+
"homepage": "https://silkweb.io"
|
|
9
|
+
}
|