u
This commit is contained in:
61
src/tools/apisuggestionsorissues.js
Normal file
61
src/tools/apisuggestionsorissues.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { defineTool } from 'libllmorbiter';
|
||||
import * as db from '../db/company.js';
|
||||
|
||||
/**
|
||||
* Creates the apisuggestionsorissues tool allowing the agent to report
|
||||
* missing API endpoints, bugs, or general issues into the company history table.
|
||||
* These reports are then visible to triage agents or administrators.
|
||||
*
|
||||
* @param {{ googleAuthId: number, companyId?: number }} ctx
|
||||
*/
|
||||
export function createApiSuggestionsOrIssuesTool({ googleAuthId, companyId }) {
|
||||
return defineTool({
|
||||
name: 'apisuggestionsorissues',
|
||||
description:
|
||||
'Report a missing API endpoint, feature request, bug, or general issue. ' +
|
||||
'The report is recorded in the company history table for review by the triage agent. ' +
|
||||
'Provide a clear description of the missing functionality or issue.',
|
||||
strict: false,
|
||||
parameters: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['text'],
|
||||
properties: {
|
||||
text: {
|
||||
type: 'string',
|
||||
description: 'Detailed description of the missing API, bug, or issue.',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: ['missing_api', 'bug', 'suggestion', 'issue', 'other'],
|
||||
description: 'Category/type of the report.',
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
description: 'Optional short summary or title.',
|
||||
},
|
||||
},
|
||||
},
|
||||
invoke: async ({ text, type, title }) => {
|
||||
const trimmedText = typeof text === 'string' ? text.trim() : '';
|
||||
if (!trimmedText) {
|
||||
throw new Error('text is required');
|
||||
}
|
||||
|
||||
const prefixParts = [];
|
||||
if (type) prefixParts.push(`[${type.toUpperCase()}]`);
|
||||
if (title) prefixParts.push(title.trim());
|
||||
|
||||
const formatted = prefixParts.length > 0
|
||||
? `${prefixParts.join(' ')}\n${trimmedText}`
|
||||
: trimmedText;
|
||||
|
||||
const entry = await db.addCompanyHistory(googleAuthId, { text: formatted });
|
||||
return {
|
||||
success: true,
|
||||
message: 'Recorded in company history for triage agent review',
|
||||
entry,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user