thepopebot 1.2.76-beta.26 → 1.2.76-beta.28
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/api/index.js +4 -12
- package/config/instrumentation.js +29 -1
- package/lib/chat/components/chat-input.js +35 -4
- package/lib/chat/components/chat-input.jsx +30 -2
- package/lib/chat/components/chat.js +50 -89
- package/lib/chat/components/chat.jsx +6 -47
- package/lib/chat/components/index.js +1 -1
- package/lib/chat/components/settings-jobs-page.js +17 -3
- package/lib/chat/components/settings-jobs-page.jsx +23 -7
- package/lib/chat/components/settings-shared.js +2 -2
- package/lib/chat/components/settings-shared.jsx +2 -2
- package/lib/code/code-page.js +1 -1
- package/lib/code/code-page.jsx +3 -1
- package/lib/cron.js +32 -4
- package/lib/triggers.js +38 -1
- package/package.json +1 -1
- package/templates/.github/workflows/rebuild-event-handler.yml +0 -5
package/api/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { dispatchCommand, dispatchPreAuthCommand } from '../lib/channels/command
|
|
|
7
7
|
import { getByChannelChatId, setActiveThread } from '../lib/db/user-channels.js';
|
|
8
8
|
import { chat, chatStream, summarizeAgentJob } from '../lib/ai/index.js';
|
|
9
9
|
import { createNotification } from '../lib/db/notifications.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getFireTriggers } from '../lib/triggers.js';
|
|
11
11
|
import { verifyApiKey } from '../lib/db/api-keys.js';
|
|
12
12
|
import { getConfig } from '../lib/config.js';
|
|
13
13
|
import { parseOAuthState, exchangeCodeForToken } from '../lib/oauth/helper.js';
|
|
@@ -19,8 +19,6 @@ const _refreshLocks = new Map();
|
|
|
19
19
|
// Bot token — resolved from DB/env, can be overridden by /telegram/register
|
|
20
20
|
let telegramBotToken = null;
|
|
21
21
|
|
|
22
|
-
// Cached trigger firing function (initialized on first request)
|
|
23
|
-
let _fireTriggers = null;
|
|
24
22
|
|
|
25
23
|
function getTelegramBotToken() {
|
|
26
24
|
if (!telegramBotToken) {
|
|
@@ -29,13 +27,6 @@ function getTelegramBotToken() {
|
|
|
29
27
|
return telegramBotToken;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
function getFireTriggers() {
|
|
33
|
-
if (!_fireTriggers) {
|
|
34
|
-
const result = loadTriggers();
|
|
35
|
-
_fireTriggers = result.fireTriggers;
|
|
36
|
-
}
|
|
37
|
-
return _fireTriggers;
|
|
38
|
-
}
|
|
39
30
|
|
|
40
31
|
// Routes that have their own authentication
|
|
41
32
|
const PUBLIC_ROUTES = ['/telegram/webhook', '/github/webhook', '/ping', '/oauth/callback'];
|
|
@@ -116,8 +107,9 @@ async function handleGetAgentSecret(request) {
|
|
|
116
107
|
return Response.json({ error: 'Forbidden' }, { status: 403 });
|
|
117
108
|
}
|
|
118
109
|
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
110
|
+
const rawKey = new URL(request.url).searchParams.get('key');
|
|
111
|
+
if (!rawKey) return Response.json({ error: 'Missing key' }, { status: 400 });
|
|
112
|
+
const key = rawKey.toUpperCase();
|
|
121
113
|
|
|
122
114
|
const { getAgentJobSecretRaw, setAgentJobSecret: saveSecret } = await import('../lib/db/config.js');
|
|
123
115
|
const raw = getAgentJobSecretRaw(key);
|
|
@@ -52,7 +52,7 @@ export async function register() {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// Start cron scheduler
|
|
55
|
-
const { loadCrons } = await import('../lib/cron.js');
|
|
55
|
+
const { loadCrons, reloadCrons } = await import('../lib/cron.js');
|
|
56
56
|
loadCrons();
|
|
57
57
|
|
|
58
58
|
// Start built-in crons (version check)
|
|
@@ -74,5 +74,33 @@ export async function register() {
|
|
|
74
74
|
const { startMaintenanceCron } = await import('../lib/maintenance.js');
|
|
75
75
|
startMaintenanceCron();
|
|
76
76
|
|
|
77
|
+
// Watch config files for hot reload (avoids full pm2 restart on git pull)
|
|
78
|
+
const { reloadTriggers } = await import('../lib/triggers.js');
|
|
79
|
+
const { default: chokidar } = await import('chokidar');
|
|
80
|
+
const { PROJECT_ROOT } = await import('../lib/paths.js');
|
|
81
|
+
const path = await import('path');
|
|
82
|
+
|
|
83
|
+
const cronsPath = path.join(PROJECT_ROOT, 'agent-job/CRONS.json');
|
|
84
|
+
const triggersPath = path.join(PROJECT_ROOT, 'event-handler/TRIGGERS.json');
|
|
85
|
+
|
|
86
|
+
const watcher = chokidar.watch([cronsPath, triggersPath], {
|
|
87
|
+
ignoreInitial: true,
|
|
88
|
+
awaitWriteFinish: { stabilityThreshold: 500 },
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
watcher.on('change', (filePath) => {
|
|
92
|
+
if (filePath.endsWith('CRONS.json')) {
|
|
93
|
+
console.log('[config watch] CRONS.json changed, reloading...');
|
|
94
|
+
reloadCrons();
|
|
95
|
+
} else if (filePath.endsWith('TRIGGERS.json')) {
|
|
96
|
+
console.log('[config watch] TRIGGERS.json changed, reloading...');
|
|
97
|
+
reloadTriggers();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
watcher.on('error', (err) => {
|
|
102
|
+
console.error('[config watch] Watcher error:', err.message);
|
|
103
|
+
});
|
|
104
|
+
|
|
77
105
|
console.log('thepopebot initialized');
|
|
78
106
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useRef, useEffect, useCallback, useState } from "react";
|
|
4
|
-
import { SendIcon, StopIcon, PaperclipIcon, XIcon, FileTextIcon, MicIcon } from "./icons.js";
|
|
4
|
+
import { SendIcon, StopIcon, PaperclipIcon, XIcon, FileTextIcon, MicIcon, KeyIcon } from "./icons.js";
|
|
5
5
|
import { useVoiceInput } from "../../voice/use-voice-input.js";
|
|
6
6
|
const getVoiceTokenFetch = () => fetch("/chat/voice-token").then((r) => r.json()).catch(() => ({ error: "Failed to get voice token" }));
|
|
7
7
|
import { VoiceBars } from "./voice-bars.jsx";
|
|
8
|
+
import { Dialog } from "./settings-shared.js";
|
|
9
|
+
import { JobSecretsManager } from "./settings-jobs-page.js";
|
|
8
10
|
import { cn } from "../utils.js";
|
|
9
11
|
const ACCEPTED_TYPES = [
|
|
10
12
|
"image/jpeg",
|
|
@@ -67,6 +69,7 @@ function ChatInput({ input, setInput, onSubmit, status, stop, files, setFiles, d
|
|
|
67
69
|
const [modeDropdownOpen, setModeDropdownOpen] = useState(false);
|
|
68
70
|
const [agentPickerOpen, setAgentPickerOpen] = useState(false);
|
|
69
71
|
const [partialText, setPartialText] = useState("");
|
|
72
|
+
const [secretsOpen, setSecretsOpen] = useState(false);
|
|
70
73
|
const dropdownRef = useRef(null);
|
|
71
74
|
const agentPickerRef = useRef(null);
|
|
72
75
|
const isStreaming = status === "streaming" || status === "submitted";
|
|
@@ -301,6 +304,18 @@ function ChatInput({ input, setInput, onSubmit, status, stop, files, setFiles, d
|
|
|
301
304
|
)
|
|
302
305
|
] })
|
|
303
306
|
] }),
|
|
307
|
+
!codeMode && /* @__PURE__ */ jsx(
|
|
308
|
+
"button",
|
|
309
|
+
{
|
|
310
|
+
type: "button",
|
|
311
|
+
onClick: () => setSecretsOpen(true),
|
|
312
|
+
className: "inline-flex items-center justify-center rounded-lg p-2.5 text-muted-foreground hover:text-foreground",
|
|
313
|
+
"aria-label": "Manage agent job secrets",
|
|
314
|
+
title: "Manage agent job secrets",
|
|
315
|
+
disabled: isStreaming,
|
|
316
|
+
children: /* @__PURE__ */ jsx(KeyIcon, { size: 16 })
|
|
317
|
+
}
|
|
318
|
+
),
|
|
304
319
|
codeModeSettings && !codeModeSettings.isInteractiveActive && /* @__PURE__ */ jsxs("div", { className: "relative", ref: agentPickerRef, children: [
|
|
305
320
|
agentPickerOpen && codeModeSettings.availableAgents?.length > 1 && /* @__PURE__ */ jsxs("div", { className: "absolute bottom-full left-0 mb-1.5 z-50 min-w-[140px] rounded-md border border-border bg-background shadow-md py-1 overflow-hidden", children: [
|
|
306
321
|
/* @__PURE__ */ jsx("p", { className: "px-3 pt-0.5 pb-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wide", children: "Launch with" }),
|
|
@@ -417,8 +432,24 @@ function ChatInput({ input, setInput, onSubmit, status, stop, files, setFiles, d
|
|
|
417
432
|
]
|
|
418
433
|
}
|
|
419
434
|
) });
|
|
420
|
-
|
|
421
|
-
|
|
435
|
+
const secretsDialog = !codeMode ? /* @__PURE__ */ jsx(
|
|
436
|
+
Dialog,
|
|
437
|
+
{
|
|
438
|
+
open: secretsOpen,
|
|
439
|
+
onClose: () => setSecretsOpen(false),
|
|
440
|
+
title: "Agent Job Secrets",
|
|
441
|
+
maxWidth: "max-w-2xl",
|
|
442
|
+
children: /* @__PURE__ */ jsx(JobSecretsManager, { showHeader: false })
|
|
443
|
+
}
|
|
444
|
+
) : null;
|
|
445
|
+
if (bare) return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
446
|
+
formContent,
|
|
447
|
+
secretsDialog
|
|
448
|
+
] });
|
|
449
|
+
return /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-4xl px-1.5 pb-[max(1rem,var(--safe-area-bottom))] md:px-6", children: [
|
|
450
|
+
formContent,
|
|
451
|
+
secretsDialog
|
|
452
|
+
] });
|
|
422
453
|
}
|
|
423
454
|
export {
|
|
424
455
|
ChatInput
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useRef, useEffect, useCallback, useState } from 'react';
|
|
4
|
-
import { SendIcon, StopIcon, PaperclipIcon, XIcon, FileTextIcon, MicIcon } from './icons.js';
|
|
4
|
+
import { SendIcon, StopIcon, PaperclipIcon, XIcon, FileTextIcon, MicIcon, KeyIcon } from './icons.js';
|
|
5
5
|
import { useVoiceInput } from '../../voice/use-voice-input.js';
|
|
6
6
|
const getVoiceTokenFetch = () =>
|
|
7
7
|
fetch('/chat/voice-token').then(r => r.json()).catch(() => ({ error: 'Failed to get voice token' }));
|
|
8
8
|
import { VoiceBars } from './voice-bars.jsx';
|
|
9
|
+
import { Dialog } from './settings-shared.js';
|
|
10
|
+
import { JobSecretsManager } from './settings-jobs-page.js';
|
|
9
11
|
import { cn } from '../utils.js';
|
|
10
12
|
|
|
11
13
|
const ACCEPTED_TYPES = [
|
|
@@ -48,6 +50,7 @@ export function ChatInput({ input, setInput, onSubmit, status, stop, files, setF
|
|
|
48
50
|
const [modeDropdownOpen, setModeDropdownOpen] = useState(false);
|
|
49
51
|
const [agentPickerOpen, setAgentPickerOpen] = useState(false);
|
|
50
52
|
const [partialText, setPartialText] = useState('');
|
|
53
|
+
const [secretsOpen, setSecretsOpen] = useState(false);
|
|
51
54
|
const dropdownRef = useRef(null);
|
|
52
55
|
const agentPickerRef = useRef(null);
|
|
53
56
|
const isStreaming = status === 'streaming' || status === 'submitted';
|
|
@@ -311,6 +314,19 @@ export function ChatInput({ input, setInput, onSubmit, status, stop, files, setF
|
|
|
311
314
|
</div>
|
|
312
315
|
)}
|
|
313
316
|
|
|
317
|
+
{!codeMode && (
|
|
318
|
+
<button
|
|
319
|
+
type="button"
|
|
320
|
+
onClick={() => setSecretsOpen(true)}
|
|
321
|
+
className="inline-flex items-center justify-center rounded-lg p-2.5 text-muted-foreground hover:text-foreground"
|
|
322
|
+
aria-label="Manage agent job secrets"
|
|
323
|
+
title="Manage agent job secrets"
|
|
324
|
+
disabled={isStreaming}
|
|
325
|
+
>
|
|
326
|
+
<KeyIcon size={16} />
|
|
327
|
+
</button>
|
|
328
|
+
)}
|
|
329
|
+
|
|
314
330
|
{/* Interactive toggle — left-click to launch with default agent,
|
|
315
331
|
right-click to pick a specific agent (when multiple are available) */}
|
|
316
332
|
{codeModeSettings && !codeModeSettings.isInteractiveActive && (
|
|
@@ -433,10 +449,22 @@ export function ChatInput({ input, setInput, onSubmit, status, stop, files, setF
|
|
|
433
449
|
</form>
|
|
434
450
|
);
|
|
435
451
|
|
|
436
|
-
|
|
452
|
+
const secretsDialog = !codeMode ? (
|
|
453
|
+
<Dialog
|
|
454
|
+
open={secretsOpen}
|
|
455
|
+
onClose={() => setSecretsOpen(false)}
|
|
456
|
+
title="Agent Job Secrets"
|
|
457
|
+
maxWidth="max-w-2xl"
|
|
458
|
+
>
|
|
459
|
+
<JobSecretsManager showHeader={false} />
|
|
460
|
+
</Dialog>
|
|
461
|
+
) : null;
|
|
462
|
+
|
|
463
|
+
if (bare) return <>{formContent}{secretsDialog}</>;
|
|
437
464
|
return (
|
|
438
465
|
<div className="mx-auto w-full max-w-4xl px-1.5 pb-[max(1rem,var(--safe-area-bottom))] md:px-6">
|
|
439
466
|
{formContent}
|
|
467
|
+
{secretsDialog}
|
|
440
468
|
</div>
|
|
441
469
|
);
|
|
442
470
|
}
|
|
@@ -344,100 +344,61 @@ function Chat({ chatId, initialMessages = [], workspace = null, chatMode = null
|
|
|
344
344
|
}
|
|
345
345
|
) })
|
|
346
346
|
] })
|
|
347
|
-
] }) }) : /* @__PURE__ */
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
347
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col min-h-0 overflow-hidden", children: showDiff && workspaceState?.id ? /* @__PURE__ */ jsx(
|
|
348
|
+
DiffViewer,
|
|
349
|
+
{
|
|
350
|
+
workspaceId: workspaceState.id,
|
|
351
|
+
diffStats,
|
|
352
|
+
onClose: () => setShowDiff(false)
|
|
353
|
+
}
|
|
354
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
355
|
+
/* @__PURE__ */ jsx(Messages, { messages, status, onRetry: handleRetry, onEdit: handleEdit }),
|
|
356
|
+
error && /* @__PURE__ */ jsx("div", { className: "mx-auto w-full max-w-4xl px-2 md:px-4", children: /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-2 text-sm text-destructive", children: error.message || "Something went wrong. Please try again." }) }),
|
|
357
|
+
/* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-4xl px-4 pb-4 md:px-6", children: [
|
|
358
|
+
isInteractiveActive && /* @__PURE__ */ jsxs(
|
|
359
|
+
"a",
|
|
360
|
+
{
|
|
361
|
+
href: `/code/${workspaceState?.id}`,
|
|
362
|
+
className: "flex items-center justify-center gap-2 rounded-xl border border-primary/20 bg-primary/5 px-4 py-3 mb-2 text-sm font-medium text-primary hover:bg-primary/10 transition-colors",
|
|
363
|
+
children: [
|
|
364
|
+
/* @__PURE__ */ jsx("span", { className: "h-2 w-2 rounded-full bg-green-500 animate-pulse" }),
|
|
365
|
+
"Click here to access Interactive Mode"
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
workspaceState && /* @__PURE__ */ jsx("div", { className: "rounded-t-xl border border-b-0 border-border px-3 py-2.5", children: /* @__PURE__ */ jsx(
|
|
370
|
+
WorkspaceBar,
|
|
352
371
|
{
|
|
353
|
-
|
|
372
|
+
repo,
|
|
373
|
+
branch,
|
|
374
|
+
onBranchChange: handleBranchChange,
|
|
375
|
+
getBranches: fetchBranches,
|
|
376
|
+
workspace: workspaceState,
|
|
354
377
|
diffStats,
|
|
355
|
-
|
|
378
|
+
onDiffStatsRefresh: handleDiffStatsRefresh,
|
|
379
|
+
onShowDiff: () => setShowDiff(true)
|
|
356
380
|
}
|
|
357
381
|
) }),
|
|
358
|
-
/* @__PURE__ */ jsx(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
bare: true,
|
|
377
|
-
input,
|
|
378
|
-
setInput,
|
|
379
|
-
onSubmit: handleSend,
|
|
380
|
-
status,
|
|
381
|
-
stop,
|
|
382
|
-
files,
|
|
383
|
-
setFiles,
|
|
384
|
-
disabled: isInteractiveActive,
|
|
385
|
-
placeholder: isInteractiveActive ? "Interactive mode is active." : defaultPlaceholder,
|
|
386
|
-
className: workspaceState ? "rounded-t-none" : void 0,
|
|
387
|
-
codeMode,
|
|
388
|
-
codeModeSettings
|
|
389
|
-
}
|
|
390
|
-
)
|
|
391
|
-
] }) })
|
|
392
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
393
|
-
/* @__PURE__ */ jsx(Messages, { messages, status, onRetry: handleRetry, onEdit: handleEdit }),
|
|
394
|
-
error && /* @__PURE__ */ jsx("div", { className: "mx-auto w-full max-w-4xl px-2 md:px-4", children: /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-2 text-sm text-destructive", children: error.message || "Something went wrong. Please try again." }) }),
|
|
395
|
-
/* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-4xl px-4 pb-4 md:px-6", children: [
|
|
396
|
-
isInteractiveActive && /* @__PURE__ */ jsxs(
|
|
397
|
-
"a",
|
|
398
|
-
{
|
|
399
|
-
href: `/code/${workspaceState?.id}`,
|
|
400
|
-
className: "flex items-center justify-center gap-2 rounded-xl border border-primary/20 bg-primary/5 px-4 py-3 mb-2 text-sm font-medium text-primary hover:bg-primary/10 transition-colors",
|
|
401
|
-
children: [
|
|
402
|
-
/* @__PURE__ */ jsx("span", { className: "h-2 w-2 rounded-full bg-green-500 animate-pulse" }),
|
|
403
|
-
"Click here to access Interactive Mode"
|
|
404
|
-
]
|
|
405
|
-
}
|
|
406
|
-
),
|
|
407
|
-
workspaceState && /* @__PURE__ */ jsx("div", { className: "rounded-t-xl border border-b-0 border-border px-3 py-2.5", children: /* @__PURE__ */ jsx(
|
|
408
|
-
WorkspaceBar,
|
|
409
|
-
{
|
|
410
|
-
repo,
|
|
411
|
-
branch,
|
|
412
|
-
onBranchChange: handleBranchChange,
|
|
413
|
-
getBranches: fetchBranches,
|
|
414
|
-
workspace: workspaceState,
|
|
415
|
-
diffStats,
|
|
416
|
-
onDiffStatsRefresh: handleDiffStatsRefresh,
|
|
417
|
-
onShowDiff: () => setShowDiff(true)
|
|
418
|
-
}
|
|
419
|
-
) }),
|
|
420
|
-
/* @__PURE__ */ jsx(
|
|
421
|
-
ChatInput,
|
|
422
|
-
{
|
|
423
|
-
bare: true,
|
|
424
|
-
input,
|
|
425
|
-
setInput,
|
|
426
|
-
onSubmit: handleSend,
|
|
427
|
-
status,
|
|
428
|
-
stop,
|
|
429
|
-
files,
|
|
430
|
-
setFiles,
|
|
431
|
-
disabled: isInteractiveActive,
|
|
432
|
-
placeholder: isInteractiveActive ? "Interactive mode is active." : defaultPlaceholder,
|
|
433
|
-
className: workspaceState ? "rounded-t-none" : void 0,
|
|
434
|
-
codeMode,
|
|
435
|
-
codeModeSettings
|
|
436
|
-
}
|
|
437
|
-
)
|
|
438
|
-
] })
|
|
382
|
+
/* @__PURE__ */ jsx(
|
|
383
|
+
ChatInput,
|
|
384
|
+
{
|
|
385
|
+
bare: true,
|
|
386
|
+
input,
|
|
387
|
+
setInput,
|
|
388
|
+
onSubmit: handleSend,
|
|
389
|
+
status,
|
|
390
|
+
stop,
|
|
391
|
+
files,
|
|
392
|
+
setFiles,
|
|
393
|
+
disabled: isInteractiveActive,
|
|
394
|
+
placeholder: isInteractiveActive ? "Interactive mode is active." : defaultPlaceholder,
|
|
395
|
+
className: workspaceState ? "rounded-t-none" : void 0,
|
|
396
|
+
codeMode,
|
|
397
|
+
codeModeSettings
|
|
398
|
+
}
|
|
399
|
+
)
|
|
439
400
|
] })
|
|
440
|
-
] })
|
|
401
|
+
] }) })
|
|
441
402
|
] });
|
|
442
403
|
}
|
|
443
404
|
export {
|
|
@@ -409,54 +409,13 @@ export function Chat({ chatId, initialMessages = [], workspace = null, chatMode
|
|
|
409
409
|
</div>
|
|
410
410
|
</div>
|
|
411
411
|
) : (
|
|
412
|
-
<div className="flex flex-1 flex-col min-h-0 overflow-hidden
|
|
413
|
-
{showDiff && workspaceState?.id && (
|
|
414
|
-
<div className="absolute inset-0 z-10 bg-black/50" />
|
|
415
|
-
)}
|
|
412
|
+
<div className="flex flex-1 flex-col min-h-0 overflow-hidden">
|
|
416
413
|
{showDiff && workspaceState?.id ? (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
onClose={() => setShowDiff(false)}
|
|
423
|
-
/>
|
|
424
|
-
</div>
|
|
425
|
-
<div className="z-20 px-4 pb-4">
|
|
426
|
-
<div className="mx-auto w-full max-w-4xl">
|
|
427
|
-
{workspaceState && (
|
|
428
|
-
<div className="rounded-t-xl border border-b-0 border-border px-3 py-2.5 bg-background">
|
|
429
|
-
<WorkspaceBar
|
|
430
|
-
repo={repo}
|
|
431
|
-
branch={branch}
|
|
432
|
-
onBranchChange={handleBranchChange}
|
|
433
|
-
getBranches={fetchBranches}
|
|
434
|
-
workspace={workspaceState}
|
|
435
|
-
diffStats={diffStats}
|
|
436
|
-
onDiffStatsRefresh={handleDiffStatsRefresh}
|
|
437
|
-
onShowDiff={() => setShowDiff(true)}
|
|
438
|
-
chatMode={codeMode ? 'code' : 'agent'}
|
|
439
|
-
/>
|
|
440
|
-
</div>
|
|
441
|
-
)}
|
|
442
|
-
<ChatInput
|
|
443
|
-
bare
|
|
444
|
-
input={input}
|
|
445
|
-
setInput={setInput}
|
|
446
|
-
onSubmit={handleSend}
|
|
447
|
-
status={status}
|
|
448
|
-
stop={stop}
|
|
449
|
-
files={files}
|
|
450
|
-
setFiles={setFiles}
|
|
451
|
-
disabled={isInteractiveActive}
|
|
452
|
-
placeholder={isInteractiveActive ? 'Interactive mode is active.' : defaultPlaceholder}
|
|
453
|
-
className={workspaceState ? "rounded-t-none" : undefined}
|
|
454
|
-
codeMode={codeMode}
|
|
455
|
-
codeModeSettings={codeModeSettings}
|
|
456
|
-
/>
|
|
457
|
-
</div>
|
|
458
|
-
</div>
|
|
459
|
-
</>
|
|
414
|
+
<DiffViewer
|
|
415
|
+
workspaceId={workspaceState.id}
|
|
416
|
+
diffStats={diffStats}
|
|
417
|
+
onClose={() => setShowDiff(false)}
|
|
418
|
+
/>
|
|
460
419
|
) : (
|
|
461
420
|
<>
|
|
462
421
|
<Messages messages={messages} status={status} onRetry={handleRetry} onEdit={handleEdit} />
|
|
@@ -13,7 +13,7 @@ export { SettingsUsersPage } from './settings-users-page.js';
|
|
|
13
13
|
export { HelperLlmPage, ChatConfigPage, ChatProvidersPage, SettingsChatPage } from './settings-chat-page.js';
|
|
14
14
|
export { ChatProvidersPage as LlmsPage } from './settings-chat-page.js';
|
|
15
15
|
export { CodingAgentsPage } from './settings-coding-agents-page.js';
|
|
16
|
-
export { JobsPage } from './settings-jobs-page.js';
|
|
16
|
+
export { JobsPage, JobSecretsManager } from './settings-jobs-page.js';
|
|
17
17
|
export { GitHubTokensPage, GitHubSecretsPage, GitHubVariablesPage, SettingsGitHubPage } from './settings-github-page.js';
|
|
18
18
|
export { SettingsGeneralPage } from './settings-general-page.js';
|
|
19
19
|
export { ProfileLayout, ProfileLoginPage, ProfileTelegramPage } from './profile-page.js';
|
|
@@ -489,7 +489,7 @@ function OAuthSecretRow({ secret, onReauthorize, onDelete }) {
|
|
|
489
489
|
] })
|
|
490
490
|
] });
|
|
491
491
|
}
|
|
492
|
-
function
|
|
492
|
+
function JobSecretsManager({ showHeader = true }) {
|
|
493
493
|
const [secrets, setSecrets] = useState([]);
|
|
494
494
|
const [loading, setLoading] = useState(true);
|
|
495
495
|
const [showAdd, setShowAdd] = useState(false);
|
|
@@ -526,7 +526,7 @@ function JobsPage() {
|
|
|
526
526
|
return /* @__PURE__ */ jsx("div", { className: "h-48 animate-pulse rounded-md bg-border/50" });
|
|
527
527
|
}
|
|
528
528
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
529
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3 mb-4", children: [
|
|
529
|
+
showHeader ? /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3 mb-4", children: [
|
|
530
530
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
531
531
|
/* @__PURE__ */ jsx("h2", { className: "text-base font-medium", children: "Job Secrets" }),
|
|
532
532
|
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Custom environment variables passed to agent job containers. These are merged with built-in auth credentials when launching jobs." })
|
|
@@ -542,7 +542,17 @@ function JobsPage() {
|
|
|
542
542
|
]
|
|
543
543
|
}
|
|
544
544
|
) })
|
|
545
|
-
] }),
|
|
545
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end mb-4", children: /* @__PURE__ */ jsxs(
|
|
546
|
+
"button",
|
|
547
|
+
{
|
|
548
|
+
onClick: () => setShowAdd(true),
|
|
549
|
+
className: "inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium bg-foreground text-background hover:bg-foreground/90 shrink-0 transition-colors",
|
|
550
|
+
children: [
|
|
551
|
+
/* @__PURE__ */ jsx(PlusIcon, { size: 14 }),
|
|
552
|
+
"Add secret"
|
|
553
|
+
]
|
|
554
|
+
}
|
|
555
|
+
) }),
|
|
546
556
|
/* @__PURE__ */ jsx(
|
|
547
557
|
AddSecretDialog,
|
|
548
558
|
{
|
|
@@ -591,6 +601,10 @@ function JobsPage() {
|
|
|
591
601
|
)) }) })
|
|
592
602
|
] });
|
|
593
603
|
}
|
|
604
|
+
function JobsPage() {
|
|
605
|
+
return /* @__PURE__ */ jsx(JobSecretsManager, {});
|
|
606
|
+
}
|
|
594
607
|
export {
|
|
608
|
+
JobSecretsManager,
|
|
595
609
|
JobsPage
|
|
596
610
|
};
|
|
@@ -590,7 +590,7 @@ function OAuthSecretRow({ secret, onReauthorize, onDelete }) {
|
|
|
590
590
|
// Jobs page
|
|
591
591
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
592
592
|
|
|
593
|
-
export function
|
|
593
|
+
export function JobSecretsManager({ showHeader = true }) {
|
|
594
594
|
const [secrets, setSecrets] = useState([]);
|
|
595
595
|
const [loading, setLoading] = useState(true);
|
|
596
596
|
const [showAdd, setShowAdd] = useState(false);
|
|
@@ -635,12 +635,24 @@ export function JobsPage() {
|
|
|
635
635
|
|
|
636
636
|
return (
|
|
637
637
|
<div>
|
|
638
|
-
|
|
639
|
-
<div className="
|
|
640
|
-
<
|
|
641
|
-
|
|
638
|
+
{showHeader ? (
|
|
639
|
+
<div className="flex items-start justify-between gap-3 mb-4">
|
|
640
|
+
<div className="min-w-0">
|
|
641
|
+
<h2 className="text-base font-medium">Job Secrets</h2>
|
|
642
|
+
<p className="text-sm text-muted-foreground">Custom environment variables passed to agent job containers. These are merged with built-in auth credentials when launching jobs.</p>
|
|
643
|
+
</div>
|
|
644
|
+
<div className="flex items-center gap-2 shrink-0 pt-0.5">
|
|
645
|
+
<button
|
|
646
|
+
onClick={() => setShowAdd(true)}
|
|
647
|
+
className="inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium bg-foreground text-background hover:bg-foreground/90 shrink-0 transition-colors"
|
|
648
|
+
>
|
|
649
|
+
<PlusIcon size={14} />
|
|
650
|
+
Add secret
|
|
651
|
+
</button>
|
|
652
|
+
</div>
|
|
642
653
|
</div>
|
|
643
|
-
|
|
654
|
+
) : (
|
|
655
|
+
<div className="flex items-center justify-end mb-4">
|
|
644
656
|
<button
|
|
645
657
|
onClick={() => setShowAdd(true)}
|
|
646
658
|
className="inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium bg-foreground text-background hover:bg-foreground/90 shrink-0 transition-colors"
|
|
@@ -649,7 +661,7 @@ export function JobsPage() {
|
|
|
649
661
|
Add secret
|
|
650
662
|
</button>
|
|
651
663
|
</div>
|
|
652
|
-
|
|
664
|
+
)}
|
|
653
665
|
<AddSecretDialog
|
|
654
666
|
open={showAdd}
|
|
655
667
|
onAdd={handleAdd}
|
|
@@ -696,3 +708,7 @@ export function JobsPage() {
|
|
|
696
708
|
</div>
|
|
697
709
|
);
|
|
698
710
|
}
|
|
711
|
+
|
|
712
|
+
export function JobsPage() {
|
|
713
|
+
return <JobSecretsManager />;
|
|
714
|
+
}
|
|
@@ -271,7 +271,7 @@ function VariableRow({ name, isSet, currentValue, onUpdate, onDelete }) {
|
|
|
271
271
|
] })
|
|
272
272
|
] });
|
|
273
273
|
}
|
|
274
|
-
function Dialog({ open, onClose, title, children }) {
|
|
274
|
+
function Dialog({ open, onClose, title, children, maxWidth = "max-w-md" }) {
|
|
275
275
|
const ref = useRef(null);
|
|
276
276
|
useEffect(() => {
|
|
277
277
|
if (!open) return;
|
|
@@ -289,7 +289,7 @@ function Dialog({ open, onClose, title, children }) {
|
|
|
289
289
|
"div",
|
|
290
290
|
{
|
|
291
291
|
ref,
|
|
292
|
-
className:
|
|
292
|
+
className: `relative z-50 w-full ${maxWidth} mx-4 rounded-lg border border-border bg-background p-6 shadow-lg max-h-[90vh] overflow-y-auto`,
|
|
293
293
|
onClick: (e) => e.stopPropagation(),
|
|
294
294
|
children: [
|
|
295
295
|
/* @__PURE__ */ jsx("h3", { className: "text-base font-semibold mb-4", children: title }),
|
|
@@ -289,7 +289,7 @@ export function VariableRow({ name, isSet, currentValue, onUpdate, onDelete }) {
|
|
|
289
289
|
// Dialog — standardized modal
|
|
290
290
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
291
291
|
|
|
292
|
-
export function Dialog({ open, onClose, title, children }) {
|
|
292
|
+
export function Dialog({ open, onClose, title, children, maxWidth = 'max-w-md' }) {
|
|
293
293
|
const ref = useRef(null);
|
|
294
294
|
|
|
295
295
|
useEffect(() => {
|
|
@@ -306,7 +306,7 @@ export function Dialog({ open, onClose, title, children }) {
|
|
|
306
306
|
<div className="fixed inset-0 bg-black/50" onClick={onClose} />
|
|
307
307
|
<div
|
|
308
308
|
ref={ref}
|
|
309
|
-
className=
|
|
309
|
+
className={`relative z-50 w-full ${maxWidth} mx-4 rounded-lg border border-border bg-background p-6 shadow-lg max-h-[90vh] overflow-y-auto`}
|
|
310
310
|
onClick={(e) => e.stopPropagation()}
|
|
311
311
|
>
|
|
312
312
|
<h3 className="text-base font-semibold mb-4">{title}</h3>
|
package/lib/code/code-page.js
CHANGED
|
@@ -266,7 +266,7 @@ function CodePage({ session, codeWorkspaceId }) {
|
|
|
266
266
|
/* @__PURE__ */ jsxs(SidebarInset, { children: [
|
|
267
267
|
/* @__PURE__ */ jsxs("div", { className: "flex h-svh flex-col overflow-hidden", children: [
|
|
268
268
|
/* @__PURE__ */ jsx(ChatHeader, { workspaceId: codeWorkspaceId }),
|
|
269
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-0 px-4 bg-muted/30 border-b border-border shrink-0 overflow-x-auto scrollbar-hide", children: [
|
|
269
|
+
!showDiff && /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-0 px-4 bg-muted/30 border-b border-border shrink-0 overflow-x-auto scrollbar-hide", children: [
|
|
270
270
|
/* @__PURE__ */ jsx(
|
|
271
271
|
PinnedTab,
|
|
272
272
|
{
|
package/lib/code/code-page.jsx
CHANGED
|
@@ -310,7 +310,8 @@ export default function CodePage({ session, codeWorkspaceId }) {
|
|
|
310
310
|
<div className="flex h-svh flex-col overflow-hidden">
|
|
311
311
|
<ChatHeader workspaceId={codeWorkspaceId} />
|
|
312
312
|
|
|
313
|
-
{/* Tab bar */}
|
|
313
|
+
{/* Tab bar — hidden while diff viewer is open so it fills the content area */}
|
|
314
|
+
{!showDiff && (
|
|
314
315
|
<div className="flex items-end gap-0 px-4 bg-muted/30 border-b border-border shrink-0 overflow-x-auto scrollbar-hide">
|
|
315
316
|
{/* Primary Code tab — pinned, not draggable */}
|
|
316
317
|
<PinnedTab
|
|
@@ -429,6 +430,7 @@ export default function CodePage({ session, codeWorkspaceId }) {
|
|
|
429
430
|
+ Port
|
|
430
431
|
</button>
|
|
431
432
|
</div>
|
|
433
|
+
)}
|
|
432
434
|
|
|
433
435
|
{/* Tab content panels — all mounted, hidden via display */}
|
|
434
436
|
<div style={{ position: 'relative', flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>
|
package/lib/cron.js
CHANGED
|
@@ -4,6 +4,9 @@ import path from 'path';
|
|
|
4
4
|
import { PROJECT_ROOT } from './paths.js';
|
|
5
5
|
import { executeAction } from './actions.js';
|
|
6
6
|
|
|
7
|
+
// Active user cron tasks (module-scoped so reloadCrons can stop them)
|
|
8
|
+
let _cronTasks = [];
|
|
9
|
+
|
|
7
10
|
function getInstalledVersion() {
|
|
8
11
|
const pkgPath = path.join(process.cwd(), 'node_modules', 'thepopebot', 'package.json');
|
|
9
12
|
return JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version;
|
|
@@ -228,7 +231,6 @@ function startBuiltinCrons() {
|
|
|
228
231
|
|
|
229
232
|
/**
|
|
230
233
|
* Load and schedule crons from CRONS.json
|
|
231
|
-
* @returns {Array} - Array of scheduled cron tasks
|
|
232
234
|
*/
|
|
233
235
|
function loadCrons() {
|
|
234
236
|
const cronFile = path.join(PROJECT_ROOT, 'agent-job/CRONS.json');
|
|
@@ -238,7 +240,8 @@ function loadCrons() {
|
|
|
238
240
|
if (!fs.existsSync(cronFile)) {
|
|
239
241
|
console.log('No CRONS.json found');
|
|
240
242
|
console.log('-----------------\n');
|
|
241
|
-
|
|
243
|
+
_cronTasks = [];
|
|
244
|
+
return;
|
|
242
245
|
}
|
|
243
246
|
|
|
244
247
|
const crons = JSON.parse(fs.readFileSync(cronFile, 'utf8'));
|
|
@@ -276,7 +279,32 @@ function loadCrons() {
|
|
|
276
279
|
|
|
277
280
|
console.log('-----------------\n');
|
|
278
281
|
|
|
279
|
-
|
|
282
|
+
_cronTasks = tasks;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Stop existing cron tasks and re-load from CRONS.json.
|
|
287
|
+
* If the new file is invalid, keeps existing tasks running.
|
|
288
|
+
*/
|
|
289
|
+
function reloadCrons() {
|
|
290
|
+
const cronFile = path.join(PROJECT_ROOT, 'agent-job/CRONS.json');
|
|
291
|
+
|
|
292
|
+
// Pre-validate before stopping anything
|
|
293
|
+
if (fs.existsSync(cronFile)) {
|
|
294
|
+
try {
|
|
295
|
+
JSON.parse(fs.readFileSync(cronFile, 'utf8'));
|
|
296
|
+
} catch (err) {
|
|
297
|
+
console.error(`[cron reload] Invalid JSON in CRONS.json, keeping existing schedule: ${err.message}`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
for (const { task } of _cronTasks) {
|
|
303
|
+
task.stop();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
loadCrons();
|
|
307
|
+
console.log('[cron reload] Cron schedule reloaded');
|
|
280
308
|
}
|
|
281
309
|
|
|
282
|
-
export { loadCrons, startBuiltinCrons, getUpdateAvailable, setUpdateAvailable, getInstalledVersion, isPrerelease, runVersionCheck };
|
|
310
|
+
export { loadCrons, reloadCrons, startBuiltinCrons, getUpdateAvailable, setUpdateAvailable, getInstalledVersion, isPrerelease, runVersionCheck };
|
package/lib/triggers.js
CHANGED
|
@@ -3,6 +3,9 @@ import path from 'path';
|
|
|
3
3
|
import { PROJECT_ROOT } from './paths.js';
|
|
4
4
|
import { executeAction } from './actions.js';
|
|
5
5
|
|
|
6
|
+
// Cached fire function (module-scoped so reloadTriggers can reset it)
|
|
7
|
+
let _fireTriggers = null;
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* Replace {{body.field}} templates with values from request context
|
|
8
11
|
* @param {string} template - String with {{body.field}} placeholders
|
|
@@ -102,4 +105,38 @@ function loadTriggers() {
|
|
|
102
105
|
return { triggerMap, fireTriggers };
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Get the cached fire function, loading on first call.
|
|
110
|
+
*/
|
|
111
|
+
function getFireTriggers() {
|
|
112
|
+
if (!_fireTriggers) {
|
|
113
|
+
const result = loadTriggers();
|
|
114
|
+
_fireTriggers = result.fireTriggers;
|
|
115
|
+
}
|
|
116
|
+
return _fireTriggers;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Re-load triggers from TRIGGERS.json.
|
|
121
|
+
* If the new file is invalid, keeps existing triggers.
|
|
122
|
+
*/
|
|
123
|
+
function reloadTriggers() {
|
|
124
|
+
const triggerFile = path.join(PROJECT_ROOT, 'event-handler/TRIGGERS.json');
|
|
125
|
+
|
|
126
|
+
// Pre-validate before discarding anything
|
|
127
|
+
if (fs.existsSync(triggerFile)) {
|
|
128
|
+
try {
|
|
129
|
+
JSON.parse(fs.readFileSync(triggerFile, 'utf8'));
|
|
130
|
+
} catch (err) {
|
|
131
|
+
console.error(`[trigger reload] Invalid JSON in TRIGGERS.json, keeping existing triggers: ${err.message}`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
_fireTriggers = null;
|
|
137
|
+
// Force re-load immediately so the log output shows
|
|
138
|
+
getFireTriggers();
|
|
139
|
+
console.log('[trigger reload] Triggers reloaded');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { loadTriggers, getFireTriggers, reloadTriggers };
|
package/package.json
CHANGED
|
@@ -68,11 +68,6 @@ jobs:
|
|
|
68
68
|
docker exec thepopebot-event-handler rm -f /tmp/.rebuild-status
|
|
69
69
|
echo "status=$STATUS" >> $GITHUB_OUTPUT
|
|
70
70
|
|
|
71
|
-
- name: Reload (no version change)
|
|
72
|
-
if: steps.pull.outputs.status == 'RELOAD'
|
|
73
|
-
run: |
|
|
74
|
-
docker exec thepopebot-event-handler gosu coding-agent pm2 reload all
|
|
75
|
-
|
|
76
71
|
- name: Pull new image and restart container
|
|
77
72
|
if: steps.pull.outputs.status == 'VERSION_CHANGED'
|
|
78
73
|
run: |
|