@lovelybunch/api 1.0.71-alpha.1 → 1.0.71-alpha.3
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/file-validation.d.ts +65 -0
- package/dist/lib/file-validation.js +125 -0
- package/dist/middleware/auth.d.ts +1 -0
- package/dist/middleware/auth.js +13 -3
- 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/status/route.d.ts +1 -1
- package/dist/routes/api/v1/proposals/[id]/route.d.ts +8 -8
- package/dist/routes/api/v1/resources/route.js +10 -7
- package/package.json +5 -4
- package/static/assets/AgentDetailPage-DVDnvYcy.js +1 -0
- package/static/assets/AgentEditPage-DRLTkdIZ.js +1 -0
- package/static/assets/AgentsPage-CVoYisFq.js +3 -0
- package/static/assets/AgentsSettingsPage-D9FDJHpC.js +6 -0
- package/static/assets/ApiKeysSettingsPage-DGcz0E10.js +7 -0
- package/static/assets/ArchitectureEditPage-PXH0HtcY.js +21 -0
- package/static/assets/ArchitecturePage-BiybPTif.js +1 -0
- package/static/assets/AuthSettingsPage-6TaOiZV7.js +11 -0
- package/static/assets/CallbackPage-BdZglBBj.js +1 -0
- package/static/assets/CodePage-B239DtM2.js +2 -0
- package/static/assets/CollapsibleSection-DaqBpCe-.js +1 -0
- package/static/assets/DashboardPage-B2FJcHVR.js +11 -0
- package/static/assets/GitPage-DaWE2Q-b.js +16 -0
- package/static/assets/GitSettingsPage-bTqUr0fn.js +6 -0
- package/static/assets/IdentityPage-eXzMXYy2.js +11 -0
- package/static/assets/ImplementationStepsEditor-CuDeossU.js +6 -0
- package/static/assets/IntegrationsSettingsPage-wAf_7nar.js +1 -0
- package/static/assets/KnowledgeDetailPage-B5ieYIze.js +1 -0
- package/static/assets/KnowledgeEditPage-OMUREl1n.js +1 -0
- package/static/assets/KnowledgePage-CKtcok1N.js +8 -0
- package/static/assets/LoginPage-B70_aCBv.js +1 -0
- package/static/assets/McpSettingsPage-DcJIlHEi.js +1 -0
- package/static/assets/NewAgentPage-DITLLDez.js +1 -0
- package/static/assets/NewKnowledgePage-C7vEg4PR.js +9 -0
- package/static/assets/NewProposalPage-z8wqyXIj.js +90 -0
- package/static/assets/ProjectEditPage-BDj8GlD_.js +11 -0
- package/static/assets/ProjectPage-CtoKV0l9.js +1 -0
- package/static/assets/PromptsSettingsPage-CI-pWQVw.js +1 -0
- package/static/assets/ProposalDetailPage-D6rhO9vm.js +1 -0
- package/static/assets/ProposalEditPage-DCy3_sbg.js +1 -0
- package/static/assets/ProposalsPage-DQLqm83b.js +17 -0
- package/static/assets/ResourcesPage-Bq9t872V.js +66 -0
- package/static/assets/RulesSettingsPage-MgsP5qaA.js +16 -0
- package/static/assets/SchedulePage-C1vDSjyh.js +4 -0
- package/static/assets/TagInput-Cdfvhozb.js +1 -0
- package/static/assets/TerminalPage-NQzi2rzj.js +1 -0
- package/static/assets/TerminalSessionPage-DQgbm-LP.js +13 -0
- package/static/assets/UserPreferencesPage-CCYsj_XY.js +1 -0
- package/static/assets/UserSettingsPage-DdCnaoY_.js +1 -0
- package/static/assets/UtilitiesPage-DGcmJSz6.js +1 -0
- package/static/assets/alert-BAeRxZ1d.js +1 -0
- package/static/assets/arrow-down-5CQhXptz.js +6 -0
- package/static/assets/arrow-left-DSqUNUH-.js +6 -0
- package/static/assets/arrow-up-CYoJSbWn.js +6 -0
- package/static/assets/badge-NJasrAx_.js +1 -0
- package/static/assets/browser-modal-x3ise3M1.js +6 -0
- package/static/assets/calendar-wiZSxCBM.js +6 -0
- package/static/assets/card-CvaBJsG6.js +1 -0
- package/static/assets/chevron-left-CaZHWPr-.js +6 -0
- package/static/assets/circle-alert-61156jM6.js +6 -0
- package/static/assets/circle-check-big-K_QMED_K.js +6 -0
- package/static/assets/circle-check-z0By2KN8.js +6 -0
- package/static/assets/circle-play-88lMuMRZ.js +6 -0
- package/static/assets/circle-x-DdTsJYO7.js +6 -0
- package/static/assets/clipboard-B9ndUJKl.js +1 -0
- package/static/assets/clipboard-BNXOfcye.js +11 -0
- package/static/assets/clock-BTCBJF7v.js +6 -0
- package/static/assets/download-BaYIFjpj.js +6 -0
- package/static/assets/droid-CmYuCN_q.js +4 -0
- package/static/assets/eye-CuSCp49Y.js +6 -0
- package/static/assets/folder-git-2-CiVM8o0Y.js +6 -0
- package/static/assets/index-B8vejVRZ.js +458 -0
- package/static/assets/{index-Bo1l13x2.css → index-CKwmN6yL.css} +2 -33
- package/static/assets/label-DtNTh--4.js +1 -0
- package/static/assets/markdown-editor-DUEthZ0y.css +1 -0
- package/static/assets/markdown-editor-DvlGlqU9.js +62 -0
- package/static/assets/pause-COIsHZIp.js +6 -0
- package/static/assets/play-a8BsF4gF.js +6 -0
- package/static/assets/plus-Bon5P_OK.js +6 -0
- package/static/assets/radio-group-DpJuX02X.js +1 -0
- package/static/assets/refresh-cw-CnHMzcH3.js +6 -0
- package/static/assets/search-BR37JgJ3.js +6 -0
- package/static/assets/switch-D86f4WeD.js +1 -0
- package/static/assets/tabs-BYrDWPwx.js +1 -0
- package/static/assets/tag--U3Nuedb.js +6 -0
- package/static/assets/terminal-preview-Be68j_3t.js +11 -0
- package/static/assets/use-terminal-2DGl8X5T.js +1 -0
- package/static/assets/xterm-DTxiCjtJ.js +9 -0
- package/static/assets/xterm-qxJ8_QYu.css +32 -0
- package/static/assets/zap-C0eIGEl_.js +6 -0
- package/static/index.html +2 -2
- package/static/assets/index-DgZp291y.js +0 -973
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File validation and sanitization utilities
|
|
3
|
+
* Use these functions to prevent path traversal attacks
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Sanitize a filename to prevent path traversal attacks
|
|
7
|
+
* Removes path separators and parent directory references
|
|
8
|
+
* Only allows safe characters
|
|
9
|
+
*
|
|
10
|
+
* @param filename - The filename to sanitize
|
|
11
|
+
* @param allowDots - Whether to allow dots in filenames (default: true)
|
|
12
|
+
* @returns Sanitized filename
|
|
13
|
+
* @throws Error if filename contains invalid characters
|
|
14
|
+
*/
|
|
15
|
+
export declare function sanitizeFilename(filename: string, allowDots?: boolean): string;
|
|
16
|
+
/**
|
|
17
|
+
* Validate that a file path doesn't escape its base directory
|
|
18
|
+
*
|
|
19
|
+
* @param basePath - The base directory path
|
|
20
|
+
* @param filePath - The file path to validate
|
|
21
|
+
* @returns The resolved safe path
|
|
22
|
+
* @throws Error if path tries to escape base directory
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateSafePath(basePath: string, filePath: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Validate file extension against allowed list
|
|
27
|
+
*
|
|
28
|
+
* @param filename - The filename to check
|
|
29
|
+
* @param allowedExtensions - Array of allowed extensions (with or without dots)
|
|
30
|
+
* @returns The validated extension
|
|
31
|
+
* @throws Error if extension not allowed
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateFileExtension(filename: string, allowedExtensions: string[]): string;
|
|
34
|
+
/**
|
|
35
|
+
* Validate file size
|
|
36
|
+
*
|
|
37
|
+
* @param size - File size in bytes
|
|
38
|
+
* @param maxSize - Maximum allowed size in bytes
|
|
39
|
+
* @throws Error if file is too large
|
|
40
|
+
*/
|
|
41
|
+
export declare function validateFileSize(size: number, maxSize: number): void;
|
|
42
|
+
/**
|
|
43
|
+
* Validate MIME type
|
|
44
|
+
*
|
|
45
|
+
* @param mimeType - The MIME type to validate
|
|
46
|
+
* @param allowedTypes - Array of allowed MIME types
|
|
47
|
+
* @throws Error if MIME type not allowed
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateMimeType(mimeType: string, allowedTypes: string[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Comprehensive file validation for uploads
|
|
52
|
+
*
|
|
53
|
+
* @param file - File object with name, size, and type
|
|
54
|
+
* @param options - Validation options
|
|
55
|
+
*/
|
|
56
|
+
export interface FileValidationOptions {
|
|
57
|
+
maxSize?: number;
|
|
58
|
+
allowedExtensions?: string[];
|
|
59
|
+
allowedMimeTypes?: string[];
|
|
60
|
+
}
|
|
61
|
+
export declare function validateUploadedFile(file: {
|
|
62
|
+
name: string;
|
|
63
|
+
size: number;
|
|
64
|
+
type: string;
|
|
65
|
+
}, options?: FileValidationOptions): void;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File validation and sanitization utilities
|
|
3
|
+
* Use these functions to prevent path traversal attacks
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Sanitize a filename to prevent path traversal attacks
|
|
7
|
+
* Removes path separators and parent directory references
|
|
8
|
+
* Only allows safe characters
|
|
9
|
+
*
|
|
10
|
+
* @param filename - The filename to sanitize
|
|
11
|
+
* @param allowDots - Whether to allow dots in filenames (default: true)
|
|
12
|
+
* @returns Sanitized filename
|
|
13
|
+
* @throws Error if filename contains invalid characters
|
|
14
|
+
*/
|
|
15
|
+
export function sanitizeFilename(filename, allowDots = true) {
|
|
16
|
+
if (!filename || typeof filename !== 'string') {
|
|
17
|
+
throw new Error('Filename must be a non-empty string');
|
|
18
|
+
}
|
|
19
|
+
// Remove any null bytes
|
|
20
|
+
if (filename.includes('\0')) {
|
|
21
|
+
throw new Error('Filename contains null bytes');
|
|
22
|
+
}
|
|
23
|
+
// Remove path separators and parent directory references
|
|
24
|
+
let sanitized = filename
|
|
25
|
+
.replace(/[\/\\]/g, '') // Remove path separators
|
|
26
|
+
.replace(/\.\./g, ''); // Remove parent directory references
|
|
27
|
+
// Remove leading/trailing dots and spaces
|
|
28
|
+
sanitized = sanitized.replace(/^[\s.]+|[\s.]+$/g, '');
|
|
29
|
+
// Check for valid characters
|
|
30
|
+
const pattern = allowDots
|
|
31
|
+
? /^[a-zA-Z0-9._-]+$/
|
|
32
|
+
: /^[a-zA-Z0-9_-]+$/;
|
|
33
|
+
if (!pattern.test(sanitized)) {
|
|
34
|
+
throw new Error('Filename contains invalid characters. Only alphanumeric, dots, hyphens, and underscores are allowed');
|
|
35
|
+
}
|
|
36
|
+
// Prevent reserved names (Windows)
|
|
37
|
+
const reservedNames = ['CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'COM4',
|
|
38
|
+
'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2',
|
|
39
|
+
'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9'];
|
|
40
|
+
const nameWithoutExt = sanitized.split('.')[0].toUpperCase();
|
|
41
|
+
if (reservedNames.includes(nameWithoutExt)) {
|
|
42
|
+
throw new Error('Filename uses a reserved system name');
|
|
43
|
+
}
|
|
44
|
+
// Enforce maximum length
|
|
45
|
+
if (sanitized.length > 255) {
|
|
46
|
+
throw new Error('Filename is too long (max 255 characters)');
|
|
47
|
+
}
|
|
48
|
+
if (sanitized.length === 0) {
|
|
49
|
+
throw new Error('Filename is empty after sanitization');
|
|
50
|
+
}
|
|
51
|
+
return sanitized;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Validate that a file path doesn't escape its base directory
|
|
55
|
+
*
|
|
56
|
+
* @param basePath - The base directory path
|
|
57
|
+
* @param filePath - The file path to validate
|
|
58
|
+
* @returns The resolved safe path
|
|
59
|
+
* @throws Error if path tries to escape base directory
|
|
60
|
+
*/
|
|
61
|
+
export function validateSafePath(basePath, filePath) {
|
|
62
|
+
const path = require('path');
|
|
63
|
+
const resolvedBase = path.resolve(basePath);
|
|
64
|
+
const resolvedPath = path.resolve(basePath, filePath);
|
|
65
|
+
// Check if the resolved path starts with the base path
|
|
66
|
+
if (!resolvedPath.startsWith(resolvedBase + path.sep) && resolvedPath !== resolvedBase) {
|
|
67
|
+
throw new Error('Path traversal detected: file path escapes base directory');
|
|
68
|
+
}
|
|
69
|
+
return resolvedPath;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate file extension against allowed list
|
|
73
|
+
*
|
|
74
|
+
* @param filename - The filename to check
|
|
75
|
+
* @param allowedExtensions - Array of allowed extensions (with or without dots)
|
|
76
|
+
* @returns The validated extension
|
|
77
|
+
* @throws Error if extension not allowed
|
|
78
|
+
*/
|
|
79
|
+
export function validateFileExtension(filename, allowedExtensions) {
|
|
80
|
+
const path = require('path');
|
|
81
|
+
const ext = path.extname(filename).toLowerCase();
|
|
82
|
+
const normalizedAllowed = allowedExtensions.map(e => e.startsWith('.') ? e.toLowerCase() : '.' + e.toLowerCase());
|
|
83
|
+
if (!normalizedAllowed.includes(ext)) {
|
|
84
|
+
throw new Error(`File extension "${ext}" not allowed. Allowed: ${normalizedAllowed.join(', ')}`);
|
|
85
|
+
}
|
|
86
|
+
return ext;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Validate file size
|
|
90
|
+
*
|
|
91
|
+
* @param size - File size in bytes
|
|
92
|
+
* @param maxSize - Maximum allowed size in bytes
|
|
93
|
+
* @throws Error if file is too large
|
|
94
|
+
*/
|
|
95
|
+
export function validateFileSize(size, maxSize) {
|
|
96
|
+
if (size > maxSize) {
|
|
97
|
+
const sizeMB = (size / 1024 / 1024).toFixed(2);
|
|
98
|
+
const maxMB = (maxSize / 1024 / 1024).toFixed(2);
|
|
99
|
+
throw new Error(`File size (${sizeMB}MB) exceeds maximum allowed size (${maxMB}MB)`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validate MIME type
|
|
104
|
+
*
|
|
105
|
+
* @param mimeType - The MIME type to validate
|
|
106
|
+
* @param allowedTypes - Array of allowed MIME types
|
|
107
|
+
* @throws Error if MIME type not allowed
|
|
108
|
+
*/
|
|
109
|
+
export function validateMimeType(mimeType, allowedTypes) {
|
|
110
|
+
if (!allowedTypes.includes(mimeType)) {
|
|
111
|
+
throw new Error(`MIME type "${mimeType}" not allowed. Allowed: ${allowedTypes.join(', ')}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export function validateUploadedFile(file, options = {}) {
|
|
115
|
+
const { maxSize = 50 * 1024 * 1024, // 50MB default
|
|
116
|
+
allowedExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.pdf', '.txt', '.md'], allowedMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'text/plain', 'text/markdown'] } = options;
|
|
117
|
+
// Validate filename
|
|
118
|
+
sanitizeFilename(file.name);
|
|
119
|
+
// Validate extension
|
|
120
|
+
validateFileExtension(file.name, allowedExtensions);
|
|
121
|
+
// Validate size
|
|
122
|
+
validateFileSize(file.size, maxSize);
|
|
123
|
+
// Validate MIME type
|
|
124
|
+
validateMimeType(file.type, allowedMimeTypes);
|
|
125
|
+
}
|
|
@@ -22,6 +22,7 @@ export declare function isAdmin(c: Context): boolean;
|
|
|
22
22
|
/**
|
|
23
23
|
* Helper to require authentication (throws if not authenticated)
|
|
24
24
|
* Returns null if auth is disabled
|
|
25
|
+
* Also accepts API key authentication
|
|
25
26
|
*/
|
|
26
27
|
export declare function requireAuth(c: Context): AuthSession | null;
|
|
27
28
|
/**
|
package/dist/middleware/auth.js
CHANGED
|
@@ -108,6 +108,7 @@ export function isAdmin(c) {
|
|
|
108
108
|
/**
|
|
109
109
|
* Helper to require authentication (throws if not authenticated)
|
|
110
110
|
* Returns null if auth is disabled
|
|
111
|
+
* Also accepts API key authentication
|
|
111
112
|
*/
|
|
112
113
|
export function requireAuth(c) {
|
|
113
114
|
const authEnabled = c.get('authEnabled');
|
|
@@ -115,11 +116,20 @@ export function requireAuth(c) {
|
|
|
115
116
|
if (authEnabled === false) {
|
|
116
117
|
return null;
|
|
117
118
|
}
|
|
119
|
+
// Check for session auth (cookie or Bearer token)
|
|
118
120
|
const session = getSession(c);
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
+
if (session) {
|
|
122
|
+
return session;
|
|
121
123
|
}
|
|
122
|
-
|
|
124
|
+
// Check for API key auth
|
|
125
|
+
const authType = c.get('authType');
|
|
126
|
+
const apiKey = c.get('apiKey');
|
|
127
|
+
if (authType === 'apikey' && apiKey) {
|
|
128
|
+
// API key is valid, authentication successful
|
|
129
|
+
// Return null to indicate auth passed but no session available
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
throw new Error('Authentication required');
|
|
123
133
|
}
|
|
124
134
|
/**
|
|
125
135
|
* Helper to require admin access (throws if not admin)
|
|
@@ -7,9 +7,9 @@ import { Context } from "hono";
|
|
|
7
7
|
* Get logging system status and configuration
|
|
8
8
|
*/
|
|
9
9
|
export declare function GET(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
10
|
+
[x: string]: any;
|
|
10
11
|
currentFile: string;
|
|
11
12
|
sizeBytes: number;
|
|
12
|
-
lastSeq: number;
|
|
13
13
|
rotateBytes: number;
|
|
14
14
|
logsDir: string;
|
|
15
15
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
@@ -12,8 +12,8 @@ export declare function POST(c: Context): Promise<(Response & import("hono").Typ
|
|
|
12
12
|
run: {
|
|
13
13
|
id: string;
|
|
14
14
|
jobId: string;
|
|
15
|
-
trigger: import("@lovelybunch/
|
|
16
|
-
status: import("@lovelybunch/
|
|
15
|
+
trigger: import("@lovelybunch/types").ScheduledJobTrigger;
|
|
16
|
+
status: import("@lovelybunch/types").ScheduledJobRunStatus;
|
|
17
17
|
startedAt: string;
|
|
18
18
|
finishedAt?: string;
|
|
19
19
|
outputPath?: string;
|
|
@@ -7,7 +7,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
7
7
|
runningCount: number;
|
|
8
8
|
jobs: {
|
|
9
9
|
id: string;
|
|
10
|
-
status: import("@lovelybunch/
|
|
10
|
+
status: import("@lovelybunch/types").ScheduledJobStatus;
|
|
11
11
|
nextRunAt?: string;
|
|
12
12
|
lastRunAt?: string;
|
|
13
13
|
timerActive: boolean;
|
|
@@ -12,7 +12,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
12
12
|
intent: string;
|
|
13
13
|
content?: string;
|
|
14
14
|
author: {
|
|
15
|
-
type: import("@lovelybunch/
|
|
15
|
+
type: import("@lovelybunch/types").AuthorType;
|
|
16
16
|
id: string;
|
|
17
17
|
name: string;
|
|
18
18
|
email?: string;
|
|
@@ -47,7 +47,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
47
47
|
version: string;
|
|
48
48
|
name: string;
|
|
49
49
|
description: string;
|
|
50
|
-
type: import("@lovelybunch/
|
|
50
|
+
type: import("@lovelybunch/types").FeatureFlagType;
|
|
51
51
|
defaultValue: any;
|
|
52
52
|
scopes: string[];
|
|
53
53
|
targets: {
|
|
@@ -95,7 +95,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
95
95
|
minimumSampleSize: number;
|
|
96
96
|
testType: "two-tailed" | "one-tailed";
|
|
97
97
|
};
|
|
98
|
-
status: import("@lovelybunch/
|
|
98
|
+
status: import("@lovelybunch/types").ExperimentStatus;
|
|
99
99
|
startedAt?: string;
|
|
100
100
|
endedAt?: string;
|
|
101
101
|
}[];
|
|
@@ -133,7 +133,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
133
133
|
schedule?: string;
|
|
134
134
|
rollbackPlan?: string;
|
|
135
135
|
};
|
|
136
|
-
status: import("@lovelybunch/
|
|
136
|
+
status: import("@lovelybunch/types").CPStatus;
|
|
137
137
|
metadata: {
|
|
138
138
|
createdAt: string;
|
|
139
139
|
updatedAt: string;
|
|
@@ -169,7 +169,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
|
|
|
169
169
|
intent: string;
|
|
170
170
|
content?: string;
|
|
171
171
|
author: {
|
|
172
|
-
type: import("@lovelybunch/
|
|
172
|
+
type: import("@lovelybunch/types").AuthorType;
|
|
173
173
|
id: string;
|
|
174
174
|
name: string;
|
|
175
175
|
email?: string;
|
|
@@ -204,7 +204,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
|
|
|
204
204
|
version: string;
|
|
205
205
|
name: string;
|
|
206
206
|
description: string;
|
|
207
|
-
type: import("@lovelybunch/
|
|
207
|
+
type: import("@lovelybunch/types").FeatureFlagType;
|
|
208
208
|
defaultValue: any;
|
|
209
209
|
scopes: string[];
|
|
210
210
|
targets: {
|
|
@@ -252,7 +252,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
|
|
|
252
252
|
minimumSampleSize: number;
|
|
253
253
|
testType: "two-tailed" | "one-tailed";
|
|
254
254
|
};
|
|
255
|
-
status: import("@lovelybunch/
|
|
255
|
+
status: import("@lovelybunch/types").ExperimentStatus;
|
|
256
256
|
startedAt?: string;
|
|
257
257
|
endedAt?: string;
|
|
258
258
|
}[];
|
|
@@ -290,7 +290,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
|
|
|
290
290
|
schedule?: string;
|
|
291
291
|
rollbackPlan?: string;
|
|
292
292
|
};
|
|
293
|
-
status: import("@lovelybunch/
|
|
293
|
+
status: import("@lovelybunch/types").CPStatus;
|
|
294
294
|
metadata: {
|
|
295
295
|
createdAt: string;
|
|
296
296
|
updatedAt: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import sharp from 'sharp';
|
|
3
4
|
import { getLogger, ResourceKinds } from '@lovelybunch/core/logging';
|
|
4
5
|
import { requireAuth } from '../../../../middleware/auth.js';
|
|
5
6
|
// Generate a random ID
|
|
@@ -65,19 +66,21 @@ async function listAllResources() {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
async function generateThumbnail(imageBuffer, id, mimeType) {
|
|
68
|
-
// For now, we'll create a simple placeholder thumbnail
|
|
69
|
-
// In a production environment, you'd use a library like Sharp for proper image processing
|
|
70
69
|
const thumbnailName = `${id}_thumb.jpg`;
|
|
71
70
|
const thumbnailPath = path.join(THUMBNAILS_DIR, thumbnailName);
|
|
72
71
|
try {
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
// Resize to max 300x300 (2x retina for 128px UI display), preserve aspect ratio
|
|
73
|
+
await sharp(imageBuffer)
|
|
74
|
+
.resize(300, 300, { fit: 'inside', withoutEnlargement: true })
|
|
75
|
+
.jpeg({ quality: 80 })
|
|
76
|
+
.toFile(thumbnailPath);
|
|
76
77
|
return thumbnailName;
|
|
77
78
|
}
|
|
78
79
|
catch (error) {
|
|
79
|
-
console.error('Failed to generate thumbnail:', error);
|
|
80
|
-
|
|
80
|
+
console.error('Failed to generate thumbnail with Sharp:', error);
|
|
81
|
+
// Fallback: save original as thumbnail if Sharp fails
|
|
82
|
+
await fs.writeFile(thumbnailPath, imageBuffer);
|
|
83
|
+
return thumbnailName;
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
export async function GET(c) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.71-alpha.
|
|
3
|
+
"version": "1.0.71-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/server-with-static.js",
|
|
6
6
|
"exports": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@hono/node-server": "^1.13.7",
|
|
38
38
|
"@hono/node-ws": "^1.0.6",
|
|
39
|
-
"@lovelybunch/core": "^1.0.71-alpha.
|
|
40
|
-
"@lovelybunch/mcp": "^1.0.71-alpha.
|
|
41
|
-
"@lovelybunch/types": "^1.0.71-alpha.
|
|
39
|
+
"@lovelybunch/core": "^1.0.71-alpha.3",
|
|
40
|
+
"@lovelybunch/mcp": "^1.0.71-alpha.3",
|
|
41
|
+
"@lovelybunch/types": "^1.0.71-alpha.3",
|
|
42
42
|
"arctic": "^1.9.2",
|
|
43
43
|
"bcrypt": "^5.1.1",
|
|
44
44
|
"cookie": "^0.6.0",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"jsonwebtoken": "^9.0.2",
|
|
50
50
|
"node-pty": "^1.0.0",
|
|
51
51
|
"replicate": "^0.34.1",
|
|
52
|
+
"sharp": "^0.33.5",
|
|
52
53
|
"ws": "^8.18.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as C,u as E,r as h,j as e,B as i,L as d,J as k,T as B,i as T,A as N}from"./index-B8vejVRZ.js";import{C as l,b as o,a as m,c as f,d as z}from"./card-CvaBJsG6.js";import{B as v}from"./badge-NJasrAx_.js";import{A as u}from"./arrow-left-DSqUNUH-.js";const D=t=>t?Array.isArray(t)?t.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(r=>r.trim()).filter(Boolean):[]:[],c={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function F(){const t=C(),r=E(),[s,y]=h.useState(null),[w,j]=h.useState(!0),[p,x]=h.useState(null);h.useEffect(()=>{async function a(){try{j(!0);const g=await(await fetch(`${N}/api/v1/agents/${t.id}`)).json();g.success?y(g.document):x(g.error||"Failed to fetch agent")}catch(n){x(n instanceof Error?n.message:"Unknown error")}finally{j(!1)}}t.id&&a()},[t.id]);const A=async()=>{if(!(!s||!confirm("Are you sure you want to delete this agent?")))try{const n=await(await fetch(`${N}/api/v1/agents/${s.filename.replace(".md","")}`,{method:"DELETE"})).json();n.success?r("/agents"):x(n.error?.message||"Failed to delete agent")}catch(a){x(a instanceof Error?a.message:"Unknown error")}};if(w)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-64 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 animate-pulse mt-2"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(i,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(d,{to:"/agents",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(u,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsxs(o,{children:[e.jsx("div",{className:"h-6 bg-muted rounded w-48 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-64 animate-pulse"})]})})]});if(p||!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agent Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The requested agent could not be found"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(i,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(d,{to:"/agents",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(u,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsx(m,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-destructive",children:p||"Agent not found"})})})})]});const b=D(s.metadata.tools);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"space-y-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:s.metadata.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(i,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(d,{to:"/agents",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(u,{className:"h-4 w-4"})})}),e.jsx(i,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(d,{to:`/agents/${s.filename.replace(".md","")}/edit`,children:[e.jsx(k,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(i,{variant:"destructive",size:"sm",onClick:A,children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(f,{children:"Description"})}),e.jsx(m,{children:e.jsx("p",{children:s.metadata.description})})]}),s.content&&e.jsxs(l,{children:[e.jsxs(o,{children:[e.jsx(f,{children:"Instructions"}),e.jsx(z,{children:"System prompt and behavior instructions for this agent"})]}),e.jsx(m,{children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-muted p-4 rounded-md",children:s.content})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(f,{children:"Agent Actions"})}),e.jsx(m,{className:"space-y-2",children:e.jsx(i,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(d,{to:`/terminal/ag-${s.filename.replace(".md","")}`,children:[e.jsx(T,{className:"h-4 w-4 mr-2"}),"Prepare Agent"]})})})]}),e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(f,{children:"Information"})}),e.jsxs(m,{className:"space-y-2",children:[s.metadata.color&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Color"}),e.jsx(v,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:c[s.metadata.color]?.bg||c.blue.bg,color:c[s.metadata.color]?.text||c.blue.text,borderColor:c[s.metadata.color]?.border||c.blue.border},children:s.metadata.color})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Tools"}),b.length>0?e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:b.map(a=>e.jsx(v,{variant:"secondary",children:a},a))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No specific tools configured - inherits all tools"})]})]})]})]})]})]})}export{F as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as X,u as Y,H as Z,r as n,j as e,B as m,L as v,i as O,I as D,a0 as ee,ac as te,A as y}from"./index-B8vejVRZ.js";import{C as N,a as C,b as se,c as ae}from"./card-CvaBJsG6.js";import{L as l}from"./label-DtNTh--4.js";import{B as re}from"./badge-NJasrAx_.js";import{c as ne}from"./clipboard-B9ndUJKl.js";import{A as z}from"./arrow-left-DSqUNUH-.js";import{C as oe,a as ie}from"./clipboard-BNXOfcye.js";function xe(){const{id:i}=X(),U=Y(),{toast:w}=Z(),[q,S]=n.useState(!0),[o,A]=n.useState(!1),[d,c]=n.useState(null),[H,R]=n.useState(""),[u,E]=n.useState(""),[g,F]=n.useState(""),[f,P]=n.useState("blue"),[x,k]=n.useState([]),[h,$]=n.useState(""),[L,p]=n.useState([]),[_,M]=n.useState(!0),[J,T]=n.useState(!1),G=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],K={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}},Q=t=>{if(!t)return[];if(Array.isArray(t)){const a=t.filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean);return Array.from(new Set(a))}return typeof t=="string"?Array.from(new Set(t.split(",").map(a=>a.trim()).filter(Boolean))):[]};n.useEffect(()=>{async function t(){try{S(!0);const s=await(await fetch(`${y}/api/v1/agents/${i}`)).json();if(!s.success)throw new Error(s.error||"Failed to load agent");const r=s.document;R(r.filename),E(r.metadata.name||""),F(r.metadata.description||""),P(r.metadata.color||"blue"),$(r.content||""),k(Q(r.metadata.tools))}catch(a){const s=a instanceof Error?a.message:"Failed to load agent";c(s)}finally{S(!1)}}i&&t()},[i]),n.useEffect(()=>{let t=!0;return(async()=>{M(!0);try{const s=await fetch(`${y}/api/v1/mcp`);if(!s.ok)throw new Error("Failed to fetch MCP servers");const r=await s.json();if(!r?.success||!Array.isArray(r.servers)){t&&p([]);return}const B=r.mcpServers&&typeof r.mcpServers=="object"?r.mcpServers:{},b=r.servers.map(I=>{const j=B[I]??{};return{name:I,enabled:j?.enabled!==!1,description:typeof j?.description=="string"?j.description:void 0}});t&&p(b)}catch(s){console.error("Failed to load MCP servers",s),t&&p([])}finally{t&&M(!1)}})(),()=>{t=!1}},[]);const V=async()=>{const t=".nut/config.json";try{await ne(t),T(!0),w({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>T(!1),2e3)}catch(a){console.error("Failed to copy config path:",a),w({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},W=async t=>{if(t.preventDefault(),!u.trim()||!g.trim()||!h.trim()){c("Name, description, and agent instructions are required");return}try{A(!0),c(null);const a={name:u.trim(),description:g.trim(),content:h.trim(),metadata:{color:f,tools:x.length?x:void 0}},r=await(await fetch(`${y}/api/v1/agents/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!r.success)throw new Error(r.error||"Failed to update agent");const b=r.document.filename.replace(/\.md$/,"");U(`/agents/${b}`)}catch(a){const s=a instanceof Error?a.message:"Failed to update agent";c(s)}finally{A(!1)}};return q?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:"Loading agent..."})})}):d?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Agent"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load agent"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/agents/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(z,{className:"h-4 w-4"})})})})]}),e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:e.jsx("div",{className:"text-destructive",children:d})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Agent"}),e.jsxs("p",{className:"text-muted-foreground",children:["File: ",H]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/agents/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(z,{className:"h-4 w-4"})})})})]}),e.jsxs(N,{children:[e.jsx(se,{children:e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-5 w-5"}),"Agent Configuration"]})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:W,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(D,{id:"name",value:u,onChange:t=>E(t.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(D,{id:"description",value:g,onChange:t=>F(t.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:G.map(t=>{const a=K[t];return e.jsx("button",{type:"button",onClick:()=>P(t),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${f===t?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:a.bg,borderColor:f===t?a.border:"hsl(var(--border))",...f===t&&{"--tw-ring-color":a.border}},title:t,children:e.jsx("span",{className:"sr-only",children:t})},t)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Agent Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this agent's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:V,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:J?e.jsx(oe,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(ie,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the agent to be able to access its name, role, or email address."]}),e.jsx(ee,{id:"content",value:h,onChange:t=>$(t.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Tools (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this agent should be able to use. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:_?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers…"}):L.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):L.map(t=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(te,{checked:x.includes(t.name),onCheckedChange:a=>{k(s=>a===!0?s.includes(t.name)?s:[...s,t.name]:s.filter(r=>r!==t.name))},disabled:o||!t.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[t.name,!t.enabled&&e.jsx(re,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.enabled?t.description||"Enabled MCP server":"Enable this server in Settings to allow agents to use it"})]})]},t.name))})]}),d&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(m,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(v,{to:`/agents/${i}`,children:"Cancel"})}),e.jsx(m,{type:"submit",disabled:o,children:o?"Saving...":"Save Changes"})]})]})})]})]})}export{xe as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as e,S as I,Y as L,r as x,H as O,A as S,n as M,B as b,L as v,i as E,ah as $,ai as _}from"./index-B8vejVRZ.js";import{C as N,a as w,b as D,c as H}from"./card-CvaBJsG6.js";import{B as y}from"./badge-NJasrAx_.js";import{c as U}from"./clipboard-B9ndUJKl.js";import{R as Y,a as G,f as J,L as F}from"./browser-modal-x3ise3M1.js";import{P as T}from"./plus-Bon5P_OK.js";import{T as K}from"./tag--U3Nuedb.js";import"./search-BR37JgJ3.js";const V=["color","tools","createdAt","updatedAt","version","focusAreas","contextPreferences","tags"];function P(t){if(t){if(Array.isArray(t)){const r=t.map(n=>{if(typeof n=="string")return n.trim();if(typeof n=="number")return`${n}`}).filter(n=>typeof n=="string"&&n.length>0);return r.length>0?r:void 0}if(typeof t=="string"){const r=t.split(",").map(n=>n.trim()).filter(n=>n.length>0);return r.length>0?r:void 0}}}function q(t,r){const n=[];if(t.content&&typeof t.content=="object")for(const o of Object.values(t.content))typeof o=="string"&&o.trim().length>0&&n.push(o.trim());const i=[];return i.push(`# ${r}`),t.description?.trim()&&i.push(t.description.trim()),[...i,...n].join(`
|
|
2
|
+
|
|
3
|
+
`).trim()}function z(t,r){const n=t.name||r.name,i=r.description||t.description||"",a={registryId:t.id,registryEndpoint:t.endpoint,registrySource:Y,author:t.author};for(const o of V){const d=r[o];if(d!==void 0)if(o==="tools"||o==="focusAreas"||o==="contextPreferences"||o==="tags"){const f=P(d);f&&(a[o]=f)}else a[o]=d}!a.version&&t.version&&(a.version=t.version),a.color||(a.color="blue"),!a.tags&&t.tags&&(a.tags=P(t.tags));for(const[o,d]of Object.entries(a))d==null&&delete a[o];return{name:n,description:i,content:q(r,n),metadata:Object.keys(a).length>0?a:void 0}}function B({open:t,onOpenChange:r,onImport:n}){return e.jsx(G,{open:t,onOpenChange:r,categoryId:"agents",title:"Coconut Registry – Agents",confirmLabel:"Import Agent",getDetail:i=>J(i.endpoint),renderPreview:(i,a)=>{if(!a)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an agent to preview"});const o=z(i,a),d=o.metadata??{},f=typeof d.version=="string"?d.version:void 0,u=Array.isArray(i.tags)?i.tags:[],j=Array.isArray(d.tools)?d.tools.filter(l=>typeof l=="string"):[],p=Array.isArray(d.focusAreas)?d.focusAreas.filter(l=>typeof l=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(I,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:i.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]}),f&&e.jsxs(y,{variant:"outline",children:["v",f]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:i.id})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(l=>e.jsx(y,{variant:"secondary",children:l},l))}),j.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:"Tools:"}),j.map(l=>e.jsx(y,{variant:"outline",children:l},l))]}),p.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Focus Areas"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground",children:p.map(l=>e.jsx("li",{children:l},l))})]})]}),e.jsx(L,{className:"[&_.prose]:max-w-none",children:o.content})]})})})},onConfirm:async(i,a)=>{const o=z(i,a);await n({summary:i,detail:a,payload:o})}})}const Q=t=>t?Array.isArray(t)?t.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(r=>r.trim()).filter(Boolean):[]:[],g={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function oe(){const[t,r]=x.useState([]),[n,i]=x.useState(!0),[a,o]=x.useState({}),[d,f]=x.useState(!1),[u,j]=x.useState(!1),{toast:p}=O(),l=x.useCallback(async()=>{i(!0);try{const s=await fetch(`${S}/api/v1/agents`);if(!s.ok)throw new Error("Failed to load agents");const m=await s.json();r(Array.isArray(m.documents)?m.documents:[])}catch(s){console.error("Failed to load agents:",s),r([])}finally{i(!1)}},[]);x.useEffect(()=>{l()},[l]);const A=async s=>{const m=`.nut/agents/${s}`;try{await U(m),o(c=>({...c,[s]:!0})),setTimeout(()=>{o(c=>({...c,[s]:!1}))},2e3),p({title:"Path copied!",description:`Copied ${m} to clipboard`})}catch(c){console.error("Failed to copy path:",c),p({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},C=x.useCallback(async({payload:s})=>{let m=!1;j(!0);try{const c=await fetch(`${S}/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.name,description:s.description,content:s.content,metadata:s.metadata})});let h=null;try{h=await c.json()}catch(k){console.error("Failed to parse registry import response:",k)}if(!(c.ok&&h?.success)){const R=(typeof h?.error=="string"?h.error:h?.error?.message)||c.statusText||"Failed to import agent from registry";throw p({title:"Failed to import agent",description:R,variant:"destructive"}),m=!0,new Error(R)}p({title:"Agent imported",description:`${s.name} is now available in Coconut`}),await l()}catch(c){if(!m){const h=c instanceof Error&&c.message?c.message:"Failed to import agent from registry";p({title:"Failed to import agent",description:h,variant:"destructive"})}throw c}finally{j(!1)}},[l,p]);return n?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(M,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading agents..."})]})})})}):t.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage agents for your development workflows"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:u,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(b,{size:"sm",asChild:!0,children:e.jsxs(v,{to:"/agents/new",children:[e.jsx(T,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(E,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Agents Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Specialized agents help you automate your development and business workflows."})]})})})]}),e.jsx(B,{open:d,onOpenChange:f,onImport:C})]}):e.jsxs(e.Fragment,{children:[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("h2",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage agents for your development workflows"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>f(!0),disabled:u,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(b,{size:"sm",asChild:!0,children:e.jsxs(v,{to:"/agents/new",children:[e.jsx(T,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx("div",{className:"grid gap-4",children:t.map(s=>{const m=Q(s.metadata.tools);return e.jsx(v,{to:`/agents/${s.filename.replace(".md","")}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(D,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"text-lg",children:s.title}),e.jsx(b,{variant:"ghost",size:"sm",onClick:c=>{c.preventDefault(),A(s.filename)},className:"h-6 w-6 p-0 hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy file path to clipboard",children:a[s.filename]?e.jsx($,{className:"w-3 h-3 text-green-600"}):e.jsx(_,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-1 rounded inline-block cursor-pointer hover:bg-muted/70 transition-colors",onClick:c=>{c.preventDefault(),A(s.filename)},title:"Click to copy file path to clipboard",children:[".nut/agents/",s.filename]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{className:"w-3 h-3"}),s.metadata.color||"blue"]}),m.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(E,{className:"w-3 h-3"}),m.join(", ")]})]})]}),s.metadata.color&&e.jsx(y,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:g[s.metadata.color]?.bg||g.blue.bg,color:g[s.metadata.color]?.text||g.blue.text,borderColor:g[s.metadata.color]?.border||g.blue.border},children:s.metadata.color})]})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.metadata.description})})})})]})},s.filename)})})]}),e.jsx(B,{open:d,onOpenChange:f,onImport:C})]})}export{oe as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as b,j as e,a1 as w,B as t,ad as C,T as A,I as r,v as l,w as c,x as d,y as o,z as i}from"./index-B8vejVRZ.js";import{C as x,b as m,c as u,d as h,a as j}from"./card-CvaBJsG6.js";import{L as a}from"./label-DtNTh--4.js";import{B as n}from"./badge-NJasrAx_.js";import{P as S}from"./plus-Bon5P_OK.js";import{P as p}from"./pause-COIsHZIp.js";import{P as R}from"./play-a8BsF4gF.js";import{Z as T}from"./zap-C0eIGEl_.js";/**
|
|
2
|
+
* @license lucide-react v0.542.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const k=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],P=b("chart-column",k);function G(){const g=[{id:"1",name:"Code Review Agent",description:"Automatically reviews pull requests and provides feedback",type:"Code Review",status:"active",model:"claude-3.5-sonnet",lastRun:"5 minutes ago",runsToday:23,successRate:"94%"},{id:"2",name:"Documentation Agent",description:"Generates and updates code documentation automatically",type:"Documentation",status:"paused",model:"gpt-4",lastRun:"2 hours ago",runsToday:8,successRate:"98%"},{id:"3",name:"Bug Hunter Agent",description:"Scans code for potential bugs and security vulnerabilities",type:"Quality Assurance",status:"active",model:"gemini-pro",lastRun:"15 minutes ago",runsToday:12,successRate:"87%"},{id:"4",name:"Performance Monitor",description:"Monitors application performance and suggests optimizations",type:"Performance",status:"inactive",model:"claude-3-haiku",lastRun:"1 day ago",runsToday:0,successRate:"91%"}],v=["Code Review","Documentation","Quality Assurance","Performance","Security","Refactoring","Testing","Architecture"],f=["claude-3.5-sonnet","claude-3-haiku","gpt-4","gpt-3.5-turbo","gemini-pro","gemini-flash"],y=s=>{switch(s){case"active":return e.jsx(T,{className:"h-4 w-4 text-green-500"});case"paused":return e.jsx(p,{className:"h-4 w-4 text-yellow-500"});case"inactive":return e.jsx("div",{className:"h-4 w-4 rounded-full bg-gray-300"});default:return e.jsx("div",{className:"h-4 w-4 rounded-full bg-gray-300"})}},N=s=>{switch(s){case"active":return e.jsx(n,{className:"bg-green-100 text-green-800",children:"Active"});case"paused":return e.jsx(n,{className:"bg-yellow-100 text-yellow-800",children:"Paused"});case"inactive":return e.jsx(n,{variant:"secondary",children:"Inactive"});default:return e.jsx(n,{variant:"secondary",children:"Unknown"})}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Agents Management"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure and manage AI agents that automate various development tasks."})]}),e.jsx(w,{}),e.jsxs(x,{children:[e.jsx(m,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Active Agents"}),e.jsx(h,{children:"Monitor and control your AI agents across different workflows."})]}),e.jsxs(t,{size:"sm",children:[e.jsx(S,{className:"h-4 w-4 mr-2"}),"Create Agent"]})]})}),e.jsx(j,{children:e.jsx("div",{className:"space-y-4",children:g.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[y(s.status),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium",children:s.name}),N(s.status),e.jsx(n,{variant:"outline",children:s.type}),e.jsx(n,{variant:"outline",children:s.model})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last run: ",s.lastRun]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Runs today: ",s.runsToday]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Success rate: ",s.successRate]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t,{variant:"outline",size:"sm",children:e.jsx(P,{className:"h-4 w-4"})}),s.status==="active"?e.jsx(t,{variant:"outline",size:"sm",children:e.jsx(p,{className:"h-4 w-4"})}):e.jsx(t,{variant:"outline",size:"sm",children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(t,{variant:"outline",size:"sm",children:e.jsx(C,{className:"h-4 w-4"})}),e.jsx(t,{variant:"outline",size:"sm",children:e.jsx(A,{className:"h-4 w-4"})})]})]},s.id))})})]}),e.jsxs(x,{children:[e.jsxs(m,{children:[e.jsx(u,{children:"Create New Agent"}),e.jsx(h,{children:"Configure a new AI agent to automate specific development tasks."})]}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"agentName",children:"Agent Name"}),e.jsx(r,{id:"agentName",placeholder:"Enter agent name"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"agentType",children:"Agent Type"}),e.jsxs(l,{children:[e.jsx(c,{children:e.jsx(d,{placeholder:"Select agent type"})}),e.jsx(o,{children:v.map(s=>e.jsx(i,{value:s.toLowerCase(),children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"agentDescription",children:"Description"}),e.jsx(r,{id:"agentDescription",placeholder:"What does this agent do?"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"aiModel",children:"AI Model"}),e.jsxs(l,{children:[e.jsx(c,{children:e.jsx(d,{placeholder:"Select AI model"})}),e.jsx(o,{children:f.map(s=>e.jsx(i,{value:s,children:s},s))})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"systemPrompt",children:"System Prompt"}),e.jsxs(l,{children:[e.jsx(c,{children:e.jsx(d,{placeholder:"Select system prompt"})}),e.jsxs(o,{children:[e.jsx(i,{value:"code-review",children:"Code Review Assistant"}),e.jsx(i,{value:"documentation",children:"Documentation Generator"}),e.jsx(i,{value:"bug-analysis",children:"Bug Analysis Expert"}),e.jsx(i,{value:"architecture",children:"Architecture Advisor"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"triggers",children:"Triggers"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["Pull Request","Commit","File Change","Schedule","Manual"].map(s=>e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",className:"rounded"}),e.jsx("span",{className:"text-sm",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"configuration",children:"Agent Configuration (JSON)"}),e.jsx("textarea",{id:"configuration",className:"w-full min-h-[120px] p-3 border rounded-md font-mono text-sm",placeholder:'{"maxTokens": 4000, "temperature": 0.3, "timeout": 30}'})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(t,{variant:"outline",children:"Test Configuration"}),e.jsx(t,{variant:"outline",children:"Save as Draft"}),e.jsx(t,{children:"Create & Activate"})]})]})]}),e.jsxs(x,{children:[e.jsxs(m,{children:[e.jsx(u,{children:"Global Agent Settings"}),e.jsx(h,{children:"Configure global settings that apply to all agents."})]}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"maxConcurrent",children:"Max Concurrent Agents"}),e.jsx(r,{id:"maxConcurrent",type:"number",placeholder:"5"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"defaultTimeout",children:"Default Timeout (seconds)"}),e.jsx(r,{id:"defaultTimeout",type:"number",placeholder:"30"})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"retryPolicy",children:"Retry Policy"}),e.jsxs(l,{children:[e.jsx(c,{children:e.jsx(d,{placeholder:"Select retry policy"})}),e.jsxs(o,{children:[e.jsx(i,{value:"none",children:"No Retries"}),e.jsx(i,{value:"exponential",children:"Exponential Backoff"}),e.jsx(i,{value:"linear",children:"Linear Retry"}),e.jsx(i,{value:"custom",children:"Custom Policy"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"enableLogging",className:"rounded"}),e.jsx(a,{htmlFor:"enableLogging",children:"Enable detailed logging"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"enableMetrics",className:"rounded"}),e.jsx(a,{htmlFor:"enableMetrics",children:"Collect performance metrics"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"enableNotifications",className:"rounded"}),e.jsx(a,{htmlFor:"enableNotifications",children:"Send failure notifications"})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(t,{variant:"outline",children:"Reset to Defaults"}),e.jsx(t,{children:"Save Settings"})]})]})]})]})}export{G as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{c as q,m as z,r as t,aX as y,j as e,B as a,aY as R,T as _,D as j,a as g,b as v,d as f,e as A,I as F,$ as N,ai as J,t as i}from"./index-B8vejVRZ.js";import{C as W,b as G,c as Q,d as V,a as Z}from"./card-CvaBJsG6.js";import{L as w}from"./label-DtNTh--4.js";import{B as ee}from"./badge-NJasrAx_.js";import{A as I,a as C}from"./alert-BAeRxZ1d.js";import{P as se}from"./plus-Bon5P_OK.js";import{C as te}from"./circle-alert-61156jM6.js";/**
|
|
2
|
+
* @license lucide-react v0.542.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],L=q("info",ae);function he(){const{authEnabled:n}=z(),[k,P]=t.useState([]),[b,K]=t.useState(!0),[M,o]=t.useState(!1),[O,d]=t.useState(!1),[h,D]=t.useState(""),[x,E]=t.useState("never"),[c,S]=t.useState(null),[m,l]=t.useState(null);t.useEffect(()=>{p()},[]);const p=async()=>{K(!0);try{const s=await y("/api/v1/api-keys");s.success&&P(s.data?.apiKeys||[])}catch(s){console.error("Failed to load API keys:",s),P([])}finally{K(!1)}},U=async()=>{if(!h.trim()){i({title:"Error",description:"Please provide a name for the API key",variant:"destructive"});return}try{const s={name:h,scopes:["*"]};x!=="never"&&(s.expiresIn=x);const r=await y("/api/v1/api-keys",{method:"POST",body:JSON.stringify(s)});r.success&&(S(r.data),o(!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(),l(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"})}},$=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"}),H=s=>s?new Date(s)<new Date:!1,X=typeof window<"u"?window.location.origin:"http://localhost:3000",Y=c?`curl -H "X-API-Key: ${c.key}" \\
|
|
7
|
+
+ ${X}/api/v1/proposals`:"",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(W,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Q,{children:"Active API Keys"}),e.jsx(V,{children:"API keys you've created for programmatic access"})]}),e.jsxs(a,{onClick:()=>o(!0),disabled:!n,children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Create API Key"]})]})}),e.jsx(Z,{children:k.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(R,{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:k.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}),H(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:()=>l(s.id),children:e.jsx(_,{className:"h-4 w-4 text-destructive"})})]},s.id))})})]}),e.jsx(j,{open:M,onOpenChange:o,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:h,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:x,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:()=>o(!1),children:"Cancel"}),e.jsx(a,{onClick:U,disabled:!n,children:"Create API Key"})]})]})}),e.jsx(j,{open:O,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(te,{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:()=>$(c.key),children:e.jsx(J,{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:Y})})]})]}),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&&l(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:()=>l(null),children:"Cancel"}),e.jsx(a,{variant:"destructive",onClick:()=>m&&B(m),children:"Delete API Key"})]})]})})]})}export{he as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{u as D,H as M,r as l,A as b,j as e,B as S,L as I,a2 as _,I as d,a0 as B}from"./index-B8vejVRZ.js";import{C as u,a as p,b as j,c as v}from"./card-CvaBJsG6.js";import{L as o}from"./label-DtNTh--4.js";import{M as P}from"./markdown-editor-DvlGlqU9.js";import{A as R}from"./arrow-left-DSqUNUH-.js";import{C as $}from"./circle-check-big-K_QMED_K.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($,{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(R,{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(B,{id:"commands",value:E,onChange:t=>T(t.target.value),placeholder:`install: npm install
|
|
4
|
+
dev: npm run dev
|
|
5
|
+
test: npm test
|
|
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(P,{value:y,onChange:t=>f(t||""),placeholder:`Write your architecture documentation in markdown...
|
|
8
|
+
|
|
9
|
+
## System Design
|
|
10
|
+
|
|
11
|
+
Describe your high-level system architecture here.
|
|
12
|
+
|
|
13
|
+
## Directory Structure
|
|
14
|
+
|
|
15
|
+
\`\`\`
|
|
16
|
+
project-root/
|
|
17
|
+
├── src/
|
|
18
|
+
│ ├── components/
|
|
19
|
+
│ ├── pages/
|
|
20
|
+
│ └── services/
|
|
21
|
+
\`\`\``,height:800})})]})]})}export{Q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as g,r as n,A as v,j as e,n as y,g as k,B as l,ap as b,ao as w,L as C,J as E,al as A}from"./index-B8vejVRZ.js";import{C as a,a as c,b as o,c as m}from"./card-CvaBJsG6.js";import{c as D}from"./clipboard-B9ndUJKl.js";function F(){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{F as default};
|