Handle HTTP tool selectors without explicit verb
This commit is contained in:
parent
c3168a848d
commit
ac067aca0a
@ -26,7 +26,15 @@ export function looksLikeHttpUrl(value?: string): boolean {
|
||||
}
|
||||
|
||||
export function splitHttpToolSelector(input: string): { baseUrl: string; tool: string } | null {
|
||||
const normalized = normalizeHttpUrlCandidate(input);
|
||||
const trimmed = input.trim();
|
||||
const candidate = (() => {
|
||||
const openParen = trimmed.indexOf('(');
|
||||
if (openParen === -1) {
|
||||
return trimmed;
|
||||
}
|
||||
return trimmed.slice(0, openParen);
|
||||
})();
|
||||
const normalized = normalizeHttpUrlCandidate(candidate);
|
||||
if (!normalized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -42,6 +42,12 @@ describe('command inference', () => {
|
||||
expect(result).toEqual({ kind: 'command', command: 'call', args: [token, 'limit=1'] });
|
||||
});
|
||||
|
||||
it('routes HTTP tool expressions with arguments directly to call', () => {
|
||||
const token = 'https://api.example.com/mcp.getStatus(component: "foo")';
|
||||
const result = inferCommandRouting(token, [], definitions);
|
||||
expect(result).toEqual({ kind: 'command', command: 'call', args: [token] });
|
||||
});
|
||||
|
||||
it('suggests names when edit distance is large', () => {
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
const result = inferCommandRouting('unknown', [], definitions);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user