@lovelybunch/api 1.0.75-alpha.1 → 1.0.75-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/auth/auth-manager.d.ts +5 -0
- package/dist/lib/auth/auth-manager.js +9 -0
- package/dist/lib/storage/file-storage.d.ts +16 -16
- package/dist/lib/storage/file-storage.js +84 -79
- package/dist/lib/terminal/terminal-manager.d.ts +3 -5
- package/dist/lib/terminal/terminal-manager.js +19 -63
- package/dist/middleware/auth.js +36 -0
- package/dist/routes/api/v1/ai/index.js +0 -2
- package/dist/routes/api/v1/ai/route.js +445 -259
- package/dist/routes/api/v1/chats/[id]/index.js +2 -1
- package/dist/routes/api/v1/chats/[id]/route.d.ts +7 -0
- package/dist/routes/api/v1/chats/[id]/route.js +30 -1
- package/dist/routes/api/v1/context/index.js +0 -2
- package/dist/routes/api/v1/events/route.js +1 -1
- package/dist/routes/api/v1/events/status/route.d.ts +1 -1
- package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
- package/dist/routes/api/v1/jobs/[id]/runs/[runId]/route.d.ts +2 -2
- package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
- package/dist/routes/api/v1/knowledge/[filename]/index.d.ts +1 -0
- package/dist/routes/api/v1/knowledge/[filename]/index.js +1 -0
- package/dist/routes/api/v1/knowledge/[filename]/route.d.ts +3 -0
- package/dist/routes/api/v1/knowledge/[filename]/route.js +254 -0
- package/dist/routes/api/v1/knowledge/index.d.ts +1 -0
- package/dist/routes/api/v1/knowledge/index.js +1 -0
- package/dist/routes/api/v1/knowledge/route.d.ts +3 -0
- package/dist/routes/api/v1/knowledge/route.js +176 -0
- package/dist/routes/api/v1/mcp/index.js +109 -34
- package/dist/routes/api/v1/proposals/[id]/route.d.ts +8 -8
- package/dist/routes/api/v1/skills/[id]/index.d.ts +1 -0
- package/dist/routes/api/v1/skills/[id]/index.js +1 -0
- package/dist/routes/api/v1/skills/[id]/route.d.ts +3 -0
- package/dist/routes/api/v1/skills/[id]/route.js +199 -0
- package/dist/routes/api/v1/skills/index.d.ts +1 -0
- package/dist/routes/api/v1/skills/index.js +1 -0
- package/dist/routes/api/v1/skills/route.d.ts +3 -0
- package/dist/routes/api/v1/skills/route.js +329 -0
- package/dist/routes/api/v1/tasks/[id]/route.d.ts +351 -0
- package/dist/routes/api/v1/tasks/[id]/route.js +156 -0
- package/dist/routes/api/v1/tasks/index.d.ts +3 -0
- package/dist/routes/api/v1/tasks/index.js +10 -0
- package/dist/routes/api/v1/tasks/route.d.ts +329 -0
- package/dist/routes/api/v1/tasks/route.js +126 -0
- package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
- package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
- package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
- package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
- package/dist/server-with-static.js +18 -14
- package/dist/server.js +15 -13
- package/package.json +8 -4
- package/static/assets/{ActivityPage-BYrDJlH6.js → ActivityPage-CbmEnYhg.js} +1 -1
- package/static/assets/ApiKeysSettingsPage-DLxQIqTT.js +2 -0
- package/static/assets/{ArchitectureEditPage-Bw2d_hmk.js → ArchitectureEditPage-CbtzgIQv.js} +4 -4
- package/static/assets/{ArchitecturePage-36wO0UD7.js → ArchitecturePage-CcAMfFZ8.js} +1 -1
- package/static/assets/{AuthSettingsPage-CKifiWsx.js → AuthSettingsPage-4Prb7nAt.js} +2 -2
- package/static/assets/{CallbackPage-Ck0dddEW.js → CallbackPage-CmWv_5Nh.js} +1 -1
- package/static/assets/CodePage-COC7rcwM.js +2 -0
- package/static/assets/{CollapsibleSection-BKY-lfsm.js → CollapsibleSection-C_VVeVSc.js} +1 -1
- package/static/assets/DashboardPage-BACFVIaW.js +41 -0
- package/static/assets/{GitPage-BgCxzm-C.js → GitPage-rFngEr_A.js} +2 -2
- package/static/assets/GitSettingsPage-CDQovOqx.js +6 -0
- package/static/assets/IdentityPage-CS4REq2E.js +11 -0
- package/static/assets/{ImplementationStepsEditor-iqrCqyOb.js → ImplementationStepsEditor-CBIgppkZ.js} +2 -2
- package/static/assets/IntegrationsSettingsPage-B7HoraBH.js +1 -0
- package/static/assets/JobDetailPage-QUhWsaWV.js +1 -0
- package/static/assets/KnowledgeDetailPage-DCJstmIr.js +1 -0
- package/static/assets/KnowledgeEditPage-EYpFPfcJ.js +1 -0
- package/static/assets/KnowledgePage-D-7skvn5.js +8 -0
- package/static/assets/{LoginPage-DqbNxfY6.js → LoginPage-L2aoqSDT.js} +1 -1
- package/static/assets/McpSettingsPage-CLwqDjw_.js +1 -0
- package/static/assets/NewKnowledgePage-Fq_QD8um.js +9 -0
- package/static/assets/NewSkillPage-DRcgovk0.js +1 -0
- package/static/assets/NewTaskPage-CleA8rH5.js +90 -0
- package/static/assets/ProjectEditPage-GIMOKgmh.js +11 -0
- package/static/assets/ProjectPage-DlWZOqnb.js +1 -0
- package/static/assets/PromptsSettingsPage-DFagGfo-.js +1 -0
- package/static/assets/ResourceDetailPage-CnFRpDec.js +1 -0
- package/static/assets/ResourcesPage-Cw3fu0JE.js +41 -0
- package/static/assets/{RoleEditPage-DhVneoNR.js → RoleEditPage-ARXq_eCs.js} +1 -1
- package/static/assets/{RolePage-BOI2T8QG.js → RolePage--XBBIrq8.js} +1 -1
- package/static/assets/{RulesSettingsPage-VsteFA-j.js → RulesSettingsPage-DEqaRH96.js} +3 -3
- package/static/assets/SchedulePage-C_B2k9P6.js +4 -0
- package/static/assets/SkillDetailPage-Dr6xyKAX.js +1 -0
- package/static/assets/SkillEditPage-BsHXmfEZ.js +1 -0
- package/static/assets/SkillsPage-BrDdAAPx.js +8 -0
- package/static/assets/SkillsSettingsPage-Cvi7xaDE.js +1 -0
- package/static/assets/SourceInput-DxF_GGj8.js +1 -0
- package/static/assets/{TagInput-BWLBdW8h.js → TagInput-DYvHbVZq.js} +1 -1
- package/static/assets/TaskDetailPage-DzcD6t03.js +1 -0
- package/static/assets/TaskEditPage-C7a6FOeJ.js +1 -0
- package/static/assets/TasksPage-ChWRSO_S.js +17 -0
- package/static/assets/TerminalPage-CoPwn8cU.js +1 -0
- package/static/assets/TerminalSessionPage-BQBZrOJa.js +13 -0
- package/static/assets/UserPreferencesPage-DjtU7veO.js +1 -0
- package/static/assets/UserSettingsPage-CfU8boJQ.js +1 -0
- package/static/assets/UtilitiesPage-sP1Crg-X.js +1 -0
- package/static/assets/{alert-C7sSXJf0.js → alert-BqZa-crG.js} +1 -1
- package/static/assets/{arrow-down-DNa4SyO2.js → arrow-down-3faV_GyO.js} +1 -1
- package/static/assets/{arrow-left-DkoECaEJ.js → arrow-left-FD3wQmzH.js} +1 -1
- package/static/assets/{arrow-up-DQlu6uQE.js → arrow-up-BzP0YNVk.js} +1 -1
- package/static/assets/{badge-2ZOe5ynf.js → badge-DRyeFib9.js} +1 -1
- package/static/assets/{browser-modal-DUCXGaha.js → browser-modal-vnePkRfO.js} +2 -2
- package/static/assets/{card-By4vbQ_f.js → card-CuQs3dpy.js} +1 -1
- package/static/assets/{chevron-left-CJfNRqcH.js → chevron-left-QZIoYcVa.js} +1 -1
- package/static/assets/{plus-D0SUNNMH.js → chevron-up-DreyvhRd.js} +2 -2
- package/static/assets/{chevrons-up-DoBrp0tt.js → chevrons-up-CsAkc9vE.js} +1 -1
- package/static/assets/{circle-alert-B4JJ0jKl.js → circle-alert-ewz28SE3.js} +1 -1
- package/static/assets/{circle-check-DC5Ek4MP.js → circle-check-2TuD-EHs.js} +1 -1
- package/static/assets/{circle-check-big-Dw4YJZos.js → circle-check-big-1xNuBPkR.js} +1 -1
- package/static/assets/{circle-play-D9VS6Vdc.js → circle-play-C_w-qCn4.js} +1 -1
- package/static/assets/{circle-x-BReHgv4g.js → circle-x-B_d4wjG-.js} +1 -1
- package/static/assets/{clipboard-CuF9OlXN.js → clipboard-B6vBm1BP.js} +1 -1
- package/static/assets/{clock-CDTi2Cen.js → clock-BIzEsx1g.js} +1 -1
- package/static/assets/{download-DHIAgGlY.js → download-Dv-RIvKK.js} +1 -1
- package/static/assets/droid-GYYyVzN-.js +18 -0
- package/static/assets/external-link-Cr8wjV6X.js +6 -0
- package/static/assets/{eye-Ch7ecV9Z.js → eye-DN958vyL.js} +1 -1
- package/static/assets/{folder-git-2-BYI_osdA.js → folder-git-2-BproRzAR.js} +1 -1
- package/static/assets/index-Co_SJV3n.js +472 -0
- package/static/assets/index-GFQ5RqVh.css +2 -0
- package/static/assets/info-CzKk8mbR.js +6 -0
- package/static/assets/{label-BUv8Ltyw.js → label-h5GIKGcJ.js} +1 -1
- package/static/assets/{markdown-editor-BP8Xkecg.js → markdown-editor-C6il4XWv.js} +1 -1
- package/static/assets/{pause-B0clczfE.js → pause-BDsjEmXM.js} +1 -1
- package/static/assets/{play-BHUpJCX1.js → play-CGsVQUJG.js} +1 -1
- package/static/assets/{radio-group-CSBH8ca-.js → radio-group-Bsd75ahK.js} +1 -1
- package/static/assets/{refresh-cw-C-yGwsHL.js → refresh-cw-qE1iNkL_.js} +1 -1
- package/static/assets/{search-DFtqbVgP.js → search-dvi0J4Dr.js} +1 -1
- package/static/assets/select-DylRS99W.js +1 -0
- package/static/assets/status-utils-CDkPeVfP.js +1 -0
- package/static/assets/{switch-WtOd8h5Z.js → switch-CsB3wpq9.js} +1 -1
- package/static/assets/{tabs-D93ZjKR7.js → tabs-Bw_4k2Rs.js} +1 -1
- package/static/assets/{tag-EEDDoCc_.js → tag-Dh5PraRd.js} +1 -1
- package/static/assets/{terminal-preview-sns5QTN_.js → terminal-preview-CfOb7xMx.js} +1 -1
- package/static/assets/use-terminal-T_tdJTCU.js +1 -0
- package/static/assets/video-bO6uuAjA.js +36 -0
- package/static/assets/{zap-BYFYWzmj.js → zap-DHZ91NcK.js} +1 -1
- package/static/index.html +2 -2
- package/static/assets/AgentDetailPage-D6yg4CtT.js +0 -1
- package/static/assets/AgentEditPage-CTnjxjX7.js +0 -1
- package/static/assets/AgentsPage-NdB5OB1C.js +0 -3
- package/static/assets/AgentsSettingsPage-CYXp908g.js +0 -6
- package/static/assets/ApiKeysSettingsPage-Jl6vvVmW.js +0 -7
- package/static/assets/CodePage-b3JR4eWW.js +0 -2
- package/static/assets/DashboardPage-Cv2-duAx.js +0 -41
- package/static/assets/GitSettingsPage-CKIWkAnw.js +0 -6
- package/static/assets/IdentityPage-BsZnszF-.js +0 -11
- package/static/assets/IntegrationsSettingsPage-C1dC_vVy.js +0 -1
- package/static/assets/JobDetailPage-BgGQJkND.js +0 -1
- package/static/assets/KnowledgeDetailPage-Dzy2V7yT.js +0 -1
- package/static/assets/KnowledgeEditPage-av1ALt0h.js +0 -1
- package/static/assets/KnowledgePage-C_UDfD9X.js +0 -8
- package/static/assets/McpSettingsPage-BqbErEWS.js +0 -1
- package/static/assets/NewAgentPage-UEVIYkt3.js +0 -1
- package/static/assets/NewKnowledgePage-CzYXdoDb.js +0 -9
- package/static/assets/NewProposalPage-DrU0ihJX.js +0 -90
- package/static/assets/ProjectEditPage-j4KporiC.js +0 -11
- package/static/assets/ProjectPage-BQNa0qA-.js +0 -1
- package/static/assets/PromptsSettingsPage-sYphs8Dn.js +0 -1
- package/static/assets/ProposalDetailPage-CHR1MmwC.js +0 -1
- package/static/assets/ProposalEditPage-CkcZqgax.js +0 -1
- package/static/assets/ProposalsPage-CUB_aLXW.js +0 -17
- package/static/assets/ResourcesPage-DzjwPoyS.js +0 -71
- package/static/assets/SchedulePage-_v4YfdHo.js +0 -4
- package/static/assets/SourceInput-BFxoOvqS.js +0 -1
- package/static/assets/TerminalPage-DtVDWX7G.js +0 -1
- package/static/assets/TerminalSessionPage-BUHzje8A.js +0 -13
- package/static/assets/UserPreferencesPage-CkXJuogz.js +0 -1
- package/static/assets/UserSettingsPage-Dz-R1ijS.js +0 -1
- package/static/assets/UtilitiesPage-CRqQYVsb.js +0 -1
- package/static/assets/calendar-tNgwmWmG.js +0 -6
- package/static/assets/droid-BvMEm3eg.js +0 -8
- package/static/assets/index-CCs6x1Au.js +0 -468
- package/static/assets/index-CzjbtPHw.css +0 -2
- package/static/assets/use-terminal-BW9XYY8N.js +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context } from 'hono';
|
|
2
|
+
export declare function POST(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
3
|
+
error: string;
|
|
4
|
+
}, 400, "json">) | (Response & import("hono").TypedResponse<{
|
|
5
|
+
error: string;
|
|
6
|
+
}, 404, "json">) | (Response & import("hono").TypedResponse<{
|
|
7
|
+
success: true;
|
|
8
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
9
|
+
error: string;
|
|
10
|
+
}, 500, "json">)>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getGlobalTerminalManager } from '../../../../../../lib/terminal/global-manager.js';
|
|
2
|
+
export async function POST(c) {
|
|
3
|
+
try {
|
|
4
|
+
const taskId = c.req.param('taskId');
|
|
5
|
+
const body = await c.req.json();
|
|
6
|
+
const { sessionId } = body;
|
|
7
|
+
if (!sessionId) {
|
|
8
|
+
return c.json({ error: 'Session ID is required' }, 400);
|
|
9
|
+
}
|
|
10
|
+
const terminalManager = getGlobalTerminalManager();
|
|
11
|
+
const success = terminalManager.destroySession(sessionId);
|
|
12
|
+
if (!success) {
|
|
13
|
+
return c.json({ error: 'Session not found' }, 404);
|
|
14
|
+
}
|
|
15
|
+
return c.json({ success: true });
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.error('Error destroying terminal session:', error);
|
|
19
|
+
return c.json({ error: 'Failed to destroy terminal session' }, 500);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context } from 'hono';
|
|
2
|
+
export declare function POST(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
3
|
+
error: string;
|
|
4
|
+
}, 400, "json">) | (Response & import("hono").TypedResponse<{
|
|
5
|
+
error: string;
|
|
6
|
+
}, 404, "json">) | (Response & import("hono").TypedResponse<{
|
|
7
|
+
success: true;
|
|
8
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
9
|
+
error: string;
|
|
10
|
+
}, 500, "json">)>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getGlobalTerminalManager } from '../../../../../../lib/terminal/global-manager.js';
|
|
2
|
+
export async function POST(c) {
|
|
3
|
+
try {
|
|
4
|
+
const taskId = c.req.param('taskId');
|
|
5
|
+
const body = await c.req.json();
|
|
6
|
+
const { sessionId, cols, rows } = body;
|
|
7
|
+
if (!sessionId || !cols || !rows) {
|
|
8
|
+
return c.json({ error: 'Session ID, cols, and rows are required' }, 400);
|
|
9
|
+
}
|
|
10
|
+
const terminalManager = getGlobalTerminalManager();
|
|
11
|
+
const success = terminalManager.resizeSession(sessionId, cols, rows);
|
|
12
|
+
if (!success) {
|
|
13
|
+
return c.json({ error: 'Session not found or resize failed' }, 404);
|
|
14
|
+
}
|
|
15
|
+
return c.json({ success: true });
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.error('Error resizing terminal session:', error);
|
|
19
|
+
return c.json({ error: 'Failed to resize terminal session' }, 500);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -31,7 +31,7 @@ export async function GET(c) {
|
|
|
31
31
|
try {
|
|
32
32
|
const url = new URL(c.req.url);
|
|
33
33
|
const searchParams = url.searchParams;
|
|
34
|
-
const
|
|
34
|
+
const taskId = searchParams.get('taskId');
|
|
35
35
|
const sessionId = searchParams.get('sessionId');
|
|
36
36
|
const withPreview = ['1', 'true', 'yes'].includes((searchParams.get('withPreview') || '').toLowerCase());
|
|
37
37
|
const linesParam = parseInt(searchParams.get('lines') || '0', 10);
|
|
@@ -45,8 +45,8 @@ export async function GET(c) {
|
|
|
45
45
|
const s = terminalManager.getSession(sessionId);
|
|
46
46
|
sessions = s ? [s] : [];
|
|
47
47
|
}
|
|
48
|
-
else if (
|
|
49
|
-
sessions = terminalManager.
|
|
48
|
+
else if (taskId) {
|
|
49
|
+
sessions = terminalManager.getSessionsByTask(taskId);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
sessions = terminalManager.getAllSessions();
|
|
@@ -54,7 +54,7 @@ export async function GET(c) {
|
|
|
54
54
|
// Return session info without the PTY instance
|
|
55
55
|
const sessionInfo = sessions.map(session => ({
|
|
56
56
|
id: session.id,
|
|
57
|
-
|
|
57
|
+
taskId: session.taskId,
|
|
58
58
|
createdAt: session.createdAt,
|
|
59
59
|
lastActivity: session.lastActivity,
|
|
60
60
|
connected: !!session.websocket,
|
|
@@ -90,9 +90,9 @@ catch (error) {
|
|
|
90
90
|
console.error(error);
|
|
91
91
|
}
|
|
92
92
|
const app = new Hono();
|
|
93
|
-
// Enable CORS for
|
|
93
|
+
// Enable CORS for frontend
|
|
94
94
|
app.use('/api/*', cors({
|
|
95
|
-
origin: '
|
|
95
|
+
origin: ['https://app.coconut.dev', 'http://localhost:5173', 'http://localhost:5174', 'http://localhost:3000'],
|
|
96
96
|
credentials: true,
|
|
97
97
|
}));
|
|
98
98
|
// Handle trailing slashes consistently for API routes
|
|
@@ -157,11 +157,11 @@ app.get('/ws/terminal-preview/:sessionId', upgradeWebSocket((c) => ({
|
|
|
157
157
|
import auth from './routes/api/v1/auth/index.js';
|
|
158
158
|
import authSettings from './routes/api/v1/auth-settings/index.js';
|
|
159
159
|
import apiKeys from './routes/api/v1/api-keys/index.js';
|
|
160
|
-
import
|
|
160
|
+
import tasks from './routes/api/v1/tasks/index.js';
|
|
161
161
|
import terminalSessions from './routes/api/v1/terminal/sessions/index.js';
|
|
162
|
-
import terminalCreate from './routes/api/v1/terminal/[
|
|
163
|
-
import terminalDestroy from './routes/api/v1/terminal/[
|
|
164
|
-
import terminalResize from './routes/api/v1/terminal/[
|
|
162
|
+
import terminalCreate from './routes/api/v1/terminal/[taskId]/create/index.js';
|
|
163
|
+
import terminalDestroy from './routes/api/v1/terminal/[taskId]/destroy/index.js';
|
|
164
|
+
import terminalResize from './routes/api/v1/terminal/[taskId]/resize/index.js';
|
|
165
165
|
import ai from './routes/api/v1/ai/index.js';
|
|
166
166
|
import chats from './routes/api/v1/chats/index.js';
|
|
167
167
|
import chatsById from './routes/api/v1/chats/[id]/index.js';
|
|
@@ -169,13 +169,15 @@ import resources from './routes/api/v1/resources/index.js';
|
|
|
169
169
|
import resourcesById from './routes/api/v1/resources/[id]/index.js';
|
|
170
170
|
import resourcesThumbnail from './routes/api/v1/resources/[id]/thumbnail/index.js';
|
|
171
171
|
import context from './routes/api/v1/context/index.js';
|
|
172
|
+
import knowledge from './routes/api/v1/knowledge/index.js';
|
|
172
173
|
import config from './routes/api/v1/config/index.js';
|
|
173
174
|
import user from './routes/api/v1/user/index.js';
|
|
174
|
-
import
|
|
175
|
-
import
|
|
175
|
+
import skills from './routes/api/v1/skills/index.js';
|
|
176
|
+
import skillsById from './routes/api/v1/skills/[id]/index.js';
|
|
176
177
|
import identity, { readAgentCard, PUBLIC_AGENT_CARD_PATH } from './routes/api/v1/identity/index.js';
|
|
177
178
|
import git from './routes/api/v1/git/index.js';
|
|
178
179
|
import mcp from './routes/api/v1/mcp/index.js';
|
|
180
|
+
import symlinks from './routes/api/v1/symlinks/index.js';
|
|
179
181
|
import jobs from './routes/api/v1/jobs/index.js';
|
|
180
182
|
import events from './routes/api/v1/events/index.js';
|
|
181
183
|
import version from './routes/api/v1/version/index.js';
|
|
@@ -184,11 +186,11 @@ console.log('🔗 Registering API routes...');
|
|
|
184
186
|
app.route('/api/v1/auth', auth);
|
|
185
187
|
app.route('/api/v1/auth-settings', authSettings);
|
|
186
188
|
app.route('/api/v1/api-keys', apiKeys);
|
|
187
|
-
app.route('/api/v1/
|
|
189
|
+
app.route('/api/v1/tasks', tasks);
|
|
188
190
|
app.route('/api/v1/terminal/sessions', terminalSessions);
|
|
189
|
-
app.route('/api/v1/terminal/:
|
|
190
|
-
app.route('/api/v1/terminal/:
|
|
191
|
-
app.route('/api/v1/terminal/:
|
|
191
|
+
app.route('/api/v1/terminal/:taskId/create', terminalCreate);
|
|
192
|
+
app.route('/api/v1/terminal/:taskId/destroy', terminalDestroy);
|
|
193
|
+
app.route('/api/v1/terminal/:taskId/resize', terminalResize);
|
|
192
194
|
app.route('/api/v1/ai', ai);
|
|
193
195
|
app.route('/api/v1/chats', chats);
|
|
194
196
|
app.route('/api/v1/chats/:id', chatsById);
|
|
@@ -196,13 +198,15 @@ app.route('/api/v1/resources', resources);
|
|
|
196
198
|
app.route('/api/v1/resources/:id', resourcesById);
|
|
197
199
|
app.route('/api/v1/resources/:id/thumbnail', resourcesThumbnail);
|
|
198
200
|
app.route('/api/v1/context', context);
|
|
201
|
+
app.route('/api/v1/knowledge', knowledge);
|
|
199
202
|
app.route('/api/v1/config', config);
|
|
200
203
|
app.route('/api/v1/user', user);
|
|
201
|
-
app.route('/api/v1/
|
|
202
|
-
app.route('/api/v1/
|
|
204
|
+
app.route('/api/v1/skills', skills);
|
|
205
|
+
app.route('/api/v1/skills/:id', skillsById);
|
|
203
206
|
app.route('/api/v1/identity', identity);
|
|
204
207
|
app.route('/api/v1/git', git);
|
|
205
208
|
app.route('/api/v1/mcp', mcp);
|
|
209
|
+
app.route('/api/v1/symlinks', symlinks);
|
|
206
210
|
app.route('/api/v1/jobs', jobs);
|
|
207
211
|
app.route('/api/v1/events', events);
|
|
208
212
|
app.route('/api/v1/version', version);
|
package/dist/server.js
CHANGED
|
@@ -91,7 +91,7 @@ catch (error) {
|
|
|
91
91
|
const app = new Hono();
|
|
92
92
|
// Enable CORS for frontend
|
|
93
93
|
app.use('*', cors({
|
|
94
|
-
origin: ['http://localhost:5173', 'http://localhost:5174', 'http://localhost:3000'],
|
|
94
|
+
origin: ['https://app.coconut.dev', 'http://localhost:5173', 'http://localhost:5174', 'http://localhost:3000'],
|
|
95
95
|
credentials: true,
|
|
96
96
|
}));
|
|
97
97
|
// Handle trailing slashes consistently for API routes
|
|
@@ -156,11 +156,11 @@ app.get('/ws/terminal-preview/:sessionId', upgradeWebSocket((c) => ({
|
|
|
156
156
|
import auth from './routes/api/v1/auth/index.js';
|
|
157
157
|
import authSettings from './routes/api/v1/auth-settings/index.js';
|
|
158
158
|
import apiKeys from './routes/api/v1/api-keys/index.js';
|
|
159
|
-
import
|
|
159
|
+
import tasks from './routes/api/v1/tasks/index.js';
|
|
160
160
|
import terminalSessions from './routes/api/v1/terminal/sessions/index.js';
|
|
161
|
-
import terminalCreate from './routes/api/v1/terminal/[
|
|
162
|
-
import terminalDestroy from './routes/api/v1/terminal/[
|
|
163
|
-
import terminalResize from './routes/api/v1/terminal/[
|
|
161
|
+
import terminalCreate from './routes/api/v1/terminal/[taskId]/create/index.js';
|
|
162
|
+
import terminalDestroy from './routes/api/v1/terminal/[taskId]/destroy/index.js';
|
|
163
|
+
import terminalResize from './routes/api/v1/terminal/[taskId]/resize/index.js';
|
|
164
164
|
import ai from './routes/api/v1/ai/index.js';
|
|
165
165
|
import chats from './routes/api/v1/chats/index.js';
|
|
166
166
|
import chatsById from './routes/api/v1/chats/[id]/index.js';
|
|
@@ -168,10 +168,11 @@ import resources from './routes/api/v1/resources/index.js';
|
|
|
168
168
|
import resourcesById from './routes/api/v1/resources/[id]/index.js';
|
|
169
169
|
import resourcesThumbnail from './routes/api/v1/resources/[id]/thumbnail/index.js';
|
|
170
170
|
import context from './routes/api/v1/context/index.js';
|
|
171
|
+
import knowledge from './routes/api/v1/knowledge/index.js';
|
|
171
172
|
import config from './routes/api/v1/config/index.js';
|
|
172
173
|
import user from './routes/api/v1/user/index.js';
|
|
173
|
-
import
|
|
174
|
-
import
|
|
174
|
+
import skills from './routes/api/v1/skills/index.js';
|
|
175
|
+
import skillsById from './routes/api/v1/skills/[id]/index.js';
|
|
175
176
|
import identity, { readAgentCard, PUBLIC_AGENT_CARD_PATH } from './routes/api/v1/identity/index.js';
|
|
176
177
|
import git from './routes/api/v1/git/index.js';
|
|
177
178
|
import mcp from './routes/api/v1/mcp/index.js';
|
|
@@ -183,11 +184,11 @@ import version from './routes/api/v1/version/index.js';
|
|
|
183
184
|
app.route('/api/v1/auth', auth);
|
|
184
185
|
app.route('/api/v1/auth-settings', authSettings);
|
|
185
186
|
app.route('/api/v1/api-keys', apiKeys);
|
|
186
|
-
app.route('/api/v1/
|
|
187
|
+
app.route('/api/v1/tasks', tasks);
|
|
187
188
|
app.route('/api/v1/terminal/sessions', terminalSessions);
|
|
188
|
-
app.route('/api/v1/terminal/:
|
|
189
|
-
app.route('/api/v1/terminal/:
|
|
190
|
-
app.route('/api/v1/terminal/:
|
|
189
|
+
app.route('/api/v1/terminal/:taskId/create', terminalCreate);
|
|
190
|
+
app.route('/api/v1/terminal/:taskId/destroy', terminalDestroy);
|
|
191
|
+
app.route('/api/v1/terminal/:taskId/resize', terminalResize);
|
|
191
192
|
app.route('/api/v1/ai', ai);
|
|
192
193
|
app.route('/api/v1/chats', chats);
|
|
193
194
|
app.route('/api/v1/chats/:id', chatsById);
|
|
@@ -195,10 +196,11 @@ app.route('/api/v1/resources', resources);
|
|
|
195
196
|
app.route('/api/v1/resources/:id', resourcesById);
|
|
196
197
|
app.route('/api/v1/resources/:id/thumbnail', resourcesThumbnail);
|
|
197
198
|
app.route('/api/v1/context', context);
|
|
199
|
+
app.route('/api/v1/knowledge', knowledge);
|
|
198
200
|
app.route('/api/v1/config', config);
|
|
199
201
|
app.route('/api/v1/user', user);
|
|
200
|
-
app.route('/api/v1/
|
|
201
|
-
app.route('/api/v1/
|
|
202
|
+
app.route('/api/v1/skills', skills);
|
|
203
|
+
app.route('/api/v1/skills/:id', skillsById);
|
|
202
204
|
app.route('/api/v1/identity', identity);
|
|
203
205
|
app.route('/api/v1/git', git);
|
|
204
206
|
app.route('/api/v1/mcp', mcp);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.75-alpha.
|
|
3
|
+
"version": "1.0.75-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/server-with-static.js",
|
|
6
6
|
"exports": {
|
|
@@ -34,11 +34,14 @@
|
|
|
34
34
|
"license": "ISC",
|
|
35
35
|
"description": "Coconut API server",
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@ai-sdk/anthropic": "^3.0.41",
|
|
37
38
|
"@hono/node-server": "^1.13.7",
|
|
38
39
|
"@hono/node-ws": "^1.0.6",
|
|
39
|
-
"@lovelybunch/core": "^1.0.75-alpha.
|
|
40
|
-
"@lovelybunch/mcp": "^1.0.75-alpha.
|
|
41
|
-
"@lovelybunch/types": "^1.0.75-alpha.
|
|
40
|
+
"@lovelybunch/core": "^1.0.75-alpha.10",
|
|
41
|
+
"@lovelybunch/mcp": "^1.0.75-alpha.10",
|
|
42
|
+
"@lovelybunch/types": "^1.0.75-alpha.10",
|
|
43
|
+
"adm-zip": "^0.5.16",
|
|
44
|
+
"ai": "^6.0.79",
|
|
42
45
|
"arctic": "^1.9.2",
|
|
43
46
|
"bcrypt": "^5.1.1",
|
|
44
47
|
"cookie": "^0.6.0",
|
|
@@ -54,6 +57,7 @@
|
|
|
54
57
|
"zod": "^3.23.0"
|
|
55
58
|
},
|
|
56
59
|
"devDependencies": {
|
|
60
|
+
"@types/adm-zip": "^0.5.7",
|
|
57
61
|
"@types/bcrypt": "^5.0.2",
|
|
58
62
|
"@types/cookie": "^0.6.0",
|
|
59
63
|
"@types/jsonwebtoken": "^9.0.5",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,A as p,j as e,
|
|
1
|
+
import{r as a,A as p,j as e,x as y,bt as v,B as N,p as w,C as b}from"./index-Co_SJV3n.js";import{C as c,a as d,b as k,c as C}from"./card-CuQs3dpy.js";import{B as m}from"./badge-DRyeFib9.js";import{R as E}from"./refresh-cw-qE1iNkL_.js";const A=5e3;function $(){const[n,o]=a.useState([]),[i,x]=a.useState(!0),[h,u]=a.useState(new Set),l=a.useCallback(async()=>{x(!0);try{const s=await fetch(`${p}/api/v1/events?limit=${A}`);if(!s.ok)throw new Error("Failed to load events");const t=await s.json();o(Array.isArray(t.items)?[...t.items].reverse():[])}catch(s){console.error("Failed to load events:",s),o([])}finally{x(!1)}},[]),g=a.useCallback(s=>{u(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},[]);a.useEffect(()=>{l()},[l]);const f=s=>{if(!s)return"Unknown time";try{return new Date(s).toLocaleString()}catch{return s}},j=s=>{switch(s?.toLowerCase()){case"error":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";case"warn":case"warning":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";case"info":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"debug":return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}};return i?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(y,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading events..."})]})})})]}):n.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Events Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Activity events will appear here as they occur."})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsxs("p",{className:"text-muted-foreground",children:["View system activity and events (",n.length," events)"]})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>void l(),disabled:i,children:[e.jsx(E,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`}),"Refresh"]})]}),e.jsx("div",{className:"space-y-3",children:n.map(s=>{const t=h.has(s.seq);return e.jsxs(c,{className:"transition-colors",children:[e.jsx(k,{className:"py-3 cursor-pointer hover:bg-muted/30",onClick:()=>g(s.seq),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-2 flex-1 min-w-0",children:[t?e.jsx(w,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}):e.jsx(b,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(C,{className:"text-sm font-medium",children:["#",s.seq]}),s.kind&&e.jsx(m,{variant:"outline",className:"text-xs",children:s.kind}),s.level&&e.jsx(m,{className:`text-xs ${j(s.level)}`,children:s.level})]}),s.message&&e.jsx("p",{className:`text-sm text-muted-foreground ${t?"":"truncate"}`,children:s.message})]})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:f(s.ts)})]})}),t&&e.jsx(d,{className:"pt-0 pb-4",children:e.jsx("pre",{className:"text-xs bg-muted p-3 rounded-md overflow-x-auto",children:JSON.stringify(s,null,2)})})]},s.seq)})})]})}export{$ as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{w as R,r as t,b1 as y,j as e,B as a,P as X,b2 as Y,O as J,D as j,b as g,d as v,f,g as A,I as F,a1 as N,ai as W,y as i}from"./index-Co_SJV3n.js";import{C as G,b as Q,c as V,d as Z,a as _}from"./card-CuQs3dpy.js";import{L as w}from"./label-h5GIKGcJ.js";import{B as ee}from"./badge-DRyeFib9.js";import{A as I,a as C}from"./alert-BqZa-crG.js";import{I as L}from"./info-CzKk8mbR.js";import{C as se}from"./circle-alert-ewz28SE3.js";function oe(){const{authEnabled:n}=R(),[P,k]=t.useState([]),[b,K]=t.useState(!0),[O,l]=t.useState(!1),[M,d]=t.useState(!1),[x,D]=t.useState(""),[h,E]=t.useState("never"),[c,S]=t.useState(null),[m,o]=t.useState(null);t.useEffect(()=>{p()},[]);const p=async()=>{K(!0);try{const s=await y("/api/v1/api-keys");s.success&&k(s.data?.apiKeys||[])}catch(s){console.error("Failed to load API keys:",s),k([])}finally{K(!1)}},U=async()=>{if(!x.trim()){i({title:"Error",description:"Please provide a name for the API key",variant:"destructive"});return}try{const s={name:x,scopes:["*"]};h!=="never"&&(s.expiresIn=h);const r=await y("/api/v1/api-keys",{method:"POST",body:JSON.stringify(s)});r.success&&(S(r.data),l(!1),d(!0),D(""),E("never"),await p(),i({title:"API Key Created",description:"Make sure to copy your API key now. You won't be able to see it again!"}))}catch(s){console.error("Failed to create API key:",s),i({title:"Error",description:"Failed to create API key",variant:"destructive"})}},B=async s=>{try{(await y(`/api/v1/api-keys/${s}`,{method:"DELETE"})).success&&(await p(),o(null),i({title:"API Key Deleted",description:"The API key has been permanently deleted"}))}catch(r){console.error("Failed to delete API key:",r),i({title:"Error",description:"Failed to delete API key",variant:"destructive"})}},H=async s=>{try{await navigator.clipboard.writeText(s),i({title:"Copied",description:"API key copied to clipboard"})}catch{i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},u=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),$=s=>s?new Date(s)<new Date:!1,q=typeof window<"u"?window.location.origin:"http://localhost:3000",z=c?`curl -H "X-API-Key: ${c.key}" \\
|
|
2
|
+
+ ${q}/api/v1/tasks`:"",T=n?null:e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["Authentication is currently disabled. API keys will only be required once you enable authentication in the ",e.jsx("a",{href:"/settings/authentication",className:"underline",children:"Authentication settings"}),"."]})]});return!n&&b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access"})]}),T]}):b?e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access to your Coconut instance"})]}),T,n&&e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["API keys provide programmatic access to your Coconut instance. Use them in CI/CD pipelines or automation scripts by including the key in the ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"X-API-Key"})," header."]})]}),e.jsxs(G,{children:[e.jsx(Q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(V,{children:"Active API Keys"}),e.jsx(Z,{children:"API keys you've created for programmatic access"})]}),e.jsxs(a,{onClick:()=>l(!0),disabled:!n,children:[e.jsx(X,{className:"mr-2 h-4 w-4"}),"Create API Key"]})]})}),e.jsx(_,{children:P.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Y,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{children:"No API keys yet"}),e.jsx("p",{className:"text-sm",children:"Create an API key to get started with programmatic access"})]}):e.jsx("div",{className:"space-y-4",children:P.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"font-medium",children:s.name}),$(s.expiresAt)&&e.jsx(ee,{variant:"destructive",children:"Expired"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:s.keyPreview}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Created: ",u(s.createdAt)]}),s.expiresAt&&e.jsxs("span",{children:["Expires: ",u(s.expiresAt)]}),s.lastUsedAt&&e.jsxs("span",{children:["Last used: ",u(s.lastUsedAt)]})]})]}),e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>o(s.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]},s.id))})})]}),e.jsx(j,{open:O,onOpenChange:l,children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Create API Key"}),e.jsx(A,{children:"Create a new API key for programmatic access. The key will only be shown once."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyName",children:"Name"}),e.jsx(F,{id:"keyName",placeholder:"CI/CD Pipeline",value:x,onChange:s=>D(s.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A descriptive name to identify this API key"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyExpiry",children:"Expiration"}),e.jsxs("select",{id:"keyExpiry",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:h,onChange:s=>E(s.target.value),children:[e.jsx("option",{value:"never",children:"Never"}),e.jsx("option",{value:"30d",children:"30 days"}),e.jsx("option",{value:"90d",children:"90 days"}),e.jsx("option",{value:"1y",children:"1 year"})]})]})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(a,{onClick:U,disabled:!n,children:"Create API Key"})]})]})}),e.jsx(j,{open:M,onOpenChange:d,children:e.jsxs(g,{className:"sm:max-w-[600px]",children:[e.jsxs(v,{children:[e.jsx(f,{children:"API Key Created"}),e.jsx(A,{children:"Make sure to copy your API key now. You won't be able to see it again!"})]}),e.jsxs(I,{variant:"destructive",className:"my-4",children:[e.jsx(se,{className:"h-4 w-4"}),e.jsx(C,{children:"This is the only time you will see this key. Store it securely."})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"API Key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{readOnly:!0,value:c.key,className:"font-mono text-sm"}),e.jsx(a,{variant:"outline",size:"icon",onClick:()=>H(c.key),children:e.jsx(W,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"mb-2",children:"Usage example:"}),e.jsx("pre",{className:"bg-muted p-3 rounded-md whitespace-pre-wrap break-words",children:e.jsx("code",{className:"font-mono text-xs",children:z})})]})]}),e.jsx(N,{children:e.jsx(a,{onClick:()=>{d(!1),S(null)},children:"I've Saved My Key"})})]})}),e.jsx(j,{open:!!m,onOpenChange:s=>!s&&o(null),children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Delete API Key"}),e.jsx(A,{children:"Are you sure you want to delete this API key? This action cannot be undone and any scripts using this key will stop working."})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(a,{variant:"destructive",onClick:()=>m&&B(m),children:"Delete API Key"})]})]})})]})}export{oe as default};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{u as D,a as M,r as l,A as b,j as e,B as S,L as I,
|
|
2
|
-
`);k(s),f(a.content.trim())}N(!1)}).catch(t=>{console.error("Failed to load context:",t),h({title:"Error",description:"Failed to load architecture documentation",variant:"destructive"}),N(!1)})},[h]);const A=async()=>{w(!0);try{const a=await(await fetch(`${b}/api/v1/context/architecture`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:y,metadata:{stack:n.stack,commands:n.commands}})})).json();if(a.success)h({title:"Success",description:"Architecture documentation saved successfully",action:e.jsx(
|
|
3
|
-
`).filter(s=>s.trim()).forEach(s=>{const[r,...c]=s.split(":");r&&c.length>0&&(a[r.trim()]=c.join(":").trim())}),x(s=>({...s,commands:a}))};return L?e.jsx("div",{className:"space-y-6",children:e.jsx(u,{children:e.jsx(p,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Architecture"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Edit technical architecture and supporting metadata"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(S,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(I,{to:"/context/architecture",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(
|
|
1
|
+
import{u as D,a as M,r as l,A as b,j as e,B as S,L as I,a3 as _,I as d,q}from"./index-Co_SJV3n.js";import{C as u,a as p,b as j,c as v}from"./card-CuQs3dpy.js";import{L as o}from"./label-h5GIKGcJ.js";import{M as B}from"./markdown-editor-C6il4XWv.js";import{A as P}from"./arrow-left-FD3wQmzH.js";import{C as R}from"./circle-check-big-1xNuBPkR.js";function Q(){const F=D(),{toast:h}=M(),[n,x]=l.useState({stack:{runtime:"",framework:"",language:"",database:"",deployment:"",repository:""},commands:{}}),[y,f]=l.useState(""),[E,k]=l.useState(""),[L,N]=l.useState(!0),[C,w]=l.useState(!1);l.useEffect(()=>{fetch(`${b}/api/v1/context/architecture`).then(t=>t.json()).then(t=>{if(t.success){const a=t.document,m={stack:{runtime:a.metadata.stack?.runtime||"",framework:a.metadata.stack?.framework||"",language:a.metadata.stack?.language||"",database:a.metadata.stack?.database||"",deployment:a.metadata.stack?.deployment||"",repository:a.metadata.stack?.repository||""},commands:a.metadata.commands||{}};x(m);const s=Object.entries(m.commands).map(([r,c])=>`${r}: ${c}`).join(`
|
|
2
|
+
`);k(s),f(a.content.trim())}N(!1)}).catch(t=>{console.error("Failed to load context:",t),h({title:"Error",description:"Failed to load architecture documentation",variant:"destructive"}),N(!1)})},[h]);const A=async()=>{w(!0);try{const a=await(await fetch(`${b}/api/v1/context/architecture`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:y,metadata:{stack:n.stack,commands:n.commands}})})).json();if(a.success)h({title:"Success",description:"Architecture documentation saved successfully",action:e.jsx(R,{className:"h-4 w-4"})}),F("/context/architecture");else throw new Error(a.error||"Failed to save context")}catch(t){console.error("Save error:",t),h({title:"Error",description:"Failed to save architecture documentation",variant:"destructive"})}finally{w(!1)}},i=(t,a)=>{x(m=>{const s={...m},r=t.split(".");let c=s;for(let g=0;g<r.length-1;g++)c=c[r[g]];return c[r[r.length-1]]=a,s})},T=t=>{k(t);const a={};t.split(`
|
|
3
|
+
`).filter(s=>s.trim()).forEach(s=>{const[r,...c]=s.split(":");r&&c.length>0&&(a[r.trim()]=c.join(":").trim())}),x(s=>({...s,commands:a}))};return L?e.jsx("div",{className:"space-y-6",children:e.jsx(u,{children:e.jsx(p,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Architecture"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Edit technical architecture and supporting metadata"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(S,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(I,{to:"/context/architecture",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(P,{className:"w-4 h-4"})})}),e.jsxs(S,{onClick:A,disabled:C,size:"sm",children:[e.jsx(_,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:C?"Saving...":"Save"})]})]})]}),e.jsxs(u,{children:[e.jsx(j,{children:e.jsx(v,{children:"Technology Stack"})}),e.jsxs(p,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"runtime",children:"Runtime"}),e.jsx(d,{id:"runtime",value:n.stack.runtime,onChange:t=>i("stack.runtime",t.target.value),placeholder:"node|python|go|etc"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"framework",children:"Framework"}),e.jsx(d,{id:"framework",value:n.stack.framework,onChange:t=>i("stack.framework",t.target.value),placeholder:"express|fastify|django|gin|etc"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"language",children:"Language"}),e.jsx(d,{id:"language",value:n.stack.language,onChange:t=>i("stack.language",t.target.value),placeholder:"typescript|javascript|python|go|etc"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"database",children:"Database"}),e.jsx(d,{id:"database",value:n.stack.database,onChange:t=>i("stack.database",t.target.value),placeholder:"postgresql|mysql|mongodb|sqlite|etc"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"deployment",children:"Deployment"}),e.jsx(d,{id:"deployment",value:n.stack.deployment,onChange:t=>i("stack.deployment",t.target.value),placeholder:"docker|kubernetes|vercel|aws|etc"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"repository",children:"Repository"}),e.jsx(d,{id:"repository",value:n.stack.repository,onChange:t=>i("stack.repository",t.target.value),placeholder:"https://github.com/yourorg/yourproject"})]})]})]})]}),e.jsxs(u,{children:[e.jsx(j,{children:e.jsx(v,{children:"Quick Commands"})}),e.jsx(p,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"commands",children:"Commands (format: command_name: command_to_run)"}),e.jsx(q,{id:"commands",value:E,onChange:t=>T(t.target.value),placeholder:`install: npm install
|
|
4
4
|
dev: npm run dev
|
|
5
5
|
test: npm test
|
|
6
6
|
build: npm run build
|
|
7
|
-
deploy: npm run deploy`,rows:4})]})})]}),e.jsxs(u,{children:[e.jsx(j,{children:e.jsx(v,{children:"Architecture Documentation"})}),e.jsx(p,{children:e.jsx(
|
|
7
|
+
deploy: npm run deploy`,rows:4})]})})]}),e.jsxs(u,{children:[e.jsx(j,{children:e.jsx(v,{children:"Architecture Documentation"})}),e.jsx(p,{children:e.jsx(B,{value:y,onChange:t=>f(t||""),placeholder:`Write your architecture documentation in markdown...
|
|
8
8
|
|
|
9
9
|
## System Design
|
|
10
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g,r as n,A as v,j as e,
|
|
1
|
+
import{a as g,r as n,A as v,j as e,x as y,F as k,B as l,M as b,ax as w,L as C,H as E,au as A}from"./index-Co_SJV3n.js";import{C as a,a as c,b as o,c as m}from"./card-CuQs3dpy.js";import{c as D}from"./clipboard-B9ndUJKl.js";function S(){const{toast:h}=g(),[r,x]=n.useState(null),[u,p]=n.useState(!0),[j,i]=n.useState(!1);n.useEffect(()=>{fetch(`${v}/api/v1/context/architecture`).then(t=>{if(t.ok)return t.json();throw new Error("Not found")}).then(t=>{t.success?(x(t.document),i(!0)):i(!1)}).catch(()=>{i(!1)}).finally(()=>{p(!1)})},[]);const N=async()=>{const t=".nut/context/architecture.md";try{await D(t),h({title:"Copied!",description:`Path ${t} copied to clipboard`})}catch(d){console.error("Failed to copy path:",d),h({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},f=()=>{const t=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"architecture-md",filename:"architecture.md",name:"architecture.md",path:".nut/context/architecture.md"}});window.dispatchEvent(t)};if(u)return e.jsx("div",{className:"space-y-6",children:e.jsx(a,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(y,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading architecture documentation..."})]})})})});if(!j||!r)return e.jsx("div",{className:"space-y-6",children:e.jsx(a,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Architecture Documentation Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Architecture documentation will appear here once created."})]})})})});const s=r.metadata;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Technical Architecture"}),e.jsx("p",{className:"text-muted-foreground",children:"System design, components, and technical patterns"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:f,children:[e.jsx(b,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(l,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(l,{size:"sm",asChild:!0,children:e.jsxs(C,{to:"/context/architecture/edit",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),s&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(a,{children:[e.jsx(o,{className:"pb-3",children:e.jsx(m,{className:"text-lg font-semibold",children:"Technology Stack"})}),e.jsx(c,{className:"space-y-3",children:s.stack&&e.jsxs("div",{className:"space-y-1 text-sm",children:[s.stack.runtime&&e.jsxs("div",{children:["Runtime: ",s.stack.runtime]}),s.stack.framework&&e.jsxs("div",{children:["Framework: ",s.stack.framework]}),s.stack.language&&e.jsxs("div",{children:["Language: ",s.stack.language]}),s.stack.database&&e.jsxs("div",{children:["Database: ",s.stack.database]}),s.stack.deployment&&e.jsxs("div",{children:["Deployment: ",s.stack.deployment]}),s.stack.repository&&e.jsxs("div",{children:["Repository:"," ",e.jsx("a",{href:s.stack.repository,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:s.stack.repository})]})]})})]}),e.jsxs(a,{children:[e.jsx(o,{className:"pb-3",children:e.jsx(m,{className:"text-lg font-semibold",children:"Quick Commands"})}),e.jsx(c,{className:"space-y-3",children:s.commands&&e.jsxs("div",{className:"space-y-1",children:[Object.entries(s.commands).slice(0,5).map(([t,d])=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("span",{className:"font-medium capitalize",children:[t,": "]}),e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-xs",children:d})]},t)),Object.entries(s.commands).length>5&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["+ ",Object.entries(s.commands).length-5," more commands"]})]})})]})]}),e.jsxs(a,{children:[e.jsx(o,{children:e.jsx(m,{className:"text-lg font-semibold",children:"Architecture Documentation"})}),e.jsx(c,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(A,{children:r.content||"No content available"})})})]})]})}export{S as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Y,
|
|
1
|
+
import{c as Y,w as le,r as n,b1 as c,j as e,a2 as O,i as ce,D as I,a0 as M,B as l,b as V,d as $,f as J,g as H,I as j,a1 as _,J as oe,N as de,O as he,Q as ue,R as xe,U as me,V as ge,W as je,Y as pe,Z as ve,y as r}from"./index-Co_SJV3n.js";import{C as p,b as v,c as w,d as f,a as y}from"./card-CuQs3dpy.js";import{L as o}from"./label-h5GIKGcJ.js";import{S as z,a as W,b as q,c as B,d as a}from"./select-DylRS99W.js";import{S as U}from"./switch-CsB3wpq9.js";import{B as k}from"./badge-DRyeFib9.js";import{C as we}from"./circle-alert-ewz28SE3.js";import"./chevron-up-DreyvhRd.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{c as Y,H as le,r as n,b6 as c,j as e,a7 as I,o as ce,D as O,a5 as $,B as
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ne=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Se=Y("user-plus",Ne);function Fe(){const{user:N,authEnabled:K,checkAuthStatus:Z}=le(),[i,d]=n.useState(null),[G,F]=n.useState(!0),[S,D]=n.useState(!1),[Q,C]=n.useState(!1),[b,P]=n.useState(""),[A,R]=n.useState(""),[T,L]=n.useState("viewer"),[E,u]=n.useState(null),[x,m]=n.useState(""),X=!K||N?.role==="admin";n.useEffect(()=>{h()},[]);const h=async()=>{try{F(!0);const s=await c("/api/v1/auth-settings");s.success?d(s.data):d(null)}catch(s){console.error("Failed to load auth settings:",s),d(null)}finally{F(!1)}},ee=async()=>{if(!i)return;const s=!i.enabled;try{const t=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({enabled:s})});if(t.success)d({...i,enabled:s}),await Z(),r({title:"Success",description:`Authentication ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to toggle auth")}catch(t){r({title:"Error",description:t.message||"Failed to toggle authentication",variant:"destructive"})}},se=async()=>{if(!i)return;const s=!i.allowRegistration;try{const t=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({allowRegistration:s})});if(t.success)d({...i,allowRegistration:s}),r({title:"Success",description:`Self-registration ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to update setting")}catch(t){r({title:"Error",description:t.message||"Failed to update setting",variant:"destructive"})}},te=async()=>{if(!b||!A){r({title:"Error",description:"Please provide email and name",variant:"destructive"});return}try{const s=await c("/api/v1/auth-settings/users",{method:"POST",body:JSON.stringify({email:b,name:A,role:T})});if(s.success)await h(),C(!1),P(""),R(""),L("viewer"),r({title:"Success",description:"User added to whitelist"});else throw new Error(s.error||"Failed to add user")}catch(s){r({title:"Error",description:s.message||"Failed to add user",variant:"destructive"})}},ie=async s=>{try{const t=await c(`/api/v1/auth-settings/users/${s}`,{method:"DELETE"});if(t.success)await h(),r({title:"Success",description:"User removed from whitelist"});else throw new Error(t.error||"Failed to remove user")}catch(t){r({title:"Error",description:t.message||"Failed to remove user",variant:"destructive"})}},re=async(s,t)=>{try{const g=await c(`/api/v1/auth-settings/users/${s}`,{method:"PUT",body:JSON.stringify({role:t})});if(g.success)await h(),r({title:"Success",description:"User role updated"});else throw new Error(g.error||"Failed to update role")}catch(g){r({title:"Error",description:g.message||"Failed to update role",variant:"destructive"})}},ae=async()=>{if(!(!E||!x)){if(x.length<8){r({title:"Error",description:"Password must be at least 8 characters",variant:"destructive"});return}try{const s=await c(`/api/v1/auth-settings/users/${E}/reset-password`,{method:"POST",body:JSON.stringify({newPassword:x})});if(s.success)u(null),m(""),r({title:"Success",description:"Password reset successfully"});else throw new Error(s.error||"Failed to reset password")}catch(s){r({title:"Error",description:s.message||"Failed to reset password",variant:"destructive"})}}},ne=async()=>{if(i)try{D(!0);const s=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({session:i.session})});if(s.success)r({title:"Success",description:"Session settings updated"});else throw new Error(s.error||"Failed to update settings")}catch(s){r({title:"Error",description:s.message||"Failed to update settings",variant:"destructive"})}finally{D(!1)}};return G?e.jsx("div",{children:"Loading..."}):i?X?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage authentication settings and user access."})]}),e.jsx(I,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),e.jsx(w,{children:"Authentication Status"})]}),e.jsx(f,{children:"Control whether authentication is required to access Coconut."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"auth-enabled",children:"Require Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When enabled, users must log in to access Coconut"})]}),e.jsx(U,{id:"auth-enabled",checked:i.enabled,onCheckedChange:ee})]}),i.enabled&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"allow-registration",children:"Allow Self-Registration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Whitelisted users can create their own accounts"})]}),e.jsx(U,{id:"allow-registration",checked:i.allowRegistration,onCheckedChange:se})]})]})]}),e.jsxs(p,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(w,{children:"Whitelisted Users"}),e.jsx(f,{children:"Manage users who can access this Coconut instance."})]}),e.jsxs(O,{open:Q,onOpenChange:C,children:[e.jsx($,{asChild:!0,children:e.jsxs(l,{size:"sm",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Add User"]})}),e.jsxs(M,{children:[e.jsxs(V,{children:[e.jsx(H,{children:"Add User to Whitelist"}),e.jsx(_,{children:"Add a user's email to allow them to register and access Coconut."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-email",children:"Email"}),e.jsx(j,{id:"new-email",type:"email",value:b,onChange:s=>P(s.target.value),placeholder:"user@example.com"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-name",children:"Name"}),e.jsx(j,{id:"new-name",value:A,onChange:s=>R(s.target.value),placeholder:"User Name"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-role",children:"Role"}),e.jsxs(J,{value:T,onValueChange:s=>L(s),children:[e.jsx(z,{children:e.jsx(W,{})}),e.jsxs(q,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]})]})]}),e.jsxs(B,{children:[e.jsx(l,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(l,{onClick:te,children:"Add User"})]})]})]})]})}),e.jsx(y,{children:e.jsx("div",{className:"space-y-4",children:i.providers.local.users.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:s.name}),s.registered?e.jsx(k,{variant:"default",className:"text-xs",children:"Registered"}):e.jsx(k,{variant:"secondary",className:"text-xs",children:"Pending"}),s.id===N?.id&&e.jsx(k,{variant:"outline",className:"text-xs",children:"You"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email}),s.lastLoginAt&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last login: ",new Date(s.lastLoginAt).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(J,{value:s.role,onValueChange:t=>re(s.id,t),children:[e.jsx(z,{className:"w-40",children:e.jsx(W,{})}),e.jsxs(q,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]}),e.jsxs(O,{open:E===s.id,onOpenChange:t=>{t||(u(null),m(""))},children:[e.jsx($,{asChild:!0,children:e.jsx(l,{size:"sm",variant:"outline",onClick:()=>u(s.id),children:e.jsx(ye,{className:"h-4 w-4"})})}),e.jsxs(M,{children:[e.jsxs(V,{children:[e.jsx(H,{children:"Reset Password"}),e.jsxs(_,{children:["Set a new password for ",s.name]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{children:[e.jsx(o,{htmlFor:"reset-password",children:"New Password"}),e.jsx(j,{id:"reset-password",type:"password",value:x,onChange:t=>m(t.target.value),placeholder:"At least 8 characters",minLength:8})]})}),e.jsxs(B,{children:[e.jsx(l,{variant:"outline",onClick:()=>{u(null),m("")},children:"Cancel"}),e.jsx(l,{onClick:ae,children:"Reset Password"})]})]})]}),s.id!==N?.id&&e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(l,{size:"sm",variant:"destructive",children:e.jsx(he,{className:"h-4 w-4"})})}),e.jsxs(ue,{children:[e.jsxs(xe,{children:[e.jsx(me,{children:"Remove User"}),e.jsxs(ge,{children:["Are you sure you want to remove ",s.name," from the whitelist? They will no longer be able to access Coconut."]})]}),e.jsxs(je,{children:[e.jsx(pe,{children:"Cancel"}),e.jsx(ve,{onClick:()=>ie(s.id),children:"Remove"})]})]})]})]})]},s.id))})})]}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsx(w,{children:"Session Settings"}),e.jsx(f,{children:"Configure session behavior and security."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"session-expiry",children:"Session Expiry"}),e.jsx(j,{id:"session-expiry",value:i.session.expiresIn,onChange:s=>d({...i,session:{...i.session,expiresIn:s.target.value}}),placeholder:"7d"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Format: 30s, 15m, 24h, 7d"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"secure-cookies",children:"Secure Cookies (HTTPS only)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable in production with HTTPS"})]}),e.jsx(U,{id:"secure-cookies",checked:i.session.secure||!1,onCheckedChange:s=>d({...i,session:{...i.session,secure:s}})})]})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",onClick:h,disabled:S,children:"Cancel"}),e.jsx(l,{onClick:ne,disabled:S,children:S?"Saving...":"Save Session Settings"})]})]}):e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have permission to manage authentication settings."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Secure your Coconut instance with authentication."})]}),e.jsx(I,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-5 w-5 text-muted-foreground"}),e.jsx(w,{children:"Authentication Not Configured"})]}),e.jsx(f,{children:"Authentication has not been initialized. Use the CLI to set up authentication."})]}),e.jsxs(y,{children:[e.jsx("div",{className:"bg-muted p-4 rounded-md",children:e.jsxs("code",{className:"text-sm",children:["$ nut auth init",e.jsx("br",{}),"$ nut auth toggle"]})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"This will create an admin user and enable authentication for your Coconut instance."})]})]})]})}export{Fe as default};
|
|
11
|
+
*/const Ne=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Se=Y("user-plus",Ne);function Pe(){const{user:N,authEnabled:K,checkAuthStatus:Q}=le(),[i,d]=n.useState(null),[Z,F]=n.useState(!0),[S,D]=n.useState(!1),[G,C]=n.useState(!1),[b,P]=n.useState(""),[A,R]=n.useState(""),[T,L]=n.useState("viewer"),[E,u]=n.useState(null),[x,m]=n.useState(""),X=!K||N?.role==="admin";n.useEffect(()=>{h()},[]);const h=async()=>{try{F(!0);const s=await c("/api/v1/auth-settings");s.success?d(s.data):d(null)}catch(s){console.error("Failed to load auth settings:",s),d(null)}finally{F(!1)}},ee=async()=>{if(!i)return;const s=!i.enabled;try{const t=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({enabled:s})});if(t.success)d({...i,enabled:s}),await Q(),r({title:"Success",description:`Authentication ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to toggle auth")}catch(t){r({title:"Error",description:t.message||"Failed to toggle authentication",variant:"destructive"})}},se=async()=>{if(!i)return;const s=!i.allowRegistration;try{const t=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({allowRegistration:s})});if(t.success)d({...i,allowRegistration:s}),r({title:"Success",description:`Self-registration ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to update setting")}catch(t){r({title:"Error",description:t.message||"Failed to update setting",variant:"destructive"})}},te=async()=>{if(!b||!A){r({title:"Error",description:"Please provide email and name",variant:"destructive"});return}try{const s=await c("/api/v1/auth-settings/users",{method:"POST",body:JSON.stringify({email:b,name:A,role:T})});if(s.success)await h(),C(!1),P(""),R(""),L("viewer"),r({title:"Success",description:"User added to whitelist"});else throw new Error(s.error||"Failed to add user")}catch(s){r({title:"Error",description:s.message||"Failed to add user",variant:"destructive"})}},ie=async s=>{try{const t=await c(`/api/v1/auth-settings/users/${s}`,{method:"DELETE"});if(t.success)await h(),r({title:"Success",description:"User removed from whitelist"});else throw new Error(t.error||"Failed to remove user")}catch(t){r({title:"Error",description:t.message||"Failed to remove user",variant:"destructive"})}},re=async(s,t)=>{try{const g=await c(`/api/v1/auth-settings/users/${s}`,{method:"PUT",body:JSON.stringify({role:t})});if(g.success)await h(),r({title:"Success",description:"User role updated"});else throw new Error(g.error||"Failed to update role")}catch(g){r({title:"Error",description:g.message||"Failed to update role",variant:"destructive"})}},ae=async()=>{if(!(!E||!x)){if(x.length<8){r({title:"Error",description:"Password must be at least 8 characters",variant:"destructive"});return}try{const s=await c(`/api/v1/auth-settings/users/${E}/reset-password`,{method:"POST",body:JSON.stringify({newPassword:x})});if(s.success)u(null),m(""),r({title:"Success",description:"Password reset successfully"});else throw new Error(s.error||"Failed to reset password")}catch(s){r({title:"Error",description:s.message||"Failed to reset password",variant:"destructive"})}}},ne=async()=>{if(i)try{D(!0);const s=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({session:i.session})});if(s.success)r({title:"Success",description:"Session settings updated"});else throw new Error(s.error||"Failed to update settings")}catch(s){r({title:"Error",description:s.message||"Failed to update settings",variant:"destructive"})}finally{D(!1)}};return Z?e.jsx("div",{children:"Loading..."}):i?X?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage authentication settings and user access."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),e.jsx(w,{children:"Authentication Status"})]}),e.jsx(f,{children:"Control whether authentication is required to access Coconut."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"auth-enabled",children:"Require Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When enabled, users must log in to access Coconut"})]}),e.jsx(U,{id:"auth-enabled",checked:i.enabled,onCheckedChange:ee})]}),i.enabled&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"allow-registration",children:"Allow Self-Registration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Whitelisted users can create their own accounts"})]}),e.jsx(U,{id:"allow-registration",checked:i.allowRegistration,onCheckedChange:se})]})]})]}),e.jsxs(p,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(w,{children:"Whitelisted Users"}),e.jsx(f,{children:"Manage users who can access this Coconut instance."})]}),e.jsxs(I,{open:G,onOpenChange:C,children:[e.jsx(M,{asChild:!0,children:e.jsxs(l,{size:"sm",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Add User"]})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(J,{children:"Add User to Whitelist"}),e.jsx(H,{children:"Add a user's email to allow them to register and access Coconut."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-email",children:"Email"}),e.jsx(j,{id:"new-email",type:"email",value:b,onChange:s=>P(s.target.value),placeholder:"user@example.com"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-name",children:"Name"}),e.jsx(j,{id:"new-name",value:A,onChange:s=>R(s.target.value),placeholder:"User Name"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-role",children:"Role"}),e.jsxs(z,{value:T,onValueChange:s=>L(s),children:[e.jsx(W,{children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]})]})]}),e.jsxs(_,{children:[e.jsx(l,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(l,{onClick:te,children:"Add User"})]})]})]})]})}),e.jsx(y,{children:e.jsx("div",{className:"space-y-4",children:i.providers.local.users.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:s.name}),s.registered?e.jsx(k,{variant:"default",className:"text-xs",children:"Registered"}):e.jsx(k,{variant:"secondary",className:"text-xs",children:"Pending"}),s.id===N?.id&&e.jsx(k,{variant:"outline",className:"text-xs",children:"You"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email}),s.lastLoginAt&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last login: ",new Date(s.lastLoginAt).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z,{value:s.role,onValueChange:t=>re(s.id,t),children:[e.jsx(W,{className:"w-40",children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]}),e.jsxs(I,{open:E===s.id,onOpenChange:t=>{t||(u(null),m(""))},children:[e.jsx(M,{asChild:!0,children:e.jsx(l,{size:"sm",variant:"outline",onClick:()=>u(s.id),children:e.jsx(ye,{className:"h-4 w-4"})})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(J,{children:"Reset Password"}),e.jsxs(H,{children:["Set a new password for ",s.name]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{children:[e.jsx(o,{htmlFor:"reset-password",children:"New Password"}),e.jsx(j,{id:"reset-password",type:"password",value:x,onChange:t=>m(t.target.value),placeholder:"At least 8 characters",minLength:8})]})}),e.jsxs(_,{children:[e.jsx(l,{variant:"outline",onClick:()=>{u(null),m("")},children:"Cancel"}),e.jsx(l,{onClick:ae,children:"Reset Password"})]})]})]}),s.id!==N?.id&&e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(l,{size:"sm",variant:"destructive",children:e.jsx(he,{className:"h-4 w-4"})})}),e.jsxs(ue,{children:[e.jsxs(xe,{children:[e.jsx(me,{children:"Remove User"}),e.jsxs(ge,{children:["Are you sure you want to remove ",s.name," from the whitelist? They will no longer be able to access Coconut."]})]}),e.jsxs(je,{children:[e.jsx(pe,{children:"Cancel"}),e.jsx(ve,{onClick:()=>ie(s.id),children:"Remove"})]})]})]})]})]},s.id))})})]}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsx(w,{children:"Session Settings"}),e.jsx(f,{children:"Configure session behavior and security."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"session-expiry",children:"Session Expiry"}),e.jsx(j,{id:"session-expiry",value:i.session.expiresIn,onChange:s=>d({...i,session:{...i.session,expiresIn:s.target.value}}),placeholder:"7d"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Format: 30s, 15m, 24h, 7d"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"secure-cookies",children:"Secure Cookies (HTTPS only)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable in production with HTTPS"})]}),e.jsx(U,{id:"secure-cookies",checked:i.session.secure||!1,onCheckedChange:s=>d({...i,session:{...i.session,secure:s}})})]})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",onClick:h,disabled:S,children:"Cancel"}),e.jsx(l,{onClick:ne,disabled:S,children:S?"Saving...":"Save Session Settings"})]})]}):e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have permission to manage authentication settings."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Secure your Coconut instance with authentication."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-5 w-5 text-muted-foreground"}),e.jsx(w,{children:"Authentication Not Configured"})]}),e.jsx(f,{children:"Authentication has not been initialized. Use the CLI to set up authentication."})]}),e.jsxs(y,{children:[e.jsx("div",{className:"bg-muted p-4 rounded-md",children:e.jsxs("code",{className:"text-sm",children:["$ nut auth init",e.jsx("br",{}),"$ nut auth toggle"]})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"This will create an admin user and enable authentication for your Coconut instance."})]})]})]})}export{Pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,j as e,
|
|
1
|
+
import{r as m,j as e,x as p,A as f}from"./index-Co_SJV3n.js";import{C as w}from"./circle-check-2TuD-EHs.js";import{C as b}from"./circle-x-B_d4wjG-.js";const r="coconut/github-auth-state";function j(s){try{window.opener&&window.opener.postMessage({type:"github-auth",...s},window.location.origin)}catch{}}const v=()=>{const[s,d]=m.useState("pending"),[h,x]=m.useState("Authorizing GitHub…");return m.useEffect(()=>{const a=new URLSearchParams(window.location.search),u=a.get("error"),l=a.get("token"),n=a.get("expires_at")||a.get("expiresAt"),c=a.get("state"),o=t=>{j(t),d(t.success?"success":"error"),x(t.message),setTimeout(()=>{try{window.close()}catch{}},1200)};if(u){localStorage.removeItem(r),o({success:!1,message:decodeURIComponent(u)});return}if(!l||!n||!c){localStorage.removeItem(r),o({success:!1,message:"Missing authorization parameters. Please try again."});return}const g=localStorage.getItem(r);if(!g||g!==c){localStorage.removeItem(r),o({success:!1,message:"Authorization state mismatch. Please start again."});return}(async()=>{try{const t=await fetch(`${f}/api/v1/git/providers/github/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:l,expiresAt:n,state:c})}),i=await t.json();if(!t.ok||!i.success)throw new Error(i?.error?.message||"Failed to store GitHub token");localStorage.removeItem(r),o({success:!0,message:"GitHub connected successfully!",expiresAt:i.data?.expiresAt||n})}catch(t){localStorage.removeItem(r),o({success:!1,message:t?.message||"Failed to store GitHub token. Please try again."})}})()},[]),e.jsx("div",{className:"flex h-screen items-center justify-center bg-background px-6",children:e.jsxs("div",{className:"max-w-sm rounded-lg border bg-card p-6 text-center shadow-sm",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:[s==="pending"&&e.jsx(p,{className:"h-6 w-6 animate-spin text-muted-foreground"}),s==="success"&&e.jsx(w,{className:"h-6 w-6 text-green-600"}),s==="error"&&e.jsx(b,{className:"h-6 w-6 text-red-600"})]}),e.jsx("h1",{className:"text-lg font-semibold",children:"GitHub Authorization"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:h}),s!=="pending"&&e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"You can close this window and return to Coconut."})]})})};export{v as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as ce,a as de,r as i,j as e,B as l,l as oe,T as me,p as M,X as xe,F as he,H as ue,D as fe,b as pe,d as je,f as ge,k as ve,a5 as B,a6 as R,a7 as H,a8 as L,a9 as O,ad as G,ac as Ne,q as ye,A as T}from"./index-Co_SJV3n.js";import{C as g,b as we,a as _,c as Se}from"./card-CuQs3dpy.js";import{B as U}from"./badge-DRyeFib9.js";import{u as Ce}from"./use-terminal-T_tdJTCU.js";import{T as be}from"./terminal-preview-CfOb7xMx.js";import{S as ke,a as Ae,b as De,c as Me,d as C}from"./select-DylRS99W.js";import{b as Te,d as Ie,c as $e,a as Ee}from"./droid-GYYyVzN-.js";import{R as Pe}from"./refresh-cw-qE1iNkL_.js";import{C as ze,a as Fe}from"./chevrons-up-CsAkc9vE.js";import{P as Be}from"./play-CGsVQUJG.js";import{C as Re}from"./chevron-up-DreyvhRd.js";import"./xterm-DTxiCjtJ.js";const He=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function Ye(){const c=ce(),{sessions:x,loading:b,error:I,refreshSessions:w,createSession:V,destroySession:q}=Ce(),{toast:v}=de(),[$,W]=i.useState([]),[X,J]=i.useState(!0),[p,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[j,K]=i.useState("claude"),[E,Q]=i.useState(""),[D,P]=i.useState(!1),[h,Y]=i.useState([]),[f,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,S]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const r=Math.floor(d/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${T}/api/v1/tasks`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading tasks:",t)}finally{J(!1)}})()},[]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${T}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${T}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(r=>({id:r.id,name:r?.metadata?.name||r.id,mcpServers:He(r?.metadata?.metadata?.mcpServers)}));se(d),S(r=>r.filter(F=>d.some(re=>re.id===F)))}}catch(t){console.error("Failed to load skills",t)}})()},[A]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(r=>r.id===n);d&&d.mcpServers.forEach(r=>{(!a||a.has(r))&&t.add(r)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.taskId?.startsWith("cp-")||s.taskId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{k(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>$.filter(s=>s.status==="draft"||s.status==="ready").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[$]),ae=()=>{const s=m.every(a=>p[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>p[s.id]),ne=async s=>{await q(s)?(v({title:"Session closed",description:s}),setTimeout(()=>w(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},le=async()=>{P(!0);try{const s=`session-${Date.now()}`,t={taskId:s,contextType:"change-task",cliAgent:j,mcpServersMap:Z,selectedMcpServers:f,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";j==="claude"?a=Te(t):j==="gemini"?a=Ie(t):j==="codex"?a=$e(t):j==="droid"&&(a=Ee(t)),await V(s,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage agents and their active sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>w(),disabled:b,children:[e.jsx(Pe,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(l,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(l,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),I&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:I})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(g,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(oe,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/tasks"),className:"text-primary hover:underline font-medium",children:"New Task"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(g,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(l,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":p[s.id]?"Hide preview":"Show preview",title:p[s.id]?"Hide preview":"Show preview",children:p[s.id]?e.jsx(Re,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.taskId}`),children:"Open"}),e.jsx(l,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(xe,{className:"h-4 w-4"})})]})]}),p[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(be,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"New Tasks"}),X?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(g,{children:e.jsx(we,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(g,{children:e.jsx(_,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved tasks found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(g,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(_,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Se,{className:"text-base leading-tight",children:s.title||s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
|
|
2
|
+
`).slice(0,2).join(" ").substring(0,150),s.content.length>150?"...":""]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.id," • by ",s.author.name," • ",new Date(s.metadata.createdAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",onClick:t=>t.stopPropagation(),children:[e.jsxs(l,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(he,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(fe,{open:A,onOpenChange:N,children:e.jsxs(pe,{className:"max-w-lg",children:[e.jsxs(je,{children:[e.jsx(ge,{children:"Start Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive session"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Agent"}),e.jsxs(ke,{value:j,onValueChange:s=>K(s),children:[e.jsx(Ae,{className:"w-full",children:e.jsx(De,{placeholder:"Select coding agent"})}),e.jsxs(Me,{children:[e.jsx(C,{value:"claude",children:"Claude Code"}),e.jsx(C,{value:"gemini",children:"Google Gemini"}),e.jsx(C,{value:"codex",children:"OpenAI Codex"}),e.jsx(C,{value:"droid",children:"Factory Droid"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[o.length," of ",u.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(l,{variant:"outline",className:"w-full justify-between",children:[o.length===0?"Select skills...":o.length===u.length?"All skills selected":`${o.length} skill${o.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),S(u.map(t=>t.id))},children:"All"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),S([])},children:"None"})]})]}),e.jsx(O,{}),u.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):u.map(s=>e.jsx(G,{checked:o.includes(s.id),onCheckedChange:t=>{S(a=>t?a.includes(s.id)?a:[...a,s.id]:a.filter(n=>n!==s.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.name}),s.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.mcpServers.join(", ")]}),s.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[f.length," of ",h.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(l,{variant:"outline",className:"w-full justify-between",children:[f.length===0?"Select MCP servers...":f.length===h.length?"All servers selected":`${f.length} server${f.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(O,{}),h.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):h.map(s=>e.jsx(G,{checked:f.includes(s),onCheckedChange:t=>{y(a=>t?a.includes(s)?a:[...a,s]:a.filter(n=>n!==s))},children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Additional Instructions (optional)"}),e.jsx(ye,{value:E,onChange:s=>Q(s.target.value),placeholder:"Add any custom instructions for the coding agent...",rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(l,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(l,{onClick:le,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{Ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,e as a,
|
|
1
|
+
import{r as x,j as e,e as a,p as m}from"./index-Co_SJV3n.js";function u({title:r,description:t,icon:n,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[n,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:r}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};
|