@agentwonderland/mcp 0.1.12 → 0.1.14
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/core/file-upload.d.ts +14 -1
- package/dist/core/file-upload.js +7 -3
- package/dist/core/formatters.d.ts +1 -0
- package/dist/core/formatters.js +3 -0
- package/dist/tools/run.js +10 -3
- package/dist/tools/solve.js +4 -2
- package/package.json +1 -1
- package/src/core/file-upload.ts +16 -3
- package/src/core/formatters.ts +4 -0
- package/src/tools/run.ts +10 -3
- package/src/tools/solve.ts +4 -2
|
@@ -6,4 +6,17 @@ export declare function isLocalFilePath(value: string): boolean;
|
|
|
6
6
|
* Scan input object for local file paths, upload them to temporary storage,
|
|
7
7
|
* and replace with download URLs. Non-file values are left unchanged.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export interface UploadResult {
|
|
10
|
+
input: Record<string, unknown>;
|
|
11
|
+
uploads: Array<{
|
|
12
|
+
field: string;
|
|
13
|
+
originalPath: string;
|
|
14
|
+
url: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Scan input object for local file paths, upload them to temporary storage,
|
|
19
|
+
* and replace with download URLs. Returns the processed input and a list
|
|
20
|
+
* of uploads performed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function uploadLocalFiles(input: Record<string, unknown>): Promise<UploadResult>;
|
package/dist/core/file-upload.js
CHANGED
|
@@ -78,10 +78,12 @@ async function uploadFile(filePath) {
|
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Scan input object for local file paths, upload them to temporary storage,
|
|
81
|
-
* and replace with download URLs.
|
|
81
|
+
* and replace with download URLs. Returns the processed input and a list
|
|
82
|
+
* of uploads performed.
|
|
82
83
|
*/
|
|
83
84
|
export async function uploadLocalFiles(input) {
|
|
84
85
|
const result = { ...input };
|
|
86
|
+
const uploads = [];
|
|
85
87
|
for (const [key, value] of Object.entries(result)) {
|
|
86
88
|
if (typeof value !== "string")
|
|
87
89
|
continue;
|
|
@@ -91,12 +93,14 @@ export async function uploadLocalFiles(input) {
|
|
|
91
93
|
if (!existsSync(resolved))
|
|
92
94
|
continue;
|
|
93
95
|
try {
|
|
94
|
-
|
|
96
|
+
const url = await uploadFile(value);
|
|
97
|
+
result[key] = url;
|
|
98
|
+
uploads.push({ field: key, originalPath: value, url });
|
|
95
99
|
}
|
|
96
100
|
catch (err) {
|
|
97
101
|
const msg = err instanceof Error ? err.message : "unknown error";
|
|
98
102
|
throw new Error(`Failed to upload file "${value}" for field "${key}": ${msg}`);
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
|
-
return result;
|
|
105
|
+
return { input: result, uploads };
|
|
102
106
|
}
|
package/dist/core/formatters.js
CHANGED
|
@@ -116,6 +116,9 @@ export function formatRunResult(result, opts) {
|
|
|
116
116
|
const latency = result.latency_ms != null ? `${result.latency_ms}ms` : "";
|
|
117
117
|
const method = opts?.paymentMethod ?? "";
|
|
118
118
|
lines.push(`${status} ${agent}${latency ? ` (${latency})` : ""}`);
|
|
119
|
+
if (result.error_code) {
|
|
120
|
+
lines.push(`Error: ${result.error_code}`);
|
|
121
|
+
}
|
|
119
122
|
if (costStr) {
|
|
120
123
|
lines.push(`Paid: ${costStr}${method ? ` via ${method}` : ""}`);
|
|
121
124
|
}
|
package/dist/tools/run.js
CHANGED
|
@@ -56,8 +56,15 @@ export function registerRunTools(server) {
|
|
|
56
56
|
}
|
|
57
57
|
const method = pay_with;
|
|
58
58
|
let processedInput;
|
|
59
|
+
let uploadSummary = "";
|
|
59
60
|
try {
|
|
60
|
-
|
|
61
|
+
const uploadResult = await uploadLocalFiles(input);
|
|
62
|
+
processedInput = uploadResult.input;
|
|
63
|
+
if (uploadResult.uploads.length > 0) {
|
|
64
|
+
uploadSummary = uploadResult.uploads
|
|
65
|
+
.map((u) => `Uploaded ${u.field}: ${u.originalPath} → ${u.url}`)
|
|
66
|
+
.join("\n");
|
|
67
|
+
}
|
|
61
68
|
}
|
|
62
69
|
catch (err) {
|
|
63
70
|
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
@@ -110,7 +117,7 @@ export function registerRunTools(server) {
|
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
119
|
if (status !== "success") {
|
|
113
|
-
return multiText(formatted, "The agent execution failed. A refund has been initiated automatically.");
|
|
120
|
+
return multiText(uploadSummary ? `${uploadSummary}\n\n${formatted}` : formatted, "The agent execution failed. A refund has been initiated automatically.");
|
|
114
121
|
}
|
|
115
122
|
const costLine = actualCost != null ? `Paid $${actualCost.toFixed(actualCost < 0.01 ? 4 : 2)}.` : "";
|
|
116
123
|
// Separate the feedback ask into its own content block so the LLM
|
|
@@ -127,6 +134,6 @@ export function registerRunTools(server) {
|
|
|
127
134
|
] : []),
|
|
128
135
|
`To save for later: favorite_agent({ agent_id: "${resultAgentId}" })`,
|
|
129
136
|
].join("\n");
|
|
130
|
-
return multiText(formatted, feedbackAsk);
|
|
137
|
+
return multiText(uploadSummary ? `${uploadSummary}\n\n${formatted}` : formatted, feedbackAsk);
|
|
131
138
|
});
|
|
132
139
|
}
|
package/dist/tools/solve.js
CHANGED
|
@@ -78,7 +78,8 @@ export function registerSolveTools(server) {
|
|
|
78
78
|
// Path 1: If authenticated, use the platform /solve route
|
|
79
79
|
let processedInput;
|
|
80
80
|
try {
|
|
81
|
-
|
|
81
|
+
const uploadResult = await uploadLocalFiles(input);
|
|
82
|
+
processedInput = uploadResult.input;
|
|
82
83
|
}
|
|
83
84
|
catch (err) {
|
|
84
85
|
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
@@ -149,7 +150,8 @@ export function registerSolveTools(server) {
|
|
|
149
150
|
let result;
|
|
150
151
|
let processedInput2;
|
|
151
152
|
try {
|
|
152
|
-
|
|
153
|
+
const uploadResult2 = await uploadLocalFiles(input);
|
|
154
|
+
processedInput2 = uploadResult2.input;
|
|
153
155
|
}
|
|
154
156
|
catch (err) {
|
|
155
157
|
const msg = err instanceof Error ? err.message : "File upload failed";
|
package/package.json
CHANGED
package/src/core/file-upload.ts
CHANGED
|
@@ -91,10 +91,21 @@ async function uploadFile(filePath: string): Promise<string> {
|
|
|
91
91
|
* Scan input object for local file paths, upload them to temporary storage,
|
|
92
92
|
* and replace with download URLs. Non-file values are left unchanged.
|
|
93
93
|
*/
|
|
94
|
+
export interface UploadResult {
|
|
95
|
+
input: Record<string, unknown>;
|
|
96
|
+
uploads: Array<{ field: string; originalPath: string; url: string }>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Scan input object for local file paths, upload them to temporary storage,
|
|
101
|
+
* and replace with download URLs. Returns the processed input and a list
|
|
102
|
+
* of uploads performed.
|
|
103
|
+
*/
|
|
94
104
|
export async function uploadLocalFiles(
|
|
95
105
|
input: Record<string, unknown>,
|
|
96
|
-
): Promise<
|
|
106
|
+
): Promise<UploadResult> {
|
|
97
107
|
const result = { ...input };
|
|
108
|
+
const uploads: UploadResult["uploads"] = [];
|
|
98
109
|
|
|
99
110
|
for (const [key, value] of Object.entries(result)) {
|
|
100
111
|
if (typeof value !== "string") continue;
|
|
@@ -104,12 +115,14 @@ export async function uploadLocalFiles(
|
|
|
104
115
|
if (!existsSync(resolved)) continue;
|
|
105
116
|
|
|
106
117
|
try {
|
|
107
|
-
|
|
118
|
+
const url = await uploadFile(value);
|
|
119
|
+
result[key] = url;
|
|
120
|
+
uploads.push({ field: key, originalPath: value, url });
|
|
108
121
|
} catch (err) {
|
|
109
122
|
const msg = err instanceof Error ? err.message : "unknown error";
|
|
110
123
|
throw new Error(`Failed to upload file "${value}" for field "${key}": ${msg}`);
|
|
111
124
|
}
|
|
112
125
|
}
|
|
113
126
|
|
|
114
|
-
return result;
|
|
127
|
+
return { input: result, uploads };
|
|
115
128
|
}
|
package/src/core/formatters.ts
CHANGED
|
@@ -111,6 +111,7 @@ interface RunResultLike {
|
|
|
111
111
|
agent_id?: string;
|
|
112
112
|
agent_name?: string;
|
|
113
113
|
output?: unknown;
|
|
114
|
+
error_code?: string;
|
|
114
115
|
latency_ms?: number;
|
|
115
116
|
execution_latency_ms?: number;
|
|
116
117
|
cost?: number;
|
|
@@ -153,6 +154,9 @@ export function formatRunResult(result: RunResultLike, opts?: { paymentMethod?:
|
|
|
153
154
|
const method = opts?.paymentMethod ?? "";
|
|
154
155
|
|
|
155
156
|
lines.push(`${status} ${agent}${latency ? ` (${latency})` : ""}`);
|
|
157
|
+
if (result.error_code) {
|
|
158
|
+
lines.push(`Error: ${result.error_code}`);
|
|
159
|
+
}
|
|
156
160
|
if (costStr) {
|
|
157
161
|
lines.push(`Paid: ${costStr}${method ? ` via ${method}` : ""}`);
|
|
158
162
|
}
|
package/src/tools/run.ts
CHANGED
|
@@ -75,8 +75,15 @@ export function registerRunTools(server: McpServer): void {
|
|
|
75
75
|
|
|
76
76
|
const method = pay_with;
|
|
77
77
|
let processedInput: Record<string, unknown>;
|
|
78
|
+
let uploadSummary = "";
|
|
78
79
|
try {
|
|
79
|
-
|
|
80
|
+
const uploadResult = await uploadLocalFiles(input);
|
|
81
|
+
processedInput = uploadResult.input;
|
|
82
|
+
if (uploadResult.uploads.length > 0) {
|
|
83
|
+
uploadSummary = uploadResult.uploads
|
|
84
|
+
.map((u) => `Uploaded ${u.field}: ${u.originalPath} → ${u.url}`)
|
|
85
|
+
.join("\n");
|
|
86
|
+
}
|
|
80
87
|
} catch (err) {
|
|
81
88
|
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
82
89
|
return text(`Error: ${msg}`);
|
|
@@ -139,7 +146,7 @@ export function registerRunTools(server: McpServer): void {
|
|
|
139
146
|
|
|
140
147
|
if (status !== "success") {
|
|
141
148
|
return multiText(
|
|
142
|
-
formatted,
|
|
149
|
+
uploadSummary ? `${uploadSummary}\n\n${formatted}` : formatted,
|
|
143
150
|
"The agent execution failed. A refund has been initiated automatically.",
|
|
144
151
|
);
|
|
145
152
|
}
|
|
@@ -161,7 +168,7 @@ export function registerRunTools(server: McpServer): void {
|
|
|
161
168
|
`To save for later: favorite_agent({ agent_id: "${resultAgentId}" })`,
|
|
162
169
|
].join("\n");
|
|
163
170
|
|
|
164
|
-
return multiText(formatted, feedbackAsk);
|
|
171
|
+
return multiText(uploadSummary ? `${uploadSummary}\n\n${formatted}` : formatted, feedbackAsk);
|
|
165
172
|
},
|
|
166
173
|
);
|
|
167
174
|
}
|
package/src/tools/solve.ts
CHANGED
|
@@ -97,7 +97,8 @@ export function registerSolveTools(server: McpServer): void {
|
|
|
97
97
|
// Path 1: If authenticated, use the platform /solve route
|
|
98
98
|
let processedInput: Record<string, unknown>;
|
|
99
99
|
try {
|
|
100
|
-
|
|
100
|
+
const uploadResult = await uploadLocalFiles(input);
|
|
101
|
+
processedInput = uploadResult.input;
|
|
101
102
|
} catch (err) {
|
|
102
103
|
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
103
104
|
return text(`Error: ${msg}`);
|
|
@@ -177,7 +178,8 @@ export function registerSolveTools(server: McpServer): void {
|
|
|
177
178
|
let result: Record<string, unknown>;
|
|
178
179
|
let processedInput2: Record<string, unknown>;
|
|
179
180
|
try {
|
|
180
|
-
|
|
181
|
+
const uploadResult2 = await uploadLocalFiles(input);
|
|
182
|
+
processedInput2 = uploadResult2.input;
|
|
181
183
|
} catch (err) {
|
|
182
184
|
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
183
185
|
return text(`Error: ${msg}`);
|