clawcupid-agent 0.0.5 → 0.0.7
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.js
CHANGED
|
@@ -6,6 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { ZipFile } from 'yazl';
|
|
8
8
|
import extract from 'extract-zip';
|
|
9
|
+
import qrcode from 'qrcode-terminal';
|
|
9
10
|
function usage() {
|
|
10
11
|
console.log('Usage: clawcupid-agent <install|pack> [--out <path>] [--api <url>]');
|
|
11
12
|
process.exit(1);
|
|
@@ -94,11 +95,16 @@ async function main() {
|
|
|
94
95
|
await execa('npx', ['clawcupid-connect@0.0.1', 'setup', '--code', code, '--api', apiBase], {
|
|
95
96
|
stdio: 'inherit',
|
|
96
97
|
});
|
|
98
|
+
const cmdText = `clawcupid link ${code}`;
|
|
97
99
|
console.log('Installed clawcupid-agent skill to:', path.join(dst, 'clawcupid-agent'));
|
|
98
100
|
console.log('Server:', apiBase);
|
|
99
|
-
console.log('
|
|
100
|
-
console.log('
|
|
101
|
-
console.log(
|
|
101
|
+
console.log('\n==============================');
|
|
102
|
+
console.log('FINAL STEP (Telegram DM)');
|
|
103
|
+
console.log('Copy & paste this message:');
|
|
104
|
+
console.log(cmdText);
|
|
105
|
+
console.log('==============================\n');
|
|
106
|
+
console.log('QR (optional):');
|
|
107
|
+
qrcode.generate(cmdText, { small: true });
|
|
102
108
|
return;
|
|
103
109
|
}
|
|
104
110
|
usage();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawcupid-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "ClawCupid agent skill installer for OpenClaw (packs .skill and installs by extracting into the OpenClaw skills directory).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,9 +20,11 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"execa": "^9.6.0",
|
|
22
22
|
"extract-zip": "^2.0.1",
|
|
23
|
+
"qrcode-terminal": "^0.12.0",
|
|
23
24
|
"yazl": "^3.3.1"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
27
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
26
28
|
"@types/yazl": "^3.3.0",
|
|
27
29
|
"tsx": "^4.20.5",
|
|
28
30
|
"typescript": "^5.9.2"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Create/enable a cron job that runs poll_and_send every 120s.
|
|
4
|
+
* Uses openclaw cron add --every <ms>.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { execa } from 'execa';
|
|
10
|
+
|
|
11
|
+
const scriptPath = path.join(os.homedir(), '.openclaw', 'skills', 'clawcupid-agent', 'scripts', 'poll_and_send.mjs');
|
|
12
|
+
|
|
13
|
+
// Create an isolated cron job; it runs a one-shot agent turn per tick.
|
|
14
|
+
// We execute the node script via exec tool from the agent run.
|
|
15
|
+
const message = `Run: node ${scriptPath}`;
|
|
16
|
+
|
|
17
|
+
await execa('openclaw', [
|
|
18
|
+
'cron',
|
|
19
|
+
'add',
|
|
20
|
+
'--name',
|
|
21
|
+
'clawcupid-poller',
|
|
22
|
+
'--every',
|
|
23
|
+
'120000',
|
|
24
|
+
'--session',
|
|
25
|
+
'isolated',
|
|
26
|
+
'--message',
|
|
27
|
+
message,
|
|
28
|
+
'--delivery',
|
|
29
|
+
'none',
|
|
30
|
+
], {
|
|
31
|
+
stdio: 'inherit',
|
|
32
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Stop ClawCupid poller cron job.
|
|
4
|
+
* Note: requires job id. MVP: user can run openclaw cron list and remove manually.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { execa } from 'execa';
|
|
8
|
+
|
|
9
|
+
console.log('To stop:');
|
|
10
|
+
console.log('1) openclaw cron list');
|
|
11
|
+
console.log('2) openclaw cron remove <job-id>');
|
|
12
|
+
|
|
13
|
+
// We keep this as guidance because CLI subcommand names may vary by OpenClaw version.
|
|
14
|
+
await execa('openclaw', ['cron', 'list'], { stdio: 'inherit' });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Poll ClawCupid for events and send them to the user's Telegram via openclaw CLI.
|
|
4
|
+
* MVP: run while OpenClaw is running (cron job inside gateway).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'node:fs/promises';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { execa } from 'execa';
|
|
11
|
+
|
|
12
|
+
const cfgPath = path.join(os.homedir(), '.openclaw', 'clawcupid.json');
|
|
13
|
+
const cursorPath = path.join(os.homedir(), '.openclaw', 'clawcupid.cursor');
|
|
14
|
+
|
|
15
|
+
const cfg = JSON.parse(await fs.readFile(cfgPath, 'utf8'));
|
|
16
|
+
const api = cfg.api;
|
|
17
|
+
const deviceId = cfg.deviceId;
|
|
18
|
+
const channel = cfg.channel ?? 'telegram';
|
|
19
|
+
const to = cfg.to;
|
|
20
|
+
|
|
21
|
+
let cursor = undefined;
|
|
22
|
+
try {
|
|
23
|
+
cursor = (await fs.readFile(cursorPath, 'utf8')).trim() || undefined;
|
|
24
|
+
} catch {}
|
|
25
|
+
|
|
26
|
+
const url = new URL(`${api}/api/poll`);
|
|
27
|
+
url.searchParams.set('deviceId', deviceId);
|
|
28
|
+
if (cursor) url.searchParams.set('cursor', cursor);
|
|
29
|
+
url.searchParams.set('timeout', '60');
|
|
30
|
+
|
|
31
|
+
const res = await fetch(url);
|
|
32
|
+
const data = await res.json();
|
|
33
|
+
if (!res.ok || !data.ok) {
|
|
34
|
+
throw new Error(`poll failed: ${res.status} ${JSON.stringify(data)}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const events = data.events ?? [];
|
|
38
|
+
let last = cursor;
|
|
39
|
+
|
|
40
|
+
for (const e of events) {
|
|
41
|
+
last = e.eventId;
|
|
42
|
+
|
|
43
|
+
const text = e?.payload?.text
|
|
44
|
+
? String(e.payload.text)
|
|
45
|
+
: `[ClawCupid] Event: ${e.type} (${e.eventId})`;
|
|
46
|
+
|
|
47
|
+
// Prefer openclaw message send (works without internal tool plumbing)
|
|
48
|
+
await execa('openclaw', ['message', 'send', '--channel', channel, '--to', String(to), '--message', text], {
|
|
49
|
+
stdio: 'ignore',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (last && last !== cursor) {
|
|
54
|
+
await fs.writeFile(cursorPath, String(last) + '\n', 'utf8');
|
|
55
|
+
}
|