@ethisyscore/extension-runtime 1.34.0 → 1.36.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.
Files changed (33) hide show
  1. package/dist/{bridge-client-UK3qcGoi.d.ts → bridge-client-DD99netz.d.ts} +2 -33
  2. package/dist/{bridge-client-CIThO7jZ.d.cts → bridge-client-DzRcKIJT.d.cts} +2 -33
  3. package/dist/bridge-envelopes-DA6vxbyb.d.cts +151 -0
  4. package/dist/bridge-envelopes-DA6vxbyb.d.ts +151 -0
  5. package/dist/host/index.cjs +76 -2
  6. package/dist/host/index.cjs.map +1 -1
  7. package/dist/host/index.d.cts +3 -3
  8. package/dist/host/index.d.ts +3 -3
  9. package/dist/host/index.js +76 -2
  10. package/dist/host/index.js.map +1 -1
  11. package/dist/mock-host/cli.cjs +87 -2
  12. package/dist/mock-host/cli.cjs.map +1 -1
  13. package/dist/mock-host/cli.d.cts +2 -2
  14. package/dist/mock-host/cli.d.ts +2 -2
  15. package/dist/mock-host/cli.js +87 -2
  16. package/dist/mock-host/cli.js.map +1 -1
  17. package/dist/mock-host/index.cjs +41 -1
  18. package/dist/mock-host/index.cjs.map +1 -1
  19. package/dist/mock-host/index.d.cts +19 -7
  20. package/dist/mock-host/index.d.ts +19 -7
  21. package/dist/mock-host/index.js +41 -1
  22. package/dist/mock-host/index.js.map +1 -1
  23. package/dist/plugin/index.cjs +15 -3
  24. package/dist/plugin/index.cjs.map +1 -1
  25. package/dist/plugin/index.d.cts +13 -5
  26. package/dist/plugin/index.d.ts +13 -5
  27. package/dist/plugin/index.js +15 -4
  28. package/dist/plugin/index.js.map +1 -1
  29. package/dist/{transport-BN9Mzn_m.d.cts → transport-CHa8ESUx.d.ts} +39 -4
  30. package/dist/{transport-Jfd9KXAh.d.ts → transport-DJE6ljme.d.cts} +39 -4
  31. package/package.json +1 -1
  32. package/dist/bridge-envelopes-BRKGSiSC.d.cts +0 -63
  33. package/dist/bridge-envelopes-BRKGSiSC.d.ts +0 -63
@@ -1,4 +1,4 @@
1
- import { d as BridgePushThemeEnvelope, c as BridgePushLocaleEnvelope, b as BridgePushDensityEnvelope, a as BridgePushA11yEnvelope, B as BridgeNavPushEnvelope } from './bridge-envelopes-BRKGSiSC.cjs';
1
+ import { U as UploadDocumentMeta, d as BridgePushThemeEnvelope, c as BridgePushLocaleEnvelope, b as BridgePushDensityEnvelope, a as BridgePushA11yEnvelope, B as BridgeNavPushEnvelope } from './bridge-envelopes-DA6vxbyb.js';
2
2
 
3
3
  /**
4
4
  * Worker-side host transport for `renderMode: remote-runtime` extensions
@@ -55,11 +55,29 @@ type McpHttpRequest = {
55
55
  uri: string;
56
56
  capabilityToken: string;
57
57
  signal?: AbortSignal;
58
- };
58
+ } | McpUploadRequest;
59
+ /**
60
+ * Host-side document-upload request (a `kind` of {@link McpHttpRequest}).
61
+ * Carries the transferred bytes + advisory metadata plus the host-minted
62
+ * capability token. As with the other request kinds, the token is attached on
63
+ * the HOST side only and never crosses the worker port. Implementations POST
64
+ * the bytes as `application/octet-stream` (metadata in `x-cc-*` headers) to the
65
+ * kernel's capability-token-authed document-upload route; `data` on success is
66
+ * an {@link UploadDocumentResult}.
67
+ */
68
+ interface McpUploadRequest {
69
+ kind: "uploadDocument";
70
+ meta: UploadDocumentMeta;
71
+ buffer: ArrayBuffer;
72
+ capabilityToken: string;
73
+ signal?: AbortSignal;
74
+ }
59
75
  /**
60
76
  * Host-side HTTP client for MCP calls. Implementations are responsible for
61
77
  * carrying the supplied `capabilityToken` on the outbound request (typically
62
- * via `Authorization: Bearer`).
78
+ * via `Authorization: Bearer` / `PluginCap`). The `uploadDocument` kind is
79
+ * additive — implementations that predate it fall through to their unknown-kind
80
+ * branch until updated (the FE upload hook is inert until the host handles it).
63
81
  */
