|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
CompanyDeleteInput
|
|
|
} from '../schemas/index.js';
|
|
|
import { CHARACTER_LIMIT, ResponseFormat } from '../constants.js';
|
|
|
-import type { Company, PaginatedResponse } from '../types.js';
|
|
|
+import type { Company, PaginatedResponse, Platform } from '../types.js';
|
|
|
|
|
|
/**
|
|
|
* Format company data for markdown output
|
|
|
@@ -185,23 +185,48 @@ export const companyCreateTool = async (args: CompanyCreateInput) => {
|
|
|
const apiClient = getApiClient();
|
|
|
|
|
|
try {
|
|
|
- const response = await apiClient.post<Company>('/api/v1/company/createCompany', args);
|
|
|
-
|
|
|
- const company = response;
|
|
|
+ // API returns { success: boolean }, not the full company object
|
|
|
+ const response = await apiClient.post<{ success: boolean }>('/api/v1/company/createCompany', args);
|
|
|
+
|
|
|
+ if (!response.success) {
|
|
|
+ return {
|
|
|
+ content: [{
|
|
|
+ type: 'text',
|
|
|
+ text: 'Error: Failed to create company - API returned success: false'
|
|
|
+ }]
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
+ // Build response from input args since API doesn't return the created object
|
|
|
+ const now = new Date();
|
|
|
const structuredOutput = {
|
|
|
- id: company.id,
|
|
|
- companyName: company.companyName,
|
|
|
- contactPerson: company.contactPerson,
|
|
|
- contactPhone: company.contactPhone,
|
|
|
- contactEmail: company.contactEmail,
|
|
|
- address: company.address,
|
|
|
- platformId: company.platformId,
|
|
|
- status: company.status,
|
|
|
- createTime: company.createTime
|
|
|
+ id: 0, // Unknown - API doesn't return the ID
|
|
|
+ companyName: args.companyName,
|
|
|
+ contactPerson: args.contactPerson || null,
|
|
|
+ contactPhone: args.contactPhone || null,
|
|
|
+ contactEmail: args.contactEmail || null,
|
|
|
+ address: args.address || null,
|
|
|
+ platformId: args.platformId || null,
|
|
|
+ status: args.status ?? 1,
|
|
|
+ createTime: now
|
|
|
};
|
|
|
|
|
|
- const markdown = `✅ **Company Created Successfully**\n\n${formatCompanyMarkdown(company)}`;
|
|
|
+ // Build markdown from input args - using type assertion to handle missing fields
|
|
|
+ const companyForMarkdown = {
|
|
|
+ id: 0,
|
|
|
+ companyName: args.companyName,
|
|
|
+ contactPerson: args.contactPerson || null,
|
|
|
+ contactPhone: args.contactPhone || null,
|
|
|
+ contactEmail: args.contactEmail || null,
|
|
|
+ address: args.address || null,
|
|
|
+ platformId: args.platformId || null,
|
|
|
+ platform: null as Platform | null,
|
|
|
+ status: args.status ?? 1,
|
|
|
+ createTime: now,
|
|
|
+ updateTime: now as Date
|
|
|
+ } as Company;
|
|
|
+
|
|
|
+ const markdown = `✅ **Company Created Successfully**\n\n${formatCompanyMarkdown(companyForMarkdown)}`;
|
|
|
|
|
|
return {
|
|
|
content: [{ type: 'text', text: markdown }],
|