@cavelon/cli 0.2.5 → 0.2.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/commands/api.js +1 -1
- package/dist/confirm-token.js +12 -5
- package/dist/kit-codes.js +1 -1
- package/dist/mcp.js +14 -4
- package/dist/native-assets/THIRD-PARTY-NOTICES +2 -2
- package/dist/native-assets/kilo-server.mjs +32 -9
- package/dist/native-assets/kilo-tui.mjs +32 -9
- package/dist/native-assets/manifest.json +14 -14
- package/dist/native-assets/omp-extension.mjs +73 -66
- package/dist/native-assets/opencode-server.mjs +32 -9
- package/dist/native-assets/opencode-tui.mjs +32 -9
- package/dist/native-assets/pi-extension.mjs +73 -66
- package/dist/openapi.js +7 -3
- package/package.json +2 -2
package/dist/commands/api.js
CHANGED
|
@@ -278,7 +278,7 @@ export const api = {
|
|
|
278
278
|
const secrets = secretsIn(doc, op, args);
|
|
279
279
|
if (secrets.length)
|
|
280
280
|
throw secretRefusal(op, secrets);
|
|
281
|
-
if (driven && !op.readOnly) {
|
|
281
|
+
if (driven && (!op.readOnly || op.method === "POST")) {
|
|
282
282
|
const words = [
|
|
283
283
|
"api",
|
|
284
284
|
name,
|
package/dist/confirm-token.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { PERSON_WAIT_MS } from "./approval-policy.js";
|
|
3
2
|
import { actingTarget, targetLine } from "./acting.js";
|
|
4
3
|
import { drivenByAgent } from "./agent-env.js";
|
|
5
4
|
import { CavelonError, ExitCode } from "./errors.js";
|
|
@@ -119,11 +118,19 @@ export async function personApproves(ctx, driven, change, target = {}) {
|
|
|
119
118
|
ctx.approved = { guarded: change.guarded ?? true };
|
|
120
119
|
return;
|
|
121
120
|
}
|
|
121
|
+
if (answer === "unavailable" || answer === "unanswered") {
|
|
122
|
+
throw new CavelonError(ExitCode.needsAction, {
|
|
123
|
+
code: "confirm_needs_person",
|
|
124
|
+
message: answer === "unavailable"
|
|
125
|
+
? "The MCP client could not obtain a usable approval answer; nothing was changed. The person confirms in their own terminal."
|
|
126
|
+
: "The dialog was cancelled or returned no approval answer; nothing was changed. The person can confirm in their own terminal.",
|
|
127
|
+
hint: `Show the person the preview and this command to run themselves: ${change.command}`,
|
|
128
|
+
details: { answer, needs_person: "terminal", person_command: change.command },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
122
131
|
throw new CavelonError(ExitCode.needsAction, {
|
|
123
132
|
code: "confirm_declined",
|
|
124
|
-
message:
|
|
125
|
-
? "The person did not approve the change; nothing was changed."
|
|
126
|
-
: `The person did not answer within ${PERSON_WAIT_MS / 60_000} minutes, or the client could not ask; nothing was changed.`,
|
|
133
|
+
message: "The MCP client returned an explicit decline; nothing was changed.",
|
|
127
134
|
hint: `Ask the person whether they want it. With their yes, call ${change.tool} again with the same confirm token, or they run ${change.command} in their own terminal.`,
|
|
128
135
|
details: { answer, person_command: change.command },
|
|
129
136
|
});
|
|
@@ -133,7 +140,7 @@ export function needsPerson(command) {
|
|
|
133
140
|
code: "confirm_needs_person",
|
|
134
141
|
message: `A coding agent cannot confirm this change; nothing was changed. The person confirms it in their own terminal: ${command}`,
|
|
135
142
|
hint: "Show the person the preview and the command; they run it themselves, outside the agent.",
|
|
136
|
-
details: { person_command: command },
|
|
143
|
+
details: { needs_person: "terminal", person_command: command },
|
|
137
144
|
});
|
|
138
145
|
}
|
|
139
146
|
export function confirmThroughClient(tool, token) {
|
package/dist/kit-codes.js
CHANGED
|
@@ -67,7 +67,7 @@ export const KIT_ERROR_CODES = [
|
|
|
67
67
|
{ code: "confirm_token_required", area: "cli", message: "Over MCP, or run by a coding agent in its shell, a changing command confirms only with the token its preview returned, never with true or a bare --confirm.", hint: "Call the tool (or run the command) without confirm, show the person the preview, then call it again with the same arguments and confirm set to its confirm_token (--confirm <token> in a shell)." },
|
|
68
68
|
{ code: "confirm_needs_person", area: "cli", message: "A coding agent cannot confirm this change, even with its preview's token: it reaches live traffic or the whole tenant, or cannot be taken back, and the agent's MCP client cannot ask the person (or the agent runs cavelon in its shell). Nothing was changed.", hint: "Show the person the preview; they run the command the refusal names in their own terminal, outside the agent." },
|
|
69
69
|
{ code: "native_ui_disconnected", area: "cli", message: "The native person UI call failed after routing. Its outcome may be unknown, so the adapter never retries through another connection.", hint: "Inspect the instance's current state before repeating the change. Reconnect the client; a new guarded attempt needs a fresh preview and person answer." },
|
|
70
|
-
{ code: "confirm_declined", area: "cli", message: "The MCP client
|
|
70
|
+
{ code: "confirm_declined", area: "cli", message: "The MCP client returned an explicit decline to the change. Nothing was changed.", hint: "Do not retry automatically. A new attempt needs the person's request and a fresh dialog answer, or they run the exact command in their own terminal." },
|
|
71
71
|
{ code: "token_mismatch", area: "cli", message: "The confirm token is not the one for this change: it belongs to another preview, or the change differs from what its preview showed; nothing was changed (exit code 4).", hint: "Show the person the new preview this answer carries, and confirm only with its confirm_token after their yes; a token confirms exactly the change its preview showed." },
|
|
72
72
|
{ code: "unknown_argument", area: "cli", message: "An MCP tool was called with an argument its schema does not list; nothing was done.", hint: "Call it again with the argument the error names (the tool's schema lists them all), spelled in snake_case." },
|
|
73
73
|
{ code: "solution_not_active", area: "cli", message: "Only an active solution can be the tenant's default route; this one is not (a draft, or inactive after a deactivate), so nothing was changed.", hint: "Activate it through the readiness gate and preview the default route in one step: `cavelon activate --harness <slug> --make-default`." },
|
package/dist/mcp.js
CHANGED
|
@@ -230,10 +230,14 @@ function clientAsks(server) {
|
|
|
230
230
|
async function askThroughClient(server, message, relatedRequestId) {
|
|
231
231
|
try {
|
|
232
232
|
const result = await server.elicitInput({ mode: "form", message, requestedSchema: APPROVAL_SCHEMA }, { timeout: PERSON_WAIT_MS, relatedRequestId });
|
|
233
|
-
|
|
233
|
+
if (result.action === "accept" && result.content?.approve === true)
|
|
234
|
+
return "approved";
|
|
235
|
+
if (result.action === "decline" || result.action === "accept" && result.content?.approve === false)
|
|
236
|
+
return "declined";
|
|
237
|
+
return result.action === "cancel" ? "unanswered" : "unavailable";
|
|
234
238
|
}
|
|
235
239
|
catch {
|
|
236
|
-
return "
|
|
240
|
+
return "unavailable";
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
function mcpIo(io) {
|
|
@@ -245,6 +249,7 @@ export function createMcpServer(io, commands, updates = {}, startup = {}) {
|
|
|
245
249
|
const server = new Server({ name: "cavelon", version: KIT_VERSION }, { capabilities: { tools: { listChanged: true } }, instructions: mcpInstructions(commands) });
|
|
246
250
|
const notice = startSessionUpdateCheck(io, updates);
|
|
247
251
|
const sessionTenants = new Map();
|
|
252
|
+
let clientUiUnavailable = false;
|
|
248
253
|
const launch = createContext(mcpIo(io), { ...startup, json: true }, "mcp").globals;
|
|
249
254
|
async function credentialAccess() {
|
|
250
255
|
const read = (async () => {
|
|
@@ -297,8 +302,13 @@ export function createMcpServer(io, commands, updates = {}, startup = {}) {
|
|
|
297
302
|
return fail(error);
|
|
298
303
|
}
|
|
299
304
|
const ctx = createContext(mcpIo(folder.io), { ...launch, json: true, tenant: tenant ?? launch.tenant, solutionEnv: solutionEnv ?? launch.solutionEnv, sessionTenants }, "mcp");
|
|
300
|
-
if (clientAsks(server))
|
|
301
|
-
ctx.askPerson = (message) =>
|
|
305
|
+
if (!clientUiUnavailable && clientAsks(server))
|
|
306
|
+
ctx.askPerson = async (message) => {
|
|
307
|
+
const answer = await askThroughClient(server, message, requestId);
|
|
308
|
+
if (answer === "unavailable")
|
|
309
|
+
clientUiUnavailable = true;
|
|
310
|
+
return answer;
|
|
311
|
+
};
|
|
302
312
|
for (const message of renamed)
|
|
303
313
|
ctx.warn(message);
|
|
304
314
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@modelcontextprotocol/sdk 1.
|
|
1
|
+
@modelcontextprotocol/sdk 1.32.1
|
|
2
2
|
MIT License
|
|
3
3
|
|
|
4
4
|
Copyright (c) 2024 Anthropic, PBC
|
|
@@ -277,7 +277,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
277
277
|
|
|
278
278
|
---
|
|
279
279
|
|
|
280
|
-
typebox 1.3.
|
|
280
|
+
typebox 1.3.36
|
|
281
281
|
TypeBox
|
|
282
282
|
|
|
283
283
|
The MIT License (MIT)
|
|
@@ -36355,6 +36355,9 @@ var Protocol = class {
|
|
|
36355
36355
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
36356
36356
|
const handleTaskResult = async () => {
|
|
36357
36357
|
const taskId = request.params.taskId;
|
|
36358
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
36359
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
36360
|
+
}
|
|
36358
36361
|
if (this._taskMessageQueue) {
|
|
36359
36362
|
let queuedMessage;
|
|
36360
36363
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -36385,12 +36388,12 @@ var Protocol = class {
|
|
|
36385
36388
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
36386
36389
|
}
|
|
36387
36390
|
if (!isTerminal(task.status)) {
|
|
36388
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
36391
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
36389
36392
|
return await handleTaskResult();
|
|
36390
36393
|
}
|
|
36391
36394
|
if (isTerminal(task.status)) {
|
|
36392
36395
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
36393
|
-
this._clearTaskQueue(taskId);
|
|
36396
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
36394
36397
|
return {
|
|
36395
36398
|
...result,
|
|
36396
36399
|
_meta: {
|
|
@@ -36427,7 +36430,7 @@ var Protocol = class {
|
|
|
36427
36430
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
36428
36431
|
}
|
|
36429
36432
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
36430
|
-
this._clearTaskQueue(request.params.taskId);
|
|
36433
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
36431
36434
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
36432
36435
|
if (!cancelledTask) {
|
|
36433
36436
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -36555,6 +36558,19 @@ var Protocol = class {
|
|
|
36555
36558
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
36556
36559
|
const capturedTransport = this._transport;
|
|
36557
36560
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
36561
|
+
const sessionId = capturedTransport?.sessionId;
|
|
36562
|
+
const store = this._taskStore;
|
|
36563
|
+
let relatedTaskFound = true;
|
|
36564
|
+
let relatedTaskLookup;
|
|
36565
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
36566
|
+
relatedTaskFound = false;
|
|
36567
|
+
relatedTaskLookup = (async () => {
|
|
36568
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
36569
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
36570
|
+
}
|
|
36571
|
+
relatedTaskFound = true;
|
|
36572
|
+
})();
|
|
36573
|
+
}
|
|
36558
36574
|
if (handler === void 0) {
|
|
36559
36575
|
const errorResponse = {
|
|
36560
36576
|
jsonrpc: "2.0",
|
|
@@ -36564,7 +36580,10 @@ var Protocol = class {
|
|
|
36564
36580
|
message: "Method not found"
|
|
36565
36581
|
}
|
|
36566
36582
|
};
|
|
36567
|
-
if (relatedTaskId &&
|
|
36583
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
36584
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
36585
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error62) => this._onerror(new Error(`Failed to send an error response: ${error62}`)));
|
|
36586
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
36568
36587
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
36569
36588
|
type: "error",
|
|
36570
36589
|
message: errorResponse,
|
|
@@ -36615,7 +36634,10 @@ var Protocol = class {
|
|
|
36615
36634
|
closeSSEStream: extra?.closeSSEStream,
|
|
36616
36635
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
36617
36636
|
};
|
|
36618
|
-
Promise.resolve().then(() => {
|
|
36637
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
36638
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
36639
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
36640
|
+
}
|
|
36619
36641
|
if (taskCreationParams) {
|
|
36620
36642
|
this.assertTaskHandlerCapability(request.method);
|
|
36621
36643
|
}
|
|
@@ -36650,7 +36672,7 @@ var Protocol = class {
|
|
|
36650
36672
|
...error62["data"] !== void 0 && { data: error62["data"] }
|
|
36651
36673
|
}
|
|
36652
36674
|
};
|
|
36653
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
36675
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
36654
36676
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
36655
36677
|
type: "error",
|
|
36656
36678
|
message: errorResponse,
|
|
@@ -37130,7 +37152,7 @@ var Protocol = class {
|
|
|
37130
37152
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
37131
37153
|
}
|
|
37132
37154
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
37133
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
37155
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
37134
37156
|
}
|
|
37135
37157
|
/**
|
|
37136
37158
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -37159,12 +37181,13 @@ var Protocol = class {
|
|
|
37159
37181
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
37160
37182
|
* @param taskId The task ID to wait for
|
|
37161
37183
|
* @param signal Abort signal to cancel the wait
|
|
37184
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
37162
37185
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
37163
37186
|
*/
|
|
37164
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
37187
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
37165
37188
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
37166
37189
|
try {
|
|
37167
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
37190
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
37168
37191
|
if (task?.pollInterval) {
|
|
37169
37192
|
interval = task.pollInterval;
|
|
37170
37193
|
}
|
|
@@ -23052,6 +23052,9 @@ var Protocol = class {
|
|
|
23052
23052
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
23053
23053
|
const handleTaskResult = async () => {
|
|
23054
23054
|
const taskId = request.params.taskId;
|
|
23055
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
23056
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
23057
|
+
}
|
|
23055
23058
|
if (this._taskMessageQueue) {
|
|
23056
23059
|
let queuedMessage;
|
|
23057
23060
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -23082,12 +23085,12 @@ var Protocol = class {
|
|
|
23082
23085
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
23083
23086
|
}
|
|
23084
23087
|
if (!isTerminal(task.status)) {
|
|
23085
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
23088
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
23086
23089
|
return await handleTaskResult();
|
|
23087
23090
|
}
|
|
23088
23091
|
if (isTerminal(task.status)) {
|
|
23089
23092
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
23090
|
-
this._clearTaskQueue(taskId);
|
|
23093
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
23091
23094
|
return {
|
|
23092
23095
|
...result,
|
|
23093
23096
|
_meta: {
|
|
@@ -23124,7 +23127,7 @@ var Protocol = class {
|
|
|
23124
23127
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
23125
23128
|
}
|
|
23126
23129
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
23127
|
-
this._clearTaskQueue(request.params.taskId);
|
|
23130
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
23128
23131
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
23129
23132
|
if (!cancelledTask) {
|
|
23130
23133
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -23252,6 +23255,19 @@ var Protocol = class {
|
|
|
23252
23255
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
23253
23256
|
const capturedTransport = this._transport;
|
|
23254
23257
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
23258
|
+
const sessionId = capturedTransport?.sessionId;
|
|
23259
|
+
const store = this._taskStore;
|
|
23260
|
+
let relatedTaskFound = true;
|
|
23261
|
+
let relatedTaskLookup;
|
|
23262
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
23263
|
+
relatedTaskFound = false;
|
|
23264
|
+
relatedTaskLookup = (async () => {
|
|
23265
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
23266
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
23267
|
+
}
|
|
23268
|
+
relatedTaskFound = true;
|
|
23269
|
+
})();
|
|
23270
|
+
}
|
|
23255
23271
|
if (handler === void 0) {
|
|
23256
23272
|
const errorResponse = {
|
|
23257
23273
|
jsonrpc: "2.0",
|
|
@@ -23261,7 +23277,10 @@ var Protocol = class {
|
|
|
23261
23277
|
message: "Method not found"
|
|
23262
23278
|
}
|
|
23263
23279
|
};
|
|
23264
|
-
if (relatedTaskId &&
|
|
23280
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
23281
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
23282
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
23283
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
23265
23284
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
23266
23285
|
type: "error",
|
|
23267
23286
|
message: errorResponse,
|
|
@@ -23312,7 +23331,10 @@ var Protocol = class {
|
|
|
23312
23331
|
closeSSEStream: extra?.closeSSEStream,
|
|
23313
23332
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
23314
23333
|
};
|
|
23315
|
-
Promise.resolve().then(() => {
|
|
23334
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
23335
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
23336
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
23337
|
+
}
|
|
23316
23338
|
if (taskCreationParams) {
|
|
23317
23339
|
this.assertTaskHandlerCapability(request.method);
|
|
23318
23340
|
}
|
|
@@ -23347,7 +23369,7 @@ var Protocol = class {
|
|
|
23347
23369
|
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
23348
23370
|
}
|
|
23349
23371
|
};
|
|
23350
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
23372
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
23351
23373
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
23352
23374
|
type: "error",
|
|
23353
23375
|
message: errorResponse,
|
|
@@ -23827,7 +23849,7 @@ var Protocol = class {
|
|
|
23827
23849
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
23828
23850
|
}
|
|
23829
23851
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
23830
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
23852
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
23831
23853
|
}
|
|
23832
23854
|
/**
|
|
23833
23855
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -23856,12 +23878,13 @@ var Protocol = class {
|
|
|
23856
23878
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
23857
23879
|
* @param taskId The task ID to wait for
|
|
23858
23880
|
* @param signal Abort signal to cancel the wait
|
|
23881
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
23859
23882
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
23860
23883
|
*/
|
|
23861
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
23884
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
23862
23885
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
23863
23886
|
try {
|
|
23864
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
23887
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
23865
23888
|
if (task?.pollInterval) {
|
|
23866
23889
|
interval = task.pollInterval;
|
|
23867
23890
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"entries": {
|
|
5
5
|
"omp": [
|
|
6
6
|
"omp-extension.mjs"
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": "kilo-server.mjs",
|
|
28
|
-
"size":
|
|
29
|
-
"sha256": "
|
|
28
|
+
"size": 1494321,
|
|
29
|
+
"sha256": "d17dee519e66697ae62a55d8d2e8d4ac411c682b947cedd235e6bc52a688d06e"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"path": "kilo-tui.mjs",
|
|
33
|
-
"size":
|
|
34
|
-
"sha256": "
|
|
33
|
+
"size": 940457,
|
|
34
|
+
"sha256": "6dce9d0bc29e9a46bb40f98c914a13d5238a9e12e52c842aaa975bcca8e2ce75"
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"path": "LICENSE",
|
|
@@ -45,28 +45,28 @@
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
"path": "omp-extension.mjs",
|
|
48
|
-
"size":
|
|
49
|
-
"sha256": "
|
|
48
|
+
"size": 1148227,
|
|
49
|
+
"sha256": "99f8e790e70fe7a72cd1affde628ea0e52fd0642db8a0084bf2791ce803e4410"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
"path": "opencode-server.mjs",
|
|
53
|
-
"size":
|
|
54
|
-
"sha256": "
|
|
53
|
+
"size": 1493309,
|
|
54
|
+
"sha256": "4829901f1c5bbe0d96156297cd11cc8cfa08f44d1a3110743e6c9316ec3fe09a"
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"path": "opencode-tui.mjs",
|
|
58
|
-
"size":
|
|
59
|
-
"sha256": "
|
|
58
|
+
"size": 940363,
|
|
59
|
+
"sha256": "ffc26d95060ec653b81789022496a90a1eb25bac23075a5f05025fa1ba97e038"
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"path": "pi-extension.mjs",
|
|
63
|
-
"size":
|
|
64
|
-
"sha256": "
|
|
63
|
+
"size": 1148135,
|
|
64
|
+
"sha256": "a45ae3ea3a8de1edb7399ddecac8544d986a73b93a55605685569d6afd711bee"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"path": "THIRD-PARTY-NOTICES",
|
|
68
68
|
"size": 18303,
|
|
69
|
-
"sha256": "
|
|
69
|
+
"sha256": "f12be1a7c8faec83012f2f31ad0d20d1d92cab7d419582c5adb2f71721f6b04e"
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"path": "TYPEBOX-LICENSE",
|
|
@@ -15066,6 +15066,7 @@ __export(settings_exports, {
|
|
|
15066
15066
|
// node_modules/typebox/build/guard/guard.mjs
|
|
15067
15067
|
var guard_exports = {};
|
|
15068
15068
|
__export(guard_exports, {
|
|
15069
|
+
CodePointCount: () => CodePointCount2,
|
|
15069
15070
|
Counted: () => Counted,
|
|
15070
15071
|
Entries: () => Entries,
|
|
15071
15072
|
EntriesRegExp: () => EntriesRegExp,
|
|
@@ -15106,16 +15107,13 @@ __export(guard_exports, {
|
|
|
15106
15107
|
Values: () => Values
|
|
15107
15108
|
});
|
|
15108
15109
|
|
|
15109
|
-
// node_modules/typebox/build/guard/
|
|
15110
|
+
// node_modules/typebox/build/guard/unicode/unicode_segment.mjs
|
|
15110
15111
|
function IsBetween(value, min, max) {
|
|
15111
15112
|
return value >= min && value <= max;
|
|
15112
15113
|
}
|
|
15113
15114
|
function IsZeroWidthJoiner(value) {
|
|
15114
15115
|
return value === 8205;
|
|
15115
15116
|
}
|
|
15116
|
-
function IsHighSurrogate(value) {
|
|
15117
|
-
return IsBetween(value, 55296, 56319);
|
|
15118
|
-
}
|
|
15119
15117
|
function IsRegionalIndicator(value) {
|
|
15120
15118
|
return IsBetween(value, 127462, 127487);
|
|
15121
15119
|
}
|
|
@@ -15153,64 +15151,30 @@ function NextGraphemeClusterIndex(value, clusterStart) {
|
|
|
15153
15151
|
}
|
|
15154
15152
|
return clusterEnd;
|
|
15155
15153
|
}
|
|
15156
|
-
function IsGraphemeCodePoint(value) {
|
|
15157
|
-
return value >= 768 && // above special range
|
|
15158
|
-
(IsHighSurrogate(value) || IsCombiningMark(value) || IsVariationSelector(value) || IsZeroWidthJoiner(value));
|
|
15159
|
-
}
|
|
15160
15154
|
function GraphemeCount(value) {
|
|
15161
|
-
let count = 0;
|
|
15162
|
-
let index = 0;
|
|
15155
|
+
let count = 0, index = 0;
|
|
15163
15156
|
while (index < value.length) {
|
|
15164
15157
|
index = NextGraphemeClusterIndex(value, index);
|
|
15165
15158
|
count++;
|
|
15166
15159
|
}
|
|
15167
15160
|
return count;
|
|
15168
15161
|
}
|
|
15169
|
-
|
|
15170
|
-
|
|
15171
|
-
|
|
15162
|
+
|
|
15163
|
+
// node_modules/typebox/build/guard/unicode/unicode.mjs
|
|
15164
|
+
function CodePointCount(value) {
|
|
15165
|
+
let result = 0, index = 0, prev = 0;
|
|
15172
15166
|
while (index < value.length) {
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15167
|
+
const next = value.charCodeAt(index++) >> 10;
|
|
15168
|
+
result += +((prev << 8 | next) !== 13879);
|
|
15169
|
+
prev = next;
|
|
15176
15170
|
}
|
|
15177
|
-
return
|
|
15171
|
+
return result;
|
|
15178
15172
|
}
|
|
15179
|
-
function
|
|
15180
|
-
|
|
15181
|
-
let index = 0;
|
|
15182
|
-
while (index < value.length) {
|
|
15183
|
-
index = NextGraphemeClusterIndex(value, index);
|
|
15184
|
-
if (++count > maxLength)
|
|
15185
|
-
return false;
|
|
15186
|
-
}
|
|
15187
|
-
return true;
|
|
15173
|
+
function IsMaxLength(value, maxLength) {
|
|
15174
|
+
return value.length <= maxLength || value.length <= maxLength << 1 && CodePointCount(value) <= maxLength;
|
|
15188
15175
|
}
|
|
15189
15176
|
function IsMinLength(value, minLength) {
|
|
15190
|
-
|
|
15191
|
-
return true;
|
|
15192
|
-
if (value.length < minLength)
|
|
15193
|
-
return false;
|
|
15194
|
-
let index = 0;
|
|
15195
|
-
while (true) {
|
|
15196
|
-
if (IsGraphemeCodePoint(value.charCodeAt(index))) {
|
|
15197
|
-
return IsMinLengthSegmented(value, minLength);
|
|
15198
|
-
}
|
|
15199
|
-
if (++index >= minLength)
|
|
15200
|
-
return true;
|
|
15201
|
-
}
|
|
15202
|
-
}
|
|
15203
|
-
function IsMaxLength(value, maxLength) {
|
|
15204
|
-
if (value.length <= maxLength)
|
|
15205
|
-
return true;
|
|
15206
|
-
let index = 0;
|
|
15207
|
-
while (true) {
|
|
15208
|
-
if (IsGraphemeCodePoint(value.charCodeAt(index))) {
|
|
15209
|
-
return IsMaxLengthSegmented(value, maxLength);
|
|
15210
|
-
}
|
|
15211
|
-
if (++index > maxLength)
|
|
15212
|
-
return false;
|
|
15213
|
-
}
|
|
15177
|
+
return value.length >= minLength << 1 || value.length >= minLength && CodePointCount(value) >= minLength;
|
|
15214
15178
|
}
|
|
15215
15179
|
|
|
15216
15180
|
// node_modules/typebox/build/guard/guard.mjs
|
|
@@ -15301,11 +15265,14 @@ function IsValueLike(value) {
|
|
|
15301
15265
|
function GraphemeCount2(value) {
|
|
15302
15266
|
return GraphemeCount(value);
|
|
15303
15267
|
}
|
|
15304
|
-
function
|
|
15305
|
-
return
|
|
15268
|
+
function CodePointCount2(value) {
|
|
15269
|
+
return CodePointCount(value);
|
|
15306
15270
|
}
|
|
15307
|
-
function
|
|
15308
|
-
return
|
|
15271
|
+
function IsMaxLength2(value, maxLength) {
|
|
15272
|
+
return IsMaxLength(value, maxLength);
|
|
15273
|
+
}
|
|
15274
|
+
function IsMinLength2(value, minLength) {
|
|
15275
|
+
return IsMinLength(value, minLength);
|
|
15309
15276
|
}
|
|
15310
15277
|
function Every(value, offset, callback) {
|
|
15311
15278
|
return value.every((item, index) => index < offset || callback(item, index));
|
|
@@ -15454,6 +15421,7 @@ function IsMap(value) {
|
|
|
15454
15421
|
var settings = {
|
|
15455
15422
|
immutableTypes: false,
|
|
15456
15423
|
maxErrors: 8,
|
|
15424
|
+
maxParseErrors: 1,
|
|
15457
15425
|
maxInstantiationCount: 128,
|
|
15458
15426
|
useAcceleration: true,
|
|
15459
15427
|
exactOptionalPropertyTypes: false,
|
|
@@ -15464,6 +15432,7 @@ var settings = {
|
|
|
15464
15432
|
function Reset() {
|
|
15465
15433
|
settings.immutableTypes = false;
|
|
15466
15434
|
settings.maxErrors = 8;
|
|
15435
|
+
settings.maxParseErrors = 1;
|
|
15467
15436
|
settings.maxInstantiationCount = 128;
|
|
15468
15437
|
settings.useAcceleration = true;
|
|
15469
15438
|
settings.exactOptionalPropertyTypes = false;
|
|
@@ -17739,8 +17708,14 @@ function TryRestInferable(type) {
|
|
|
17739
17708
|
function TryInferable(type) {
|
|
17740
17709
|
return IsInfer(type) ? Inferrable(type.name, type.extends) : void 0;
|
|
17741
17710
|
}
|
|
17742
|
-
function TryInferResults(rest, right
|
|
17743
|
-
|
|
17711
|
+
function TryInferResults(rest, right) {
|
|
17712
|
+
const result = [];
|
|
17713
|
+
for (const head of rest) {
|
|
17714
|
+
if (!IsExtendsTrueLike(ExtendsLeft({}, head, right)))
|
|
17715
|
+
return void 0;
|
|
17716
|
+
result.push(head);
|
|
17717
|
+
}
|
|
17718
|
+
return result;
|
|
17744
17719
|
}
|
|
17745
17720
|
function InferTupleResult(inferred, name, left, right) {
|
|
17746
17721
|
const results = TryInferResults(left, right);
|
|
@@ -17784,9 +17759,18 @@ function ExtendsTupleToTuple(inferred, left, right) {
|
|
|
17784
17759
|
const reversed = Reversed(instantiatedRight);
|
|
17785
17760
|
return Elements(inferred, reversed, ApplyReverse(left, reversed), ApplyReverse(instantiatedRight, reversed));
|
|
17786
17761
|
}
|
|
17762
|
+
function ExtendsTupleToArrayReduce(inferred, left, right) {
|
|
17763
|
+
for (const head of left) {
|
|
17764
|
+
const result = ExtendsLeft(inferred, head, right);
|
|
17765
|
+
if (!IsExtendsTrueLike(result))
|
|
17766
|
+
return result;
|
|
17767
|
+
inferred = result.inferred;
|
|
17768
|
+
}
|
|
17769
|
+
return ExtendsTrue(inferred);
|
|
17770
|
+
}
|
|
17787
17771
|
function ExtendsTupleToArray(inferred, left, right) {
|
|
17788
17772
|
const inferrable = TryInferable(right);
|
|
17789
|
-
return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) :
|
|
17773
|
+
return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) : ExtendsTupleToArrayReduce(inferred, left, right);
|
|
17790
17774
|
}
|
|
17791
17775
|
function ExtendsTuple(inferred, left, right) {
|
|
17792
17776
|
const instantiatedLeft = InstantiateElements(inferred, State([], []), left);
|
|
@@ -27456,6 +27440,9 @@ var Protocol = class {
|
|
|
27456
27440
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
27457
27441
|
const handleTaskResult = async () => {
|
|
27458
27442
|
const taskId = request.params.taskId;
|
|
27443
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
27444
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
27445
|
+
}
|
|
27459
27446
|
if (this._taskMessageQueue) {
|
|
27460
27447
|
let queuedMessage;
|
|
27461
27448
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -27486,12 +27473,12 @@ var Protocol = class {
|
|
|
27486
27473
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
27487
27474
|
}
|
|
27488
27475
|
if (!isTerminal(task.status)) {
|
|
27489
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
27476
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
27490
27477
|
return await handleTaskResult();
|
|
27491
27478
|
}
|
|
27492
27479
|
if (isTerminal(task.status)) {
|
|
27493
27480
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
27494
|
-
this._clearTaskQueue(taskId);
|
|
27481
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
27495
27482
|
return {
|
|
27496
27483
|
...result,
|
|
27497
27484
|
_meta: {
|
|
@@ -27528,7 +27515,7 @@ var Protocol = class {
|
|
|
27528
27515
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
27529
27516
|
}
|
|
27530
27517
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
27531
|
-
this._clearTaskQueue(request.params.taskId);
|
|
27518
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
27532
27519
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
27533
27520
|
if (!cancelledTask) {
|
|
27534
27521
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -27656,6 +27643,19 @@ var Protocol = class {
|
|
|
27656
27643
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
27657
27644
|
const capturedTransport = this._transport;
|
|
27658
27645
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
27646
|
+
const sessionId = capturedTransport?.sessionId;
|
|
27647
|
+
const store = this._taskStore;
|
|
27648
|
+
let relatedTaskFound = true;
|
|
27649
|
+
let relatedTaskLookup;
|
|
27650
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
27651
|
+
relatedTaskFound = false;
|
|
27652
|
+
relatedTaskLookup = (async () => {
|
|
27653
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
27654
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
27655
|
+
}
|
|
27656
|
+
relatedTaskFound = true;
|
|
27657
|
+
})();
|
|
27658
|
+
}
|
|
27659
27659
|
if (handler === void 0) {
|
|
27660
27660
|
const errorResponse = {
|
|
27661
27661
|
jsonrpc: "2.0",
|
|
@@ -27665,7 +27665,10 @@ var Protocol = class {
|
|
|
27665
27665
|
message: "Method not found"
|
|
27666
27666
|
}
|
|
27667
27667
|
};
|
|
27668
|
-
if (relatedTaskId &&
|
|
27668
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
27669
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
27670
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
27671
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
27669
27672
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
27670
27673
|
type: "error",
|
|
27671
27674
|
message: errorResponse,
|
|
@@ -27716,7 +27719,10 @@ var Protocol = class {
|
|
|
27716
27719
|
closeSSEStream: extra?.closeSSEStream,
|
|
27717
27720
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
27718
27721
|
};
|
|
27719
|
-
Promise.resolve().then(() => {
|
|
27722
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
27723
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
27724
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
27725
|
+
}
|
|
27720
27726
|
if (taskCreationParams) {
|
|
27721
27727
|
this.assertTaskHandlerCapability(request.method);
|
|
27722
27728
|
}
|
|
@@ -27751,7 +27757,7 @@ var Protocol = class {
|
|
|
27751
27757
|
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
27752
27758
|
}
|
|
27753
27759
|
};
|
|
27754
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
27760
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
27755
27761
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
27756
27762
|
type: "error",
|
|
27757
27763
|
message: errorResponse,
|
|
@@ -28231,7 +28237,7 @@ var Protocol = class {
|
|
|
28231
28237
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
28232
28238
|
}
|
|
28233
28239
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
28234
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
28240
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
28235
28241
|
}
|
|
28236
28242
|
/**
|
|
28237
28243
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -28260,12 +28266,13 @@ var Protocol = class {
|
|
|
28260
28266
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
28261
28267
|
* @param taskId The task ID to wait for
|
|
28262
28268
|
* @param signal Abort signal to cancel the wait
|
|
28269
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
28263
28270
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
28264
28271
|
*/
|
|
28265
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
28272
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
28266
28273
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
28267
28274
|
try {
|
|
28268
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
28275
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
28269
28276
|
if (task?.pollInterval) {
|
|
28270
28277
|
interval = task.pollInterval;
|
|
28271
28278
|
}
|
|
@@ -36355,6 +36355,9 @@ var Protocol = class {
|
|
|
36355
36355
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
36356
36356
|
const handleTaskResult = async () => {
|
|
36357
36357
|
const taskId = request.params.taskId;
|
|
36358
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
36359
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
36360
|
+
}
|
|
36358
36361
|
if (this._taskMessageQueue) {
|
|
36359
36362
|
let queuedMessage;
|
|
36360
36363
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -36385,12 +36388,12 @@ var Protocol = class {
|
|
|
36385
36388
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
36386
36389
|
}
|
|
36387
36390
|
if (!isTerminal(task.status)) {
|
|
36388
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
36391
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
36389
36392
|
return await handleTaskResult();
|
|
36390
36393
|
}
|
|
36391
36394
|
if (isTerminal(task.status)) {
|
|
36392
36395
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
36393
|
-
this._clearTaskQueue(taskId);
|
|
36396
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
36394
36397
|
return {
|
|
36395
36398
|
...result,
|
|
36396
36399
|
_meta: {
|
|
@@ -36427,7 +36430,7 @@ var Protocol = class {
|
|
|
36427
36430
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
36428
36431
|
}
|
|
36429
36432
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
36430
|
-
this._clearTaskQueue(request.params.taskId);
|
|
36433
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
36431
36434
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
36432
36435
|
if (!cancelledTask) {
|
|
36433
36436
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -36555,6 +36558,19 @@ var Protocol = class {
|
|
|
36555
36558
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
36556
36559
|
const capturedTransport = this._transport;
|
|
36557
36560
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
36561
|
+
const sessionId = capturedTransport?.sessionId;
|
|
36562
|
+
const store = this._taskStore;
|
|
36563
|
+
let relatedTaskFound = true;
|
|
36564
|
+
let relatedTaskLookup;
|
|
36565
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
36566
|
+
relatedTaskFound = false;
|
|
36567
|
+
relatedTaskLookup = (async () => {
|
|
36568
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
36569
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
36570
|
+
}
|
|
36571
|
+
relatedTaskFound = true;
|
|
36572
|
+
})();
|
|
36573
|
+
}
|
|
36558
36574
|
if (handler === void 0) {
|
|
36559
36575
|
const errorResponse = {
|
|
36560
36576
|
jsonrpc: "2.0",
|
|
@@ -36564,7 +36580,10 @@ var Protocol = class {
|
|
|
36564
36580
|
message: "Method not found"
|
|
36565
36581
|
}
|
|
36566
36582
|
};
|
|
36567
|
-
if (relatedTaskId &&
|
|
36583
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
36584
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
36585
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error62) => this._onerror(new Error(`Failed to send an error response: ${error62}`)));
|
|
36586
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
36568
36587
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
36569
36588
|
type: "error",
|
|
36570
36589
|
message: errorResponse,
|
|
@@ -36615,7 +36634,10 @@ var Protocol = class {
|
|
|
36615
36634
|
closeSSEStream: extra?.closeSSEStream,
|
|
36616
36635
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
36617
36636
|
};
|
|
36618
|
-
Promise.resolve().then(() => {
|
|
36637
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
36638
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
36639
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
36640
|
+
}
|
|
36619
36641
|
if (taskCreationParams) {
|
|
36620
36642
|
this.assertTaskHandlerCapability(request.method);
|
|
36621
36643
|
}
|
|
@@ -36650,7 +36672,7 @@ var Protocol = class {
|
|
|
36650
36672
|
...error62["data"] !== void 0 && { data: error62["data"] }
|
|
36651
36673
|
}
|
|
36652
36674
|
};
|
|
36653
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
36675
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
36654
36676
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
36655
36677
|
type: "error",
|
|
36656
36678
|
message: errorResponse,
|
|
@@ -37130,7 +37152,7 @@ var Protocol = class {
|
|
|
37130
37152
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
37131
37153
|
}
|
|
37132
37154
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
37133
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
37155
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
37134
37156
|
}
|
|
37135
37157
|
/**
|
|
37136
37158
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -37159,12 +37181,13 @@ var Protocol = class {
|
|
|
37159
37181
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
37160
37182
|
* @param taskId The task ID to wait for
|
|
37161
37183
|
* @param signal Abort signal to cancel the wait
|
|
37184
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
37162
37185
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
37163
37186
|
*/
|
|
37164
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
37187
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
37165
37188
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
37166
37189
|
try {
|
|
37167
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
37190
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
37168
37191
|
if (task?.pollInterval) {
|
|
37169
37192
|
interval = task.pollInterval;
|
|
37170
37193
|
}
|
|
@@ -23049,6 +23049,9 @@ var Protocol = class {
|
|
|
23049
23049
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
23050
23050
|
const handleTaskResult = async () => {
|
|
23051
23051
|
const taskId = request.params.taskId;
|
|
23052
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
23053
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
23054
|
+
}
|
|
23052
23055
|
if (this._taskMessageQueue) {
|
|
23053
23056
|
let queuedMessage;
|
|
23054
23057
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -23079,12 +23082,12 @@ var Protocol = class {
|
|
|
23079
23082
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
23080
23083
|
}
|
|
23081
23084
|
if (!isTerminal(task.status)) {
|
|
23082
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
23085
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
23083
23086
|
return await handleTaskResult();
|
|
23084
23087
|
}
|
|
23085
23088
|
if (isTerminal(task.status)) {
|
|
23086
23089
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
23087
|
-
this._clearTaskQueue(taskId);
|
|
23090
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
23088
23091
|
return {
|
|
23089
23092
|
...result,
|
|
23090
23093
|
_meta: {
|
|
@@ -23121,7 +23124,7 @@ var Protocol = class {
|
|
|
23121
23124
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
23122
23125
|
}
|
|
23123
23126
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
23124
|
-
this._clearTaskQueue(request.params.taskId);
|
|
23127
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
23125
23128
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
23126
23129
|
if (!cancelledTask) {
|
|
23127
23130
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -23249,6 +23252,19 @@ var Protocol = class {
|
|
|
23249
23252
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
23250
23253
|
const capturedTransport = this._transport;
|
|
23251
23254
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
23255
|
+
const sessionId = capturedTransport?.sessionId;
|
|
23256
|
+
const store = this._taskStore;
|
|
23257
|
+
let relatedTaskFound = true;
|
|
23258
|
+
let relatedTaskLookup;
|
|
23259
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
23260
|
+
relatedTaskFound = false;
|
|
23261
|
+
relatedTaskLookup = (async () => {
|
|
23262
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
23263
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
23264
|
+
}
|
|
23265
|
+
relatedTaskFound = true;
|
|
23266
|
+
})();
|
|
23267
|
+
}
|
|
23252
23268
|
if (handler === void 0) {
|
|
23253
23269
|
const errorResponse = {
|
|
23254
23270
|
jsonrpc: "2.0",
|
|
@@ -23258,7 +23274,10 @@ var Protocol = class {
|
|
|
23258
23274
|
message: "Method not found"
|
|
23259
23275
|
}
|
|
23260
23276
|
};
|
|
23261
|
-
if (relatedTaskId &&
|
|
23277
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
23278
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
23279
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
23280
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
23262
23281
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
23263
23282
|
type: "error",
|
|
23264
23283
|
message: errorResponse,
|
|
@@ -23309,7 +23328,10 @@ var Protocol = class {
|
|
|
23309
23328
|
closeSSEStream: extra?.closeSSEStream,
|
|
23310
23329
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
23311
23330
|
};
|
|
23312
|
-
Promise.resolve().then(() => {
|
|
23331
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
23332
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
23333
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
23334
|
+
}
|
|
23313
23335
|
if (taskCreationParams) {
|
|
23314
23336
|
this.assertTaskHandlerCapability(request.method);
|
|
23315
23337
|
}
|
|
@@ -23344,7 +23366,7 @@ var Protocol = class {
|
|
|
23344
23366
|
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
23345
23367
|
}
|
|
23346
23368
|
};
|
|
23347
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
23369
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
23348
23370
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
23349
23371
|
type: "error",
|
|
23350
23372
|
message: errorResponse,
|
|
@@ -23824,7 +23846,7 @@ var Protocol = class {
|
|
|
23824
23846
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
23825
23847
|
}
|
|
23826
23848
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
23827
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
23849
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
23828
23850
|
}
|
|
23829
23851
|
/**
|
|
23830
23852
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -23853,12 +23875,13 @@ var Protocol = class {
|
|
|
23853
23875
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
23854
23876
|
* @param taskId The task ID to wait for
|
|
23855
23877
|
* @param signal Abort signal to cancel the wait
|
|
23878
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
23856
23879
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
23857
23880
|
*/
|
|
23858
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
23881
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
23859
23882
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
23860
23883
|
try {
|
|
23861
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
23884
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
23862
23885
|
if (task?.pollInterval) {
|
|
23863
23886
|
interval = task.pollInterval;
|
|
23864
23887
|
}
|
|
@@ -15063,6 +15063,7 @@ __export(settings_exports, {
|
|
|
15063
15063
|
// node_modules/typebox/build/guard/guard.mjs
|
|
15064
15064
|
var guard_exports = {};
|
|
15065
15065
|
__export(guard_exports, {
|
|
15066
|
+
CodePointCount: () => CodePointCount2,
|
|
15066
15067
|
Counted: () => Counted,
|
|
15067
15068
|
Entries: () => Entries,
|
|
15068
15069
|
EntriesRegExp: () => EntriesRegExp,
|
|
@@ -15103,16 +15104,13 @@ __export(guard_exports, {
|
|
|
15103
15104
|
Values: () => Values
|
|
15104
15105
|
});
|
|
15105
15106
|
|
|
15106
|
-
// node_modules/typebox/build/guard/
|
|
15107
|
+
// node_modules/typebox/build/guard/unicode/unicode_segment.mjs
|
|
15107
15108
|
function IsBetween(value, min, max) {
|
|
15108
15109
|
return value >= min && value <= max;
|
|
15109
15110
|
}
|
|
15110
15111
|
function IsZeroWidthJoiner(value) {
|
|
15111
15112
|
return value === 8205;
|
|
15112
15113
|
}
|
|
15113
|
-
function IsHighSurrogate(value) {
|
|
15114
|
-
return IsBetween(value, 55296, 56319);
|
|
15115
|
-
}
|
|
15116
15114
|
function IsRegionalIndicator(value) {
|
|
15117
15115
|
return IsBetween(value, 127462, 127487);
|
|
15118
15116
|
}
|
|
@@ -15150,64 +15148,30 @@ function NextGraphemeClusterIndex(value, clusterStart) {
|
|
|
15150
15148
|
}
|
|
15151
15149
|
return clusterEnd;
|
|
15152
15150
|
}
|
|
15153
|
-
function IsGraphemeCodePoint(value) {
|
|
15154
|
-
return value >= 768 && // above special range
|
|
15155
|
-
(IsHighSurrogate(value) || IsCombiningMark(value) || IsVariationSelector(value) || IsZeroWidthJoiner(value));
|
|
15156
|
-
}
|
|
15157
15151
|
function GraphemeCount(value) {
|
|
15158
|
-
let count = 0;
|
|
15159
|
-
let index = 0;
|
|
15152
|
+
let count = 0, index = 0;
|
|
15160
15153
|
while (index < value.length) {
|
|
15161
15154
|
index = NextGraphemeClusterIndex(value, index);
|
|
15162
15155
|
count++;
|
|
15163
15156
|
}
|
|
15164
15157
|
return count;
|
|
15165
15158
|
}
|
|
15166
|
-
|
|
15167
|
-
|
|
15168
|
-
|
|
15159
|
+
|
|
15160
|
+
// node_modules/typebox/build/guard/unicode/unicode.mjs
|
|
15161
|
+
function CodePointCount(value) {
|
|
15162
|
+
let result = 0, index = 0, prev = 0;
|
|
15169
15163
|
while (index < value.length) {
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
|
|
15164
|
+
const next = value.charCodeAt(index++) >> 10;
|
|
15165
|
+
result += +((prev << 8 | next) !== 13879);
|
|
15166
|
+
prev = next;
|
|
15173
15167
|
}
|
|
15174
|
-
return
|
|
15168
|
+
return result;
|
|
15175
15169
|
}
|
|
15176
|
-
function
|
|
15177
|
-
|
|
15178
|
-
let index = 0;
|
|
15179
|
-
while (index < value.length) {
|
|
15180
|
-
index = NextGraphemeClusterIndex(value, index);
|
|
15181
|
-
if (++count > maxLength)
|
|
15182
|
-
return false;
|
|
15183
|
-
}
|
|
15184
|
-
return true;
|
|
15170
|
+
function IsMaxLength(value, maxLength) {
|
|
15171
|
+
return value.length <= maxLength || value.length <= maxLength << 1 && CodePointCount(value) <= maxLength;
|
|
15185
15172
|
}
|
|
15186
15173
|
function IsMinLength(value, minLength) {
|
|
15187
|
-
|
|
15188
|
-
return true;
|
|
15189
|
-
if (value.length < minLength)
|
|
15190
|
-
return false;
|
|
15191
|
-
let index = 0;
|
|
15192
|
-
while (true) {
|
|
15193
|
-
if (IsGraphemeCodePoint(value.charCodeAt(index))) {
|
|
15194
|
-
return IsMinLengthSegmented(value, minLength);
|
|
15195
|
-
}
|
|
15196
|
-
if (++index >= minLength)
|
|
15197
|
-
return true;
|
|
15198
|
-
}
|
|
15199
|
-
}
|
|
15200
|
-
function IsMaxLength(value, maxLength) {
|
|
15201
|
-
if (value.length <= maxLength)
|
|
15202
|
-
return true;
|
|
15203
|
-
let index = 0;
|
|
15204
|
-
while (true) {
|
|
15205
|
-
if (IsGraphemeCodePoint(value.charCodeAt(index))) {
|
|
15206
|
-
return IsMaxLengthSegmented(value, maxLength);
|
|
15207
|
-
}
|
|
15208
|
-
if (++index > maxLength)
|
|
15209
|
-
return false;
|
|
15210
|
-
}
|
|
15174
|
+
return value.length >= minLength << 1 || value.length >= minLength && CodePointCount(value) >= minLength;
|
|
15211
15175
|
}
|
|
15212
15176
|
|
|
15213
15177
|
// node_modules/typebox/build/guard/guard.mjs
|
|
@@ -15298,11 +15262,14 @@ function IsValueLike(value) {
|
|
|
15298
15262
|
function GraphemeCount2(value) {
|
|
15299
15263
|
return GraphemeCount(value);
|
|
15300
15264
|
}
|
|
15301
|
-
function
|
|
15302
|
-
return
|
|
15265
|
+
function CodePointCount2(value) {
|
|
15266
|
+
return CodePointCount(value);
|
|
15303
15267
|
}
|
|
15304
|
-
function
|
|
15305
|
-
return
|
|
15268
|
+
function IsMaxLength2(value, maxLength) {
|
|
15269
|
+
return IsMaxLength(value, maxLength);
|
|
15270
|
+
}
|
|
15271
|
+
function IsMinLength2(value, minLength) {
|
|
15272
|
+
return IsMinLength(value, minLength);
|
|
15306
15273
|
}
|
|
15307
15274
|
function Every(value, offset, callback) {
|
|
15308
15275
|
return value.every((item, index) => index < offset || callback(item, index));
|
|
@@ -15451,6 +15418,7 @@ function IsMap(value) {
|
|
|
15451
15418
|
var settings = {
|
|
15452
15419
|
immutableTypes: false,
|
|
15453
15420
|
maxErrors: 8,
|
|
15421
|
+
maxParseErrors: 1,
|
|
15454
15422
|
maxInstantiationCount: 128,
|
|
15455
15423
|
useAcceleration: true,
|
|
15456
15424
|
exactOptionalPropertyTypes: false,
|
|
@@ -15461,6 +15429,7 @@ var settings = {
|
|
|
15461
15429
|
function Reset() {
|
|
15462
15430
|
settings.immutableTypes = false;
|
|
15463
15431
|
settings.maxErrors = 8;
|
|
15432
|
+
settings.maxParseErrors = 1;
|
|
15464
15433
|
settings.maxInstantiationCount = 128;
|
|
15465
15434
|
settings.useAcceleration = true;
|
|
15466
15435
|
settings.exactOptionalPropertyTypes = false;
|
|
@@ -17736,8 +17705,14 @@ function TryRestInferable(type) {
|
|
|
17736
17705
|
function TryInferable(type) {
|
|
17737
17706
|
return IsInfer(type) ? Inferrable(type.name, type.extends) : void 0;
|
|
17738
17707
|
}
|
|
17739
|
-
function TryInferResults(rest, right
|
|
17740
|
-
|
|
17708
|
+
function TryInferResults(rest, right) {
|
|
17709
|
+
const result = [];
|
|
17710
|
+
for (const head of rest) {
|
|
17711
|
+
if (!IsExtendsTrueLike(ExtendsLeft({}, head, right)))
|
|
17712
|
+
return void 0;
|
|
17713
|
+
result.push(head);
|
|
17714
|
+
}
|
|
17715
|
+
return result;
|
|
17741
17716
|
}
|
|
17742
17717
|
function InferTupleResult(inferred, name, left, right) {
|
|
17743
17718
|
const results = TryInferResults(left, right);
|
|
@@ -17781,9 +17756,18 @@ function ExtendsTupleToTuple(inferred, left, right) {
|
|
|
17781
17756
|
const reversed = Reversed(instantiatedRight);
|
|
17782
17757
|
return Elements(inferred, reversed, ApplyReverse(left, reversed), ApplyReverse(instantiatedRight, reversed));
|
|
17783
17758
|
}
|
|
17759
|
+
function ExtendsTupleToArrayReduce(inferred, left, right) {
|
|
17760
|
+
for (const head of left) {
|
|
17761
|
+
const result = ExtendsLeft(inferred, head, right);
|
|
17762
|
+
if (!IsExtendsTrueLike(result))
|
|
17763
|
+
return result;
|
|
17764
|
+
inferred = result.inferred;
|
|
17765
|
+
}
|
|
17766
|
+
return ExtendsTrue(inferred);
|
|
17767
|
+
}
|
|
17784
17768
|
function ExtendsTupleToArray(inferred, left, right) {
|
|
17785
17769
|
const inferrable = TryInferable(right);
|
|
17786
|
-
return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) :
|
|
17770
|
+
return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) : ExtendsTupleToArrayReduce(inferred, left, right);
|
|
17787
17771
|
}
|
|
17788
17772
|
function ExtendsTuple(inferred, left, right) {
|
|
17789
17773
|
const instantiatedLeft = InstantiateElements(inferred, State([], []), left);
|
|
@@ -27456,6 +27440,9 @@ var Protocol = class {
|
|
|
27456
27440
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
27457
27441
|
const handleTaskResult = async () => {
|
|
27458
27442
|
const taskId = request.params.taskId;
|
|
27443
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
27444
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
27445
|
+
}
|
|
27459
27446
|
if (this._taskMessageQueue) {
|
|
27460
27447
|
let queuedMessage;
|
|
27461
27448
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -27486,12 +27473,12 @@ var Protocol = class {
|
|
|
27486
27473
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
27487
27474
|
}
|
|
27488
27475
|
if (!isTerminal(task.status)) {
|
|
27489
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
27476
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
27490
27477
|
return await handleTaskResult();
|
|
27491
27478
|
}
|
|
27492
27479
|
if (isTerminal(task.status)) {
|
|
27493
27480
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
27494
|
-
this._clearTaskQueue(taskId);
|
|
27481
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
27495
27482
|
return {
|
|
27496
27483
|
...result,
|
|
27497
27484
|
_meta: {
|
|
@@ -27528,7 +27515,7 @@ var Protocol = class {
|
|
|
27528
27515
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
27529
27516
|
}
|
|
27530
27517
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
27531
|
-
this._clearTaskQueue(request.params.taskId);
|
|
27518
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
27532
27519
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
27533
27520
|
if (!cancelledTask) {
|
|
27534
27521
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -27656,6 +27643,19 @@ var Protocol = class {
|
|
|
27656
27643
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
27657
27644
|
const capturedTransport = this._transport;
|
|
27658
27645
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
27646
|
+
const sessionId = capturedTransport?.sessionId;
|
|
27647
|
+
const store = this._taskStore;
|
|
27648
|
+
let relatedTaskFound = true;
|
|
27649
|
+
let relatedTaskLookup;
|
|
27650
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
27651
|
+
relatedTaskFound = false;
|
|
27652
|
+
relatedTaskLookup = (async () => {
|
|
27653
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
27654
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
27655
|
+
}
|
|
27656
|
+
relatedTaskFound = true;
|
|
27657
|
+
})();
|
|
27658
|
+
}
|
|
27659
27659
|
if (handler === void 0) {
|
|
27660
27660
|
const errorResponse = {
|
|
27661
27661
|
jsonrpc: "2.0",
|
|
@@ -27665,7 +27665,10 @@ var Protocol = class {
|
|
|
27665
27665
|
message: "Method not found"
|
|
27666
27666
|
}
|
|
27667
27667
|
};
|
|
27668
|
-
if (relatedTaskId &&
|
|
27668
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
27669
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
27670
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
27671
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
27669
27672
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
27670
27673
|
type: "error",
|
|
27671
27674
|
message: errorResponse,
|
|
@@ -27716,7 +27719,10 @@ var Protocol = class {
|
|
|
27716
27719
|
closeSSEStream: extra?.closeSSEStream,
|
|
27717
27720
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
27718
27721
|
};
|
|
27719
|
-
Promise.resolve().then(() => {
|
|
27722
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
27723
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
27724
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
27725
|
+
}
|
|
27720
27726
|
if (taskCreationParams) {
|
|
27721
27727
|
this.assertTaskHandlerCapability(request.method);
|
|
27722
27728
|
}
|
|
@@ -27751,7 +27757,7 @@ var Protocol = class {
|
|
|
27751
27757
|
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
27752
27758
|
}
|
|
27753
27759
|
};
|
|
27754
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
27760
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
27755
27761
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
27756
27762
|
type: "error",
|
|
27757
27763
|
message: errorResponse,
|
|
@@ -28231,7 +28237,7 @@ var Protocol = class {
|
|
|
28231
28237
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
28232
28238
|
}
|
|
28233
28239
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
28234
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
28240
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
28235
28241
|
}
|
|
28236
28242
|
/**
|
|
28237
28243
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -28260,12 +28266,13 @@ var Protocol = class {
|
|
|
28260
28266
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
28261
28267
|
* @param taskId The task ID to wait for
|
|
28262
28268
|
* @param signal Abort signal to cancel the wait
|
|
28269
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
28263
28270
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
28264
28271
|
*/
|
|
28265
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
28272
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
28266
28273
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
28267
28274
|
try {
|
|
28268
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
28275
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
28269
28276
|
if (task?.pollInterval) {
|
|
28270
28277
|
interval = task.pollInterval;
|
|
28271
28278
|
}
|
package/dist/openapi.js
CHANGED
|
@@ -26,6 +26,10 @@ export function operations(doc) {
|
|
|
26
26
|
const byKey = new Map();
|
|
27
27
|
for (const p of [...shared, ...own])
|
|
28
28
|
byKey.set(`${p.in}:${p.name}`, p);
|
|
29
|
+
const personOnly = personOnlyOf(raw);
|
|
30
|
+
const confirmation = confirmationOf(raw);
|
|
31
|
+
const readPost = method === "post" && raw["x-cavelon-read-only"] === true &&
|
|
32
|
+
!personOnly?.marked && !confirmation.confirmation;
|
|
29
33
|
out.push({
|
|
30
34
|
operationId,
|
|
31
35
|
alias: aliasOf(operationId, path, method),
|
|
@@ -38,9 +42,9 @@ export function operations(doc) {
|
|
|
38
42
|
parameters: [...byKey.values()],
|
|
39
43
|
requestBody: raw.requestBody ? deref(doc, raw.requestBody) : undefined,
|
|
40
44
|
responses: raw.responses ?? {},
|
|
41
|
-
readOnly: method === "get" || method === "head" || method === "options",
|
|
42
|
-
personOnly
|
|
43
|
-
...
|
|
45
|
+
readOnly: method === "get" || method === "head" || method === "options" || readPost,
|
|
46
|
+
personOnly,
|
|
47
|
+
...confirmation,
|
|
44
48
|
});
|
|
45
49
|
}
|
|
46
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelon/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/node": "^20.19.0",
|
|
47
47
|
"esbuild": "0.28.2",
|
|
48
48
|
"eslint": "^10.12.0",
|
|
49
|
-
"typebox": "1.3.
|
|
49
|
+
"typebox": "1.3.36",
|
|
50
50
|
"typescript": "~6.0.3",
|
|
51
51
|
"typescript-eslint": "^8.71.0",
|
|
52
52
|
"vitest": "^4.0.0",
|