64
82
  interface McpHttpClient {
65
83
  fetch(request: McpHttpRequest): Promise<{
@@ -201,6 +219,7 @@ declare class WorkerRemoteDomTransport {
201
219
  private readonly coalesceMs;
202
220
  private readonly maxConcurrentMcpRequests;
203
221
  private readonly abortController;
222
+ private readonly inFlightAborts;
204
223
  private inFlightMcpRequests;
205
224
  private remoteDomConsumer;
206
225
  private bridgeMessageConsumer;
@@ -323,9 +342,25 @@ declare class WorkerRemoteDomTransport {
323
342
  * settles (regardless of resolution/rejection shape).
324
343
  */
325
344
  private dispatchMcp;
345
+ /**
346
+ * Create a per-request AbortController and register it under the request id
347
+ * so an inbound `ethisys:mcp:abort` can cancel just this call. If the
348
+ * transport is already disposed the controller starts aborted so the
349
+ * handler's `mcpClient.fetch` short-circuits immediately.
350
+ */
351
+ private registerRequestAbort;
352
+ /** Drop a settled request's AbortController. */
353
+ private releaseRequestAbort;
354
+ /**
355
+ * The signal to hand to `mcpClient.fetch` for a given request: the
356
+ * per-request controller when registered (client cancel path), falling back
357
+ * to the dispose-level controller.
358
+ */
359
+ private requestSignal;
326
360
  private handleInvokeTool;
327
361
  private handleGetResource;
362
+ private handleUploadDocument;
328
363
  private replyError;
329
364
  }
330
365
 
331
- export { DEFAULT_MAX_CONCURRENT_MCP_REQUESTS as D, type InputEventPayload as I, type McpHttpClient as M, WORKER_TRANSPORT_PROTOCOL as W, type McpHttpRequest as a, type WorkerCtor as b, type WorkerHandshakePayload as c, type WorkerLike as d, WorkerRemoteDomTransport as e, type WorkerRemoteDomTransportOptions as f };
366
+ export { DEFAULT_MAX_CONCURRENT_MCP_REQUESTS as D, type InputEventPayload as I, type McpHttpClient as M, WORKER_TRANSPORT_PROTOCOL as W, type McpHttpRequest as a, type McpUploadRequest as b, type WorkerCtor as c, type WorkerHandshakePayload as d, type WorkerLike as e, WorkerRemoteDomTransport as f, type WorkerRemoteDomTransportOptions as g };
@@ -1,4 +1,4 @@
1
- import { d as BridgePushThemeEnvelope, c as BridgePushLocaleEnvelope, b as BridgePushDensityEnvelope, a as BridgePushA11yEnvelope, B as BridgeNavPushEnvelope } from './bridge-envelopes-BRKGSiSC.js';
1
+ import { U as UploadDocumentMeta, d as BridgePushThemeEnvelope, c as BridgePushLocaleEnvelope, b as BridgePushDensityEnvelope, a as BridgePushA11yEnvelope, B as BridgeNavPushEnvelope } from './bridge-envelopes-DA6vxbyb.cjs';
2
2
 
3
3
  /**
4
4
  * Worker-side host transport for `renderMode: remote-runtime` extensions
@@ -55,11 +55,29 @@ type McpHttpRequest = {
55
55
  uri: string;
56
56
  capabilityToken: string;
57
57
  signal?: AbortSignal;
58
- };
58
+ } | McpUploadRequest;
59
+ /**
60
+ * Host-side document-upload request (a `kind` of {@link McpHttpRequest}).
61
+ * Carries the transferred bytes + advisory metadata plus the host-minted
62
+ * capability token. As with the other request kinds, the token is attached on
63
+ * the HOST side only and never crosses the worker port. Implementations POST
64
+ * the bytes as `application/octet-stream` (metadata in `x-cc-*` headers) to the
65
+ * kernel's capability-token-authed document-upload route; `data` on success is
66
+ * an {@link UploadDocumentResult}.
67
+ */
68
+ interface McpUploadRequest {
69
+ kind: "uploadDocument";
70
+ meta: UploadDocumentMeta;
71
+ buffer: ArrayBuffer;
72
+ capabilityToken: string;
73
+ signal?: AbortSignal;
74
+ }
59
75
  /**
60
76
  * Host-side HTTP client for MCP calls. Implementations are responsible for
61
77
  * carrying the supplied `capabilityToken` on the outbound request (typically
62
- * via `Authorization: Bearer`).
78
+ * via `Authorization: Bearer` / `PluginCap`). The `uploadDocument` kind is
79
+ * additive — implementations that predate it fall through to their unknown-kind
80
+ * branch until updated (the FE upload hook is inert until the host handles it).
63
81
  */
64
82
  interface McpHttpClient {
65
83
  fetch(request: McpHttpRequest): Promise<{
@@ -201,6 +219,7 @@ declare class WorkerRemoteDomTransport {
201
219
  private readonly coalesceMs;
202
220
  private readonly maxConcurrentMcpRequests;
203
221
  private readonly abortController;
222
+ private readonly inFlightAborts;
204
223
  private inFlightMcpRequests;
205
224
  private remoteDomConsumer;
206
225
  private bridgeMessageConsumer;
@@ -323,9 +342,25 @@ declare class WorkerRemoteDomTransport {
323
342
  * settles (regardless of resolution/rejection shape).
324
343
  */
325
344
  private dispatchMcp;
345
+ /**
346
+ * Create a per-request AbortController and register it under the request id
347
+ * so an inbound `ethisys:mcp:abort` can cancel just this call. If the
348
+ * transport is already disposed the controller starts aborted so the
349
+ * handler's `mcpClient.fetch` short-circuits immediately.
350
+ */
351
+ private registerRequestAbort;
352
+ /** Drop a settled request's AbortController. */
353
+ private releaseRequestAbort;
354
+ /**
355
+ * The signal to hand to `mcpClient.fetch` for a given request: the
356
+ * per-request controller when registered (client cancel path), falling back
357
+ * to the dispose-level controller.
358
+ */
359
+ private requestSignal;
326
360
  private handleInvokeTool;
327
361
  private handleGetResource;
362
+ private handleUploadDocument;
328
363
  private replyError;
329
364
  }
330
365
 
331
- export { DEFAULT_MAX_CONCURRENT_MCP_REQUESTS as D, type InputEventPayload as I, type McpHttpClient as M, WORKER_TRANSPORT_PROTOCOL as W, type McpHttpRequest as a, type WorkerCtor as b, type WorkerHandshakePayload as c, type WorkerLike as d, WorkerRemoteDomTransport as e, type WorkerRemoteDomTransportOptions as f };
366
+ export { DEFAULT_MAX_CONCURRENT_MCP_REQUESTS as D, type InputEventPayload as I, type McpHttpClient as M, WORKER_TRANSPORT_PROTOCOL as W, type McpHttpRequest as a, type McpUploadRequest as b, type WorkerCtor as c, type WorkerHandshakePayload as d, type WorkerLike as e, WorkerRemoteDomTransport as f, type WorkerRemoteDomTransportOptions as g };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethisyscore/extension-runtime",
3
- "version": "1.34.0",
3
+ "version": "1.36.0",
4
4
  "description": "Host + plugin runtime for EthisysCore Contract A (host-rendered) and Contract B (worker remote-runtime) extensions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,63 +0,0 @@
1
- /**
2
- * Wire-shape constants and type guards for host→plugin bridge push messages
3
- * (WI 4858 sub-plan 2). These types ride the existing MessagePort channel
4
- * alongside the `ethisys:mcp:*` and `ethisys:remotedom` envelopes — the
5
- * `type` discriminant keeps them fully separate at the dispatch site.
6
- *
7
- * The host posts bridge pushes through `WorkerRemoteDomTransport.hostPort`;
8
- * the plugin side reads them in `createPortBridgeClient` (plugin-ui package).
9
- * In-realm (Tier T) plugins use `InMemoryBridgeTransport` which calls the
10
- * subscriber callbacks directly — no serialisation needed.
11
- */
12
- declare const BRIDGE_PUSH_THEME: "ethisys:bridge:theme";
13
- declare const BRIDGE_PUSH_LOCALE: "ethisys:bridge:locale";
14
- declare const BRIDGE_PUSH_DENSITY: "ethisys:bridge:density";
15
- declare const BRIDGE_PUSH_A11Y: "ethisys:bridge:a11y";
16
- declare const BRIDGE_NAV_PUSH: "ethisys:bridge:nav";
17
- declare const BRIDGE_SESSION_TOKEN_PUSH: "ethisys:bridge:token";
18
- /** Theme push: host → plugin whenever the host theme changes. */
19
- interface BridgePushThemeEnvelope {
20
- readonly type: typeof BRIDGE_PUSH_THEME;
21
- /** "light" | "dark" | "high-contrast" */
22
- readonly mode: string;
23
- /** Flat design-token map (CSS-variable-name → value). May be empty. */
24
- readonly tokens: Readonly<Record<string, string>>;
25
- }
26
- /** Locale push: host → plugin whenever the active locale changes. */
27
- interface BridgePushLocaleEnvelope {
28
- readonly type: typeof BRIDGE_PUSH_LOCALE;
29
- /** BCP 47 tag, e.g. "en-GB". */
30
- readonly locale: string;
31
- /** "ltr" | "rtl" */
32
- readonly dir: "ltr" | "rtl";
33
- }
34
- /** Density push: host → plugin when the UI density preference changes. */
35
- interface BridgePushDensityEnvelope {
36
- readonly type: typeof BRIDGE_PUSH_DENSITY;
37
- /** "comfortable" | "compact" */
38
- readonly density: string;
39
- }
40
- /** A11y push: host → plugin when accessibility prefs change. */
41
- interface BridgePushA11yEnvelope {
42
- readonly type: typeof BRIDGE_PUSH_A11Y;
43
- readonly reducedMotion: boolean;
44
- readonly highContrast: boolean;
45
- }
46
- /** Nav push: host → plugin when the SPA location changes. */
47
- interface BridgeNavPushEnvelope {
48
- readonly type: typeof BRIDGE_NAV_PUSH;
49
- /** Current SPA path (pathname + search). */
50
- readonly path: string;
51
- /** `window.history.length` at the time of push. */
52
- readonly historyLength: number;
53
- }
54
- /** Host → plugin: push a short-lived frontend-session token. */
55
- interface BridgeSessionTokenPushEnvelope {
56
- readonly type: typeof BRIDGE_SESSION_TOKEN_PUSH;
57
- /** Opaque JWT string — audience-restricted to the plugin's own backend. */
58
- readonly token: string;
59
- /** Absolute epoch-ms at which the token expires. Refresh fires 30 s before. */
60
- readonly expiresAtMs: number;
61
- }
62
-
63
- export type { BridgeNavPushEnvelope as B, BridgePushA11yEnvelope as a, BridgePushDensityEnvelope as b, BridgePushLocaleEnvelope as c, BridgePushThemeEnvelope as d, BridgeSessionTokenPushEnvelope as e };
@@ -1,63 +0,0 @@
1
- /**
2
- * Wire-shape constants and type guards for host→plugin bridge push messages
3
- * (WI 4858 sub-plan 2). These types ride the existing MessagePort channel
4
- * alongside the `ethisys:mcp:*` and `ethisys:remotedom` envelopes — the
5
- * `type` discriminant keeps them fully separate at the dispatch site.
6
- *
7
- * The host posts bridge pushes through `WorkerRemoteDomTransport.hostPort`;
8
- * the plugin side reads them in `createPortBridgeClient` (plugin-ui package).
9
- * In-realm (Tier T) plugins use `InMemoryBridgeTransport` which calls the
10
- * subscriber callbacks directly — no serialisation needed.
11
- */
12
- declare const BRIDGE_PUSH_THEME: "ethisys:bridge:theme";
13
- declare const BRIDGE_PUSH_LOCALE: "ethisys:bridge:locale";
14
- declare const BRIDGE_PUSH_DENSITY: "ethisys:bridge:density";
15
- declare const BRIDGE_PUSH_A11Y: "ethisys:bridge:a11y";
16
- declare const BRIDGE_NAV_PUSH: "ethisys:bridge:nav";
17
- declare const BRIDGE_SESSION_TOKEN_PUSH: "ethisys:bridge:token";
18
- /** Theme push: host → plugin whenever the host theme changes. */
19
- interface BridgePushThemeEnvelope {
20
- readonly type: typeof BRIDGE_PUSH_THEME;
21
- /** "light" | "dark" | "high-contrast" */
22
- readonly mode: string;
23
- /** Flat design-token map (CSS-variable-name → value). May be empty. */
24
- readonly tokens: Readonly<Record<string, string>>;
25
- }
26
- /** Locale push: host → plugin whenever the active locale changes. */
27
- interface BridgePushLocaleEnvelope {
28
- readonly type: typeof BRIDGE_PUSH_LOCALE;
29
- /** BCP 47 tag, e.g. "en-GB". */
30
- readonly locale: string;
31
- /** "ltr" | "rtl" */
32
- readonly dir: "ltr" | "rtl";
33
- }
34
- /** Density push: host → plugin when the UI density preference changes. */
35
- interface BridgePushDensityEnvelope {
36
- readonly type: typeof BRIDGE_PUSH_DENSITY;
37
- /** "comfortable" | "compact" */
38
- readonly density: string;
39
- }
40
- /** A11y push: host → plugin when accessibility prefs change. */
41
- interface BridgePushA11yEnvelope {
42
- readonly type: typeof BRIDGE_PUSH_A11Y;
43
- readonly reducedMotion: boolean;
44
- readonly highContrast: boolean;
45
- }
46
- /** Nav push: host → plugin when the SPA location changes. */
47
- interface BridgeNavPushEnvelope {
48
- readonly type: typeof BRIDGE_NAV_PUSH;
49
- /** Current SPA path (pathname + search). */
50
- readonly path: string;
51
- /** `window.history.length` at the time of push. */
52
- readonly historyLength: number;
53
- }
54
- /** Host → plugin: push a short-lived frontend-session token. */
55
- interface BridgeSessionTokenPushEnvelope {
56
- readonly type: typeof BRIDGE_SESSION_TOKEN_PUSH;
57
- /** Opaque JWT string — audience-restricted to the plugin's own backend. */
58
- readonly token: string;
59
- /** Absolute epoch-ms at which the token expires. Refresh fires 30 s before. */
60
- readonly expiresAtMs: number;
61
- }
62
-
63
- export type { BridgeNavPushEnvelope as B, BridgePushA11yEnvelope as a, BridgePushDensityEnvelope as b, BridgePushLocaleEnvelope as c, BridgePushThemeEnvelope as d, BridgeSessionTokenPushEnvelope as e };