@lovelybunch/api 1.0.76-alpha.9 → 1.0.77-alpha.0

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 (173) hide show
  1. package/dist/lib/git.d.ts +3 -0
  2. package/dist/lib/git.js +35 -0
  3. package/dist/lib/terminal/terminal-manager.js +2 -1
  4. package/dist/routes/api/v1/ai/route.js +214 -152
  5. package/dist/routes/api/v1/config/route.js +13 -9
  6. package/dist/routes/api/v1/context/agents/route.d.ts +3 -0
  7. package/dist/routes/api/v1/context/agents/route.js +159 -0
  8. package/dist/routes/api/v1/context/index.js +6 -4
  9. package/dist/routes/api/v1/context/memory/route.d.ts +3 -0
  10. package/dist/routes/api/v1/context/memory/route.js +163 -0
  11. package/dist/routes/api/v1/context/team/route.d.ts +3 -0
  12. package/dist/routes/api/v1/context/team/route.js +159 -0
  13. package/dist/routes/api/v1/events/status/route.d.ts +1 -1
  14. package/dist/routes/api/v1/git/index.js +27 -1
  15. package/dist/routes/api/v1/jobs/[id]/route.d.ts +26 -32
  16. package/dist/routes/api/v1/jobs/[id]/route.js +3 -3
  17. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
  18. package/dist/routes/api/v1/jobs/[id]/runs/[runId]/route.d.ts +2 -2
  19. package/dist/routes/api/v1/jobs/route.d.ts +33 -33
  20. package/dist/routes/api/v1/jobs/route.js +17 -2
  21. package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
  22. package/dist/routes/api/v1/mail/route.d.ts +3 -3
  23. package/dist/routes/api/v1/mcp/index.js +194 -21
  24. package/dist/routes/api/v1/resources/generate/route.js +10 -3
  25. package/dist/routes/api/v1/slack/route.d.ts +6 -6
  26. package/dist/routes/api/v1/tasks/[id]/route.d.ts +4 -4
  27. package/dist/routes/api/v1/tasks/[id]/steps/[stepId]/route.d.ts +2 -2
  28. package/dist/routes/api/v1/tasks/route.d.ts +1 -1
  29. package/dist/server-with-static.js +23 -17
  30. package/dist/server.js +1 -0
  31. package/package.json +24 -23
  32. package/static/assets/ActivityPage-rASRHKYj.js +1 -0
  33. package/static/assets/AgentsContextEditPage-CMWD-7mS.js +9 -0
  34. package/static/assets/AgentsContextPage-VfMmxxr6.js +1 -0
  35. package/static/assets/{ApiKeysSettingsPage-CjrCuHHE.js → ApiKeysSettingsPage-DxtuyXwn.js} +2 -2
  36. package/static/assets/{AuthSettingsPage-elJX4TCV.js → AuthSettingsPage-CWTpS6BA.js} +2 -2
  37. package/static/assets/{CallbackPage-CUuZYgBL.js → CallbackPage-CjlTVuif.js} +1 -1
  38. package/static/assets/CodePage-DwjtGxQi.js +2 -0
  39. package/static/assets/{CollapsibleSection-DfTxWX0X.js → CollapsibleSection-LrQJlSxD.js} +1 -1
  40. package/static/assets/{DashboardPage-CmS8UPSm.js → DashboardPage-DnyFyDO0.js} +9 -19
  41. package/static/assets/{GitPage-DSfn76oO.js → GitPage-o37iQMYQ.js} +3 -3
  42. package/static/assets/{GitSettingsPage-Bu8h7hcr.js → GitSettingsPage-O0fe5kxm.js} +2 -2
  43. package/static/assets/{IdentityPage-NFKq2FHi.js → IdentityPage-KWjruliO.js} +2 -2
  44. package/static/assets/{ImplementationStepsEditor-Cn-MshnR.js → ImplementationStepsEditor-h_Mxu1tF.js} +2 -2
  45. package/static/assets/IntegrationsSettingsPage-DeFQd6af.js +1 -0
  46. package/static/assets/JobDetailPage-HOLpF7Sx.js +1 -0
  47. package/static/assets/KnowledgeDetailPage-C5egPQ54.js +1 -0
  48. package/static/assets/KnowledgeEditPage-DrdvEGuR.js +1 -0
  49. package/static/assets/{KnowledgePage-C3zoPEcH.js → KnowledgePage-CK5rtZcv.js} +2 -2
  50. package/static/assets/{LoginPage-BYNLGEnz.js → LoginPage-DajEouCN.js} +1 -1
  51. package/static/assets/MailInboxPage-CewILL7o.js +1 -0
  52. package/static/assets/MailProcessingModal-B1ZLXyYl.js +1 -0
  53. package/static/assets/MailReadPage--LnQ743i.js +1 -0
  54. package/static/assets/MailSentPage-BqO4iBq6.js +1 -0
  55. package/static/assets/{McpSettingsPage-CfhBioEH.js → McpSettingsPage-BZ6GJOtk.js} +1 -1
  56. package/static/assets/MemoryEditPage-BLfdKEDu.js +13 -0
  57. package/static/assets/MemoryPage-BV0RlvUS.js +1 -0
  58. package/static/assets/{NewKnowledgePage-BUwh_DFd.js → NewKnowledgePage-SrBhXpH6.js} +1 -1
  59. package/static/assets/{NewSkillPage-B2rztwzD.js → NewSkillPage-vt-0rIkv.js} +1 -1
  60. package/static/assets/{NewTaskPage-Cvw20nug.js → NewTaskPage-CBUpwIFP.js} +2 -2
  61. package/static/assets/{NotFoundPage-CXvLVHsT.js → NotFoundPage-CWF5qOC0.js} +1 -1
  62. package/static/assets/{NotificationsSettingsPage-Df_GZ7_p.js → NotificationsSettingsPage-3ZvMrqiq.js} +1 -1
  63. package/static/assets/{PromptsSettingsPage-QTxJgO5-.js → PromptsSettingsPage-pHKoiUPI.js} +1 -1
  64. package/static/assets/{ResourceDetailPage-C9RHHVKu.js → ResourceDetailPage-CE4iDbv7.js} +1 -1
  65. package/static/assets/ResourcesPage-4_5NA4RF.js +41 -0
  66. package/static/assets/{RoleEditPage-N2-v2MXN.js → RoleEditPage-4sSELIRX.js} +1 -1
  67. package/static/assets/{RolePage-Da0kZMUH.js → RolePage-Ds17xn4X.js} +1 -1
  68. package/static/assets/{RulesSettingsPage-CSd5iz22.js → RulesSettingsPage-DnyGaden.js} +1 -1
  69. package/static/assets/RunDetailPage-D2ajvKfh.js +1 -0
  70. package/static/assets/SchedulePage-oEGct1B1.js +4 -0
  71. package/static/assets/{SkillDetailPage-QjqBAuFU.js → SkillDetailPage-mSypV_JK.js} +1 -1
  72. package/static/assets/{SkillEditPage-BB0x4VVH.js → SkillEditPage-DeI8uu3S.js} +1 -1
  73. package/static/assets/{SkillsPage-BMDNxMmZ.js → SkillsPage-Bb_dEdun.js} +2 -2
  74. package/static/assets/{SkillsSettingsPage-DcdeOlAl.js → SkillsSettingsPage-CMWf2O9y.js} +1 -1
  75. package/static/assets/SourceInput-CtyUOXOG.js +1 -0
  76. package/static/assets/{TagInput-bxFcAknC.js → TagInput-C0NyMxlY.js} +1 -1
  77. package/static/assets/{TaskDetailPage-CAmREdfh.js → TaskDetailPage-6DDI0juh.js} +1 -1
  78. package/static/assets/{TaskEditPage-BDgZtG36.js → TaskEditPage-Btc1NXtR.js} +1 -1
  79. package/static/assets/{TasksPage-BQ6eLw0T.js → TasksPage-C9TYvqRz.js} +3 -3
  80. package/static/assets/TeamEditPage-CLvNy6Ss.js +9 -0
  81. package/static/assets/TeamPage-DSWax4fa.js +1 -0
  82. package/static/assets/{TerminalPage-BhWGRGf1.js → TerminalPage-DNDHEYJZ.js} +1 -1
  83. package/static/assets/{TerminalSessionPage-Bu-WiE0d.js → TerminalSessionPage-nNCw_oDE.js} +2 -2
  84. package/static/assets/{UserPreferencesPage-B_Tu1a8h.js → UserPreferencesPage-jc1SA79x.js} +1 -1
  85. package/static/assets/UserSettingsPage-pr6n15Pz.js +1 -0
  86. package/static/assets/UtilitiesPage-CjLb989o.js +1 -0
  87. package/static/assets/{alert-C42EBWiI.js → alert-BtkLXQ3p.js} +1 -1
  88. package/static/assets/{arrow-down-CuFFg288.js → arrow-down-DnNLmXEs.js} +1 -1
  89. package/static/assets/{arrow-left-C8VbyW3d.js → arrow-left-B9NBHEkS.js} +1 -1
  90. package/static/assets/{arrow-up-down-GN3qK2mU.js → arrow-up-down-DIuMvAne.js} +1 -1
  91. package/static/assets/{arrow-up-vC1c-5gW.js → arrow-up-eMUJY7J9.js} +1 -1
  92. package/static/assets/{badge-CKwUSKzT.js → badge-BbfU_aPt.js} +1 -1
  93. package/static/assets/{browser-modal-C9VBJ_El.js → browser-modal-J9l3o5os.js} +2 -2
  94. package/static/assets/{card-DRBgMGuU.js → card-CL5bB4cs.js} +1 -1
  95. package/static/assets/{chevron-left-2sP4ienq.js → chevron-left-B-7K6MNx.js} +1 -1
  96. package/static/assets/{chevron-up-DJfyvHso.js → chevron-up-BwTmMEW2.js} +1 -1
  97. package/static/assets/{chevrons-up-DfFpzHXf.js → chevrons-up-jI6nxhrz.js} +1 -1
  98. package/static/assets/{circle-alert-DP4rtmEK.js → circle-alert-vJFSz39V.js} +1 -1
  99. package/static/assets/{circle-check-Cnp-EoKX.js → circle-check-D2LVHMl-.js} +1 -1
  100. package/static/assets/{circle-check-big-3mrGMFVn.js → circle-check-big-BwQ_q1N7.js} +1 -1
  101. package/static/assets/{circle-play-7F5AVehH.js → circle-play-CLKDBkrK.js} +1 -1
  102. package/static/assets/{circle-x-DxbiyJ6w.js → circle-x-CuUVLiI-.js} +1 -1
  103. package/static/assets/{clipboard-CQNR4_yT.js → clipboard-BHOFelnW.js} +1 -1
  104. package/static/assets/{clock-DGw3R_UL.js → clock-D-X3KCw6.js} +1 -1
  105. package/static/assets/{code-DSNMK8tD.js → code-DqYaanki.js} +1 -1
  106. package/static/assets/{download-BWL6PFiw.js → download-DeEju9jg.js} +1 -1
  107. package/static/assets/{external-link-BqUE-DMN.js → external-link-CrRz0sU-.js} +1 -1
  108. package/static/assets/{eye-BD57N1qQ.js → eye-Cx9ZGkg5.js} +1 -1
  109. package/static/assets/{folder-git-2-CW5Zi8Bm.js → folder-git-2-Cizv1NA6.js} +1 -1
  110. package/static/assets/globe-lpD9Jv31.js +6 -0
  111. package/static/assets/{index-BWktaW8U.js → index-BCYTbJRb.js} +1 -1
  112. package/static/assets/{index-BArpuuuE.js → index-BL-5Bhtg.js} +1 -1
  113. package/static/assets/{index-EpelXypg.js → index-BPdWQ0rI.js} +1 -1
  114. package/static/assets/{index-CheR43vH.js → index-BVrOTqTm.js} +1 -1
  115. package/static/assets/{index-uxv5vQZF.js → index-BknCCMZK.js} +1 -1
  116. package/static/assets/{index-CVVL2h9f.js → index-BvZJRqTz.js} +1 -1
  117. package/static/assets/index-ByTA2ZiD.js +497 -0
  118. package/static/assets/{index-CMt1ExW-.js → index-CMaK0hpv.js} +1 -1
  119. package/static/assets/{index-CMQcknsg.js → index-CkT4WgqR.js} +1 -1
  120. package/static/assets/{index-Bedu89qc.js → index-CuLP7P_G.js} +1 -1
  121. package/static/assets/{index-B9OOTqx4.js → index-D12O6wM3.js} +1 -1
  122. package/static/assets/{index-stPObw-o.js → index-DIt703WU.js} +1 -1
  123. package/static/assets/{index-CXWGFCS-.js → index-DK1gGyTZ.js} +1 -1
  124. package/static/assets/index-DVMcu9sQ.css +1 -0
  125. package/static/assets/{index-BG5vEV31.js → index-Dc9Njo8L.js} +1 -1
  126. package/static/assets/{index-B0fLM-4F.js → index-DgAcL75U.js} +1 -1
  127. package/static/assets/{index-BmTTXfmk.js → index-Djzp98Vj.js} +1 -1
  128. package/static/assets/{index-DO47L-WG.js → index-Dnj5cWsp.js} +1 -1
  129. package/static/assets/{index-X4fPPLHI.js → index-Hy3cH93B.js} +1 -1
  130. package/static/assets/{index-D4awulBm.js → index-ihWq-CVE.js} +1 -1
  131. package/static/assets/{info-DMJxIp7i.js → info-DxhTCbw1.js} +1 -1
  132. package/static/assets/{label-DxDedS8x.js → label-Dp0-28_O.js} +1 -1
  133. package/static/assets/{markdown-editor-DJ2CscSp.js → markdown-editor-DUmrf1eN.js} +3 -3
  134. package/static/assets/{message-square-DF58cqKJ.js → message-square-BPOApeM3.js} +1 -1
  135. package/static/assets/{paperclip-CHyfSVll.js → paperclip-Bfjc1WLZ.js} +1 -1
  136. package/static/assets/{pause-B-ouFhaQ.js → pause-Bfz-QQZp.js} +1 -1
  137. package/static/assets/{pipeline-builders-Bkf0wt_O.js → pipeline-builders-DrEjlsbH.js} +1 -1
  138. package/static/assets/{play-B0y1weCV.js → play-fOwEoIcu.js} +1 -1
  139. package/static/assets/{radio-group-DFNQiPDU.js → radio-group-B8RB7N01.js} +1 -1
  140. package/static/assets/{refresh-cw-5y5jTc6x.js → refresh-cw-Cj_5MZiJ.js} +1 -1
  141. package/static/assets/{search-B5deRThk.js → search-BgbqRUnf.js} +1 -1
  142. package/static/assets/{select-BzOa_wZx.js → select-CfwLZl55.js} +1 -1
  143. package/static/assets/server-u9FLHclt.js +6 -0
  144. package/static/assets/{switch-Bf2z8aaj.js → switch-CX_Inx_p.js} +1 -1
  145. package/static/assets/{tabs-DkdBSep3.js → tabs-Bj0YyeRI.js} +1 -1
  146. package/static/assets/{tag-gRsTk0jY.js → tag-rYG4CdRx.js} +1 -1
  147. package/static/assets/terminal-preview-BNm5-Umi.js +1 -0
  148. package/static/assets/triangle-alert-C0ovMJwZ.js +6 -0
  149. package/static/assets/{use-terminal-D6Qe1nwM.js → use-terminal-D1UnvAVs.js} +1 -1
  150. package/static/assets/{video-DXo9sCfT.js → video-CuyRES-H.js} +1 -1
  151. package/static/index.html +2 -2
  152. package/static/assets/ActivityPage-BaSoKgwZ.js +0 -1
  153. package/static/assets/ArchitectureEditPage-MYU7btLs.js +0 -21
  154. package/static/assets/ArchitecturePage-CGqWy8b1.js +0 -1
  155. package/static/assets/CodePage-C_bzfOnI.js +0 -2
  156. package/static/assets/IntegrationsSettingsPage-Cw6ItrNf.js +0 -1
  157. package/static/assets/JobDetailPage-DLSD4HiU.js +0 -1
  158. package/static/assets/KnowledgeDetailPage-DY8PpD9X.js +0 -1
  159. package/static/assets/KnowledgeEditPage-B28N-7vM.js +0 -1
  160. package/static/assets/MailInboxPage-DDYg0W70.js +0 -1
  161. package/static/assets/MailProcessingModal-CXIrtSz0.js +0 -6
  162. package/static/assets/MailReadPage-CVz6oD-y.js +0 -1
  163. package/static/assets/MailSentPage-ClaVWZCR.js +0 -1
  164. package/static/assets/ProjectEditPage-DKf6ZoiG.js +0 -11
  165. package/static/assets/ProjectPage-CHhx9s1k.js +0 -1
  166. package/static/assets/ResourcesPage-BI8tfYZ2.js +0 -41
  167. package/static/assets/SchedulePage-CS8g2Db-.js +0 -4
  168. package/static/assets/SourceInput-rc4KSqcv.js +0 -1
  169. package/static/assets/UserSettingsPage-BnEGtrGo.js +0 -1
  170. package/static/assets/UtilitiesPage-k7ABCAig.js +0 -1
  171. package/static/assets/index-Cht-fo9a.css +0 -1
  172. package/static/assets/index-DB2Tq9wz.js +0 -487
  173. package/static/assets/terminal-preview-BfrUN2ok.js +0 -1
