@devframes/hub 0.7.16 → 0.8.1
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/client/index.d.mts +25 -5
- package/dist/client/index.mjs +71 -2
- package/dist/constants.d.mts +1 -1
- package/dist/{context-Bg8Y0rGG.d.mts → context-Cw5sDVoA.d.mts} +1 -1
- package/dist/{index-ra1YGFux.d.mts → index-Bx3T-R7i.d.mts} +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/node/index.d.mts +19 -2
- package/dist/node/index.mjs +54 -44
- package/dist/remote-url-KVXtKP47.mjs +73 -0
- package/dist/{settings-BV2OlKYo.d.mts → settings-Byh48aCd.d.mts} +46 -1
- package/dist/types/index.d.mts +4 -4
- package/package.json +5 -4
package/dist/client/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { N as NavTarget, O as DevframeViewIframe, P as RemoteConnectionInfo, a as DevframeCommandEntry, g as DevframeDockEntry, h as DevframeDockEntriesGrouped, n as DevframeClientCommand, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings, x as DevframeDockUserEntry, y as DevframeDockEntryIcon } from "../settings-Byh48aCd.mjs";
|
|
2
2
|
import { DEFAULT_CATEGORIES_ORDER } from "../constants.mjs";
|
|
3
|
-
import { w as DevframeMessagesClient, y as DevframeMessageEntryInput } from "../context-
|
|
4
|
-
import "../index-
|
|
5
|
-
import { DevframeClientRpcHost, DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientOptions, DevframeRpcContext, RpcClientEvents, RpcClientEvents as RpcClientEvents$1 } from "devframe/client";
|
|
3
|
+
import { w as DevframeMessagesClient, y as DevframeMessageEntryInput } from "../context-Cw5sDVoA.mjs";
|
|
4
|
+
import "../index-Bx3T-R7i.mjs";
|
|
5
|
+
import { DevframeClientRpcHost, DevframeConnection, DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientOptions, DevframeRpcContext, RpcClientEvents, RpcClientEvents as RpcClientEvents$1 } from "devframe/client";
|
|
6
6
|
import { EventEmitter } from "devframe/types";
|
|
7
7
|
import { SharedState } from "devframe/utils/shared-state";
|
|
8
8
|
import { WhenContext } from "devframe/utils/when";
|
|
@@ -256,6 +256,16 @@ declare function getDevframeClientContext(): DevframeClientContext | undefined;
|
|
|
256
256
|
*/
|
|
257
257
|
declare function setDevframeClientContext(ctx: DevframeClientContext | undefined): void;
|
|
258
258
|
//#endregion
|
|
259
|
+
//#region src/client/dock-resources.d.ts
|
|
260
|
+
/**
|
|
261
|
+
* Resolve a dock iframe URL relative to the Devframe server that provided the
|
|
262
|
+
* dock entry. This keeps root-relative and dot-relative paths on the host
|
|
263
|
+
* server when an external viewer renders the hub.
|
|
264
|
+
*/
|
|
265
|
+
declare function resolveDockUrl(url: string, connection: DevframeConnection): string;
|
|
266
|
+
/** Resolve URL-backed dock icons while preserving Iconify names and data URLs. */
|
|
267
|
+
declare function resolveDockIcon(icon: DevframeDockEntryIcon, connection: DevframeConnection): DevframeDockEntryIcon;
|
|
268
|
+
//#endregion
|
|
259
269
|
//#region src/client/frame-nav.d.ts
|
|
260
270
|
/**
|
|
261
271
|
* Shared-iframe soft navigation — the viewer-side half of a host↔iframe
|
|
@@ -463,8 +473,18 @@ interface MessagesClientOptions {
|
|
|
463
473
|
*/
|
|
464
474
|
declare function createMessagesClient(rpc: DevframeRpcClient, options?: MessagesClientOptions): DevframeMessagesClient;
|
|
465
475
|
//#endregion
|
|
476
|
+
//#region src/remote-url.d.ts
|
|
477
|
+
/** Remove the remote connection descriptor from a URL before displaying or copying it. */
|
|
478
|
+
declare function stripRemoteConnectionFromUrl(input: string): string;
|
|
479
|
+
//#endregion
|
|
466
480
|
//#region src/client/remote.d.ts
|
|
467
481
|
type ConnectRemoteDevframeOptions = Omit<DevframeRpcClientOptions, 'connectionMeta' | 'authToken'>;
|
|
482
|
+
/**
|
|
483
|
+
* Build an external viewer URL from an existing trusted Devframe connection.
|
|
484
|
+
* Returns the original URL if the connection has no auth token, does not use
|
|
485
|
+
* WebSockets, or has an invalid metadata URL.
|
|
486
|
+
*/
|
|
487
|
+
declare function buildRemoteDevframeUrl(url: string, connection: DevframeConnection): string;
|
|
468
488
|
/**
|
|
469
489
|
* Parse a {@link RemoteConnectionInfo} descriptor from the current page's URL
|
|
470
490
|
* (or a provided URL/string). Checks the URL fragment first, then the query.
|
|
@@ -484,4 +504,4 @@ declare function parseRemoteConnection(input?: string): RemoteConnectionInfo | n
|
|
|
484
504
|
*/
|
|
485
505
|
declare function connectRemoteDevframe(options?: ConnectRemoteDevframeOptions): Promise<DevframeRpcClient>;
|
|
486
506
|
//#endregion
|
|
487
|
-
export { CLIENT_CONTEXT_KEY, CommandsContext, ConnectRemoteDevframeOptions, DEFAULT_CATEGORIES_ORDER, DevframeClientContext, DevframeClientHost, DevframeClientHostOptions, type DevframeClientRpcHost, DockClientScriptContext, DockClientType, DockEntryState, DockEntryStateEvents, DockPanelStorage, DockRegistration, DockRenderer, DockRendererInstance, DockRendererMountOptions, DockRenderersContext, DocksConnectionContext, DocksContext, DocksEntriesContext, DocksPanelContext, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, FrameNavClient, FrameNavClientOptions, FrameNavEnvelope, FrameNavFrameMessage, FrameNavHostMessage, FrameNavHostPayload, FrameNavListenTarget, FrameTab, MessagesClientOptions, type RpcClientEvents, WhenClauseContext, attachFrameNavClient, connectRemoteDevframe, createDevframeClientHost, createMessagesClient, getDevframeClientContext, parseRemoteConnection, setDevframeClientContext };
|
|
507
|
+
export { CLIENT_CONTEXT_KEY, CommandsContext, ConnectRemoteDevframeOptions, DEFAULT_CATEGORIES_ORDER, DevframeClientContext, DevframeClientHost, DevframeClientHostOptions, type DevframeClientRpcHost, DockClientScriptContext, DockClientType, DockEntryState, DockEntryStateEvents, DockPanelStorage, DockRegistration, DockRenderer, DockRendererInstance, DockRendererMountOptions, DockRenderersContext, DocksConnectionContext, DocksContext, DocksEntriesContext, DocksPanelContext, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, FrameNavClient, FrameNavClientOptions, FrameNavEnvelope, FrameNavFrameMessage, FrameNavHostMessage, FrameNavHostPayload, FrameNavListenTarget, FrameTab, MessagesClientOptions, type RpcClientEvents, WhenClauseContext, attachFrameNavClient, buildRemoteDevframeUrl, connectRemoteDevframe, createDevframeClientHost, createMessagesClient, getDevframeClientContext, parseRemoteConnection, resolveDockIcon, resolveDockUrl, setDevframeClientContext, stripRemoteConnectionFromUrl };
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS } from "../constants.mjs";
|
|
2
|
+
import { n as stripRemoteConnectionFromUrl, t as buildRemoteConnectionUrl } from "../remote-url-KVXtKP47.mjs";
|
|
2
3
|
import { REMOTE_CONNECTION_KEY } from "devframe/constants";
|
|
3
|
-
import { connectDevframe, getDevframeRpcClient } from "devframe/client";
|
|
4
|
+
import { connectDevframe, getDevframeRpcClient, resolveWsUrl } from "devframe/client";
|
|
4
5
|
import { createEventEmitter } from "devframe/utils/events";
|
|
5
6
|
import { destr } from "destr";
|
|
6
7
|
export * from "devframe/client";
|
|
@@ -21,6 +22,53 @@ function setDevframeClientContext(ctx) {
|
|
|
21
22
|
globalThis[CLIENT_CONTEXT_KEY] = ctx;
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
25
|
+
//#region src/client/dock-resources.ts
|
|
26
|
+
const URL_SCHEME_RE = /^[a-z][a-z\d+.-]*:/i;
|
|
27
|
+
function resolveResourceUrl(value, connection) {
|
|
28
|
+
const url = value.trim();
|
|
29
|
+
if (!url || URL_SCHEME_RE.test(url) || url.startsWith("//")) return url;
|
|
30
|
+
if (!url.startsWith("/") && !url.startsWith("./") && !url.startsWith("../")) return url;
|
|
31
|
+
try {
|
|
32
|
+
return new URL(url, connection.metaBaseUrl).href;
|
|
33
|
+
} catch {
|
|
34
|
+
return url;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function resolveIconUrl(value, connection) {
|
|
38
|
+
const url = value.trim();
|
|
39
|
+
if (!url || URL_SCHEME_RE.test(url) || url.startsWith("//")) return url;
|
|
40
|
+
if (!url.includes("/") && !url.includes(".")) return url;
|
|
41
|
+
try {
|
|
42
|
+
return new URL(url, connection.metaBaseUrl).href;
|
|
43
|
+
} catch {
|
|
44
|
+
return url;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolve a dock iframe URL relative to the Devframe server that provided the
|
|
49
|
+
* dock entry. This keeps root-relative and dot-relative paths on the host
|
|
50
|
+
* server when an external viewer renders the hub.
|
|
51
|
+
*/
|
|
52
|
+
function resolveDockUrl(url, connection) {
|
|
53
|
+
const resolved = resolveResourceUrl(url, connection);
|
|
54
|
+
if (resolved !== url.trim()) return resolved;
|
|
55
|
+
const value = url.trim();
|
|
56
|
+
if (!value || URL_SCHEME_RE.test(value) || value.startsWith("//")) return /^localhost:\d/i.test(value) ? `http://${value}` : value;
|
|
57
|
+
try {
|
|
58
|
+
return new URL(`http://${value}`).href;
|
|
59
|
+
} catch {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Resolve URL-backed dock icons while preserving Iconify names and data URLs. */
|
|
64
|
+
function resolveDockIcon(icon, connection) {
|
|
65
|
+
if (typeof icon === "string") return resolveIconUrl(icon, connection);
|
|
66
|
+
return {
|
|
67
|
+
light: resolveIconUrl(icon.light, connection),
|
|
68
|
+
dark: resolveIconUrl(icon.dark, connection)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
24
72
|
//#region src/client/frame-nav.ts
|
|
25
73
|
/**
|
|
26
74
|
* Shared-iframe soft navigation — the viewer-side half of a host↔iframe
|
|
@@ -650,6 +698,27 @@ function base64UrlDecode(value) {
|
|
|
650
698
|
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
651
699
|
return new TextDecoder().decode(bytes);
|
|
652
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Build an external viewer URL from an existing trusted Devframe connection.
|
|
703
|
+
* Returns the original URL if the connection has no auth token, does not use
|
|
704
|
+
* WebSockets, or has an invalid metadata URL.
|
|
705
|
+
*/
|
|
706
|
+
function buildRemoteDevframeUrl(url, connection) {
|
|
707
|
+
if (!connection.authToken || connection.connectionMeta.backend !== "websocket") return url;
|
|
708
|
+
let base;
|
|
709
|
+
try {
|
|
710
|
+
base = new URL(connection.metaBaseUrl);
|
|
711
|
+
} catch {
|
|
712
|
+
return url;
|
|
713
|
+
}
|
|
714
|
+
return buildRemoteConnectionUrl(url, {
|
|
715
|
+
v: 1,
|
|
716
|
+
backend: "websocket",
|
|
717
|
+
websocket: resolveWsUrl(connection.connectionMeta.websocket, connection.metaBaseUrl, base),
|
|
718
|
+
authToken: connection.authToken,
|
|
719
|
+
origin: base.origin
|
|
720
|
+
});
|
|
721
|
+
}
|
|
653
722
|
function extractKeyFromFragment(hash) {
|
|
654
723
|
if (!hash) return null;
|
|
655
724
|
const raw = hash.startsWith("#") ? hash.slice(1) : hash;
|
|
@@ -726,4 +795,4 @@ async function connectRemoteDevframe(options = {}) {
|
|
|
726
795
|
});
|
|
727
796
|
}
|
|
728
797
|
//#endregion
|
|
729
|
-
export { CLIENT_CONTEXT_KEY, DEFAULT_CATEGORIES_ORDER, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, attachFrameNavClient, connectRemoteDevframe, createDevframeClientHost, createMessagesClient, getDevframeClientContext, parseRemoteConnection, setDevframeClientContext };
|
|
798
|
+
export { CLIENT_CONTEXT_KEY, DEFAULT_CATEGORIES_ORDER, FRAME_NAV_CHANNEL, FRAME_NAV_VERSION, attachFrameNavClient, buildRemoteDevframeUrl, connectRemoteDevframe, createDevframeClientHost, createMessagesClient, getDevframeClientContext, parseRemoteConnection, resolveDockIcon, resolveDockUrl, setDevframeClientContext, stripRemoteConnectionFromUrl };
|
package/dist/constants.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as DevframeDocksHost, L as JsonRenderSpec, R as JsonRenderer, l as DevframeCommandsHost, m as DevframeDockActivation, y as DevframeDockEntryIcon } from "./settings-Byh48aCd.mjs";
|
|
2
2
|
import { CreateHostContextOptions } from "devframe/node";
|
|
3
3
|
import { DevframeHost, DevframeNodeContext, EventEmitter } from "devframe/types";
|
|
4
4
|
import { ChildProcess } from "node:child_process";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./settings-
|
|
2
|
-
import "./context-
|
|
1
|
+
import "./settings-Byh48aCd.mjs";
|
|
2
|
+
import "./context-Cw5sDVoA.mjs";
|
|
3
3
|
import { RpcDefinitionsFilter, RpcDefinitionsToFunctions } from "devframe/rpc";
|
|
4
4
|
import { ConnectionMeta as ConnectionMeta$1, DevframeCapabilities, DevframeDiagnosticsDefinition, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeHost as DevframeHost$1, DevframeNodeRpcSession, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeViewHost, EntriesToObject, EventEmitter as EventEmitter$1, EventUnsubscribe, EventsMap, PartialWithoutId, RpcBroadcastOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, Thenable } from "devframe/types";
|
|
5
5
|
export { RpcStreamingChannel as C, Thenable as E, RpcSharedStateHost as S, RpcStreamingHost as T, RpcBroadcastOptions as _, DevframeDiagnosticsLogger as a, RpcFunctionsHost as b, DevframeRpcClientFunctions as c, DevframeViewHost as d, EntriesToObject as f, PartialWithoutId as g, EventsMap as h, DevframeDiagnosticsHost as i, DevframeRpcServerFunctions as l, EventUnsubscribe as m, DevframeCapabilities as n, DevframeHost$1 as o, EventEmitter$1 as p, DevframeDiagnosticsDefinition as r, DevframeNodeRpcSession as s, ConnectionMeta$1 as t, DevframeRpcSharedStates as u, RpcDefinitionsFilter as v, RpcStreamingChannelOptions as w, RpcSharedStateGetOptions as x, RpcDefinitionsToFunctions as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as DevframeViewLauncher, C as DevframeDocksHost, D as DevframeViewGroup, E as DevframeViewCustomRender, F as RemoteDockOptions, I as JsonRenderElement, L as JsonRenderSpec, M as FrameSubTabsConfig, N as NavTarget, O as DevframeViewIframe, P as RemoteConnectionInfo, R as JsonRenderer, S as DevframeDocksActiveState, T as DevframeViewBuiltin, _ as DevframeDockEntryBase, a as DevframeCommandEntry, b as DevframeDockEntryRegistry, c as DevframeCommandShortcutOverrides, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, g as DevframeDockEntry, h as DevframeDockEntriesGrouped, i as DevframeCommandBase, j as DevframeViewLauncherStatus, k as DevframeViewJsonRender, l as DevframeCommandsHost, m as DevframeDockActivation, n as DevframeClientCommand, o as DevframeCommandHandle, p as ClientScriptEntry, r as DevframeCommandAgentOptions, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings, u as DevframeCommandsHostEvents, v as DevframeDockEntryCategory, w as DevframeViewAction, x as DevframeDockUserEntry, y as DevframeDockEntryIcon } from "./settings-Byh48aCd.mjs";
|
|
2
2
|
import { DEFAULT_CATEGORIES_ORDER } from "./constants.mjs";
|
|
3
|
-
import { C as DevframeMessageShortcutInput, D as DevframeMessagesListDelta, E as DevframeMessagesLevelShortcuts, S as DevframeMessageLevel, T as DevframeMessagesHost, _ as DevframeMessageEntry, a as DevframeChildProcessOutput, b as DevframeMessageFilePosition, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageElementPosition, h as DevframeMessageActivateAction, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageAction, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageEntryFrom, w as DevframeMessagesClient, x as DevframeMessageHandle, y as DevframeMessageEntryInput } from "./context-
|
|
4
|
-
import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "./index-
|
|
3
|
+
import { C as DevframeMessageShortcutInput, D as DevframeMessagesListDelta, E as DevframeMessagesLevelShortcuts, S as DevframeMessageLevel, T as DevframeMessagesHost, _ as DevframeMessageEntry, a as DevframeChildProcessOutput, b as DevframeMessageFilePosition, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageElementPosition, h as DevframeMessageActivateAction, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageAction, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageEntryFrom, w as DevframeMessagesClient, x as DevframeMessageHandle, y as DevframeMessageEntryInput } from "./context-Cw5sDVoA.mjs";
|
|
4
|
+
import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "./index-Bx3T-R7i.mjs";
|
|
5
5
|
import { WhenContext, WhenExpression } from "devframe/utils/when";
|
|
6
6
|
//#region src/define.d.ts
|
|
7
7
|
declare const defineHubRpcFunction: <NAME extends string, TYPE extends import("devframe/rpc").RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends import("devframe/rpc").RpcArgsSchema | undefined = undefined, const RS extends import("devframe/rpc").RpcReturnSchema | undefined = undefined>(definition: import("devframe/rpc").RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>) => import("devframe/rpc").RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeHubContext>;
|
|
@@ -21,4 +21,4 @@ declare function defineDockEntry<const T extends DevframeDockUserEntry, const W
|
|
|
21
21
|
*/
|
|
22
22
|
declare function defineJsonRenderSpec(spec: JsonRenderSpec): JsonRenderSpec;
|
|
23
23
|
//#endregion
|
|
24
|
-
export { type ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, DEFAULT_CATEGORIES_ORDER, type DevframeCapabilities, type DevframeChildProcessExecuteOptions, type DevframeChildProcessOutput, type DevframeChildProcessResult, type DevframeChildProcessTerminalSession, type DevframeClientCommand, type DevframeCommandBase, type DevframeCommandEntry, type DevframeCommandHandle, type DevframeCommandKeybinding, type DevframeCommandShortcutOverrides, type DevframeCommandsHost, type DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockActivation, type DevframeDockEntriesGrouped, type DevframeDockEntry, type DevframeDockEntryBase, type DevframeDockEntryCategory, type DevframeDockEntryIcon, type DevframeDockEntryRegistry, type DevframeDockUserEntry, type DevframeDocksActiveState, type DevframeDocksHost, type DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, type DevframeMessageAction, type DevframeMessageActivateAction, type DevframeMessageElementPosition, type DevframeMessageEntry, type DevframeMessageEntryFrom, type DevframeMessageEntryInput, type DevframeMessageFilePosition, type DevframeMessageHandle, type DevframeMessageLevel, type DevframeMessageShortcutInput, type DevframeMessagesClient, type DevframeMessagesHost, type DevframeMessagesLevelShortcuts, type DevframeMessagesListDelta, type DevframeNodeRpcSession, type DevframePtyExecuteOptions, type DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeServerCommandEntry, type DevframeServerCommandInput, type DevframeTerminalSession, type DevframeTerminalSessionBase, type DevframeTerminalStatus, type DevframeTerminalsHost, type DevframeViewAction, type DevframeViewBuiltin, type DevframeViewCustomRender, type DevframeViewGroup, type DevframeViewHost, type DevframeViewIframe, type DevframeViewJsonRender, type DevframeViewLauncher, type DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, type FrameSubTabsConfig, type JsonRenderElement, type JsonRenderSpec, type JsonRenderer, type NavTarget, type PartialWithoutId, type RemoteConnectionInfo, type RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable, defineCommand, defineDockEntry, defineHubRpcFunction, defineJsonRenderSpec };
|
|
24
|
+
export { type ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, DEFAULT_CATEGORIES_ORDER, type DevframeCapabilities, type DevframeChildProcessExecuteOptions, type DevframeChildProcessOutput, type DevframeChildProcessResult, type DevframeChildProcessTerminalSession, type DevframeClientCommand, type DevframeCommandAgentOptions, type DevframeCommandBase, type DevframeCommandEntry, type DevframeCommandHandle, type DevframeCommandKeybinding, type DevframeCommandShortcutOverrides, type DevframeCommandsHost, type DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockActivation, type DevframeDockEntriesGrouped, type DevframeDockEntry, type DevframeDockEntryBase, type DevframeDockEntryCategory, type DevframeDockEntryIcon, type DevframeDockEntryRegistry, type DevframeDockUserEntry, type DevframeDocksActiveState, type DevframeDocksHost, type DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, type DevframeMessageAction, type DevframeMessageActivateAction, type DevframeMessageElementPosition, type DevframeMessageEntry, type DevframeMessageEntryFrom, type DevframeMessageEntryInput, type DevframeMessageFilePosition, type DevframeMessageHandle, type DevframeMessageLevel, type DevframeMessageShortcutInput, type DevframeMessagesClient, type DevframeMessagesHost, type DevframeMessagesLevelShortcuts, type DevframeMessagesListDelta, type DevframeNodeRpcSession, type DevframePtyExecuteOptions, type DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeServerCommandEntry, type DevframeServerCommandInput, type DevframeTerminalSession, type DevframeTerminalSessionBase, type DevframeTerminalStatus, type DevframeTerminalsHost, type DevframeViewAction, type DevframeViewBuiltin, type DevframeViewCustomRender, type DevframeViewGroup, type DevframeViewHost, type DevframeViewIframe, type DevframeViewJsonRender, type DevframeViewLauncher, type DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, type FrameSubTabsConfig, type JsonRenderElement, type JsonRenderSpec, type JsonRenderer, type NavTarget, type PartialWithoutId, type RemoteConnectionInfo, type RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable, defineCommand, defineDockEntry, defineHubRpcFunction, defineJsonRenderSpec };
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as DevframeDocksHost$1, O as DevframeViewIframe, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, g as DevframeDockEntry, l as DevframeCommandsHost$1, o as DevframeCommandHandle, p as ClientScriptEntry, t as DevframeDocksUserSettings, x as DevframeDockUserEntry } from "../settings-Byh48aCd.mjs";
|
|
2
2
|
import { DEFAULT_CATEGORIES_ORDER } from "../constants.mjs";
|
|
3
|
-
import { C as DevframeMessageShortcutInput, D as DevframeMessagesListDelta, T as DevframeMessagesHost$1, _ as DevframeMessageEntry, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, n as DevframeHubContext, p as DevframeTerminalsHost$1, r as createHubContext, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, x as DevframeMessageHandle, y as DevframeMessageEntryInput } from "../context-
|
|
3
|
+
import { C as DevframeMessageShortcutInput, D as DevframeMessagesListDelta, T as DevframeMessagesHost$1, _ as DevframeMessageEntry, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, n as DevframeHubContext, p as DevframeTerminalsHost$1, r as createHubContext, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, x as DevframeMessageHandle, y as DevframeMessageEntryInput } from "../context-Cw5sDVoA.mjs";
|
|
4
4
|
import { RpcFunctionDefinitionAny } from "devframe/rpc";
|
|
5
5
|
import { DevframeDefinition } from "devframe/types";
|
|
6
6
|
import { SharedState } from "devframe/utils/shared-state";
|
|
@@ -9,6 +9,12 @@ declare class DevframeCommandsHost implements DevframeCommandsHost$1 {
|
|
|
9
9
|
readonly context: DevframeHubContext;
|
|
10
10
|
readonly commands: DevframeCommandsHost$1['commands'];
|
|
11
11
|
readonly events: DevframeCommandsHost$1['events'];
|
|
12
|
+
/**
|
|
13
|
+
* Lazy agent projection: `ctx.agent` queries this provider at list/invoke
|
|
14
|
+
* time, deriving tools from {@link commands} on demand — the commands map
|
|
15
|
+
* stays the single source of truth, nothing is mirrored or kept in sync.
|
|
16
|
+
*/
|
|
17
|
+
private readonly agentProvider;
|
|
12
18
|
constructor(context: DevframeHubContext);
|
|
13
19
|
register(command: DevframeServerCommandInput): DevframeCommandHandle;
|
|
14
20
|
unregister(id: string): boolean;
|
|
@@ -16,6 +22,17 @@ declare class DevframeCommandsHost implements DevframeCommandsHost$1 {
|
|
|
16
22
|
list(): DevframeServerCommandEntry[];
|
|
17
23
|
private findCommand;
|
|
18
24
|
private toSerializable;
|
|
25
|
+
/** Reject `agent` on handler-less commands anywhere in the tree, up front. */
|
|
26
|
+
private validateAgentExposure;
|
|
27
|
+
/**
|
|
28
|
+
* Derive the agent-tool projection of the current command trees: every
|
|
29
|
+
* agent-flagged, handler-bearing command (children included) becomes a
|
|
30
|
+
* callable tool. Queried lazily by the provider registered in the
|
|
31
|
+
* constructor. `when` clauses evaluate client-side only and are not
|
|
32
|
+
* enforced here — opting in a `when`-gated command is a deliberate author
|
|
33
|
+
* decision (documented on `DevframeCommandAgentOptions`).
|
|
34
|
+
*/
|
|
35
|
+
private collectAgentTools;
|
|
19
36
|
}
|
|
20
37
|
//#endregion
|
|
21
38
|
//#region src/node/host-docks.d.ts
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS } from "../constants.mjs";
|
|
2
2
|
import { r as defineHubRpcFunction } from "../define-Pbx8dsKz.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { t as buildRemoteConnectionUrl } from "../remote-url-KVXtKP47.mjs";
|
|
4
4
|
import { createEventEmitter } from "devframe/utils/events";
|
|
5
|
-
import { createHostContext, createStorage } from "devframe/node";
|
|
5
|
+
import { coerceAgentPositionalArgs, createHostContext, createStorage } from "devframe/node";
|
|
6
6
|
import { debounce } from "perfect-debounce";
|
|
7
7
|
import { defineDiagnostics } from "nostics";
|
|
8
8
|
import { colors } from "devframe/utils/colors";
|
|
@@ -82,6 +82,10 @@ const diagnostics = defineDiagnostics({
|
|
|
82
82
|
DF8403: {
|
|
83
83
|
why: (p) => `Command id "${p.id}" is already used by another command or child command`,
|
|
84
84
|
fix: "Use globally unique command ids for top-level commands and all child commands."
|
|
85
|
+
},
|
|
86
|
+
DF8404: {
|
|
87
|
+
why: (p) => `Command "${p.id}" declares agent exposure but has no handler`,
|
|
88
|
+
fix: "Agent-exposed commands must be executable server-side. Add a `handler` to the command, or move the `agent` field to an executable child command."
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
});
|
|
@@ -116,14 +120,23 @@ var DevframeCommandsHost = class {
|
|
|
116
120
|
context;
|
|
117
121
|
commands = /* @__PURE__ */ new Map();
|
|
118
122
|
events = createEventEmitter();
|
|
123
|
+
/**
|
|
124
|
+
* Lazy agent projection: `ctx.agent` queries this provider at list/invoke
|
|
125
|
+
* time, deriving tools from {@link commands} on demand — the commands map
|
|
126
|
+
* stays the single source of truth, nothing is mirrored or kept in sync.
|
|
127
|
+
*/
|
|
128
|
+
agentProvider;
|
|
119
129
|
constructor(context) {
|
|
120
130
|
this.context = context;
|
|
131
|
+
this.agentProvider = context.agent?.registerToolProvider(() => this.collectAgentTools());
|
|
121
132
|
}
|
|
122
133
|
register(command) {
|
|
123
134
|
if (this.commands.has(command.id)) throw diagnostics.DF8400({ id: command.id });
|
|
124
135
|
validateCommandIds(this.commands, command);
|
|
136
|
+
this.validateAgentExposure(command);
|
|
125
137
|
this.commands.set(command.id, command);
|
|
126
138
|
this.events.emit("command:registered", this.toSerializable(command));
|
|
139
|
+
this.agentProvider?.notifyChanged();
|
|
127
140
|
return {
|
|
128
141
|
id: command.id,
|
|
129
142
|
update: (patch) => {
|
|
@@ -136,15 +149,20 @@ var DevframeCommandsHost = class {
|
|
|
136
149
|
id: existing.id
|
|
137
150
|
};
|
|
138
151
|
validateCommandIds(this.commands, next, existing.id);
|
|
152
|
+
this.validateAgentExposure(next);
|
|
139
153
|
Object.assign(existing, patch);
|
|
140
154
|
this.events.emit("command:registered", this.toSerializable(existing));
|
|
155
|
+
this.agentProvider?.notifyChanged();
|
|
141
156
|
},
|
|
142
157
|
unregister: () => this.unregister(command.id)
|
|
143
158
|
};
|
|
144
159
|
}
|
|
145
160
|
unregister(id) {
|
|
146
161
|
const deleted = this.commands.delete(id);
|
|
147
|
-
if (deleted)
|
|
162
|
+
if (deleted) {
|
|
163
|
+
this.events.emit("command:unregistered", id);
|
|
164
|
+
this.agentProvider?.notifyChanged();
|
|
165
|
+
}
|
|
148
166
|
return deleted;
|
|
149
167
|
}
|
|
150
168
|
async execute(id, ...args) {
|
|
@@ -165,13 +183,44 @@ var DevframeCommandsHost = class {
|
|
|
165
183
|
}
|
|
166
184
|
}
|
|
167
185
|
toSerializable(cmd) {
|
|
168
|
-
const { handler: _, children, ...rest } = cmd;
|
|
186
|
+
const { handler: _, agent: __, children, ...rest } = cmd;
|
|
169
187
|
return {
|
|
170
188
|
...rest,
|
|
171
189
|
source: "server",
|
|
172
190
|
...children ? { children: children.map((c) => this.toSerializable(c)) } : {}
|
|
173
191
|
};
|
|
174
192
|
}
|
|
193
|
+
/** Reject `agent` on handler-less commands anywhere in the tree, up front. */
|
|
194
|
+
validateAgentExposure(command) {
|
|
195
|
+
if (command.agent && !command.handler) throw diagnostics.DF8404({ id: command.id });
|
|
196
|
+
for (const child of command.children ?? []) this.validateAgentExposure(child);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Derive the agent-tool projection of the current command trees: every
|
|
200
|
+
* agent-flagged, handler-bearing command (children included) becomes a
|
|
201
|
+
* callable tool. Queried lazily by the provider registered in the
|
|
202
|
+
* constructor. `when` clauses evaluate client-side only and are not
|
|
203
|
+
* enforced here — opting in a `when`-gated command is a deliberate author
|
|
204
|
+
* decision (documented on `DevframeCommandAgentOptions`).
|
|
205
|
+
*/
|
|
206
|
+
collectAgentTools() {
|
|
207
|
+
const tools = [];
|
|
208
|
+
const walk = (command) => {
|
|
209
|
+
const agent = command.agent;
|
|
210
|
+
if (agent && command.handler) tools.push({
|
|
211
|
+
id: command.id,
|
|
212
|
+
title: agent.title ?? command.title,
|
|
213
|
+
description: agent.description,
|
|
214
|
+
safety: agent.safety ?? "action",
|
|
215
|
+
tags: agent.tags,
|
|
216
|
+
args: agent.args,
|
|
217
|
+
handler: async (args) => this.execute(command.id, ...coerceAgentPositionalArgs(args, agent.args, "drop"))
|
|
218
|
+
});
|
|
219
|
+
for (const child of command.children ?? []) walk(child);
|
|
220
|
+
};
|
|
221
|
+
for (const command of this.commands.values()) walk(command);
|
|
222
|
+
return tools;
|
|
223
|
+
}
|
|
175
224
|
};
|
|
176
225
|
//#endregion
|
|
177
226
|
//#region src/node/host-docks.ts
|
|
@@ -182,45 +231,6 @@ function normaliseRemoteOptions(remote) {
|
|
|
182
231
|
originLock: opts.originLock ?? true
|
|
183
232
|
};
|
|
184
233
|
}
|
|
185
|
-
function base64UrlEncode(value) {
|
|
186
|
-
const bytes = new TextEncoder().encode(value);
|
|
187
|
-
let binary = "";
|
|
188
|
-
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
189
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
190
|
-
}
|
|
191
|
-
function buildRemoteUrl(baseUrl, payload, transport) {
|
|
192
|
-
const encoded = base64UrlEncode(JSON.stringify(payload));
|
|
193
|
-
const param = `${REMOTE_CONNECTION_KEY}=${encoded}`;
|
|
194
|
-
if (transport === "fragment") {
|
|
195
|
-
const hashIdx = baseUrl.indexOf("#");
|
|
196
|
-
if (hashIdx === -1) return `${baseUrl}#${param}`;
|
|
197
|
-
const before = baseUrl.slice(0, hashIdx);
|
|
198
|
-
const rawHash = baseUrl.slice(hashIdx + 1);
|
|
199
|
-
if (!rawHash) return `${before}#${param}`;
|
|
200
|
-
const routeQueryIdx = rawHash.indexOf("?");
|
|
201
|
-
if (routeQueryIdx !== -1) {
|
|
202
|
-
const beforeQuery = rawHash.slice(0, routeQueryIdx + 1);
|
|
203
|
-
const params = new URLSearchParams(rawHash.slice(routeQueryIdx + 1));
|
|
204
|
-
params.set(REMOTE_CONNECTION_KEY, encoded);
|
|
205
|
-
return `${before}#${beforeQuery}${params.toString()}`;
|
|
206
|
-
}
|
|
207
|
-
const parts = rawHash.split("&");
|
|
208
|
-
const existingIdx = parts.findIndex((part) => {
|
|
209
|
-
const [key] = part.split("=");
|
|
210
|
-
return key === REMOTE_CONNECTION_KEY;
|
|
211
|
-
});
|
|
212
|
-
if (existingIdx >= 0) {
|
|
213
|
-
parts[existingIdx] = param;
|
|
214
|
-
return `${before}#${parts.join("&")}`;
|
|
215
|
-
}
|
|
216
|
-
return `${before}#${rawHash}&${param}`;
|
|
217
|
-
}
|
|
218
|
-
const qIdx = baseUrl.indexOf("?");
|
|
219
|
-
const hashIdx = baseUrl.indexOf("#");
|
|
220
|
-
const hash = hashIdx === -1 ? "" : baseUrl.slice(hashIdx);
|
|
221
|
-
const beforeHash = hashIdx === -1 ? baseUrl : baseUrl.slice(0, hashIdx);
|
|
222
|
-
return `${beforeHash}${qIdx === -1 || qIdx >= (hashIdx === -1 ? beforeHash.length : hashIdx) ? "?" : "&"}${param}${hash}`;
|
|
223
|
-
}
|
|
224
234
|
var DevframeDocksHost = class {
|
|
225
235
|
context;
|
|
226
236
|
views = /* @__PURE__ */ new Map();
|
|
@@ -254,7 +264,7 @@ var DevframeDocksHost = class {
|
|
|
254
264
|
};
|
|
255
265
|
return {
|
|
256
266
|
...view,
|
|
257
|
-
url:
|
|
267
|
+
url: buildRemoteConnectionUrl(view.url, payload, record.options.transport)
|
|
258
268
|
};
|
|
259
269
|
}
|
|
260
270
|
resolveDevServerOrigin() {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { REMOTE_CONNECTION_KEY } from "devframe/constants";
|
|
2
|
+
//#region src/remote-url.ts
|
|
3
|
+
function base64UrlEncode(value) {
|
|
4
|
+
const bytes = new TextEncoder().encode(value);
|
|
5
|
+
let binary = "";
|
|
6
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
7
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
8
|
+
}
|
|
9
|
+
function setRemoteConnectionParam(value, param) {
|
|
10
|
+
const parts = value ? value.split("&") : [];
|
|
11
|
+
const existingIdx = parts.findIndex((part) => part.split("=")[0] === REMOTE_CONNECTION_KEY);
|
|
12
|
+
if (existingIdx >= 0) parts[existingIdx] = param;
|
|
13
|
+
else parts.push(param);
|
|
14
|
+
return parts.join("&");
|
|
15
|
+
}
|
|
16
|
+
/** Encode a remote connection descriptor into an external viewer URL. */
|
|
17
|
+
function buildRemoteConnectionUrl(baseUrl, payload, transport = "fragment") {
|
|
18
|
+
const param = `${REMOTE_CONNECTION_KEY}=${base64UrlEncode(JSON.stringify(payload))}`;
|
|
19
|
+
if (transport === "fragment") {
|
|
20
|
+
const hashIdx = baseUrl.indexOf("#");
|
|
21
|
+
if (hashIdx === -1) return `${baseUrl}#${param}`;
|
|
22
|
+
const beforeHash = baseUrl.slice(0, hashIdx);
|
|
23
|
+
const rawHash = baseUrl.slice(hashIdx + 1);
|
|
24
|
+
if (!rawHash) return `${beforeHash}#${param}`;
|
|
25
|
+
const routeQueryIdx = rawHash.indexOf("?");
|
|
26
|
+
if (routeQueryIdx !== -1) return `${beforeHash}#${rawHash.slice(0, routeQueryIdx + 1)}${setRemoteConnectionParam(rawHash.slice(routeQueryIdx + 1), param)}`;
|
|
27
|
+
return `${beforeHash}#${setRemoteConnectionParam(rawHash, param)}`;
|
|
28
|
+
}
|
|
29
|
+
const hashIdx = baseUrl.indexOf("#");
|
|
30
|
+
const hash = hashIdx === -1 ? "" : baseUrl.slice(hashIdx);
|
|
31
|
+
const beforeHash = hashIdx === -1 ? baseUrl : baseUrl.slice(0, hashIdx);
|
|
32
|
+
return `${beforeHash}${beforeHash.includes("?") ? "&" : "?"}${param}${hash}`;
|
|
33
|
+
}
|
|
34
|
+
/** Remove the remote connection descriptor from a URL before displaying or copying it. */
|
|
35
|
+
function stripRemoteConnectionFromUrl(input) {
|
|
36
|
+
function stripParamList(value) {
|
|
37
|
+
const parts = value.split("&");
|
|
38
|
+
const filtered = parts.filter((part) => part.split("=")[0] !== REMOTE_CONNECTION_KEY);
|
|
39
|
+
return [filtered.join("&"), filtered.length !== parts.length];
|
|
40
|
+
}
|
|
41
|
+
const hashIdx = input.indexOf("#");
|
|
42
|
+
let beforeHash = hashIdx === -1 ? input : input.slice(0, hashIdx);
|
|
43
|
+
let hash = hashIdx === -1 ? void 0 : input.slice(hashIdx + 1);
|
|
44
|
+
let changed = false;
|
|
45
|
+
if (hash !== void 0) {
|
|
46
|
+
const routeQueryIdx = hash.indexOf("?");
|
|
47
|
+
if (routeQueryIdx === -1) {
|
|
48
|
+
const [nextHash, didChange] = stripParamList(hash);
|
|
49
|
+
hash = nextHash;
|
|
50
|
+
changed ||= didChange;
|
|
51
|
+
} else {
|
|
52
|
+
const route = hash.slice(0, routeQueryIdx);
|
|
53
|
+
const [query, didChange] = stripParamList(hash.slice(routeQueryIdx + 1));
|
|
54
|
+
if (didChange) {
|
|
55
|
+
hash = query ? `${route}?${query}` : route;
|
|
56
|
+
changed = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const queryIdx = beforeHash.indexOf("?");
|
|
61
|
+
if (queryIdx !== -1) {
|
|
62
|
+
const path = beforeHash.slice(0, queryIdx);
|
|
63
|
+
const [query, didChange] = stripParamList(beforeHash.slice(queryIdx + 1));
|
|
64
|
+
if (didChange) {
|
|
65
|
+
beforeHash = query ? `${path}?${query}` : path;
|
|
66
|
+
changed = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!changed) return input;
|
|
70
|
+
return hash ? `${beforeHash}#${hash}` : beforeHash;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { stripRemoteConnectionFromUrl as n, buildRemoteConnectionUrl as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
1
2
|
import { ConnectionMeta, EventEmitter } from "devframe/types";
|
|
2
3
|
//#region src/types/json-render.d.ts
|
|
3
4
|
/** @deprecated Use `DevframeJsonRenderSpec`'s element shape from `@devframes/json-render` instead. Removed in 0.8. */
|
|
@@ -496,6 +497,43 @@ interface DevframeCommandBase {
|
|
|
496
497
|
*/
|
|
497
498
|
keybindings?: DevframeCommandKeybinding[];
|
|
498
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* Opt-in agent exposure for a server command — mirrors the `agent` field on
|
|
502
|
+
* `defineRpcFunction`. A command carrying this field (and a `handler`) is
|
|
503
|
+
* projected into `ctx.agent` as a callable tool, reaching MCP clients through
|
|
504
|
+
* the devframe MCP adapter.
|
|
505
|
+
*
|
|
506
|
+
* `when` clauses are evaluated client-side only and are **not** enforced for
|
|
507
|
+
* agent calls — opt in a `when`-gated command only if running it outside its
|
|
508
|
+
* UI context is safe.
|
|
509
|
+
*
|
|
510
|
+
* @experimental The agent-native surface is experimental and may change
|
|
511
|
+
* without a major version bump until it stabilizes.
|
|
512
|
+
*/
|
|
513
|
+
interface DevframeCommandAgentOptions {
|
|
514
|
+
/**
|
|
515
|
+
* Description shown to the agent. Write it as a prompt: state when to call
|
|
516
|
+
* the command, not just what it does.
|
|
517
|
+
*/
|
|
518
|
+
description: string;
|
|
519
|
+
/** Display title (falls back to the command's `title`). */
|
|
520
|
+
title?: string;
|
|
521
|
+
/**
|
|
522
|
+
* Safety classification — drives MCP hint annotations.
|
|
523
|
+
* @default 'action'
|
|
524
|
+
*/
|
|
525
|
+
safety?: 'read' | 'action' | 'destructive';
|
|
526
|
+
/** Free-form tags for grouping/filtering. */
|
|
527
|
+
tags?: readonly string[];
|
|
528
|
+
/**
|
|
529
|
+
* Positional [Standard Schema](https://standardschema.dev/) validators for
|
|
530
|
+
* the handler's arguments — the same shape RPC definitions carry (valibot,
|
|
531
|
+
* zod, arktype, devframe's built-in `s` builder, …). Each is advertised
|
|
532
|
+
* under `arg0` / `arg1` / … on the tool's JSON-Schema input. Omitted: the
|
|
533
|
+
* tool takes no arguments.
|
|
534
|
+
*/
|
|
535
|
+
args?: readonly StandardSchemaV1[];
|
|
536
|
+
}
|
|
499
537
|
/**
|
|
500
538
|
* Server command input — what plugins pass to `ctx.commands.register()`.
|
|
501
539
|
*/
|
|
@@ -504,6 +542,13 @@ interface DevframeServerCommandInput extends DevframeCommandBase {
|
|
|
504
542
|
* Handler for this command. Optional if the command only serves as a group for children.
|
|
505
543
|
*/
|
|
506
544
|
handler?: (...args: any[]) => any | Promise<any>;
|
|
545
|
+
/**
|
|
546
|
+
* Opt this command in to the agent surface (`ctx.agent` → MCP). Requires a
|
|
547
|
+
* `handler`. See {@link DevframeCommandAgentOptions}.
|
|
548
|
+
*
|
|
549
|
+
* @experimental
|
|
550
|
+
*/
|
|
551
|
+
agent?: DevframeCommandAgentOptions;
|
|
507
552
|
/**
|
|
508
553
|
* Static sub-commands. Two levels max (parent → children).
|
|
509
554
|
* Each child must have a globally unique `id`.
|
|
@@ -584,4 +629,4 @@ interface DevframeDocksUserSettings {
|
|
|
584
629
|
commandShortcuts: DevframeCommandShortcutOverrides;
|
|
585
630
|
}
|
|
586
631
|
//#endregion
|
|
587
|
-
export {
|
|
632
|
+
export { DevframeViewLauncher as A, DevframeDocksHost as C, DevframeViewGroup as D, DevframeViewCustomRender as E, RemoteDockOptions as F, JsonRenderElement as I, JsonRenderSpec as L, FrameSubTabsConfig as M, NavTarget as N, DevframeViewIframe as O, RemoteConnectionInfo as P, JsonRenderer as R, DevframeDocksActiveState as S, DevframeViewBuiltin as T, DevframeDockEntryBase as _, DevframeCommandEntry as a, DevframeDockEntryRegistry as b, DevframeCommandShortcutOverrides as c, DevframeServerCommandEntry as d, DevframeServerCommandInput as f, DevframeDockEntry as g, DevframeDockEntriesGrouped as h, DevframeCommandBase as i, DevframeViewLauncherStatus as j, DevframeViewJsonRender as k, DevframeCommandsHost as l, DevframeDockActivation as m, DevframeClientCommand as n, DevframeCommandHandle as o, ClientScriptEntry as p, DevframeCommandAgentOptions as r, DevframeCommandKeybinding as s, DevframeDocksUserSettings as t, DevframeCommandsHostEvents as u, DevframeDockEntryCategory as v, DevframeViewAction as w, DevframeDockUserEntry as x, DevframeDockEntryIcon as y };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as DevframeMessageShortcutInput, D as DevframeMessagesListDelta, E as DevframeMessagesLevelShortcuts, S as DevframeMessageLevel, T as DevframeMessagesHost, _ as DevframeMessageEntry, a as DevframeChildProcessOutput, b as DevframeMessageFilePosition, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageElementPosition, h as DevframeMessageActivateAction, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageAction, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageEntryFrom, w as DevframeMessagesClient, x as DevframeMessageHandle, y as DevframeMessageEntryInput } from "../context-
|
|
3
|
-
import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "../index-
|
|
4
|
-
export { ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, type DevframeCapabilities, DevframeChildProcessExecuteOptions, DevframeChildProcessOutput, DevframeChildProcessResult, DevframeChildProcessTerminalSession, DevframeClientCommand, DevframeCommandBase, DevframeCommandEntry, DevframeCommandHandle, DevframeCommandKeybinding, DevframeCommandShortcutOverrides, DevframeCommandsHost, DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, DevframeDockActivation, DevframeDockEntriesGrouped, DevframeDockEntry, DevframeDockEntryBase, DevframeDockEntryCategory, DevframeDockEntryIcon, DevframeDockEntryRegistry, DevframeDockUserEntry, DevframeDocksActiveState, DevframeDocksHost, DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, DevframeMessageAction, DevframeMessageActivateAction, DevframeMessageElementPosition, DevframeMessageEntry, DevframeMessageEntryFrom, DevframeMessageEntryInput, DevframeMessageFilePosition, DevframeMessageHandle, DevframeMessageLevel, DevframeMessageShortcutInput, DevframeMessagesClient, DevframeMessagesHost, DevframeMessagesLevelShortcuts, DevframeMessagesListDelta, type DevframeNodeRpcSession, DevframePtyExecuteOptions, DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, DevframeServerCommandEntry, DevframeServerCommandInput, DevframeTerminalSession, DevframeTerminalSessionBase, DevframeTerminalStatus, DevframeTerminalsHost, DevframeViewAction, DevframeViewBuiltin, DevframeViewCustomRender, DevframeViewGroup, type DevframeViewHost, DevframeViewIframe, DevframeViewJsonRender, DevframeViewLauncher, DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, FrameSubTabsConfig, JsonRenderElement, JsonRenderSpec, JsonRenderer, NavTarget, type PartialWithoutId, RemoteConnectionInfo, RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable };
|
|
1
|
+
import { A as DevframeViewLauncher, C as DevframeDocksHost, D as DevframeViewGroup, E as DevframeViewCustomRender, F as RemoteDockOptions, I as JsonRenderElement, L as JsonRenderSpec, M as FrameSubTabsConfig, N as NavTarget, O as DevframeViewIframe, P as RemoteConnectionInfo, R as JsonRenderer, S as DevframeDocksActiveState, T as DevframeViewBuiltin, _ as DevframeDockEntryBase, a as DevframeCommandEntry, b as DevframeDockEntryRegistry, c as DevframeCommandShortcutOverrides, d as DevframeServerCommandEntry, f as DevframeServerCommandInput, g as DevframeDockEntry, h as DevframeDockEntriesGrouped, i as DevframeCommandBase, j as DevframeViewLauncherStatus, k as DevframeViewJsonRender, l as DevframeCommandsHost, m as DevframeDockActivation, n as DevframeClientCommand, o as DevframeCommandHandle, p as ClientScriptEntry, r as DevframeCommandAgentOptions, s as DevframeCommandKeybinding, t as DevframeDocksUserSettings, u as DevframeCommandsHostEvents, v as DevframeDockEntryCategory, w as DevframeViewAction, x as DevframeDockUserEntry, y as DevframeDockEntryIcon } from "../settings-Byh48aCd.mjs";
|
|
2
|
+
import { C as DevframeMessageShortcutInput, D as DevframeMessagesListDelta, E as DevframeMessagesLevelShortcuts, S as DevframeMessageLevel, T as DevframeMessagesHost, _ as DevframeMessageEntry, a as DevframeChildProcessOutput, b as DevframeMessageFilePosition, c as DevframePtyExecuteOptions, d as DevframeTerminalSessionBase, f as DevframeTerminalStatus, g as DevframeMessageElementPosition, h as DevframeMessageActivateAction, i as DevframeChildProcessExecuteOptions, l as DevframePtyTerminalSession, m as DevframeMessageAction, n as DevframeHubContext, o as DevframeChildProcessResult, p as DevframeTerminalsHost, s as DevframeChildProcessTerminalSession, t as CreateHubContextOptions, u as DevframeTerminalSession, v as DevframeMessageEntryFrom, w as DevframeMessagesClient, x as DevframeMessageHandle, y as DevframeMessageEntryInput } from "../context-Cw5sDVoA.mjs";
|
|
3
|
+
import { C as RpcStreamingChannel, E as Thenable, S as RpcSharedStateHost, T as RpcStreamingHost, _ as RpcBroadcastOptions, a as DevframeDiagnosticsLogger, b as RpcFunctionsHost, c as DevframeRpcClientFunctions, d as DevframeViewHost, f as EntriesToObject, g as PartialWithoutId, h as EventsMap, i as DevframeDiagnosticsHost, l as DevframeRpcServerFunctions, m as EventUnsubscribe, n as DevframeCapabilities, o as DevframeHost, p as EventEmitter, r as DevframeDiagnosticsDefinition, s as DevframeNodeRpcSession, t as ConnectionMeta, u as DevframeRpcSharedStates, v as RpcDefinitionsFilter, w as RpcStreamingChannelOptions, x as RpcSharedStateGetOptions, y as RpcDefinitionsToFunctions } from "../index-Bx3T-R7i.mjs";
|
|
4
|
+
export { ClientScriptEntry, type ConnectionMeta, type CreateHubContextOptions, type DevframeCapabilities, DevframeChildProcessExecuteOptions, DevframeChildProcessOutput, DevframeChildProcessResult, DevframeChildProcessTerminalSession, DevframeClientCommand, DevframeCommandAgentOptions, DevframeCommandBase, DevframeCommandEntry, DevframeCommandHandle, DevframeCommandKeybinding, DevframeCommandShortcutOverrides, DevframeCommandsHost, DevframeCommandsHostEvents, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, DevframeDockActivation, DevframeDockEntriesGrouped, DevframeDockEntry, DevframeDockEntryBase, DevframeDockEntryCategory, DevframeDockEntryIcon, DevframeDockEntryRegistry, DevframeDockUserEntry, DevframeDocksActiveState, DevframeDocksHost, DevframeDocksUserSettings, type DevframeHost, type DevframeHubContext, DevframeMessageAction, DevframeMessageActivateAction, DevframeMessageElementPosition, DevframeMessageEntry, DevframeMessageEntryFrom, DevframeMessageEntryInput, DevframeMessageFilePosition, DevframeMessageHandle, DevframeMessageLevel, DevframeMessageShortcutInput, DevframeMessagesClient, DevframeMessagesHost, DevframeMessagesLevelShortcuts, DevframeMessagesListDelta, type DevframeNodeRpcSession, DevframePtyExecuteOptions, DevframePtyTerminalSession, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, DevframeServerCommandEntry, DevframeServerCommandInput, DevframeTerminalSession, DevframeTerminalSessionBase, DevframeTerminalStatus, DevframeTerminalsHost, DevframeViewAction, DevframeViewBuiltin, DevframeViewCustomRender, DevframeViewGroup, type DevframeViewHost, DevframeViewIframe, DevframeViewJsonRender, DevframeViewLauncher, DevframeViewLauncherStatus, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, FrameSubTabsConfig, JsonRenderElement, JsonRenderSpec, JsonRenderer, NavTarget, type PartialWithoutId, RemoteConnectionInfo, RemoteDockOptions, type RpcBroadcastOptions, type RpcDefinitionsFilter, type RpcDefinitionsToFunctions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type Thenable };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devframes/hub",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"description": "Framework-neutral hub layer for devframe — docks, terminals, messages, commands.",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"devframe": "0.
|
|
36
|
+
"devframe": "0.8.1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"
|
|
39
|
+
"@standard-schema/spec": "^1.1.0",
|
|
40
40
|
"destr": "^2.0.5",
|
|
41
41
|
"nostics": "^1.2.0",
|
|
42
42
|
"pathe": "^2.0.3",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"@types/node": "^26.1.2",
|
|
49
49
|
"mlly": "^1.8.2",
|
|
50
50
|
"tsdown": "^0.22.14",
|
|
51
|
-
"
|
|
51
|
+
"valibot": "^1.4.2",
|
|
52
|
+
"devframe": "0.8.1"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
55
|
"build": "tsdown",
|