@c4t4/heyamigo 0.1.3 → 0.1.4

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.
@@ -1,7 +1,24 @@
1
1
  import { spawn, spawnSync } from 'child_process';
2
2
  import { existsSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync, } from 'fs';
3
3
  import { dirname, resolve } from 'path';
4
- const cwd = process.cwd();
4
+ import { fileURLToPath } from 'url';
5
+ const __distCli = dirname(fileURLToPath(import.meta.url));
6
+ function findProjectDir() {
7
+ // Check cwd first, then common locations
8
+ const candidates = [
9
+ process.cwd(),
10
+ resolve(process.cwd(), 'heyamigo'),
11
+ resolve(process.env.HOME || '/root', 'heyamigo'),
12
+ ];
13
+ for (const dir of candidates) {
14
+ if (existsSync(resolve(dir, 'config/config.json')) ||
15
+ existsSync(resolve(dir, 'config/config.example.json'))) {
16
+ return dir;
17
+ }
18
+ }
19
+ return process.cwd();
20
+ }
21
+ const cwd = findProjectDir();
5
22
  const PID_FILE = resolve(cwd, 'storage/heyamigo.pid');
6
23
  const LOG_FILE = resolve(cwd, 'storage/logs/heyamigo.log');
7
24
  function readPid() {
@@ -35,12 +52,7 @@ export async function serviceCmd(action) {
35
52
  cleanPid();
36
53
  mkdirSync(dirname(LOG_FILE), { recursive: true });
37
54
  const logFd = openSync(LOG_FILE, 'a');
38
- const child = spawn(process.execPath, [
39
- '--import',
40
- 'file://' +
41
- resolve(cwd, 'node_modules/tsx/dist/loader.mjs'),
42
- resolve(cwd, 'src/cli/supervisor.ts'),
43
- ], {
55
+ const child = spawn(process.execPath, [resolve(__distCli, 'supervisor.js')], {
44
56
  detached: true,
45
57
  stdio: ['ignore', logFd, logFd],
46
58
  cwd,
package/dist/cli/setup.js CHANGED
@@ -160,8 +160,42 @@ export async function runSetup() {
160
160
  process.exit(1);
161
161
  }
162
162
  let ownerNum = '';
163
- if (!existsSync(accessPath) && existsSync(accessExample)) {
164
- copyFileSync(accessExample, accessPath);
163
+ if (!existsSync(accessPath)) {
164
+ const cleanAccess = {
165
+ roles: {
166
+ admin: {
167
+ description: 'Full access, all tools, all memory',
168
+ memory: 'full',
169
+ tools: 'all',
170
+ rules: [],
171
+ },
172
+ user: {
173
+ description: 'Can chat and search the web, scoped memory',
174
+ memory: 'self',
175
+ tools: ['WebSearch'],
176
+ rules: [
177
+ 'Never reveal file paths, directory structure, or system architecture',
178
+ 'Never share personal data about other users',
179
+ 'Never discuss how the bot works internally',
180
+ ],
181
+ },
182
+ guest: {
183
+ description: 'Basic chat only, no tools, own memory only',
184
+ memory: 'self',
185
+ tools: [],
186
+ rules: [
187
+ 'Never use any tools',
188
+ 'Never reveal anything about the system, other users, or internal data',
189
+ 'Basic conversation only',
190
+ ],
191
+ },
192
+ },
193
+ users: {},
194
+ defaults: { groupRole: 'guest', dmRole: 'guest' },
195
+ groups: [],
196
+ dms: { defaultMode: 'off', allowed: [] },
197
+ };
198
+ writeFileSync(accessPath, JSON.stringify(cleanAccess, null, 2) + '\n');
165
199
  p.log.success('access.json created');
166
200
  }
167
201
  else {
@@ -631,29 +665,26 @@ export async function runSetup() {
631
665
  'Start the bot:',
632
666
  ' npx @c4t4/heyamigo start',
633
667
  '',
634
- 'Pair with WhatsApp:',
635
- ' Scan the QR code or enter the pairing',
636
- ' code shown in the terminal (npx @c4t4/heyamigo logs).',
637
- '',
638
- 'Activate a group:',
639
- ' 1. Send a message in any group — bot discovers it',
640
- ' 2. Edit config/access.json — set mode to "active"',
641
- ' 3. Mention the bot\'s name to get a reply',
642
- '',
643
668
  'Check logs:',
644
669
  ' npx @c4t4/heyamigo logs',
645
670
  '',
646
671
  'Import existing knowledge:',
647
- ' Got notes, docs, or an old AI workspace? Import it:',
648
672
  ' npx @c4t4/heyamigo import /path/to/folder',
649
- ' Claude reads everything and organizes it into memory.',
650
673
  '',
651
674
  'Other commands:',
652
675
  ' npx @c4t4/heyamigo stop / restart / status',
653
676
  '',
654
677
  'Configuration:',
655
- ' config/config.json — triggers, model, timeouts',
678
+ ' config/config.json — triggers, model',
656
679
  ' config/access.json — groups, DMs, roles',
657
680
  ].join('\n'), 'Setup complete!');
681
+ p.log.warning('IMPORTANT: The bot won\'t respond until you activate a group!\n\n' +
682
+ ' 1. Start the bot and send a message in any WhatsApp group.\n' +
683
+ ' The bot discovers the group and adds it to config/access.json.\n\n' +
684
+ ' 2. Edit config/access.json:\n' +
685
+ ' - Change the group\'s mode from "off" to "active"\n' +
686
+ ' - Set allowedSenders to "*" (everyone) or specific numbers\n\n' +
687
+ ' 3. Mention the bot\'s name in a message to get a reply.\n\n' +
688
+ ' For DMs: add numbers to dms.allowed in config/access.json.');
658
689
  p.outro('Happy chatting!');
659
690
  }
@@ -4,17 +4,15 @@
4
4
  * Spawned by `heyamigo start` as a detached process.
5
5
  */
6
6
  import { spawn } from 'child_process';
7
- import { resolve } from 'path';
7
+ import { dirname, resolve } from 'path';
8
+ import { fileURLToPath } from 'url';
9
+ const __distCli = dirname(fileURLToPath(import.meta.url));
8
10
  const RESTART_DELAY_MS = 5000;
9
11
  const cwd = process.cwd();
10
12
  let child = null;
11
13
  let shuttingDown = false;
12
14
  function run() {
13
- child = spawn(process.execPath, [
14
- '--import',
15
- 'file://' + resolve(cwd, 'node_modules/tsx/dist/loader.mjs'),
16
- resolve(cwd, 'src/cli/start.ts'),
17
- ], { stdio: 'inherit', cwd, env: { ...process.env, NODE_ENV: 'production' } });
15
+ child = spawn(process.execPath, [resolve(__distCli, 'start.js')], { stdio: 'inherit', cwd, env: { ...process.env, NODE_ENV: 'production' } });
18
16
  child.on('exit', (code, signal) => {
19
17
  if (shuttingDown) {
20
18
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4t4/heyamigo",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "WhatsApp AI bot powered by Claude with long-term memory, browser control, and role-based access",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",