@@ -7,6 +7,9 @@ export declare function getConfig(c: Context): Promise<(Response & import("hono"
7
7
  success: true;
8
8
  data: {
9
9
  enabled: boolean;
10
+ channelId: string;
11
+ channelName: string;
12
+ siteUrl: string;
10
13
  notifications: {
11
14
  proposals: {
12
15
  created: boolean;
@@ -21,9 +24,6 @@ export declare function getConfig(c: Context): Promise<(Response & import("hono"
21
24
  merge: boolean;
22
25
  };
23
26
  };
24
- channelId: string;
25
- channelName: string;
26
- siteUrl: string;
27
27
  hasBotToken: boolean;
28
28
  hasSigningSecret: boolean;
29
29
  };
@@ -39,6 +39,9 @@ export declare function updateConfig(c: Context): Promise<(Response & import("ho
39
39
  success: true;
40
40
  data: {
41
41
  enabled: boolean;
42
+ channelId: string;
43
+ channelName: string;
44
+ siteUrl: string;
42
45
  notifications: {
43
46
  proposals: {
44
47
  created: boolean;
@@ -53,9 +56,6 @@ export declare function updateConfig(c: Context): Promise<(Response & import("ho
53
56
  merge: boolean;
54
57
  };
55
58
  };
56
- channelId: string;
57
- channelName: string;
58
- siteUrl: string;
59
59
  hasBotToken: boolean;
60
60
  hasSigningSecret: boolean;
61
61
  };
@@ -13,7 +13,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
13
13
  intent?: string;
14
14
  content?: string;
15
15
  author: {
16
- type: import("@lovelybunch/types").AuthorType;
16
+ type: import("node_modules/@lovelybunch/types/src/index.js").AuthorType;
17
17
  id: string;
18
18
  name: string;
19
19
  email?: string;
@@ -29,7 +29,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
29
29
  error?: string;
30
30
  executedAt?: string;
31
31
  }[];
32
- status: import("@lovelybunch/types").TaskStatus;
32
+ status: import("node_modules/@lovelybunch/types/src/index.js").TaskStatus;
33
33
  comments?: {
34
34
  id: string;
35
35
  author: string;
@@ -60,7 +60,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
60
60
  intent?: string;
61
61
  content?: string;
62
62
  author: {
63
- type: import("@lovelybunch/types").AuthorType;
63
+ type: import("node_modules/@lovelybunch/types/src/index.js").AuthorType;
64
64
  id: string;
65
65
  name: string;
66
66
  email?: string;
@@ -76,7 +76,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
76
76
  error?: string;
77
77
  executedAt?: string;
78
78
  }[];
79
- status: import("@lovelybunch/types").TaskStatus;
79
+ status: import("node_modules/@lovelybunch/types/src/index.js").TaskStatus;
80
80
  comments?: {
81
81
  id: string;
82
82
  author: string;
@@ -19,7 +19,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
19
19
  intent?: string;
20
20
  content?: string;
21
21
  author: {
22
- type: import("@lovelybunch/types").AuthorType;
22
+ type: import("node_modules/@lovelybunch/types/src/index.js").AuthorType;
23
23
  id: string;
24
24
  name: string;
25
25
  email?: string;
@@ -35,7 +35,7 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
35
35
  error?: string;
36
36
  executedAt?: string;
37
37
  }[];
38
- status: import("@lovelybunch/types").TaskStatus;
38
+ status: import("node_modules/@lovelybunch/types/src/index.js").TaskStatus;
39
39
  comments?: {
40
40
  id: string;
41
41
  author: string;
@@ -14,7 +14,7 @@ import { Context } from 'hono';
14
14
  */
15
15
  export declare function GET(c: Context): Promise<(Response & import("hono").TypedResponse<{
16
16
  offset: number;
17
- data: never[];
17
+ data: import("hono/utils/types").JSONValue[];
18
18
  limit: number;
19
19
  totalCount: number;
20
20
  count: number;
@@ -16,6 +16,11 @@ const __filename = fileURLToPath(import.meta.url);
16
16
  const __dirname = path.dirname(__filename);
17
17
  // Load environment variables from .env file in project root
18
18
  dotenvConfig({ path: path.resolve(__dirname, '../../../.env') });
19
+ const verbose = process.env.COCONUT_VERBOSE === '1' || process.env.COCONUT_VERBOSE === 'true';
20
+ function vlog(...args) {
21
+ if (verbose)
22
+ console.log(...args);
23
+ }
19
24
  // Helper: Find .nut directory by traversing up from cwd
20
25
  // Only returns a .nut directory if it contains config.json
21
26
  function findNutDirectorySync() {
@@ -33,7 +38,7 @@ function findNutDirectorySync() {
33
38
  }
34
39
  // Initialize logger with config from .nut/config.json or use OS app data directory
35
40
  // This must happen BEFORE importing route handlers (they call getLogger at module level)
36
- console.log('🔍 Initializing activity logging...');
41
+ vlog('🔍 Initializing activity logging...');
37
42
  try {
38
43
  const nutDir = findNutDirectorySync();
39
44
  let logsDir = getLogsDir(); // Default to OS app data directory
@@ -43,8 +48,8 @@ try {
43
48
  if (nutDir) {
44
49
  const projectRoot = path.dirname(nutDir);
45
50
  const configPath = path.join(nutDir, 'config.json');
46
- console.log(' Project root:', projectRoot);
47
- console.log(' Config path:', configPath);
51
+ vlog(' Project root:', projectRoot);
52
+ vlog(' Config path:', configPath);
48
53
  const configData = fs.readFileSync(configPath, 'utf-8');
49
54
  const config = JSON.parse(configData);
50
55
  // Check if logging is explicitly disabled in config
@@ -68,9 +73,9 @@ try {
68
73
  logsDir,
69
74
  rotateBytes
70
75
  });
71
- console.log('📝 Activity logging ENABLED');
72
- console.log(' Logs directory:', logsDir);
73
- console.log(' Coconut ID:', coconutId);
76
+ vlog('📝 Activity logging ENABLED');
77
+ vlog(' Logs directory:', logsDir);
78
+ vlog(' Coconut ID:', coconutId);
74
79
  // Test log immediately
75
80
  logger.log({
76
81
  kind: 'system.startup',
@@ -79,10 +84,10 @@ try {
79
84
  tags: ['system', 'startup'],
80
85
  payload: { message: 'Server starting with logging enabled' }
81
86
  });
82
- console.log(' ✓ Test event logged');
87
+ vlog(' ✓ Test event logged');
83
88
  }
84
89
  else {
85
- console.log('📝 Activity logging disabled in config');
90
+ vlog('📝 Activity logging disabled in config');
86
91
  }
87
92
  }
88
93
  catch (error) {
@@ -100,13 +105,14 @@ app.use('/api/*', trimTrailingSlash());
100
105
  // Import and apply authentication middleware
101
106
  import { authMiddleware } from './middleware/auth.js';
102
107
  app.use('/api/*', authMiddleware);
108
+ app.use('/ws/*', authMiddleware);
103
109
  // Create WebSocket support
104
110
  const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
105
111
  // WebSocket route for terminal sessions
106
112
  app.get('/ws/terminal/:sessionId', upgradeWebSocket((c) => ({
107
113
  onOpen: (_evt, ws) => {
108
114
  const sessionId = c.req.param('sessionId');
109
- console.log(`WebSocket connected for terminal session: ${sessionId}`);
115
+ vlog(`WebSocket connected for terminal session: ${sessionId}`);
110
116
  const terminalManager = getGlobalTerminalManager();
111
117
  // Extract the raw WebSocket from the WSContext
112
118
  const rawWs = ws.raw;
@@ -125,7 +131,7 @@ app.get('/ws/terminal/:sessionId', upgradeWebSocket((c) => ({
125
131
  // Message handling is done in the terminal manager
126
132
  },
127
133
  onClose: (_evt, _ws) => {
128
- console.log('WebSocket connection closed');
134
+ vlog('WebSocket connection closed');
129
135
  },
130
136
  onError: (evt, _ws) => {
131
137
  console.error('WebSocket error:', evt);
@@ -185,7 +191,7 @@ import version from './routes/api/v1/version/index.js';
185
191
  import { slackRoutes } from './routes/api/v1/slack/index.js';
186
192
  import { mailRoutes } from './routes/api/v1/mail/index.js';
187
193
  // Register API routes FIRST
188
- console.log('🔗 Registering API routes...');
194
+ vlog('🔗 Registering API routes...');
189
195
  app.route('/api/v1/auth', auth);
190
196
  app.route('/api/v1/auth-settings', authSettings);
191
197
  app.route('/api/v1/api-keys', apiKeys);
@@ -216,7 +222,7 @@ app.route('/api/v1/events', events);
216
222
  app.route('/api/v1/version', version);
217
223
  app.route('/api/v1/slack', slackRoutes);
218
224
  app.route('/api/v1/mail', mailRoutes);
219
- console.log('✅ API routes registered');
225
+ vlog('✅ API routes registered');
220
226
  app.get(PUBLIC_AGENT_CARD_PATH, authMiddleware, async (c) => {
221
227
  try {
222
228
  const document = await readAgentCard();
@@ -259,7 +265,7 @@ for (const possiblePath of possibleStaticPaths) {
259
265
  try {
260
266
  if (fs.existsSync(possiblePath)) {
261
267
  staticPath = possiblePath;
262
- console.log(`📁 Serving static files from: ${staticPath}`);
268
+ vlog(`📁 Serving static files from: ${staticPath}`);
263
269
  break;
264
270
  }
265
271
  }
@@ -304,7 +310,7 @@ else {
304
310
  export async function startServer(options = {}) {
305
311
  const port = options.port || (process.env.PORT ? parseInt(process.env.PORT) : 3000);
306
312
  const host = options.host || '0.0.0.0';
307
- console.log(`Starting server on ${host}:${port}...`);
313
+ vlog(`Starting server on ${host}:${port}...`);
308
314
  const server = serve({
309
315
  fetch: app.fetch,
310
316
  port,
@@ -319,10 +325,10 @@ export async function startServer(options = {}) {
319
325
  httpServer.requestTimeout = 330_000;
320
326
  // Inject WebSocket support
321
327
  injectWebSocket(server);
322
- console.log(`🚀 Server running at http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`);
323
- console.log(`🔌 WebSocket available at ws://${host === '0.0.0.0' ? 'localhost' : host}:${port}/ws/terminal/:sessionId`);
328
+ vlog(`🚀 Server running at http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`);
329
+ vlog(`🔌 WebSocket available at ws://${host === '0.0.0.0' ? 'localhost' : host}:${port}/ws/terminal/:sessionId`);
324
330
  if (staticPath) {
325
- console.log(`🌐 Frontend available at http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`);
331
+ vlog(`🌐 Frontend available at http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`);
326
332
  }
327
333
  return server;
328
334
  }
package/dist/server.js CHANGED
@@ -99,6 +99,7 @@ app.use('/api/*', trimTrailingSlash());
99
99
  // Import and apply authentication middleware
100
100
  import { authMiddleware } from './middleware/auth.js';
101
101
  app.use('/api/*', authMiddleware);
102
+ app.use('/ws/*', authMiddleware);
102
103
  // Create WebSocket support
103
104
  const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
104
105
  // WebSocket route for terminal sessions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovelybunch/api",
3
- "version": "1.0.76-alpha.9",
3
+ "version": "1.0.77-alpha.0",
4
4
  "type": "module",
5
5
  "main": "dist/server-with-static.js",
6
6
  "exports": {
@@ -11,18 +11,6 @@
11
11
  "dist/**/*",
12
12
  "static/**/*"
13
13
  ],
14
- "scripts": {
15
- "dev": "NODE_ENV=development GAIT_DEV_ROOT=../../.nut tsx watch src/server.ts",
16
- "build": "tsc",
17
- "build:bundle": "tsc && node scripts/bundle-frontend.js",
18
- "start": "node dist/server-with-static.js",
19
- "start:dev": "node dist/server.js",
20
- "clean": "rm -rf dist static tsconfig.tsbuildinfo coverage",
21
- "test": "vitest run",
22
- "test:coverage": "vitest run --coverage",
23
- "test:watch": "vitest watch",
24
- "test:ui": "vitest --ui"
25
- },
26
14
  "keywords": [
27
15
  "api",
28
16
  "server",
@@ -35,11 +23,8 @@
35
23
  "description": "Coconut API server",
36
24
  "dependencies": {
37
25
  "@ai-sdk/anthropic": "^3.0.41",
38
- "@hono/node-server": "^1.13.7",
39
- "@hono/node-ws": "^1.0.6",
40
- "@lovelybunch/core": "^1.0.76-alpha.9",
41
- "@lovelybunch/mcp": "^1.0.76-alpha.9",
42
- "@lovelybunch/types": "^1.0.76-alpha.9",
26
+ "@hono/node-server": "^1.19.11",
27
+ "@hono/node-ws": "^1.3.0",
43
28
  "adm-zip": "^0.5.16",
44
29
  "ai": "^6.0.79",
45
30
  "bcryptjs": "^2.4.3",
@@ -47,13 +32,16 @@
47
32
  "dotenv": "^17.2.1",
48
33
  "fuse.js": "^7.0.0",
49
34
  "gray-matter": "^4.0.3",
50
- "hono": "^4.9.5",
35
+ "hono": "^4.12.9",
51
36
  "jsonwebtoken": "^9.0.2",
52
37
  "node-pty": "^1.0.0",
53
38
  "replicate": "^0.34.1",
54
39
  "sharp": "^0.33.5",
55
40
  "ws": "^8.18.0",
56
- "zod": "^3.23.0"
41
+ "zod": "^3.23.0",
42
+ "@lovelybunch/core": "1.0.77-alpha.0",
43
+ "@lovelybunch/types": "1.0.77-alpha.0",
44
+ "@lovelybunch/mcp": "1.0.77-alpha.0"
57
45
  },
58
46
  "devDependencies": {
59
47
  "@types/adm-zip": "^0.5.7",
@@ -62,9 +50,22 @@
62
50
  "@types/jsonwebtoken": "^9.0.5",
63
51
  "@types/node": "^22.10.2",
64
52
  "@types/ws": "^8.5.13",
65
- "@vitest/coverage-v8": "^1.6.1",
53
+ "@vitest/coverage-v8": "4.1.1",
54
+ "@vitest/ui": "4.1.1",
66
55
  "tsx": "^4.19.2",
67
56
  "typescript": "^5.7.2",
68
- "vitest": "^4.0.5"
57
+ "vitest": "4.1.1"
58
+ },
59
+ "scripts": {
60
+ "dev": "NODE_ENV=development GAIT_DEV_ROOT=../../.nut tsx watch src/server.ts",
61
+ "build": "tsc -b",
62
+ "build:bundle": "tsc && node scripts/bundle-frontend.js",
63
+ "start": "node dist/server-with-static.js",
64
+ "start:dev": "node dist/server.js",
65
+ "clean": "rm -rf dist static tsconfig.tsbuildinfo coverage",
66
+ "test": "vitest run",
67
+ "test:coverage": "vitest run --coverage",
68
+ "test:watch": "vitest watch",
69
+ "test:ui": "vitest --ui"
69
70
  }
70
- }
71
+ }
@@ -0,0 +1 @@
1
+ import{r as a,A as p,j as e,v,bK as y,B as N,n as w,C as b}from"./index-ByTA2ZiD.js";import{C as c,a as d,b as k,c as C}from"./card-CL5bB4cs.js";import{B as m}from"./badge-BbfU_aPt.js";import{R as E}from"./refresh-cw-Cj_5MZiJ.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};
@@ -0,0 +1,9 @@
1
+ import{u as p,a as j,r as n,A as l,j as e,B as h,L as v,a1 as N}from"./index-ByTA2ZiD.js";import{C as m,a as x,b as C,c as S}from"./card-CL5bB4cs.js";import{M as w}from"./markdown-editor-DUmrf1eN.js";import{A as y}from"./arrow-left-B9NBHEkS.js";import{C as A}from"./circle-check-big-BwQ_q1N7.js";import"./index-CuLP7P_G.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
+
3
+ ## Agent Definitions
4
+
5
+ Describe agents, their capabilities, and configurations.
6
+
7
+ ## Agent Guidelines
8
+
9
+ Key guidelines for agent behavior and interaction patterns.`,height:800})})]})]})}export{F as default};
@@ -0,0 +1 @@
1
+ import{a as g,r as t,A as N,j as e,v,av as C,B as a,L as d,_ as l,M as w,au as y,aq as E}from"./index-ByTA2ZiD.js";import{C as i,a as c,b}from"./card-CL5bB4cs.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,2 +1,2 @@
1
- import{s as R,r as t,bw as y,j as e,B as a,P as W,bx as X,E as Y,D as j,b as g,d as v,f,g as A,I as F,W as N,ae as J,v as i}from"./index-DB2Tq9wz.js";import{C as G,b as Q,c as V,d as Z,a as _}from"./card-DRBgMGuU.js";import{L as w}from"./label-DxDedS8x.js";import{B as ee}from"./badge-CKwUSKzT.js";import{A as I,a as C}from"./alert-C42EBWiI.js";import{I as L}from"./info-DMJxIp7i.js";import{C as se}from"./circle-alert-DP4rtmEK.js";function oe(){const{authEnabled:n}=R(),[P,k]=t.useState([]),[b,K]=t.useState(!0),[O,l]=t.useState(!1),[M,d]=t.useState(!1),[x,D]=t.useState(""),[h,E]=t.useState("never"),[c,S]=t.useState(null),[m,o]=t.useState(null);t.useEffect(()=>{p()},[]);const p=async()=>{K(!0);try{const s=await y("/api/v1/api-keys");s.success&&k(s.data?.apiKeys||[])}catch(s){console.error("Failed to load API keys:",s),k([])}finally{K(!1)}},U=async()=>{if(!x.trim()){i({title:"Error",description:"Please provide a name for the API key",variant:"destructive"});return}try{const s={name:x,scopes:["*"]};h!=="never"&&(s.expiresIn=h);const r=await y("/api/v1/api-keys",{method:"POST",body:JSON.stringify(s)});r.success&&(S(r.data),l(!1),d(!0),D(""),E("never"),await p(),i({title:"API Key Created",description:"Make sure to copy your API key now. You won't be able to see it again!"}))}catch(s){console.error("Failed to create API key:",s),i({title:"Error",description:"Failed to create API key",variant:"destructive"})}},B=async s=>{try{(await y(`/api/v1/api-keys/${s}`,{method:"DELETE"})).success&&(await p(),o(null),i({title:"API Key Deleted",description:"The API key has been permanently deleted"}))}catch(r){console.error("Failed to delete API key:",r),i({title:"Error",description:"Failed to delete API key",variant:"destructive"})}},H=async s=>{try{await navigator.clipboard.writeText(s),i({title:"Copied",description:"API key copied to clipboard"})}catch{i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},u=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),$=s=>s?new Date(s)<new Date:!1,q=typeof window<"u"?window.location.origin:"http://localhost:3000",z=c?`curl -H "X-API-Key: ${c.key}" \\
2
- + ${q}/api/v1/tasks`:"",T=n?null:e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["Authentication is currently disabled. API keys will only be required once you enable authentication in the ",e.jsx("a",{href:"/settings/authentication",className:"underline",children:"Authentication settings"}),"."]})]});return!n&&b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access"})]}),T]}):b?e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access to your Coconut instance"})]}),T,n&&e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["API keys provide programmatic access to your Coconut instance. Use them in CI/CD pipelines or automation scripts by including the key in the ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"X-API-Key"})," header."]})]}),e.jsxs(G,{children:[e.jsx(Q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(V,{children:"Active API Keys"}),e.jsx(Z,{children:"API keys you've created for programmatic access"})]}),e.jsxs(a,{onClick:()=>l(!0),disabled:!n,children:[e.jsx(W,{className:"mr-2 h-4 w-4"}),"Create API Key"]})]})}),e.jsx(_,{children:P.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(X,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{children:"No API keys yet"}),e.jsx("p",{className:"text-sm",children:"Create an API key to get started with programmatic access"})]}):e.jsx("div",{className:"space-y-4",children:P.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"font-medium",children:s.name}),$(s.expiresAt)&&e.jsx(ee,{variant:"destructive",children:"Expired"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:s.keyPreview}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Created: ",u(s.createdAt)]}),s.expiresAt&&e.jsxs("span",{children:["Expires: ",u(s.expiresAt)]}),s.lastUsedAt&&e.jsxs("span",{children:["Last used: ",u(s.lastUsedAt)]})]})]}),e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>o(s.id),children:e.jsx(Y,{className:"h-4 w-4 text-destructive"})})]},s.id))})})]}),e.jsx(j,{open:O,onOpenChange:l,children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Create API Key"}),e.jsx(A,{children:"Create a new API key for programmatic access. The key will only be shown once."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyName",children:"Name"}),e.jsx(F,{id:"keyName",placeholder:"CI/CD Pipeline",value:x,onChange:s=>D(s.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A descriptive name to identify this API key"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyExpiry",children:"Expiration"}),e.jsxs("select",{id:"keyExpiry",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:h,onChange:s=>E(s.target.value),children:[e.jsx("option",{value:"never",children:"Never"}),e.jsx("option",{value:"30d",children:"30 days"}),e.jsx("option",{value:"90d",children:"90 days"}),e.jsx("option",{value:"1y",children:"1 year"})]})]})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(a,{onClick:U,disabled:!n,children:"Create API Key"})]})]})}),e.jsx(j,{open:M,onOpenChange:d,children:e.jsxs(g,{className:"sm:max-w-[600px]",children:[e.jsxs(v,{children:[e.jsx(f,{children:"API Key Created"}),e.jsx(A,{children:"Make sure to copy your API key now. You won't be able to see it again!"})]}),e.jsxs(I,{variant:"destructive",className:"my-4",children:[e.jsx(se,{className:"h-4 w-4"}),e.jsx(C,{children:"This is the only time you will see this key. Store it securely."})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"API Key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{readOnly:!0,value:c.key,className:"font-mono text-sm"}),e.jsx(a,{variant:"outline",size:"icon",onClick:()=>H(c.key),children:e.jsx(J,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"mb-2",children:"Usage example:"}),e.jsx("pre",{className:"bg-muted p-3 rounded-md whitespace-pre-wrap break-words",children:e.jsx("code",{className:"font-mono text-xs",children:z})})]})]}),e.jsx(N,{children:e.jsx(a,{onClick:()=>{d(!1),S(null)},children:"I've Saved My Key"})})]})}),e.jsx(j,{open:!!m,onOpenChange:s=>!s&&o(null),children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Delete API Key"}),e.jsx(A,{children:"Are you sure you want to delete this API key? This action cannot be undone and any scripts using this key will stop working."})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(a,{variant:"destructive",onClick:()=>m&&B(m),children:"Delete API Key"})]})]})})]})}export{oe as default};
1
+ import{t as z,r as t,bD as y,j as e,B as a,P as R,bE as X,H as J,D as j,b as g,d as v,f,g as A,I as F,Y as N,ae as W,w as i}from"./index-ByTA2ZiD.js";import{C as G,b as Q,c as V,d as Z,a as _}from"./card-CL5bB4cs.js";import{L as w}from"./label-Dp0-28_O.js";import{B as ee}from"./badge-BbfU_aPt.js";import{A as I,a as C}from"./alert-BtkLXQ3p.js";import{I as L}from"./info-DxhTCbw1.js";import{C as se}from"./circle-alert-vJFSz39V.js";function oe(){const{authEnabled:n}=z(),[P,k]=t.useState([]),[b,K]=t.useState(!0),[O,l]=t.useState(!1),[M,d]=t.useState(!1),[x,D]=t.useState(""),[h,E]=t.useState("never"),[c,S]=t.useState(null),[m,o]=t.useState(null);t.useEffect(()=>{p()},[]);const p=async()=>{K(!0);try{const s=await y("/api/v1/api-keys");s.success&&k(s.data?.apiKeys||[])}catch(s){console.error("Failed to load API keys:",s),k([])}finally{K(!1)}},U=async()=>{if(!x.trim()){i({title:"Error",description:"Please provide a name for the API key",variant:"destructive"});return}try{const s={name:x,scopes:["*"]};h!=="never"&&(s.expiresIn=h);const r=await y("/api/v1/api-keys",{method:"POST",body:JSON.stringify(s)});r.success&&(S(r.data),l(!1),d(!0),D(""),E("never"),await p(),i({title:"API Key Created",description:"Make sure to copy your API key now. You won't be able to see it again!"}))}catch(s){console.error("Failed to create API key:",s),i({title:"Error",description:"Failed to create API key",variant:"destructive"})}},B=async s=>{try{(await y(`/api/v1/api-keys/${s}`,{method:"DELETE"})).success&&(await p(),o(null),i({title:"API Key Deleted",description:"The API key has been permanently deleted"}))}catch(r){console.error("Failed to delete API key:",r),i({title:"Error",description:"Failed to delete API key",variant:"destructive"})}},H=async s=>{try{await navigator.clipboard.writeText(s),i({title:"Copied",description:"API key copied to clipboard"})}catch{i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},u=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),Y=s=>s?new Date(s)<new Date:!1,$=typeof window<"u"?window.location.origin:"http://localhost:3000",q=c?`curl -H "X-API-Key: ${c.key}" \\
2
+ + ${$}/api/v1/tasks`:"",T=n?null:e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["Authentication is currently disabled. API keys will only be required once you enable authentication in the ",e.jsx("a",{href:"/settings/authentication",className:"underline",children:"Authentication settings"}),"."]})]});return!n&&b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access"})]}),T]}):b?e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access to your Coconut instance"})]}),T,n&&e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["API keys provide programmatic access to your Coconut instance. Use them in CI/CD pipelines or automation scripts by including the key in the ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"X-API-Key"})," header."]})]}),e.jsxs(G,{children:[e.jsx(Q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(V,{children:"Active API Keys"}),e.jsx(Z,{children:"API keys you've created for programmatic access"})]}),e.jsxs(a,{onClick:()=>l(!0),disabled:!n,children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),"Create API Key"]})]})}),e.jsx(_,{children:P.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(X,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{children:"No API keys yet"}),e.jsx("p",{className:"text-sm",children:"Create an API key to get started with programmatic access"})]}):e.jsx("div",{className:"space-y-4",children:P.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"font-medium",children:s.name}),Y(s.expiresAt)&&e.jsx(ee,{variant:"destructive",children:"Expired"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:s.keyPreview}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Created: ",u(s.createdAt)]}),s.expiresAt&&e.jsxs("span",{children:["Expires: ",u(s.expiresAt)]}),s.lastUsedAt&&e.jsxs("span",{children:["Last used: ",u(s.lastUsedAt)]})]})]}),e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>o(s.id),children:e.jsx(J,{className:"h-4 w-4 text-destructive"})})]},s.id))})})]}),e.jsx(j,{open:O,onOpenChange:l,children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Create API Key"}),e.jsx(A,{children:"Create a new API key for programmatic access. The key will only be shown once."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyName",children:"Name"}),e.jsx(F,{id:"keyName",placeholder:"CI/CD Pipeline",value:x,onChange:s=>D(s.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A descriptive name to identify this API key"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyExpiry",children:"Expiration"}),e.jsxs("select",{id:"keyExpiry",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:h,onChange:s=>E(s.target.value),children:[e.jsx("option",{value:"never",children:"Never"}),e.jsx("option",{value:"30d",children:"30 days"}),e.jsx("option",{value:"90d",children:"90 days"}),e.jsx("option",{value:"1y",children:"1 year"})]})]})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(a,{onClick:U,disabled:!n,children:"Create API Key"})]})]})}),e.jsx(j,{open:M,onOpenChange:d,children:e.jsxs(g,{className:"sm:max-w-[600px]",children:[e.jsxs(v,{children:[e.jsx(f,{children:"API Key Created"}),e.jsx(A,{children:"Make sure to copy your API key now. You won't be able to see it again!"})]}),e.jsxs(I,{variant:"destructive",className:"my-4",children:[e.jsx(se,{className:"h-4 w-4"}),e.jsx(C,{children:"This is the only time you will see this key. Store it securely."})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"API Key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{readOnly:!0,value:c.key,className:"font-mono text-sm"}),e.jsx(a,{variant:"outline",size:"icon",onClick:()=>H(c.key),children:e.jsx(W,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"mb-2",children:"Usage example:"}),e.jsx("pre",{className:"bg-muted p-3 rounded-md whitespace-pre-wrap break-words",children:e.jsx("code",{className:"font-mono text-xs",children:q})})]})]}),e.jsx(N,{children:e.jsx(a,{onClick:()=>{d(!1),S(null)},children:"I've Saved My Key"})})]})}),e.jsx(j,{open:!!m,onOpenChange:s=>!s&&o(null),children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Delete API Key"}),e.jsx(A,{children:"Are you sure you want to delete this API key? This action cannot be undone and any scripts using this key will stop working."})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(a,{variant:"destructive",onClick:()=>m&&B(m),children:"Delete API Key"})]})]})})]})}export{oe as default};
@@ -1,4 +1,4 @@
1
- import{c as Y,s as le,r as n,bw as c,j as e,bv as O,i as ce,D as I,V as M,B as l,b as V,d as $,f as H,g as J,I as j,W as z,y as oe,z as de,E as he,H as ue,J as xe,N as me,O as ge,Q as je,R as pe,U as ve,v as r}from"./index-DB2Tq9wz.js";import{C as p,b as v,c as w,d as f,a as y}from"./card-DRBgMGuU.js";import{L as o}from"./label-DxDedS8x.js";import{S as _,a as W,b as q,c as B,d as a}from"./select-BzOa_wZx.js";import{S as U}from"./switch-Bf2z8aaj.js";import{B as k}from"./badge-CKwUSKzT.js";import{C as we}from"./circle-alert-DP4rtmEK.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";/**
1
+ import{c as Y,t as le,r as n,bD as l,j as e,bx as O,i as ce,D as I,W as M,B as c,b as V,d as $,f as H,g as J,I as j,Y as z,z as oe,E as de,H as he,J as ue,N as xe,O as me,Q as ge,R as je,U as pe,V as ve,w as r}from"./index-ByTA2ZiD.js";import{C as p,b as v,c as w,d as f,a as y}from"./card-CL5bB4cs.js";import{L as o}from"./label-Dp0-28_O.js";import{S as _,a as W,b as q,c as B,d as a}from"./select-CfwLZl55.js";import{S as E}from"./switch-CX_Inx_p.js";import{B as U}from"./badge-BbfU_aPt.js";import{C as we}from"./circle-alert-vJFSz39V.js";import"./index-CuLP7P_G.js";import"./chevron-up-BwTmMEW2.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{c as Y,s as le,r as n,bw as c,j as e,bv as O,i as ce,D as I,V as M,B as l
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Ne=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Se=Y("user-plus",Ne);function Re(){const{user:N,authEnabled:K,checkAuthStatus:Q}=le(),[i,d]=n.useState(null),[G,F]=n.useState(!0),[S,D]=n.useState(!1),[X,C]=n.useState(!1),[b,P]=n.useState(""),[A,R]=n.useState(""),[T,L]=n.useState("viewer"),[E,u]=n.useState(null),[x,m]=n.useState(""),Z=!K||N?.role==="admin";n.useEffect(()=>{h()},[]);const h=async()=>{try{F(!0);const s=await c("/api/v1/auth-settings");s.success?d(s.data):d(null)}catch(s){console.error("Failed to load auth settings:",s),d(null)}finally{F(!1)}},ee=async()=>{if(!i)return;const s=!i.enabled;try{const t=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({enabled:s})});if(t.success)d({...i,enabled:s}),await Q(),r({title:"Success",description:`Authentication ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to toggle auth")}catch(t){r({title:"Error",description:t.message||"Failed to toggle authentication",variant:"destructive"})}},se=async()=>{if(!i)return;const s=!i.allowRegistration;try{const t=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({allowRegistration:s})});if(t.success)d({...i,allowRegistration:s}),r({title:"Success",description:`Self-registration ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to update setting")}catch(t){r({title:"Error",description:t.message||"Failed to update setting",variant:"destructive"})}},te=async()=>{if(!b||!A){r({title:"Error",description:"Please provide email and name",variant:"destructive"});return}try{const s=await c("/api/v1/auth-settings/users",{method:"POST",body:JSON.stringify({email:b,name:A,role:T})});if(s.success)await h(),C(!1),P(""),R(""),L("viewer"),r({title:"Success",description:"User added to whitelist"});else throw new Error(s.error||"Failed to add user")}catch(s){r({title:"Error",description:s.message||"Failed to add user",variant:"destructive"})}},ie=async s=>{try{const t=await c(`/api/v1/auth-settings/users/${s}`,{method:"DELETE"});if(t.success)await h(),r({title:"Success",description:"User removed from whitelist"});else throw new Error(t.error||"Failed to remove user")}catch(t){r({title:"Error",description:t.message||"Failed to remove user",variant:"destructive"})}},re=async(s,t)=>{try{const g=await c(`/api/v1/auth-settings/users/${s}`,{method:"PUT",body:JSON.stringify({role:t})});if(g.success)await h(),r({title:"Success",description:"User role updated"});else throw new Error(g.error||"Failed to update role")}catch(g){r({title:"Error",description:g.message||"Failed to update role",variant:"destructive"})}},ae=async()=>{if(!(!E||!x)){if(x.length<8){r({title:"Error",description:"Password must be at least 8 characters",variant:"destructive"});return}try{const s=await c(`/api/v1/auth-settings/users/${E}/reset-password`,{method:"POST",body:JSON.stringify({newPassword:x})});if(s.success)u(null),m(""),r({title:"Success",description:"Password reset successfully"});else throw new Error(s.error||"Failed to reset password")}catch(s){r({title:"Error",description:s.message||"Failed to reset password",variant:"destructive"})}}},ne=async()=>{if(i)try{D(!0);const s=await c("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({session:i.session})});if(s.success)r({title:"Success",description:"Session settings updated"});else throw new Error(s.error||"Failed to update settings")}catch(s){r({title:"Error",description:s.message||"Failed to update settings",variant:"destructive"})}finally{D(!1)}};return G?e.jsx("div",{children:"Loading..."}):i?Z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage authentication settings and user access."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),e.jsx(w,{children:"Authentication Status"})]}),e.jsx(f,{children:"Control whether authentication is required to access Coconut."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"auth-enabled",children:"Require Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When enabled, users must log in to access Coconut"})]}),e.jsx(U,{id:"auth-enabled",checked:i.enabled,onCheckedChange:ee})]}),i.enabled&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"allow-registration",children:"Allow Self-Registration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Whitelisted users can create their own accounts"})]}),e.jsx(U,{id:"allow-registration",checked:i.allowRegistration,onCheckedChange:se})]})]})]}),e.jsxs(p,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(w,{children:"Whitelisted Users"}),e.jsx(f,{children:"Manage users who can access this Coconut instance."})]}),e.jsxs(I,{open:X,onOpenChange:C,children:[e.jsx(M,{asChild:!0,children:e.jsxs(l,{size:"sm",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Add User"]})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(H,{children:"Add User to Whitelist"}),e.jsx(J,{children:"Add a user's email to allow them to register and access Coconut."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-email",children:"Email"}),e.jsx(j,{id:"new-email",type:"email",value:b,onChange:s=>P(s.target.value),placeholder:"user@example.com"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-name",children:"Name"}),e.jsx(j,{id:"new-name",value:A,onChange:s=>R(s.target.value),placeholder:"User Name"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-role",children:"Role"}),e.jsxs(_,{value:T,onValueChange:s=>L(s),children:[e.jsx(W,{children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]})]})]}),e.jsxs(z,{children:[e.jsx(l,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(l,{onClick:te,children:"Add User"})]})]})]})]})}),e.jsx(y,{children:e.jsx("div",{className:"space-y-4",children:i.providers.local.users.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:s.name}),s.registered?e.jsx(k,{variant:"default",className:"text-xs",children:"Registered"}):e.jsx(k,{variant:"secondary",className:"text-xs",children:"Pending"}),s.id===N?.id&&e.jsx(k,{variant:"outline",className:"text-xs",children:"You"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email}),s.lastLoginAt&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last login: ",new Date(s.lastLoginAt).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_,{value:s.role,onValueChange:t=>re(s.id,t),children:[e.jsx(W,{className:"w-40",children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]}),e.jsxs(I,{open:E===s.id,onOpenChange:t=>{t||(u(null),m(""))},children:[e.jsx(M,{asChild:!0,children:e.jsx(l,{size:"sm",variant:"outline",onClick:()=>u(s.id),children:e.jsx(ye,{className:"h-4 w-4"})})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(H,{children:"Reset Password"}),e.jsxs(J,{children:["Set a new password for ",s.name]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{children:[e.jsx(o,{htmlFor:"reset-password",children:"New Password"}),e.jsx(j,{id:"reset-password",type:"password",value:x,onChange:t=>m(t.target.value),placeholder:"At least 8 characters",minLength:8})]})}),e.jsxs(z,{children:[e.jsx(l,{variant:"outline",onClick:()=>{u(null),m("")},children:"Cancel"}),e.jsx(l,{onClick:ae,children:"Reset Password"})]})]})]}),s.id!==N?.id&&e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(l,{size:"sm",variant:"destructive",children:e.jsx(he,{className:"h-4 w-4"})})}),e.jsxs(ue,{children:[e.jsxs(xe,{children:[e.jsx(me,{children:"Remove User"}),e.jsxs(ge,{children:["Are you sure you want to remove ",s.name," from the whitelist? They will no longer be able to access Coconut."]})]}),e.jsxs(je,{children:[e.jsx(pe,{children:"Cancel"}),e.jsx(ve,{onClick:()=>ie(s.id),children:"Remove"})]})]})]})]})]},s.id))})})]}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsx(w,{children:"Session Settings"}),e.jsx(f,{children:"Configure session behavior and security."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"session-expiry",children:"Session Expiry"}),e.jsx(j,{id:"session-expiry",value:i.session.expiresIn,onChange:s=>d({...i,session:{...i.session,expiresIn:s.target.value}}),placeholder:"7d"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Format: 30s, 15m, 24h, 7d"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"secure-cookies",children:"Secure Cookies (HTTPS only)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable in production with HTTPS"})]}),e.jsx(U,{id:"secure-cookies",checked:i.session.secure||!1,onCheckedChange:s=>d({...i,session:{...i.session,secure:s}})})]})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",onClick:h,disabled:S,children:"Cancel"}),e.jsx(l,{onClick:ne,disabled:S,children:S?"Saving...":"Save Session Settings"})]})]}):e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have permission to manage authentication settings."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Secure your Coconut instance with authentication."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-5 w-5 text-muted-foreground"}),e.jsx(w,{children:"Authentication Not Configured"})]}),e.jsx(f,{children:"Authentication has not been initialized. Use the CLI to set up authentication."})]}),e.jsxs(y,{children:[e.jsx("div",{className:"bg-muted p-4 rounded-md",children:e.jsxs("code",{className:"text-sm",children:["$ nut auth init",e.jsx("br",{}),"$ nut auth toggle"]})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"This will create an admin user and enable authentication for your Coconut instance."})]})]})]})}export{Re as default};
11
+ */const Ne=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Se=Y("user-plus",Ne);function Re(){const{user:N,authEnabled:K,checkAuthStatus:Q}=le(),[i,d]=n.useState(null),[G,k]=n.useState(!0),[F,D]=n.useState(!1),[X,S]=n.useState(!1),[C,P]=n.useState(""),[b,R]=n.useState(""),[T,L]=n.useState("viewer"),[A,h]=n.useState(null),[u,x]=n.useState(""),Z=!K||N?.role==="admin";n.useEffect(()=>{m()},[]);const m=async()=>{try{k(!0);const s=await l("/api/v1/auth-settings");s.success?d(s.data):d(null)}catch(s){console.error("Failed to load auth settings:",s),d(null)}finally{k(!1)}},ee=async()=>{if(!i)return;const s=!i.enabled;try{const t=await l("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({enabled:s})});if(t.success)d({...i,enabled:s}),await Q(),r({title:"Success",description:`Authentication ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to toggle auth")}catch(t){r({title:"Error",description:t.message||"Failed to toggle authentication",variant:"destructive"})}},se=async()=>{if(!i)return;const s=!i.allowRegistration;try{const t=await l("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({allowRegistration:s})});if(t.success)d({...i,allowRegistration:s}),r({title:"Success",description:`Self-registration ${s?"enabled":"disabled"}`});else throw new Error(t.error||"Failed to update setting")}catch(t){r({title:"Error",description:t.message||"Failed to update setting",variant:"destructive"})}},te=async()=>{if(!C||!b){r({title:"Error",description:"Please provide email and name",variant:"destructive"});return}try{const s=await l("/api/v1/auth-settings/users",{method:"POST",body:JSON.stringify({email:C,name:b,role:T})});if(s.success)await m(),S(!1),P(""),R(""),L("viewer"),r({title:"Success",description:"User added to whitelist"});else throw new Error(s.error||"Failed to add user")}catch(s){r({title:"Error",description:s.message||"Failed to add user",variant:"destructive"})}},ie=async s=>{try{const t=await l(`/api/v1/auth-settings/users/${s}`,{method:"DELETE"});if(t.success)await m(),r({title:"Success",description:"User removed from whitelist"});else throw new Error(t.error||"Failed to remove user")}catch(t){r({title:"Error",description:t.message||"Failed to remove user",variant:"destructive"})}},re=async(s,t)=>{try{const g=await l(`/api/v1/auth-settings/users/${s}`,{method:"PUT",body:JSON.stringify({role:t})});if(g.success)await m(),r({title:"Success",description:"User role updated"});else throw new Error(g.error||"Failed to update role")}catch(g){r({title:"Error",description:g.message||"Failed to update role",variant:"destructive"})}},ae=async()=>{if(!(!A||!u)){if(u.length<8){r({title:"Error",description:"Password must be at least 8 characters",variant:"destructive"});return}try{const s=await l(`/api/v1/auth-settings/users/${A}/reset-password`,{method:"POST",body:JSON.stringify({newPassword:u})});if(s.success)h(null),x(""),r({title:"Success",description:"Password reset successfully"});else throw new Error(s.error||"Failed to reset password")}catch(s){r({title:"Error",description:s.message||"Failed to reset password",variant:"destructive"})}}},ne=async()=>{if(i)try{D(!0);const s=await l("/api/v1/auth-settings",{method:"PUT",body:JSON.stringify({session:i.session})});if(s.success)r({title:"Success",description:"Session settings updated"});else throw new Error(s.error||"Failed to update settings")}catch(s){r({title:"Error",description:s.message||"Failed to update settings",variant:"destructive"})}finally{D(!1)}};return G?e.jsx("div",{children:"Loading..."}):i?Z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage authentication settings and user access."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),e.jsx(w,{children:"Authentication Status"})]}),e.jsx(f,{children:"Control whether authentication is required to access Coconut."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"auth-enabled",children:"Require Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When enabled, users must log in to access Coconut"})]}),e.jsx(E,{id:"auth-enabled",checked:i.enabled,onCheckedChange:ee})]}),i.enabled&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"allow-registration",children:"Allow Self-Registration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Whitelisted users can create their own accounts"})]}),e.jsx(E,{id:"allow-registration",checked:i.allowRegistration,onCheckedChange:se})]})]})]}),e.jsxs(p,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(w,{children:"Whitelisted Users"}),e.jsx(f,{children:"Manage users who can access this Coconut instance."})]}),e.jsxs(I,{open:X,onOpenChange:S,children:[e.jsx(M,{asChild:!0,children:e.jsxs(c,{size:"sm",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Add User"]})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(H,{children:"Add User to Whitelist"}),e.jsx(J,{children:"Add a user's email to allow them to register and access Coconut."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-email",children:"Email"}),e.jsx(j,{id:"new-email",type:"email",value:C,onChange:s=>P(s.target.value),placeholder:"user@example.com"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-name",children:"Name"}),e.jsx(j,{id:"new-name",value:b,onChange:s=>R(s.target.value),placeholder:"User Name"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"new-role",children:"Role"}),e.jsxs(_,{value:T,onValueChange:s=>L(s),children:[e.jsx(W,{children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]})]})]}),e.jsxs(z,{children:[e.jsx(c,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(c,{onClick:te,children:"Add User"})]})]})]})]})}),e.jsx(y,{children:e.jsx("div",{className:"space-y-4",children:i.providers.local.users.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:s.name}),s.registered?e.jsx(U,{variant:"default",className:"text-xs",children:"Registered"}):e.jsx(U,{variant:"secondary",className:"text-xs",children:"Pending"}),s.id===N?.id&&e.jsx(U,{variant:"outline",className:"text-xs",children:"You"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email}),s.lastLoginAt&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last login: ",new Date(s.lastLoginAt).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_,{value:s.role,onValueChange:t=>re(s.id,t),children:[e.jsx(W,{className:"w-40",children:e.jsx(q,{})}),e.jsxs(B,{children:[e.jsx(a,{value:"viewer",children:"Viewer"}),e.jsx(a,{value:"engineer",children:"Engineer"}),e.jsx(a,{value:"designer",children:"Designer"}),e.jsx(a,{value:"product_manager",children:"Product Manager"}),e.jsx(a,{value:"manager",children:"Manager"}),e.jsx(a,{value:"admin",children:"Admin"})]})]}),e.jsxs(I,{open:A===s.id,onOpenChange:t=>{t||(h(null),x(""))},children:[e.jsx(M,{asChild:!0,children:e.jsx(c,{size:"sm",variant:"outline",onClick:()=>h(s.id),children:e.jsx(ye,{className:"h-4 w-4"})})}),e.jsxs(V,{children:[e.jsxs($,{children:[e.jsx(H,{children:"Reset Password"}),e.jsxs(J,{children:["Set a new password for ",s.name]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{children:[e.jsx(o,{htmlFor:"reset-password",children:"New Password"}),e.jsx(j,{id:"reset-password",type:"password",value:u,onChange:t=>x(t.target.value),placeholder:"At least 8 characters",minLength:8})]})}),e.jsxs(z,{children:[e.jsx(c,{variant:"outline",onClick:()=>{h(null),x("")},children:"Cancel"}),e.jsx(c,{onClick:ae,children:"Reset Password"})]})]})]}),s.id!==N?.id&&e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(c,{size:"sm",variant:"destructive",children:e.jsx(he,{className:"h-4 w-4"})})}),e.jsxs(ue,{children:[e.jsxs(xe,{children:[e.jsx(me,{children:"Remove User"}),e.jsxs(ge,{children:["Are you sure you want to remove ",s.name," from the whitelist? They will no longer be able to access Coconut."]})]}),e.jsxs(je,{children:[e.jsx(pe,{children:"Cancel"}),e.jsx(ve,{onClick:()=>ie(s.id),children:"Remove"})]})]})]})]})]},s.id))})})]}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsx(w,{children:"Session Settings"}),e.jsx(f,{children:"Configure session behavior and security."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"session-expiry",children:"Session Expiry"}),e.jsx(j,{id:"session-expiry",value:i.session.expiresIn,onChange:s=>d({...i,session:{...i.session,expiresIn:s.target.value}}),placeholder:"7d"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Format: 30s, 15m, 24h, 7d"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"secure-cookies",children:"Secure Cookies (HTTPS only)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable in production with HTTPS"})]}),e.jsx(E,{id:"secure-cookies",checked:i.session.secure||!1,onCheckedChange:s=>d({...i,session:{...i.session,secure:s}})})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(c,{onClick:ne,disabled:F,children:F?"Saving...":"Save Session Settings"})})]}):e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have permission to manage authentication settings."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Authentication"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Secure your Coconut instance with authentication."})]}),e.jsx(O,{}),e.jsxs(p,{children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-5 w-5 text-muted-foreground"}),e.jsx(w,{children:"Authentication Not Configured"})]}),e.jsx(f,{children:"Authentication has not been initialized. Use the CLI to set up authentication."})]}),e.jsxs(y,{children:[e.jsx("div",{className:"bg-muted p-4 rounded-md",children:e.jsxs("code",{className:"text-sm",children:["$ nut auth init",e.jsx("br",{}),"$ nut auth toggle"]})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"This will create an admin user and enable authentication for your Coconut instance."})]})]})]})}export{Re as default};
@@ -1 +1 @@
1
- import{r as m,j as e,t as x,A as f}from"./index-DB2Tq9wz.js";import{C as w}from"./circle-check-Cnp-EoKX.js";import{C as b}from"./circle-x-DxbiyJ6w.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};
1
+ import{r as m,j as e,v as x,A as f}from"./index-ByTA2ZiD.js";import{C as w}from"./circle-check-D2LVHMl-.js";import{C as b}from"./circle-x-CuUVLiI-.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 y=()=>{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{y as default};
@@ -0,0 +1,2 @@
1
+ import{u as ce,a as de,r as i,j as e,B as r,T as oe,n as M,X as me,F as xe,_ as he,D as ue,b as fe,d as pe,f as je,k as ge,a4 as B,a5 as R,a6 as H,a7 as L,a8 as O,a9 as _,o as ve,A as T}from"./index-ByTA2ZiD.js";import{C as g,b as Ne,a as G,c as ye}from"./card-CL5bB4cs.js";import{B as U}from"./badge-BbfU_aPt.js";import{u as we}from"./use-terminal-D1UnvAVs.js";import{T as Se}from"./terminal-preview-BNm5-Umi.js";import{S as Ce,a as be,b as ke,c as Ae,d as w}from"./select-CfwLZl55.js";import{b as De,e as Me,d as Te,c as Ie,a as $e}from"./pipeline-builders-DrEjlsbH.js";import{R as Ee}from"./refresh-cw-Cj_5MZiJ.js";import{C as Pe,a as ze}from"./chevrons-up-jI6nxhrz.js";import{P as Fe}from"./play-fOwEoIcu.js";import{C as Be}from"./code-DqYaanki.js";import{C as Re}from"./chevron-up-BwTmMEW2.js";import{S as He}from"./server-u9FLHclt.js";import"./xterm-DTxiCjtJ.js";import"./index-CuLP7P_G.js";const Le=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function ts(){const c=ce(),{sessions:x,loading:b,error:I,refreshSessions:S,createSession:V,destroySession:K}=we(),{toast:v}=de(),[$,W]=i.useState([]),[q,X]=i.useState(!0),[j,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[f,J]=i.useState("claude"),[E,Q]=i.useState(""),[D,P]=i.useState(!1),[h,Y]=i.useState([]),[p,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,C]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const l=Math.floor(d/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${T}/api/v1/tasks`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading tasks:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{S()},[S]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${T}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${T}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(l=>({id:l.id,name:l?.metadata?.name||l.id,mcpServers:Le(l?.metadata?.metadata?.mcpServers)}));se(d),C(l=>l.filter(F=>d.some(le=>le.id===F)))}}catch(t){console.error("Failed to load skills",t)}})()},[A]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(l=>l.id===n);d&&d.mcpServers.forEach(l=>{(!a||a.has(l))&&t.add(l)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.taskId?.startsWith("cp-")||s.taskId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{k(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>$.filter(s=>s.status==="draft"||s.status==="ready").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[$]),ae=()=>{const s=m.every(a=>j[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>j[s.id]),ne=async s=>{await K(s)?(v({title:"Session closed",description:s}),setTimeout(()=>S(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},re=async()=>{P(!0);try{const s=`session-${Date.now()}`,t={taskId:s,contextType:"change-task",cliAgent:f,mcpServersMap:Z,selectedMcpServers:p,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";f==="claude"?a=De(t):f==="gemini"?a=Me(t):f==="codex"?a=Te(t):f==="droid"?a=Ie(t):f==="kiro"&&(a=$e(t)),await V(s,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage agents and their active sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>S(),disabled:b,children:[e.jsx(Ee,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(r,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),I&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:I})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(g,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(Be,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/tasks"),className:"text-primary hover:underline font-medium",children:"New Task"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(g,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":j[s.id]?"Hide preview":"Show preview",title:j[s.id]?"Hide preview":"Show preview",children:j[s.id]?e.jsx(Re,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.taskId}`),children:"Open"}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(me,{className:"h-4 w-4"})})]})]}),j[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(Se,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"New Tasks"}),q?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(g,{children:e.jsx(Ne,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(g,{children:e.jsx(G,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved tasks found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(g,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(G,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(ye,{className:"text-base leading-tight",children:s.title||s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
2
+ `).slice(0,2).join(" ").substring(0,150),s.content.length>150?"...":""]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.id," • by ",s.author.name," • ",new Date(s.metadata.createdAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",onClick:t=>t.stopPropagation(),children:[e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(xe,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(he,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(ue,{open:A,onOpenChange:N,children:e.jsxs(fe,{className:"max-w-lg",children:[e.jsxs(pe,{children:[e.jsx(je,{children:"Start Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive session"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Agent"}),e.jsxs(Ce,{value:f,onValueChange:s=>J(s),children:[e.jsx(be,{className:"w-full",children:e.jsx(ke,{placeholder:"Select coding agent"})}),e.jsxs(Ae,{children:[e.jsx(w,{value:"claude",children:"Claude Code"}),e.jsx(w,{value:"gemini",children:"Google Gemini"}),e.jsx(w,{value:"codex",children:"OpenAI Codex"}),e.jsx(w,{value:"droid",children:"Factory Droid"}),e.jsx(w,{value:"kiro",children:"Kiro"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[o.length," of ",u.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[o.length===0?"Select skills...":o.length===u.length?"All skills selected":`${o.length} skill${o.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C(u.map(t=>t.id))},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C([])},children:"None"})]})]}),e.jsx(O,{}),u.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):u.map(s=>e.jsx(_,{checked:o.includes(s.id),onCheckedChange:t=>{C(a=>t?a.includes(s.id)?a:[...a,s.id]:a.filter(n=>n!==s.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.name}),s.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.mcpServers.join(", ")]}),s.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[p.length," of ",h.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[p.length===0?"Select MCP servers...":p.length===h.length?"All servers selected":`${p.length} server${p.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(O,{}),h.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):h.map(s=>e.jsx(_,{checked:p.includes(s),onCheckedChange:t=>{y(a=>t?a.includes(s)?a:[...a,s]:a.filter(n=>n!==s))},children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Additional Instructions (optional)"}),e.jsx(ve,{value:E,onChange:s=>Q(s.target.value),placeholder:"Add any custom instructions for the coding agent...",rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(r,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(r,{onClick:re,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{ts as default};
@@ -1 +1 @@
1
- import{r as x,j as e,e as a,n as m}from"./index-DB2Tq9wz.js";function u({title:n,description:t,icon:r,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:n}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};
1
+ import{r as x,j as e,e as a,n as m}from"./index-ByTA2ZiD.js";function u({title:n,description:t,icon:r,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:n}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};