@ethisyscore/extension-runtime 1.115.0 → 1.116.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-DzRcKIJT.d.cts → bridge-client-D0fogVGd.d.cts} +1 -1
- package/dist/{bridge-client-DD99netz.d.ts → bridge-client-tIK_iYT9.d.ts} +1 -1
- package/dist/{bridge-envelopes-DA6vxbyb.d.cts → bridge-envelopes-DAuew-fU.d.cts} +34 -0
- package/dist/{bridge-envelopes-DA6vxbyb.d.ts → bridge-envelopes-DAuew-fU.d.ts} +34 -0
- package/dist/host/index.d.cts +3 -3
- package/dist/host/index.d.ts +3 -3
- package/dist/mock-host/cli.d.cts +2 -2
- package/dist/mock-host/cli.d.ts +2 -2
- package/dist/mock-host/index.d.cts +2 -2
- package/dist/mock-host/index.d.ts +2 -2
- package/dist/plugin/index.cjs +94 -0
- package/dist/plugin/index.cjs.map +1 -1
- package/dist/plugin/index.d.cts +77 -5
- package/dist/plugin/index.d.ts +77 -5
- package/dist/plugin/index.js +93 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/{transport-BuX8gzq1.d.ts → transport-B9mwIXYs.d.ts} +1 -1
- package/dist/{transport-C4xoMWBE.d.cts → transport-Cjpb_qPo.d.cts} +1 -1
- package/package.json +1 -1
package/dist/plugin/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { M as McpTransport } from '../bridge-envelopes-
|
|
2
|
-
export { U as UploadDocumentMeta, f as UploadDocumentResult } from '../bridge-envelopes-
|
|
1
|
+
import { M as McpTransport } from '../bridge-envelopes-DAuew-fU.cjs';
|
|
2
|
+
export { U as UploadDocumentMeta, f as UploadDocumentResult } from '../bridge-envelopes-DAuew-fU.cjs';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import { SduiNode, RenderMode } from '@ethisyscore/protocol';
|
|
6
6
|
export { PagedResponse, PaginatedEnvelope } from '@ethisyscore/protocol';
|
|
7
7
|
import { RemoteConnection } from '@remote-dom/core';
|
|
8
|
-
import { P as PortBridgeClient, T as ThemePayload, L as LocalePayload } from '../bridge-client-
|
|
9
|
-
export { A as A11yPayload, B as BridgePortShim, D as DensityPayload, N as NavPayload, S as SessionTokenPayload, c as createPortBridgeClient } from '../bridge-client-
|
|
8
|
+
import { P as PortBridgeClient, T as ThemePayload, L as LocalePayload } from '../bridge-client-D0fogVGd.cjs';
|
|
9
|
+
export { A as A11yPayload, B as BridgePortShim, D as DensityPayload, N as NavPayload, S as SessionTokenPayload, c as createPortBridgeClient } from '../bridge-client-D0fogVGd.cjs';
|
|
10
10
|
export { M as MCP_ERROR_CODES, a as McpErrorCode, b as McpToolError, c as classifyHostError, d as classifyHostResponse, i as isMcpErrorCode, e as isMcpToolError, f as isRetryableMcpErrorCode, m as mcpErrorCodeFromHttpStatus } from '../mcp-error-CCZQd8Xl.cjs';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -218,6 +218,78 @@ declare function useExtensionRuntimeTransport(override?: McpTransport): McpTrans
|
|
|
218
218
|
*/
|
|
219
219
|
declare function useOptionalExtensionRuntimeTransport(override?: McpTransport): McpTransport | null;
|
|
220
220
|
|
|
221
|
+
interface UseModuleToolOptions {
|
|
222
|
+
/**
|
|
223
|
+
* Override the transport resolved from {@link ExtensionRuntimeProvider}.
|
|
224
|
+
* Primarily intended for tests and advanced multi-host scenarios.
|
|
225
|
+
*/
|
|
226
|
+
transport?: McpTransport;
|
|
227
|
+
}
|
|
228
|
+
interface UseModuleToolResult<TReq, TRes> {
|
|
229
|
+
/**
|
|
230
|
+
* Invoke the operation. Each call gets a fresh {@link AbortController} that is
|
|
231
|
+
* aborted on unmount so unresolved promises cannot keep state alive after the
|
|
232
|
+
* component is gone.
|
|
233
|
+
*/
|
|
234
|
+
invoke: (req: TReq) => Promise<TRes>;
|
|
235
|
+
loading: boolean;
|
|
236
|
+
error: Error | undefined;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The cross-application counterpart to {@link useMcpTool}: names a MODULE and an
|
|
240
|
+
* OPERATION rather than a tool, so the operator's provider selection decides which
|
|
241
|
+
* application answers.
|
|
242
|
+
*
|
|
243
|
+
* **Use this, not {@link useMcpTool}, for another application's data.** A surface
|
|
244
|
+
* capability token is refused for cross-extension tools (EXT_MCP_008), so naming
|
|
245
|
+
* `projects:create-client` from a plugin surface does not reach Projects at all;
|
|
246
|
+
* it is refused and the screen silently does nothing. Naming the operation reaches
|
|
247
|
+
* whichever application the operator chose, and falls back to `fallbackToolName`
|
|
248
|
+
* while they have chosen none, which is the state every organisation starts in.
|
|
249
|
+
*
|
|
250
|
+
* Keep using {@link useMcpTool} for the plugin's OWN tools. There is no provider to
|
|
251
|
+
* choose between when the answer can only come from one place, and routing such a
|
|
252
|
+
* call through a per-organisation lookup is the failure that emptied the onboarding
|
|
253
|
+
* admin picker for every SDK-hosted plugin.
|
|
254
|
+
*
|
|
255
|
+
* `invoke` is a stable reference across renders for the same module, operation,
|
|
256
|
+
* fallback and transport, making it safe to use inside `useEffect` deps.
|
|
257
|
+
*/
|
|
258
|
+
declare function useModuleTool<TReq, TRes>(moduleKey: string, operationKey: string, fallbackToolName: string, opts?: UseModuleToolOptions): UseModuleToolResult<TReq, TRes>;
|
|
259
|
+
|
|
260
|
+
interface UseModuleQueryOptions {
|
|
261
|
+
/**
|
|
262
|
+
* Gate the fetch on a guard. When false the hook returns idle state and never
|
|
263
|
+
* invokes, which is how a read that depends on a selection is expressed without
|
|
264
|
+
* violating the rules of hooks. Defaults to `true`.
|
|
265
|
+
*/
|
|
266
|
+
enabled?: boolean;
|
|
267
|
+
}
|
|
268
|
+
interface UseModuleQueryResult<TRes> {
|
|
269
|
+
data: TRes | undefined;
|
|
270
|
+
loading: boolean;
|
|
271
|
+
error: Error | undefined;
|
|
272
|
+
/** Re-run the fetch against the current args. */
|
|
273
|
+
refetch: () => void;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The cross-application counterpart to {@link useMcpQuery}: an auto-fetching read that
|
|
277
|
+
* names a MODULE and an OPERATION, so the operator's provider selection decides which
|
|
278
|
+
* application answers.
|
|
279
|
+
*
|
|
280
|
+
* Use this, not {@link useMcpQuery}, for another application's data. A surface
|
|
281
|
+
* capability token is refused for cross-extension tools (EXT_MCP_008), so naming
|
|
282
|
+
* `hr:list-employees` from a plugin surface reaches nothing and the picker renders
|
|
283
|
+
* empty. Naming the operation reaches the chosen provider, and falls back to
|
|
284
|
+
* `fallbackToolName` while none is chosen, which is where every organisation starts.
|
|
285
|
+
*
|
|
286
|
+
* Keep {@link useMcpQuery} for the plugin's own tools and for platform intrinsics such
|
|
287
|
+
* as `users:*`: where only one source can answer there is no choice to model, and
|
|
288
|
+
* routing such a read through a per-organisation lookup is the failure that emptied
|
|
289
|
+
* the onboarding admin picker for every SDK-hosted plugin.
|
|
290
|
+
*/
|
|
291
|
+
declare function useModuleQuery<TArgs, TRes>(moduleKey: string, operationKey: string, fallbackToolName: string, args: TArgs, options?: UseModuleQueryOptions): UseModuleQueryResult<TRes>;
|
|
292
|
+
|
|
221
293
|
interface UseMcpResourceOptions {
|
|
222
294
|
/**
|
|
223
295
|
* Override the transport resolved from {@link ExtensionRuntimeProvider}.
|
|
@@ -685,4 +757,4 @@ interface UseAuthResult {
|
|
|
685
757
|
*/
|
|
686
758
|
declare function useAuth(transport: McpTransport): UseAuthResult;
|
|
687
759
|
|
|
688
|
-
export { BridgeClientContext, type ClientPushChannel, ClientPushContext, type ClientPushEvent, type ClientPushSubscribeOptions, type CreatePortMcpTransportOptions, type CreateRemoteRootOptions, type DeclarativePluginConfig, type EthisysPluginConfig, ExtensionRuntimeProvider, type ExtensionRuntimeProviderProps, type HostIdentity, HostIdentityContext, type HostIdentityUser, type HostPermission, type ItemsResponse, LocalePayload, McpTransport, PluginRealtimeContext, type PluginRealtimeSource, PortBridgeClient, type PortShim, type RemoteRoot, ThemePayload, type UseAuthResult, type UseClientPushSubscriptionOptions, type UseFrontendSessionTokenResult, type UseMcpQueryOptions, type UseMcpQueryResult, type UseMcpResourceOptions, type UseMcpResourceResult, type UseMcpToolOptions, type UseMcpToolResult, createPortMcpTransport, createRemoteRoot, decodeJwtPayload, defineDeclarativePlugin, defineEthisysPlugin, unwrapItems, useAuth, useBridgeClient, useBridgeLocale, useBridgeTheme, useClientPushSubscription, useExtensionRuntimeTransport, useFrontendSessionToken, useHostIdentity, useMcpQuery, useMcpResource, useMcpTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource };
|
|
760
|
+
export { BridgeClientContext, type ClientPushChannel, ClientPushContext, type ClientPushEvent, type ClientPushSubscribeOptions, type CreatePortMcpTransportOptions, type CreateRemoteRootOptions, type DeclarativePluginConfig, type EthisysPluginConfig, ExtensionRuntimeProvider, type ExtensionRuntimeProviderProps, type HostIdentity, HostIdentityContext, type HostIdentityUser, type HostPermission, type ItemsResponse, LocalePayload, McpTransport, PluginRealtimeContext, type PluginRealtimeSource, PortBridgeClient, type PortShim, type RemoteRoot, ThemePayload, type UseAuthResult, type UseClientPushSubscriptionOptions, type UseFrontendSessionTokenResult, type UseMcpQueryOptions, type UseMcpQueryResult, type UseMcpResourceOptions, type UseMcpResourceResult, type UseMcpToolOptions, type UseMcpToolResult, type UseModuleQueryOptions, type UseModuleQueryResult, type UseModuleToolOptions, type UseModuleToolResult, createPortMcpTransport, createRemoteRoot, decodeJwtPayload, defineDeclarativePlugin, defineEthisysPlugin, unwrapItems, useAuth, useBridgeClient, useBridgeLocale, useBridgeTheme, useClientPushSubscription, useExtensionRuntimeTransport, useFrontendSessionToken, useHostIdentity, useMcpQuery, useMcpResource, useMcpTool, useModuleQuery, useModuleTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource };
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { M as McpTransport } from '../bridge-envelopes-
|
|
2
|
-
export { U as UploadDocumentMeta, f as UploadDocumentResult } from '../bridge-envelopes-
|
|
1
|
+
import { M as McpTransport } from '../bridge-envelopes-DAuew-fU.js';
|
|
2
|
+
export { U as UploadDocumentMeta, f as UploadDocumentResult } from '../bridge-envelopes-DAuew-fU.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import { SduiNode, RenderMode } from '@ethisyscore/protocol';
|
|
6
6
|
export { PagedResponse, PaginatedEnvelope } from '@ethisyscore/protocol';
|
|
7
7
|
import { RemoteConnection } from '@remote-dom/core';
|
|
8
|
-
import { P as PortBridgeClient, T as ThemePayload, L as LocalePayload } from '../bridge-client-
|
|
9
|
-
export { A as A11yPayload, B as BridgePortShim, D as DensityPayload, N as NavPayload, S as SessionTokenPayload, c as createPortBridgeClient } from '../bridge-client-
|
|
8
|
+
import { P as PortBridgeClient, T as ThemePayload, L as LocalePayload } from '../bridge-client-tIK_iYT9.js';
|
|
9
|
+
export { A as A11yPayload, B as BridgePortShim, D as DensityPayload, N as NavPayload, S as SessionTokenPayload, c as createPortBridgeClient } from '../bridge-client-tIK_iYT9.js';
|
|
10
10
|
export { M as MCP_ERROR_CODES, a as McpErrorCode, b as McpToolError, c as classifyHostError, d as classifyHostResponse, i as isMcpErrorCode, e as isMcpToolError, f as isRetryableMcpErrorCode, m as mcpErrorCodeFromHttpStatus } from '../mcp-error-CCZQd8Xl.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -218,6 +218,78 @@ declare function useExtensionRuntimeTransport(override?: McpTransport): McpTrans
|
|
|
218
218
|
*/
|
|
219
219
|
declare function useOptionalExtensionRuntimeTransport(override?: McpTransport): McpTransport | null;
|
|
220
220
|
|
|
221
|
+
interface UseModuleToolOptions {
|
|
222
|
+
/**
|
|
223
|
+
* Override the transport resolved from {@link ExtensionRuntimeProvider}.
|
|
224
|
+
* Primarily intended for tests and advanced multi-host scenarios.
|
|
225
|
+
*/
|
|
226
|
+
transport?: McpTransport;
|
|
227
|
+
}
|
|
228
|
+
interface UseModuleToolResult<TReq, TRes> {
|
|
229
|
+
/**
|
|
230
|
+
* Invoke the operation. Each call gets a fresh {@link AbortController} that is
|
|
231
|
+
* aborted on unmount so unresolved promises cannot keep state alive after the
|
|
232
|
+
* component is gone.
|
|
233
|
+
*/
|
|
234
|
+
invoke: (req: TReq) => Promise<TRes>;
|
|
235
|
+
loading: boolean;
|
|
236
|
+
error: Error | undefined;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The cross-application counterpart to {@link useMcpTool}: names a MODULE and an
|
|
240
|
+
* OPERATION rather than a tool, so the operator's provider selection decides which
|
|
241
|
+
* application answers.
|
|
242
|
+
*
|
|
243
|
+
* **Use this, not {@link useMcpTool}, for another application's data.** A surface
|
|
244
|
+
* capability token is refused for cross-extension tools (EXT_MCP_008), so naming
|
|
245
|
+
* `projects:create-client` from a plugin surface does not reach Projects at all;
|
|
246
|
+
* it is refused and the screen silently does nothing. Naming the operation reaches
|
|
247
|
+
* whichever application the operator chose, and falls back to `fallbackToolName`
|
|
248
|
+
* while they have chosen none, which is the state every organisation starts in.
|
|
249
|
+
*
|
|
250
|
+
* Keep using {@link useMcpTool} for the plugin's OWN tools. There is no provider to
|
|
251
|
+
* choose between when the answer can only come from one place, and routing such a
|
|
252
|
+
* call through a per-organisation lookup is the failure that emptied the onboarding
|
|
253
|
+
* admin picker for every SDK-hosted plugin.
|
|
254
|
+
*
|
|
255
|
+
* `invoke` is a stable reference across renders for the same module, operation,
|
|
256
|
+
* fallback and transport, making it safe to use inside `useEffect` deps.
|
|
257
|
+
*/
|
|
258
|
+
declare function useModuleTool<TReq, TRes>(moduleKey: string, operationKey: string, fallbackToolName: string, opts?: UseModuleToolOptions): UseModuleToolResult<TReq, TRes>;
|
|
259
|
+
|
|
260
|
+
interface UseModuleQueryOptions {
|
|
261
|
+
/**
|
|
262
|
+
* Gate the fetch on a guard. When false the hook returns idle state and never
|
|
263
|
+
* invokes, which is how a read that depends on a selection is expressed without
|
|
264
|
+
* violating the rules of hooks. Defaults to `true`.
|
|
265
|
+
*/
|
|
266
|
+
enabled?: boolean;
|
|
267
|
+
}
|
|
268
|
+
interface UseModuleQueryResult<TRes> {
|
|
269
|
+
data: TRes | undefined;
|
|
270
|
+
loading: boolean;
|
|
271
|
+
error: Error | undefined;
|
|
272
|
+
/** Re-run the fetch against the current args. */
|
|
273
|
+
refetch: () => void;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The cross-application counterpart to {@link useMcpQuery}: an auto-fetching read that
|
|
277
|
+
* names a MODULE and an OPERATION, so the operator's provider selection decides which
|
|
278
|
+
* application answers.
|
|
279
|
+
*
|
|
280
|
+
* Use this, not {@link useMcpQuery}, for another application's data. A surface
|
|
281
|
+
* capability token is refused for cross-extension tools (EXT_MCP_008), so naming
|
|
282
|
+
* `hr:list-employees` from a plugin surface reaches nothing and the picker renders
|
|
283
|
+
* empty. Naming the operation reaches the chosen provider, and falls back to
|
|
284
|
+
* `fallbackToolName` while none is chosen, which is where every organisation starts.
|
|
285
|
+
*
|
|
286
|
+
* Keep {@link useMcpQuery} for the plugin's own tools and for platform intrinsics such
|
|
287
|
+
* as `users:*`: where only one source can answer there is no choice to model, and
|
|
288
|
+
* routing such a read through a per-organisation lookup is the failure that emptied
|
|
289
|
+
* the onboarding admin picker for every SDK-hosted plugin.
|
|
290
|
+
*/
|
|
291
|
+
declare function useModuleQuery<TArgs, TRes>(moduleKey: string, operationKey: string, fallbackToolName: string, args: TArgs, options?: UseModuleQueryOptions): UseModuleQueryResult<TRes>;
|
|
292
|
+
|
|
221
293
|
interface UseMcpResourceOptions {
|
|
222
294
|
/**
|
|
223
295
|
* Override the transport resolved from {@link ExtensionRuntimeProvider}.
|
|
@@ -685,4 +757,4 @@ interface UseAuthResult {
|
|
|
685
757
|
*/
|
|
686
758
|
declare function useAuth(transport: McpTransport): UseAuthResult;
|
|
687
759
|
|
|
688
|
-
export { BridgeClientContext, type ClientPushChannel, ClientPushContext, type ClientPushEvent, type ClientPushSubscribeOptions, type CreatePortMcpTransportOptions, type CreateRemoteRootOptions, type DeclarativePluginConfig, type EthisysPluginConfig, ExtensionRuntimeProvider, type ExtensionRuntimeProviderProps, type HostIdentity, HostIdentityContext, type HostIdentityUser, type HostPermission, type ItemsResponse, LocalePayload, McpTransport, PluginRealtimeContext, type PluginRealtimeSource, PortBridgeClient, type PortShim, type RemoteRoot, ThemePayload, type UseAuthResult, type UseClientPushSubscriptionOptions, type UseFrontendSessionTokenResult, type UseMcpQueryOptions, type UseMcpQueryResult, type UseMcpResourceOptions, type UseMcpResourceResult, type UseMcpToolOptions, type UseMcpToolResult, createPortMcpTransport, createRemoteRoot, decodeJwtPayload, defineDeclarativePlugin, defineEthisysPlugin, unwrapItems, useAuth, useBridgeClient, useBridgeLocale, useBridgeTheme, useClientPushSubscription, useExtensionRuntimeTransport, useFrontendSessionToken, useHostIdentity, useMcpQuery, useMcpResource, useMcpTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource };
|
|
760
|
+
export { BridgeClientContext, type ClientPushChannel, ClientPushContext, type ClientPushEvent, type ClientPushSubscribeOptions, type CreatePortMcpTransportOptions, type CreateRemoteRootOptions, type DeclarativePluginConfig, type EthisysPluginConfig, ExtensionRuntimeProvider, type ExtensionRuntimeProviderProps, type HostIdentity, HostIdentityContext, type HostIdentityUser, type HostPermission, type ItemsResponse, LocalePayload, McpTransport, PluginRealtimeContext, type PluginRealtimeSource, PortBridgeClient, type PortShim, type RemoteRoot, ThemePayload, type UseAuthResult, type UseClientPushSubscriptionOptions, type UseFrontendSessionTokenResult, type UseMcpQueryOptions, type UseMcpQueryResult, type UseMcpResourceOptions, type UseMcpResourceResult, type UseMcpToolOptions, type UseMcpToolResult, type UseModuleQueryOptions, type UseModuleQueryResult, type UseModuleToolOptions, type UseModuleToolResult, createPortMcpTransport, createRemoteRoot, decodeJwtPayload, defineDeclarativePlugin, defineEthisysPlugin, unwrapItems, useAuth, useBridgeClient, useBridgeLocale, useBridgeTheme, useClientPushSubscription, useExtensionRuntimeTransport, useFrontendSessionToken, useHostIdentity, useMcpQuery, useMcpResource, useMcpTool, useModuleQuery, useModuleTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource };
|
package/dist/plugin/index.js
CHANGED
|
@@ -58,6 +58,98 @@ function useOptionalExtensionRuntimeTransport(override) {
|
|
|
58
58
|
const fromContext = useContext(ExtensionRuntimeContext);
|
|
59
59
|
return override ?? fromContext ?? null;
|
|
60
60
|
}
|
|
61
|
+
function useModuleTool(moduleKey, operationKey, fallbackToolName, opts) {
|
|
62
|
+
const transport = useExtensionRuntimeTransport(opts?.transport);
|
|
63
|
+
const [loading, setLoading] = useState(false);
|
|
64
|
+
const [error, setError] = useState(void 0);
|
|
65
|
+
const controllerRef = useRef(null);
|
|
66
|
+
const mountedRef = useRef(true);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
mountedRef.current = true;
|
|
69
|
+
return () => {
|
|
70
|
+
mountedRef.current = false;
|
|
71
|
+
controllerRef.current?.abort();
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
74
|
+
const invoke = useCallback(
|
|
75
|
+
async (req) => {
|
|
76
|
+
const controller = new AbortController();
|
|
77
|
+
controllerRef.current?.abort();
|
|
78
|
+
controllerRef.current = controller;
|
|
79
|
+
setLoading(true);
|
|
80
|
+
setError(void 0);
|
|
81
|
+
try {
|
|
82
|
+
const invokeOperation = transport.invokeOperation;
|
|
83
|
+
if (typeof invokeOperation !== "function") {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`This host's MCP transport does not support module operations, so ${moduleKey}/${operationKey} cannot be resolved to a provider. Upgrade the host, or call the plugin's own proxy tool with useMcpTool instead.`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const result = await invokeOperation.call(
|
|
89
|
+
transport,
|
|
90
|
+
moduleKey,
|
|
91
|
+
operationKey,
|
|
92
|
+
fallbackToolName,
|
|
93
|
+
req,
|
|
94
|
+
controller.signal
|
|
95
|
+
);
|
|
96
|
+
if (mountedRef.current && !controller.signal.aborted) {
|
|
97
|
+
setLoading(false);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
} catch (err) {
|
|
101
|
+
const wrapped = err instanceof Error ? err : new Error(String(err));
|
|
102
|
+
if (mountedRef.current && !controller.signal.aborted) {
|
|
103
|
+
setError(wrapped);
|
|
104
|
+
setLoading(false);
|
|
105
|
+
}
|
|
106
|
+
throw wrapped;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
[transport, moduleKey, operationKey, fallbackToolName]
|
|
110
|
+
);
|
|
111
|
+
return { invoke, loading, error };
|
|
112
|
+
}
|
|
113
|
+
function useModuleQuery(moduleKey, operationKey, fallbackToolName, args, options) {
|
|
114
|
+
const enabled = options?.enabled ?? true;
|
|
115
|
+
const { invoke } = useModuleTool(moduleKey, operationKey, fallbackToolName);
|
|
116
|
+
const [data, setData] = useState(void 0);
|
|
117
|
+
const [loading, setLoading] = useState(enabled);
|
|
118
|
+
const [error, setError] = useState(void 0);
|
|
119
|
+
const [tick, setTick] = useState(0);
|
|
120
|
+
const argsKey = JSON.stringify(args);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (!enabled) {
|
|
123
|
+
setLoading(false);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
let cancelled = false;
|
|
127
|
+
setLoading(true);
|
|
128
|
+
invoke(args).then((result) => {
|
|
129
|
+
if (cancelled) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
setData(result);
|
|
133
|
+
setError(void 0);
|
|
134
|
+
setLoading(false);
|
|
135
|
+
}).catch((err) => {
|
|
136
|
+
if (cancelled) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
140
|
+
setLoading(false);
|
|
141
|
+
});
|
|
142
|
+
return () => {
|
|
143
|
+
cancelled = true;
|
|
144
|
+
};
|
|
145
|
+
}, [argsKey, tick, invoke, enabled]);
|
|
146
|
+
return {
|
|
147
|
+
data,
|
|
148
|
+
loading,
|
|
149
|
+
error,
|
|
150
|
+
refetch: () => setTick((t) => t + 1)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
61
153
|
function useMcpResource(uri, opts) {
|
|
62
154
|
const transport = useExtensionRuntimeTransport(opts?.transport);
|
|
63
155
|
const [data, setData] = useState(void 0);
|
|
@@ -899,6 +991,6 @@ function useAuth(transport) {
|
|
|
899
991
|
};
|
|
900
992
|
}
|
|
901
993
|
|
|
902
|
-
export { BridgeClientContext, ClientPushContext, ExtensionRuntimeProvider, HostIdentityContext, MCP_ERROR_CODES, McpToolError, PluginRealtimeContext, classifyHostError, classifyHostResponse, createPortBridgeClient, createPortMcpTransport, createRemoteRoot, decodeJwtPayload, defineDeclarativePlugin, defineEthisysPlugin, isMcpErrorCode, isMcpToolError, isRetryableMcpErrorCode, mcpErrorCodeFromHttpStatus, unwrapItems, useAuth, useBridgeClient, useBridgeLocale, useBridgeTheme, useClientPushSubscription, useExtensionRuntimeTransport, useFrontendSessionToken, useHostIdentity, useMcpQuery, useMcpResource, useMcpTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource };
|
|
994
|
+
export { BridgeClientContext, ClientPushContext, ExtensionRuntimeProvider, HostIdentityContext, MCP_ERROR_CODES, McpToolError, PluginRealtimeContext, classifyHostError, classifyHostResponse, createPortBridgeClient, createPortMcpTransport, createRemoteRoot, decodeJwtPayload, defineDeclarativePlugin, defineEthisysPlugin, isMcpErrorCode, isMcpToolError, isRetryableMcpErrorCode, mcpErrorCodeFromHttpStatus, unwrapItems, useAuth, useBridgeClient, useBridgeLocale, useBridgeTheme, useClientPushSubscription, useExtensionRuntimeTransport, useFrontendSessionToken, useHostIdentity, useMcpQuery, useMcpResource, useMcpTool, useModuleQuery, useModuleTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource };
|
|
903
995
|
//# sourceMappingURL=index.js.map
|
|
904
996
|
//# sourceMappingURL=index.js.map
|