@nanogpt/mcp 1.0.0
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/activeRequests.d.ts +26 -0
- package/dist/activeRequests.d.ts.map +1 -0
- package/dist/activeRequests.js +39 -0
- package/dist/activeRequests.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +136 -0
- package/dist/config.js.map +1 -0
- package/dist/httpClient.d.ts +36 -0
- package/dist/httpClient.d.ts.map +1 -0
- package/dist/httpClient.js +211 -0
- package/dist/httpClient.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +168 -0
- package/dist/index.js.map +1 -0
- package/dist/resources.d.ts +68 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +198 -0
- package/dist/resources.js.map +1 -0
- package/dist/toolUtils.d.ts +115 -0
- package/dist/toolUtils.d.ts.map +1 -0
- package/dist/toolUtils.js +369 -0
- package/dist/toolUtils.js.map +1 -0
- package/dist/tools/balance.d.ts +48 -0
- package/dist/tools/balance.d.ts.map +1 -0
- package/dist/tools/balance.js +78 -0
- package/dist/tools/balance.js.map +1 -0
- package/dist/tools/chat.d.ts +89 -0
- package/dist/tools/chat.d.ts.map +1 -0
- package/dist/tools/chat.js +125 -0
- package/dist/tools/chat.js.map +1 -0
- package/dist/tools/imageGenerate.d.ts +116 -0
- package/dist/tools/imageGenerate.d.ts.map +1 -0
- package/dist/tools/imageGenerate.js +220 -0
- package/dist/tools/imageGenerate.js.map +1 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +11 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/listModels.d.ts +149 -0
- package/dist/tools/listModels.d.ts.map +1 -0
- package/dist/tools/listModels.js +224 -0
- package/dist/tools/listModels.js.map +1 -0
- package/dist/tools/scrapeUrls.d.ts +51 -0
- package/dist/tools/scrapeUrls.d.ts.map +1 -0
- package/dist/tools/scrapeUrls.js +100 -0
- package/dist/tools/scrapeUrls.js.map +1 -0
- package/dist/tools/webSearch.d.ts +69 -0
- package/dist/tools/webSearch.d.ts.map +1 -0
- package/dist/tools/webSearch.js +120 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/tools/youtubeTranscribe.d.ts +45 -0
- package/dist/tools/youtubeTranscribe.d.ts.map +1 -0
- package/dist/tools/youtubeTranscribe.js +88 -0
- package/dist/tools/youtubeTranscribe.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nanogpt_chat tool
|
|
3
|
+
*
|
|
4
|
+
* Send a chat completion request to an AI model.
|
|
5
|
+
* Non-streaming only for MCP v1.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
import { requestJson } from '../httpClient.js';
|
|
10
|
+
import { getConfig } from '../config.js';
|
|
11
|
+
import { handleToolError, processRawResponse, buildContent, zodToJsonSchema } from '../toolUtils.js';
|
|
12
|
+
// Message schema
|
|
13
|
+
const messageSchema = z.object({
|
|
14
|
+
role: z.enum(['system', 'user', 'assistant']),
|
|
15
|
+
content: z.string(),
|
|
16
|
+
});
|
|
17
|
+
// Input schema
|
|
18
|
+
export const inputSchema = z.object({
|
|
19
|
+
messages: z.array(messageSchema).min(1),
|
|
20
|
+
model: z.string().optional(),
|
|
21
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
22
|
+
max_tokens: z.number().min(1).optional(),
|
|
23
|
+
include_usage: z.boolean().optional(),
|
|
24
|
+
reasoning: z
|
|
25
|
+
.object({
|
|
26
|
+
exclude: z.boolean().optional(),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
29
|
+
include_raw: z.boolean().optional().default(false),
|
|
30
|
+
});
|
|
31
|
+
// Output schema
|
|
32
|
+
export const outputSchema = z.object({
|
|
33
|
+
content: z.string(),
|
|
34
|
+
message: z.record(z.unknown()),
|
|
35
|
+
usage: z.record(z.unknown()).optional(),
|
|
36
|
+
raw: z.union([z.record(z.unknown()), z.string()]).optional(),
|
|
37
|
+
});
|
|
38
|
+
// JSON Schemas for MCP registration
|
|
39
|
+
export const inputJsonSchema = zodToJsonSchema(inputSchema);
|
|
40
|
+
export const outputJsonSchema = zodToJsonSchema(outputSchema);
|
|
41
|
+
// Tool metadata
|
|
42
|
+
export const name = 'nanogpt_chat';
|
|
43
|
+
export const description = "Send a chat completion request to an AI model. Returns the assistant's response. Non-streaming.";
|
|
44
|
+
// Annotations
|
|
45
|
+
export const annotations = {
|
|
46
|
+
readOnlyHint: false,
|
|
47
|
+
openWorldHint: true,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Handler for nanogpt_chat
|
|
51
|
+
*/
|
|
52
|
+
export async function handler(args) {
|
|
53
|
+
try {
|
|
54
|
+
// Validate input
|
|
55
|
+
const input = inputSchema.parse(args);
|
|
56
|
+
const config = getConfig();
|
|
57
|
+
// Determine model
|
|
58
|
+
const model = input.model || config.defaultModel;
|
|
59
|
+
if (!model) {
|
|
60
|
+
throw new McpError(ErrorCode.InvalidRequest, 'No model specified. Either provide a "model" parameter or set NANOGPT_DEFAULT_MODEL environment variable.');
|
|
61
|
+
}
|
|
62
|
+
// Build request body
|
|
63
|
+
const requestBody = {
|
|
64
|
+
model,
|
|
65
|
+
messages: input.messages,
|
|
66
|
+
stream: false, // Force non-streaming for MCP v1
|
|
67
|
+
};
|
|
68
|
+
if (input.temperature !== undefined) {
|
|
69
|
+
requestBody.temperature = input.temperature;
|
|
70
|
+
}
|
|
71
|
+
if (input.max_tokens !== undefined) {
|
|
72
|
+
requestBody.max_tokens = input.max_tokens;
|
|
73
|
+
}
|
|
74
|
+
if (input.reasoning !== undefined) {
|
|
75
|
+
requestBody.reasoning = input.reasoning;
|
|
76
|
+
}
|
|
77
|
+
// Call NanoGPT API
|
|
78
|
+
const response = await requestJson({
|
|
79
|
+
method: 'POST',
|
|
80
|
+
path: '/v1/chat/completions',
|
|
81
|
+
body: requestBody,
|
|
82
|
+
});
|
|
83
|
+
const data = response.json;
|
|
84
|
+
// Extract assistant message
|
|
85
|
+
const choice = data.choices?.[0];
|
|
86
|
+
if (!choice) {
|
|
87
|
+
throw new McpError(ErrorCode.InternalError, 'No response from model');
|
|
88
|
+
}
|
|
89
|
+
const assistantMessage = choice.message;
|
|
90
|
+
const contentText = assistantMessage.content ?? '';
|
|
91
|
+
// Build output
|
|
92
|
+
const output = {
|
|
93
|
+
content: contentText,
|
|
94
|
+
message: assistantMessage,
|
|
95
|
+
};
|
|
96
|
+
// Include usage if requested or available
|
|
97
|
+
if (input.include_usage && data.usage) {
|
|
98
|
+
output.usage = data.usage;
|
|
99
|
+
}
|
|
100
|
+
// Process raw response
|
|
101
|
+
const { raw, resourceLink } = processRawResponse({ status: response.status, headers: response.headers, body: data }, input.include_raw);
|
|
102
|
+
if (raw !== undefined) {
|
|
103
|
+
output.raw = raw;
|
|
104
|
+
}
|
|
105
|
+
// Build content - handle tool calls or other non-text content
|
|
106
|
+
let displayText;
|
|
107
|
+
if (contentText) {
|
|
108
|
+
displayText = contentText;
|
|
109
|
+
}
|
|
110
|
+
else if (assistantMessage.tool_calls) {
|
|
111
|
+
displayText = `Assistant requested tool calls: ${JSON.stringify(assistantMessage.tool_calls)}`;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
displayText = JSON.stringify(assistantMessage);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
content: buildContent(displayText, resourceLink),
|
|
118
|
+
structuredContent: output,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
return handleToolError(err);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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AC;QAEF,0CAA0C;QAC1C,IAAI,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACtC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,CAAC;QAED,uBAAuB;QACvB,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAC9C,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAClE,KAAK,CAAC,WAAW,CAClB,CAAC;QACF,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;QACnB,CAAC;QAED,8DAA8D;QAC9D,IAAI,WAAmB,CAAC;QACxB,IAAI,WAAW,EAAE,CAAC;YAChB,WAAW,GAAG,WAAW,CAAC;QAC5B,CAAC;aAAM,IAAI,gBAAgB,CAAC,UAAU,EAAE,CAAC;YACvC,WAAW,GAAG,mCAAmC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;QACjG,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACjD,CAAC;QAED,OAAO;YACL,OAAO,EAAE,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC;YAChD,iBAAiB,EAAE,MAAM;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nanogpt_image_generate tool
|
|
3
|
+
*
|
|
4
|
+
* Generate images from a text prompt using AI image models.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const inputSchema: z.ZodObject<{
|
|
8
|
+
prompt: z.ZodString;
|
|
9
|
+
model: z.ZodOptional<z.ZodString>;
|
|
10
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
size: z.ZodOptional<z.ZodString>;
|
|
12
|
+
resolution: z.ZodOptional<z.ZodString>;
|
|
13
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
16
|
+
quality: z.ZodOptional<z.ZodString>;
|
|
17
|
+
response_format: z.ZodOptional<z.ZodEnum<["url", "b64_json"]>>;
|
|
18
|
+
imageDataUrl: z.ZodOptional<z.ZodString>;
|
|
19
|
+
imageDataUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
include_raw: boolean;
|
|
23
|
+
prompt: string;
|
|
24
|
+
model?: string | undefined;
|
|
25
|
+
n?: number | undefined;
|
|
26
|
+
size?: string | undefined;
|
|
27
|
+
resolution?: string | undefined;
|
|
28
|
+
width?: number | undefined;
|
|
29
|
+
height?: number | undefined;
|
|
30
|
+
aspect_ratio?: string | undefined;
|
|
31
|
+
quality?: string | undefined;
|
|
32
|
+
response_format?: "url" | "b64_json" | undefined;
|
|
33
|
+
imageDataUrl?: string | undefined;
|
|
34
|
+
imageDataUrls?: string[] | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
prompt: string;
|
|
37
|
+
include_raw?: boolean | undefined;
|
|
38
|
+
model?: string | undefined;
|
|
39
|
+
n?: number | undefined;
|
|
40
|
+
size?: string | undefined;
|
|
41
|
+
resolution?: string | undefined;
|
|
42
|
+
width?: number | undefined;
|
|
43
|
+
height?: number | undefined;
|
|
44
|
+
aspect_ratio?: string | undefined;
|
|
45
|
+
quality?: string | undefined;
|
|
46
|
+
response_format?: "url" | "b64_json" | undefined;
|
|
47
|
+
imageDataUrl?: string | undefined;
|
|
48
|
+
imageDataUrls?: string[] | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
export declare const outputSchema: z.ZodObject<{
|
|
51
|
+
images: z.ZodArray<z.ZodObject<{
|
|
52
|
+
kind: z.ZodEnum<["resource", "url", "error"]>;
|
|
53
|
+
uri: z.ZodOptional<z.ZodString>;
|
|
54
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
55
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
url: z.ZodOptional<z.ZodString>;
|
|
57
|
+
error: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
kind: "error" | "url" | "resource";
|
|
60
|
+
error?: string | undefined;
|
|
61
|
+
bytes?: number | undefined;
|
|
62
|
+
mimeType?: string | undefined;
|
|
63
|
+
uri?: string | undefined;
|
|
64
|
+
url?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
kind: "error" | "url" | "resource";
|
|
67
|
+
error?: string | undefined;
|
|
68
|
+
bytes?: number | undefined;
|
|
69
|
+
mimeType?: string | undefined;
|
|
70
|
+
uri?: string | undefined;
|
|
71
|
+
url?: string | undefined;
|
|
72
|
+
}>, "many">;
|
|
73
|
+
raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
images: {
|
|
76
|
+
kind: "error" | "url" | "resource";
|
|
77
|
+
error?: string | undefined;
|
|
78
|
+
bytes?: number | undefined;
|
|
79
|
+
mimeType?: string | undefined;
|
|
80
|
+
uri?: string | undefined;
|
|
81
|
+
url?: string | undefined;
|
|
82
|
+
}[];
|
|
83
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
images: {
|
|
86
|
+
kind: "error" | "url" | "resource";
|
|
87
|
+
error?: string | undefined;
|
|
88
|
+
bytes?: number | undefined;
|
|
89
|
+
mimeType?: string | undefined;
|
|
90
|
+
uri?: string | undefined;
|
|
91
|
+
url?: string | undefined;
|
|
92
|
+
}[];
|
|
93
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
export declare const inputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
96
|
+
export declare const outputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
97
|
+
export declare const name = "nanogpt_image_generate";
|
|
98
|
+
export declare const description = "Generate images from a text prompt using AI image models like DALL-E, Flux, or Midjourney.";
|
|
99
|
+
export declare const annotations: {
|
|
100
|
+
readOnlyHint: boolean;
|
|
101
|
+
openWorldHint: boolean;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Handler for nanogpt_image_generate
|
|
105
|
+
*/
|
|
106
|
+
export declare function handler(args: unknown): Promise<{
|
|
107
|
+
content: {
|
|
108
|
+
type: string;
|
|
109
|
+
text?: string;
|
|
110
|
+
uri?: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
mimeType?: string;
|
|
113
|
+
}[];
|
|
114
|
+
structuredContent: Record<string, unknown>;
|
|
115
|
+
}>;
|
|
116
|
+
//# sourceMappingURL=imageGenerate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageGenerate.d.ts","sourceRoot":"","sources":["../../src/tools/imageGenerate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EActB,CAAC;AAGH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYvB,CAAC;AAGH,eAAO,MAAM,eAAe,sCAA+B,CAAC;AAC5D,eAAO,MAAM,gBAAgB,sCAAgC,CAAC;AAG9D,eAAO,MAAM,IAAI,2BAA2B,CAAC;AAC7C,eAAO,MAAM,WAAW,+FACsE,CAAC;AAG/F,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AA+CF;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,OAAO;;cA4HV,MAAM;eAAS,MAAM;cAAQ,MAAM;eAAS,MAAM;mBAAa,MAAM;;;GAcrG"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nanogpt_image_generate tool
|
|
3
|
+
*
|
|
4
|
+
* Generate images from a text prompt using AI image models.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { requestJson } from '../httpClient.js';
|
|
8
|
+
import { handleToolError, processRawResponse, zodToJsonSchema, } from '../toolUtils.js';
|
|
9
|
+
import { putBase64Image } from '../resources.js';
|
|
10
|
+
// Input schema
|
|
11
|
+
export const inputSchema = z.object({
|
|
12
|
+
prompt: z.string().min(1),
|
|
13
|
+
model: z.string().optional(),
|
|
14
|
+
n: z.number().min(1).max(10).optional(),
|
|
15
|
+
size: z.string().optional(),
|
|
16
|
+
resolution: z.string().optional(),
|
|
17
|
+
width: z.number().min(1).optional(),
|
|
18
|
+
height: z.number().min(1).optional(),
|
|
19
|
+
aspect_ratio: z.string().optional(),
|
|
20
|
+
quality: z.string().optional(),
|
|
21
|
+
response_format: z.enum(['url', 'b64_json']).optional(),
|
|
22
|
+
imageDataUrl: z.string().optional(),
|
|
23
|
+
imageDataUrls: z.array(z.string()).optional(),
|
|
24
|
+
include_raw: z.boolean().optional().default(false),
|
|
25
|
+
});
|
|
26
|
+
// Output schema
|
|
27
|
+
export const outputSchema = z.object({
|
|
28
|
+
images: z.array(z.object({
|
|
29
|
+
kind: z.enum(['resource', 'url', 'error']),
|
|
30
|
+
uri: z.string().optional(),
|
|
31
|
+
mimeType: z.string().optional(),
|
|
32
|
+
bytes: z.number().optional(),
|
|
33
|
+
url: z.string().optional(),
|
|
34
|
+
error: z.string().optional(),
|
|
35
|
+
})),
|
|
36
|
+
raw: z.union([z.record(z.unknown()), z.string()]).optional(),
|
|
37
|
+
});
|
|
38
|
+
// JSON Schemas for MCP registration
|
|
39
|
+
export const inputJsonSchema = zodToJsonSchema(inputSchema);
|
|
40
|
+
export const outputJsonSchema = zodToJsonSchema(outputSchema);
|
|
41
|
+
// Tool metadata
|
|
42
|
+
export const name = 'nanogpt_image_generate';
|
|
43
|
+
export const description = 'Generate images from a text prompt using AI image models like DALL-E, Flux, or Midjourney.';
|
|
44
|
+
// Annotations
|
|
45
|
+
export const annotations = {
|
|
46
|
+
readOnlyHint: false,
|
|
47
|
+
openWorldHint: true,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Detect MIME type from base64 data.
|
|
51
|
+
* Handles data URLs (data:image/png;base64,...) and raw base64 with magic bytes.
|
|
52
|
+
*/
|
|
53
|
+
function detectMimeType(base64Data) {
|
|
54
|
+
// Check for data URL prefix
|
|
55
|
+
const dataUrlMatch = base64Data.match(/^data:([^;]+);base64,/);
|
|
56
|
+
if (dataUrlMatch) {
|
|
57
|
+
return dataUrlMatch[1];
|
|
58
|
+
}
|
|
59
|
+
// Try to detect from magic bytes in raw base64
|
|
60
|
+
// First few bytes of common image formats when base64 encoded:
|
|
61
|
+
// PNG: iVBOR (first 5 chars of base64)
|
|
62
|
+
// JPEG: /9j/ (first 4 chars of base64)
|
|
63
|
+
// GIF: R0lG (first 4 chars of base64)
|
|
64
|
+
// WebP: UklG (first 4 chars of base64, RIFF header)
|
|
65
|
+
if (base64Data.startsWith('iVBOR')) {
|
|
66
|
+
return 'image/png';
|
|
67
|
+
}
|
|
68
|
+
if (base64Data.startsWith('/9j/')) {
|
|
69
|
+
return 'image/jpeg';
|
|
70
|
+
}
|
|
71
|
+
if (base64Data.startsWith('R0lG')) {
|
|
72
|
+
return 'image/gif';
|
|
73
|
+
}
|
|
74
|
+
if (base64Data.startsWith('UklG')) {
|
|
75
|
+
return 'image/webp';
|
|
76
|
+
}
|
|
77
|
+
// Default to PNG if detection fails
|
|
78
|
+
return 'image/png';
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Handler for nanogpt_image_generate
|
|
82
|
+
*/
|
|
83
|
+
export async function handler(args) {
|
|
84
|
+
try {
|
|
85
|
+
// Validate input
|
|
86
|
+
const input = inputSchema.parse(args);
|
|
87
|
+
// Build request body - default to URL format unless explicitly requested
|
|
88
|
+
const requestBody = {
|
|
89
|
+
prompt: input.prompt,
|
|
90
|
+
response_format: input.response_format || 'url',
|
|
91
|
+
};
|
|
92
|
+
if (input.model)
|
|
93
|
+
requestBody.model = input.model;
|
|
94
|
+
if (input.n)
|
|
95
|
+
requestBody.n = input.n;
|
|
96
|
+
if (input.size)
|
|
97
|
+
requestBody.size = input.size;
|
|
98
|
+
if (input.resolution)
|
|
99
|
+
requestBody.resolution = input.resolution;
|
|
100
|
+
if (input.width)
|
|
101
|
+
requestBody.width = input.width;
|
|
102
|
+
if (input.height)
|
|
103
|
+
requestBody.height = input.height;
|
|
104
|
+
if (input.aspect_ratio)
|
|
105
|
+
requestBody.aspect_ratio = input.aspect_ratio;
|
|
106
|
+
if (input.quality)
|
|
107
|
+
requestBody.quality = input.quality;
|
|
108
|
+
if (input.imageDataUrl)
|
|
109
|
+
requestBody.imageDataUrl = input.imageDataUrl;
|
|
110
|
+
if (input.imageDataUrls)
|
|
111
|
+
requestBody.imageDataUrls = input.imageDataUrls;
|
|
112
|
+
// Call NanoGPT API
|
|
113
|
+
const response = await requestJson({
|
|
114
|
+
method: 'POST',
|
|
115
|
+
path: '/v1/images/generations',
|
|
116
|
+
body: requestBody,
|
|
117
|
+
});
|
|
118
|
+
const data = response.json;
|
|
119
|
+
const images = [];
|
|
120
|
+
const resourceLinks = [];
|
|
121
|
+
// Process each image
|
|
122
|
+
if (data.data) {
|
|
123
|
+
for (let i = 0; i < data.data.length; i++) {
|
|
124
|
+
const item = data.data[i];
|
|
125
|
+
if (item.b64_json) {
|
|
126
|
+
// Detect MIME type from base64 data
|
|
127
|
+
const mimeType = detectMimeType(item.b64_json);
|
|
128
|
+
// Store base64 image as resource
|
|
129
|
+
const result = putBase64Image(item.b64_json, mimeType);
|
|
130
|
+
if (result) {
|
|
131
|
+
images.push({
|
|
132
|
+
kind: 'resource',
|
|
133
|
+
uri: result.uri,
|
|
134
|
+
mimeType,
|
|
135
|
+
bytes: result.bytes,
|
|
136
|
+
});
|
|
137
|
+
resourceLinks.push({
|
|
138
|
+
type: 'resource_link',
|
|
139
|
+
uri: result.uri,
|
|
140
|
+
name: `Image ${i + 1}`,
|
|
141
|
+
mimeType,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// Image too large to store - report as error with details
|
|
146
|
+
images.push({
|
|
147
|
+
kind: 'error',
|
|
148
|
+
mimeType,
|
|
149
|
+
error: 'Image exceeds maximum storage size and could not be cached',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else if (item.url) {
|
|
154
|
+
// Return URL directly
|
|
155
|
+
images.push({
|
|
156
|
+
kind: 'url',
|
|
157
|
+
url: item.url,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Build output
|
|
163
|
+
const output = {
|
|
164
|
+
images,
|
|
165
|
+
};
|
|
166
|
+
// Process raw response
|
|
167
|
+
const { raw, resourceLink } = processRawResponse({ status: response.status, headers: response.headers, body: data }, input.include_raw);
|
|
168
|
+
if (raw !== undefined) {
|
|
169
|
+
output.raw = raw;
|
|
170
|
+
}
|
|
171
|
+
if (resourceLink) {
|
|
172
|
+
resourceLinks.push(resourceLink);
|
|
173
|
+
}
|
|
174
|
+
// Build human-readable content
|
|
175
|
+
let displayText;
|
|
176
|
+
if (images.length === 0) {
|
|
177
|
+
displayText = 'No images generated.';
|
|
178
|
+
}
|
|
179
|
+
else if (images.length === 1) {
|
|
180
|
+
const img = images[0];
|
|
181
|
+
if (img.kind === 'url') {
|
|
182
|
+
displayText = `Generated 1 image: ${img.url}`;
|
|
183
|
+
}
|
|
184
|
+
else if (img.kind === 'error') {
|
|
185
|
+
displayText = `Generated 1 image but storage failed: ${img.error}`;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
displayText = `Generated 1 image (stored as resource: ${img.uri})`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const urlCount = images.filter((i) => i.kind === 'url').length;
|
|
193
|
+
const resourceCount = images.filter((i) => i.kind === 'resource').length;
|
|
194
|
+
const errorCount = images.filter((i) => i.kind === 'error').length;
|
|
195
|
+
const parts = [];
|
|
196
|
+
if (urlCount > 0)
|
|
197
|
+
parts.push(`${urlCount} as URLs`);
|
|
198
|
+
if (resourceCount > 0)
|
|
199
|
+
parts.push(`${resourceCount} as resources`);
|
|
200
|
+
if (errorCount > 0)
|
|
201
|
+
parts.push(`${errorCount} failed to store`);
|
|
202
|
+
displayText = `Generated ${images.length} images (${parts.join(', ')})`;
|
|
203
|
+
}
|
|
204
|
+
// Build content with all resource links
|
|
205
|
+
const content = [
|
|
206
|
+
{ type: 'text', text: displayText },
|
|
207
|
+
];
|
|
208
|
+
for (const link of resourceLinks) {
|
|
209
|
+
content.push(link);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
content,
|
|
213
|
+
structuredContent: output,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
return handleToolError(err);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=imageGenerate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageGenerate.js","sourceRoot":"","sources":["../../src/tools/imageGenerate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,kBA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AAU,GAAG,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,kBAAkB,CAAC,CAAC;YAChE,WAAW,GAAG,aAAa,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1E,CAAC;QAED,wCAAwC;QACxC,MAAM,OAAO,GAA2F;YACtG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE;SACpC,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;QAED,OAAO;YACL,OAAO;YACP,iBAAiB,EAAE,MAAM;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export all tools
|
|
3
|
+
*/
|
|
4
|
+
export * as balance from './balance.js';
|
|
5
|
+
export * as chat from './chat.js';
|
|
6
|
+
export * as imageGenerate from './imageGenerate.js';
|
|
7
|
+
export * as webSearch from './webSearch.js';
|
|
8
|
+
export * as scrapeUrls from './scrapeUrls.js';
|
|
9
|
+
export * as youtubeTranscribe from './youtubeTranscribe.js';
|
|
10
|
+
export { listTextModels, listImageModels, listAudioModels, listVideoModels } from './listModels.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export all tools
|
|
3
|
+
*/
|
|
4
|
+
export * as balance from './balance.js';
|
|
5
|
+
export * as chat from './chat.js';
|
|
6
|
+
export * as imageGenerate from './imageGenerate.js';
|
|
7
|
+
export * as webSearch from './webSearch.js';
|
|
8
|
+
export * as scrapeUrls from './scrapeUrls.js';
|
|
9
|
+
export * as youtubeTranscribe from './youtubeTranscribe.js';
|
|
10
|
+
export { listTextModels, listImageModels, listAudioModels, listVideoModels } from './listModels.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model listing tools
|
|
3
|
+
*
|
|
4
|
+
* - nanogpt_list_text_models
|
|
5
|
+
* - nanogpt_list_image_models
|
|
6
|
+
* - nanogpt_list_audio_models
|
|
7
|
+
* - nanogpt_list_video_models
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export declare const listTextModels: {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
inputSchema: z.ZodObject<{
|
|
14
|
+
detailed: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
include_raw: boolean;
|
|
18
|
+
detailed?: boolean | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
include_raw?: boolean | undefined;
|
|
21
|
+
detailed?: boolean | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
outputSchema: z.ZodObject<{
|
|
24
|
+
data: z.ZodArray<z.ZodUnknown, "many">;
|
|
25
|
+
raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
data: unknown[];
|
|
28
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
data: unknown[];
|
|
31
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
inputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
34
|
+
outputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
35
|
+
annotations: {
|
|
36
|
+
readOnlyHint: boolean;
|
|
37
|
+
openWorldHint: boolean;
|
|
38
|
+
};
|
|
39
|
+
handler(args: unknown): Promise<{
|
|
40
|
+
content: import("../toolUtils.js").ContentItem[];
|
|
41
|
+
structuredContent: Record<string, unknown>;
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
export declare const listImageModels: {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
inputSchema: z.ZodObject<{
|
|
48
|
+
detailed: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
include_raw: boolean;
|
|
52
|
+
detailed?: boolean | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
include_raw?: boolean | undefined;
|
|
55
|
+
detailed?: boolean | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
outputSchema: z.ZodObject<{
|
|
58
|
+
data: z.ZodArray<z.ZodUnknown, "many">;
|
|
59
|
+
raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
data: unknown[];
|
|
62
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
data: unknown[];
|
|
65
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
inputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
68
|
+
outputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
69
|
+
annotations: {
|
|
70
|
+
readOnlyHint: boolean;
|
|
71
|
+
openWorldHint: boolean;
|
|
72
|
+
};
|
|
73
|
+
handler(args: unknown): Promise<{
|
|
74
|
+
content: import("../toolUtils.js").ContentItem[];
|
|
75
|
+
structuredContent: Record<string, unknown>;
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
export declare const listAudioModels: {
|
|
79
|
+
name: string;
|
|
80
|
+
description: string;
|
|
81
|
+
inputSchema: z.ZodObject<{
|
|
82
|
+
detailed: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
type: z.ZodOptional<z.ZodEnum<["tts", "stt", "all"]>>;
|
|
84
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
include_raw: boolean;
|
|
87
|
+
type?: "tts" | "stt" | "all" | undefined;
|
|
88
|
+
detailed?: boolean | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
type?: "tts" | "stt" | "all" | undefined;
|
|
91
|
+
include_raw?: boolean | undefined;
|
|
92
|
+
detailed?: boolean | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
outputSchema: z.ZodObject<{
|
|
95
|
+
data: z.ZodArray<z.ZodUnknown, "many">;
|
|
96
|
+
raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
data: unknown[];
|
|
99
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
data: unknown[];
|
|
102
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
inputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
105
|
+
outputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
106
|
+
annotations: {
|
|
107
|
+
readOnlyHint: boolean;
|
|
108
|
+
openWorldHint: boolean;
|
|
109
|
+
};
|
|
110
|
+
handler(args: unknown): Promise<{
|
|
111
|
+
content: import("../toolUtils.js").ContentItem[];
|
|
112
|
+
structuredContent: Record<string, unknown>;
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
export declare const listVideoModels: {
|
|
116
|
+
name: string;
|
|
117
|
+
description: string;
|
|
118
|
+
inputSchema: z.ZodObject<{
|
|
119
|
+
detailed: z.ZodOptional<z.ZodBoolean>;
|
|
120
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
include_raw: boolean;
|
|
123
|
+
detailed?: boolean | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
include_raw?: boolean | undefined;
|
|
126
|
+
detailed?: boolean | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
outputSchema: z.ZodObject<{
|
|
129
|
+
data: z.ZodArray<z.ZodUnknown, "many">;
|
|
130
|
+
raw: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
data: unknown[];
|
|
133
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
data: unknown[];
|
|
136
|
+
raw?: string | Record<string, unknown> | undefined;
|
|
137
|
+
}>;
|
|
138
|
+
inputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
139
|
+
outputJsonSchema: import("../toolUtils.js").JsonSchema;
|
|
140
|
+
annotations: {
|
|
141
|
+
readOnlyHint: boolean;
|
|
142
|
+
openWorldHint: boolean;
|
|
143
|
+
};
|
|
144
|
+
handler(args: unknown): Promise<{
|
|
145
|
+
content: import("../toolUtils.js").ContentItem[];
|
|
146
|
+
structuredContent: Record<string, unknown>;
|
|
147
|
+
}>;
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=listModels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listModels.d.ts","sourceRoot":"","sources":["../../src/tools/listModels.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsCxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWL,OAAO;;;;CAwC5B,CAAC;AAMF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWN,OAAO;;;;CAyC5B,CAAC;AAMF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWN,OAAO;;;;CA6C5B,CAAC;AAMF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWN,OAAO;;;;CAyC5B,CAAC"}
|