@lovelybunch/api 1.0.77 → 1.0.78-alpha.1

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.
Files changed (131) hide show
  1. package/dist/routes/api/v1/auth-settings/route.js +57 -0
  2. package/dist/routes/api/v1/context/architecture/route.d.ts +3 -0
  3. package/dist/routes/api/v1/context/architecture/route.js +245 -0
  4. package/dist/routes/api/v1/context/project/route.d.ts +3 -0
  5. package/dist/routes/api/v1/context/project/route.js +200 -0
  6. package/dist/routes/api/v1/jobs/[id]/route.d.ts +2 -2
  7. package/dist/routes/api/v1/jobs/route.d.ts +2 -2
  8. package/package.json +4 -4
  9. package/static/assets/{ActivityPage-Cq-tJtyJ.js → ActivityPage-GDXCtp2F.js} +1 -1
  10. package/static/assets/{AgentsContextEditPage-JQVZwgYS.js → AgentsContextEditPage-DoMluWwB.js} +1 -1
  11. package/static/assets/{AgentsContextPage-D3qs8jm1.js → AgentsContextPage-CXHbtOdz.js} +1 -1
  12. package/static/assets/{ApiKeysSettingsPage-DV6SHXFl.js → ApiKeysSettingsPage-DbstsqyB.js} +1 -1
  13. package/static/assets/{AuthSettingsPage-HGl3bv86.js → AuthSettingsPage-CK9eFJo0.js} +1 -1
  14. package/static/assets/{CallbackPage-gTamj-aw.js → CallbackPage-BFE5x2Hd.js} +1 -1
  15. package/static/assets/{CoconutCallbackPage-BSsfwmO9.js → CoconutCallbackPage-D2aFrloh.js} +1 -1
  16. package/static/assets/{CodePage-BZglHH_Q.js → CodePage-BfUucBak.js} +1 -1
  17. package/static/assets/{CollapsibleSection-wvr0ZutV.js → CollapsibleSection-Cu7uJYqA.js} +1 -1
  18. package/static/assets/{DashboardPage-kHE94CF0.js → DashboardPage-xDDYm5-7.js} +1 -1
  19. package/static/assets/{GitPage-6RIgBfUa.js → GitPage-Ca_CKgGJ.js} +1 -1
  20. package/static/assets/{GitSettingsPage-BsbGiw1j.js → GitSettingsPage-Bx0JsYW4.js} +1 -1
  21. package/static/assets/{IdentityPage-BNpiVrav.js → IdentityPage-DbG7B63H.js} +1 -1
  22. package/static/assets/{ImplementationStepsEditor-0gLMjKu3.js → ImplementationStepsEditor-D_eIbq-s.js} +1 -1
  23. package/static/assets/{IntegrationsSettingsPage-CrHIVn_B.js → IntegrationsSettingsPage-2lBY2pzo.js} +1 -1
  24. package/static/assets/{JobDetailPage-DQf8bRkh.js → JobDetailPage-DVIv1yvM.js} +1 -1
  25. package/static/assets/{KnowledgeDetailPage-UGz_iyMr.js → KnowledgeDetailPage-CgR2Sjgu.js} +1 -1
  26. package/static/assets/{KnowledgeEditPage-CX7nnUHE.js → KnowledgeEditPage-XrvVy-Nr.js} +1 -1
  27. package/static/assets/{KnowledgePage-B9vVX08N.js → KnowledgePage-Bd4yUZve.js} +1 -1
  28. package/static/assets/{LoginPage-uctPsP7c.js → LoginPage-BPjBtFbe.js} +1 -1
  29. package/static/assets/{MailInboxPage-iFOMcWbJ.js → MailInboxPage-Uv5Yd0V5.js} +1 -1
  30. package/static/assets/{MailProcessingModal-CWZ6NlWD.js → MailProcessingModal-DFCnUJD5.js} +1 -1
  31. package/static/assets/{MailReadPage-Cm3EGR04.js → MailReadPage-BjBTIvdR.js} +1 -1
  32. package/static/assets/{MailSentPage-B_yCduWu.js → MailSentPage-Dsv4mmWO.js} +1 -1
  33. package/static/assets/{McpSettingsPage-BIuIEeMa.js → McpSettingsPage-ddInKeE_.js} +1 -1
  34. package/static/assets/{MemoryEditPage-UItxPPYu.js → MemoryEditPage-1Duk8_Ep.js} +1 -1
  35. package/static/assets/{MemoryPage-Bewz284-.js → MemoryPage-BsVDrfoH.js} +1 -1
  36. package/static/assets/{NewKnowledgePage-CTFD-rPP.js → NewKnowledgePage-QD99jkhw.js} +1 -1
  37. package/static/assets/{NewSkillPage-BUJ5TRTk.js → NewSkillPage-CzXXY_2H.js} +1 -1
  38. package/static/assets/{NewTaskPage-B34HFZLj.js → NewTaskPage-Dnvq8q0H.js} +1 -1
  39. package/static/assets/{NotFoundPage-BfybYiKU.js → NotFoundPage-CXNHyu2I.js} +1 -1
  40. package/static/assets/{NotificationsSettingsPage-1ydinio6.js → NotificationsSettingsPage-CMwizTN5.js} +1 -1
  41. package/static/assets/{PromptsSettingsPage-DqO7rEba.js → PromptsSettingsPage-mzfSW46B.js} +1 -1
  42. package/static/assets/{ResourceDetailPage-BFG5kNE4.js → ResourceDetailPage-DmVFJJeE.js} +1 -1
  43. package/static/assets/{ResourcesPage-B0NtohGC.js → ResourcesPage-B-S4WIgq.js} +1 -1
  44. package/static/assets/{RoleEditPage-CgsWmLJB.js → RoleEditPage-CLDE56qK.js} +1 -1
  45. package/static/assets/{RolePage-CI6GUlGa.js → RolePage-D43fy7y9.js} +1 -1
  46. package/static/assets/{RulesSettingsPage-TUgWSUD5.js → RulesSettingsPage-CZJQIr_7.js} +1 -1
  47. package/static/assets/{RunDetailPage-CXlauF0u.js → RunDetailPage-DM1a32RR.js} +1 -1
  48. package/static/assets/{SchedulePage-KyktudT3.js → SchedulePage-D2fMyBig.js} +1 -1
  49. package/static/assets/{SkillDetailPage-DHxNBkWp.js → SkillDetailPage-BePyNqOX.js} +1 -1
  50. package/static/assets/{SkillEditPage-Lrm4XlCK.js → SkillEditPage-DBc1H0t2.js} +1 -1
  51. package/static/assets/{SkillsPage-b7uubp-n.js → SkillsPage-Be_0YQkP.js} +1 -1
  52. package/static/assets/{SkillsSettingsPage-BRJIpJec.js → SkillsSettingsPage-Vr645xmf.js} +1 -1
  53. package/static/assets/{SourceInput-Qv8Dn4Xx.js → SourceInput-Xd7tPRiQ.js} +1 -1
  54. package/static/assets/{TagInput-Czvs9lsc.js → TagInput-D0zZF7xt.js} +1 -1
  55. package/static/assets/{TaskDetailPage-CivkpQe2.js → TaskDetailPage-Bpg8n3W0.js} +1 -1
  56. package/static/assets/{TaskEditPage-Bc6gS0c6.js → TaskEditPage-BNvNMUgF.js} +1 -1
  57. package/static/assets/{TasksPage-DuKgC8KM.js → TasksPage-BQE58PD0.js} +1 -1
  58. package/static/assets/{TeamEditPage-m4NJFGUY.js → TeamEditPage-C4UQSONx.js} +1 -1
  59. package/static/assets/{TeamPage-DBU-jnVj.js → TeamPage-CVtSifUm.js} +1 -1
  60. package/static/assets/{TerminalPage-CI45TuGe.js → TerminalPage-SUFGXm4l.js} +1 -1
  61. package/static/assets/{TerminalSessionPage-DQkhJQaK.js → TerminalSessionPage-BVsNKUkH.js} +1 -1
  62. package/static/assets/{UserPreferencesPage-BUY2Lmbx.js → UserPreferencesPage-Df-ITRan.js} +1 -1
  63. package/static/assets/{UserSettingsPage-BcMiPkly.js → UserSettingsPage-DXVtBXML.js} +1 -1
  64. package/static/assets/{UtilitiesPage-DMerZZcL.js → UtilitiesPage-D6fqcEaT.js} +1 -1
  65. package/static/assets/{alert-BSl_15w4.js → alert-DAl4a56c.js} +1 -1
  66. package/static/assets/{arrow-down-_ri289ss.js → arrow-down-CDCYDGUx.js} +1 -1
  67. package/static/assets/{arrow-left-Fa3x1DU7.js → arrow-left-VDfx33Jh.js} +1 -1
  68. package/static/assets/{arrow-up-iWDv2UXW.js → arrow-up-CDSv61uo.js} +1 -1
  69. package/static/assets/{arrow-up-down-Ckwtzrps.js → arrow-up-down-Ezpoqf2s.js} +1 -1
  70. package/static/assets/{badge-YRTRpaJp.js → badge-D_uqNUSH.js} +1 -1
  71. package/static/assets/{browser-modal-U9aSv2St.js → browser-modal-C5jrpzix.js} +1 -1
  72. package/static/assets/{card-_08H8QL5.js → card-B0QREUF4.js} +1 -1
  73. package/static/assets/{chevron-left-BLnAnQzA.js → chevron-left-35sibkLF.js} +1 -1
  74. package/static/assets/{chevron-up-CrW20eZR.js → chevron-up-BjM6KODw.js} +1 -1
  75. package/static/assets/{chevrons-up-BrCIGM2h.js → chevrons-up-jJ4zW_aE.js} +1 -1
  76. package/static/assets/{circle-alert-CCndfzX8.js → circle-alert-gQD7uoQT.js} +1 -1
  77. package/static/assets/{circle-check-D2WB1eR8.js → circle-check-KTXf2BuN.js} +1 -1
  78. package/static/assets/{circle-check-big-B12KqpqV.js → circle-check-big-CJ5S5SSR.js} +1 -1
  79. package/static/assets/{circle-play-D8mTxsnE.js → circle-play-SYdQRKi1.js} +1 -1
  80. package/static/assets/{circle-x-CPxsFSfb.js → circle-x-Bcwe-LN_.js} +1 -1
  81. package/static/assets/{clipboard-BXUoFzC_.js → clipboard-VHK-krjO.js} +1 -1
  82. package/static/assets/{clock-B7qx7N62.js → clock-D5ggHAx5.js} +1 -1
  83. package/static/assets/{code-B-wgFVBM.js → code-Dg1ZHEGS.js} +1 -1
  84. package/static/assets/{download-CIGVn2po.js → download-CGb5cJiK.js} +1 -1
  85. package/static/assets/{external-link-CD6WP5iK.js → external-link-Cf9EKGQO.js} +1 -1
  86. package/static/assets/{eye-C-lnahtV.js → eye-oD_Emdr8.js} +1 -1
  87. package/static/assets/{folder-git-2-CkR5A1oS.js → folder-git-2-DX-nlC0d.js} +1 -1
  88. package/static/assets/{globe-D3Av4xEm.js → globe-pOzIGyKN.js} +1 -1
  89. package/static/assets/{index-BBof4w7u.js → index-BIwO8uo-.js} +1 -1
  90. package/static/assets/{index-C-It-oJ8.js → index-BUPxY8PP.js} +3 -3
  91. package/static/assets/{index-Cr9wB9uC.js → index-BXQJo5V4.js} +1 -1
  92. package/static/assets/{index-BOOVSXG_.js → index-Bfgdm0Cb.js} +1 -1
  93. package/static/assets/{index-CRfSJN7A.js → index-Bxwh96Rz.js} +1 -1
  94. package/static/assets/{index-BVG65cBY.js → index-C3FDBd4S.js} +1 -1
  95. package/static/assets/{index-Dtu42bmK.js → index-C3MMQmQg.js} +1 -1
  96. package/static/assets/{index-B5h_EDHQ.js → index-C6yQwDNN.js} +1 -1
  97. package/static/assets/{index-BgtJOhTt.js → index-CC7HjVOa.js} +1 -1
  98. package/static/assets/{index-ZcikYUIr.js → index-CCGFI_UP.js} +1 -1
  99. package/static/assets/{index-BZ-DEXFT.js → index-CHyffstY.js} +1 -1
  100. package/static/assets/{index-CpVubLYu.js → index-Cidb9y3R.js} +1 -1
  101. package/static/assets/{index-CSunDccS.js → index-CoFwRL3K.js} +1 -1
  102. package/static/assets/{index-B5VNtwZQ.js → index-CusNnDtY.js} +1 -1
  103. package/static/assets/{index-BiTK53WF.js → index-Cuz8Apx7.js} +1 -1
  104. package/static/assets/{index-BwbLMbrC.js → index-DchDWBTE.js} +1 -1
  105. package/static/assets/{index-CdxRNWYK.js → index-DjJ6EU0v.js} +1 -1
  106. package/static/assets/{index-DZp_7HEX.js → index-FklRfl66.js} +1 -1
  107. package/static/assets/{index-DMMdqgMw.js → index-pfpWERL-.js} +1 -1
  108. package/static/assets/{info-D_iUr_LO.js → info-DlnFCJCq.js} +1 -1
  109. package/static/assets/{label-DpGd2A9i.js → label-CjHH2sSK.js} +1 -1
  110. package/static/assets/{markdown-editor-DsIWl9E6.js → markdown-editor-BN8QzPHa.js} +3 -3
  111. package/static/assets/{message-square-CU7CplMV.js → message-square-k2mWEt-W.js} +1 -1
  112. package/static/assets/{paperclip-BdTSwWBI.js → paperclip-pH0rHAfm.js} +1 -1
  113. package/static/assets/{pause-VD4MvX1V.js → pause-BF-WAXuj.js} +1 -1
  114. package/static/assets/{play-CIBDggo3.js → play-szwfQctH.js} +1 -1
  115. package/static/assets/{radio-group-BwcltCgD.js → radio-group-BAAsV2rJ.js} +1 -1
  116. package/static/assets/{refresh-cw-DjSZHJFs.js → refresh-cw-CxDJQR9R.js} +1 -1
  117. package/static/assets/{search-DtmFY0AW.js → search-CoqBUnty.js} +1 -1
  118. package/static/assets/{select-B3LUgp-0.js → select-SvSJ1fXP.js} +1 -1
  119. package/static/assets/{server-6-FMGHIh.js → server-yLtQ3igN.js} +1 -1
  120. package/static/assets/{switch-D7Gn9yQA.js → switch-DNt53KzF.js} +1 -1
  121. package/static/assets/{tabs-PDBtRsYD.js → tabs-DBHspaGs.js} +1 -1
  122. package/static/assets/{tag-B30iaxwe.js → tag-yDsYYVah.js} +1 -1
  123. package/static/assets/{terminal-preview-ZpgPQSVP.js → terminal-preview-DYd7d-he.js} +1 -1
  124. package/static/assets/{triangle-alert-D2pqhLFw.js → triangle-alert-Dy1Oo-ts.js} +1 -1
  125. package/static/assets/{use-terminal-Cp7abMCW.js → use-terminal-DpQ4ZVfs.js} +1 -1
  126. package/static/assets/{video-CteJuAKv.js → video-BoEpz24p.js} +1 -1
  127. package/static/index.html +1 -1
  128. package/dist/config/m2m.d.ts +0 -26
  129. package/dist/config/m2m.js +0 -27
  130. package/dist/lib/auth/clerk-m2m-verifier.d.ts +0 -34
  131. package/dist/lib/auth/clerk-m2m-verifier.js +0 -47
