@ethisyscore/extension-runtime 1.33.0 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bridge-client-UK3qcGoi.d.ts → bridge-client-DD99netz.d.ts} +2 -33
- package/dist/{bridge-client-CIThO7jZ.d.cts → bridge-client-DzRcKIJT.d.cts} +2 -33
- package/dist/bridge-envelopes-DA6vxbyb.d.cts +151 -0
- package/dist/bridge-envelopes-DA6vxbyb.d.ts +151 -0
- package/dist/host/index.cjs +76 -2
- package/dist/host/index.cjs.map +1 -1
- package/dist/host/index.d.cts +3 -3
- package/dist/host/index.d.ts +3 -3
- package/dist/host/index.js +76 -2
- package/dist/host/index.js.map +1 -1
- package/dist/mock-host/cli.cjs +87 -2
- package/dist/mock-host/cli.cjs.map +1 -1
- package/dist/mock-host/cli.d.cts +2 -2
- package/dist/mock-host/cli.d.ts +2 -2
- package/dist/mock-host/cli.js +87 -2
- package/dist/mock-host/cli.js.map +1 -1
- package/dist/mock-host/index.cjs +41 -1
- package/dist/mock-host/index.cjs.map +1 -1
- package/dist/mock-host/index.d.cts +19 -7
- package/dist/mock-host/index.d.ts +19 -7
- package/dist/mock-host/index.js +41 -1
- package/dist/mock-host/index.js.map +1 -1
- package/dist/plugin/index.cjs +15 -3
- package/dist/plugin/index.cjs.map +1 -1
- package/dist/plugin/index.d.cts +13 -5
- package/dist/plugin/index.d.ts +13 -5
- package/dist/plugin/index.js +15 -4
- package/dist/plugin/index.js.map +1 -1
- package/dist/{transport-BN9Mzn_m.d.cts → transport-CHa8ESUx.d.ts} +39 -4
- package/dist/{transport-Jfd9KXAh.d.ts → transport-DJE6ljme.d.cts} +39 -4
- package/package.json +1 -1
- package/dist/bridge-envelopes-BRKGSiSC.d.cts +0 -63
- package/dist/bridge-envelopes-BRKGSiSC.d.ts +0 -63
package/dist/host/index.js
CHANGED
|
@@ -307,6 +307,13 @@ var WorkerRemoteDomTransport = class {
|
|
|
307
307
|
coalesceMs;
|
|
308
308
|
maxConcurrentMcpRequests;
|
|
309
309
|
abortController;
|
|
310
|
+
// Per-request AbortControllers keyed by request id. An inbound
|
|
311
|
+
// `ethisys:mcp:abort` envelope (the worker posts one when a hook's
|
|
312
|
+
// AbortSignal fires on unmount / arg change) aborts just that request;
|
|
313
|
+
// dispose() fans out to every registered controller. Without this a
|
|
314
|
+
// cancelled call — most costly for uploadDocument — keeps streaming to the
|
|
315
|
+
// kernel even though the plugin promise already rejected.
|
|
316
|
+
inFlightAborts = /* @__PURE__ */ new Map();
|
|
310
317
|
inFlightMcpRequests = 0;
|
|
311
318
|
remoteDomConsumer;
|
|
312
319
|
bridgeMessageConsumer;
|
|
@@ -494,6 +501,10 @@ var WorkerRemoteDomTransport = class {
|
|
|
494
501
|
this.disposed = true;
|
|
495
502
|
try {
|
|
496
503
|
this.abortController.abort();
|
|
504
|
+
for (const controller of this.inFlightAborts.values()) {
|
|
505
|
+
controller.abort();
|
|
506
|
+
}
|
|
507
|
+
this.inFlightAborts.clear();
|
|
497
508
|
} catch {
|
|
498
509
|
}
|
|
499
510
|
try {
|
|
@@ -532,6 +543,12 @@ var WorkerRemoteDomTransport = class {
|
|
|
532
543
|
case "ethisys:mcp:getResource":
|
|
533
544
|
this.dispatchMcp(message, "ethisys:mcp:getResource:result", (m) => this.handleGetResource(m));
|
|
534
545
|
return;
|
|
546
|
+
case "ethisys:mcp:uploadDocument":
|
|
547
|
+
this.dispatchMcp(message, "ethisys:mcp:uploadDocument:result", (m) => this.handleUploadDocument(m));
|
|
548
|
+
return;
|
|
549
|
+
case "ethisys:mcp:abort":
|
|
550
|
+
this.inFlightAborts.get(message.id ?? "")?.abort();
|
|
551
|
+
return;
|
|
535
552
|
case "ethisys:remotedom":
|
|
536
553
|
this.remoteDomConsumer?.(message.payload);
|
|
537
554
|
return;
|
|
@@ -561,10 +578,37 @@ var WorkerRemoteDomTransport = class {
|
|
|
561
578
|
return;
|
|
562
579
|
}
|
|
563
580
|
this.inFlightMcpRequests++;
|
|
581
|
+
this.registerRequestAbort(message.id);
|
|
564
582
|
handler(message).finally(() => {
|
|
583
|
+
this.releaseRequestAbort(message.id);
|
|
565
584
|
this.inFlightMcpRequests = Math.max(0, this.inFlightMcpRequests - 1);
|
|
566
585
|
});
|
|
567
586
|
}
|
|
587
|
+
/**
|
|
588
|
+
* Create a per-request AbortController and register it under the request id
|
|
589
|
+
* so an inbound `ethisys:mcp:abort` can cancel just this call. If the
|
|
590
|
+
* transport is already disposed the controller starts aborted so the
|
|
591
|
+
* handler's `mcpClient.fetch` short-circuits immediately.
|
|
592
|
+
*/
|
|
593
|
+
registerRequestAbort(id) {
|
|
594
|
+
const controller = new AbortController();
|
|
595
|
+
if (this.abortController.signal.aborted) {
|
|
596
|
+
controller.abort();
|
|
597
|
+
}
|
|
598
|
+
this.inFlightAborts.set(id, controller);
|
|
599
|
+
}
|
|
600
|
+
/** Drop a settled request's AbortController. */
|
|
601
|
+
releaseRequestAbort(id) {
|
|
602
|
+
this.inFlightAborts.delete(id);
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* The signal to hand to `mcpClient.fetch` for a given request: the
|
|
606
|
+
* per-request controller when registered (client cancel path), falling back
|
|
607
|
+
* to the dispose-level controller.
|
|
608
|
+
*/
|
|
609
|
+
requestSignal(id) {
|
|
610
|
+
return this.inFlightAborts.get(id)?.signal ?? this.abortController.signal;
|
|
611
|
+
}
|
|
568
612
|
async handleInvokeTool(message) {
|
|
569
613
|
let token;
|
|
570
614
|
try {
|
|
@@ -582,7 +626,7 @@ var WorkerRemoteDomTransport = class {
|
|
|
582
626
|
name: message.name,
|
|
583
627
|
args: message.args,
|
|
584
628
|
capabilityToken: token,
|
|
585
|
-
signal: this.
|
|
629
|
+
signal: this.requestSignal(message.id)
|
|
586
630
|
});
|
|
587
631
|
this.safePostMessage({
|
|
588
632
|
id: message.id,
|
|
@@ -611,7 +655,7 @@ var WorkerRemoteDomTransport = class {
|
|
|
611
655
|
kind: "getResource",
|
|
612
656
|
uri: message.uri,
|
|
613
657
|
capabilityToken: token,
|
|
614
|
-
signal: this.
|
|
658
|
+
signal: this.requestSignal(message.id)
|
|
615
659
|
});
|
|
616
660
|
this.safePostMessage({
|
|
617
661
|
id: message.id,
|
|
@@ -624,6 +668,36 @@ var WorkerRemoteDomTransport = class {
|
|
|
624
668
|
this.replyError(message.id, "ethisys:mcp:getResource:result", err);
|
|
625
669
|
}
|
|
626
670
|
}
|
|
671
|
+
async handleUploadDocument(message) {
|
|
672
|
+
let token;
|
|
673
|
+
try {
|
|
674
|
+
token = await this.capabilityTokenProvider();
|
|
675
|
+
} catch (err) {
|
|
676
|
+
this.replyError(message.id, "ethisys:mcp:uploadDocument:result", err);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (this.disposed) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
try {
|
|
683
|
+
const result = await this.mcpClient.fetch({
|
|
684
|
+
kind: "uploadDocument",
|
|
685
|
+
meta: message.meta,
|
|
686
|
+
buffer: message.buffer,
|
|
687
|
+
capabilityToken: token,
|
|
688
|
+
signal: this.requestSignal(message.id)
|
|
689
|
+
});
|
|
690
|
+
this.safePostMessage({
|
|
691
|
+
id: message.id,
|
|
692
|
+
type: "ethisys:mcp:uploadDocument:result",
|
|
693
|
+
ok: result.ok,
|
|
694
|
+
data: result.data,
|
|
695
|
+
error: result.error
|
|
696
|
+
});
|
|
697
|
+
} catch (err) {
|
|
698
|
+
this.replyError(message.id, "ethisys:mcp:uploadDocument:result", err);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
627
701
|
replyError(id, type, err) {
|
|
628
702
|
const message = err instanceof Error ? err.message : "MCP request failed";
|
|
629
703
|
this.safePostMessage({ id, type, ok: false, error: message });
|