clawnexus-skill 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/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # clawnexus-skill
2
+
3
+ ClawNexus Skill for OpenClaw — query and manage AI instances from within an OpenClaw conversation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install clawnexus-skill
9
+ ```
10
+
11
+ ## Prerequisites
12
+
13
+ The `clawnexus` daemon must be running:
14
+
15
+ ```bash
16
+ npm install -g clawnexus
17
+ clawnexus start
18
+ ```
19
+
20
+ ## Actions
21
+
22
+ | Action | Description | Parameters |
23
+ |--------|-------------|------------|
24
+ | `list` | List all known instances | — |
25
+ | `info` | Get details for a specific instance | `name` |
26
+ | `scan` | Scan the local network for instances | — |
27
+ | `alias` | Set a friendly alias for an instance | `id`, `alias` |
28
+ | `connect` | Get WebSocket URL for an instance | `name` |
29
+ | `health` | Check daemon status | — |
30
+
31
+ ## Usage
32
+
33
+ ```typescript
34
+ import { handleSkillRequest } from "clawnexus-skill";
35
+
36
+ // List all instances
37
+ const result = await handleSkillRequest({ action: "list" });
38
+ // { success: true, data: { count: 2, instances: [...] } }
39
+
40
+ // Get instance info
41
+ const info = await handleSkillRequest({
42
+ action: "info",
43
+ params: { name: "home" },
44
+ });
45
+
46
+ // Scan the network
47
+ const scan = await handleSkillRequest({ action: "scan" });
48
+
49
+ // Set an alias
50
+ const alias = await handleSkillRequest({
51
+ action: "alias",
52
+ params: { id: "my-agent-id", alias: "home" },
53
+ });
54
+
55
+ // Get connection URL
56
+ const conn = await handleSkillRequest({
57
+ action: "connect",
58
+ params: { name: "home" },
59
+ });
60
+ // { success: true, data: { url: "ws://192.168.1.10:18789" } }
61
+ ```
62
+
63
+ ## Configuration
64
+
65
+ | Environment Variable | Description | Default |
66
+ |---------------------|-------------|---------|
67
+ | `CLAWNEXUS_API` | Daemon API URL | `http://localhost:17890` |
68
+
69
+ ## License
70
+
71
+ MIT
package/SKILL.md ADDED
@@ -0,0 +1,32 @@
1
+ # ClawNexus Skill
2
+
3
+ Query and manage OpenClaw instances discovered by the ClawNexus daemon.
4
+
5
+ ## Prerequisites
6
+
7
+ The `clawnexus` daemon must be running on `localhost:17890`.
8
+
9
+ ```bash
10
+ clawnexus start
11
+ ```
12
+
13
+ ## Actions
14
+
15
+ | Action | Description | Parameters |
16
+ |--------|-------------|------------|
17
+ | `list` | List all known instances | — |
18
+ | `info` | Get instance details | `name` |
19
+ | `scan` | Scan local network | — |
20
+ | `alias` | Set instance alias | `id`, `alias` |
21
+ | `connect` | Get WebSocket URL | `name` |
22
+ | `health` | Check daemon status | — |
23
+
24
+ ## Example Usage
25
+
26
+ ```json
27
+ { "action": "list" }
28
+ { "action": "info", "params": { "name": "home" } }
29
+ { "action": "scan" }
30
+ { "action": "alias", "params": { "id": "my-agent", "alias": "home" } }
31
+ { "action": "connect", "params": { "name": "home" } }
32
+ ```
@@ -0,0 +1,11 @@
1
+ interface SkillRequest {
2
+ action: string;
3
+ params?: Record<string, string>;
4
+ }
5
+ interface SkillResponse {
6
+ success: boolean;
7
+ data?: unknown;
8
+ error?: string;
9
+ }
10
+ export declare function handleSkillRequest(request: SkillRequest): Promise<SkillResponse>;
11
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ // ClawNexus Skill — OpenClaw Skill entry point
3
+ // Queries clawnexus daemon HTTP API at localhost:17890
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.handleSkillRequest = handleSkillRequest;
6
+ const API_URL = process.env.CLAWNEXUS_API ?? "http://localhost:17890";
7
+ async function callDaemon(method, path, body) {
8
+ try {
9
+ const res = await fetch(`${API_URL}${path}`, {
10
+ method,
11
+ headers: body ? { "Content-Type": "application/json" } : undefined,
12
+ body: body ? JSON.stringify(body) : undefined,
13
+ signal: AbortSignal.timeout(5000),
14
+ });
15
+ const data = await res.json();
16
+ return { ok: res.ok, data };
17
+ }
18
+ catch {
19
+ return { ok: false, data: { error: "Cannot connect to ClawNexus daemon" } };
20
+ }
21
+ }
22
+ async function handleSkillRequest(request) {
23
+ switch (request.action) {
24
+ case "list": {
25
+ const { ok, data } = await callDaemon("GET", "/instances");
26
+ return ok
27
+ ? { success: true, data }
28
+ : { success: false, error: data.error };
29
+ }
30
+ case "info": {
31
+ const name = request.params?.name;
32
+ if (!name)
33
+ return { success: false, error: "Missing instance name" };
34
+ const { ok, data } = await callDaemon("GET", `/instances/${encodeURIComponent(name)}`);
35
+ return ok
36
+ ? { success: true, data }
37
+ : { success: false, error: "Instance not found" };
38
+ }
39
+ case "scan": {
40
+ const { ok, data } = await callDaemon("POST", "/scan");
41
+ return ok
42
+ ? { success: true, data }
43
+ : { success: false, error: data.error };
44
+ }
45
+ case "alias": {
46
+ const id = request.params?.id;
47
+ const alias = request.params?.alias;
48
+ if (!id || !alias)
49
+ return { success: false, error: "Missing id or alias" };
50
+ const { ok, data } = await callDaemon("PUT", `/instances/${encodeURIComponent(id)}/alias`, { alias });
51
+ return ok
52
+ ? { success: true, data }
53
+ : { success: false, error: data.error };
54
+ }
55
+ case "connect": {
56
+ const name = request.params?.name;
57
+ if (!name)
58
+ return { success: false, error: "Missing instance name" };
59
+ const { ok, data } = await callDaemon("GET", `/instances/${encodeURIComponent(name)}`);
60
+ if (!ok)
61
+ return { success: false, error: "Instance not found" };
62
+ const inst = data;
63
+ const protocol = inst.tls ? "wss" : "ws";
64
+ return { success: true, data: { url: `${protocol}://${inst.address}:${inst.gateway_port}` } };
65
+ }
66
+ case "health": {
67
+ const { ok, data } = await callDaemon("GET", "/health");
68
+ return ok
69
+ ? { success: true, data }
70
+ : { success: false, error: "Daemon not available" };
71
+ }
72
+ case "resolve": {
73
+ const name = request.params?.name;
74
+ if (!name)
75
+ return { success: false, error: "Missing .claw name" };
76
+ const { ok, data } = await callDaemon("GET", `/resolve/${encodeURIComponent(name)}`);
77
+ return ok
78
+ ? { success: true, data }
79
+ : { success: false, error: "Name not found" };
80
+ }
81
+ default:
82
+ return { success: false, error: `Unknown action: ${request.action}` };
83
+ }
84
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "clawnexus-skill",
3
+ "version": "0.1.0",
4
+ "description": "ClawNexus OpenClaw Skill — query and manage instances from within OpenClaw",
5
+ "license": "MIT",
6
+ "author": "alan-silverstreams <alan@silverstream.tech>",
7
+ "homepage": "https://github.com/alan-silverstreams/ClawNexus",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/alan-silverstreams/ClawNexus.git",
11
+ "directory": "packages/skill"
12
+ },
13
+ "bugs": "https://github.com/alan-silverstreams/ClawNexus/issues",
14
+ "keywords": [
15
+ "openclaw",
16
+ "ai",
17
+ "agent",
18
+ "skill",
19
+ "clawnexus",
20
+ "instance",
21
+ "management"
22
+ ],
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
+ "files": [
26
+ "dist",
27
+ "SKILL.md",
28
+ "README.md"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc -p tsconfig.json",
32
+ "dev": "tsc -p tsconfig.json --watch",
33
+ "test": "vitest run",
34
+ "prepublishOnly": "pnpm build"
35
+ },
36
+ "engines": {
37
+ "node": ">=22"
38
+ },
39
+ "devDependencies": {
40
+ "typescript": "^5.7.0",
41
+ "@types/node": "^22.0.0"
42
+ }
43
+ }