@@ -293,6 +293,63 @@ authSettings.put('/oauth/coconut', async (c) => {
293
293
  return c.json({ success: false, error: error.message || 'Failed to update Coconut OAuth' }, error.message === 'Admin access required' ? 403 : 500);
294
294
  }
295
295
  });
296
+ /**
297
+ * PUT /api/v1/auth-settings/control-plane
298
+ * Admin-only: set or clear control plane secrets persisted in auth.json.
299
+ *
300
+ * Request body:
301
+ * { callbackToken: string }
302
+ *
303
+ * Rules:
304
+ * - `callbackToken` is required and must be a string.
305
+ * - Non-empty values are trimmed and persisted.
306
+ * - Empty-string values clear the persisted token.
307
+ *
308
+ * Response intentionally never returns the raw token; it only reports whether
309
+ * a callback token is configured after the update.
310
+ */
311
+ authSettings.put('/control-plane', async (c) => {
312
+ try {
313
+ requireAdmin(c);
314
+ const authManager = getAuthManager();
315
+ const config = await authManager.loadAuthConfig();
316
+ const body = await c.req
317
+ .json()
318
+ .catch(() => ({}));
319
+ if (typeof body.callbackToken !== 'string') {
320
+ return c.json({ success: false, error: '`callbackToken` (string) is required' }, 400);
321
+ }
322
+ const callbackToken = body.callbackToken.trim();
323
+ if (!config.controlPlane) {
324
+ config.controlPlane = {};
325
+ }
326
+ if (callbackToken) {
327
+ config.controlPlane.callbackToken = callbackToken;
328
+ }
329
+ else {
330
+ delete config.controlPlane.callbackToken;
331
+ if (Object.keys(config.controlPlane).length === 0) {
332
+ delete config.controlPlane;
333
+ }
334
+ }
335
+ await authManager.saveAuthConfig(config);
336
+ return c.json({
337
+ success: true,
338
+ data: {
339
+ controlPlane: {
340
+ hasCallbackToken: !!config.controlPlane?.callbackToken,
341
+ },
342
+ },
343
+ });
344
+ }
345
+ catch (error) {
346
+ console.error('Update control plane settings error:', error);
347
+ return c.json({
348
+ success: false,
349
+ error: error.message || 'Failed to update control plane settings',
350
+ }, error.message === 'Admin access required' ? 403 : 500);
351
+ }
352
+ });
296
353
  /**
297
354
  * PUT /api/v1/auth-settings/oauth/:provider
298
355
  * Configure a third-party OAuth provider (admin only). Coconut OAuth has its
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ declare const app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
3
+ export default app;
@@ -0,0 +1,245 @@
1
+ import { Hono } from 'hono';
2
+ import { promises as fs } from 'fs';
3
+ import path from 'path';
4
+ import matter from 'gray-matter';
5
+ import { findGaitDirectory } from '../../../../../lib/gait-path.js';
6
+ import { getLogger, ContextKinds } from '@lovelybunch/core/logging';
7
+ import { requireAuth } from '../../../../../middleware/auth.js';
8
+ // Helper function to generate a simple summary from content
9
+ function generateSummary(content, maxLines = 3, maxChars = 200) {
10
+ // Remove markdown formatting for cleaner summary
11
+ const cleanContent = content
12
+ .replace(/^#+\s+/gm, '') // Remove headings
13
+ .replace(/[*_`]/g, '') // Remove bold, italic, code
14
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Convert links to text
15
+ .trim();
16
+ // Get first few lines
17
+ const lines = cleanContent.split('\n').filter(line => line.trim().length > 0);
18
+ const summary = lines.slice(0, maxLines).join(' ');
19
+ // Truncate if too long
20
+ return summary.length > maxChars
21
+ ? summary.substring(0, maxChars) + '...'
22
+ : summary;
23
+ }
24
+ const app = new Hono();
25
+ async function getArchitecturePath() {
26
+ const gaitDir = await findGaitDirectory();
27
+ if (!gaitDir)
28
+ return null;
29
+ return path.join(gaitDir, 'context');
30
+ }
31
+ /**
32
+ * GET /api/v1/context/architecture
33
+ * Load architecture document
34
+ */
35
+ app.get('/', async (c) => {
36
+ try {
37
+ const architecturePath = await getArchitecturePath();
38
+ if (!architecturePath) {
39
+ return c.json({
40
+ success: false,
41
+ error: 'GAIT directory not found'
42
+ }, 404);
43
+ }
44
+ // Ensure directory exists
45
+ await fs.mkdir(architecturePath, { recursive: true });
46
+ // Look for architecture.md file
47
+ const filePath = path.join(architecturePath, 'architecture.md');
48
+ try {
49
+ const fileContent = await fs.readFile(filePath, 'utf-8');
50
+ const { data, content } = matter(fileContent);
51
+ // Extract title from first heading or use default
52
+ const title = content.match(/^#\s+(.+)$/m)?.[1] || 'Architecture Overview';
53
+ const document = {
54
+ filename: 'architecture.md',
55
+ metadata: {
56
+ ...data,
57
+ updated: data.updated || new Date().toISOString().split('T')[0],
58
+ type: 'architecture',
59
+ category: 'design',
60
+ tags: data.tags || []
61
+ },
62
+ content,
63
+ title
64
+ };
65
+ return c.json({
66
+ success: true,
67
+ document
68
+ });
69
+ }
70
+ catch (fileError) {
71
+ // If file doesn't exist, return default content
72
+ const defaultContent = `# Architecture Overview
73
+
74
+ This document describes the overall architecture and design patterns used in this project.
75
+
76
+ ## System Architecture
77
+
78
+ Describe the high-level system architecture, including major components and their relationships.
79
+
80
+ ## Design Patterns
81
+
82
+ Document the key design patterns and architectural principles followed in this project.
83
+
84
+ ### Frontend Architecture
85
+
86
+ - Component structure
87
+ - State management
88
+ - Routing approach
89
+ - UI/UX patterns
90
+
91
+ ### Backend Architecture
92
+
93
+ - API design
94
+ - Data layer
95
+ - Service architecture
96
+ - Authentication & authorization
97
+
98
+ ## Data Flow
99
+
100
+ Explain how data flows through the system, including:
101
+
102
+ - Request/response cycles
103
+ - Data transformations
104
+ - Caching strategies
105
+ - Error handling
106
+
107
+ ## Technology Decisions
108
+
109
+ Document key technology choices and the reasoning behind them:
110
+
111
+ - Framework selections
112
+ - Database choices
113
+ - Third-party integrations
114
+ - Development tools
115
+
116
+ ## Deployment Architecture
117
+
118
+ Describe the deployment strategy and infrastructure:
119
+
120
+ - Environment setup
121
+ - CI/CD pipeline
122
+ - Monitoring and logging
123
+ - Scaling considerations
124
+
125
+ ## Security Considerations
126
+
127
+ Outline security measures and best practices:
128
+
129
+ - Authentication mechanisms
130
+ - Data protection
131
+ - API security
132
+ - Infrastructure security
133
+
134
+ ## Performance Considerations
135
+
136
+ Document performance optimization strategies:
137
+
138
+ - Caching layers
139
+ - Database optimization
140
+ - Frontend performance
141
+ - Monitoring and metrics
142
+ `;
143
+ const document = {
144
+ filename: 'architecture.md',
145
+ metadata: {
146
+ version: '1.0',
147
+ updated: new Date().toISOString().split('T')[0],
148
+ type: 'architecture',
149
+ category: 'design',
150
+ tags: []
151
+ },
152
+ content: defaultContent,
153
+ title: 'Architecture Overview'
154
+ };
155
+ return c.json({
156
+ success: true,
157
+ document
158
+ });
159
+ }
160
+ }
161
+ catch (error) {
162
+ console.error('Error loading architecture document:', error);
163
+ return c.json({
164
+ success: false,
165
+ error: 'Failed to load architecture document'
166
+ }, 500);
167
+ }
168
+ });
169
+ /**
170
+ * PUT /api/v1/context/architecture
171
+ * Update architecture document
172
+ */
173
+ app.put('/', async (c) => {
174
+ try {
175
+ const body = await c.req.json();
176
+ if (!body.content) {
177
+ return c.json({ success: false, error: 'Content is required' }, 400);
178
+ }
179
+ const architecturePath = await getArchitecturePath();
180
+ if (!architecturePath) {
181
+ return c.json({ success: false, error: 'GAIT directory not found' }, 404);
182
+ }
183
+ await fs.mkdir(architecturePath, { recursive: true });
184
+ const filePath = path.join(architecturePath, 'architecture.md');
185
+ // Read current content if it exists
186
+ let currentData = {};
187
+ try {
188
+ const currentContent = await fs.readFile(filePath, 'utf-8');
189
+ const { data } = matter(currentContent);
190
+ currentData = data;
191
+ }
192
+ catch {
193
+ // File doesn't exist, use defaults
194
+ }
195
+ // Prepare updated metadata
196
+ const updatedMetadata = {
197
+ ...currentData,
198
+ ...body.metadata,
199
+ updated: new Date().toISOString().split('T')[0],
200
+ type: 'architecture',
201
+ category: 'design',
202
+ version: currentData.version || '1.0'
203
+ };
204
+ // Create the markdown content with frontmatter
205
+ const fileContent = matter.stringify(body.content, updatedMetadata);
206
+ await fs.writeFile(filePath, fileContent, 'utf-8');
207
+ // Extract updated title
208
+ const title = body.title ||
209
+ body.content.match(/^#\s+(.+)$/m)?.[1] ||
210
+ 'Architecture Overview';
211
+ // Log architecture update event
212
+ try {
213
+ const session = await requireAuth(c);
214
+ const actor = session ? `human:${session.email}` : "human:unknown";
215
+ const logger = getLogger();
216
+ logger.log({
217
+ kind: ContextKinds.ARCHITECTURE_UPDATE,
218
+ actor,
219
+ subject: `context:architecture.md`,
220
+ tags: ["context", "architecture"],
221
+ payload: {
222
+ title,
223
+ summary: generateSummary(body.content),
224
+ }
225
+ });
226
+ }
227
+ catch (logError) {
228
+ console.error('Error logging architecture update:', logError);
229
+ }
230
+ return c.json({
231
+ success: true,
232
+ document: {
233
+ filename: 'architecture.md',
234
+ title,
235
+ metadata: updatedMetadata,
236
+ content: body.content
237
+ }
238
+ });
239
+ }
240
+ catch (error) {
241
+ console.error('Error updating architecture document:', error);
242
+ return c.json({ success: false, error: 'Failed to update architecture document' }, 500);
243
+ }
244
+ });
245
+ export default app;
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ declare const app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
3
+ export default app;
@@ -0,0 +1,200 @@
1
+ import { Hono } from 'hono';
2
+ import { promises as fs } from 'fs';
3
+ import path from 'path';
4
+ import matter from 'gray-matter';
5
+ import { findGaitDirectory } from '../../../../../lib/gait-path.js';
6
+ import { getLogger, ContextKinds } from '@lovelybunch/core/logging';
7
+ import { requireAuth } from '../../../../../middleware/auth.js';
8
+ // Helper function to generate a simple summary from content
9
+ function generateSummary(content, maxLines = 3, maxChars = 200) {
10
+ // Remove markdown formatting for cleaner summary
11
+ const cleanContent = content
12
+ .replace(/^#+\s+/gm, '') // Remove headings
13
+ .replace(/[*_`]/g, '') // Remove bold, italic, code
14
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Convert links to text
15
+ .trim();
16
+ // Get first few lines
17
+ const lines = cleanContent.split('\n').filter(line => line.trim().length > 0);
18
+ const summary = lines.slice(0, maxLines).join(' ');
19
+ // Truncate if too long
20
+ return summary.length > maxChars
21
+ ? summary.substring(0, maxChars) + '...'
22
+ : summary;
23
+ }
24
+ const app = new Hono();
25
+ async function getProjectPath() {
26
+ const gaitDir = await findGaitDirectory();
27
+ if (!gaitDir)
28
+ return null;
29
+ return path.join(gaitDir, 'context');
30
+ }
31
+ /**
32
+ * GET /api/v1/context/project
33
+ * Load project overview document
34
+ */
35
+ app.get('/', async (c) => {
36
+ try {
37
+ const projectPath = await getProjectPath();
38
+ if (!projectPath) {
39
+ return c.json({
40
+ success: false,
41
+ error: 'GAIT directory not found'
42
+ }, 404);
43
+ }
44
+ // Ensure directory exists
45
+ await fs.mkdir(projectPath, { recursive: true });
46
+ // Look for project.md file
47
+ const filePath = path.join(projectPath, 'project.md');
48
+ try {
49
+ const fileContent = await fs.readFile(filePath, 'utf-8');
50
+ const { data, content } = matter(fileContent);
51
+ // Extract title from first heading or use default
52
+ const title = content.match(/^#\s+(.+)$/m)?.[1] || 'Project Overview';
53
+ const document = {
54
+ filename: 'project.md',
55
+ metadata: {
56
+ ...data,
57
+ updated: data.updated || new Date().toISOString().split('T')[0],
58
+ type: 'project',
59
+ category: 'overview',
60
+ tags: data.tags || []
61
+ },
62
+ content,
63
+ title
64
+ };
65
+ return c.json({
66
+ success: true,
67
+ document
68
+ });
69
+ }
70
+ catch (fileError) {
71
+ // If file doesn't exist, return default content
72
+ const defaultContent = `# Project Overview
73
+
74
+ This document provides an overview of the project, including its purpose, goals, and key information.
75
+
76
+ ## Purpose
77
+
78
+ Describe the main purpose and objectives of this project.
79
+
80
+ ## Key Features
81
+
82
+ - Feature 1
83
+ - Feature 2
84
+ - Feature 3
85
+
86
+ ## Technology Stack
87
+
88
+ List the main technologies, frameworks, and tools used in this project.
89
+
90
+ ## Getting Started
91
+
92
+ Provide instructions for setting up and running the project locally.
93
+
94
+ ## Documentation
95
+
96
+ Links to additional documentation, guides, and resources.
97
+ `;
98
+ const document = {
99
+ filename: 'project.md',
100
+ metadata: {
101
+ version: '1.0',
102
+ updated: new Date().toISOString().split('T')[0],
103
+ type: 'project',
104
+ category: 'overview',
105
+ tags: []
106
+ },
107
+ content: defaultContent,
108
+ title: 'Project Overview'
109
+ };
110
+ return c.json({
111
+ success: true,
112
+ document
113
+ });
114
+ }
115
+ }
116
+ catch (error) {
117
+ console.error('Error loading project document:', error);
118
+ return c.json({
119
+ success: false,
120
+ error: 'Failed to load project document'
121
+ }, 500);
122
+ }
123
+ });
124
+ /**
125
+ * PUT /api/v1/context/project
126
+ * Update project overview document
127
+ */
128
+ app.put('/', async (c) => {
129
+ try {
130
+ const body = await c.req.json();
131
+ if (!body.content) {
132
+ return c.json({ success: false, error: 'Content is required' }, 400);
133
+ }
134
+ const projectPath = await getProjectPath();
135
+ if (!projectPath) {
136
+ return c.json({ success: false, error: 'GAIT directory not found' }, 404);
137
+ }
138
+ await fs.mkdir(projectPath, { recursive: true });
139
+ const filePath = path.join(projectPath, 'project.md');
140
+ // Read current content if it exists
141
+ let currentData = {};
142
+ try {
143
+ const currentContent = await fs.readFile(filePath, 'utf-8');
144
+ const { data } = matter(currentContent);
145
+ currentData = data;
146
+ }
147
+ catch {
148
+ // File doesn't exist, use defaults
149
+ }
150
+ // Prepare updated metadata
151
+ const updatedMetadata = {
152
+ ...currentData,
153
+ ...body.metadata,
154
+ updated: new Date().toISOString().split('T')[0],
155
+ type: 'project',
156
+ category: 'overview',
157
+ version: currentData.version || '1.0'
158
+ };
159
+ // Create the markdown content with frontmatter
160
+ const fileContent = matter.stringify(body.content, updatedMetadata);
161
+ await fs.writeFile(filePath, fileContent, 'utf-8');
162
+ // Extract updated title
163
+ const title = body.title ||
164
+ body.content.match(/^#\s+(.+)$/m)?.[1] ||
165
+ 'Project Overview';
166
+ // Log project update event
167
+ try {
168
+ const session = await requireAuth(c);
169
+ const actor = session ? `human:${session.email}` : "human:unknown";
170
+ const logger = getLogger();
171
+ logger.log({
172
+ kind: ContextKinds.PROJECT_UPDATE,
173
+ actor,
174
+ subject: `context:project.md`,
175
+ tags: ["context", "project"],
176
+ payload: {
177
+ title,
178
+ summary: generateSummary(body.content),
179
+ }
180
+ });
181
+ }
182
+ catch (logError) {
183
+ console.error('Error logging project update:', logError);
184
+ }
185
+ return c.json({
186
+ success: true,
187
+ document: {
188
+ filename: 'project.md',
189
+ title,
190
+ metadata: updatedMetadata,
191
+ content: body.content
192
+ }
193
+ });
194
+ }
195
+ catch (error) {
196
+ console.error('Error updating project document:', error);
197
+ return c.json({ success: false, error: 'Failed to update project document' }, 500);
198
+ }
199
+ });
200
+ export default app;
@@ -39,8 +39,8 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
39
39
  agentIds?: string[];
40
40
  mcpServers?: string[];
41
41
  runs: {
42
- id: string;
43
42
  error?: string;
43
+ id: string;
44
44
  status: import("@lovelybunch/types").ScheduledJobRunStatus;
45
45
  jobId: string;
46
46
  trigger: import("@lovelybunch/types").ScheduledJobTrigger;
@@ -100,8 +100,8 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
100
100
  agentIds?: string[];
101
101
  mcpServers?: string[];
102
102
  runs: {
103
- id: string;
104
103
  error?: string;
104
+ id: string;
105
105
  status: import("@lovelybunch/types").ScheduledJobRunStatus;
106
106
  jobId: string;
107
107
  trigger: import("@lovelybunch/types").ScheduledJobTrigger;
@@ -41,8 +41,8 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
41
41
  agentIds?: string[];
42
42
  mcpServers?: string[];
43
43
  runs: {
44
- id: string;
45
44
  error?: string;
45
+ id: string;
46
46
  status: import("@lovelybunch/types").ScheduledJobRunStatus;
47
47
  jobId: string;
48
48
  trigger: import("@lovelybunch/types").ScheduledJobTrigger;
@@ -96,8 +96,8 @@ export declare function POST(c: Context): Promise<(Response & import("hono").Typ
96
96
  agentIds?: string[];
97
97
  mcpServers?: string[];
98
98
  runs: {
99
- id: string;
100
99
  error?: string;
100
+ id: string;
101
101
  status: import("@lovelybunch/types").ScheduledJobRunStatus;
102
102
  jobId: string;
103
103
  trigger: import("@lovelybunch/types").ScheduledJobTrigger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovelybunch/api",
3
- "version": "1.0.77",
3
+ "version": "1.0.78-alpha.1",
4
4
  "type": "module",
5
5
  "main": "dist/server-with-static.js",
6
6
  "exports": {
@@ -40,9 +40,9 @@
40
40
  "sharp": "^0.33.5",
41
41
  "ws": "^8.18.0",
42
42
  "zod": "^3.23.0",
43
- "@lovelybunch/types": "1.0.77",
44
- "@lovelybunch/core": "1.0.77",
45
- "@lovelybunch/mcp": "1.0.77"
43
+ "@lovelybunch/core": "1.0.78-alpha.1",
44
+ "@lovelybunch/types": "1.0.78-alpha.1",
45
+ "@lovelybunch/mcp": "1.0.78-alpha.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/adm-zip": "^0.5.7",
@@ -1 +1 @@
1
- import{r as a,A as p,j as e,v,bN as y,B as N,n as w,C as b}from"./index-C-It-oJ8.js";import{C as c,a as d,b as k,c as C}from"./card-_08H8QL5.js";import{B as m}from"./badge-YRTRpaJp.js";import{R as E}from"./refresh-cw-DjSZHJFs.js";const A=5e3;function $(){const[n,o]=a.useState([]),[i,x]=a.useState(!0),[h,u]=a.useState(new Set),l=a.useCallback(async()=>{x(!0);try{const s=await fetch(`${p}/api/v1/events?limit=${A}`);if(!s.ok)throw new Error("Failed to load events");const t=await s.json();o(Array.isArray(t.items)?[...t.items].reverse():[])}catch(s){console.error("Failed to load events:",s),o([])}finally{x(!1)}},[]),g=a.useCallback(s=>{u(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},[]);a.useEffect(()=>{l()},[l]);const f=s=>{if(!s)return"Unknown time";try{return new Date(s).toLocaleString()}catch{return s}},j=s=>{switch(s?.toLowerCase()){case"error":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";case"warn":case"warning":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";case"info":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"debug":return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}};return i?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(v,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading events..."})]})})})]}):n.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(y,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Events Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Activity events will appear here as they occur."})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsxs("p",{className:"text-muted-foreground",children:["View system activity and events (",n.length," events)"]})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>void l(),disabled:i,children:[e.jsx(E,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`}),"Refresh"]})]}),e.jsx("div",{className:"space-y-3",children:n.map(s=>{const t=h.has(s.seq);return e.jsxs(c,{className:"transition-colors",children:[e.jsx(k,{className:"py-3 cursor-pointer hover:bg-muted/30",onClick:()=>g(s.seq),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-2 flex-1 min-w-0",children:[t?e.jsx(w,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}):e.jsx(b,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(C,{className:"text-sm font-medium",children:["#",s.seq]}),s.kind&&e.jsx(m,{variant:"outline",className:"text-xs",children:s.kind}),s.level&&e.jsx(m,{className:`text-xs ${j(s.level)}`,children:s.level})]}),s.message&&e.jsx("p",{className:`text-sm text-muted-foreground ${t?"":"truncate"}`,children:s.message})]})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:f(s.ts)})]})}),t&&e.jsx(d,{className:"pt-0 pb-4",children:e.jsx("pre",{className:"text-xs bg-muted p-3 rounded-md overflow-x-auto",children:JSON.stringify(s,null,2)})})]},s.seq)})})]})}export{$ as default};
1
+ import{r as a,A as p,j as e,v,bN as y,B as N,n as w,C as b}from"./index-BUPxY8PP.js";import{C as c,a as d,b as k,c as C}from"./card-B0QREUF4.js";import{B as m}from"./badge-D_uqNUSH.js";import{R as E}from"./refresh-cw-CxDJQR9R.js";const A=5e3;function $(){const[n,o]=a.useState([]),[i,x]=a.useState(!0),[h,u]=a.useState(new Set),l=a.useCallback(async()=>{x(!0);try{const s=await fetch(`${p}/api/v1/events?limit=${A}`);if(!s.ok)throw new Error("Failed to load events");const t=await s.json();o(Array.isArray(t.items)?[...t.items].reverse():[])}catch(s){console.error("Failed to load events:",s),o([])}finally{x(!1)}},[]),g=a.useCallback(s=>{u(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},[]);a.useEffect(()=>{l()},[l]);const f=s=>{if(!s)return"Unknown time";try{return new Date(s).toLocaleString()}catch{return s}},j=s=>{switch(s?.toLowerCase()){case"error":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";case"warn":case"warning":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";case"info":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"debug":return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}};return i?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(v,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading events..."})]})})})]}):n.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(y,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Events Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Activity events will appear here as they occur."})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsxs("p",{className:"text-muted-foreground",children:["View system activity and events (",n.length," events)"]})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>void l(),disabled:i,children:[e.jsx(E,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`}),"Refresh"]})]}),e.jsx("div",{className:"space-y-3",children:n.map(s=>{const t=h.has(s.seq);return e.jsxs(c,{className:"transition-colors",children:[e.jsx(k,{className:"py-3 cursor-pointer hover:bg-muted/30",onClick:()=>g(s.seq),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-2 flex-1 min-w-0",children:[t?e.jsx(w,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}):e.jsx(b,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(C,{className:"text-sm font-medium",children:["#",s.seq]}),s.kind&&e.jsx(m,{variant:"outline",className:"text-xs",children:s.kind}),s.level&&e.jsx(m,{className:`text-xs ${j(s.level)}`,children:s.level})]}),s.message&&e.jsx("p",{className:`text-sm text-muted-foreground ${t?"":"truncate"}`,children:s.message})]})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:f(s.ts)})]})}),t&&e.jsx(d,{className:"pt-0 pb-4",children:e.jsx("pre",{className:"text-xs bg-muted p-3 rounded-md overflow-x-auto",children:JSON.stringify(s,null,2)})})]},s.seq)})})]})}export{$ as default};
@@ -1,4 +1,4 @@
1
- import{u as p,a as j,r as n,A as l,j as e,B as h,L as v,a5 as N}from"./index-C-It-oJ8.js";import{C as m,a as x,b as C,c as S}from"./card-_08H8QL5.js";import{M as w}from"./markdown-editor-DsIWl9E6.js";import{A as y}from"./arrow-left-Fa3x1DU7.js";import{C as A}from"./circle-check-big-B12KqpqV.js";import"./index-CpVubLYu.js";function F(){const f=p(),{toast:t}=j(),[a,i]=n.useState(""),[g,r]=n.useState(!0),[o,c]=n.useState(!1);n.useEffect(()=>{fetch(`${l}/api/v1/context/agents`).then(s=>s.json()).then(s=>{s.success&&i(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load agents definition",variant:"destructive"}),r(!1)})},[t]);const u=async()=>{c(!0);try{const d=await(await fetch(`${l}/api/v1/context/agents`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a,metadata:{}})})).json();if(d.success)t({title:"Success",description:"Agents definition saved successfully",action:e.jsx(A,{className:"h-4 w-4"})}),f("/context/agents");else throw new Error(d.error||"Failed to save")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save agents definition",variant:"destructive"})}finally{c(!1)}};return g?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{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 Agents Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define agents, their capabilities, and configurations"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:"/context/agents",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(y,{className:"w-4 h-4"})})}),e.jsxs(h,{onClick:u,disabled:o,size:"sm",children:[e.jsx(N,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(C,{children:e.jsx(S,{children:"Agents Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:a,onChange:s=>i(s||""),placeholder:`Write your agents definition in markdown...
1
+ import{u as p,a as j,r as n,A as l,j as e,B as h,L as v,a5 as N}from"./index-BUPxY8PP.js";import{C as m,a as x,b as C,c as S}from"./card-B0QREUF4.js";import{M as w}from"./markdown-editor-BN8QzPHa.js";import{A as y}from"./arrow-left-VDfx33Jh.js";import{C as A}from"./circle-check-big-CJ5S5SSR.js";import"./index-Cidb9y3R.js";function F(){const f=p(),{toast:t}=j(),[a,i]=n.useState(""),[g,r]=n.useState(!0),[o,c]=n.useState(!1);n.useEffect(()=>{fetch(`${l}/api/v1/context/agents`).then(s=>s.json()).then(s=>{s.success&&i(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load agents definition",variant:"destructive"}),r(!1)})},[t]);const u=async()=>{c(!0);try{const d=await(await fetch(`${l}/api/v1/context/agents`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a,metadata:{}})})).json();if(d.success)t({title:"Success",description:"Agents definition saved successfully",action:e.jsx(A,{className:"h-4 w-4"})}),f("/context/agents");else throw new Error(d.error||"Failed to save")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save agents definition",variant:"destructive"})}finally{c(!1)}};return g?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{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 Agents Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define agents, their capabilities, and configurations"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:"/context/agents",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(y,{className:"w-4 h-4"})})}),e.jsxs(h,{onClick:u,disabled:o,size:"sm",children:[e.jsx(N,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(C,{children:e.jsx(S,{children:"Agents Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:a,onChange:s=>i(s||""),placeholder:`Write your agents definition in markdown...
2
2
 
3
3
  ## Agent Definitions
4
4
 
@@ -1 +1 @@
1
- import{a as g,r as t,A as N,j as e,v,az as C,B as a,L as d,a2 as l,M as w,ay as y,au as E}from"./index-C-It-oJ8.js";import{C as i,a as c,b}from"./card-_08H8QL5.js";import{c as A}from"./clipboard-B9ndUJKl.js";function D(){const{toast:r}=g(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${N}/api/v1/context/agents`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/agents.md";try{await A(s),r({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),r({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"agents-md",filename:"agents.md",name:"agents.md",path:".nut/context/agents.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(v,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading agents definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Agents Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Agents definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(d,{to:"/context/agents/edit",children:[e.jsx(l,{className:"h-4 w-4 mr-2"}),"Create Agents Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground",children:"Agent definitions and configurations"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(d,{to:"/context/agents/edit",children:[e.jsx(l,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(b,{className:"pb-0"}),e.jsx(c,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(E,{children:o.content||"No content available"})})})]})]})}export{D as default};
1
+ import{a as g,r as t,A as N,j as e,v,az as C,B as a,L as d,a2 as l,M as w,ay as y,au as E}from"./index-BUPxY8PP.js";import{C as i,a as c,b}from"./card-B0QREUF4.js";import{c as A}from"./clipboard-B9ndUJKl.js";function D(){const{toast:r}=g(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${N}/api/v1/context/agents`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/agents.md";try{await A(s),r({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),r({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"agents-md",filename:"agents.md",name:"agents.md",path:".nut/context/agents.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(v,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading agents definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Agents Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Agents definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(d,{to:"/context/agents/edit",children:[e.jsx(l,{className:"h-4 w-4 mr-2"}),"Create Agents Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground",children:"Agent definitions and configurations"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(d,{to:"/context/agents/edit",children:[e.jsx(l,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(b,{className:"pb-0"}),e.jsx(c,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(E,{children:o.content||"No content available"})})})]})]})}export{D as default};