@lovelybunch/api 1.0.71-alpha.8 → 1.0.71
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/jobs/job-runner.js +6 -1
- package/dist/lib/mcp-client.d.ts +39 -0
- package/dist/lib/mcp-client.js +131 -0
- package/dist/routes/api/v1/ai/route.js +2 -2
- package/dist/routes/api/v1/ai/tools.js +2 -2
- package/dist/routes/api/v1/mcp/index.js +36 -0
- package/dist/server-with-static.js +7 -0
- package/dist/server.js +7 -0
- package/package.json +4 -4
- package/static/assets/{AgentDetailPage-DgEbsro7.js → AgentDetailPage-CZ2tz-Ol.js} +1 -1
- package/static/assets/{AgentEditPage-C-oRXb2i.js → AgentEditPage-BiAoWU1z.js} +1 -1
- package/static/assets/{AgentsPage-LAiPsGo6.js → AgentsPage-D_HMA-40.js} +1 -1
- package/static/assets/{AgentsSettingsPage-Dg6xOvLr.js → AgentsSettingsPage-C5ZsOVSL.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-CCK0qACG.js → ApiKeysSettingsPage-C7Xlzj-X.js} +1 -1
- package/static/assets/{ArchitectureEditPage-BPO6OFWv.js → ArchitectureEditPage-B9nVQn0B.js} +1 -1
- package/static/assets/{ArchitecturePage-8fad_lNX.js → ArchitecturePage-CChIC6Qa.js} +1 -1
- package/static/assets/{AuthSettingsPage-DdfuUhwy.js → AuthSettingsPage-CaeV2cQ4.js} +1 -1
- package/static/assets/{CallbackPage-B66-RhgE.js → CallbackPage-DmeStBSx.js} +1 -1
- package/static/assets/{CodePage-BXPnfaYj.js → CodePage-BtKkipWC.js} +1 -1
- package/static/assets/{CollapsibleSection-Bo6dPNB0.js → CollapsibleSection-Cb80fCCb.js} +1 -1
- package/static/assets/{DashboardPage-g9RbjrxM.js → DashboardPage-DdApq_B-.js} +1 -1
- package/static/assets/{GitPage-CRhOabK5.js → GitPage-D2aJfzTq.js} +1 -1
- package/static/assets/{GitSettingsPage-4ThmHYiO.js → GitSettingsPage-Bz17VWrK.js} +1 -1
- package/static/assets/{IdentityPage-D2dQOIVu.js → IdentityPage-O7o2b4JB.js} +1 -1
- package/static/assets/{ImplementationStepsEditor-DqjmTpCD.js → ImplementationStepsEditor-BkJjQBc-.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-DL0EQ1Dp.js → IntegrationsSettingsPage-brFTXUBL.js} +1 -1
- package/static/assets/KnowledgeDetailPage-e5OpRrZ2.js +1 -0
- package/static/assets/KnowledgeEditPage-DgyPoIJv.js +1 -0
- package/static/assets/{KnowledgePage-CZBbkkxc.js → KnowledgePage-Ck_FeruK.js} +1 -1
- package/static/assets/{LoginPage-B3yLDlzb.js → LoginPage-IqcnIlMj.js} +1 -1
- package/static/assets/McpSettingsPage-KJBLTelP.js +1 -0
- package/static/assets/{NewAgentPage-DWkEh2H0.js → NewAgentPage-DLIvDpeZ.js} +1 -1
- package/static/assets/NewKnowledgePage-xBm9PTKB.js +9 -0
- package/static/assets/{NewProposalPage-B-6r2u9V.js → NewProposalPage-BlocVyGv.js} +1 -1
- package/static/assets/{ProjectEditPage-CXQL9wWm.js → ProjectEditPage-BlA-908F.js} +1 -1
- package/static/assets/{ProjectPage-N1-VPCXb.js → ProjectPage-Dj-tc-ZE.js} +1 -1
- package/static/assets/{PromptsSettingsPage-CkfWwaVo.js → PromptsSettingsPage-BvU01T7L.js} +1 -1
- package/static/assets/{ProposalDetailPage-CVjCtz3l.js → ProposalDetailPage-_8Wn6NJt.js} +1 -1
- package/static/assets/{ProposalEditPage-BlLNHhID.js → ProposalEditPage-BbbWkAuu.js} +1 -1
- package/static/assets/{ProposalsPage-Cg_8UnUz.js → ProposalsPage-erDBdH7Z.js} +1 -1
- package/static/assets/ResourcesPage-B1uF-EA-.js +71 -0
- package/static/assets/{RulesSettingsPage-DejeW-zE.js → RulesSettingsPage-DurFFm98.js} +1 -1
- package/static/assets/{SchedulePage-DRdcV50U.js → SchedulePage-BAnM4Lu5.js} +1 -1
- package/static/assets/SourceInput-7lTShZ6_.js +1 -0
- package/static/assets/{TagInput-Qey-JNSc.js → TagInput-2_jYxO52.js} +1 -1
- package/static/assets/TerminalPage-CRVEtFXr.js +1 -0
- package/static/assets/{TerminalSessionPage-Gy2cvUkm.js → TerminalSessionPage-BjvQegW1.js} +3 -3
- package/static/assets/{UserPreferencesPage-BuI5MILN.js → UserPreferencesPage-C5ueVUwG.js} +1 -1
- package/static/assets/{UserSettingsPage-qtJLo7KK.js → UserSettingsPage-DhOu8xZ3.js} +1 -1
- package/static/assets/{UtilitiesPage-BFQjoH8u.js → UtilitiesPage-olcchfEX.js} +1 -1
- package/static/assets/{alert-B1XiCMQp.js → alert-bP1PxakB.js} +1 -1
- package/static/assets/{arrow-down-CeHH_n_1.js → arrow-down-BoBPr1Sn.js} +1 -1
- package/static/assets/{arrow-left-1kNbh1Lu.js → arrow-left-orDiJ2Pw.js} +1 -1
- package/static/assets/{arrow-up-BYvPnrJd.js → arrow-up-CCloQpeV.js} +1 -1
- package/static/assets/{badge-NXKbF0v1.js → badge-D7styiB7.js} +1 -1
- package/static/assets/{browser-modal-rJ-NhTpW.js → browser-modal-n0MeSpgA.js} +1 -1
- package/static/assets/{calendar-v-JFQxNh.js → calendar-w3geg78-.js} +1 -1
- package/static/assets/{card-CSNr-FQA.js → card-pzUJtmwJ.js} +1 -1
- package/static/assets/{chevron-left-Br4J9Cp9.js → chevron-left-B6nXpDLi.js} +1 -1
- package/static/assets/{circle-alert-Dupw7IFA.js → circle-alert-BcFpY-ZU.js} +1 -1
- package/static/assets/{circle-check-B9hjnh3h.js → circle-check-HRharHjy.js} +1 -1
- package/static/assets/{circle-check-big-oAo0Oeyn.js → circle-check-big-B2CFEks4.js} +1 -1
- package/static/assets/{circle-play-CVSiuxiN.js → circle-play-CfrNAC9J.js} +1 -1
- package/static/assets/{circle-x-t7MHMAR2.js → circle-x-CNn7_0Ew.js} +1 -1
- package/static/assets/{clipboard-DHZxrsFW.js → clipboard-LaXihY2m.js} +1 -1
- package/static/assets/{clock-LA-30ZGm.js → clock-By2Dd4u0.js} +1 -1
- package/static/assets/{download-CnYQegjL.js → download--HiFU7TR.js} +1 -1
- package/static/assets/droid-C6RWH9f4.js +4 -0
- package/static/assets/{eye-CeI1df80.js → eye-DorygWtP.js} +1 -1
- package/static/assets/{folder-git-2-DEoH-p1C.js → folder-git-2-B8bjLoxc.js} +1 -1
- package/static/assets/{index-D9b0oysW.css → index-B5SwW-PH.css} +1 -1
- package/static/assets/{index-D_Lz5G-Q.js → index-BfJaT17z.js} +8 -8
- package/static/assets/{label-JyYTDtEw.js → label-CTlQtJaU.js} +1 -1
- package/static/assets/{markdown-editor-Chiudu3u.js → markdown-editor-BOcltq2r.js} +1 -1
- package/static/assets/{pause-C3Ag1l-W.js → pause-D33aM-oa.js} +1 -1
- package/static/assets/{play-BCmsp0g8.js → play-B6IdXHPj.js} +1 -1
- package/static/assets/{plus-CMaJeyI7.js → plus-DhYjijTS.js} +1 -1
- package/static/assets/{radio-group-BaKpW9AK.js → radio-group-B-Rc5x_L.js} +1 -1
- package/static/assets/{refresh-cw-2s-Cw28o.js → refresh-cw-BuuX9h4Z.js} +1 -1
- package/static/assets/{search-C_8YfOPe.js → search-BiMN-o92.js} +1 -1
- package/static/assets/{switch-C8QENxXl.js → switch-vSV_roZ2.js} +1 -1
- package/static/assets/{tabs-B2NsP4LT.js → tabs-ChuwGq16.js} +1 -1
- package/static/assets/{tag-BMxDJZSb.js → tag-DERlGH35.js} +1 -1
- package/static/assets/terminal-preview-BFedy4-J.js +11 -0
- package/static/assets/terminal-xj47PT8r.css +1 -0
- package/static/assets/{use-terminal-Se41LFUi.js → use-terminal-qzkum-B5.js} +1 -1
- package/static/assets/{zap-CCyjZlP1.js → zap-DwFz_ltU.js} +1 -1
- package/static/index.html +2 -2
- package/static/assets/KnowledgeDetailPage-Chu61B6A.js +0 -1
- package/static/assets/KnowledgeEditPage-n_nRhHz5.js +0 -1
- package/static/assets/McpSettingsPage-CwJgm_Ig.js +0 -1
- package/static/assets/NewKnowledgePage-qiZHOBk_.js +0 -9
- package/static/assets/ResourcesPage-6X2GbhJW.js +0 -71
- package/static/assets/TerminalPage-oL2epDcB.js +0 -1
- package/static/assets/droid-CmYuCN_q.js +0 -4
- package/static/assets/terminal-preview-BcVtz3Tb.js +0 -11
|
@@ -145,7 +145,12 @@ export class JobRunner {
|
|
|
145
145
|
for (const serverName of mcpServers) {
|
|
146
146
|
const config = allMcpConfigs[serverName];
|
|
147
147
|
if (config && config.enabled !== false) {
|
|
148
|
-
|
|
148
|
+
// Ensure type field is present (required by some CLI tools like Claude)
|
|
149
|
+
const configWithType = { ...config };
|
|
150
|
+
if (!configWithType.type) {
|
|
151
|
+
configWithType.type = configWithType.url ? 'http' : 'stdio';
|
|
152
|
+
}
|
|
153
|
+
filteredConfigs[serverName] = configWithType;
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
const mcpJson = {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client helper for connecting to HTTP/SSE MCP servers
|
|
3
|
+
* Provides tool discovery and execution proxying
|
|
4
|
+
*/
|
|
5
|
+
export interface McpServerConfig {
|
|
6
|
+
name?: string;
|
|
7
|
+
type?: 'http' | 'sse' | 'stdio';
|
|
8
|
+
url?: string;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
env?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export interface DiscoveredTool {
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
inputSchema?: object;
|
|
16
|
+
serverName: string;
|
|
17
|
+
serverUrl: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ToolCallResult {
|
|
20
|
+
content: Array<{
|
|
21
|
+
type: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
isError?: boolean;
|
|
26
|
+
structuredContent?: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Connect to an HTTP/SSE MCP server and discover its available tools
|
|
30
|
+
*/
|
|
31
|
+
export declare function discoverToolsFromServer(serverName: string, config: McpServerConfig): Promise<DiscoveredTool[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Execute a tool on an HTTP/SSE MCP server
|
|
34
|
+
*/
|
|
35
|
+
export declare function executeToolOnServer(serverName: string, config: McpServerConfig, toolName: string, args: Record<string, unknown>): Promise<ToolCallResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Close all cached client connections (for cleanup)
|
|
38
|
+
*/
|
|
39
|
+
export declare function closeAllConnections(): void;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client helper for connecting to HTTP/SSE MCP servers
|
|
3
|
+
* Provides tool discovery and execution proxying
|
|
4
|
+
*/
|
|
5
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
7
|
+
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
8
|
+
// Cache for active client connections
|
|
9
|
+
const clientCache = new Map();
|
|
10
|
+
// Clean up stale connections after 5 minutes
|
|
11
|
+
const CONNECTION_TTL_MS = 5 * 60 * 1000;
|
|
12
|
+
/**
|
|
13
|
+
* Get or create a client connection to an MCP server
|
|
14
|
+
*/
|
|
15
|
+
async function getOrCreateClient(serverName, config) {
|
|
16
|
+
const cacheKey = `${serverName}:${config.url}`;
|
|
17
|
+
const cached = clientCache.get(cacheKey);
|
|
18
|
+
if (cached) {
|
|
19
|
+
cached.lastUsed = Date.now();
|
|
20
|
+
return cached.client;
|
|
21
|
+
}
|
|
22
|
+
const client = new Client({
|
|
23
|
+
name: 'coconut-api',
|
|
24
|
+
version: '1.0.0'
|
|
25
|
+
});
|
|
26
|
+
const url = new URL(config.url);
|
|
27
|
+
// Try StreamableHTTP first (newer), fall back to SSE (legacy)
|
|
28
|
+
let transport;
|
|
29
|
+
if (config.type === 'sse') {
|
|
30
|
+
// Explicitly SSE
|
|
31
|
+
transport = new SSEClientTransport(url);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// Default to StreamableHTTP for 'http' type or unspecified
|
|
35
|
+
transport = new StreamableHTTPClientTransport(url);
|
|
36
|
+
}
|
|
37
|
+
await client.connect(transport);
|
|
38
|
+
clientCache.set(cacheKey, { client, lastUsed: Date.now() });
|
|
39
|
+
// Schedule cleanup
|
|
40
|
+
scheduleCleanup();
|
|
41
|
+
return client;
|
|
42
|
+
}
|
|
43
|
+
let cleanupScheduled = false;
|
|
44
|
+
function scheduleCleanup() {
|
|
45
|
+
if (cleanupScheduled)
|
|
46
|
+
return;
|
|
47
|
+
cleanupScheduled = true;
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
cleanupScheduled = false;
|
|
50
|
+
const now = Date.now();
|
|
51
|
+
for (const [key, entry] of clientCache.entries()) {
|
|
52
|
+
if (now - entry.lastUsed > CONNECTION_TTL_MS) {
|
|
53
|
+
try {
|
|
54
|
+
entry.client.close();
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
// Ignore close errors
|
|
58
|
+
}
|
|
59
|
+
clientCache.delete(key);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Reschedule if there are still cached connections
|
|
63
|
+
if (clientCache.size > 0) {
|
|
64
|
+
scheduleCleanup();
|
|
65
|
+
}
|
|
66
|
+
}, CONNECTION_TTL_MS);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Connect to an HTTP/SSE MCP server and discover its available tools
|
|
70
|
+
*/
|
|
71
|
+
export async function discoverToolsFromServer(serverName, config) {
|
|
72
|
+
if (!config.url) {
|
|
73
|
+
throw new Error(`Server ${serverName} has no URL configured`);
|
|
74
|
+
}
|
|
75
|
+
if (config.enabled === false) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const client = await getOrCreateClient(serverName, config);
|
|
80
|
+
const toolsResult = await client.listTools();
|
|
81
|
+
return toolsResult.tools.map(tool => ({
|
|
82
|
+
name: tool.name,
|
|
83
|
+
description: tool.description,
|
|
84
|
+
inputSchema: tool.inputSchema,
|
|
85
|
+
serverName,
|
|
86
|
+
serverUrl: config.url
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error(`Failed to discover tools from ${serverName}:`, error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Execute a tool on an HTTP/SSE MCP server
|
|
96
|
+
*/
|
|
97
|
+
export async function executeToolOnServer(serverName, config, toolName, args) {
|
|
98
|
+
if (!config.url) {
|
|
99
|
+
throw new Error(`Server ${serverName} has no URL configured`);
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const client = await getOrCreateClient(serverName, config);
|
|
103
|
+
const result = await client.callTool({
|
|
104
|
+
name: toolName,
|
|
105
|
+
arguments: args
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
content: result.content,
|
|
109
|
+
isError: result.isError,
|
|
110
|
+
structuredContent: result.structuredContent
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.error(`Failed to execute tool ${toolName} on ${serverName}:`, error);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Close all cached client connections (for cleanup)
|
|
120
|
+
*/
|
|
121
|
+
export function closeAllConnections() {
|
|
122
|
+
for (const [key, entry] of clientCache.entries()) {
|
|
123
|
+
try {
|
|
124
|
+
entry.client.close();
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
// Ignore close errors
|
|
128
|
+
}
|
|
129
|
+
clientCache.delete(key);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -985,12 +985,12 @@ function getSystemPrompt(context, contextContent) {
|
|
|
985
985
|
- Help maintain consistency across the project`;
|
|
986
986
|
case "settings":
|
|
987
987
|
return `${basePrompt} You are currently in the settings section. Help users:
|
|
988
|
-
- Configure their
|
|
988
|
+
- Configure their Coconut environment
|
|
989
989
|
- Set up integrations and workflows
|
|
990
990
|
- Optimize their development process
|
|
991
991
|
- Understand configuration options
|
|
992
992
|
- Troubleshoot setup issues`;
|
|
993
993
|
default:
|
|
994
|
-
return `${basePrompt} Provide helpful, contextual assistance based on the user's current needs in their
|
|
994
|
+
return `${basePrompt} Provide helpful, contextual assistance based on the user's current needs in their Coconut workflow.`;
|
|
995
995
|
}
|
|
996
996
|
}
|
|
@@ -920,12 +920,12 @@ function getSystemPrompt(context, contextContent) {
|
|
|
920
920
|
- Help maintain consistency across the project`;
|
|
921
921
|
case "settings":
|
|
922
922
|
return `${basePrompt} You are currently in the settings section. Help users:
|
|
923
|
-
- Configure their
|
|
923
|
+
- Configure their Coconut environment
|
|
924
924
|
- Set up integrations and workflows
|
|
925
925
|
- Optimize their development process
|
|
926
926
|
- Understand configuration options
|
|
927
927
|
- Troubleshoot setup issues`;
|
|
928
928
|
default:
|
|
929
|
-
return `${basePrompt} Provide helpful, contextual assistance based on the user's current needs in their
|
|
929
|
+
return `${basePrompt} Provide helpful, contextual assistance based on the user's current needs in their Coconut workflow.`;
|
|
930
930
|
}
|
|
931
931
|
}
|
|
@@ -22,9 +22,34 @@ function resolveGaitPath() {
|
|
|
22
22
|
}
|
|
23
23
|
return basePath;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Helper function to detect transport type from server config
|
|
27
|
+
* @param server - The MCP server configuration object
|
|
28
|
+
* @returns 'http' if server has type='http'/'sse' or url field, 'stdio' otherwise
|
|
29
|
+
*/
|
|
30
|
+
function getTransportType(server) {
|
|
31
|
+
if (server && typeof server === 'object') {
|
|
32
|
+
const s = server;
|
|
33
|
+
// Check explicit type field first
|
|
34
|
+
if (s.type === 'http' || s.type === 'sse') {
|
|
35
|
+
return 'http';
|
|
36
|
+
}
|
|
37
|
+
if (s.type === 'stdio') {
|
|
38
|
+
return 'stdio';
|
|
39
|
+
}
|
|
40
|
+
// Fallback to detecting from url presence
|
|
41
|
+
if ('url' in s && typeof s.url === 'string') {
|
|
42
|
+
return 'http';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return 'stdio';
|
|
46
|
+
}
|
|
25
47
|
/**
|
|
26
48
|
* GET /api/v1/mcp
|
|
27
49
|
* Returns the list of MCP server names and available tools
|
|
50
|
+
*
|
|
51
|
+
* Query params:
|
|
52
|
+
* - transport: 'http' | 'stdio' - Filter servers by transport type (optional)
|
|
28
53
|
*/
|
|
29
54
|
app.get('/', async (c) => {
|
|
30
55
|
try {
|
|
@@ -42,6 +67,17 @@ app.get('/', async (c) => {
|
|
|
42
67
|
console.error('Error reading MCP config:', err);
|
|
43
68
|
}
|
|
44
69
|
}
|
|
70
|
+
// Filter by transport type if query param provided
|
|
71
|
+
const transportFilter = c.req.query('transport');
|
|
72
|
+
if (transportFilter && (transportFilter === 'http' || transportFilter === 'stdio')) {
|
|
73
|
+
const filteredServers = {};
|
|
74
|
+
for (const [name, server] of Object.entries(externalServers)) {
|
|
75
|
+
if (getTransportType(server) === transportFilter) {
|
|
76
|
+
filteredServers[name] = server;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
externalServers = filteredServers;
|
|
80
|
+
}
|
|
45
81
|
const names = Object.keys(externalServers);
|
|
46
82
|
// Add built-in tools (include full JSON schema for parameters)
|
|
47
83
|
// Note: proposals is read-only, knowledge/project/architecture are read+write, events is read-only
|
|
@@ -300,6 +300,13 @@ export async function startServer(options = {}) {
|
|
|
300
300
|
port,
|
|
301
301
|
hostname: host,
|
|
302
302
|
});
|
|
303
|
+
// Set extended timeouts for long-running requests like image generation
|
|
304
|
+
// These need to be longer than the 5-minute Replicate client timeout
|
|
305
|
+
// Node.js HTTP server defaults headersTimeout to 60s which was causing premature timeouts
|
|
306
|
+
const httpServer = server;
|
|
307
|
+
httpServer.timeout = 330_000; // 5.5 minutes (slightly longer than Replicate timeout)
|
|
308
|
+
httpServer.headersTimeout = 330_000;
|
|
309
|
+
httpServer.requestTimeout = 330_000;
|
|
303
310
|
// Inject WebSocket support
|
|
304
311
|
injectWebSocket(server);
|
|
305
312
|
console.log(`🚀 Server running at http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`);
|
package/dist/server.js
CHANGED
|
@@ -233,6 +233,13 @@ const server = serve({
|
|
|
233
233
|
fetch: app.fetch,
|
|
234
234
|
port,
|
|
235
235
|
});
|
|
236
|
+
// Set extended timeouts for long-running requests like image generation
|
|
237
|
+
// These need to be longer than the 5-minute Replicate client timeout
|
|
238
|
+
// Node.js HTTP server defaults headersTimeout to 60s which was causing premature timeouts
|
|
239
|
+
const httpServer = server;
|
|
240
|
+
httpServer.timeout = 330_000; // 5.5 minutes (slightly longer than Replicate timeout)
|
|
241
|
+
httpServer.headersTimeout = 330_000;
|
|
242
|
+
httpServer.requestTimeout = 330_000;
|
|
236
243
|
// Inject WebSocket support
|
|
237
244
|
injectWebSocket(server);
|
|
238
245
|
console.log(`🚀 Server running at http://localhost:${port}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.71
|
|
3
|
+
"version": "1.0.71",
|
|
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
|
|
40
|
-
"@lovelybunch/mcp": "^1.0.71
|
|
41
|
-
"@lovelybunch/types": "^1.0.71
|
|
39
|
+
"@lovelybunch/core": "^1.0.71",
|
|
40
|
+
"@lovelybunch/mcp": "^1.0.71",
|
|
41
|
+
"@lovelybunch/types": "^1.0.71",
|
|
42
42
|
"arctic": "^1.9.2",
|
|
43
43
|
"bcrypt": "^5.1.1",
|
|
44
44
|
"cookie": "^0.6.0",
|
|
@@ -1 +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-
|
|
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-BfJaT17z.js";import{C as l,b as o,a as m,c as f,d as z}from"./card-pzUJtmwJ.js";import{B as v}from"./badge-D7styiB7.js";import{A as u}from"./arrow-left-orDiJ2Pw.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};
|
|
@@ -1 +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-
|
|
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-BfJaT17z.js";import{C as N,a as C,b as se,c as ae}from"./card-pzUJtmwJ.js";import{L as l}from"./label-CTlQtJaU.js";import{B as re}from"./badge-D7styiB7.js";import{c as ne}from"./clipboard-B9ndUJKl.js";import{A as z}from"./arrow-left-orDiJ2Pw.js";import{C as oe,a as ie}from"./clipboard-LaXihY2m.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};
|
|
@@ -1,3 +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-
|
|
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-BfJaT17z.js";import{C as N,a as w,b as D,c as H}from"./card-pzUJtmwJ.js";import{B as y}from"./badge-D7styiB7.js";import{c as U}from"./clipboard-B9ndUJKl.js";import{R as Y,L as F}from"./browser-modal-n0MeSpgA.js";import{R as G,f as J}from"./registry-ANRa5WBi.js";import{P as T}from"./plus-DhYjijTS.js";import{T as K}from"./tag-DERlGH35.js";import"./search-BiMN-o92.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
2
|
|
|
3
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:G,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(Y,{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 ie(){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{ie as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-BfJaT17z.js";import{C as x,b as m,c as u,d as h,a as j}from"./card-pzUJtmwJ.js";import{L as a}from"./label-CTlQtJaU.js";import{B as n}from"./badge-D7styiB7.js";import{P as S}from"./plus-DhYjijTS.js";import{P as p}from"./pause-D33aM-oa.js";import{P as R}from"./play-B6IdXHPj.js";import{Z as T}from"./zap-DwFz_ltU.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as R,m as X,r as t,b5 as y,j as e,B as a,b6 as Y,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-
|
|
1
|
+
import{c as R,m as X,r as t,b5 as y,j as e,B as a,b6 as Y,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-BfJaT17z.js";import{C as W,b as G,c as Q,d as V,a as Z}from"./card-pzUJtmwJ.js";import{L as w}from"./label-CTlQtJaU.js";import{B as ee}from"./badge-D7styiB7.js";import{A as I,a as C}from"./alert-bP1PxakB.js";import{P as se}from"./plus-DhYjijTS.js";import{C as te}from"./circle-alert-BcFpY-ZU.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-BfJaT17z.js";import{C as u,a as p,b as j,c as v}from"./card-pzUJtmwJ.js";import{L as o}from"./label-CTlQtJaU.js";import{M as P}from"./markdown-editor-BOcltq2r.js";import{A as R}from"./arrow-left-orDiJ2Pw.js";import{C as $}from"./circle-check-big-B2CFEks4.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
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
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
4
|
dev: npm run dev
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as g,r as n,A as v,j as e,n as y,g as k,B as l,az as b,ay as w,L as C,J as E,av as A}from"./index-
|
|
1
|
+
import{H as g,r as n,A as v,j as e,n as y,g as k,B as l,az as b,ay as w,L as C,J as E,av as A}from"./index-BfJaT17z.js";import{C as a,a as c,b as o,c as m}from"./card-pzUJtmwJ.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Y,m as le,r as n,b5 as c,j as e,a1 as O,b4 as ce,D as I,_ as M,B as l,a as $,b as V,d as _,e as z,I as j,v as H,w as J,x as W,y as q,z as a,$ as B,M as oe,N as de,T as he,O as ue,P as xe,Q as me,R as ge,U as je,V as pe,W as ve,t as r}from"./index-
|
|
1
|
+
import{c as Y,m as le,r as n,b5 as c,j as e,a1 as O,b4 as ce,D as I,_ as M,B as l,a as $,b as V,d as _,e as z,I as j,v as H,w as J,x as W,y as q,z as a,$ as B,M as oe,N as de,T as he,O as ue,P as xe,Q as me,R as ge,U as je,V as pe,W as ve,t as r}from"./index-BfJaT17z.js";import{C as p,b as v,c as w,d as f,a as y}from"./card-pzUJtmwJ.js";import{L as o}from"./label-CTlQtJaU.js";import{S as U}from"./switch-vSV_roZ2.js";import{B as k}from"./badge-D7styiB7.js";import{C as we}from"./circle-alert-BcFpY-ZU.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,j as e,n as x,A as f}from"./index-
|
|
1
|
+
import{r as m,j as e,n as x,A as f}from"./index-BfJaT17z.js";import{C as w}from"./circle-check-HRharHjy.js";import{C as b}from"./circle-x-CNn7_0Ew.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,p]=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"),p(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(x,{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};
|