@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.
- package/dist/lib/git.d.ts +3 -0
- package/dist/lib/git.js +35 -0
- package/dist/lib/terminal/terminal-manager.js +2 -1
- package/dist/routes/api/v1/ai/route.js +214 -152
- package/dist/routes/api/v1/config/route.js +13 -9
- package/dist/routes/api/v1/context/agents/route.d.ts +3 -0
- package/dist/routes/api/v1/context/agents/route.js +159 -0
- package/dist/routes/api/v1/context/index.js +6 -4
- package/dist/routes/api/v1/context/memory/route.d.ts +3 -0
- package/dist/routes/api/v1/context/memory/route.js +163 -0
- package/dist/routes/api/v1/context/team/route.d.ts +3 -0
- package/dist/routes/api/v1/context/team/route.js +159 -0
- package/dist/routes/api/v1/events/status/route.d.ts +1 -1
- package/dist/routes/api/v1/git/index.js +27 -1
- package/dist/routes/api/v1/jobs/[id]/route.d.ts +26 -32
- package/dist/routes/api/v1/jobs/[id]/route.js +3 -3
- package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
- package/dist/routes/api/v1/jobs/[id]/runs/[runId]/route.d.ts +2 -2
- package/dist/routes/api/v1/jobs/route.d.ts +33 -33
- package/dist/routes/api/v1/jobs/route.js +17 -2
- package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
- package/dist/routes/api/v1/mail/route.d.ts +3 -3
- package/dist/routes/api/v1/mcp/index.js +194 -21
- package/dist/routes/api/v1/resources/generate/route.js +10 -3
- package/dist/routes/api/v1/slack/route.d.ts +6 -6
- package/dist/routes/api/v1/tasks/[id]/route.d.ts +4 -4
- package/dist/routes/api/v1/tasks/[id]/steps/[stepId]/route.d.ts +2 -2
- package/dist/routes/api/v1/tasks/route.d.ts +1 -1
- package/dist/server-with-static.js +23 -17
- package/dist/server.js +1 -0
- package/package.json +24 -23
- package/static/assets/ActivityPage-rASRHKYj.js +1 -0
- package/static/assets/AgentsContextEditPage-CMWD-7mS.js +9 -0
- package/static/assets/AgentsContextPage-VfMmxxr6.js +1 -0
- package/static/assets/{ApiKeysSettingsPage-CjrCuHHE.js → ApiKeysSettingsPage-DxtuyXwn.js} +2 -2
- package/static/assets/{AuthSettingsPage-elJX4TCV.js → AuthSettingsPage-CWTpS6BA.js} +2 -2
- package/static/assets/{CallbackPage-CUuZYgBL.js → CallbackPage-CjlTVuif.js} +1 -1
- package/static/assets/CodePage-DwjtGxQi.js +2 -0
- package/static/assets/{CollapsibleSection-DfTxWX0X.js → CollapsibleSection-LrQJlSxD.js} +1 -1
- package/static/assets/{DashboardPage-CmS8UPSm.js → DashboardPage-DnyFyDO0.js} +9 -19
- package/static/assets/{GitPage-DSfn76oO.js → GitPage-o37iQMYQ.js} +3 -3
- package/static/assets/{GitSettingsPage-Bu8h7hcr.js → GitSettingsPage-O0fe5kxm.js} +2 -2
- package/static/assets/{IdentityPage-NFKq2FHi.js → IdentityPage-KWjruliO.js} +2 -2
- package/static/assets/{ImplementationStepsEditor-Cn-MshnR.js → ImplementationStepsEditor-h_Mxu1tF.js} +2 -2
- package/static/assets/IntegrationsSettingsPage-DeFQd6af.js +1 -0
- package/static/assets/JobDetailPage-HOLpF7Sx.js +1 -0
- package/static/assets/KnowledgeDetailPage-C5egPQ54.js +1 -0
- package/static/assets/KnowledgeEditPage-DrdvEGuR.js +1 -0
- package/static/assets/{KnowledgePage-C3zoPEcH.js → KnowledgePage-CK5rtZcv.js} +2 -2
- package/static/assets/{LoginPage-BYNLGEnz.js → LoginPage-DajEouCN.js} +1 -1
- package/static/assets/MailInboxPage-CewILL7o.js +1 -0
- package/static/assets/MailProcessingModal-B1ZLXyYl.js +1 -0
- package/static/assets/MailReadPage--LnQ743i.js +1 -0
- package/static/assets/MailSentPage-BqO4iBq6.js +1 -0
- package/static/assets/{McpSettingsPage-CfhBioEH.js → McpSettingsPage-BZ6GJOtk.js} +1 -1
- package/static/assets/MemoryEditPage-BLfdKEDu.js +13 -0
- package/static/assets/MemoryPage-BV0RlvUS.js +1 -0
- package/static/assets/{NewKnowledgePage-BUwh_DFd.js → NewKnowledgePage-SrBhXpH6.js} +1 -1
- package/static/assets/{NewSkillPage-B2rztwzD.js → NewSkillPage-vt-0rIkv.js} +1 -1
- package/static/assets/{NewTaskPage-Cvw20nug.js → NewTaskPage-CBUpwIFP.js} +2 -2
- package/static/assets/{NotFoundPage-CXvLVHsT.js → NotFoundPage-CWF5qOC0.js} +1 -1
- package/static/assets/{NotificationsSettingsPage-Df_GZ7_p.js → NotificationsSettingsPage-3ZvMrqiq.js} +1 -1
- package/static/assets/{PromptsSettingsPage-QTxJgO5-.js → PromptsSettingsPage-pHKoiUPI.js} +1 -1
- package/static/assets/{ResourceDetailPage-C9RHHVKu.js → ResourceDetailPage-CE4iDbv7.js} +1 -1
- package/static/assets/ResourcesPage-4_5NA4RF.js +41 -0
- package/static/assets/{RoleEditPage-N2-v2MXN.js → RoleEditPage-4sSELIRX.js} +1 -1
- package/static/assets/{RolePage-Da0kZMUH.js → RolePage-Ds17xn4X.js} +1 -1
- package/static/assets/{RulesSettingsPage-CSd5iz22.js → RulesSettingsPage-DnyGaden.js} +1 -1
- package/static/assets/RunDetailPage-D2ajvKfh.js +1 -0
- package/static/assets/SchedulePage-oEGct1B1.js +4 -0
- package/static/assets/{SkillDetailPage-QjqBAuFU.js → SkillDetailPage-mSypV_JK.js} +1 -1
- package/static/assets/{SkillEditPage-BB0x4VVH.js → SkillEditPage-DeI8uu3S.js} +1 -1
- package/static/assets/{SkillsPage-BMDNxMmZ.js → SkillsPage-Bb_dEdun.js} +2 -2
- package/static/assets/{SkillsSettingsPage-DcdeOlAl.js → SkillsSettingsPage-CMWf2O9y.js} +1 -1
- package/static/assets/SourceInput-CtyUOXOG.js +1 -0
- package/static/assets/{TagInput-bxFcAknC.js → TagInput-C0NyMxlY.js} +1 -1
- package/static/assets/{TaskDetailPage-CAmREdfh.js → TaskDetailPage-6DDI0juh.js} +1 -1
- package/static/assets/{TaskEditPage-BDgZtG36.js → TaskEditPage-Btc1NXtR.js} +1 -1
- package/static/assets/{TasksPage-BQ6eLw0T.js → TasksPage-C9TYvqRz.js} +3 -3
- package/static/assets/TeamEditPage-CLvNy6Ss.js +9 -0
- package/static/assets/TeamPage-DSWax4fa.js +1 -0
- package/static/assets/{TerminalPage-BhWGRGf1.js → TerminalPage-DNDHEYJZ.js} +1 -1
- package/static/assets/{TerminalSessionPage-Bu-WiE0d.js → TerminalSessionPage-nNCw_oDE.js} +2 -2
- package/static/assets/{UserPreferencesPage-B_Tu1a8h.js → UserPreferencesPage-jc1SA79x.js} +1 -1
- package/static/assets/UserSettingsPage-pr6n15Pz.js +1 -0
- package/static/assets/UtilitiesPage-CjLb989o.js +1 -0
- package/static/assets/{alert-C42EBWiI.js → alert-BtkLXQ3p.js} +1 -1
- package/static/assets/{arrow-down-CuFFg288.js → arrow-down-DnNLmXEs.js} +1 -1
- package/static/assets/{arrow-left-C8VbyW3d.js → arrow-left-B9NBHEkS.js} +1 -1
- package/static/assets/{arrow-up-down-GN3qK2mU.js → arrow-up-down-DIuMvAne.js} +1 -1
- package/static/assets/{arrow-up-vC1c-5gW.js → arrow-up-eMUJY7J9.js} +1 -1
- package/static/assets/{badge-CKwUSKzT.js → badge-BbfU_aPt.js} +1 -1
- package/static/assets/{browser-modal-C9VBJ_El.js → browser-modal-J9l3o5os.js} +2 -2
- package/static/assets/{card-DRBgMGuU.js → card-CL5bB4cs.js} +1 -1
- package/static/assets/{chevron-left-2sP4ienq.js → chevron-left-B-7K6MNx.js} +1 -1
- package/static/assets/{chevron-up-DJfyvHso.js → chevron-up-BwTmMEW2.js} +1 -1
- package/static/assets/{chevrons-up-DfFpzHXf.js → chevrons-up-jI6nxhrz.js} +1 -1
- package/static/assets/{circle-alert-DP4rtmEK.js → circle-alert-vJFSz39V.js} +1 -1
- package/static/assets/{circle-check-Cnp-EoKX.js → circle-check-D2LVHMl-.js} +1 -1
- package/static/assets/{circle-check-big-3mrGMFVn.js → circle-check-big-BwQ_q1N7.js} +1 -1
- package/static/assets/{circle-play-7F5AVehH.js → circle-play-CLKDBkrK.js} +1 -1
- package/static/assets/{circle-x-DxbiyJ6w.js → circle-x-CuUVLiI-.js} +1 -1
- package/static/assets/{clipboard-CQNR4_yT.js → clipboard-BHOFelnW.js} +1 -1
- package/static/assets/{clock-DGw3R_UL.js → clock-D-X3KCw6.js} +1 -1
- package/static/assets/{code-DSNMK8tD.js → code-DqYaanki.js} +1 -1
- package/static/assets/{download-BWL6PFiw.js → download-DeEju9jg.js} +1 -1
- package/static/assets/{external-link-BqUE-DMN.js → external-link-CrRz0sU-.js} +1 -1
- package/static/assets/{eye-BD57N1qQ.js → eye-Cx9ZGkg5.js} +1 -1
- package/static/assets/{folder-git-2-CW5Zi8Bm.js → folder-git-2-Cizv1NA6.js} +1 -1
- package/static/assets/globe-lpD9Jv31.js +6 -0
- package/static/assets/{index-BWktaW8U.js → index-BCYTbJRb.js} +1 -1
- package/static/assets/{index-BArpuuuE.js → index-BL-5Bhtg.js} +1 -1
- package/static/assets/{index-EpelXypg.js → index-BPdWQ0rI.js} +1 -1
- package/static/assets/{index-CheR43vH.js → index-BVrOTqTm.js} +1 -1
- package/static/assets/{index-uxv5vQZF.js → index-BknCCMZK.js} +1 -1
- package/static/assets/{index-CVVL2h9f.js → index-BvZJRqTz.js} +1 -1
- package/static/assets/index-ByTA2ZiD.js +497 -0
- package/static/assets/{index-CMt1ExW-.js → index-CMaK0hpv.js} +1 -1
- package/static/assets/{index-CMQcknsg.js → index-CkT4WgqR.js} +1 -1
- package/static/assets/{index-Bedu89qc.js → index-CuLP7P_G.js} +1 -1
- package/static/assets/{index-B9OOTqx4.js → index-D12O6wM3.js} +1 -1
- package/static/assets/{index-stPObw-o.js → index-DIt703WU.js} +1 -1
- package/static/assets/{index-CXWGFCS-.js → index-DK1gGyTZ.js} +1 -1
- package/static/assets/index-DVMcu9sQ.css +1 -0
- package/static/assets/{index-BG5vEV31.js → index-Dc9Njo8L.js} +1 -1
- package/static/assets/{index-B0fLM-4F.js → index-DgAcL75U.js} +1 -1
- package/static/assets/{index-BmTTXfmk.js → index-Djzp98Vj.js} +1 -1
- package/static/assets/{index-DO47L-WG.js → index-Dnj5cWsp.js} +1 -1
- package/static/assets/{index-X4fPPLHI.js → index-Hy3cH93B.js} +1 -1
- package/static/assets/{index-D4awulBm.js → index-ihWq-CVE.js} +1 -1
- package/static/assets/{info-DMJxIp7i.js → info-DxhTCbw1.js} +1 -1
- package/static/assets/{label-DxDedS8x.js → label-Dp0-28_O.js} +1 -1
- package/static/assets/{markdown-editor-DJ2CscSp.js → markdown-editor-DUmrf1eN.js} +3 -3
- package/static/assets/{message-square-DF58cqKJ.js → message-square-BPOApeM3.js} +1 -1
- package/static/assets/{paperclip-CHyfSVll.js → paperclip-Bfjc1WLZ.js} +1 -1
- package/static/assets/{pause-B-ouFhaQ.js → pause-Bfz-QQZp.js} +1 -1
- package/static/assets/{pipeline-builders-Bkf0wt_O.js → pipeline-builders-DrEjlsbH.js} +1 -1
- package/static/assets/{play-B0y1weCV.js → play-fOwEoIcu.js} +1 -1
- package/static/assets/{radio-group-DFNQiPDU.js → radio-group-B8RB7N01.js} +1 -1
- package/static/assets/{refresh-cw-5y5jTc6x.js → refresh-cw-Cj_5MZiJ.js} +1 -1
- package/static/assets/{search-B5deRThk.js → search-BgbqRUnf.js} +1 -1
- package/static/assets/{select-BzOa_wZx.js → select-CfwLZl55.js} +1 -1
- package/static/assets/server-u9FLHclt.js +6 -0
- package/static/assets/{switch-Bf2z8aaj.js → switch-CX_Inx_p.js} +1 -1
- package/static/assets/{tabs-DkdBSep3.js → tabs-Bj0YyeRI.js} +1 -1
- package/static/assets/{tag-gRsTk0jY.js → tag-rYG4CdRx.js} +1 -1
- package/static/assets/terminal-preview-BNm5-Umi.js +1 -0
- package/static/assets/triangle-alert-C0ovMJwZ.js +6 -0
- package/static/assets/{use-terminal-D6Qe1nwM.js → use-terminal-D1UnvAVs.js} +1 -1
- package/static/assets/{video-DXo9sCfT.js → video-CuyRES-H.js} +1 -1
- package/static/index.html +2 -2
- package/static/assets/ActivityPage-BaSoKgwZ.js +0 -1
- package/static/assets/ArchitectureEditPage-MYU7btLs.js +0 -21
- package/static/assets/ArchitecturePage-CGqWy8b1.js +0 -1
- package/static/assets/CodePage-C_bzfOnI.js +0 -2
- package/static/assets/IntegrationsSettingsPage-Cw6ItrNf.js +0 -1
- package/static/assets/JobDetailPage-DLSD4HiU.js +0 -1
- package/static/assets/KnowledgeDetailPage-DY8PpD9X.js +0 -1
- package/static/assets/KnowledgeEditPage-B28N-7vM.js +0 -1
- package/static/assets/MailInboxPage-DDYg0W70.js +0 -1
- package/static/assets/MailProcessingModal-CXIrtSz0.js +0 -6
- package/static/assets/MailReadPage-CVz6oD-y.js +0 -1
- package/static/assets/MailSentPage-ClaVWZCR.js +0 -1
- package/static/assets/ProjectEditPage-DKf6ZoiG.js +0 -11
- package/static/assets/ProjectPage-CHhx9s1k.js +0 -1
- package/static/assets/ResourcesPage-BI8tfYZ2.js +0 -41
- package/static/assets/SchedulePage-CS8g2Db-.js +0 -4
- package/static/assets/SourceInput-rc4KSqcv.js +0 -1
- package/static/assets/UserSettingsPage-BnEGtrGo.js +0 -1
- package/static/assets/UtilitiesPage-k7ABCAig.js +0 -1
- package/static/assets/index-Cht-fo9a.css +0 -1
- package/static/assets/index-DB2Tq9wz.js +0 -487
- package/static/assets/terminal-preview-BfrUN2ok.js +0 -1
|
@@ -9,12 +9,6 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
9
9
|
}, 404, "json">) | (Response & import("hono").TypedResponse<{
|
|
10
10
|
success: true;
|
|
11
11
|
data: {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
description?: string;
|
|
15
|
-
prompt: string;
|
|
16
|
-
model: string;
|
|
17
|
-
status: ScheduledJobStatus;
|
|
18
12
|
schedule: {
|
|
19
13
|
type: "cron";
|
|
20
14
|
expression: string;
|
|
@@ -27,29 +21,32 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
27
21
|
timezone?: string;
|
|
28
22
|
anchorHour?: number;
|
|
29
23
|
};
|
|
24
|
+
status: ScheduledJobStatus;
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
30
27
|
metadata: {
|
|
31
28
|
createdAt: string;
|
|
32
29
|
updatedAt: string;
|
|
33
30
|
lastRunAt?: string;
|
|
34
31
|
nextRunAt?: string;
|
|
35
32
|
};
|
|
33
|
+
tags?: string[];
|
|
34
|
+
description?: string;
|
|
35
|
+
model: string;
|
|
36
|
+
prompt: string;
|
|
37
|
+
mcpServers?: string[];
|
|
38
|
+
contextPaths?: string[];
|
|
39
|
+
agentId?: string;
|
|
40
|
+
agentIds?: string[];
|
|
36
41
|
runs: {
|
|
37
|
-
id: string;
|
|
38
42
|
jobId: string;
|
|
39
43
|
trigger: import("@lovelybunch/types").ScheduledJobTrigger;
|
|
40
44
|
status: import("@lovelybunch/types").ScheduledJobRunStatus;
|
|
45
|
+
error?: string;
|
|
46
|
+
id: string;
|
|
41
47
|
startedAt: string;
|
|
42
48
|
finishedAt?: string;
|
|
43
|
-
outputPath?: string;
|
|
44
|
-
summary?: string;
|
|
45
|
-
error?: string;
|
|
46
|
-
cliCommand?: string;
|
|
47
49
|
}[];
|
|
48
|
-
tags?: string[];
|
|
49
|
-
contextPaths?: string[];
|
|
50
|
-
agentId?: string;
|
|
51
|
-
agentIds?: string[];
|
|
52
|
-
mcpServers?: string[];
|
|
53
50
|
};
|
|
54
51
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
55
52
|
success: false;
|
|
@@ -73,12 +70,6 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
|
|
|
73
70
|
}, 400, "json">) | (Response & import("hono").TypedResponse<{
|
|
74
71
|
success: true;
|
|
75
72
|
data: {
|
|
76
|
-
id: string;
|
|
77
|
-
name: string;
|
|
78
|
-
description?: string;
|
|
79
|
-
prompt: string;
|
|
80
|
-
model: string;
|
|
81
|
-
status: ScheduledJobStatus;
|
|
82
73
|
schedule: {
|
|
83
74
|
type: "cron";
|
|
84
75
|
expression: string;
|
|
@@ -91,29 +82,32 @@ export declare function PATCH(c: Context): Promise<(Response & import("hono").Ty
|
|
|
91
82
|
timezone?: string;
|
|
92
83
|
anchorHour?: number;
|
|
93
84
|
};
|
|
85
|
+
status: ScheduledJobStatus;
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
94
88
|
metadata: {
|
|
95
89
|
createdAt: string;
|
|
96
90
|
updatedAt: string;
|
|
97
91
|
lastRunAt?: string;
|
|
98
92
|
nextRunAt?: string;
|
|
99
93
|
};
|
|
94
|
+
tags?: string[];
|
|
95
|
+
description?: string;
|
|
96
|
+
model: string;
|
|
97
|
+
prompt: string;
|
|
98
|
+
mcpServers?: string[];
|
|
99
|
+
contextPaths?: string[];
|
|
100
|
+
agentId?: string;
|
|
101
|
+
agentIds?: string[];
|
|
100
102
|
runs: {
|
|
101
|
-
id: string;
|
|
102
103
|
jobId: string;
|
|
103
104
|
trigger: import("@lovelybunch/types").ScheduledJobTrigger;
|
|
104
105
|
status: import("@lovelybunch/types").ScheduledJobRunStatus;
|
|
106
|
+
error?: string;
|
|
107
|
+
id: string;
|
|
105
108
|
startedAt: string;
|
|
106
109
|
finishedAt?: string;
|
|
107
|
-
outputPath?: string;
|
|
108
|
-
summary?: string;
|
|
109
|
-
error?: string;
|
|
110
|
-
cliCommand?: string;
|
|
111
110
|
}[];
|
|
112
|
-
tags?: string[];
|
|
113
|
-
contextPaths?: string[];
|
|
114
|
-
agentId?: string;
|
|
115
|
-
agentIds?: string[];
|
|
116
|
-
mcpServers?: string[];
|
|
117
111
|
};
|
|
118
112
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
119
113
|
success: false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JobStore } from '../../../../../lib/jobs/job-store.js';
|
|
2
2
|
import { getGlobalJobScheduler } from '../../../../../lib/jobs/global-job-scheduler.js';
|
|
3
|
-
import { normalizeSchedule, normalizeStatus, } from '../route.js';
|
|
3
|
+
import { normalizeSchedule, normalizeStatus, withLightweightRuns, } from '../route.js';
|
|
4
4
|
const store = new JobStore();
|
|
5
5
|
const scheduler = getGlobalJobScheduler();
|
|
6
6
|
function normalizeScheduleUpdate(current, incoming) {
|
|
@@ -32,7 +32,7 @@ export async function GET(c) {
|
|
|
32
32
|
}
|
|
33
33
|
}, 404);
|
|
34
34
|
}
|
|
35
|
-
return c.json({ success: true, data: job });
|
|
35
|
+
return c.json({ success: true, data: withLightweightRuns(job) });
|
|
36
36
|
}
|
|
37
37
|
catch (error) {
|
|
38
38
|
console.error('Failed to fetch job:', error);
|
|
@@ -101,7 +101,7 @@ export async function PATCH(c) {
|
|
|
101
101
|
const reloaded = await store.getJob(updated.id);
|
|
102
102
|
return c.json({
|
|
103
103
|
success: true,
|
|
104
|
-
data: reloaded ?? updated
|
|
104
|
+
data: withLightweightRuns(reloaded ?? updated)
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
catch (error) {
|
|
@@ -12,8 +12,8 @@ export declare function POST(c: Context): Promise<(Response & import("hono").Typ
|
|
|
12
12
|
run: {
|
|
13
13
|
id: string;
|
|
14
14
|
jobId: string;
|
|
15
|
-
trigger: import("
|
|
16
|
-
status: import("
|
|
15
|
+
trigger: import("node_modules/@lovelybunch/types/src/index.js").ScheduledJobTrigger;
|
|
16
|
+
status: import("node_modules/@lovelybunch/types/src/index.js").ScheduledJobRunStatus;
|
|
17
17
|
startedAt: string;
|
|
18
18
|
finishedAt?: string;
|
|
19
19
|
outputPath?: string;
|
|
@@ -10,8 +10,8 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
10
10
|
data: {
|
|
11
11
|
id: string;
|
|
12
12
|
jobId: string;
|
|
13
|
-
trigger: import("
|
|
14
|
-
status: import("
|
|
13
|
+
trigger: import("node_modules/@lovelybunch/types/src/index.js").ScheduledJobTrigger;
|
|
14
|
+
status: import("node_modules/@lovelybunch/types/src/index.js").ScheduledJobRunStatus;
|
|
15
15
|
startedAt: string;
|
|
16
16
|
finishedAt?: string;
|
|
17
17
|
outputPath?: string;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { DayOfWeek, ScheduledJobSchedule, ScheduledJobStatus } from '@lovelybunch/types';
|
|
2
|
+
import { DayOfWeek, ScheduledJobRun, ScheduledJobRunMeta, ScheduledJobSchedule, ScheduledJobStatus } from '@lovelybunch/types';
|
|
3
3
|
export declare function normalizeSchedule(schedule?: Partial<ScheduledJobSchedule>): ScheduledJobSchedule;
|
|
4
4
|
export declare function normalizeStatus(status?: ScheduledJobStatus): ScheduledJobStatus;
|
|
5
|
+
export declare function toRunMeta(run: ScheduledJobRun): ScheduledJobRunMeta;
|
|
6
|
+
export declare function withLightweightRuns<T extends {
|
|
7
|
+
runs: ScheduledJobRun[];
|
|
8
|
+
}>(job: T): Omit<T, 'runs'> & {
|
|
9
|
+
runs: ScheduledJobRunMeta[];
|
|
10
|
+
};
|
|
5
11
|
export declare function GET(c: Context): Promise<(Response & import("hono").TypedResponse<{
|
|
6
12
|
success: true;
|
|
7
13
|
data: {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
prompt: string;
|
|
12
|
-
model: string;
|
|
13
|
-
status: ScheduledJobStatus;
|
|
14
14
|
schedule: {
|
|
15
15
|
type: "cron";
|
|
16
16
|
expression: string;
|
|
@@ -23,29 +23,32 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
23
23
|
timezone?: string;
|
|
24
24
|
anchorHour?: number;
|
|
25
25
|
};
|
|
26
|
+
status: ScheduledJobStatus;
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
26
29
|
metadata: {
|
|
27
30
|
createdAt: string;
|
|
28
31
|
updatedAt: string;
|
|
29
32
|
lastRunAt?: string;
|
|
30
33
|
nextRunAt?: string;
|
|
31
34
|
};
|
|
35
|
+
tags?: string[];
|
|
36
|
+
description?: string;
|
|
37
|
+
model: string;
|
|
38
|
+
prompt: string;
|
|
39
|
+
mcpServers?: string[];
|
|
40
|
+
contextPaths?: string[];
|
|
41
|
+
agentId?: string;
|
|
42
|
+
agentIds?: string[];
|
|
32
43
|
runs: {
|
|
33
|
-
id: string;
|
|
34
44
|
jobId: string;
|
|
35
45
|
trigger: import("@lovelybunch/types").ScheduledJobTrigger;
|
|
36
46
|
status: import("@lovelybunch/types").ScheduledJobRunStatus;
|
|
47
|
+
error?: string;
|
|
48
|
+
id: string;
|
|
37
49
|
startedAt: string;
|
|
38
50
|
finishedAt?: string;
|
|
39
|
-
outputPath?: string;
|
|
40
|
-
summary?: string;
|
|
41
|
-
error?: string;
|
|
42
|
-
cliCommand?: string;
|
|
43
51
|
}[];
|
|
44
|
-
tags?: string[];
|
|
45
|
-
contextPaths?: string[];
|
|
46
|
-
agentId?: string;
|
|
47
|
-
agentIds?: string[];
|
|
48
|
-
mcpServers?: string[];
|
|
49
52
|
}[];
|
|
50
53
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
51
54
|
success: false;
|
|
@@ -63,12 +66,6 @@ export declare function POST(c: Context): Promise<(Response & import("hono").Typ
|
|
|
63
66
|
}, 400, "json">) | (Response & import("hono").TypedResponse<{
|
|
64
67
|
success: true;
|
|
65
68
|
data: {
|
|
66
|
-
id: string;
|
|
67
|
-
name: string;
|
|
68
|
-
description?: string;
|
|
69
|
-
prompt: string;
|
|
70
|
-
model: string;
|
|
71
|
-
status: ScheduledJobStatus;
|
|
72
69
|
schedule: {
|
|
73
70
|
type: "cron";
|
|
74
71
|
expression: string;
|
|
@@ -81,29 +78,32 @@ export declare function POST(c: Context): Promise<(Response & import("hono").Typ
|
|
|
81
78
|
timezone?: string;
|
|
82
79
|
anchorHour?: number;
|
|
83
80
|
};
|
|
81
|
+
status: ScheduledJobStatus;
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
84
|
metadata: {
|
|
85
85
|
createdAt: string;
|
|
86
86
|
updatedAt: string;
|
|
87
87
|
lastRunAt?: string;
|
|
88
88
|
nextRunAt?: string;
|
|
89
89
|
};
|
|
90
|
+
tags?: string[];
|
|
91
|
+
description?: string;
|
|
92
|
+
model: string;
|
|
93
|
+
prompt: string;
|
|
94
|
+
mcpServers?: string[];
|
|
95
|
+
contextPaths?: string[];
|
|
96
|
+
agentId?: string;
|
|
97
|
+
agentIds?: string[];
|
|
90
98
|
runs: {
|
|
91
|
-
id: string;
|
|
92
99
|
jobId: string;
|
|
93
100
|
trigger: import("@lovelybunch/types").ScheduledJobTrigger;
|
|
94
101
|
status: import("@lovelybunch/types").ScheduledJobRunStatus;
|
|
102
|
+
error?: string;
|
|
103
|
+
id: string;
|
|
95
104
|
startedAt: string;
|
|
96
105
|
finishedAt?: string;
|
|
97
|
-
outputPath?: string;
|
|
98
|
-
summary?: string;
|
|
99
|
-
error?: string;
|
|
100
|
-
cliCommand?: string;
|
|
101
106
|
}[];
|
|
102
|
-
tags?: string[];
|
|
103
|
-
contextPaths?: string[];
|
|
104
|
-
agentId?: string;
|
|
105
|
-
agentIds?: string[];
|
|
106
|
-
mcpServers?: string[];
|
|
107
107
|
};
|
|
108
108
|
}, 201, "json">) | (Response & import("hono").TypedResponse<{
|
|
109
109
|
success: false;
|
|
@@ -58,12 +58,27 @@ export function normalizeSchedule(schedule) {
|
|
|
58
58
|
export function normalizeStatus(status) {
|
|
59
59
|
return status === 'active' ? 'active' : 'paused';
|
|
60
60
|
}
|
|
61
|
+
export function toRunMeta(run) {
|
|
62
|
+
return {
|
|
63
|
+
id: run.id,
|
|
64
|
+
jobId: run.jobId,
|
|
65
|
+
trigger: run.trigger,
|
|
66
|
+
status: run.status,
|
|
67
|
+
startedAt: run.startedAt,
|
|
68
|
+
finishedAt: run.finishedAt,
|
|
69
|
+
error: run.error,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function withLightweightRuns(job) {
|
|
73
|
+
const { runs, ...rest } = job;
|
|
74
|
+
return { ...rest, runs: runs.map(toRunMeta) };
|
|
75
|
+
}
|
|
61
76
|
export async function GET(c) {
|
|
62
77
|
try {
|
|
63
78
|
const jobs = await store.listJobs();
|
|
64
79
|
return c.json({
|
|
65
80
|
success: true,
|
|
66
|
-
data: jobs
|
|
81
|
+
data: jobs.map(withLightweightRuns)
|
|
67
82
|
});
|
|
68
83
|
}
|
|
69
84
|
catch (error) {
|
|
@@ -131,7 +146,7 @@ export async function POST(c) {
|
|
|
131
146
|
const created = await store.getJob(job.id);
|
|
132
147
|
return c.json({
|
|
133
148
|
success: true,
|
|
134
|
-
data: created ?? job
|
|
149
|
+
data: withLightweightRuns(created ?? job)
|
|
135
150
|
}, 201);
|
|
136
151
|
}
|
|
137
152
|
catch (error) {
|
|
@@ -7,7 +7,7 @@ export declare function GET(c: Context): Promise<(Response & import("hono").Type
|
|
|
7
7
|
runningCount: number;
|
|
8
8
|
jobs: {
|
|
9
9
|
id: string;
|
|
10
|
-
status: import("
|
|
10
|
+
status: import("node_modules/@lovelybunch/types/src/index.js").ScheduledJobStatus;
|
|
11
11
|
nextRunAt?: string;
|
|
12
12
|
lastRunAt?: string;
|
|
13
13
|
timerActive: boolean;
|
|
@@ -116,7 +116,7 @@ export declare function setMailStatusHandler(c: Context): Promise<(Response & im
|
|
|
116
116
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
117
117
|
success: false;
|
|
118
118
|
error: any;
|
|
119
|
-
},
|
|
119
|
+
}, 404 | 500, "json">)>;
|
|
120
120
|
/**
|
|
121
121
|
* POST /api/v1/mail/:id/reply
|
|
122
122
|
* Reply to an email
|
|
@@ -154,7 +154,7 @@ export declare function replyMailHandler(c: Context): Promise<(Response & import
|
|
|
154
154
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
155
155
|
success: false;
|
|
156
156
|
error: any;
|
|
157
|
-
},
|
|
157
|
+
}, 404 | 500, "json">)>;
|
|
158
158
|
/**
|
|
159
159
|
* POST /api/v1/mail/send
|
|
160
160
|
* Send an email (coming soon)
|
|
@@ -217,7 +217,7 @@ export declare function setMailActionHandler(c: Context): Promise<(Response & im
|
|
|
217
217
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
218
218
|
success: false;
|
|
219
219
|
error: any;
|
|
220
|
-
},
|
|
220
|
+
}, 404 | 500, "json">)>;
|
|
221
221
|
/**
|
|
222
222
|
* GET /api/v1/mail/:id/processing
|
|
223
223
|
* Get processing status and log tail for an email
|
|
@@ -3,10 +3,36 @@ import { promises as fs } from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { ZodError } from 'zod';
|
|
5
5
|
import { listTasks, getTask, createTask, updateTask, deleteTask, getContext, updateContext, appendContext, replaceContextSection, listKnowledge, getKnowledge, createKnowledge, updateKnowledge, listEvents, } from '@lovelybunch/core';
|
|
6
|
-
import { tasksFullTool, knowledgeTool, normalizeKnowledgeMetadata, eventsTool,
|
|
6
|
+
import { tasksFullTool, knowledgeTool, normalizeKnowledgeMetadata, eventsTool, roleContextTool, agentsContextTool, teamContextTool, memoryContextTool, resourcesTool, listConnectorsTool, connectorRequestTool, resolveConnectorUrl } from '@lovelybunch/mcp';
|
|
7
7
|
import { FileStorageAdapter } from '../../../../lib/storage/file-storage.js';
|
|
8
|
+
import { homedir } from 'os';
|
|
9
|
+
import { readFileSync, existsSync } from 'fs';
|
|
8
10
|
const app = new Hono();
|
|
9
11
|
const storage = new FileStorageAdapter();
|
|
12
|
+
const COCONUT_HOST = 'https://app.coconut.dev';
|
|
13
|
+
function getCallbackToken() {
|
|
14
|
+
try {
|
|
15
|
+
const platform = process.platform;
|
|
16
|
+
let configDir;
|
|
17
|
+
if (platform === 'win32') {
|
|
18
|
+
configDir = path.join(process.env.APPDATA || homedir(), 'coconuts');
|
|
19
|
+
}
|
|
20
|
+
else if (platform === 'darwin') {
|
|
21
|
+
configDir = path.join(homedir(), 'Library', 'Application Support', 'coconuts');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
configDir = path.join(process.env.XDG_CONFIG_HOME || path.join(homedir(), '.config'), 'coconuts');
|
|
25
|
+
}
|
|
26
|
+
const configFile = path.join(configDir, 'config.json');
|
|
27
|
+
if (!existsSync(configFile))
|
|
28
|
+
return null;
|
|
29
|
+
const config = JSON.parse(readFileSync(configFile, 'utf-8'));
|
|
30
|
+
return config.apiKeys?.callbackToken || null;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
10
36
|
function resolveGaitPath() {
|
|
11
37
|
let basePath;
|
|
12
38
|
if (process.env.NODE_ENV === 'development' && process.env.GAIT_DEV_ROOT) {
|
|
@@ -78,15 +104,18 @@ app.get('/', async (c) => {
|
|
|
78
104
|
}
|
|
79
105
|
const names = Object.keys(externalServers);
|
|
80
106
|
// Add built-in tools (include full JSON schema for parameters)
|
|
81
|
-
// Note: tasks now supports full CRUD, knowledge/
|
|
107
|
+
// Note: tasks now supports full CRUD, knowledge/context tools are read+write, events is read-only
|
|
82
108
|
const builtInTools = {
|
|
83
109
|
tasks: tasksFullTool,
|
|
84
110
|
knowledge_documents: knowledgeTool,
|
|
85
111
|
activity_events: eventsTool,
|
|
86
|
-
project_context: projectContextTool,
|
|
87
|
-
architecture_context: architectureContextTool,
|
|
88
112
|
role_context: roleContextTool,
|
|
89
|
-
|
|
113
|
+
agents_context: agentsContextTool,
|
|
114
|
+
team_context: teamContextTool,
|
|
115
|
+
memory_context: memoryContextTool,
|
|
116
|
+
resources: resourcesTool,
|
|
117
|
+
list_connectors: listConnectorsTool,
|
|
118
|
+
connector_request: connectorRequestTool
|
|
90
119
|
};
|
|
91
120
|
return c.json({
|
|
92
121
|
success: true,
|
|
@@ -106,16 +135,19 @@ app.get('/', async (c) => {
|
|
|
106
135
|
*/
|
|
107
136
|
app.get('/schema', async (c) => {
|
|
108
137
|
try {
|
|
109
|
-
// Note: tasks now supports full CRUD, knowledge/
|
|
138
|
+
// Note: tasks now supports full CRUD, knowledge/context tools are read+write, events is read-only
|
|
110
139
|
const schema = {
|
|
111
140
|
tools: {
|
|
112
141
|
tasks: tasksFullTool,
|
|
113
142
|
knowledge_documents: knowledgeTool,
|
|
114
143
|
activity_events: eventsTool,
|
|
115
|
-
project_context: projectContextTool,
|
|
116
|
-
architecture_context: architectureContextTool,
|
|
117
144
|
role_context: roleContextTool,
|
|
118
|
-
|
|
145
|
+
agents_context: agentsContextTool,
|
|
146
|
+
team_context: teamContextTool,
|
|
147
|
+
memory_context: memoryContextTool,
|
|
148
|
+
resources: resourcesTool,
|
|
149
|
+
list_connectors: listConnectorsTool,
|
|
150
|
+
connector_request: connectorRequestTool
|
|
119
151
|
}
|
|
120
152
|
};
|
|
121
153
|
return c.json(schema);
|
|
@@ -144,18 +176,27 @@ app.post('/execute', async (c) => {
|
|
|
144
176
|
if (tool === 'activity_events') {
|
|
145
177
|
return await executeEventsTool(c, args);
|
|
146
178
|
}
|
|
147
|
-
if (tool === 'project_context') {
|
|
148
|
-
return await executeProjectContextTool(c, args);
|
|
149
|
-
}
|
|
150
|
-
if (tool === 'architecture_context') {
|
|
151
|
-
return await executeArchitectureContextTool(c, args);
|
|
152
|
-
}
|
|
153
179
|
if (tool === 'role_context') {
|
|
154
180
|
return await executeRoleContextTool(c, args);
|
|
155
181
|
}
|
|
182
|
+
if (tool === 'agents_context') {
|
|
183
|
+
return await executeAgentsContextTool(c, args);
|
|
184
|
+
}
|
|
185
|
+
if (tool === 'team_context') {
|
|
186
|
+
return await executeTeamContextTool(c, args);
|
|
187
|
+
}
|
|
188
|
+
if (tool === 'memory_context') {
|
|
189
|
+
return await executeMemoryContextTool(c, args);
|
|
190
|
+
}
|
|
156
191
|
if (tool === 'resources') {
|
|
157
192
|
return await executeResourcesTool(c, args);
|
|
158
193
|
}
|
|
194
|
+
if (tool === 'list_connectors') {
|
|
195
|
+
return await executeListConnectorsTool(c);
|
|
196
|
+
}
|
|
197
|
+
if (tool === 'connector_request') {
|
|
198
|
+
return await executeConnectorRequestTool(c, args);
|
|
199
|
+
}
|
|
159
200
|
return c.json({ success: false, error: 'Unknown tool' }, 400);
|
|
160
201
|
}
|
|
161
202
|
catch (error) {
|
|
@@ -446,15 +487,18 @@ async function executeContextTool(c, contextType, args) {
|
|
|
446
487
|
}
|
|
447
488
|
}
|
|
448
489
|
// Wrapper functions for each context type (maintain API compatibility)
|
|
449
|
-
async function executeProjectContextTool(c, args) {
|
|
450
|
-
return executeContextTool(c, 'project', args);
|
|
451
|
-
}
|
|
452
|
-
async function executeArchitectureContextTool(c, args) {
|
|
453
|
-
return executeContextTool(c, 'architecture', args);
|
|
454
|
-
}
|
|
455
490
|
async function executeRoleContextTool(c, args) {
|
|
456
491
|
return executeContextTool(c, 'role', args);
|
|
457
492
|
}
|
|
493
|
+
async function executeAgentsContextTool(c, args) {
|
|
494
|
+
return executeContextTool(c, 'agents', args);
|
|
495
|
+
}
|
|
496
|
+
async function executeTeamContextTool(c, args) {
|
|
497
|
+
return executeContextTool(c, 'team', args);
|
|
498
|
+
}
|
|
499
|
+
async function executeMemoryContextTool(c, args) {
|
|
500
|
+
return executeContextTool(c, 'memory', args);
|
|
501
|
+
}
|
|
458
502
|
// Resources tool executor — proxies to the resource API endpoints on the same server
|
|
459
503
|
async function executeResourcesTool(c, args) {
|
|
460
504
|
const { operation, query, type_filter, resource_id, prompt, model, aspect_ratio, text, voice, duration, resolution, url, tags, description } = args;
|
|
@@ -525,6 +569,135 @@ async function executeResourcesTool(c, args) {
|
|
|
525
569
|
return c.json({ success: false, error: error.message || 'Resources tool execution failed' }, 500);
|
|
526
570
|
}
|
|
527
571
|
}
|
|
572
|
+
async function executeListConnectorsTool(c) {
|
|
573
|
+
const token = getCallbackToken();
|
|
574
|
+
if (!token) {
|
|
575
|
+
return c.json({
|
|
576
|
+
success: false,
|
|
577
|
+
error: 'Callback token not configured. Set it via PUT /api/v1/config?type=global with { "apiKeys": { "callbackToken": "cpt_xxx" } }'
|
|
578
|
+
}, 400);
|
|
579
|
+
}
|
|
580
|
+
try {
|
|
581
|
+
const res = await fetch(`${COCONUT_HOST}/api/connectors/accounts`, {
|
|
582
|
+
headers: { 'X-Callback-Token': token }
|
|
583
|
+
});
|
|
584
|
+
if (!res.ok) {
|
|
585
|
+
const body = await res.text().catch(() => '');
|
|
586
|
+
return c.json({
|
|
587
|
+
success: false,
|
|
588
|
+
error: `Control plane returned ${res.status}: ${body || res.statusText}`
|
|
589
|
+
}, res.status >= 500 ? 502 : 400);
|
|
590
|
+
}
|
|
591
|
+
const data = await res.json();
|
|
592
|
+
const accounts = Array.isArray(data) ? data : (data.accounts ?? data.data ?? []);
|
|
593
|
+
return c.json({
|
|
594
|
+
success: true,
|
|
595
|
+
data: accounts,
|
|
596
|
+
count: accounts.length,
|
|
597
|
+
message: `Found ${accounts.length} connected service${accounts.length === 1 ? '' : 's'}`
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
catch (error) {
|
|
601
|
+
console.error('Error listing connectors:', error);
|
|
602
|
+
return c.json({ success: false, error: error.message || 'Failed to list connectors' }, 500);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
async function executeConnectorRequestTool(c, args) {
|
|
606
|
+
const { app: appSlug, method, path: apiPath, body, headers: extraHeaders } = args;
|
|
607
|
+
if (!appSlug || !method || !apiPath) {
|
|
608
|
+
return c.json({ success: false, error: 'app, method, and path are required' }, 400);
|
|
609
|
+
}
|
|
610
|
+
const token = getCallbackToken();
|
|
611
|
+
if (!token) {
|
|
612
|
+
return c.json({
|
|
613
|
+
success: false,
|
|
614
|
+
error: 'Callback token not configured. Set it via PUT /api/v1/config?type=global with { "apiKeys": { "callbackToken": "cpt_xxx" } }'
|
|
615
|
+
}, 400);
|
|
616
|
+
}
|
|
617
|
+
try {
|
|
618
|
+
const accounts = await fetchConnectorAccounts(token);
|
|
619
|
+
const account = accounts.find((a) => a.appSlug === appSlug || a.appName?.toLowerCase() === appSlug.toLowerCase());
|
|
620
|
+
if (!account) {
|
|
621
|
+
return c.json({
|
|
622
|
+
success: false,
|
|
623
|
+
error: `No connected account found for "${appSlug}"`,
|
|
624
|
+
available: accounts.map((a) => a.appSlug || a.appName)
|
|
625
|
+
}, 404);
|
|
626
|
+
}
|
|
627
|
+
const url = resolveConnectorUrl(appSlug, apiPath);
|
|
628
|
+
if (!url) {
|
|
629
|
+
return c.json({
|
|
630
|
+
success: false,
|
|
631
|
+
error: `Unknown app "${appSlug}" and path is not a full URL. Use a full URL (https://...) or a known app slug.`
|
|
632
|
+
}, 400);
|
|
633
|
+
}
|
|
634
|
+
let parsedBody = undefined;
|
|
635
|
+
if (body) {
|
|
636
|
+
try {
|
|
637
|
+
parsedBody = typeof body === 'string' ? JSON.parse(body) : body;
|
|
638
|
+
}
|
|
639
|
+
catch {
|
|
640
|
+
return c.json({ success: false, error: 'Invalid JSON in body parameter' }, 400);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
let parsedHeaders = {};
|
|
644
|
+
if (extraHeaders) {
|
|
645
|
+
try {
|
|
646
|
+
parsedHeaders = typeof extraHeaders === 'string' ? JSON.parse(extraHeaders) : extraHeaders;
|
|
647
|
+
}
|
|
648
|
+
catch {
|
|
649
|
+
return c.json({ success: false, error: 'Invalid JSON in headers parameter' }, 400);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
const proxyPayload = {
|
|
653
|
+
accountId: account.accountId,
|
|
654
|
+
url,
|
|
655
|
+
method: method.toUpperCase()
|
|
656
|
+
};
|
|
657
|
+
if (parsedBody !== undefined)
|
|
658
|
+
proxyPayload.body = parsedBody;
|
|
659
|
+
if (Object.keys(parsedHeaders).length > 0)
|
|
660
|
+
proxyPayload.headers = parsedHeaders;
|
|
661
|
+
const proxyRes = await fetch(`${COCONUT_HOST}/api/connectors/proxy`, {
|
|
662
|
+
method: 'POST',
|
|
663
|
+
headers: {
|
|
664
|
+
'Content-Type': 'application/json',
|
|
665
|
+
'X-Callback-Token': token
|
|
666
|
+
},
|
|
667
|
+
body: JSON.stringify(proxyPayload)
|
|
668
|
+
});
|
|
669
|
+
if (!proxyRes.ok) {
|
|
670
|
+
const errBody = await proxyRes.text().catch(() => '');
|
|
671
|
+
return c.json({
|
|
672
|
+
success: false,
|
|
673
|
+
error: `Proxy request failed (${proxyRes.status}): ${errBody || proxyRes.statusText}`
|
|
674
|
+
}, proxyRes.status >= 500 ? 502 : 400);
|
|
675
|
+
}
|
|
676
|
+
const responseData = await proxyRes.json().catch(async () => {
|
|
677
|
+
return await proxyRes.text().catch(() => null);
|
|
678
|
+
});
|
|
679
|
+
return c.json({
|
|
680
|
+
success: true,
|
|
681
|
+
data: responseData,
|
|
682
|
+
message: `${method.toUpperCase()} ${apiPath} via ${appSlug}`
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
catch (error) {
|
|
686
|
+
console.error('Error executing connector request:', error);
|
|
687
|
+
return c.json({ success: false, error: error.message || 'Connector request failed' }, 500);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
async function fetchConnectorAccounts(token) {
|
|
691
|
+
const res = await fetch(`${COCONUT_HOST}/api/connectors/accounts`, {
|
|
692
|
+
headers: { 'X-Callback-Token': token }
|
|
693
|
+
});
|
|
694
|
+
if (!res.ok) {
|
|
695
|
+
const body = await res.text().catch(() => '');
|
|
696
|
+
throw new Error(`Failed to fetch accounts (${res.status}): ${body || res.statusText}`);
|
|
697
|
+
}
|
|
698
|
+
const data = await res.json();
|
|
699
|
+
return Array.isArray(data) ? data : (data.accounts ?? data.data ?? []);
|
|
700
|
+
}
|
|
528
701
|
/**
|
|
529
702
|
* GET /api/v1/mcp/raw-config
|
|
530
703
|
* Returns the raw MCP configuration for editing in settings UI
|
|
@@ -70,6 +70,7 @@ const THUMBNAILS_DIR = path.join(RESOURCES_DIR, 'thumbnails');
|
|
|
70
70
|
// Model ID mapping from frontend values to Replicate model identifiers
|
|
71
71
|
const MODEL_ID_MAP = {
|
|
72
72
|
'nano-banana-pro': 'google/nano-banana-pro',
|
|
73
|
+
'nano-banana-2': 'google/nano-banana-2',
|
|
73
74
|
'flux-2-dev': 'black-forest-labs/flux-2-dev',
|
|
74
75
|
'flux-2-pro': 'black-forest-labs/flux-2-pro',
|
|
75
76
|
'gpt-image-1.5': 'openai/gpt-image-1.5',
|
|
@@ -135,7 +136,7 @@ export async function POST(c) {
|
|
|
135
136
|
}, 400);
|
|
136
137
|
}
|
|
137
138
|
const body = await c.req.json();
|
|
138
|
-
const { prompt, model = 'nano-banana-
|
|
139
|
+
const { prompt, model = 'nano-banana-2', dimensions, resolution, output_format = 'png', output_quality, quality, go_fast, safety_tolerance, background, image_input,
|
|
139
140
|
// Legacy
|
|
140
141
|
inspiration } = body;
|
|
141
142
|
if (!prompt) {
|
|
@@ -215,7 +216,7 @@ export async function POST(c) {
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
// Map model selector value to Replicate model ID
|
|
218
|
-
const replicateModelId = MODEL_ID_MAP[model] || MODEL_ID_MAP['nano-banana-
|
|
219
|
+
const replicateModelId = MODEL_ID_MAP[model] || MODEL_ID_MAP['nano-banana-2'];
|
|
219
220
|
// Build model-specific input payload
|
|
220
221
|
const input = {
|
|
221
222
|
prompt: fullPrompt,
|
|
@@ -233,7 +234,13 @@ export async function POST(c) {
|
|
|
233
234
|
}
|
|
234
235
|
// Model-specific parameters
|
|
235
236
|
if (model === 'nano-banana-pro' || model === 'Nano Banana Pro') {
|
|
236
|
-
|
|
237
|
+
input.resolution = resolution || '2K';
|
|
238
|
+
input.safety_filter_level = 'block_only_high';
|
|
239
|
+
if (imageInputArray.length > 0) {
|
|
240
|
+
input.image_input = imageInputArray;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else if (model === 'nano-banana-2') {
|
|
237
244
|
input.resolution = resolution || '2K';
|
|
238
245
|
input.safety_filter_level = 'block_only_high';
|
|
239
246
|
if (imageInputArray.length > 0) {
|