@harbinger-ai/harbinger 0.1.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/LICENSE +21 -0
- package/README.md +406 -0
- package/agents/README.md +76 -0
- package/agents/_template/CONFIG.yaml +7 -0
- package/agents/_template/HEARTBEAT.md +59 -0
- package/agents/_template/IDENTITY.md +4 -0
- package/agents/_template/SKILLS.md +1 -0
- package/agents/_template/SOUL.md +25 -0
- package/agents/_template/TOOLS.md +3 -0
- package/agents/binary-reverser/CONFIG.yaml +21 -0
- package/agents/binary-reverser/HEARTBEAT.md +65 -0
- package/agents/binary-reverser/IDENTITY.md +1 -0
- package/agents/binary-reverser/SKILLS.md +1 -0
- package/agents/binary-reverser/SOUL.md +23 -0
- package/agents/binary-reverser/TOOLS.md +99 -0
- package/agents/browser-agent/CONFIG.yaml +20 -0
- package/agents/browser-agent/HEARTBEAT.md +79 -0
- package/agents/browser-agent/IDENTITY.md +5 -0
- package/agents/browser-agent/SKILLS.md +86 -0
- package/agents/browser-agent/SOUL.md +23 -0
- package/agents/browser-agent/TOOLS.md +186 -0
- package/agents/cloud-infiltrator/CONFIG.yaml +22 -0
- package/agents/cloud-infiltrator/HEARTBEAT.md +78 -0
- package/agents/cloud-infiltrator/IDENTITY.md +1 -0
- package/agents/cloud-infiltrator/SKILLS.md +1 -0
- package/agents/cloud-infiltrator/SOUL.md +23 -0
- package/agents/cloud-infiltrator/TOOLS.md +68 -0
- package/agents/coding-assistant/CONFIG.yaml +22 -0
- package/agents/coding-assistant/HEARTBEAT.md +57 -0
- package/agents/coding-assistant/IDENTITY.md +5 -0
- package/agents/coding-assistant/SKILLS.md +69 -0
- package/agents/coding-assistant/SOUL.md +60 -0
- package/agents/coding-assistant/TOOLS.md +168 -0
- package/agents/learning-agent/CONFIG.yaml +21 -0
- package/agents/learning-agent/HEARTBEAT.md +63 -0
- package/agents/learning-agent/IDENTITY.md +5 -0
- package/agents/learning-agent/SKILLS.md +86 -0
- package/agents/learning-agent/SOUL.md +77 -0
- package/agents/learning-agent/TOOLS.md +145 -0
- package/agents/maintainer/CONFIG.yaml +31 -0
- package/agents/maintainer/HEARTBEAT.md +28 -0
- package/agents/maintainer/IDENTITY.md +33 -0
- package/agents/maintainer/SKILLS.md +24 -0
- package/agents/maintainer/SOUL.md +61 -0
- package/agents/maintainer/TOOLS.md +29 -0
- package/agents/maintainer/lib/engine.js +279 -0
- package/agents/maintainer/lib/safe-fixer.js +183 -0
- package/agents/morning-brief/CONFIG.yaml +22 -0
- package/agents/morning-brief/HEARTBEAT.md +60 -0
- package/agents/morning-brief/IDENTITY.md +5 -0
- package/agents/morning-brief/SKILLS.md +56 -0
- package/agents/morning-brief/SOUL.md +64 -0
- package/agents/morning-brief/TOOLS.md +112 -0
- package/agents/osint-detective/CONFIG.yaml +24 -0
- package/agents/osint-detective/HEARTBEAT.md +66 -0
- package/agents/osint-detective/IDENTITY.md +1 -0
- package/agents/osint-detective/SKILLS.md +1 -0
- package/agents/osint-detective/SOUL.md +23 -0
- package/agents/osint-detective/TOOLS.md +81 -0
- package/agents/recon-scout/CONFIG.yaml +22 -0
- package/agents/recon-scout/HEARTBEAT.md +79 -0
- package/agents/recon-scout/IDENTITY.md +1 -0
- package/agents/recon-scout/SKILLS.md +1 -0
- package/agents/recon-scout/SOUL.md +23 -0
- package/agents/recon-scout/TOOLS.md +93 -0
- package/agents/report-writer/CONFIG.yaml +21 -0
- package/agents/report-writer/HEARTBEAT.md +63 -0
- package/agents/report-writer/IDENTITY.md +1 -0
- package/agents/report-writer/SKILLS.md +1 -0
- package/agents/report-writer/SOUL.md +23 -0
- package/agents/report-writer/TOOLS.md +69 -0
- package/agents/shared/README.md +13 -0
- package/agents/web-hacker/CONFIG.yaml +24 -0
- package/agents/web-hacker/HEARTBEAT.md +78 -0
- package/agents/web-hacker/IDENTITY.md +1 -0
- package/agents/web-hacker/SKILLS.md +1 -0
- package/agents/web-hacker/SOUL.md +23 -0
- package/agents/web-hacker/TOOLS.md +86 -0
- package/api/CLAUDE.md +19 -0
- package/api/index.js +274 -0
- package/bin/cli.js +620 -0
- package/bin/local.sh +31 -0
- package/bin/postinstall.js +63 -0
- package/config/index.js +24 -0
- package/config/instrumentation.js +93 -0
- package/drizzle/0000_initial.sql +52 -0
- package/drizzle/0001_bounty_and_registry.sql +82 -0
- package/drizzle/0002_sync_columns.sql +7 -0
- package/drizzle/0003_graceful_bloodscream.sql +86 -0
- package/drizzle/meta/0000_snapshot.json +321 -0
- package/drizzle/meta/0003_snapshot.json +878 -0
- package/drizzle/meta/_journal.json +34 -0
- package/drizzle/relations.ts +3 -0
- package/drizzle/schema.ts +145 -0
- package/lib/actions.js +47 -0
- package/lib/agents.js +166 -0
- package/lib/ai/agent.js +96 -0
- package/lib/ai/autonomous-engine.js +261 -0
- package/lib/ai/index.js +359 -0
- package/lib/ai/model-router.js +254 -0
- package/lib/ai/model.js +73 -0
- package/lib/ai/tools.js +84 -0
- package/lib/auth/actions.js +28 -0
- package/lib/auth/config.js +27 -0
- package/lib/auth/edge-config.js +27 -0
- package/lib/auth/index.js +27 -0
- package/lib/auth/middleware.js +53 -0
- package/lib/bounty/actions.js +119 -0
- package/lib/bounty/findings.js +64 -0
- package/lib/bounty/programs.js +34 -0
- package/lib/bounty/sync-targets.js +267 -0
- package/lib/bounty/targets.js +33 -0
- package/lib/channels/base.js +56 -0
- package/lib/channels/index.js +15 -0
- package/lib/channels/telegram.js +148 -0
- package/lib/chat/actions.js +288 -0
- package/lib/chat/api.js +135 -0
- package/lib/chat/components/app-sidebar.js +237 -0
- package/lib/chat/components/app-sidebar.jsx +289 -0
- package/lib/chat/components/chat-header.js +27 -0
- package/lib/chat/components/chat-header.jsx +37 -0
- package/lib/chat/components/chat-input.js +230 -0
- package/lib/chat/components/chat-input.jsx +228 -0
- package/lib/chat/components/chat-nav-context.js +11 -0
- package/lib/chat/components/chat-nav-context.jsx +11 -0
- package/lib/chat/components/chat-page.js +81 -0
- package/lib/chat/components/chat-page.jsx +100 -0
- package/lib/chat/components/chat.js +150 -0
- package/lib/chat/components/chat.jsx +182 -0
- package/lib/chat/components/chats-page.js +302 -0
- package/lib/chat/components/chats-page.jsx +330 -0
- package/lib/chat/components/crons-page.js +172 -0
- package/lib/chat/components/crons-page.jsx +244 -0
- package/lib/chat/components/enhanced-tool-call.js +103 -0
- package/lib/chat/components/enhanced-tool-call.jsx +139 -0
- package/lib/chat/components/findings-page.js +175 -0
- package/lib/chat/components/findings-page.jsx +214 -0
- package/lib/chat/components/greeting.js +22 -0
- package/lib/chat/components/greeting.jsx +26 -0
- package/lib/chat/components/icons.js +777 -0
- package/lib/chat/components/icons.jsx +741 -0
- package/lib/chat/components/index.js +26 -0
- package/lib/chat/components/mcp-page.js +260 -0
- package/lib/chat/components/mcp-page.jsx +355 -0
- package/lib/chat/components/message.js +289 -0
- package/lib/chat/components/message.jsx +315 -0
- package/lib/chat/components/messages.js +66 -0
- package/lib/chat/components/messages.jsx +77 -0
- package/lib/chat/components/notifications-page.js +56 -0
- package/lib/chat/components/notifications-page.jsx +87 -0
- package/lib/chat/components/page-layout.js +21 -0
- package/lib/chat/components/page-layout.jsx +28 -0
- package/lib/chat/components/registry-page.js +222 -0
- package/lib/chat/components/registry-page.jsx +255 -0
- package/lib/chat/components/settings-layout.js +40 -0
- package/lib/chat/components/settings-layout.jsx +54 -0
- package/lib/chat/components/settings-secrets-page.js +216 -0
- package/lib/chat/components/settings-secrets-page.jsx +264 -0
- package/lib/chat/components/sidebar-history-item.js +132 -0
- package/lib/chat/components/sidebar-history-item.jsx +113 -0
- package/lib/chat/components/sidebar-history.js +115 -0
- package/lib/chat/components/sidebar-history.jsx +157 -0
- package/lib/chat/components/sidebar-user-nav.js +63 -0
- package/lib/chat/components/sidebar-user-nav.jsx +73 -0
- package/lib/chat/components/status-bar.js +39 -0
- package/lib/chat/components/status-bar.jsx +51 -0
- package/lib/chat/components/swarm-page.js +157 -0
- package/lib/chat/components/swarm-page.jsx +210 -0
- package/lib/chat/components/targets-page.js +376 -0
- package/lib/chat/components/targets-page.jsx +389 -0
- package/lib/chat/components/tool-call.js +86 -0
- package/lib/chat/components/tool-call.jsx +104 -0
- package/lib/chat/components/tool-panel.js +107 -0
- package/lib/chat/components/tool-panel.jsx +145 -0
- package/lib/chat/components/triggers-page.js +153 -0
- package/lib/chat/components/triggers-page.jsx +221 -0
- package/lib/chat/components/ui/confirm-dialog.js +53 -0
- package/lib/chat/components/ui/confirm-dialog.jsx +57 -0
- package/lib/chat/components/ui/dropdown-menu.js +98 -0
- package/lib/chat/components/ui/dropdown-menu.jsx +116 -0
- package/lib/chat/components/ui/rename-dialog.js +74 -0
- package/lib/chat/components/ui/rename-dialog.jsx +72 -0
- package/lib/chat/components/ui/scroll-area.js +13 -0
- package/lib/chat/components/ui/scroll-area.jsx +17 -0
- package/lib/chat/components/ui/separator.js +21 -0
- package/lib/chat/components/ui/separator.jsx +18 -0
- package/lib/chat/components/ui/sheet.js +75 -0
- package/lib/chat/components/ui/sheet.jsx +95 -0
- package/lib/chat/components/ui/sidebar.js +227 -0
- package/lib/chat/components/ui/sidebar.jsx +245 -0
- package/lib/chat/components/ui/tooltip.js +56 -0
- package/lib/chat/components/ui/tooltip.jsx +66 -0
- package/lib/chat/components/upgrade-dialog.js +151 -0
- package/lib/chat/components/upgrade-dialog.jsx +170 -0
- package/lib/chat/utils.js +11 -0
- package/lib/cron.js +246 -0
- package/lib/db/api-keys.js +163 -0
- package/lib/db/chats.js +145 -0
- package/lib/db/index.js +52 -0
- package/lib/db/notifications.js +99 -0
- package/lib/db/schema.js +145 -0
- package/lib/db/update-check.js +96 -0
- package/lib/db/users.js +89 -0
- package/lib/mcp/actions.js +104 -0
- package/lib/mcp/client.js +79 -0
- package/lib/mcp/handler.js +57 -0
- package/lib/mcp/server.js +165 -0
- package/lib/paths.js +46 -0
- package/lib/registry/actions.js +164 -0
- package/lib/registry/catalog.js +137 -0
- package/lib/registry/tools.js +71 -0
- package/lib/tools/create-job.js +99 -0
- package/lib/tools/github.js +217 -0
- package/lib/tools/openai.js +35 -0
- package/lib/tools/telegram.js +292 -0
- package/lib/triggers.js +118 -0
- package/lib/utils/render-md.js +102 -0
- package/package.json +103 -0
- package/setup/lib/auth.mjs +81 -0
- package/setup/lib/env.mjs +21 -0
- package/setup/lib/fs-utils.mjs +20 -0
- package/setup/lib/github.mjs +149 -0
- package/setup/lib/prerequisites.mjs +155 -0
- package/setup/lib/prompts.mjs +267 -0
- package/setup/lib/providers.mjs +48 -0
- package/setup/lib/sync.mjs +125 -0
- package/setup/lib/targets.mjs +45 -0
- package/setup/lib/telegram-verify.mjs +63 -0
- package/setup/lib/telegram.mjs +76 -0
- package/setup/setup-telegram.mjs +264 -0
- package/setup/setup.mjs +842 -0
- package/templates/.dockerignore +5 -0
- package/templates/.env.example +63 -0
- package/templates/.github/workflows/auto-merge.yml +117 -0
- package/templates/.github/workflows/build-image.yml +36 -0
- package/templates/.github/workflows/notify-job-failed.yml +64 -0
- package/templates/.github/workflows/notify-pr-complete.yml +119 -0
- package/templates/.github/workflows/rebuild-event-handler.yml +121 -0
- package/templates/.github/workflows/run-job.yml +89 -0
- package/templates/.github/workflows/upgrade-event-handler.yml +62 -0
- package/templates/.gitignore.template +45 -0
- package/templates/.pi/extensions/env-sanitizer/index.ts +48 -0
- package/templates/.pi/extensions/env-sanitizer/package.json +5 -0
- package/templates/CLAUDE.md +29 -0
- package/templates/CLAUDE.md.template +307 -0
- package/templates/app/api/[...thepopebot]/route.js +1 -0
- package/templates/app/api/auth/[...nextauth]/route.js +1 -0
- package/templates/app/chat/[chatId]/page.js +8 -0
- package/templates/app/chats/page.js +7 -0
- package/templates/app/components/ascii-logo.jsx +10 -0
- package/templates/app/components/login-form.jsx +92 -0
- package/templates/app/components/setup-form.jsx +82 -0
- package/templates/app/components/theme-provider.jsx +11 -0
- package/templates/app/components/theme-toggle.jsx +38 -0
- package/templates/app/components/ui/button.jsx +21 -0
- package/templates/app/components/ui/card.jsx +23 -0
- package/templates/app/components/ui/input.jsx +10 -0
- package/templates/app/components/ui/label.jsx +10 -0
- package/templates/app/crons/page.js +5 -0
- package/templates/app/findings/page.js +7 -0
- package/templates/app/globals.css +90 -0
- package/templates/app/layout.js +19 -0
- package/templates/app/login/page.js +15 -0
- package/templates/app/notifications/page.js +7 -0
- package/templates/app/page.js +7 -0
- package/templates/app/settings/crons/page.js +5 -0
- package/templates/app/settings/layout.js +7 -0
- package/templates/app/settings/mcp/page.js +5 -0
- package/templates/app/settings/page.js +5 -0
- package/templates/app/settings/secrets/page.js +5 -0
- package/templates/app/settings/triggers/page.js +5 -0
- package/templates/app/stream/chat/route.js +1 -0
- package/templates/app/swarm/page.js +7 -0
- package/templates/app/targets/page.js +7 -0
- package/templates/app/toolbox/page.js +7 -0
- package/templates/app/triggers/page.js +5 -0
- package/templates/config/AGENT.md +34 -0
- package/templates/config/CRONS.json +56 -0
- package/templates/config/EVENT_HANDLER.md +224 -0
- package/templates/config/HEARTBEAT.md +3 -0
- package/templates/config/JOB_SUMMARY.md +130 -0
- package/templates/config/MCP_SERVERS.json +1 -0
- package/templates/config/SKILL_BUILDING_GUIDE.md +90 -0
- package/templates/config/SOUL.md +17 -0
- package/templates/config/TRIGGERS.json +58 -0
- package/templates/docker/event-handler/Dockerfile +20 -0
- package/templates/docker/event-handler/ecosystem.config.cjs +8 -0
- package/templates/docker/job-claude-code/Dockerfile +34 -0
- package/templates/docker/job-claude-code/entrypoint.sh +139 -0
- package/templates/docker/job-pi-coding-agent/Dockerfile +44 -0
- package/templates/docker/job-pi-coding-agent/entrypoint.sh +163 -0
- package/templates/docker-compose.yml +63 -0
- package/templates/instrumentation.js +6 -0
- package/templates/middleware.js +1 -0
- package/templates/next.config.mjs +3 -0
- package/templates/postcss.config.mjs +5 -0
- package/templates/skills/LICENSE +21 -0
- package/templates/skills/README.md +119 -0
- package/templates/skills/brave-search/SKILL.md +79 -0
- package/templates/skills/brave-search/content.js +86 -0
- package/templates/skills/brave-search/package-lock.json +621 -0
- package/templates/skills/brave-search/package.json +14 -0
- package/templates/skills/brave-search/search.js +199 -0
- package/templates/skills/browser-tools/SKILL.md +196 -0
- package/templates/skills/browser-tools/browser-content.js +103 -0
- package/templates/skills/browser-tools/browser-cookies.js +35 -0
- package/templates/skills/browser-tools/browser-eval.js +53 -0
- package/templates/skills/browser-tools/browser-hn-scraper.js +108 -0
- package/templates/skills/browser-tools/browser-nav.js +44 -0
- package/templates/skills/browser-tools/browser-pick.js +162 -0
- package/templates/skills/browser-tools/browser-screenshot.js +34 -0
- package/templates/skills/browser-tools/browser-start.js +87 -0
- package/templates/skills/browser-tools/package-lock.json +2556 -0
- package/templates/skills/browser-tools/package.json +19 -0
- package/templates/skills/llm-secrets/SKILL.md +34 -0
- package/templates/skills/llm-secrets/llm-secrets.js +33 -0
- package/templates/skills/modify-self/SKILL.md +12 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// postinstall runs from the package dir inside node_modules.
|
|
11
|
+
// The user's project root is two levels up: node_modules/thepopebot/ -> project root
|
|
12
|
+
const projectRoot = path.resolve(__dirname, '..', '..', '..');
|
|
13
|
+
const templatesDir = path.join(__dirname, '..', 'templates');
|
|
14
|
+
|
|
15
|
+
// Skip if templates dir doesn't exist (shouldn't happen, but be safe)
|
|
16
|
+
if (!fs.existsSync(templatesDir)) process.exit(0);
|
|
17
|
+
|
|
18
|
+
// Skip if this doesn't look like a user project (no package.json with thepopebot dep)
|
|
19
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
20
|
+
if (!fs.existsSync(pkgPath)) process.exit(0);
|
|
21
|
+
try {
|
|
22
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
23
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
24
|
+
if (!deps || !deps.thepopebot) process.exit(0);
|
|
25
|
+
} catch { process.exit(0); }
|
|
26
|
+
|
|
27
|
+
function walk(dir) {
|
|
28
|
+
const files = [];
|
|
29
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
const fullPath = path.join(dir, entry.name);
|
|
32
|
+
if (entry.isDirectory()) {
|
|
33
|
+
files.push(...walk(fullPath));
|
|
34
|
+
} else {
|
|
35
|
+
files.push(path.relative(templatesDir, fullPath));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return files;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const changed = [];
|
|
42
|
+
for (const relPath of walk(templatesDir)) {
|
|
43
|
+
const src = path.join(templatesDir, relPath);
|
|
44
|
+
const dest = path.join(projectRoot, relPath);
|
|
45
|
+
if (fs.existsSync(dest)) {
|
|
46
|
+
const srcContent = fs.readFileSync(src);
|
|
47
|
+
const destContent = fs.readFileSync(dest);
|
|
48
|
+
if (!srcContent.equals(destContent)) {
|
|
49
|
+
changed.push(relPath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (changed.length > 0) {
|
|
55
|
+
console.log('\n thepopebot: these project files differ from the latest package templates.');
|
|
56
|
+
console.log(' This is normal if you\'ve customized them. If thepopebot was just');
|
|
57
|
+
console.log(' updated, new defaults may be available.\n');
|
|
58
|
+
for (const file of changed) {
|
|
59
|
+
console.log(` ${file}`);
|
|
60
|
+
}
|
|
61
|
+
console.log('\n To compare: npx thepopebot diff <file>');
|
|
62
|
+
console.log(' To restore: npx thepopebot reset <file>\n');
|
|
63
|
+
}
|
package/config/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js config wrapper for thepopebot.
|
|
3
|
+
* Enables instrumentation hook for cron scheduling on server start.
|
|
4
|
+
*
|
|
5
|
+
* Usage in user's next.config.mjs:
|
|
6
|
+
* import { withThepopebot } from 'thepopebot/config';
|
|
7
|
+
* export default withThepopebot({});
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} nextConfig - User's Next.js config
|
|
10
|
+
* @returns {Object} Enhanced Next.js config
|
|
11
|
+
*/
|
|
12
|
+
export const withHarbinger = withThepopebot;
|
|
13
|
+
|
|
14
|
+
export function withThepopebot(nextConfig = {}) {
|
|
15
|
+
return {
|
|
16
|
+
...nextConfig,
|
|
17
|
+
distDir: process.env.NEXT_BUILD_DIR || '.next',
|
|
18
|
+
serverExternalPackages: [
|
|
19
|
+
...(nextConfig.serverExternalPackages || []),
|
|
20
|
+
'better-sqlite3',
|
|
21
|
+
'drizzle-orm',
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js instrumentation hook for thepopebot.
|
|
3
|
+
* This file is loaded by Next.js on server start when instrumentationHook is enabled.
|
|
4
|
+
*
|
|
5
|
+
* Users should create an instrumentation.js in their project root that imports this:
|
|
6
|
+
*
|
|
7
|
+
* export { register } from 'thepopebot/instrumentation';
|
|
8
|
+
*
|
|
9
|
+
* Or they can re-export and add their own logic.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
let initialized = false;
|
|
13
|
+
|
|
14
|
+
export async function register() {
|
|
15
|
+
// Only run on the server, and only once
|
|
16
|
+
if (typeof window !== 'undefined' || initialized) return;
|
|
17
|
+
initialized = true;
|
|
18
|
+
|
|
19
|
+
// Skip database init and cron scheduling during `next build` —
|
|
20
|
+
// these are runtime-only concerns that keep the event loop alive
|
|
21
|
+
// and can cause build output corruption.
|
|
22
|
+
if (process.argv.includes('build')) return;
|
|
23
|
+
|
|
24
|
+
// Load .env from project root
|
|
25
|
+
const dotenv = await import('dotenv');
|
|
26
|
+
dotenv.config();
|
|
27
|
+
|
|
28
|
+
// Set AUTH_URL from APP_URL so NextAuth redirects to the correct host (e.g., on sign-out)
|
|
29
|
+
if (process.env.APP_URL && !process.env.AUTH_URL) {
|
|
30
|
+
process.env.AUTH_URL = process.env.APP_URL;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Validate AUTH_SECRET is set (required by Auth.js for session encryption)
|
|
34
|
+
if (!process.env.AUTH_SECRET) {
|
|
35
|
+
console.error('\n ERROR: AUTH_SECRET is not set in your .env file.');
|
|
36
|
+
console.error(' This is required for session encryption.');
|
|
37
|
+
console.error(' Run "npm run setup" to generate it automatically, or add manually:');
|
|
38
|
+
console.error(' openssl rand -base64 32\n');
|
|
39
|
+
throw new Error('AUTH_SECRET environment variable is required');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Initialize auth database
|
|
43
|
+
const { initDatabase } = await import('../lib/db/index.js');
|
|
44
|
+
initDatabase();
|
|
45
|
+
|
|
46
|
+
// Discover agent profiles
|
|
47
|
+
const { discoverAgents } = await import('../lib/agents.js');
|
|
48
|
+
const agents = discoverAgents();
|
|
49
|
+
if (agents.length > 0) {
|
|
50
|
+
const names = agents.map(a => a.codename || a.id).join(', ');
|
|
51
|
+
console.log(`thepopebot: ${agents.length} agent profiles loaded (${names})`);
|
|
52
|
+
console.log('thepopebot: use @AGENT_NAME in chat to route to a specific agent');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Optionally start autonomous thinking engine
|
|
56
|
+
if (process.env.AUTONOMOUS_THINKING === 'true') {
|
|
57
|
+
const { startAutonomousEngine } = await import('../lib/ai/autonomous-engine.js');
|
|
58
|
+
startAutonomousEngine({
|
|
59
|
+
agentId: 'thepopebot',
|
|
60
|
+
agentName: 'THEPOPEBOT',
|
|
61
|
+
interval: Number(process.env.AUTONOMOUS_INTERVAL) || 60000,
|
|
62
|
+
});
|
|
63
|
+
console.log('thepopebot: autonomous thinking engine started');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Start cron scheduler
|
|
67
|
+
const { loadCrons } = await import('../lib/cron.js');
|
|
68
|
+
loadCrons();
|
|
69
|
+
|
|
70
|
+
// Start built-in crons (version check)
|
|
71
|
+
const { startBuiltinCrons, setUpdateAvailable } = await import('../lib/cron.js');
|
|
72
|
+
startBuiltinCrons();
|
|
73
|
+
|
|
74
|
+
// Warm in-memory flag from DB (covers the window before the async cron fetch completes)
|
|
75
|
+
try {
|
|
76
|
+
const { getAvailableVersion } = await import('../lib/db/update-check.js');
|
|
77
|
+
const stored = getAvailableVersion();
|
|
78
|
+
if (stored) setUpdateAvailable(stored);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.warn('thepopebot: update check warm-up failed:', err.message);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Pre-warm MCP client (load external tools)
|
|
84
|
+
try {
|
|
85
|
+
const { loadMcpTools } = await import('../lib/mcp/client.js');
|
|
86
|
+
const mcpTools = await loadMcpTools();
|
|
87
|
+
if (mcpTools.length > 0) console.log(`thepopebot: ${mcpTools.length} MCP tools loaded`);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.warn('thepopebot: MCP tools pre-warm failed:', err.message);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log('thepopebot initialized');
|
|
93
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
CREATE TABLE `chats` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`user_id` text NOT NULL,
|
|
4
|
+
`title` text DEFAULT 'New Chat' NOT NULL,
|
|
5
|
+
`starred` integer DEFAULT 0 NOT NULL,
|
|
6
|
+
`created_at` integer NOT NULL,
|
|
7
|
+
`updated_at` integer NOT NULL
|
|
8
|
+
);
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
CREATE TABLE `messages` (
|
|
11
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
12
|
+
`chat_id` text NOT NULL,
|
|
13
|
+
`role` text NOT NULL,
|
|
14
|
+
`content` text NOT NULL,
|
|
15
|
+
`created_at` integer NOT NULL
|
|
16
|
+
);
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
CREATE TABLE `notifications` (
|
|
19
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
20
|
+
`notification` text NOT NULL,
|
|
21
|
+
`payload` text NOT NULL,
|
|
22
|
+
`read` integer DEFAULT 0 NOT NULL,
|
|
23
|
+
`created_at` integer NOT NULL
|
|
24
|
+
);
|
|
25
|
+
--> statement-breakpoint
|
|
26
|
+
CREATE TABLE `settings` (
|
|
27
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
28
|
+
`type` text NOT NULL,
|
|
29
|
+
`key` text NOT NULL,
|
|
30
|
+
`value` text NOT NULL,
|
|
31
|
+
`created_by` text,
|
|
32
|
+
`created_at` integer NOT NULL,
|
|
33
|
+
`updated_at` integer NOT NULL
|
|
34
|
+
);
|
|
35
|
+
--> statement-breakpoint
|
|
36
|
+
CREATE TABLE `subscriptions` (
|
|
37
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
38
|
+
`platform` text NOT NULL,
|
|
39
|
+
`channel_id` text NOT NULL,
|
|
40
|
+
`created_at` integer NOT NULL
|
|
41
|
+
);
|
|
42
|
+
--> statement-breakpoint
|
|
43
|
+
CREATE TABLE `users` (
|
|
44
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
45
|
+
`email` text NOT NULL,
|
|
46
|
+
`password_hash` text NOT NULL,
|
|
47
|
+
`role` text DEFAULT 'admin' NOT NULL,
|
|
48
|
+
`created_at` integer NOT NULL,
|
|
49
|
+
`updated_at` integer NOT NULL
|
|
50
|
+
);
|
|
51
|
+
--> statement-breakpoint
|
|
52
|
+
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
CREATE TABLE `programs` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`name` text NOT NULL,
|
|
4
|
+
`platform` text DEFAULT 'custom' NOT NULL,
|
|
5
|
+
`url` text,
|
|
6
|
+
`scope_url` text,
|
|
7
|
+
`min_bounty` integer,
|
|
8
|
+
`max_bounty` integer,
|
|
9
|
+
`status` text DEFAULT 'active' NOT NULL,
|
|
10
|
+
`notes` text,
|
|
11
|
+
`created_at` integer NOT NULL,
|
|
12
|
+
`updated_at` integer NOT NULL
|
|
13
|
+
);
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
CREATE TABLE `targets` (
|
|
16
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
17
|
+
`program_id` text,
|
|
18
|
+
`type` text DEFAULT 'domain' NOT NULL,
|
|
19
|
+
`value` text NOT NULL,
|
|
20
|
+
`status` text DEFAULT 'in_scope' NOT NULL,
|
|
21
|
+
`technologies` text,
|
|
22
|
+
`notes` text,
|
|
23
|
+
`last_scanned_at` integer,
|
|
24
|
+
`created_at` integer NOT NULL,
|
|
25
|
+
`updated_at` integer NOT NULL
|
|
26
|
+
);
|
|
27
|
+
--> statement-breakpoint
|
|
28
|
+
CREATE TABLE `findings` (
|
|
29
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
30
|
+
`target_id` text,
|
|
31
|
+
`title` text NOT NULL,
|
|
32
|
+
`severity` text DEFAULT 'info' NOT NULL,
|
|
33
|
+
`type` text NOT NULL,
|
|
34
|
+
`status` text DEFAULT 'new' NOT NULL,
|
|
35
|
+
`description` text,
|
|
36
|
+
`steps_to_reproduce` text,
|
|
37
|
+
`impact` text,
|
|
38
|
+
`evidence` text,
|
|
39
|
+
`bounty_amount` integer,
|
|
40
|
+
`report_url` text,
|
|
41
|
+
`agent_id` text,
|
|
42
|
+
`tool_id` text,
|
|
43
|
+
`raw_output` text,
|
|
44
|
+
`reported_at` integer,
|
|
45
|
+
`created_at` integer NOT NULL,
|
|
46
|
+
`updated_at` integer NOT NULL
|
|
47
|
+
);
|
|
48
|
+
--> statement-breakpoint
|
|
49
|
+
CREATE TABLE `tools` (
|
|
50
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
51
|
+
`catalog_id` text,
|
|
52
|
+
`name` text NOT NULL,
|
|
53
|
+
`slug` text NOT NULL,
|
|
54
|
+
`category` text NOT NULL,
|
|
55
|
+
`description` text,
|
|
56
|
+
`docker_image` text,
|
|
57
|
+
`install_cmd` text,
|
|
58
|
+
`source_url` text,
|
|
59
|
+
`version` text,
|
|
60
|
+
`installed` integer DEFAULT 0 NOT NULL,
|
|
61
|
+
`enabled` integer DEFAULT 1 NOT NULL,
|
|
62
|
+
`config` text,
|
|
63
|
+
`mcp_server_id` text,
|
|
64
|
+
`created_at` integer NOT NULL,
|
|
65
|
+
`updated_at` integer NOT NULL
|
|
66
|
+
);
|
|
67
|
+
--> statement-breakpoint
|
|
68
|
+
CREATE UNIQUE INDEX `tools_slug_unique` ON `tools` (`slug`);
|
|
69
|
+
--> statement-breakpoint
|
|
70
|
+
CREATE TABLE `docker_containers` (
|
|
71
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
72
|
+
`tool_id` text,
|
|
73
|
+
`container_id` text,
|
|
74
|
+
`image_name` text NOT NULL,
|
|
75
|
+
`status` text DEFAULT 'created' NOT NULL,
|
|
76
|
+
`agent_id` text,
|
|
77
|
+
`ports` text,
|
|
78
|
+
`env` text,
|
|
79
|
+
`logs` text,
|
|
80
|
+
`created_at` integer NOT NULL,
|
|
81
|
+
`stopped_at` integer
|
|
82
|
+
);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ALTER TABLE `programs` ADD `sync_handle` text;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE `programs` ADD `last_synced_at` integer;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE `targets` ADD `sync_source` text;
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
ALTER TABLE `targets` ADD `sync_program_handle` text;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
CREATE TABLE `docker_containers` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`tool_id` text,
|
|
4
|
+
`container_id` text,
|
|
5
|
+
`image_name` text NOT NULL,
|
|
6
|
+
`status` text DEFAULT 'created' NOT NULL,
|
|
7
|
+
`agent_id` text,
|
|
8
|
+
`ports` text,
|
|
9
|
+
`env` text,
|
|
10
|
+
`logs` text,
|
|
11
|
+
`created_at` integer NOT NULL,
|
|
12
|
+
`stopped_at` integer
|
|
13
|
+
);
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
CREATE TABLE `findings` (
|
|
16
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
17
|
+
`target_id` text,
|
|
18
|
+
`title` text NOT NULL,
|
|
19
|
+
`severity` text DEFAULT 'info' NOT NULL,
|
|
20
|
+
`type` text NOT NULL,
|
|
21
|
+
`status` text DEFAULT 'new' NOT NULL,
|
|
22
|
+
`description` text,
|
|
23
|
+
`steps_to_reproduce` text,
|
|
24
|
+
`impact` text,
|
|
25
|
+
`evidence` text,
|
|
26
|
+
`bounty_amount` integer,
|
|
27
|
+
`report_url` text,
|
|
28
|
+
`agent_id` text,
|
|
29
|
+
`tool_id` text,
|
|
30
|
+
`raw_output` text,
|
|
31
|
+
`reported_at` integer,
|
|
32
|
+
`created_at` integer NOT NULL,
|
|
33
|
+
`updated_at` integer NOT NULL
|
|
34
|
+
);
|
|
35
|
+
--> statement-breakpoint
|
|
36
|
+
CREATE TABLE `programs` (
|
|
37
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
38
|
+
`name` text NOT NULL,
|
|
39
|
+
`platform` text DEFAULT 'custom' NOT NULL,
|
|
40
|
+
`url` text,
|
|
41
|
+
`scope_url` text,
|
|
42
|
+
`min_bounty` integer,
|
|
43
|
+
`max_bounty` integer,
|
|
44
|
+
`status` text DEFAULT 'active' NOT NULL,
|
|
45
|
+
`notes` text,
|
|
46
|
+
`sync_handle` text,
|
|
47
|
+
`last_synced_at` integer,
|
|
48
|
+
`created_at` integer NOT NULL,
|
|
49
|
+
`updated_at` integer NOT NULL
|
|
50
|
+
);
|
|
51
|
+
--> statement-breakpoint
|
|
52
|
+
CREATE TABLE `targets` (
|
|
53
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
54
|
+
`program_id` text,
|
|
55
|
+
`type` text DEFAULT 'domain' NOT NULL,
|
|
56
|
+
`value` text NOT NULL,
|
|
57
|
+
`status` text DEFAULT 'in_scope' NOT NULL,
|
|
58
|
+
`technologies` text,
|
|
59
|
+
`notes` text,
|
|
60
|
+
`last_scanned_at` integer,
|
|
61
|
+
`sync_source` text,
|
|
62
|
+
`sync_program_handle` text,
|
|
63
|
+
`created_at` integer NOT NULL,
|
|
64
|
+
`updated_at` integer NOT NULL
|
|
65
|
+
);
|
|
66
|
+
--> statement-breakpoint
|
|
67
|
+
CREATE TABLE `tools` (
|
|
68
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
69
|
+
`catalog_id` text,
|
|
70
|
+
`name` text NOT NULL,
|
|
71
|
+
`slug` text NOT NULL,
|
|
72
|
+
`category` text NOT NULL,
|
|
73
|
+
`description` text,
|
|
74
|
+
`docker_image` text,
|
|
75
|
+
`install_cmd` text,
|
|
76
|
+
`source_url` text,
|
|
77
|
+
`version` text,
|
|
78
|
+
`installed` integer DEFAULT 0 NOT NULL,
|
|
79
|
+
`enabled` integer DEFAULT 1 NOT NULL,
|
|
80
|
+
`config` text,
|
|
81
|
+
`mcp_server_id` text,
|
|
82
|
+
`created_at` integer NOT NULL,
|
|
83
|
+
`updated_at` integer NOT NULL
|
|
84
|
+
);
|
|
85
|
+
--> statement-breakpoint
|
|
86
|
+
CREATE UNIQUE INDEX `tools_slug_unique` ON `tools` (`slug`);
|