@nexvora/mcp-server 0.3.3 → 0.4.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.
|
@@ -4,21 +4,24 @@ declare const InputSchema: z.ZodObject<{
|
|
|
4
4
|
prompt: z.ZodString;
|
|
5
5
|
model: z.ZodOptional<z.ZodEnum<["PLATFORM_CHOICE", "GEMINI_FLASH", "CLAUDE_SONNET", "CLAUDE_OPUS"]>>;
|
|
6
6
|
agentId: z.ZodOptional<z.ZodString>;
|
|
7
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
7
8
|
}, "strip", z.ZodTypeAny, {
|
|
8
9
|
prompt: string;
|
|
9
10
|
agentId?: string | undefined;
|
|
10
11
|
model?: "PLATFORM_CHOICE" | "GEMINI_FLASH" | "CLAUDE_SONNET" | "CLAUDE_OPUS" | undefined;
|
|
12
|
+
timeoutSeconds?: number | undefined;
|
|
11
13
|
}, {
|
|
12
14
|
prompt: string;
|
|
13
15
|
agentId?: string | undefined;
|
|
14
16
|
model?: "PLATFORM_CHOICE" | "GEMINI_FLASH" | "CLAUDE_SONNET" | "CLAUDE_OPUS" | undefined;
|
|
17
|
+
timeoutSeconds?: number | undefined;
|
|
15
18
|
}>;
|
|
16
|
-
interface
|
|
17
|
-
|
|
19
|
+
interface TaskResult {
|
|
20
|
+
taskId: string;
|
|
18
21
|
status: string;
|
|
19
22
|
result?: string;
|
|
20
|
-
|
|
23
|
+
feeCoins?: number;
|
|
21
24
|
}
|
|
22
|
-
export declare const nexvora_submit_task: ToolDefinition<typeof InputSchema,
|
|
25
|
+
export declare const nexvora_submit_task: ToolDefinition<typeof InputSchema, TaskResult>;
|
|
23
26
|
export {};
|
|
24
27
|
//# sourceMappingURL=nexvora_submit_task.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexvora_submit_task.d.ts","sourceRoot":"","sources":["../../src/tools/nexvora_submit_task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"nexvora_submit_task.d.ts","sourceRoot":"","sources":["../../src/tools/nexvora_submit_task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;EAqBf,CAAC;AAgBH,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,OAAO,WAAW,EAAE,UAAU,CAwE9E,CAAC"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
3
|
+
const POLL_INTERVAL_MS = 2_000;
|
|
4
|
+
/**
|
|
5
|
+
* Statuses that mean the task will never produce a result, so we stop polling
|
|
6
|
+
* immediately rather than waiting out the timeout. Matched case-insensitively
|
|
7
|
+
* as substrings so we tolerate the backend's exact enum spelling
|
|
8
|
+
* (FAILED / TIMED_OUT / CANCELLED / EXPIRED / REJECTED / NO_DONOR_*).
|
|
9
|
+
*/
|
|
10
|
+
const TERMINAL_FAILURE = /FAIL|CANCEL|EXPIR|TIMEOUT|TIMED_OUT|REJECT|NO_DONOR|ERROR/;
|
|
2
11
|
const InputSchema = z.object({
|
|
3
12
|
prompt: z.string().min(1).describe("The task prompt to submit to the AI relay"),
|
|
4
13
|
model: z
|
|
@@ -10,19 +19,80 @@ const InputSchema = z.object({
|
|
|
10
19
|
.uuid()
|
|
11
20
|
.optional()
|
|
12
21
|
.describe("UUID of the donor agent to bill; omit for platform billing"),
|
|
22
|
+
timeoutSeconds: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.min(5)
|
|
26
|
+
.max(300)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe("How long to wait for the assigned agent to finish before returning. " +
|
|
29
|
+
"Default 120. The task keeps running server-side even if this elapses."),
|
|
13
30
|
});
|
|
31
|
+
function sleep(ms) {
|
|
32
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33
|
+
}
|
|
14
34
|
export const nexvora_submit_task = {
|
|
15
35
|
name: "nexvora_submit_task",
|
|
16
|
-
description: "Submit an AI task to the NexVora relay network
|
|
17
|
-
"available agent, executes the prompt, and
|
|
18
|
-
"
|
|
36
|
+
description: "Submit an AI task to the NexVora relay network and wait for the result. The " +
|
|
37
|
+
"platform selects the best available agent, executes the prompt, and this tool " +
|
|
38
|
+
"blocks until that agent returns the answer (or the timeout elapses), then returns " +
|
|
39
|
+
"the result text. Coins are deducted from the authenticated user's wallet.",
|
|
19
40
|
inputSchema: InputSchema,
|
|
20
41
|
async handler(input, client) {
|
|
21
|
-
|
|
42
|
+
// 1. Submit. POST /tasks returns immediately with the task id; the assigned
|
|
43
|
+
// agent runs the prompt asynchronously and posts its output later via
|
|
44
|
+
// PATCH /tasks/{id}/result. Returning here (the old behaviour) handed the
|
|
45
|
+
// caller a bare "QUEUED" ack with no answer.
|
|
46
|
+
const submitted = await client.post("/tasks", {
|
|
22
47
|
prompt: input.prompt,
|
|
23
48
|
model: input.model ?? "PLATFORM_CHOICE",
|
|
24
49
|
agentId: input.agentId,
|
|
25
50
|
});
|
|
51
|
+
const taskId = submitted.taskId;
|
|
52
|
+
const timeoutSeconds = input.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS;
|
|
53
|
+
const deadline = Date.now() + timeoutSeconds * 1_000;
|
|
54
|
+
// 2. Poll GET /tasks/{id} until the result lands, a terminal failure state
|
|
55
|
+
// is reached, or we run out of time. GET only carries the decrypted
|
|
56
|
+
// `result` once status is COMPLETED.
|
|
57
|
+
let lastStatus = submitted.status ?? "QUEUED";
|
|
58
|
+
while (Date.now() < deadline) {
|
|
59
|
+
// Check first, sleep after: an already-finished task returns immediately
|
|
60
|
+
// without burning a poll interval, and the sleep is never reached on the
|
|
61
|
+
// happy path (important under fake timers in tests).
|
|
62
|
+
const detail = await client.get(`/tasks/${taskId}`);
|
|
63
|
+
lastStatus = detail.status ?? lastStatus;
|
|
64
|
+
const status = lastStatus.toUpperCase();
|
|
65
|
+
if (detail.result != null && detail.result !== "") {
|
|
66
|
+
return { taskId, status, result: detail.result, feeCoins: detail.feeCoins };
|
|
67
|
+
}
|
|
68
|
+
if (status === "COMPLETED") {
|
|
69
|
+
return {
|
|
70
|
+
taskId,
|
|
71
|
+
status,
|
|
72
|
+
result: detail.result ?? "(completed with empty result)",
|
|
73
|
+
feeCoins: detail.feeCoins,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (TERMINAL_FAILURE.test(status)) {
|
|
77
|
+
return {
|
|
78
|
+
taskId,
|
|
79
|
+
status,
|
|
80
|
+
result: `Task ended as ${status} before producing a result.`,
|
|
81
|
+
feeCoins: detail.feeCoins,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
await sleep(POLL_INTERVAL_MS);
|
|
85
|
+
}
|
|
86
|
+
// 3. Timed out waiting. The task is not cancelled — it keeps running and can
|
|
87
|
+
// be fetched later by id; we just stop blocking the tool call.
|
|
88
|
+
return {
|
|
89
|
+
taskId,
|
|
90
|
+
status: lastStatus.toUpperCase(),
|
|
91
|
+
result: `No agent returned a result within ${timeoutSeconds}s (current status: ` +
|
|
92
|
+
`${lastStatus}). The task is still running server-side; retry later or ` +
|
|
93
|
+
`raise timeoutSeconds. Often this means no donor is currently online for ` +
|
|
94
|
+
`the requested model.`,
|
|
95
|
+
};
|
|
26
96
|
},
|
|
27
97
|
};
|
|
28
98
|
//# sourceMappingURL=nexvora_submit_task.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexvora_submit_task.js","sourceRoot":"","sources":["../../src/tools/nexvora_submit_task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAC/E,KAAK,EAAE,CAAC;SACL,IAAI,CAAC,CAAC,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;SACzE,QAAQ,EAAE;SACV,QAAQ,CAAC,8CAA8C,CAAC;IAC3D,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,IAAI,EAAE;SACN,QAAQ,EAAE;SACV,QAAQ,CAAC,4DAA4D,CAAC;CAC1E,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"nexvora_submit_task.js","sourceRoot":"","sources":["../../src/tools/nexvora_submit_task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,2DAA2D,CAAC;AAErF,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAC/E,KAAK,EAAE,CAAC;SACL,IAAI,CAAC,CAAC,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;SACzE,QAAQ,EAAE;SACV,QAAQ,CAAC,8CAA8C,CAAC;IAC3D,OAAO,EAAE,CAAC;SACP,MAAM,EAAE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