@devframes/hub 0.7.15 → 0.8.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/client/index.d.mts +3 -3
- package/dist/constants.d.mts +1 -1
- package/dist/{context-CvxNyUBj.d.mts → context-Cw5sDVoA.d.mts} +1 -1
- package/dist/{index-CB6kSg0u.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 +65 -6
- package/dist/{settings-Bn38f2Yw.d.mts → settings-Byh48aCd.d.mts} +52 -1
- package/dist/types/index.d.mts +4 -4
- package/package.json +5 -4
package/dist/client/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
3
|
+
import { w as DevframeMessagesClient, y as DevframeMessageEntryInput } from "../context-Cw5sDVoA.mjs";
|
|
4
|
+
import "../index-Bx3T-R7i.mjs";
|
|
5
5
|
import { DevframeClientRpcHost, 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";
|
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
|
@@ -2,7 +2,7 @@ import { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS } from "../consta
|
|
|
2
2
|
import { r as defineHubRpcFunction } from "../define-Pbx8dsKz.mjs";
|
|
3
3
|
import { REMOTE_CONNECTION_KEY } from "devframe/constants";
|
|
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
|
|
@@ -724,6 +773,12 @@ var DevframeTerminalsHost = class {
|
|
|
724
773
|
let pty;
|
|
725
774
|
let runId = 0;
|
|
726
775
|
let streamClosed = false;
|
|
776
|
+
let session;
|
|
777
|
+
const markStatus = (next) => {
|
|
778
|
+
if (session.status === next) return;
|
|
779
|
+
session.status = next;
|
|
780
|
+
this.events.emit("terminal:session:updated", session);
|
|
781
|
+
};
|
|
727
782
|
const closeStream = () => {
|
|
728
783
|
if (streamClosed) return;
|
|
729
784
|
streamClosed = true;
|
|
@@ -767,8 +822,10 @@ var DevframeTerminalsHost = class {
|
|
|
767
822
|
if (streamClosed || currentRun !== runId) return;
|
|
768
823
|
controller?.enqueue(typeof data === "string" ? data : data.toString("utf8"));
|
|
769
824
|
});
|
|
770
|
-
proc.onExit(() => {
|
|
771
|
-
if (currentRun
|
|
825
|
+
proc.onExit(({ exitCode, signal }) => {
|
|
826
|
+
if (currentRun !== runId) return;
|
|
827
|
+
closeStream();
|
|
828
|
+
markStatus(signal === 0 && exitCode !== 0 ? "error" : "stopped");
|
|
772
829
|
});
|
|
773
830
|
return proc;
|
|
774
831
|
};
|
|
@@ -781,7 +838,7 @@ var DevframeTerminalsHost = class {
|
|
|
781
838
|
reason: error instanceof Error ? error.message : String(error)
|
|
782
839
|
});
|
|
783
840
|
}
|
|
784
|
-
|
|
841
|
+
session = {
|
|
785
842
|
...terminal,
|
|
786
843
|
status: "running",
|
|
787
844
|
interactive: true,
|
|
@@ -810,11 +867,13 @@ var DevframeTerminalsHost = class {
|
|
|
810
867
|
pty?.kill();
|
|
811
868
|
pty = void 0;
|
|
812
869
|
closeStream();
|
|
870
|
+
markStatus("stopped");
|
|
813
871
|
},
|
|
814
872
|
restart: async () => {
|
|
815
873
|
if (streamClosed) return;
|
|
816
874
|
pty?.kill();
|
|
817
875
|
pty = spawnPty();
|
|
876
|
+
markStatus("running");
|
|
818
877
|
}
|
|
819
878
|
};
|
|
820
879
|
this.register(session);
|
|
@@ -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. */
|
|
@@ -419,6 +420,12 @@ interface DevframeViewGroup extends DevframeDockEntryBase {
|
|
|
419
420
|
* ```
|
|
420
421
|
*/
|
|
421
422
|
categoryOrder?: Record<string, number>;
|
|
423
|
+
/**
|
|
424
|
+
* Optional accent color for the group button. When set, the viewer may use
|
|
425
|
+
* it to style the group button and/or its popover. When unset, the viewer
|
|
426
|
+
* falls back to its own default styling.
|
|
427
|
+
*/
|
|
428
|
+
accentColor?: string;
|
|
422
429
|
}
|
|
423
430
|
/**
|
|
424
431
|
* The **open** registry of dock entry variants, keyed by their `type`
|
|
@@ -490,6 +497,43 @@ interface DevframeCommandBase {
|
|
|
490
497
|
*/
|
|
491
498
|
keybindings?: DevframeCommandKeybinding[];
|
|
492
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
|
+
}
|
|
493
537
|
/**
|
|
494
538
|
* Server command input — what plugins pass to `ctx.commands.register()`.
|
|
495
539
|
*/
|
|
@@ -498,6 +542,13 @@ interface DevframeServerCommandInput extends DevframeCommandBase {
|
|
|
498
542
|
* Handler for this command. Optional if the command only serves as a group for children.
|
|
499
543
|
*/
|
|
500
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;
|
|
501
552
|
/**
|
|
502
553
|
* Static sub-commands. Two levels max (parent → children).
|
|
503
554
|
* Each child must have a globally unique `id`.
|
|
@@ -578,4 +629,4 @@ interface DevframeDocksUserSettings {
|
|
|
578
629
|
commandShortcuts: DevframeCommandShortcutOverrides;
|
|
579
630
|
}
|
|
580
631
|
//#endregion
|
|
581
|
-
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.0",
|
|
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.0"
|
|
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.0"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
55
|
"build": "tsdown",
|