Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Execute a discovered tool with specific parameters.
| `search_id` | string | ✓ | Search ID from the search that found this tool |
| `params_to_tool` | string | ✓ | JSON string of parameters to pass to the tool |
| `session_id` | string | | Session identifier (auto-generated if omitted) |
| `max_data_size` | number | | Max response size in bytes (default: 20480) |
| `max_response_size` | number | | Max response size in bytes (default: 20480) |

**Example:**

Expand Down Expand Up @@ -153,7 +153,7 @@ If not provided, the SDK automatically generates and maintains a session ID for

### Large Responses

When tool output exceeds `max_data_size`, you'll receive:
When tool output exceeds `max_response_size`, you'll receive:

```json
{
Expand Down
8 changes: 6 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/api/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('QverisClient', () => {
);
});

it('should include max_data_size when provided', async () => {
it('should include max_response_size when provided', async () => {
fetchMock.mockResolvedValueOnce({
ok: true,
json: async () => ({
Expand All @@ -217,7 +217,7 @@ describe('QverisClient', () => {
await client.executeTool('tool-1', {
search_id: 'search-123',
parameters: {},
max_data_size: 102400,
max_response_size: 102400,
});

expect(fetchMock).toHaveBeenCalledWith(
Expand All @@ -226,7 +226,7 @@ describe('QverisClient', () => {
body: JSON.stringify({
search_id: 'search-123',
parameters: {},
max_data_size: 102400,
max_response_size: 102400,
}),
})
);
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,19 @@ async function main(): Promise<void> {
};
}

// Handle other errors
// Handle other errors (including fetch network errors)
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
const errorCause = error instanceof Error && error.cause instanceof Error
? error.cause.message
: undefined;

return {
content: [
{
type: 'text',
text: JSON.stringify({
error: error instanceof Error ? error.message : 'Unknown error occurred',
error: errorMessage,
...(errorCause && { cause: errorCause }),
}),
},
],
Expand Down
18 changes: 9 additions & 9 deletions src/tools/execute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ describe('execute_tool', () => {
expect(executeToolSchema.properties.params_to_tool.type).toBe('string');
});

it('should define max_data_size with default', () => {
expect(executeToolSchema.properties.max_data_size.type).toBe('number');
expect(executeToolSchema.properties.max_data_size.default).toBe(20480);
it('should define max_response_size with default', () => {
expect(executeToolSchema.properties.max_response_size.type).toBe('number');
expect(executeToolSchema.properties.max_response_size.default).toBe(20480);
});

it('should define session_id as optional', () => {
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('execute_tool', () => {
search_id: 'search-123',
session_id: 'default-session',
parameters: { city: 'Tokyo', units: 'metric' },
max_data_size: undefined,
max_response_size: undefined,
});

expect(result).toEqual(mockResponse);
Expand Down Expand Up @@ -109,11 +109,11 @@ describe('execute_tool', () => {
search_id: 'search-123',
session_id: 'custom-session',
parameters: {},
max_data_size: undefined,
max_response_size: undefined,
});
});

it('should pass max_data_size when provided', async () => {
it('should pass max_response_size when provided', async () => {
executeToolMock.mockResolvedValueOnce({
execution_id: 'exec-123',
tool_id: 'tool-1',
Expand All @@ -128,7 +128,7 @@ describe('execute_tool', () => {
tool_id: 'tool-1',
search_id: 'search-123',
params_to_tool: '{}',
max_data_size: 102400,
max_response_size: 102400,
},
'default-session'
);
Expand All @@ -137,7 +137,7 @@ describe('execute_tool', () => {
search_id: 'search-123',
session_id: 'default-session',
parameters: {},
max_data_size: 102400,
max_response_size: 102400,
});
});

Expand Down Expand Up @@ -201,7 +201,7 @@ describe('execute_tool', () => {
search_id: 'search-123',
session_id: 'default-session',
parameters: complexParams,
max_data_size: undefined,
max_response_size: undefined,
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/tools/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ExecuteToolInput {
* @default 20480 (20KB)
* @minimum -1 (-1 means no limit)
*/
max_data_size?: number;
max_response_size?: number;
}

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ export const executeToolSchema = {
'Session identifier for tracking user sessions. ' +
'If not provided, an auto-generated session ID will be used.',
},
max_data_size: {
max_response_size: {
type: 'number',
description:
'Maximum size of response data in bytes. ' +
Expand Down Expand Up @@ -124,7 +124,7 @@ export async function executeExecuteTool(
search_id: input.search_id,
session_id: input.session_id ?? defaultSessionId,
parameters,
max_data_size: input.max_data_size,
max_response_size: input.max_response_size,
});

return response;
Expand Down
10 changes: 5 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export interface SearchResponse {
* search_id: "abc123",
* session_id: "user-session-123",
* parameters: { city: "London", units: "metric" },
* max_data_size: 20480
* max_response_size: 20480
* };
* ```
*/
Expand Down Expand Up @@ -188,19 +188,19 @@ export interface ExecuteRequest {
* @default 20480 (20KB)
* @minimum -1 (-1 means no limit)
*/
max_data_size?: number;
max_response_size?: number;
}

/**
* Result data when the response fits within max_data_size.
* Result data when the response fits within max_response_size.
*/
export interface ExecuteResultData {
/** The actual result data from the tool execution */
data: unknown;
}

/**
* Result data when the response exceeds max_data_size.
* Result data when the response exceeds max_response_size.
* Provides truncated content and a URL to download the full result.
*/
export interface ExecuteResultTruncated {
Expand All @@ -214,7 +214,7 @@ export interface ExecuteResultTruncated {
full_content_file_url: string;

/**
* The initial portion of the response (max_data_size bytes).
* The initial portion of the response (max_response_size bytes).
* Useful for previewing the data structure.
*/
truncated_content: string;
Expand Down