@lovelybunch/api 1.0.72 → 1.0.74
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/routes/api/v1/ai/route.js +79 -18
- package/dist/routes/api/v1/ai/tools.js +76 -16
- package/dist/routes/api/v1/mcp/index.js +129 -573
- package/dist/routes/api/v1/proposals/[id]/route.d.ts +12 -0
- package/dist/routes/api/v1/proposals/route.d.ts +12 -0
- package/package.json +6 -5
- package/static/assets/ActivityPage-AWTVFLmK.js +1 -0
- package/static/assets/{AgentDetailPage-Dww8h17d.js → AgentDetailPage-DtGFrHzZ.js} +1 -1
- package/static/assets/{AgentEditPage-K6I9kvCf.js → AgentEditPage-1026aJox.js} +1 -1
- package/static/assets/{AgentsPage-nnMzCmw9.js → AgentsPage-9Hre8AD1.js} +2 -2
- package/static/assets/{AgentsSettingsPage-Dnkw87_8.js → AgentsSettingsPage-CILCHaO9.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-DY0vNNSR.js → ApiKeysSettingsPage-D-l8q30N.js} +1 -1
- package/static/assets/{ArchitectureEditPage-wx1LBCGC.js → ArchitectureEditPage-DiRR28Rx.js} +1 -1
- package/static/assets/{ArchitecturePage-C4bkskmN.js → ArchitecturePage-FcRJGw8O.js} +1 -1
- package/static/assets/{AuthSettingsPage-AXU_vx8p.js → AuthSettingsPage-D528tGhc.js} +1 -1
- package/static/assets/{CallbackPage-B6CJkdJu.js → CallbackPage-BMZOjCy_.js} +1 -1
- package/static/assets/CodePage-CCNmmkv_.js +2 -0
- package/static/assets/{CollapsibleSection-DgGytfeZ.js → CollapsibleSection-CG5gAVWB.js} +1 -1
- package/static/assets/DashboardPage-D5C34QbO.js +41 -0
- package/static/assets/{GitPage-vBLrGiwG.js → GitPage-ofZrdSSl.js} +1 -1
- package/static/assets/{GitSettingsPage-D22W0fXd.js → GitSettingsPage-Cld_sN5t.js} +1 -1
- package/static/assets/{IdentityPage-B8xDJx3W.js → IdentityPage-Dj-Do8q7.js} +1 -1
- package/static/assets/{ImplementationStepsEditor-BY7wwwdO.js → ImplementationStepsEditor-BZQKPJ1C.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-CSr-dlmL.js → IntegrationsSettingsPage-DTT6nX3v.js} +1 -1
- package/static/assets/JobDetailPage-CWexORzH.js +1 -0
- package/static/assets/{KnowledgeDetailPage-8q-MYEOA.js → KnowledgeDetailPage-C-a0njhy.js} +1 -1
- package/static/assets/{KnowledgeEditPage-Di63BhFz.js → KnowledgeEditPage-B93ffsgz.js} +1 -1
- package/static/assets/{KnowledgePage-BuEcOdou.js → KnowledgePage-DS7xi1qJ.js} +1 -1
- package/static/assets/{LoginPage-CBRJBmlC.js → LoginPage-FUflG9B8.js} +1 -1
- package/static/assets/{McpSettingsPage-gariusH3.js → McpSettingsPage-A6uws8gQ.js} +1 -1
- package/static/assets/{NewAgentPage-DDkFaqIq.js → NewAgentPage-CqBlVqdy.js} +1 -1
- package/static/assets/{NewKnowledgePage-BqMSsS53.js → NewKnowledgePage-ue0ZRgKf.js} +1 -1
- package/static/assets/{NewProposalPage-C77pO28o.js → NewProposalPage-BDbStKts.js} +1 -1
- package/static/assets/{ProjectEditPage-Dp5M7aXW.js → ProjectEditPage-_a9hJTgi.js} +1 -1
- package/static/assets/{ProjectPage-BBL0XITa.js → ProjectPage-DAlEu9Af.js} +1 -1
- package/static/assets/{PromptsSettingsPage-DOcni_gq.js → PromptsSettingsPage-4_C5zvq6.js} +1 -1
- package/static/assets/{ProposalDetailPage-5b6lLZRq.js → ProposalDetailPage-mZ9qj0wJ.js} +1 -1
- package/static/assets/{ProposalEditPage-lm9wiiHa.js → ProposalEditPage-DqJ3Po23.js} +1 -1
- package/static/assets/{ProposalsPage-Dcms-16A.js → ProposalsPage-DaR_KuZx.js} +1 -1
- package/static/assets/{ResourcesPage-BGugJIYF.js → ResourcesPage-WMPlFn0S.js} +1 -1
- package/static/assets/{RoleEditPage-DI1lGRK2.js → RoleEditPage-DIoamJfW.js} +1 -1
- package/static/assets/{RolePage-B1kmmDDF.js → RolePage-4aL0vR7F.js} +1 -1
- package/static/assets/{RulesSettingsPage-Br_c4fhl.js → RulesSettingsPage-CerRq_kE.js} +1 -1
- package/static/assets/SchedulePage-DF9TqOA6.js +4 -0
- package/static/assets/{SourceInput-BuPLoJuZ.js → SourceInput-CXv23vkE.js} +1 -1
- package/static/assets/{TagInput-CkZQYmnO.js → TagInput-DL_48L0p.js} +1 -1
- package/static/assets/{TerminalPage-CYqTT1pK.js → TerminalPage-BL8pa_9k.js} +1 -1
- package/static/assets/{TerminalSessionPage-a9QWo08R.js → TerminalSessionPage-DcC_o_sA.js} +1 -1
- package/static/assets/{UserPreferencesPage-IVxOVtNk.js → UserPreferencesPage-DoMyvwD4.js} +1 -1
- package/static/assets/{UserSettingsPage-Dsop4_yN.js → UserSettingsPage-CqibuEiq.js} +1 -1
- package/static/assets/{UtilitiesPage-CZCmnyTp.js → UtilitiesPage-6BGeolw9.js} +1 -1
- package/static/assets/{alert-nipAjehb.js → alert-DQ9shGSz.js} +1 -1
- package/static/assets/{arrow-down-DQTEjf4E.js → arrow-down-D5oSUxtq.js} +1 -1
- package/static/assets/{arrow-left-BgRi6mQL.js → arrow-left-BJ9vzpff.js} +1 -1
- package/static/assets/{arrow-up-jLj_KhSo.js → arrow-up-DWNinaN_.js} +1 -1
- package/static/assets/{badge-CqnJU-OF.js → badge-BLbqPEov.js} +1 -1
- package/static/assets/{browser-modal-DBBFKngy.js → browser-modal-Dh2dy_2x.js} +1 -1
- package/static/assets/{calendar-CA_W4UKa.js → calendar-CaBty4QE.js} +1 -1
- package/static/assets/{card-DdTVdbjN.js → card-BTg0Fecj.js} +1 -1
- package/static/assets/{chevron-left-CM04t09S.js → chevron-left-V0REBjky.js} +1 -1
- package/static/assets/{chevrons-up-DgSgy4LT.js → chevrons-up-BvR9KFeO.js} +1 -1
- package/static/assets/{circle-alert-UErAnUQ-.js → circle-alert-DR1DiLh5.js} +1 -1
- package/static/assets/{circle-check-2oo3aeGx.js → circle-check-DED-Ne-m.js} +1 -1
- package/static/assets/{circle-check-big-CQsXU9Fx.js → circle-check-big-CFsUUo2_.js} +1 -1
- package/static/assets/{circle-play-BHGmBl9H.js → circle-play-DQ32zg60.js} +1 -1
- package/static/assets/{circle-x-DoAXluPx.js → circle-x-CDTWutj4.js} +1 -1
- package/static/assets/{clipboard-NaRSfq4S.js → clipboard-CTFAlaYo.js} +1 -1
- package/static/assets/{clock-C1lOY_Qr.js → clock-pVWUoJDo.js} +1 -1
- package/static/assets/{download-Co1Xt7Td.js → download-Bt7lWWYL.js} +1 -1
- package/static/assets/{eye-54QpT_B-.js → eye-o7gPa7E6.js} +1 -1
- package/static/assets/{folder-git-2-x65JY04J.js → folder-git-2-CHwnYB8a.js} +1 -1
- package/static/assets/{index-VBSAUXJg.js → index-DaqYJNAM.js} +30 -30
- package/static/assets/{label-C6P6J-NS.js → label-BtnLfquf.js} +1 -1
- package/static/assets/{markdown-editor-CgzPMMiE.js → markdown-editor-Cmsc5nNu.js} +1 -1
- package/static/assets/{pause-CU8WFOyJ.js → pause-EIDnvByV.js} +1 -1
- package/static/assets/{play-nlXIUG-M.js → play-D_fLXyLR.js} +1 -1
- package/static/assets/{plus-nBUooJPr.js → plus-ZCd709aN.js} +1 -1
- package/static/assets/{radio-group-CQVEYWSk.js → radio-group-STvlCDl-.js} +1 -1
- package/static/assets/{refresh-cw-ChsHXM-C.js → refresh-cw-BF0hXtxu.js} +1 -1
- package/static/assets/{search-ygMlQfjH.js → search-kmqzieAc.js} +1 -1
- package/static/assets/{switch-BcjQDy93.js → switch-CjDKvzd0.js} +1 -1
- package/static/assets/{tabs-B2pmN66L.js → tabs-DPohYGac.js} +1 -1
- package/static/assets/{tag-BEI3zSmE.js → tag-Dg9notds.js} +1 -1
- package/static/assets/{terminal-preview-_bKoIC7R.js → terminal-preview-CnytxbzD.js} +1 -1
- package/static/assets/{use-terminal-DKszJuOd.js → use-terminal-LpFJK0k7.js} +1 -1
- package/static/assets/{zap-w4hozPoR.js → zap-DBKgrFQ_.js} +1 -1
- package/static/index.html +1 -1
- package/static/assets/ActivityPage-qJKqmwv7.js +0 -1
- package/static/assets/CodePage-DGxzOKzh.js +0 -2
- package/static/assets/DashboardPage-3PlgC6UV.js +0 -41
- package/static/assets/JobDetailPage-BUHRLYvQ.js +0 -1
- package/static/assets/SchedulePage-DMBddFXL.js +0 -4
|
@@ -3,8 +3,9 @@ import { join, resolve as pathResolve, basename } from 'path';
|
|
|
3
3
|
import { existsSync, readFileSync, promises as fs, createReadStream } from 'fs';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import readline from 'readline';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { ZodError } from 'zod';
|
|
7
|
+
import { getLogsDir, listProposals, getProposal, createProposal, updateProposal, deleteProposal, } from '@lovelybunch/core';
|
|
8
|
+
import { proposalsFullTool, knowledgeTool, normalizeKnowledgeMetadata, eventsTool, projectContextTool, architectureContextTool, roleContextTool } from '@lovelybunch/mcp';
|
|
8
9
|
import matter from 'gray-matter';
|
|
9
10
|
import Fuse from 'fuse.js';
|
|
10
11
|
import { FileStorageAdapter } from '../../../../lib/storage/file-storage.js';
|
|
@@ -53,11 +54,11 @@ export async function POST(c) {
|
|
|
53
54
|
? `${baseSystem}\n\nThe following persona is authoritative and overrides general guidance above. You must strictly follow it.\n\n${agentPersona}`
|
|
54
55
|
: baseSystem;
|
|
55
56
|
// Prepare tools for function calling
|
|
56
|
-
// Note: proposals
|
|
57
|
+
// Note: proposals/knowledge/project/architecture are read+write, events is read-only
|
|
57
58
|
const tools = enableTools ? [
|
|
58
59
|
{
|
|
59
60
|
type: "function",
|
|
60
|
-
function:
|
|
61
|
+
function: proposalsFullTool
|
|
61
62
|
},
|
|
62
63
|
{
|
|
63
64
|
type: "function",
|
|
@@ -239,17 +240,26 @@ async function executeToolCalls(toolCalls) {
|
|
|
239
240
|
let functionArgs;
|
|
240
241
|
if (toolCall.function?.arguments) {
|
|
241
242
|
try {
|
|
242
|
-
|
|
243
|
+
// Try to sanitize common JSON issues before parsing
|
|
244
|
+
let argsStr = toolCall.function.arguments;
|
|
245
|
+
// Remove trailing commas before ] or }
|
|
246
|
+
argsStr = argsStr.replace(/,(\s*[}\]])/g, '$1');
|
|
247
|
+
// Fix common LLM JSON issues:
|
|
248
|
+
// Remove control characters (except \n, \r, \t which are valid in JSON strings)
|
|
249
|
+
argsStr = argsStr.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, '');
|
|
250
|
+
functionArgs = JSON.parse(argsStr);
|
|
243
251
|
}
|
|
244
252
|
catch (parseError) {
|
|
245
253
|
// LLM may generate invalid JSON with unescaped characters in long content
|
|
246
|
-
// Return a helpful error message
|
|
247
254
|
const errorMsg = parseError instanceof Error ? parseError.message : 'Unknown parse error';
|
|
255
|
+
const hint = errorMsg.includes('position')
|
|
256
|
+
? 'The content may contain unescaped quotes or special characters. Try updating with shorter/simpler content, or update one field at a time.'
|
|
257
|
+
: 'Please retry with simpler content.';
|
|
248
258
|
return {
|
|
249
259
|
tool_call_id: toolCall.id,
|
|
250
260
|
content: JSON.stringify({
|
|
251
261
|
success: false,
|
|
252
|
-
error: `Invalid tool arguments: ${errorMsg}.
|
|
262
|
+
error: `Invalid tool arguments: ${errorMsg}. ${hint}`
|
|
253
263
|
})
|
|
254
264
|
};
|
|
255
265
|
}
|
|
@@ -299,38 +309,89 @@ async function executeToolCalls(toolCalls) {
|
|
|
299
309
|
});
|
|
300
310
|
return Promise.all(resultPromises);
|
|
301
311
|
}
|
|
302
|
-
// Proposals tool
|
|
303
|
-
async function executeProposalsToolDirect(args,
|
|
304
|
-
const { operation, id, filters } = args;
|
|
312
|
+
// Proposals tool - full CRUD operations using @lovelybunch/core
|
|
313
|
+
async function executeProposalsToolDirect(args, _storage) {
|
|
314
|
+
const { operation, id, filters, proposal, updates } = args;
|
|
305
315
|
try {
|
|
306
316
|
switch (operation) {
|
|
307
317
|
case 'list': {
|
|
308
|
-
const proposals = await
|
|
318
|
+
const proposals = await listProposals(filters || {});
|
|
309
319
|
return {
|
|
310
320
|
success: true,
|
|
311
321
|
data: proposals,
|
|
312
|
-
|
|
322
|
+
count: proposals.length,
|
|
323
|
+
message: `Found ${proposals.length} tasks`
|
|
313
324
|
};
|
|
314
325
|
}
|
|
315
326
|
case 'get': {
|
|
316
327
|
if (!id) {
|
|
317
|
-
return { success: false, error: '
|
|
328
|
+
return { success: false, error: 'Task ID is required for get operation' };
|
|
318
329
|
}
|
|
319
|
-
const
|
|
330
|
+
const result = await getProposal(id);
|
|
331
|
+
if (!result) {
|
|
332
|
+
return { success: false, error: 'Task not found' };
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
success: true,
|
|
336
|
+
data: result,
|
|
337
|
+
message: `Retrieved task ${id}`
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
case 'create': {
|
|
320
341
|
if (!proposal) {
|
|
321
|
-
return { success: false, error: '
|
|
342
|
+
return { success: false, error: 'Task data is required for create operation' };
|
|
322
343
|
}
|
|
344
|
+
const created = await createProposal(proposal);
|
|
323
345
|
return {
|
|
324
346
|
success: true,
|
|
325
|
-
data:
|
|
326
|
-
message: `
|
|
347
|
+
data: created,
|
|
348
|
+
message: `Created task ${created.id}`
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
case 'update': {
|
|
352
|
+
if (!id) {
|
|
353
|
+
return { success: false, error: 'Task ID is required for update operation' };
|
|
354
|
+
}
|
|
355
|
+
const updateData = updates || proposal;
|
|
356
|
+
if (!updateData) {
|
|
357
|
+
return { success: false, error: 'Update data is required for update operation' };
|
|
358
|
+
}
|
|
359
|
+
const updated = await updateProposal(id, updateData);
|
|
360
|
+
return {
|
|
361
|
+
success: true,
|
|
362
|
+
data: updated,
|
|
363
|
+
message: `Updated task ${id}`
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
case 'delete': {
|
|
367
|
+
if (!id) {
|
|
368
|
+
return { success: false, error: 'Task ID is required for delete operation' };
|
|
369
|
+
}
|
|
370
|
+
const deleted = await deleteProposal(id);
|
|
371
|
+
if (!deleted) {
|
|
372
|
+
return { success: false, error: 'Task not found' };
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
375
|
+
success: true,
|
|
376
|
+
message: `Deleted task ${id}`
|
|
327
377
|
};
|
|
328
378
|
}
|
|
329
379
|
default:
|
|
330
|
-
return { success: false, error: `
|
|
380
|
+
return { success: false, error: `Unknown operation: ${operation}. Supported operations: list, get, create, update, delete` };
|
|
331
381
|
}
|
|
332
382
|
}
|
|
333
383
|
catch (error) {
|
|
384
|
+
// Handle Zod validation errors specially
|
|
385
|
+
if (error instanceof ZodError) {
|
|
386
|
+
return {
|
|
387
|
+
success: false,
|
|
388
|
+
error: 'Validation failed',
|
|
389
|
+
details: error.issues.map(e => ({
|
|
390
|
+
path: e.path.join('.'),
|
|
391
|
+
message: e.message
|
|
392
|
+
}))
|
|
393
|
+
};
|
|
394
|
+
}
|
|
334
395
|
console.error('Error executing proposals tool:', error);
|
|
335
396
|
return { success: false, error: error.message || 'Tool execution failed' };
|
|
336
397
|
}
|
|
@@ -3,8 +3,9 @@ import { homedir } from 'os';
|
|
|
3
3
|
import { join, resolve as pathResolve, basename } from 'path';
|
|
4
4
|
import { existsSync, readFileSync, promises as fs, createReadStream } from 'fs';
|
|
5
5
|
import readline from 'readline';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { ZodError } from 'zod';
|
|
7
|
+
import { getLogsDir, listProposals, getProposal, createProposal, updateProposal, deleteProposal, } from '@lovelybunch/core';
|
|
8
|
+
import { proposalsFullTool, knowledgeTool, normalizeKnowledgeMetadata, eventsTool, projectContextTool, architectureContextTool, roleContextTool } from '@lovelybunch/mcp';
|
|
8
9
|
import matter from 'gray-matter';
|
|
9
10
|
import { FileStorageAdapter } from '../../../../lib/storage/file-storage.js';
|
|
10
11
|
// Function to get global config API key as fallback
|
|
@@ -93,11 +94,11 @@ export async function POST(c) {
|
|
|
93
94
|
...toolResultMessages
|
|
94
95
|
];
|
|
95
96
|
// Prepare tools for potential additional tool calls
|
|
96
|
-
// Note: proposals
|
|
97
|
+
// Note: proposals/knowledge/project/architecture are read+write, events is read-only
|
|
97
98
|
const tools = [
|
|
98
99
|
{
|
|
99
100
|
type: "function",
|
|
100
|
-
function:
|
|
101
|
+
function: proposalsFullTool
|
|
101
102
|
},
|
|
102
103
|
{
|
|
103
104
|
type: "function",
|
|
@@ -242,6 +243,9 @@ async function executeToolCalls(toolCalls) {
|
|
|
242
243
|
let argsStr = toolCall.function.arguments;
|
|
243
244
|
// Remove trailing commas before ] or }
|
|
244
245
|
argsStr = argsStr.replace(/,(\s*[}\]])/g, '$1');
|
|
246
|
+
// Fix common LLM JSON issues:
|
|
247
|
+
// 1. Remove control characters (except \n, \r, \t which are valid in JSON strings)
|
|
248
|
+
argsStr = argsStr.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, '');
|
|
245
249
|
// Try parsing the sanitized string
|
|
246
250
|
functionArgs = JSON.parse(argsStr);
|
|
247
251
|
}
|
|
@@ -255,11 +259,16 @@ async function executeToolCalls(toolCalls) {
|
|
|
255
259
|
arguments: toolCall.function?.arguments?.substring(0, 500),
|
|
256
260
|
error: parseError instanceof Error ? parseError.message : 'Unknown parse error'
|
|
257
261
|
});
|
|
262
|
+
// Provide a more helpful error message
|
|
263
|
+
const errorMsg = parseError instanceof Error ? parseError.message : 'JSON parse error';
|
|
264
|
+
const hint = errorMsg.includes('position')
|
|
265
|
+
? 'The content may contain unescaped quotes or special characters. Try updating with shorter/simpler content, or update one field at a time.'
|
|
266
|
+
: 'Please retry with simpler content.';
|
|
258
267
|
return {
|
|
259
268
|
tool_call_id: toolCall.id,
|
|
260
269
|
content: JSON.stringify({
|
|
261
270
|
success: false,
|
|
262
|
-
error: `Invalid tool arguments: ${
|
|
271
|
+
error: `Invalid tool arguments: ${errorMsg}. ${hint}`
|
|
263
272
|
})
|
|
264
273
|
};
|
|
265
274
|
}
|
|
@@ -304,38 +313,89 @@ async function executeToolCalls(toolCalls) {
|
|
|
304
313
|
});
|
|
305
314
|
return Promise.all(resultPromises);
|
|
306
315
|
}
|
|
307
|
-
// Proposals tool
|
|
308
|
-
async function executeProposalsToolDirect(args,
|
|
309
|
-
const { operation, id, filters } = args;
|
|
316
|
+
// Proposals tool - full CRUD operations using @lovelybunch/core
|
|
317
|
+
async function executeProposalsToolDirect(args, _storage) {
|
|
318
|
+
const { operation, id, filters, proposal, updates } = args;
|
|
310
319
|
try {
|
|
311
320
|
switch (operation) {
|
|
312
321
|
case 'list': {
|
|
313
|
-
const proposals = await
|
|
322
|
+
const proposals = await listProposals(filters || {});
|
|
314
323
|
return {
|
|
315
324
|
success: true,
|
|
316
325
|
data: proposals,
|
|
317
|
-
|
|
326
|
+
count: proposals.length,
|
|
327
|
+
message: `Found ${proposals.length} tasks`
|
|
318
328
|
};
|
|
319
329
|
}
|
|
320
330
|
case 'get': {
|
|
321
331
|
if (!id) {
|
|
322
|
-
return { success: false, error: '
|
|
332
|
+
return { success: false, error: 'Task ID is required for get operation' };
|
|
323
333
|
}
|
|
324
|
-
const
|
|
334
|
+
const result = await getProposal(id);
|
|
335
|
+
if (!result) {
|
|
336
|
+
return { success: false, error: 'Task not found' };
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
success: true,
|
|
340
|
+
data: result,
|
|
341
|
+
message: `Retrieved task ${id}`
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
case 'create': {
|
|
325
345
|
if (!proposal) {
|
|
326
|
-
return { success: false, error: '
|
|
346
|
+
return { success: false, error: 'Task data is required for create operation' };
|
|
347
|
+
}
|
|
348
|
+
const created = await createProposal(proposal);
|
|
349
|
+
return {
|
|
350
|
+
success: true,
|
|
351
|
+
data: created,
|
|
352
|
+
message: `Created task ${created.id}`
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
case 'update': {
|
|
356
|
+
if (!id) {
|
|
357
|
+
return { success: false, error: 'Task ID is required for update operation' };
|
|
358
|
+
}
|
|
359
|
+
const updateData = updates || proposal;
|
|
360
|
+
if (!updateData) {
|
|
361
|
+
return { success: false, error: 'Update data is required for update operation' };
|
|
362
|
+
}
|
|
363
|
+
const updated = await updateProposal(id, updateData);
|
|
364
|
+
return {
|
|
365
|
+
success: true,
|
|
366
|
+
data: updated,
|
|
367
|
+
message: `Updated task ${id}`
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
case 'delete': {
|
|
371
|
+
if (!id) {
|
|
372
|
+
return { success: false, error: 'Task ID is required for delete operation' };
|
|
373
|
+
}
|
|
374
|
+
const deleted = await deleteProposal(id);
|
|
375
|
+
if (!deleted) {
|
|
376
|
+
return { success: false, error: 'Task not found' };
|
|
327
377
|
}
|
|
328
378
|
return {
|
|
329
379
|
success: true,
|
|
330
|
-
|
|
331
|
-
message: `Retrieved proposal ${id}`
|
|
380
|
+
message: `Deleted task ${id}`
|
|
332
381
|
};
|
|
333
382
|
}
|
|
334
383
|
default:
|
|
335
|
-
return { success: false, error: `
|
|
384
|
+
return { success: false, error: `Unknown operation: ${operation}. Supported operations: list, get, create, update, delete` };
|
|
336
385
|
}
|
|
337
386
|
}
|
|
338
387
|
catch (error) {
|
|
388
|
+
// Handle Zod validation errors specially
|
|
389
|
+
if (error instanceof ZodError) {
|
|
390
|
+
return {
|
|
391
|
+
success: false,
|
|
392
|
+
error: 'Validation failed',
|
|
393
|
+
details: error.issues.map(e => ({
|
|
394
|
+
path: e.path.join('.'),
|
|
395
|
+
message: e.message
|
|
396
|
+
}))
|
|
397
|
+
};
|
|
398
|
+
}
|
|
339
399
|
console.error('Error executing proposals tool:', error);
|
|
340
400
|
return { success: false, error: error.message || 'Tool execution failed' };
|
|
341
401
|
}
|