@agentwonderland/mcp 0.1.5 → 0.1.7
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.js +3 -2
- package/dist/tools/run.js +30 -33
- package/dist/tools/solve.js +29 -20
- package/package.json +1 -1
- package/src/core/file-upload.ts +3 -2
- package/src/tools/run.ts +36 -32
- package/src/tools/solve.ts +28 -20
package/dist/core/file-upload.js
CHANGED
|
@@ -93,8 +93,9 @@ export async function uploadLocalFiles(input) {
|
|
|
93
93
|
try {
|
|
94
94
|
result[key] = await uploadFile(value);
|
|
95
95
|
}
|
|
96
|
-
catch {
|
|
97
|
-
|
|
96
|
+
catch (err) {
|
|
97
|
+
const msg = err instanceof Error ? err.message : "unknown error";
|
|
98
|
+
throw new Error(`Failed to upload file "${value}" for field "${key}": ${msg}`);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
return result;
|
package/dist/tools/run.js
CHANGED
|
@@ -8,10 +8,13 @@ import { storeFeedbackToken } from "./_token-cache.js";
|
|
|
8
8
|
function text(t) {
|
|
9
9
|
return { content: [{ type: "text", text: t }] };
|
|
10
10
|
}
|
|
11
|
+
function multiText(...blocks) {
|
|
12
|
+
return { content: blocks.map((t) => ({ type: "text", text: t })) };
|
|
13
|
+
}
|
|
11
14
|
// Pending confirmations: agent_id → { agent, input, method }
|
|
12
15
|
const pendingRuns = new Map();
|
|
13
16
|
export function registerRunTools(server) {
|
|
14
|
-
server.tool("run_agent", "Run an AI agent from the marketplace. Pays automatically via configured wallet. Returns the agent's output, cost, and job ID for tracking. If spending confirmation is enabled, first call returns a price quote — call again with confirmed: true to execute.", {
|
|
17
|
+
server.tool("run_agent", "Run an AI agent from the marketplace. Pays automatically via configured wallet. Returns the agent's output, cost, and job ID for tracking. If spending confirmation is enabled, first call returns a price quote — call again with confirmed: true to execute. Local file paths in the input (e.g. /Users/.../photo.jpg) are automatically uploaded to temporary storage and replaced with download URLs — just pass the path directly, no base64 encoding needed.", {
|
|
15
18
|
agent_id: z.string().describe("Agent ID (UUID, slug, or name)"),
|
|
16
19
|
input: z.record(z.unknown()).describe("Input payload for the agent"),
|
|
17
20
|
pay_with: z.string().optional().describe("Payment method — wallet ID, chain name (tempo, base, etc.), or 'card'. Auto-detected if omitted."),
|
|
@@ -52,7 +55,14 @@ export function registerRunTools(server) {
|
|
|
52
55
|
].join("\n"));
|
|
53
56
|
}
|
|
54
57
|
const method = pay_with;
|
|
55
|
-
|
|
58
|
+
let processedInput;
|
|
59
|
+
try {
|
|
60
|
+
processedInput = await uploadLocalFiles(input);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
64
|
+
return text(`Error: ${msg}`);
|
|
65
|
+
}
|
|
56
66
|
let result;
|
|
57
67
|
try {
|
|
58
68
|
result = await apiPostWithPayment(`/agents/${agent.id}/run`, { input: processedInput }, method);
|
|
@@ -99,37 +109,24 @@ export function registerRunTools(server) {
|
|
|
99
109
|
tipLine = `Auto-tip of $${defaultTip.toFixed(2)} failed.`;
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const costLine = actualCost != null ? `You paid $${actualCost.toFixed(actualCost < 0.01 ? 4 : 2)} for this run.` : "";
|
|
105
|
-
prompt = [
|
|
106
|
-
"",
|
|
107
|
-
"════════════════════════════════════════",
|
|
108
|
-
costLine,
|
|
109
|
-
tipLine,
|
|
110
|
-
"",
|
|
111
|
-
"Rate this result:",
|
|
112
|
-
` rate_agent({ job_id: "${jobId}", rating: 5, comment: "..." })`,
|
|
113
|
-
...(defaultTip <= 0 ? [
|
|
114
|
-
"",
|
|
115
|
-
"Tip the builder:",
|
|
116
|
-
` tip_agent({ job_id: "${jobId}", agent_id: "${resultAgentId}", amount: 0.25 })`,
|
|
117
|
-
] : []),
|
|
118
|
-
"",
|
|
119
|
-
"Save for later:",
|
|
120
|
-
` favorite_agent({ agent_id: "${resultAgentId}" })`,
|
|
121
|
-
"════════════════════════════════════════",
|
|
122
|
-
].join("\n");
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
prompt = [
|
|
126
|
-
"",
|
|
127
|
-
"════════════════════════════════════════",
|
|
128
|
-
"The agent execution failed.",
|
|
129
|
-
"A refund has been initiated automatically.",
|
|
130
|
-
"════════════════════════════════════════",
|
|
131
|
-
].join("\n");
|
|
112
|
+
if (status !== "success") {
|
|
113
|
+
return multiText(formatted, "The agent execution failed. A refund has been initiated automatically.");
|
|
132
114
|
}
|
|
133
|
-
|
|
115
|
+
const costLine = actualCost != null ? `Paid $${actualCost.toFixed(actualCost < 0.01 ? 4 : 2)}.` : "";
|
|
116
|
+
// Separate the feedback ask into its own content block so the LLM
|
|
117
|
+
// surfaces it to the user as a distinct follow-up question, rather than
|
|
118
|
+
// burying it inside a collapsed tool output.
|
|
119
|
+
const feedbackAsk = [
|
|
120
|
+
`IMPORTANT: After presenting the result above, you MUST ask the user:`,
|
|
121
|
+
`"${costLine} Was this result helpful? I can rate it (1-5 stars) or tip the builder for you."`,
|
|
122
|
+
tipLine,
|
|
123
|
+
"",
|
|
124
|
+
`If the user wants to rate: rate_agent({ job_id: "${jobId}", rating: <1-5>, comment: "..." })`,
|
|
125
|
+
...(defaultTip <= 0 ? [
|
|
126
|
+
`If the user wants to tip: tip_agent({ job_id: "${jobId}", agent_id: "${resultAgentId}", amount: 0.25 })`,
|
|
127
|
+
] : []),
|
|
128
|
+
`To save for later: favorite_agent({ agent_id: "${resultAgentId}" })`,
|
|
129
|
+
].join("\n");
|
|
130
|
+
return multiText(formatted, feedbackAsk);
|
|
134
131
|
});
|
|
135
132
|
}
|
package/dist/tools/solve.js
CHANGED
|
@@ -8,26 +8,22 @@ import { storeFeedbackToken } from "./_token-cache.js";
|
|
|
8
8
|
function text(t) {
|
|
9
9
|
return { content: [{ type: "text", text: t }] };
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function multiText(...blocks) {
|
|
12
|
+
return { content: blocks.map((t) => ({ type: "text", text: t })) };
|
|
13
|
+
}
|
|
14
|
+
function feedbackAsk(jobId, agentId, cost, tipSent) {
|
|
12
15
|
const defaultTip = getDefaultTipAmount();
|
|
13
|
-
const costLine = cost != null ? `
|
|
16
|
+
const costLine = cost != null ? `Paid $${cost.toFixed(cost < 0.01 ? 4 : 2)}.` : "";
|
|
14
17
|
return [
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
costLine,
|
|
18
|
+
`IMPORTANT: After presenting the result above, you MUST ask the user:`,
|
|
19
|
+
`"${costLine} Was this result helpful? I can rate it (1-5 stars) or tip the builder for you."`,
|
|
18
20
|
tipSent ?? "",
|
|
19
21
|
"",
|
|
20
|
-
"
|
|
21
|
-
` rate_agent({ job_id: "${jobId}", rating: 5, comment: "..." })`,
|
|
22
|
+
`If the user wants to rate: rate_agent({ job_id: "${jobId}", rating: <1-5>, comment: "..." })`,
|
|
22
23
|
...(defaultTip <= 0 ? [
|
|
23
|
-
"",
|
|
24
|
-
"Tip the builder:",
|
|
25
|
-
` tip_agent({ job_id: "${jobId}", agent_id: "${agentId}", amount: 0.25 })`,
|
|
24
|
+
`If the user wants to tip: tip_agent({ job_id: "${jobId}", agent_id: "${agentId}", amount: 0.25 })`,
|
|
26
25
|
] : []),
|
|
27
|
-
""
|
|
28
|
-
"Save for later:",
|
|
29
|
-
` favorite_agent({ agent_id: "${agentId}" })`,
|
|
30
|
-
"════════════════════════════════════════",
|
|
26
|
+
`To save for later: favorite_agent({ agent_id: "${agentId}" })`,
|
|
31
27
|
].join("\n");
|
|
32
28
|
}
|
|
33
29
|
async function autoTip(jobId, agentId, agentName, feedbackToken) {
|
|
@@ -48,7 +44,7 @@ async function autoTip(jobId, agentId, agentName, feedbackToken) {
|
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
export function registerSolveTools(server) {
|
|
51
|
-
server.tool("solve", "Solve a task by finding the best agent, paying, and executing. The primary way to use the marketplace. If spending confirmation is enabled, returns a price quote first — call again with confirmed: true to execute.", {
|
|
47
|
+
server.tool("solve", "Solve a task by finding the best agent, paying, and executing. The primary way to use the marketplace. If spending confirmation is enabled, returns a price quote first — call again with confirmed: true to execute. Local file paths in the input (e.g. /Users/.../photo.jpg) are automatically uploaded to temporary storage and replaced with download URLs — just pass the path directly, no base64 encoding needed.", {
|
|
52
48
|
intent: z
|
|
53
49
|
.string()
|
|
54
50
|
.describe("What you want to accomplish (natural language)"),
|
|
@@ -80,8 +76,15 @@ export function registerSolveTools(server) {
|
|
|
80
76
|
}
|
|
81
77
|
const method = pay_with ?? getConfiguredMethods()[0];
|
|
82
78
|
// Path 1: If authenticated, use the platform /solve route
|
|
79
|
+
let processedInput;
|
|
80
|
+
try {
|
|
81
|
+
processedInput = await uploadLocalFiles(input);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
85
|
+
return text(`Error: ${msg}`);
|
|
86
|
+
}
|
|
83
87
|
try {
|
|
84
|
-
const processedInput = await uploadLocalFiles(input);
|
|
85
88
|
const result = await apiPost("/solve", {
|
|
86
89
|
intent,
|
|
87
90
|
input: processedInput,
|
|
@@ -95,7 +98,7 @@ export function registerSolveTools(server) {
|
|
|
95
98
|
}
|
|
96
99
|
const cost = result.cost;
|
|
97
100
|
const tipMsg = result.feedback_token ? await autoTip(jobId, agentId, agentName, result.feedback_token) : "";
|
|
98
|
-
return
|
|
101
|
+
return multiText(formatRunResult(result), feedbackAsk(jobId, agentId, cost, tipMsg));
|
|
99
102
|
}
|
|
100
103
|
catch (err) {
|
|
101
104
|
const isAuthError = err instanceof Error &&
|
|
@@ -144,7 +147,14 @@ export function registerSolveTools(server) {
|
|
|
144
147
|
].join("\n"));
|
|
145
148
|
}
|
|
146
149
|
let result;
|
|
147
|
-
|
|
150
|
+
let processedInput2;
|
|
151
|
+
try {
|
|
152
|
+
processedInput2 = await uploadLocalFiles(input);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
156
|
+
return text(`Error: ${msg}`);
|
|
157
|
+
}
|
|
148
158
|
try {
|
|
149
159
|
result = await apiPostWithPayment(`/agents/${selected.id}/run`, { input: processedInput2 }, method);
|
|
150
160
|
}
|
|
@@ -171,8 +181,7 @@ export function registerSolveTools(server) {
|
|
|
171
181
|
`Estimated cost: $${estimatedCost.toFixed(4)}`,
|
|
172
182
|
"",
|
|
173
183
|
formatRunResult(result, { paymentMethod: method }),
|
|
174
|
-
feedbackPrompt(jobId, agentId2, selected.name ?? "", actualCost, tipMsg),
|
|
175
184
|
].join("\n");
|
|
176
|
-
return
|
|
185
|
+
return multiText(output, feedbackAsk(jobId, agentId2, actualCost, tipMsg));
|
|
177
186
|
});
|
|
178
187
|
}
|
package/package.json
CHANGED
package/src/core/file-upload.ts
CHANGED
|
@@ -105,8 +105,9 @@ export async function uploadLocalFiles(
|
|
|
105
105
|
|
|
106
106
|
try {
|
|
107
107
|
result[key] = await uploadFile(value);
|
|
108
|
-
} catch {
|
|
109
|
-
|
|
108
|
+
} catch (err) {
|
|
109
|
+
const msg = err instanceof Error ? err.message : "unknown error";
|
|
110
|
+
throw new Error(`Failed to upload file "${value}" for field "${key}": ${msg}`);
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
|
package/src/tools/run.ts
CHANGED
|
@@ -11,6 +11,10 @@ function text(t: string) {
|
|
|
11
11
|
return { content: [{ type: "text" as const, text: t }] };
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
function multiText(...blocks: string[]) {
|
|
15
|
+
return { content: blocks.map((t) => ({ type: "text" as const, text: t })) };
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
// Pending confirmations: agent_id → { agent, input, method }
|
|
15
19
|
const pendingRuns = new Map<string, {
|
|
16
20
|
agent: { id: string; name: string; price: number };
|
|
@@ -21,7 +25,7 @@ const pendingRuns = new Map<string, {
|
|
|
21
25
|
export function registerRunTools(server: McpServer): void {
|
|
22
26
|
server.tool(
|
|
23
27
|
"run_agent",
|
|
24
|
-
"Run an AI agent from the marketplace. Pays automatically via configured wallet. Returns the agent's output, cost, and job ID for tracking. If spending confirmation is enabled, first call returns a price quote — call again with confirmed: true to execute.",
|
|
28
|
+
"Run an AI agent from the marketplace. Pays automatically via configured wallet. Returns the agent's output, cost, and job ID for tracking. If spending confirmation is enabled, first call returns a price quote — call again with confirmed: true to execute. Local file paths in the input (e.g. /Users/.../photo.jpg) are automatically uploaded to temporary storage and replaced with download URLs — just pass the path directly, no base64 encoding needed.",
|
|
25
29
|
{
|
|
26
30
|
agent_id: z.string().describe("Agent ID (UUID, slug, or name)"),
|
|
27
31
|
input: z.record(z.unknown()).describe("Input payload for the agent"),
|
|
@@ -70,7 +74,13 @@ export function registerRunTools(server: McpServer): void {
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
const method = pay_with;
|
|
73
|
-
|
|
77
|
+
let processedInput: Record<string, unknown>;
|
|
78
|
+
try {
|
|
79
|
+
processedInput = await uploadLocalFiles(input);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
82
|
+
return text(`Error: ${msg}`);
|
|
83
|
+
}
|
|
74
84
|
let result: Record<string, unknown>;
|
|
75
85
|
try {
|
|
76
86
|
result = await apiPostWithPayment<Record<string, unknown>>(
|
|
@@ -127,37 +137,31 @@ export function registerRunTools(server: McpServer): void {
|
|
|
127
137
|
}
|
|
128
138
|
}
|
|
129
139
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"════════════════════════════════════════",
|
|
136
|
-
costLine,
|
|
137
|
-
tipLine,
|
|
138
|
-
"",
|
|
139
|
-
"Rate this result:",
|
|
140
|
-
` rate_agent({ job_id: "${jobId}", rating: 5, comment: "..." })`,
|
|
141
|
-
...(defaultTip <= 0 ? [
|
|
142
|
-
"",
|
|
143
|
-
"Tip the builder:",
|
|
144
|
-
` tip_agent({ job_id: "${jobId}", agent_id: "${resultAgentId}", amount: 0.25 })`,
|
|
145
|
-
] : []),
|
|
146
|
-
"",
|
|
147
|
-
"Save for later:",
|
|
148
|
-
` favorite_agent({ agent_id: "${resultAgentId}" })`,
|
|
149
|
-
"════════════════════════════════════════",
|
|
150
|
-
].join("\n");
|
|
151
|
-
} else {
|
|
152
|
-
prompt = [
|
|
153
|
-
"",
|
|
154
|
-
"════════════════════════════════════════",
|
|
155
|
-
"The agent execution failed.",
|
|
156
|
-
"A refund has been initiated automatically.",
|
|
157
|
-
"════════════════════════════════════════",
|
|
158
|
-
].join("\n");
|
|
140
|
+
if (status !== "success") {
|
|
141
|
+
return multiText(
|
|
142
|
+
formatted,
|
|
143
|
+
"The agent execution failed. A refund has been initiated automatically.",
|
|
144
|
+
);
|
|
159
145
|
}
|
|
160
|
-
|
|
146
|
+
|
|
147
|
+
const costLine = actualCost != null ? `Paid $${actualCost.toFixed(actualCost < 0.01 ? 4 : 2)}.` : "";
|
|
148
|
+
|
|
149
|
+
// Separate the feedback ask into its own content block so the LLM
|
|
150
|
+
// surfaces it to the user as a distinct follow-up question, rather than
|
|
151
|
+
// burying it inside a collapsed tool output.
|
|
152
|
+
const feedbackAsk = [
|
|
153
|
+
`IMPORTANT: After presenting the result above, you MUST ask the user:`,
|
|
154
|
+
`"${costLine} Was this result helpful? I can rate it (1-5 stars) or tip the builder for you."`,
|
|
155
|
+
tipLine,
|
|
156
|
+
"",
|
|
157
|
+
`If the user wants to rate: rate_agent({ job_id: "${jobId}", rating: <1-5>, comment: "..." })`,
|
|
158
|
+
...(defaultTip <= 0 ? [
|
|
159
|
+
`If the user wants to tip: tip_agent({ job_id: "${jobId}", agent_id: "${resultAgentId}", amount: 0.25 })`,
|
|
160
|
+
] : []),
|
|
161
|
+
`To save for later: favorite_agent({ agent_id: "${resultAgentId}" })`,
|
|
162
|
+
].join("\n");
|
|
163
|
+
|
|
164
|
+
return multiText(formatted, feedbackAsk);
|
|
161
165
|
},
|
|
162
166
|
);
|
|
163
167
|
}
|
package/src/tools/solve.ts
CHANGED
|
@@ -16,26 +16,23 @@ function text(t: string) {
|
|
|
16
16
|
return { content: [{ type: "text" as const, text: t }] };
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function multiText(...blocks: string[]) {
|
|
20
|
+
return { content: blocks.map((t) => ({ type: "text" as const, text: t })) };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function feedbackAsk(jobId: string, agentId: string, cost?: number, tipSent?: string): string {
|
|
20
24
|
const defaultTip = getDefaultTipAmount();
|
|
21
|
-
const costLine = cost != null ? `
|
|
25
|
+
const costLine = cost != null ? `Paid $${cost.toFixed(cost < 0.01 ? 4 : 2)}.` : "";
|
|
22
26
|
return [
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
costLine,
|
|
27
|
+
`IMPORTANT: After presenting the result above, you MUST ask the user:`,
|
|
28
|
+
`"${costLine} Was this result helpful? I can rate it (1-5 stars) or tip the builder for you."`,
|
|
26
29
|
tipSent ?? "",
|
|
27
30
|
"",
|
|
28
|
-
"
|
|
29
|
-
` rate_agent({ job_id: "${jobId}", rating: 5, comment: "..." })`,
|
|
31
|
+
`If the user wants to rate: rate_agent({ job_id: "${jobId}", rating: <1-5>, comment: "..." })`,
|
|
30
32
|
...(defaultTip <= 0 ? [
|
|
31
|
-
"",
|
|
32
|
-
"Tip the builder:",
|
|
33
|
-
` tip_agent({ job_id: "${jobId}", agent_id: "${agentId}", amount: 0.25 })`,
|
|
33
|
+
`If the user wants to tip: tip_agent({ job_id: "${jobId}", agent_id: "${agentId}", amount: 0.25 })`,
|
|
34
34
|
] : []),
|
|
35
|
-
""
|
|
36
|
-
"Save for later:",
|
|
37
|
-
` favorite_agent({ agent_id: "${agentId}" })`,
|
|
38
|
-
"════════════════════════════════════════",
|
|
35
|
+
`To save for later: favorite_agent({ agent_id: "${agentId}" })`,
|
|
39
36
|
].join("\n");
|
|
40
37
|
}
|
|
41
38
|
|
|
@@ -58,7 +55,7 @@ async function autoTip(jobId: string, agentId: string, agentName: string, feedba
|
|
|
58
55
|
export function registerSolveTools(server: McpServer): void {
|
|
59
56
|
server.tool(
|
|
60
57
|
"solve",
|
|
61
|
-
"Solve a task by finding the best agent, paying, and executing. The primary way to use the marketplace. If spending confirmation is enabled, returns a price quote first — call again with confirmed: true to execute.",
|
|
58
|
+
"Solve a task by finding the best agent, paying, and executing. The primary way to use the marketplace. If spending confirmation is enabled, returns a price quote first — call again with confirmed: true to execute. Local file paths in the input (e.g. /Users/.../photo.jpg) are automatically uploaded to temporary storage and replaced with download URLs — just pass the path directly, no base64 encoding needed.",
|
|
62
59
|
{
|
|
63
60
|
intent: z
|
|
64
61
|
.string()
|
|
@@ -98,8 +95,14 @@ export function registerSolveTools(server: McpServer): void {
|
|
|
98
95
|
const method = pay_with ?? getConfiguredMethods()[0];
|
|
99
96
|
|
|
100
97
|
// Path 1: If authenticated, use the platform /solve route
|
|
98
|
+
let processedInput: Record<string, unknown>;
|
|
99
|
+
try {
|
|
100
|
+
processedInput = await uploadLocalFiles(input);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
103
|
+
return text(`Error: ${msg}`);
|
|
104
|
+
}
|
|
101
105
|
try {
|
|
102
|
-
const processedInput = await uploadLocalFiles(input);
|
|
103
106
|
const result = await apiPost<Record<string, unknown>>("/solve", {
|
|
104
107
|
intent,
|
|
105
108
|
input: processedInput,
|
|
@@ -115,7 +118,7 @@ export function registerSolveTools(server: McpServer): void {
|
|
|
115
118
|
|
|
116
119
|
const cost = (result as Record<string, unknown>).cost as number | undefined;
|
|
117
120
|
const tipMsg = result.feedback_token ? await autoTip(jobId, agentId, agentName, result.feedback_token as string) : "";
|
|
118
|
-
return
|
|
121
|
+
return multiText(formatRunResult(result), feedbackAsk(jobId, agentId, cost, tipMsg));
|
|
119
122
|
} catch (err: unknown) {
|
|
120
123
|
const isAuthError =
|
|
121
124
|
err instanceof Error &&
|
|
@@ -172,7 +175,13 @@ export function registerSolveTools(server: McpServer): void {
|
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
let result: Record<string, unknown>;
|
|
175
|
-
|
|
178
|
+
let processedInput2: Record<string, unknown>;
|
|
179
|
+
try {
|
|
180
|
+
processedInput2 = await uploadLocalFiles(input);
|
|
181
|
+
} catch (err) {
|
|
182
|
+
const msg = err instanceof Error ? err.message : "File upload failed";
|
|
183
|
+
return text(`Error: ${msg}`);
|
|
184
|
+
}
|
|
176
185
|
try {
|
|
177
186
|
result = await apiPostWithPayment<Record<string, unknown>>(
|
|
178
187
|
`/agents/${selected.id}/run`,
|
|
@@ -208,10 +217,9 @@ export function registerSolveTools(server: McpServer): void {
|
|
|
208
217
|
`Estimated cost: $${estimatedCost.toFixed(4)}`,
|
|
209
218
|
"",
|
|
210
219
|
formatRunResult(result, { paymentMethod: method }),
|
|
211
|
-
feedbackPrompt(jobId, agentId2, selected.name ?? "", actualCost, tipMsg),
|
|
212
220
|
].join("\n");
|
|
213
221
|
|
|
214
|
-
return
|
|
222
|
+
return multiText(output, feedbackAsk(jobId, agentId2, actualCost, tipMsg));
|
|
215
223
|
},
|
|
216
224
|
);
|
|
217
225
|
}
|