beecork 1.7.1 → 2.0.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 +52 -111
- package/dist/index.js +1394 -581
- package/package.json +26 -54
- package/dist/capabilities/index.d.ts +0 -3
- package/dist/capabilities/index.js +0 -2
- package/dist/capabilities/manager.d.ts +0 -13
- package/dist/capabilities/manager.js +0 -115
- package/dist/capabilities/packs.d.ts +0 -2
- package/dist/capabilities/packs.js +0 -54
- package/dist/capabilities/types.d.ts +0 -21
- package/dist/capabilities/types.js +0 -1
- package/dist/channels/admin.d.ts +0 -10
- package/dist/channels/admin.js +0 -20
- package/dist/channels/command-handler.d.ts +0 -19
- package/dist/channels/command-handler.js +0 -235
- package/dist/channels/discord.d.ts +0 -17
- package/dist/channels/discord.js +0 -266
- package/dist/channels/index.d.ts +0 -7
- package/dist/channels/index.js +0 -6
- package/dist/channels/loader.d.ts +0 -7
- package/dist/channels/loader.js +0 -87
- package/dist/channels/pipeline.d.ts +0 -50
- package/dist/channels/pipeline.js +0 -92
- package/dist/channels/registry.d.ts +0 -36
- package/dist/channels/registry.js +0 -80
- package/dist/channels/send-helpers.d.ts +0 -19
- package/dist/channels/send-helpers.js +0 -21
- package/dist/channels/telegram.d.ts +0 -47
- package/dist/channels/telegram.js +0 -649
- package/dist/channels/types.d.ts +0 -41
- package/dist/channels/types.js +0 -1
- package/dist/channels/voice-state.d.ts +0 -29
- package/dist/channels/voice-state.js +0 -45
- package/dist/channels/webhook.d.ts +0 -16
- package/dist/channels/webhook.js +0 -222
- package/dist/channels/whatsapp.d.ts +0 -28
- package/dist/channels/whatsapp.js +0 -323
- package/dist/cli/capabilities.d.ts +0 -3
- package/dist/cli/capabilities.js +0 -72
- package/dist/cli/channel.d.ts +0 -3
- package/dist/cli/channel.js +0 -202
- package/dist/cli/commands.d.ts +0 -15
- package/dist/cli/commands.js +0 -279
- package/dist/cli/doctor.d.ts +0 -1
- package/dist/cli/doctor.js +0 -208
- package/dist/cli/handoff.d.ts +0 -8
- package/dist/cli/handoff.js +0 -33
- package/dist/cli/helpers.d.ts +0 -2
- package/dist/cli/helpers.js +0 -21
- package/dist/cli/mcp.d.ts +0 -3
- package/dist/cli/mcp.js +0 -47
- package/dist/cli/media.d.ts +0 -2
- package/dist/cli/media.js +0 -125
- package/dist/cli/setup.d.ts +0 -1
- package/dist/cli/setup.js +0 -239
- package/dist/cli/store.d.ts +0 -3
- package/dist/cli/store.js +0 -108
- package/dist/config.d.ts +0 -11
- package/dist/config.js +0 -115
- package/dist/cron/scheduler.d.ts +0 -22
- package/dist/cron/scheduler.js +0 -220
- package/dist/cron/store.d.ts +0 -12
- package/dist/cron/store.js +0 -83
- package/dist/daemon.d.ts +0 -1
- package/dist/daemon.js +0 -345
- package/dist/dashboard/html.d.ts +0 -1
- package/dist/dashboard/html.js +0 -849
- package/dist/dashboard/routes.d.ts +0 -17
- package/dist/dashboard/routes.js +0 -623
- package/dist/dashboard/server.d.ts +0 -1
- package/dist/dashboard/server.js +0 -104
- package/dist/db/connection.d.ts +0 -29
- package/dist/db/connection.js +0 -37
- package/dist/db/index.d.ts +0 -14
- package/dist/db/index.js +0 -127
- package/dist/db/migrations.d.ts +0 -2
- package/dist/db/migrations.js +0 -384
- package/dist/delegation/manager.d.ts +0 -18
- package/dist/delegation/manager.js +0 -89
- package/dist/index.d.ts +0 -2
- package/dist/knowledge/index.d.ts +0 -2
- package/dist/knowledge/index.js +0 -1
- package/dist/knowledge/manager.d.ts +0 -17
- package/dist/knowledge/manager.js +0 -160
- package/dist/knowledge/types.d.ts +0 -7
- package/dist/knowledge/types.js +0 -1
- package/dist/machines/forwarder.d.ts +0 -7
- package/dist/machines/forwarder.js +0 -35
- package/dist/machines/index.d.ts +0 -1
- package/dist/machines/index.js +0 -1
- package/dist/machines/registry.d.ts +0 -15
- package/dist/machines/registry.js +0 -46
- package/dist/mcp/handlers.d.ts +0 -37
- package/dist/mcp/handlers.js +0 -520
- package/dist/mcp/server.d.ts +0 -2
- package/dist/mcp/server.js +0 -86
- package/dist/mcp/tool-definitions.d.ts +0 -1225
- package/dist/mcp/tool-definitions.js +0 -412
- package/dist/mcp/validate.d.ts +0 -23
- package/dist/mcp/validate.js +0 -65
- package/dist/media/factory.d.ts +0 -6
- package/dist/media/factory.js +0 -36
- package/dist/media/generators/dall-e.d.ts +0 -10
- package/dist/media/generators/dall-e.js +0 -41
- package/dist/media/generators/elevenlabs-music.d.ts +0 -9
- package/dist/media/generators/elevenlabs-music.js +0 -34
- package/dist/media/generators/elevenlabs-sfx.d.ts +0 -9
- package/dist/media/generators/elevenlabs-sfx.js +0 -33
- package/dist/media/generators/kling.d.ts +0 -9
- package/dist/media/generators/kling.js +0 -47
- package/dist/media/generators/lyria.d.ts +0 -10
- package/dist/media/generators/lyria.js +0 -41
- package/dist/media/generators/nano-banana.d.ts +0 -10
- package/dist/media/generators/nano-banana.js +0 -45
- package/dist/media/generators/poll-util.d.ts +0 -12
- package/dist/media/generators/poll-util.js +0 -22
- package/dist/media/generators/recraft.d.ts +0 -9
- package/dist/media/generators/recraft.js +0 -52
- package/dist/media/generators/runway.d.ts +0 -9
- package/dist/media/generators/runway.js +0 -49
- package/dist/media/generators/stable-diffusion.d.ts +0 -9
- package/dist/media/generators/stable-diffusion.js +0 -35
- package/dist/media/generators/veo.d.ts +0 -9
- package/dist/media/generators/veo.js +0 -32
- package/dist/media/index.d.ts +0 -6
- package/dist/media/index.js +0 -8
- package/dist/media/loader.d.ts +0 -8
- package/dist/media/loader.js +0 -46
- package/dist/media/store.d.ts +0 -17
- package/dist/media/store.js +0 -69
- package/dist/media/types.d.ts +0 -43
- package/dist/media/types.js +0 -1
- package/dist/memory/extractor.d.ts +0 -5
- package/dist/memory/extractor.js +0 -157
- package/dist/notifications/index.d.ts +0 -4
- package/dist/notifications/index.js +0 -21
- package/dist/notifications/ntfy.d.ts +0 -9
- package/dist/notifications/ntfy.js +0 -25
- package/dist/notifications/pushover.d.ts +0 -9
- package/dist/notifications/pushover.js +0 -26
- package/dist/notifications/types.d.ts +0 -5
- package/dist/notifications/types.js +0 -1
- package/dist/notifications/webhook-provider.d.ts +0 -9
- package/dist/notifications/webhook-provider.js +0 -24
- package/dist/observability/analytics.d.ts +0 -30
- package/dist/observability/analytics.js +0 -118
- package/dist/pipe/anthropic-client.d.ts +0 -9
- package/dist/pipe/anthropic-client.js +0 -50
- package/dist/pipe/brain.d.ts +0 -16
- package/dist/pipe/brain.js +0 -89
- package/dist/pipe/memory-store.d.ts +0 -8
- package/dist/pipe/memory-store.js +0 -39
- package/dist/pipe/project-scanner.d.ts +0 -6
- package/dist/pipe/project-scanner.js +0 -26
- package/dist/pipe/types.d.ts +0 -34
- package/dist/pipe/types.js +0 -1
- package/dist/projects/index.d.ts +0 -4
- package/dist/projects/index.js +0 -2
- package/dist/projects/manager.d.ts +0 -13
- package/dist/projects/manager.js +0 -166
- package/dist/projects/router.d.ts +0 -17
- package/dist/projects/router.js +0 -246
- package/dist/projects/types.d.ts +0 -19
- package/dist/projects/types.js +0 -1
- package/dist/service/install.d.ts +0 -4
- package/dist/service/install.js +0 -146
- package/dist/service/templates.d.ts +0 -4
- package/dist/service/templates.js +0 -52
- package/dist/service/windows.d.ts +0 -8
- package/dist/service/windows.js +0 -59
- package/dist/session/budget-guard.d.ts +0 -20
- package/dist/session/budget-guard.js +0 -31
- package/dist/session/circuit-breaker.d.ts +0 -19
- package/dist/session/circuit-breaker.js +0 -91
- package/dist/session/context-compactor.d.ts +0 -32
- package/dist/session/context-compactor.js +0 -45
- package/dist/session/context-monitor.d.ts +0 -15
- package/dist/session/context-monitor.js +0 -44
- package/dist/session/handoff.d.ts +0 -21
- package/dist/session/handoff.js +0 -50
- package/dist/session/manager.d.ts +0 -60
- package/dist/session/manager.js +0 -416
- package/dist/session/memory-store.d.ts +0 -29
- package/dist/session/memory-store.js +0 -45
- package/dist/session/message-queue.d.ts +0 -28
- package/dist/session/message-queue.js +0 -52
- package/dist/session/pending-dispatcher.d.ts +0 -31
- package/dist/session/pending-dispatcher.js +0 -120
- package/dist/session/pending-store.d.ts +0 -60
- package/dist/session/pending-store.js +0 -118
- package/dist/session/stale-session.d.ts +0 -31
- package/dist/session/stale-session.js +0 -45
- package/dist/session/subprocess.d.ts +0 -32
- package/dist/session/subprocess.js +0 -230
- package/dist/session/tab-store.d.ts +0 -28
- package/dist/session/tab-store.js +0 -78
- package/dist/session/tool-classifier.d.ts +0 -4
- package/dist/session/tool-classifier.js +0 -56
- package/dist/tasks/scheduler.d.ts +0 -45
- package/dist/tasks/scheduler.js +0 -329
- package/dist/tasks/store.d.ts +0 -11
- package/dist/tasks/store.js +0 -103
- package/dist/timeline/index.d.ts +0 -3
- package/dist/timeline/index.js +0 -2
- package/dist/timeline/logger.d.ts +0 -8
- package/dist/timeline/logger.js +0 -11
- package/dist/timeline/query.d.ts +0 -11
- package/dist/timeline/query.js +0 -67
- package/dist/timeline/types.d.ts +0 -12
- package/dist/timeline/types.js +0 -1
- package/dist/types.d.ts +0 -225
- package/dist/types.js +0 -3
- package/dist/users/index.d.ts +0 -2
- package/dist/users/index.js +0 -1
- package/dist/users/service.d.ts +0 -17
- package/dist/users/service.js +0 -46
- package/dist/util/auto-heal.d.ts +0 -43
- package/dist/util/auto-heal.js +0 -107
- package/dist/util/install-info.d.ts +0 -37
- package/dist/util/install-info.js +0 -80
- package/dist/util/logger.d.ts +0 -18
- package/dist/util/logger.js +0 -118
- package/dist/util/paths.d.ts +0 -13
- package/dist/util/paths.js +0 -55
- package/dist/util/platform.d.ts +0 -2
- package/dist/util/platform.js +0 -11
- package/dist/util/progress.d.ts +0 -34
- package/dist/util/progress.js +0 -133
- package/dist/util/rate-limiter.d.ts +0 -14
- package/dist/util/rate-limiter.js +0 -50
- package/dist/util/retry.d.ts +0 -2
- package/dist/util/retry.js +0 -18
- package/dist/util/text.d.ts +0 -32
- package/dist/util/text.js +0 -101
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -4
- package/dist/voice/index.d.ts +0 -17
- package/dist/voice/index.js +0 -42
- package/dist/voice/stt.d.ts +0 -16
- package/dist/voice/stt.js +0 -57
- package/dist/voice/tts.d.ts +0 -23
- package/dist/voice/tts.js +0 -84
- package/dist/watchers/evaluator.d.ts +0 -5
- package/dist/watchers/evaluator.js +0 -45
- package/dist/watchers/index.d.ts +0 -4
- package/dist/watchers/index.js +0 -3
- package/dist/watchers/scheduler.d.ts +0 -20
- package/dist/watchers/scheduler.js +0 -183
- package/dist/watchers/store.d.ts +0 -10
- package/dist/watchers/store.js +0 -56
- package/dist/watchers/types.d.ts +0 -15
- package/dist/watchers/types.js +0 -1
- package/scripts/postinstall.mjs +0 -50
package/dist/cli/commands.js
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { spawn, execSync } from 'node:child_process';
|
|
4
|
-
import { getDb, closeDb } from '../db/index.js';
|
|
5
|
-
import { getConfig } from '../config.js';
|
|
6
|
-
import { TaskStore } from '../tasks/store.js';
|
|
7
|
-
import { TabStore } from '../session/tab-store.js';
|
|
8
|
-
import { getDaemonPid, timeAgo } from './helpers.js';
|
|
9
|
-
import { startService, stopService } from '../service/install.js';
|
|
10
|
-
import { getPidPath, getLogsDir } from '../util/paths.js';
|
|
11
|
-
import { VERSION } from '../version.js';
|
|
12
|
-
function requireDb() {
|
|
13
|
-
try {
|
|
14
|
-
return getDb();
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
console.error('Database not initialized — run "beecork setup" first.');
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export async function startDaemon() {
|
|
22
|
-
const existingPid = getDaemonPid();
|
|
23
|
-
if (existingPid) {
|
|
24
|
-
console.log(`Beecork daemon is already running (PID: ${existingPid})`);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
startService();
|
|
29
|
-
console.log('Beecork daemon started via system service.');
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
// Fallback: start daemon directly
|
|
33
|
-
console.log('Starting daemon directly...');
|
|
34
|
-
const daemonPath = new URL('../daemon.js', import.meta.url).pathname;
|
|
35
|
-
const child = spawn('node', [daemonPath], {
|
|
36
|
-
detached: true,
|
|
37
|
-
stdio: 'ignore',
|
|
38
|
-
});
|
|
39
|
-
child.unref();
|
|
40
|
-
console.log(`Beecork daemon started (PID: ${child.pid})`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export async function stopDaemon() {
|
|
44
|
-
const pid = getDaemonPid();
|
|
45
|
-
if (!pid) {
|
|
46
|
-
console.log('Beecork daemon is not running.');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
stopService();
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
// Fallback: kill by PID
|
|
54
|
-
try {
|
|
55
|
-
process.kill(pid, 'SIGTERM');
|
|
56
|
-
const pidPath = getPidPath();
|
|
57
|
-
if (fs.existsSync(pidPath))
|
|
58
|
-
fs.unlinkSync(pidPath);
|
|
59
|
-
}
|
|
60
|
-
catch (killErr) {
|
|
61
|
-
const msg = killErr instanceof Error ? killErr.message : String(killErr);
|
|
62
|
-
console.error(`Failed to stop daemon (PID ${pid}): ${msg}`);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
console.log('Beecork daemon stopped.');
|
|
67
|
-
}
|
|
68
|
-
export async function showStatus() {
|
|
69
|
-
const pid = getDaemonPid();
|
|
70
|
-
const config = getConfig();
|
|
71
|
-
console.log(`\nBeecork v${VERSION}`);
|
|
72
|
-
console.log(`Daemon: ${pid ? `running (PID ${pid})` : 'stopped'}`);
|
|
73
|
-
console.log(`Deployment: ${config.deployment}`);
|
|
74
|
-
try {
|
|
75
|
-
getDb(); // ensure DB initialized
|
|
76
|
-
const tabs = TabStore.listAll();
|
|
77
|
-
console.log(`\nTabs (${tabs.length}):`);
|
|
78
|
-
for (const tab of tabs) {
|
|
79
|
-
const ago = timeAgo(tab.lastActivityAt);
|
|
80
|
-
const pidInfo = tab.pid ? ` (PID ${tab.pid})` : '';
|
|
81
|
-
console.log(` ${tab.name.padEnd(20)} ${tab.status.padEnd(12)} last active: ${ago}${pidInfo}`);
|
|
82
|
-
}
|
|
83
|
-
const store = new TaskStore();
|
|
84
|
-
const jobs = store.list();
|
|
85
|
-
const activeJobs = jobs.filter((j) => j.enabled);
|
|
86
|
-
console.log(`\nTasks: ${activeJobs.length} active (${jobs.length} total)`);
|
|
87
|
-
if (activeJobs.length > 0) {
|
|
88
|
-
for (const job of activeJobs.slice(0, 5)) {
|
|
89
|
-
const lastRun = job.lastRunAt ? `last: ${timeAgo(job.lastRunAt)}` : 'never run';
|
|
90
|
-
console.log(` ${job.name.padEnd(20)} ${job.scheduleType}:${job.schedule.padEnd(15)} → tab:${job.tabName} (${lastRun})`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
closeDb();
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
console.log('\n(database not initialized — run "beecork setup" first)');
|
|
97
|
-
}
|
|
98
|
-
console.log('');
|
|
99
|
-
}
|
|
100
|
-
export async function listTabs() {
|
|
101
|
-
requireDb();
|
|
102
|
-
const tabs = TabStore.listAll();
|
|
103
|
-
closeDb();
|
|
104
|
-
if (tabs.length === 0) {
|
|
105
|
-
console.log('No tabs.');
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
console.log(`\nTabs (${tabs.length}):\n`);
|
|
109
|
-
for (const tab of tabs) {
|
|
110
|
-
const ago = timeAgo(tab.lastActivityAt);
|
|
111
|
-
console.log(` ${tab.name.padEnd(20)} [${tab.status}] dir:${tab.workingDir} — ${ago}`);
|
|
112
|
-
}
|
|
113
|
-
console.log('');
|
|
114
|
-
}
|
|
115
|
-
export async function tailLogs(tabName) {
|
|
116
|
-
const logFile = tabName
|
|
117
|
-
? `${getLogsDir()}/${path.basename(tabName)}.log`
|
|
118
|
-
: `${getLogsDir()}/daemon.stdout.log`;
|
|
119
|
-
if (!fs.existsSync(logFile)) {
|
|
120
|
-
console.log(`No log file found: ${logFile}`);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (process.platform === 'win32') {
|
|
124
|
-
// Windows: use PowerShell Get-Content -Wait
|
|
125
|
-
const child = spawn('powershell', ['-Command', `Get-Content -Path '${logFile}' -Tail 50 -Wait`], { stdio: 'inherit' });
|
|
126
|
-
process.on('SIGINT', () => child.kill());
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
const child = spawn('tail', ['-f', '-n', '50', logFile], { stdio: 'inherit' });
|
|
130
|
-
process.on('SIGINT', () => child.kill());
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export async function listCrons() {
|
|
134
|
-
requireDb();
|
|
135
|
-
const store = new TaskStore();
|
|
136
|
-
const jobs = store.list();
|
|
137
|
-
if (jobs.length === 0) {
|
|
138
|
-
console.log('No tasks.');
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
console.log(`\nTasks (${jobs.length}):\n`);
|
|
142
|
-
for (const job of jobs) {
|
|
143
|
-
const status = job.enabled ? 'enabled' : 'disabled';
|
|
144
|
-
const lastRun = job.lastRunAt ? timeAgo(job.lastRunAt) : 'never';
|
|
145
|
-
console.log(` ${job.name.padEnd(20)} [${status}] ${job.scheduleType}:${job.schedule}`);
|
|
146
|
-
console.log(` -> tab:${job.tabName} | last: ${lastRun} | ID: ${job.id}`);
|
|
147
|
-
}
|
|
148
|
-
console.log('');
|
|
149
|
-
}
|
|
150
|
-
export async function deleteCron(id) {
|
|
151
|
-
requireDb();
|
|
152
|
-
const store = new TaskStore();
|
|
153
|
-
if (store.delete(id)) {
|
|
154
|
-
console.log(`Deleted task: ${id}`);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
console.log(`No task found with ID: ${id}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export async function listWatchers() {
|
|
161
|
-
const db = requireDb();
|
|
162
|
-
const watchers = db.prepare('SELECT * FROM watchers ORDER BY created_at').all();
|
|
163
|
-
closeDb();
|
|
164
|
-
if (watchers.length === 0) {
|
|
165
|
-
console.log('No watchers.');
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
console.log(`\nWatchers (${watchers.length}):\n`);
|
|
169
|
-
for (const w of watchers) {
|
|
170
|
-
const status = w.enabled ? 'enabled' : 'disabled';
|
|
171
|
-
const lastCheck = w.last_check_at ? timeAgo(w.last_check_at) : 'never';
|
|
172
|
-
console.log(` ${w.name.padEnd(20)} [${status}] ${w.schedule}`);
|
|
173
|
-
console.log(` condition: ${w.condition} | action: ${w.action} | triggers: ${w.trigger_count} | last: ${lastCheck} | ID: ${w.id}`);
|
|
174
|
-
}
|
|
175
|
-
console.log('');
|
|
176
|
-
}
|
|
177
|
-
export async function deleteWatcher(id) {
|
|
178
|
-
const db = requireDb();
|
|
179
|
-
const result = db.prepare('DELETE FROM watchers WHERE id = ?').run(id);
|
|
180
|
-
closeDb();
|
|
181
|
-
if (result.changes > 0) {
|
|
182
|
-
console.log(`Deleted watcher: ${id}`);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
console.log(`No watcher found with ID: ${id}`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
export async function listMemories() {
|
|
189
|
-
const db = requireDb();
|
|
190
|
-
const memories = db
|
|
191
|
-
.prepare('SELECT * FROM memories ORDER BY created_at DESC LIMIT 50')
|
|
192
|
-
.all();
|
|
193
|
-
closeDb();
|
|
194
|
-
if (memories.length === 0) {
|
|
195
|
-
console.log('No memories stored.');
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
console.log(`\nMemories (${memories.length}):\n`);
|
|
199
|
-
for (const mem of memories) {
|
|
200
|
-
const scope = mem.tabName ? `tab:${mem.tabName}` : 'global';
|
|
201
|
-
console.log(` [${mem.id}] (${mem.source}, ${scope}) ${mem.content.slice(0, 100)}${mem.content.length > 100 ? '...' : ''}`);
|
|
202
|
-
console.log(` ${timeAgo(mem.createdAt)}`);
|
|
203
|
-
}
|
|
204
|
-
console.log('');
|
|
205
|
-
}
|
|
206
|
-
export async function deleteMemory(id) {
|
|
207
|
-
const db = requireDb();
|
|
208
|
-
const result = db.prepare('DELETE FROM memories WHERE id = ?').run(parseInt(id, 10));
|
|
209
|
-
closeDb();
|
|
210
|
-
if (result.changes > 0) {
|
|
211
|
-
console.log(`Deleted memory: ${id}`);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
console.log(`No memory found with ID: ${id}`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
export async function updateBeecork(options) {
|
|
218
|
-
if (options.check) {
|
|
219
|
-
try {
|
|
220
|
-
const latest = execSync('npm view beecork version', { encoding: 'utf-8' }).trim();
|
|
221
|
-
const current = VERSION;
|
|
222
|
-
if (latest === current) {
|
|
223
|
-
console.log(`Already up to date (v${current})`);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
console.log(`Update available: v${current} → v${latest}`);
|
|
227
|
-
console.log('Run `beecork update` to install.');
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
console.log('Could not check for updates.');
|
|
232
|
-
}
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
// Stop daemon if running
|
|
236
|
-
const pid = getDaemonPid();
|
|
237
|
-
if (pid) {
|
|
238
|
-
console.log('Stopping daemon before update...');
|
|
239
|
-
await stopDaemon();
|
|
240
|
-
}
|
|
241
|
-
console.log(`Updating beecork from v${VERSION}...`);
|
|
242
|
-
try {
|
|
243
|
-
execSync('npm install -g beecork@latest', { stdio: 'inherit' });
|
|
244
|
-
const newVersion = execSync('npm view beecork version', { encoding: 'utf-8' }).trim();
|
|
245
|
-
console.log(`Update complete! v${VERSION} → v${newVersion}`);
|
|
246
|
-
}
|
|
247
|
-
catch {
|
|
248
|
-
console.error('Update failed. Try running: npm install -g beecork@latest');
|
|
249
|
-
}
|
|
250
|
-
// Restart if it was running — spawn the NEW binary so the freshly installed
|
|
251
|
-
// code is used, not the stale in-memory code from before the update.
|
|
252
|
-
if (pid) {
|
|
253
|
-
console.log('Restarting daemon...');
|
|
254
|
-
try {
|
|
255
|
-
execSync('beecork start', { stdio: 'inherit' });
|
|
256
|
-
}
|
|
257
|
-
catch {
|
|
258
|
-
console.error('Could not restart daemon. Run "beecork start" manually.');
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
export async function sendMessage(message) {
|
|
263
|
-
// This is a simple CLI test command. It starts a subprocess directly.
|
|
264
|
-
const { TabManager } = await import('../session/manager.js');
|
|
265
|
-
const config = getConfig();
|
|
266
|
-
const manager = new TabManager(config);
|
|
267
|
-
console.log(`Sending to default tab: "${message}"\n`);
|
|
268
|
-
try {
|
|
269
|
-
const result = await manager.sendMessage('default', message);
|
|
270
|
-
console.log(result.text);
|
|
271
|
-
if (result.costUsd > 0) {
|
|
272
|
-
console.log(`\n--- Cost: $${result.costUsd.toFixed(4)} | Duration: ${result.durationMs}ms ---`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
catch (err) {
|
|
276
|
-
console.error('Error:', err instanceof Error ? err.message : err);
|
|
277
|
-
}
|
|
278
|
-
closeDb();
|
|
279
|
-
}
|
package/dist/cli/doctor.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function runDoctor(): Promise<void>;
|
package/dist/cli/doctor.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { execSync } from 'node:child_process';
|
|
3
|
-
import { getConfig } from '../config.js';
|
|
4
|
-
import { getDbPath, getPidPath, getBeecorkHome, getConfigPath, getMcpConfigPath, getWhatsappSessionPath, } from '../util/paths.js';
|
|
5
|
-
import { getMediaDir } from '../media/store.js';
|
|
6
|
-
export async function runDoctor() {
|
|
7
|
-
const checks = [];
|
|
8
|
-
// 1. Check Claude binary
|
|
9
|
-
try {
|
|
10
|
-
const config = getConfig();
|
|
11
|
-
const bin = config.claudeCode?.bin || 'claude';
|
|
12
|
-
const whichCmd = process.platform === 'win32' ? 'where' : 'which';
|
|
13
|
-
execSync(`${whichCmd} ${bin}`, { encoding: 'utf-8' });
|
|
14
|
-
try {
|
|
15
|
-
const version = execSync(`${bin} --version 2>&1`, { encoding: 'utf-8' }).trim();
|
|
16
|
-
checks.push({ name: 'Claude Code', status: 'pass', message: `Found: ${version}` });
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
checks.push({ name: 'Claude Code', status: 'pass', message: `Found at: ${bin}` });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
checks.push({
|
|
24
|
-
name: 'Claude Code',
|
|
25
|
-
status: 'fail',
|
|
26
|
-
message: 'Claude Code binary not found. Install: npm install -g @anthropic-ai/claude-code',
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
// 2. Check config file
|
|
30
|
-
const configPath = getConfigPath();
|
|
31
|
-
if (fs.existsSync(configPath)) {
|
|
32
|
-
try {
|
|
33
|
-
const config = getConfig();
|
|
34
|
-
checks.push({ name: 'Config', status: 'pass', message: configPath });
|
|
35
|
-
// 3. Check Telegram token
|
|
36
|
-
if (config.telegram?.token) {
|
|
37
|
-
try {
|
|
38
|
-
const resp = await fetch(`https://api.telegram.org/bot${config.telegram.token}/getMe`, {
|
|
39
|
-
signal: AbortSignal.timeout(10000),
|
|
40
|
-
});
|
|
41
|
-
if (resp.ok) {
|
|
42
|
-
const data = (await resp.json());
|
|
43
|
-
checks.push({
|
|
44
|
-
name: 'Telegram bot',
|
|
45
|
-
status: 'pass',
|
|
46
|
-
message: `@${data.result.username}`,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
checks.push({
|
|
51
|
-
name: 'Telegram bot',
|
|
52
|
-
status: 'fail',
|
|
53
|
-
message: 'Invalid token — getMe returned error',
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
checks.push({
|
|
59
|
-
name: 'Telegram bot',
|
|
60
|
-
status: 'warn',
|
|
61
|
-
message: 'Could not reach Telegram API',
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
checks.push({ name: 'Telegram bot', status: 'warn', message: 'No token configured' });
|
|
67
|
-
}
|
|
68
|
-
// 4. Check WhatsApp session
|
|
69
|
-
if (config.whatsapp?.enabled) {
|
|
70
|
-
const sessionPath = config.whatsapp.sessionPath || getWhatsappSessionPath();
|
|
71
|
-
if (fs.existsSync(sessionPath) && fs.readdirSync(sessionPath).length > 0) {
|
|
72
|
-
checks.push({ name: 'WhatsApp session', status: 'pass', message: sessionPath });
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
checks.push({
|
|
76
|
-
name: 'WhatsApp session',
|
|
77
|
-
status: 'warn',
|
|
78
|
-
message: 'No session data — QR scan needed',
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
checks.push({ name: 'Config', status: 'fail', message: `Invalid config: ${err}` });
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
checks.push({
|
|
89
|
-
name: 'Config',
|
|
90
|
-
status: 'fail',
|
|
91
|
-
message: `Not found at ${configPath}. Run: beecork setup`,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
// 5. Check database
|
|
95
|
-
const dbPath = getDbPath();
|
|
96
|
-
if (fs.existsSync(dbPath)) {
|
|
97
|
-
try {
|
|
98
|
-
const { openDb } = await import('../db/connection.js');
|
|
99
|
-
const db = openDb(dbPath, { readonly: true });
|
|
100
|
-
const integrity = db.pragma('integrity_check');
|
|
101
|
-
if (integrity[0]?.integrity_check === 'ok') {
|
|
102
|
-
const size = (fs.statSync(dbPath).size / 1024).toFixed(0);
|
|
103
|
-
checks.push({ name: 'Database', status: 'pass', message: `${size} KB, integrity OK` });
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
checks.push({ name: 'Database', status: 'fail', message: 'Integrity check failed!' });
|
|
107
|
-
}
|
|
108
|
-
db.close();
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
checks.push({ name: 'Database', status: 'fail', message: `Cannot open: ${err}` });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
checks.push({
|
|
116
|
-
name: 'Database',
|
|
117
|
-
status: 'warn',
|
|
118
|
-
message: 'No database yet — starts on first run',
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
// 6. Check daemon
|
|
122
|
-
const pidPath = getPidPath();
|
|
123
|
-
if (fs.existsSync(pidPath)) {
|
|
124
|
-
const pid = parseInt(fs.readFileSync(pidPath, 'utf-8').trim(), 10);
|
|
125
|
-
try {
|
|
126
|
-
process.kill(pid, 0);
|
|
127
|
-
checks.push({ name: 'Daemon', status: 'pass', message: `Running (PID ${pid})` });
|
|
128
|
-
}
|
|
129
|
-
catch {
|
|
130
|
-
checks.push({
|
|
131
|
-
name: 'Daemon',
|
|
132
|
-
status: 'warn',
|
|
133
|
-
message: `Stale PID file (PID ${pid} not running)`,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
checks.push({ name: 'Daemon', status: 'warn', message: 'Not running' });
|
|
139
|
-
}
|
|
140
|
-
// 7. Check disk space for media
|
|
141
|
-
try {
|
|
142
|
-
const mediaDir = getMediaDir();
|
|
143
|
-
const homeDir = getBeecorkHome();
|
|
144
|
-
// Simple check: can we write a temp file?
|
|
145
|
-
const testPath = `${homeDir}/.doctor-test`;
|
|
146
|
-
fs.writeFileSync(testPath, 'test');
|
|
147
|
-
fs.unlinkSync(testPath);
|
|
148
|
-
if (fs.existsSync(mediaDir)) {
|
|
149
|
-
const files = fs.readdirSync(mediaDir);
|
|
150
|
-
checks.push({
|
|
151
|
-
name: 'Media dir',
|
|
152
|
-
status: 'pass',
|
|
153
|
-
message: `${files.length} files in ${mediaDir}`,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
checks.push({
|
|
158
|
-
name: 'Media dir',
|
|
159
|
-
status: 'pass',
|
|
160
|
-
message: 'Not created yet (created on first media)',
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
catch {
|
|
165
|
-
checks.push({
|
|
166
|
-
name: 'Disk space',
|
|
167
|
-
status: 'fail',
|
|
168
|
-
message: 'Cannot write to beecork home directory',
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
// 8. Check MCP config
|
|
172
|
-
const mcpConfigPath = getMcpConfigPath();
|
|
173
|
-
if (fs.existsSync(mcpConfigPath)) {
|
|
174
|
-
try {
|
|
175
|
-
const mcpConfig = JSON.parse(fs.readFileSync(mcpConfigPath, 'utf-8'));
|
|
176
|
-
const serverCount = Object.keys(mcpConfig.mcpServers || {}).length;
|
|
177
|
-
checks.push({
|
|
178
|
-
name: 'MCP config',
|
|
179
|
-
status: 'pass',
|
|
180
|
-
message: `${serverCount} server(s) configured`,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
checks.push({
|
|
185
|
-
name: 'MCP config',
|
|
186
|
-
status: 'fail',
|
|
187
|
-
message: 'Invalid JSON in mcp-config.json',
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
checks.push({ name: 'MCP config', status: 'pass', message: 'Default (beecork MCP only)' });
|
|
193
|
-
}
|
|
194
|
-
// Print results — gate ANSI on a real TTY so piping to a file/grep yields plain text.
|
|
195
|
-
console.log('\nBeecork Doctor\n');
|
|
196
|
-
const colored = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
197
|
-
const icons = colored
|
|
198
|
-
? { pass: '\x1b[32m✓\x1b[0m', warn: '\x1b[33m!\x1b[0m', fail: '\x1b[31m✗\x1b[0m' }
|
|
199
|
-
: { pass: '✓', warn: '!', fail: '✗' };
|
|
200
|
-
for (const check of checks) {
|
|
201
|
-
console.log(` ${icons[check.status]} ${check.name}: ${check.message}`);
|
|
202
|
-
}
|
|
203
|
-
const fails = checks.filter((c) => c.status === 'fail').length;
|
|
204
|
-
const warns = checks.filter((c) => c.status === 'warn').length;
|
|
205
|
-
console.log(`\n ${checks.length} checks: ${checks.length - fails - warns} passed, ${warns} warnings, ${fails} failures\n`);
|
|
206
|
-
if (fails > 0)
|
|
207
|
-
process.exit(1);
|
|
208
|
-
}
|
package/dist/cli/handoff.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { exportTab, formatHandoffInfo, type TabHandoffInfo } from '../session/handoff.js';
|
|
2
|
-
export { exportTab, formatHandoffInfo, type TabHandoffInfo };
|
|
3
|
-
/**
|
|
4
|
-
* CLI-only flow: print the handoff info, spawn claude with `--resume`, and
|
|
5
|
-
* inherit stdio so the user is dropped into an interactive session. Calls
|
|
6
|
-
* `process.exit` on subprocess exit — only safe from the CLI entry point.
|
|
7
|
-
*/
|
|
8
|
-
export declare function attachTab(tabName: string): void;
|
package/dist/cli/handoff.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { getConfig } from '../config.js';
|
|
3
|
-
import { exportTab, formatHandoffInfo } from '../session/handoff.js';
|
|
4
|
-
// Re-export the daemon-shared helpers so existing CLI callers keep working.
|
|
5
|
-
export { exportTab, formatHandoffInfo };
|
|
6
|
-
/**
|
|
7
|
-
* CLI-only flow: print the handoff info, spawn claude with `--resume`, and
|
|
8
|
-
* inherit stdio so the user is dropped into an interactive session. Calls
|
|
9
|
-
* `process.exit` on subprocess exit — only safe from the CLI entry point.
|
|
10
|
-
*/
|
|
11
|
-
export function attachTab(tabName) {
|
|
12
|
-
const info = exportTab(tabName);
|
|
13
|
-
if (!info) {
|
|
14
|
-
console.error(`Tab "${tabName}" not found.`);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
const config = getConfig();
|
|
18
|
-
const bin = config.claudeCode?.bin || 'claude';
|
|
19
|
-
console.log(`\nAttaching to tab "${info.name}"...`);
|
|
20
|
-
console.log(` Session: ${info.sessionId}`);
|
|
21
|
-
console.log(` Working dir: ${info.workingDir}`);
|
|
22
|
-
console.log(` Status: ${info.status}`);
|
|
23
|
-
console.log('');
|
|
24
|
-
// Spawn Claude Code in the terminal, resuming the session
|
|
25
|
-
const child = spawn(bin, ['--session-id', info.sessionId, '--resume'], {
|
|
26
|
-
cwd: info.workingDir,
|
|
27
|
-
stdio: 'inherit', // Attach to terminal
|
|
28
|
-
env: { ...process.env },
|
|
29
|
-
});
|
|
30
|
-
child.on('exit', (code) => {
|
|
31
|
-
process.exit(code ?? 0);
|
|
32
|
-
});
|
|
33
|
-
}
|
package/dist/cli/helpers.d.ts
DELETED
package/dist/cli/helpers.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { getPidPath } from '../util/paths.js';
|
|
3
|
-
export { timeAgo } from '../util/text.js';
|
|
4
|
-
export function getDaemonPid() {
|
|
5
|
-
const pidPath = getPidPath();
|
|
6
|
-
if (!fs.existsSync(pidPath))
|
|
7
|
-
return null;
|
|
8
|
-
const pid = parseInt(fs.readFileSync(pidPath, 'utf-8').trim(), 10);
|
|
9
|
-
if (isNaN(pid))
|
|
10
|
-
return null;
|
|
11
|
-
// Check if process is actually running
|
|
12
|
-
try {
|
|
13
|
-
process.kill(pid, 0);
|
|
14
|
-
return pid;
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
// Stale PID file
|
|
18
|
-
fs.unlinkSync(pidPath);
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
package/dist/cli/mcp.d.ts
DELETED
package/dist/cli/mcp.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { getMcpConfigPath } from '../util/paths.js';
|
|
3
|
-
function loadMcpConfig() {
|
|
4
|
-
const path = getMcpConfigPath();
|
|
5
|
-
if (fs.existsSync(path)) {
|
|
6
|
-
return JSON.parse(fs.readFileSync(path, 'utf-8'));
|
|
7
|
-
}
|
|
8
|
-
return { mcpServers: {} };
|
|
9
|
-
}
|
|
10
|
-
function saveMcpConfig(config) {
|
|
11
|
-
fs.writeFileSync(getMcpConfigPath(), JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
12
|
-
}
|
|
13
|
-
export function mcpAdd(name, command, args) {
|
|
14
|
-
const config = loadMcpConfig();
|
|
15
|
-
if (config.mcpServers[name]) {
|
|
16
|
-
console.log(`Updating existing MCP server: ${name}`);
|
|
17
|
-
}
|
|
18
|
-
config.mcpServers[name] = { command, args: args.length > 0 ? args : undefined };
|
|
19
|
-
saveMcpConfig(config);
|
|
20
|
-
console.log(`MCP server "${name}" registered.`);
|
|
21
|
-
console.log(` Command: ${command}${args.length ? ' ' + args.join(' ') : ''}`);
|
|
22
|
-
}
|
|
23
|
-
export function mcpRemove(name) {
|
|
24
|
-
const config = loadMcpConfig();
|
|
25
|
-
if (!config.mcpServers[name]) {
|
|
26
|
-
console.log(`MCP server "${name}" not found.`);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
delete config.mcpServers[name];
|
|
30
|
-
saveMcpConfig(config);
|
|
31
|
-
console.log(`MCP server "${name}" removed.`);
|
|
32
|
-
}
|
|
33
|
-
export function mcpList() {
|
|
34
|
-
const config = loadMcpConfig();
|
|
35
|
-
const servers = Object.entries(config.mcpServers);
|
|
36
|
-
if (servers.length === 0) {
|
|
37
|
-
console.log('No MCP servers configured.');
|
|
38
|
-
console.log('Add one: beecork mcp add <name> <command> [args...]');
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
console.log(`\n${servers.length} MCP server(s):\n`);
|
|
42
|
-
for (const [name, server] of servers) {
|
|
43
|
-
const args = server.args ? ' ' + server.args.join(' ') : '';
|
|
44
|
-
console.log(` ${name}: ${server.command}${args}`);
|
|
45
|
-
}
|
|
46
|
-
console.log('');
|
|
47
|
-
}
|
package/dist/cli/media.d.ts
DELETED