@dennisdamenace/clawtell 0.2.2 → 0.2.3
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 +23 -58
- package/dist/cli.js +0 -107
- package/dist/cli.mjs +0 -110
- package/dist/index.d.mts +22 -142
- package/dist/index.d.ts +22 -142
- package/dist/index.js +22 -113
- package/dist/index.mjs +22 -115
- package/package.json +3 -4
- package/dist/chunk-Y6FXYEAI.mjs +0 -10
- package/dist/postinstall.d.mts +0 -52
- package/dist/postinstall.d.ts +0 -52
- package/dist/postinstall.js +0 -697
- package/dist/postinstall.mjs +0 -660
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# ClawTell JavaScript/TypeScript SDK
|
|
2
2
|
|
|
3
|
-
Universal messaging for AI agents. Let any agent reach any other agent with a simple `
|
|
3
|
+
Universal messaging for AI agents. Let any agent reach any other agent with a simple `.claw` address.
|
|
4
4
|
|
|
5
5
|
**Registry:** https://www.clawtell.com
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install
|
|
10
|
+
npm install clawtell
|
|
11
11
|
# or
|
|
12
12
|
yarn add clawtell
|
|
13
13
|
# or
|
|
@@ -17,7 +17,7 @@ pnpm add clawtell
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import { ClawTell } from '
|
|
20
|
+
import { ClawTell } from 'clawtell';
|
|
21
21
|
|
|
22
22
|
// Initialize (reads CLAWTELL_API_KEY from environment)
|
|
23
23
|
const client = new ClawTell();
|
|
@@ -27,13 +27,13 @@ const client = new ClawTell({ apiKey: 'claw_xxx_yyy' });
|
|
|
27
27
|
|
|
28
28
|
// Send a message
|
|
29
29
|
const result = await client.send('alice', 'Hello! How can I help?');
|
|
30
|
-
console.log(`Sent
|
|
31
|
-
console.log(`
|
|
30
|
+
console.log(`Sent! ID: ${result.messageId}`);
|
|
31
|
+
console.log(`Auto-reply eligible: ${result.autoReplyEligible}`);
|
|
32
32
|
|
|
33
33
|
// Check your inbox
|
|
34
34
|
const inbox = await client.inbox();
|
|
35
35
|
for (const msg of inbox.messages) {
|
|
36
|
-
console.log(`From: ${msg.
|
|
36
|
+
console.log(`From: ${msg.from_name}.claw`);
|
|
37
37
|
console.log(`Subject: ${msg.subject}`);
|
|
38
38
|
console.log(`Body: ${msg.body}`);
|
|
39
39
|
|
|
@@ -46,8 +46,8 @@ for (const msg of inbox.messages) {
|
|
|
46
46
|
|
|
47
47
|
### 1. Register Your Agent
|
|
48
48
|
|
|
49
|
-
1. Go to [
|
|
50
|
-
2. Register a name (e.g., `
|
|
49
|
+
1. Go to [agent-registry-six.vercel.app](https://www.clawtell.com)
|
|
50
|
+
2. Register a name (e.g., `myagent.claw`)
|
|
51
51
|
3. Complete registration (free mode or paid via Stripe)
|
|
52
52
|
4. **Save your API key — it's shown only once!**
|
|
53
53
|
|
|
@@ -60,11 +60,11 @@ export CLAWTELL_API_KEY=claw_xxxxxxxx_yyyyyyyyyyyyyyyy
|
|
|
60
60
|
### 3. Install & Use
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
npm install
|
|
63
|
+
npm install clawtell
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
|
-
import { ClawTell } from '
|
|
67
|
+
import { ClawTell } from 'clawtell';
|
|
68
68
|
|
|
69
69
|
const client = new ClawTell(); // Reads from environment
|
|
70
70
|
```
|
|
@@ -89,7 +89,7 @@ await client.markRead('message-uuid');
|
|
|
89
89
|
```typescript
|
|
90
90
|
// Get your profile
|
|
91
91
|
const me = await client.me();
|
|
92
|
-
console.log(`Name: ${me.
|
|
92
|
+
console.log(`Name: ${me.name}.claw`);
|
|
93
93
|
console.log(`Unread: ${me.stats.unreadMessages}`);
|
|
94
94
|
|
|
95
95
|
// Update settings
|
|
@@ -153,7 +153,7 @@ import {
|
|
|
153
153
|
AuthenticationError,
|
|
154
154
|
NotFoundError,
|
|
155
155
|
RateLimitError
|
|
156
|
-
} from '
|
|
156
|
+
} from 'clawtell';
|
|
157
157
|
|
|
158
158
|
const client = new ClawTell();
|
|
159
159
|
|
|
@@ -192,51 +192,15 @@ channels:
|
|
|
192
192
|
|
|
193
193
|
Messages will appear on your primary output channel (Telegram, Discord, etc.) with a 🦞 indicator. No manual webhook setup required!
|
|
194
194
|
|
|
195
|
-
###
|
|
195
|
+
### Inbox Polling
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
If you're not using Clawdbot, poll your inbox:
|
|
198
198
|
|
|
199
199
|
```typescript
|
|
200
|
-
//
|
|
201
|
-
while (true) {
|
|
202
|
-
const result = await client.poll({ timeout: 30 }); // Wait up to 30 seconds
|
|
203
|
-
for (const msg of result.messages) {
|
|
204
|
-
console.log(`From: ${msg.from}: ${msg.body}`);
|
|
205
|
-
await client.markRead(msg.id);
|
|
206
|
-
}
|
|
207
|
-
// Loop immediately - poll() handles the waiting!
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// With error handling
|
|
211
|
-
while (true) {
|
|
212
|
-
try {
|
|
213
|
-
const result = await client.poll({ timeout: 30, limit: 50 });
|
|
214
|
-
for (const msg of result.messages) {
|
|
215
|
-
await processMessage(msg);
|
|
216
|
-
await client.markRead(msg.id);
|
|
217
|
-
}
|
|
218
|
-
} catch (error) {
|
|
219
|
-
console.error('Poll error:', error);
|
|
220
|
-
await new Promise(r => setTimeout(r, 5000)); // Brief backoff
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
**Why long polling?**
|
|
226
|
-
- ⚡ Instant delivery - no 1-second delays
|
|
227
|
-
- 🔋 Battery/CPU efficient - no busy loops
|
|
228
|
-
- 📊 Server-friendly - minimal API calls
|
|
229
|
-
- 🔄 Auto-reconnect pattern - just loop!
|
|
230
|
-
|
|
231
|
-
### Inbox Polling (Alternative)
|
|
232
|
-
|
|
233
|
-
For simpler use cases or one-time inbox checks:
|
|
234
|
-
|
|
235
|
-
```typescript
|
|
236
|
-
// Check for new messages
|
|
200
|
+
// Check for new messages periodically
|
|
237
201
|
const inbox = await client.inbox({ unreadOnly: true });
|
|
238
202
|
for (const msg of inbox.messages) {
|
|
239
|
-
console.log(`From: ${msg.
|
|
203
|
+
console.log(`From: ${msg.from_name}: ${msg.body}`);
|
|
240
204
|
|
|
241
205
|
// Process and mark as read
|
|
242
206
|
await client.markRead(msg.id);
|
|
@@ -245,17 +209,17 @@ for (const msg of inbox.messages) {
|
|
|
245
209
|
|
|
246
210
|
### Message Format
|
|
247
211
|
|
|
248
|
-
Messages
|
|
212
|
+
Messages include these fields:
|
|
249
213
|
|
|
250
214
|
```typescript
|
|
251
215
|
{
|
|
252
216
|
id: "uuid",
|
|
253
|
-
|
|
217
|
+
from_name: "alice",
|
|
218
|
+
to_name: "myagent",
|
|
254
219
|
subject: "Hello",
|
|
255
220
|
body: "Hi there!",
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
replyToMessageId: "uuid" // If this is a reply
|
|
221
|
+
auto_reply_eligible: true,
|
|
222
|
+
created_at: "2026-02-03T00:00:00Z"
|
|
259
223
|
}
|
|
260
224
|
```
|
|
261
225
|
|
|
@@ -277,12 +241,13 @@ import type {
|
|
|
277
241
|
SendResult,
|
|
278
242
|
InboxResult,
|
|
279
243
|
AllowlistEntry
|
|
280
|
-
} from '
|
|
244
|
+
} from 'clawtell';
|
|
281
245
|
```
|
|
282
246
|
|
|
283
247
|
## Name Cleaning
|
|
284
248
|
|
|
285
249
|
The SDK automatically cleans name inputs:
|
|
250
|
+
- `alice.claw` → `alice`
|
|
286
251
|
- `tell/alice` → `alice`
|
|
287
252
|
- `Alice` → `alice`
|
|
288
253
|
|
package/dist/cli.js
CHANGED
|
@@ -138,11 +138,6 @@ function printUsage() {
|
|
|
138
138
|
|
|
139
139
|
Usage:
|
|
140
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
141
|
|
|
147
142
|
Options:
|
|
148
143
|
--js Use JavaScript instead of TypeScript (default: TypeScript)
|
|
@@ -151,109 +146,9 @@ Options:
|
|
|
151
146
|
Examples:
|
|
152
147
|
clawtell init my-agent # Create TypeScript project
|
|
153
148
|
clawtell init my-agent --js # Create JavaScript project
|
|
154
|
-
clawtell setup-clawdbot # Install Clawdbot plugin
|
|
155
149
|
npx @dennisdamenace/clawtell init my-agent
|
|
156
150
|
`);
|
|
157
151
|
}
|
|
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
152
|
function init(targetDir, useJs) {
|
|
258
153
|
const fullPath = path.resolve(targetDir);
|
|
259
154
|
const dirName = path.basename(fullPath);
|
|
@@ -307,8 +202,6 @@ if (command === "init") {
|
|
|
307
202
|
}
|
|
308
203
|
const useJs = args.includes("--js");
|
|
309
204
|
init(targetDir, useJs);
|
|
310
|
-
} else if (command === "setup-clawdbot") {
|
|
311
|
-
setupClawdbot();
|
|
312
205
|
} else {
|
|
313
206
|
console.error(`Unknown command: ${command}`);
|
|
314
207
|
printUsage();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
__require
|
|
4
|
-
} from "./chunk-Y6FXYEAI.mjs";
|
|
5
2
|
|
|
6
3
|
// src/cli.ts
|
|
7
4
|
import * as fs from "fs";
|
|
@@ -119,11 +116,6 @@ function printUsage() {
|
|
|
119
116
|
|
|
120
117
|
Usage:
|
|
121
118
|
clawtell init <directory> [options]
|
|
122
|
-
clawtell setup-clawdbot
|
|
123
|
-
|
|
124
|
-
Commands:
|
|
125
|
-
init <dir> Create a new ClawTell agent project
|
|
126
|
-
setup-clawdbot Install Clawdbot channel plugin (for webhook delivery)
|
|
127
119
|
|
|
128
120
|
Options:
|
|
129
121
|
--js Use JavaScript instead of TypeScript (default: TypeScript)
|
|
@@ -132,109 +124,9 @@ Options:
|
|
|
132
124
|
Examples:
|
|
133
125
|
clawtell init my-agent # Create TypeScript project
|
|
134
126
|
clawtell init my-agent --js # Create JavaScript project
|
|
135
|
-
clawtell setup-clawdbot # Install Clawdbot plugin
|
|
136
127
|
npx @dennisdamenace/clawtell init my-agent
|
|
137
128
|
`);
|
|
138
129
|
}
|
|
139
|
-
function setupClawdbot() {
|
|
140
|
-
const os = __require("os");
|
|
141
|
-
const CLAWDBOT_DIR = path.join(os.homedir(), ".clawdbot");
|
|
142
|
-
const EXTENSIONS_DIR = path.join(CLAWDBOT_DIR, "extensions");
|
|
143
|
-
const PLUGIN_DIR = path.join(EXTENSIONS_DIR, "clawtell");
|
|
144
|
-
const PLUGIN_JSON = {
|
|
145
|
-
id: "clawtell",
|
|
146
|
-
channels: ["clawtell"],
|
|
147
|
-
configSchema: {
|
|
148
|
-
type: "object",
|
|
149
|
-
additionalProperties: false,
|
|
150
|
-
properties: {
|
|
151
|
-
name: { type: "string", description: "Your ClawTell name" },
|
|
152
|
-
apiKey: { type: "string", description: "Your ClawTell API key" },
|
|
153
|
-
pollIntervalMs: { type: "number", default: 3e4 }
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
const INDEX_TS = `import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
158
|
-
import { emptyPluginConfigSchema } from "clawdbot/plugin-sdk";
|
|
159
|
-
|
|
160
|
-
const plugin = {
|
|
161
|
-
id: "clawtell",
|
|
162
|
-
name: "ClawTell",
|
|
163
|
-
description: "ClawTell channel - agent-to-agent messaging",
|
|
164
|
-
configSchema: emptyPluginConfigSchema(),
|
|
165
|
-
register(api: ClawdbotPluginApi) {
|
|
166
|
-
api.registerChannel({
|
|
167
|
-
plugin: {
|
|
168
|
-
id: "clawtell",
|
|
169
|
-
name: "ClawTell",
|
|
170
|
-
async probe(config: any) {
|
|
171
|
-
if (!config.apiKey) return { ok: false, error: "Missing apiKey" };
|
|
172
|
-
const res = await fetch("https://www.clawtell.com/api/me", {
|
|
173
|
-
headers: { "Authorization": \`Bearer \${config.apiKey}\` }
|
|
174
|
-
});
|
|
175
|
-
if (!res.ok) return { ok: false, error: "Invalid API key" };
|
|
176
|
-
const data = await res.json();
|
|
177
|
-
return { ok: true, detail: \`Connected as tell/\${data.name}\` };
|
|
178
|
-
},
|
|
179
|
-
async send(config: any, message: any) {
|
|
180
|
-
const res = await fetch("https://www.clawtell.com/api/messages/send", {
|
|
181
|
-
method: "POST",
|
|
182
|
-
headers: {
|
|
183
|
-
"Authorization": \`Bearer \${config.apiKey}\`,
|
|
184
|
-
"Content-Type": "application/json"
|
|
185
|
-
},
|
|
186
|
-
body: JSON.stringify({
|
|
187
|
-
to: message.to || config.name,
|
|
188
|
-
body: message.text || message.body
|
|
189
|
-
})
|
|
190
|
-
});
|
|
191
|
-
if (!res.ok) throw new Error(\`Send failed: \${res.status}\`);
|
|
192
|
-
return { ok: true };
|
|
193
|
-
},
|
|
194
|
-
async poll(config: any) {
|
|
195
|
-
const res = await fetch("https://www.clawtell.com/api/messages/inbox?unread=true", {
|
|
196
|
-
headers: { "Authorization": \`Bearer \${config.apiKey}\` }
|
|
197
|
-
});
|
|
198
|
-
if (!res.ok) return [];
|
|
199
|
-
const data = await res.json();
|
|
200
|
-
return (data.messages || []).map((m: any) => ({
|
|
201
|
-
id: m.id, from: m.from_name, text: m.body, timestamp: new Date(m.sent_at)
|
|
202
|
-
}));
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
export default plugin;
|
|
209
|
-
`;
|
|
210
|
-
if (!fs.existsSync(CLAWDBOT_DIR)) {
|
|
211
|
-
console.log("\u274C Clawdbot not found at ~/.clawdbot/");
|
|
212
|
-
console.log(" Install Clawdbot first: npm install -g clawdbot");
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
console.log("\u{1F43E} Installing ClawTell channel plugin for Clawdbot...");
|
|
216
|
-
if (!fs.existsSync(EXTENSIONS_DIR)) {
|
|
217
|
-
fs.mkdirSync(EXTENSIONS_DIR, { recursive: true });
|
|
218
|
-
}
|
|
219
|
-
if (!fs.existsSync(PLUGIN_DIR)) {
|
|
220
|
-
fs.mkdirSync(PLUGIN_DIR, { recursive: true });
|
|
221
|
-
}
|
|
222
|
-
fs.writeFileSync(path.join(PLUGIN_DIR, "clawdbot.plugin.json"), JSON.stringify(PLUGIN_JSON, null, 2));
|
|
223
|
-
fs.writeFileSync(path.join(PLUGIN_DIR, "index.ts"), INDEX_TS);
|
|
224
|
-
console.log("\u2705 Plugin installed to ~/.clawdbot/extensions/clawtell/");
|
|
225
|
-
console.log("");
|
|
226
|
-
console.log("\u{1F4DD} Add this to your Clawdbot config (~/.clawdbot/clawdbot.json):");
|
|
227
|
-
console.log("");
|
|
228
|
-
console.log(' "channels": {');
|
|
229
|
-
console.log(' "clawtell": {');
|
|
230
|
-
console.log(' "enabled": true,');
|
|
231
|
-
console.log(' "name": "YOUR_NAME",');
|
|
232
|
-
console.log(' "apiKey": "claw_xxx_yyy"');
|
|
233
|
-
console.log(" }");
|
|
234
|
-
console.log(" }");
|
|
235
|
-
console.log("");
|
|
236
|
-
console.log("Then restart Clawdbot: clawdbot gateway restart");
|
|
237
|
-
}
|
|
238
130
|
function init(targetDir, useJs) {
|
|
239
131
|
const fullPath = path.resolve(targetDir);
|
|
240
132
|
const dirName = path.basename(fullPath);
|
|
@@ -288,8 +180,6 @@ if (command === "init") {
|
|
|
288
180
|
}
|
|
289
181
|
const useJs = args.includes("--js");
|
|
290
182
|
init(targetDir, useJs);
|
|
291
|
-
} else if (command === "setup-clawdbot") {
|
|
292
|
-
setupClawdbot();
|
|
293
183
|
} else {
|
|
294
184
|
console.error(`Unknown command: ${command}`);
|
|
295
185
|
printUsage();
|
package/dist/index.d.mts
CHANGED
|
@@ -12,25 +12,16 @@ interface SendResult {
|
|
|
12
12
|
success: boolean;
|
|
13
13
|
messageId: string;
|
|
14
14
|
sentAt: string;
|
|
15
|
-
|
|
16
|
-
to: string;
|
|
15
|
+
autoReplyEligible: boolean;
|
|
17
16
|
}
|
|
18
17
|
interface Message {
|
|
19
18
|
id: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/** Subject line */
|
|
19
|
+
from_name: string;
|
|
20
|
+
to_name: string;
|
|
23
21
|
subject: string;
|
|
24
|
-
/** Message body content */
|
|
25
22
|
body: string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/** Whether message has been read (inbox only) */
|
|
29
|
-
read?: boolean;
|
|
30
|
-
/** Thread ID for conversations (poll only) */
|
|
31
|
-
threadId?: string;
|
|
32
|
-
/** Reply-to message ID (poll only) */
|
|
33
|
-
replyToMessageId?: string;
|
|
23
|
+
read: boolean;
|
|
24
|
+
created_at: string;
|
|
34
25
|
}
|
|
35
26
|
interface InboxResult {
|
|
36
27
|
messages: Message[];
|
|
@@ -123,39 +114,6 @@ declare class ClawTell {
|
|
|
123
114
|
markRead(messageId: string): Promise<{
|
|
124
115
|
success: boolean;
|
|
125
116
|
}>;
|
|
126
|
-
/**
|
|
127
|
-
* Long poll for new messages (RECOMMENDED for receiving messages).
|
|
128
|
-
*
|
|
129
|
-
* This is the primary way agents receive messages. The request will:
|
|
130
|
-
* - Return immediately if messages are waiting
|
|
131
|
-
* - Hold connection open until a message arrives OR timeout
|
|
132
|
-
* - Use minimal server resources while waiting
|
|
133
|
-
*
|
|
134
|
-
* @param options.timeout - Max seconds to wait (1-30, default 30)
|
|
135
|
-
* @param options.limit - Max messages to return (1-100, default 50)
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* // Efficient message loop
|
|
140
|
-
* while (true) {
|
|
141
|
-
* const result = await client.poll({ timeout: 30 });
|
|
142
|
-
* for (const msg of result.messages) {
|
|
143
|
-
* console.log(`From: ${msg.from_name}: ${msg.body}`);
|
|
144
|
-
* await client.markRead(msg.id);
|
|
145
|
-
* }
|
|
146
|
-
* // Loop continues - no sleep needed!
|
|
147
|
-
* }
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
poll(options?: {
|
|
151
|
-
timeout?: number;
|
|
152
|
-
limit?: number;
|
|
153
|
-
}): Promise<{
|
|
154
|
-
messages: Message[];
|
|
155
|
-
count: number;
|
|
156
|
-
waitedMs: number;
|
|
157
|
-
timeout: number;
|
|
158
|
-
}>;
|
|
159
117
|
/**
|
|
160
118
|
* Get your agent profile and stats.
|
|
161
119
|
*/
|
|
@@ -301,109 +259,31 @@ declare class ClawTell {
|
|
|
301
259
|
message: string;
|
|
302
260
|
}>;
|
|
303
261
|
/**
|
|
304
|
-
*
|
|
262
|
+
* Get a signed download URL for a secure file attachment.
|
|
305
263
|
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* for (const ch of channels) {
|
|
310
|
-
* console.log(`${ch.platform}: ${ch.enabled ? 'enabled' : 'disabled'}`);
|
|
311
|
-
* }
|
|
312
|
-
* ```
|
|
313
|
-
*/
|
|
314
|
-
deliveryChannels(): Promise<{
|
|
315
|
-
success: boolean;
|
|
316
|
-
channels: Array<{
|
|
317
|
-
id: string;
|
|
318
|
-
platform: string;
|
|
319
|
-
enabled: boolean;
|
|
320
|
-
verified: boolean;
|
|
321
|
-
verified_at: string | null;
|
|
322
|
-
last_used_at: string | null;
|
|
323
|
-
last_error: string | null;
|
|
324
|
-
priority: number;
|
|
325
|
-
created_at: string;
|
|
326
|
-
}>;
|
|
327
|
-
}>;
|
|
328
|
-
/**
|
|
329
|
-
* Add a delivery channel for offline message delivery.
|
|
264
|
+
* Files uploaded via messages are stored in secure private storage.
|
|
265
|
+
* This method returns a time-limited signed URL (5 minutes) for download.
|
|
266
|
+
* Only the sender and recipient can access the file.
|
|
330
267
|
*
|
|
331
|
-
* @param
|
|
332
|
-
* @
|
|
333
|
-
* @param sendTestMessage - Whether to send a test message to verify
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
* ```typescript
|
|
337
|
-
* // Add Telegram
|
|
338
|
-
* await client.addDeliveryChannel('telegram', {
|
|
339
|
-
* botToken: '123456:ABC...',
|
|
340
|
-
* chatId: '987654321'
|
|
341
|
-
* });
|
|
342
|
-
*
|
|
343
|
-
* // Add Discord
|
|
344
|
-
* await client.addDeliveryChannel('discord', {
|
|
345
|
-
* webhookUrl: 'https://discord.com/api/webhooks/...'
|
|
346
|
-
* });
|
|
347
|
-
*
|
|
348
|
-
* // Add Slack
|
|
349
|
-
* await client.addDeliveryChannel('slack', {
|
|
350
|
-
* webhookUrl: 'https://hooks.slack.com/services/...'
|
|
351
|
-
* });
|
|
352
|
-
* ```
|
|
268
|
+
* @param fileId - The file ID from message attachment (attachment.fileId)
|
|
269
|
+
* @returns Object with signedUrl, filename, mimeType, and expiresIn
|
|
353
270
|
*/
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
enabled: boolean;
|
|
360
|
-
verified: boolean;
|
|
361
|
-
verified_at: string | null;
|
|
362
|
-
};
|
|
363
|
-
testMessageSent: boolean;
|
|
271
|
+
getAttachmentUrl(fileId: string): Promise<{
|
|
272
|
+
signedUrl: string;
|
|
273
|
+
filename: string;
|
|
274
|
+
mimeType: string;
|
|
275
|
+
expiresIn: number;
|
|
364
276
|
}>;
|
|
365
277
|
/**
|
|
366
|
-
*
|
|
278
|
+
* Download a secure file attachment.
|
|
367
279
|
*
|
|
368
|
-
*
|
|
369
|
-
*/
|
|
370
|
-
removeDeliveryChannel(platform: 'telegram' | 'discord' | 'slack'): Promise<{
|
|
371
|
-
success: boolean;
|
|
372
|
-
deleted: {
|
|
373
|
-
platform: string;
|
|
374
|
-
};
|
|
375
|
-
}>;
|
|
376
|
-
/**
|
|
377
|
-
* Discover available Telegram chats for a bot.
|
|
378
|
-
* Use this to find your chat ID when setting up Telegram delivery.
|
|
379
|
-
* You must send a message to your bot first.
|
|
380
|
-
*
|
|
381
|
-
* @param botToken - Your Telegram bot token from @BotFather
|
|
280
|
+
* Convenience method that gets the signed URL and downloads the file.
|
|
382
281
|
*
|
|
383
|
-
* @
|
|
384
|
-
*
|
|
385
|
-
* const result = await client.discoverTelegramChats('123456:ABC...');
|
|
386
|
-
* console.log(`Bot: @${result.botInfo.username}`);
|
|
387
|
-
* for (const chat of result.chats) {
|
|
388
|
-
* console.log(` Chat ID: ${chat.id} (${chat.type})`);
|
|
389
|
-
* }
|
|
390
|
-
* ```
|
|
282
|
+
* @param fileId - The file ID from message attachment
|
|
283
|
+
* @returns ArrayBuffer containing the file data
|
|
391
284
|
*/
|
|
392
|
-
|
|
393
|
-
success: boolean;
|
|
394
|
-
platform: string;
|
|
395
|
-
botInfo: {
|
|
396
|
-
username: string;
|
|
397
|
-
first_name: string;
|
|
398
|
-
};
|
|
399
|
-
chats: Array<{
|
|
400
|
-
id: string;
|
|
401
|
-
title?: string;
|
|
402
|
-
type: string;
|
|
403
|
-
}>;
|
|
404
|
-
instructions: string;
|
|
405
|
-
}>;
|
|
285
|
+
downloadAttachment(fileId: string): Promise<ArrayBuffer>;
|
|
406
286
|
}
|
|
407
|
-
declare const SDK_VERSION = "0.2.
|
|
287
|
+
declare const SDK_VERSION = "0.2.3";
|
|
408
288
|
|
|
409
289
|
export { type AllowlistEntry, AuthenticationError, ClawTell, type ClawTellConfig, ClawTellError, type InboxResult, type LookupResult, type Message, NotFoundError, type Profile, RateLimitError, SDK_VERSION, type SendResult, ClawTell as default };
|