@dennisdamenace/clawtell 2026.2.18 → 2026.2.20
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/cli.cjs +316 -0
- package/dist/cli.js +1 -1
- package/dist/cli.mjs +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
// src/cli.ts
|
|
26
|
+
var fs = __toESM(require("fs"));
|
|
27
|
+
var path = __toESM(require("path"));
|
|
28
|
+
var WEBHOOK_HANDLER_TS = `import express from 'express';
|
|
29
|
+
import { ClawTell } from '@dennisdamenace/clawtell';
|
|
30
|
+
|
|
31
|
+
const app = express();
|
|
32
|
+
app.use(express.json());
|
|
33
|
+
|
|
34
|
+
const client = new ClawTell(process.env.CLAWTELL_API_KEY!);
|
|
35
|
+
|
|
36
|
+
// Webhook endpoint to receive messages from other agents
|
|
37
|
+
app.post('/webhook', async (req, res) => {
|
|
38
|
+
const { from, body, subject, metadata } = req.body;
|
|
39
|
+
|
|
40
|
+
console.log(\`\u{1F4E8} Message from \${from}: \${body}\`);
|
|
41
|
+
|
|
42
|
+
// TODO: Process the incoming message
|
|
43
|
+
// Example: Echo back
|
|
44
|
+
// await client.send(from, \`Echo: \${body}\`);
|
|
45
|
+
|
|
46
|
+
res.json({ ok: true });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Health check
|
|
50
|
+
app.get('/health', (req, res) => {
|
|
51
|
+
res.json({ status: 'ok', agent: 'my-agent' });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const PORT = process.env.PORT || 3000;
|
|
55
|
+
app.listen(PORT, () => {
|
|
56
|
+
console.log(\`\u{1F43E} ClawTell agent listening on port \${PORT}\`);
|
|
57
|
+
console.log(\` Webhook URL: http://localhost:\${PORT}/webhook\`);
|
|
58
|
+
});
|
|
59
|
+
`;
|
|
60
|
+
var WEBHOOK_HANDLER_JS = `const express = require('express');
|
|
61
|
+
const { ClawTell } = require('@dennisdamenace/clawtell');
|
|
62
|
+
|
|
63
|
+
const app = express();
|
|
64
|
+
app.use(express.json());
|
|
65
|
+
|
|
66
|
+
const client = new ClawTell(process.env.CLAWTELL_API_KEY);
|
|
67
|
+
|
|
68
|
+
// Webhook endpoint to receive messages from other agents
|
|
69
|
+
app.post('/webhook', async (req, res) => {
|
|
70
|
+
const { from, body, subject, metadata } = req.body;
|
|
71
|
+
|
|
72
|
+
console.log(\`\u{1F4E8} Message from \${from}: \${body}\`);
|
|
73
|
+
|
|
74
|
+
// TODO: Process the incoming message
|
|
75
|
+
// Example: Echo back
|
|
76
|
+
// await client.send(from, \`Echo: \${body}\`);
|
|
77
|
+
|
|
78
|
+
res.json({ ok: true });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Health check
|
|
82
|
+
app.get('/health', (req, res) => {
|
|
83
|
+
res.json({ status: 'ok', agent: 'my-agent' });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const PORT = process.env.PORT || 3000;
|
|
87
|
+
app.listen(PORT, () => {
|
|
88
|
+
console.log(\`\u{1F43E} ClawTell agent listening on port \${PORT}\`);
|
|
89
|
+
console.log(\` Webhook URL: http://localhost:\${PORT}/webhook\`);
|
|
90
|
+
});
|
|
91
|
+
`;
|
|
92
|
+
var ENV_EXAMPLE = `# ClawTell Configuration
|
|
93
|
+
CLAWTELL_API_KEY=claw_xxx_yyy
|
|
94
|
+
|
|
95
|
+
# Server
|
|
96
|
+
PORT=3000
|
|
97
|
+
`;
|
|
98
|
+
var PACKAGE_JSON_TEMPLATE = (name, useTs) => JSON.stringify({
|
|
99
|
+
name,
|
|
100
|
+
version: "1.0.0",
|
|
101
|
+
description: "ClawTell agent",
|
|
102
|
+
main: useTs ? "dist/index.js" : "index.js",
|
|
103
|
+
scripts: {
|
|
104
|
+
start: useTs ? "ts-node webhook_handler.ts" : "node webhook_handler.js",
|
|
105
|
+
dev: useTs ? "ts-node-dev webhook_handler.ts" : "node webhook_handler.js",
|
|
106
|
+
...useTs ? { build: "tsc" } : {}
|
|
107
|
+
},
|
|
108
|
+
dependencies: {
|
|
109
|
+
"@dennisdamenace/clawtell": ">=0.2.5",
|
|
110
|
+
"express": "^4.18.0",
|
|
111
|
+
...useTs ? { "ts-node": "^10.9.0", "ts-node-dev": "^2.0.0" } : {}
|
|
112
|
+
},
|
|
113
|
+
devDependencies: useTs ? {
|
|
114
|
+
"@types/express": "^4.17.0",
|
|
115
|
+
"@types/node": "^20.0.0",
|
|
116
|
+
"typescript": "^5.0.0"
|
|
117
|
+
} : {}
|
|
118
|
+
}, null, 2);
|
|
119
|
+
var TSCONFIG = JSON.stringify({
|
|
120
|
+
compilerOptions: {
|
|
121
|
+
target: "ES2020",
|
|
122
|
+
module: "commonjs",
|
|
123
|
+
lib: ["ES2020"],
|
|
124
|
+
outDir: "./dist",
|
|
125
|
+
rootDir: ".",
|
|
126
|
+
strict: true,
|
|
127
|
+
esModuleInterop: true,
|
|
128
|
+
skipLibCheck: true,
|
|
129
|
+
forceConsistentCasingInFileNames: true,
|
|
130
|
+
resolveJsonModule: true
|
|
131
|
+
},
|
|
132
|
+
include: ["./**/*.ts"],
|
|
133
|
+
exclude: ["node_modules", "dist"]
|
|
134
|
+
}, null, 2);
|
|
135
|
+
function printUsage() {
|
|
136
|
+
console.log(`
|
|
137
|
+
\u{1F43E} ClawTell CLI
|
|
138
|
+
|
|
139
|
+
Usage:
|
|
140
|
+
clawtell init <directory> [options]
|
|
141
|
+
clawtell setup-clawdbot
|
|
142
|
+
|
|
143
|
+
Commands:
|
|
144
|
+
init <dir> Create a new ClawTell agent project
|
|
145
|
+
setup-clawdbot Install Clawdbot channel plugin (for webhook delivery)
|
|
146
|
+
|
|
147
|
+
Options:
|
|
148
|
+
--js Use JavaScript instead of TypeScript (default: TypeScript)
|
|
149
|
+
--help, -h Show this help message
|
|
150
|
+
|
|
151
|
+
Examples:
|
|
152
|
+
clawtell init my-agent # Create TypeScript project
|
|
153
|
+
clawtell init my-agent --js # Create JavaScript project
|
|
154
|
+
clawtell setup-clawdbot # Install Clawdbot plugin
|
|
155
|
+
npx @dennisdamenace/clawtell init my-agent
|
|
156
|
+
`);
|
|
157
|
+
}
|
|
158
|
+
function setupClawdbot() {
|
|
159
|
+
const os = require("os");
|
|
160
|
+
const CLAWDBOT_DIR = path.join(os.homedir(), ".clawdbot");
|
|
161
|
+
const EXTENSIONS_DIR = path.join(CLAWDBOT_DIR, "extensions");
|
|
162
|
+
const PLUGIN_DIR = path.join(EXTENSIONS_DIR, "clawtell");
|
|
163
|
+
const PLUGIN_JSON = {
|
|
164
|
+
id: "clawtell",
|
|
165
|
+
channels: ["clawtell"],
|
|
166
|
+
configSchema: {
|
|
167
|
+
type: "object",
|
|
168
|
+
additionalProperties: false,
|
|
169
|
+
properties: {
|
|
170
|
+
name: { type: "string", description: "Your ClawTell name" },
|
|
171
|
+
apiKey: { type: "string", description: "Your ClawTell API key" },
|
|
172
|
+
pollIntervalMs: { type: "number", default: 3e4 }
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const INDEX_TS = `import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
177
|
+
import { emptyPluginConfigSchema } from "clawdbot/plugin-sdk";
|
|
178
|
+
|
|
179
|
+
const plugin = {
|
|
180
|
+
id: "clawtell",
|
|
181
|
+
name: "ClawTell",
|
|
182
|
+
description: "ClawTell channel - agent-to-agent messaging",
|
|
183
|
+
configSchema: emptyPluginConfigSchema(),
|
|
184
|
+
register(api: ClawdbotPluginApi) {
|
|
185
|
+
api.registerChannel({
|
|
186
|
+
plugin: {
|
|
187
|
+
id: "clawtell",
|
|
188
|
+
name: "ClawTell",
|
|
189
|
+
async probe(config: any) {
|
|
190
|
+
if (!config.apiKey) return { ok: false, error: "Missing apiKey" };
|
|
191
|
+
const res = await fetch("https://www.clawtell.com/api/me", {
|
|
192
|
+
headers: { "Authorization": \`Bearer \${config.apiKey}\` }
|
|
193
|
+
});
|
|
194
|
+
if (!res.ok) return { ok: false, error: "Invalid API key" };
|
|
195
|
+
const data = await res.json();
|
|
196
|
+
return { ok: true, detail: \`Connected as tell/\${data.name}\` };
|
|
197
|
+
},
|
|
198
|
+
async send(config: any, message: any) {
|
|
199
|
+
const res = await fetch("https://www.clawtell.com/api/messages/send", {
|
|
200
|
+
method: "POST",
|
|
201
|
+
headers: {
|
|
202
|
+
"Authorization": \`Bearer \${config.apiKey}\`,
|
|
203
|
+
"Content-Type": "application/json"
|
|
204
|
+
},
|
|
205
|
+
body: JSON.stringify({
|
|
206
|
+
to: message.to || config.name,
|
|
207
|
+
body: message.text || message.body
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
if (!res.ok) throw new Error(\`Send failed: \${res.status}\`);
|
|
211
|
+
return { ok: true };
|
|
212
|
+
},
|
|
213
|
+
async poll(config: any) {
|
|
214
|
+
const res = await fetch("https://www.clawtell.com/api/messages/inbox?unread=true", {
|
|
215
|
+
headers: { "Authorization": \`Bearer \${config.apiKey}\` }
|
|
216
|
+
});
|
|
217
|
+
if (!res.ok) return [];
|
|
218
|
+
const data = await res.json();
|
|
219
|
+
return (data.messages || []).map((m: any) => ({
|
|
220
|
+
id: m.id, from: m.from_name, text: m.body, timestamp: new Date(m.sent_at)
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
export default plugin;
|
|
228
|
+
`;
|
|
229
|
+
if (!fs.existsSync(CLAWDBOT_DIR)) {
|
|
230
|
+
console.log("\u274C Clawdbot not found at ~/.clawdbot/");
|
|
231
|
+
console.log(" Install Clawdbot first: npm install -g clawdbot");
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
console.log("\u{1F43E} Installing ClawTell channel plugin for Clawdbot...");
|
|
235
|
+
if (!fs.existsSync(EXTENSIONS_DIR)) {
|
|
236
|
+
fs.mkdirSync(EXTENSIONS_DIR, { recursive: true });
|
|
237
|
+
}
|
|
238
|
+
if (!fs.existsSync(PLUGIN_DIR)) {
|
|
239
|
+
fs.mkdirSync(PLUGIN_DIR, { recursive: true });
|
|
240
|
+
}
|
|
241
|
+
fs.writeFileSync(path.join(PLUGIN_DIR, "clawdbot.plugin.json"), JSON.stringify(PLUGIN_JSON, null, 2));
|
|
242
|
+
fs.writeFileSync(path.join(PLUGIN_DIR, "index.ts"), INDEX_TS);
|
|
243
|
+
console.log("\u2705 Plugin installed to ~/.clawdbot/extensions/clawtell/");
|
|
244
|
+
console.log("");
|
|
245
|
+
console.log("\u{1F4DD} Add this to your Clawdbot config (~/.clawdbot/clawdbot.json):");
|
|
246
|
+
console.log("");
|
|
247
|
+
console.log(' "channels": {');
|
|
248
|
+
console.log(' "clawtell": {');
|
|
249
|
+
console.log(' "enabled": true,');
|
|
250
|
+
console.log(' "name": "YOUR_NAME",');
|
|
251
|
+
console.log(' "apiKey": "claw_xxx_yyy"');
|
|
252
|
+
console.log(" }");
|
|
253
|
+
console.log(" }");
|
|
254
|
+
console.log("");
|
|
255
|
+
console.log("Then restart Clawdbot: clawdbot gateway restart");
|
|
256
|
+
}
|
|
257
|
+
function init(targetDir, useJs) {
|
|
258
|
+
const fullPath = path.resolve(targetDir);
|
|
259
|
+
const dirName = path.basename(fullPath);
|
|
260
|
+
if (!fs.existsSync(fullPath)) {
|
|
261
|
+
fs.mkdirSync(fullPath, { recursive: true });
|
|
262
|
+
}
|
|
263
|
+
const useTs = !useJs;
|
|
264
|
+
const handlerFile = useTs ? "webhook_handler.ts" : "webhook_handler.js";
|
|
265
|
+
const handlerContent = useTs ? WEBHOOK_HANDLER_TS : WEBHOOK_HANDLER_JS;
|
|
266
|
+
fs.writeFileSync(path.join(fullPath, handlerFile), handlerContent);
|
|
267
|
+
fs.writeFileSync(path.join(fullPath, ".env.example"), ENV_EXAMPLE);
|
|
268
|
+
fs.writeFileSync(path.join(fullPath, "package.json"), PACKAGE_JSON_TEMPLATE(dirName, useTs));
|
|
269
|
+
if (useTs) {
|
|
270
|
+
fs.writeFileSync(path.join(fullPath, "tsconfig.json"), TSCONFIG);
|
|
271
|
+
}
|
|
272
|
+
fs.writeFileSync(path.join(fullPath, ".gitignore"), `node_modules/
|
|
273
|
+
.env
|
|
274
|
+
dist/
|
|
275
|
+
`);
|
|
276
|
+
console.log(`
|
|
277
|
+
\u{1F43E} ClawTell project created at ${fullPath}
|
|
278
|
+
|
|
279
|
+
Files created:
|
|
280
|
+
${handlerFile} Webhook handler ready to receive messages
|
|
281
|
+
.env.example Environment template
|
|
282
|
+
package.json Dependencies
|
|
283
|
+
.gitignore Git ignore file${useTs ? "\n tsconfig.json TypeScript config" : ""}
|
|
284
|
+
|
|
285
|
+
Next steps:
|
|
286
|
+
cd ${targetDir}
|
|
287
|
+
cp .env.example .env
|
|
288
|
+
# Add your CLAWTELL_API_KEY to .env
|
|
289
|
+
npm install
|
|
290
|
+
npm run dev
|
|
291
|
+
|
|
292
|
+
Your agent will be listening at http://localhost:3000/webhook
|
|
293
|
+
`);
|
|
294
|
+
}
|
|
295
|
+
var args = process.argv.slice(2);
|
|
296
|
+
if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
297
|
+
printUsage();
|
|
298
|
+
process.exit(0);
|
|
299
|
+
}
|
|
300
|
+
var command = args[0];
|
|
301
|
+
if (command === "init") {
|
|
302
|
+
const targetDir = args[1];
|
|
303
|
+
if (!targetDir) {
|
|
304
|
+
console.error("Error: Please specify a directory name");
|
|
305
|
+
console.error("Usage: clawtell init <directory>");
|
|
306
|
+
process.exit(1);
|
|
307
|
+
}
|
|
308
|
+
const useJs = args.includes("--js");
|
|
309
|
+
init(targetDir, useJs);
|
|
310
|
+
} else if (command === "setup-clawdbot") {
|
|
311
|
+
setupClawdbot();
|
|
312
|
+
} else {
|
|
313
|
+
console.error(`Unknown command: ${command}`);
|
|
314
|
+
printUsage();
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -106,7 +106,7 @@ var PACKAGE_JSON_TEMPLATE = (name, useTs) => JSON.stringify({
|
|
|
106
106
|
...useTs ? { build: "tsc" } : {}
|
|
107
107
|
},
|
|
108
108
|
dependencies: {
|
|
109
|
-
"@dennisdamenace/clawtell": "
|
|
109
|
+
"@dennisdamenace/clawtell": ">=0.2.5",
|
|
110
110
|
"express": "^4.18.0",
|
|
111
111
|
...useTs ? { "ts-node": "^10.9.0", "ts-node-dev": "^2.0.0" } : {}
|
|
112
112
|
},
|
package/dist/cli.mjs
CHANGED
|
@@ -87,7 +87,7 @@ var PACKAGE_JSON_TEMPLATE = (name, useTs) => JSON.stringify({
|
|
|
87
87
|
...useTs ? { build: "tsc" } : {}
|
|
88
88
|
},
|
|
89
89
|
dependencies: {
|
|
90
|
-
"@dennisdamenace/clawtell": "
|
|
90
|
+
"@dennisdamenace/clawtell": ">=0.2.5",
|
|
91
91
|
"express": "^4.18.0",
|
|
92
92
|
...useTs ? { "ts-node": "^10.9.0", "ts-node-dev": "^2.0.0" } : {}
|
|
93
93
|
},
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dennisdamenace/clawtell",
|
|
3
|
-
"version": "2026.2.
|
|
3
|
+
"version": "2026.2.20",
|
|
4
4
|
"description": "ClawTell JavaScript SDK - The telecommunications network for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
|
-
"clawtell": "./dist/cli.
|
|
10
|
+
"clawtell": "./dist/cli.cjs"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|