devframe 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/adapters/build.d.mts +1 -1
  2. package/dist/adapters/build.mjs +2 -2
  3. package/dist/adapters/cac.d.mts +1 -1
  4. package/dist/adapters/cac.mjs +1 -1
  5. package/dist/adapters/cli.d.mts +1 -1
  6. package/dist/adapters/cli.mjs +1 -1
  7. package/dist/adapters/dev.d.mts +15 -2
  8. package/dist/adapters/dev.mjs +1 -1
  9. package/dist/adapters/embedded.d.mts +1 -1
  10. package/dist/adapters/mcp.d.mts +1 -1
  11. package/dist/adapters/mcp.mjs +1 -1
  12. package/dist/{cac-B1LM3zit.mjs → cac-D4_9ok0z.mjs} +1 -1
  13. package/dist/cli/main.mjs +2 -2
  14. package/dist/client/index.d.mts +1 -1
  15. package/dist/{context-CQefP2jR.mjs → context-CBg8iRbQ.mjs} +1 -1
  16. package/dist/{context-DFzmxCLa.d.mts → context-DoSozfvx.d.mts} +1 -1
  17. package/dist/{dev-BSHFZGZr.mjs → dev-Bc49u3qg.mjs} +7 -5
  18. package/dist/{devframe-qgCKL683.d.mts → devframe-mQ4qZAuo.d.mts} +1 -1
  19. package/dist/{diagnostics-B5-qHeqD.mjs → diagnostics-D7wM2cwM.mjs} +4 -0
  20. package/dist/{fetch-CK0S253E.mjs → fetch-BKaD0Vb3.mjs} +2 -2
  21. package/dist/helpers/vite.d.mts +1 -1
  22. package/dist/helpers/vite.mjs +2 -2
  23. package/dist/{host-h3-Kz7t5Xab.mjs → host-h3-D2hYZvDK.mjs} +2 -2
  24. package/dist/{http-Dvgxujcu.mjs → http-C4T68YV6.mjs} +1 -1
  25. package/dist/{index-B7RgLw--.d.mts → index-b64Uuhy2.d.mts} +2 -2
  26. package/dist/index.d.mts +2 -2
  27. package/dist/{instance-registry-D6fxYu36.mjs → instance-registry-BnnA2Eoh.mjs} +1 -1
  28. package/dist/node/auth.d.mts +2 -2
  29. package/dist/node/hub-internals.d.mts +2 -2
  30. package/dist/node/hub-internals.mjs +1 -1
  31. package/dist/node/index.d.mts +2 -2
  32. package/dist/node/index.mjs +4 -4
  33. package/dist/recipes/common-rpc-functions.d.mts +1 -1
  34. package/dist/recipes/interactive-auth.d.mts +2 -2
  35. package/dist/recipes/interactive-auth.mjs +1 -1
  36. package/dist/rpc/transports/ws-server.d.mts +1 -1
  37. package/dist/rpc/transports/ws-server.mjs +26 -5
  38. package/dist/{server-CXaDDUl0.mjs → server-CD8XmBXl.mjs} +25 -6
  39. package/dist/{server-E9z4ZWbd.d.mts → server-UHWae43Q.d.mts} +20 -3
  40. package/dist/{storage-Dzoc3NVC.mjs → storage-CTNVbuFB.mjs} +1 -1
  41. package/dist/types/index.d.mts +2 -2
  42. package/dist/utils/events.d.mts +1 -1
  43. package/dist/utils/shared-state.d.mts +1 -1
  44. package/dist/utils/streaming-channel.d.mts +1 -1
  45. package/dist/{ws-server-J-zkiOyp.d.mts → ws-server-uKQcClcJ.d.mts} +13 -5
  46. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { r as DevframeDefinition } from "../devframe-qgCKL683.mjs";
1
+ import { r as DevframeDefinition } from "../devframe-mQ4qZAuo.mjs";
2
2
  //#region src/adapters/build.d.ts
3
3
  interface CreateBuildOptions {
4
4
  /** Output directory. Defaults to `dist-static`. */
@@ -3,8 +3,8 @@ import { n as colors } from "../diagnostics-reporter-CsIG85Q5.mjs";
3
3
  import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_RPC_DUMP_DIRNAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
4
4
  import { n as strictJsonStringify } from "../serialization-C8Mnw9hK.mjs";
5
5
  import { n as structuredCloneStringify } from "../structured-clone-CbAV5rFI.mjs";
6
- import { n as createHostContext, t as createH3DevframeHost } from "../host-h3-Kz7t5Xab.mjs";
7
- import { t as diagnostics } from "../diagnostics-B5-qHeqD.mjs";
6
+ import { n as createHostContext, t as createH3DevframeHost } from "../host-h3-D2hYZvDK.mjs";
7
+ import { t as diagnostics } from "../diagnostics-D7wM2cwM.mjs";
8
8
  import { n as resolveBasePath } from "../_shared-bWRzeSa0.mjs";
9
9
  import { existsSync } from "node:fs";
10
10
  import { dirname, resolve } from "pathe";
@@ -1,4 +1,4 @@
1
- import { Ft as InferCliFlags, It as defineCliFlags, Lt as parseCliFlags, Pt as CliFlagsSchema, r as DevframeDefinition } from "../devframe-qgCKL683.mjs";
1
+ import { Ft as InferCliFlags, It as defineCliFlags, Lt as parseCliFlags, Pt as CliFlagsSchema, r as DevframeDefinition } from "../devframe-mQ4qZAuo.mjs";
2
2
  import { CAC } from "cac";
3
3
  import { H3 } from "h3";
4
4
  //#region src/adapters/cac.d.ts
@@ -1,2 +1,2 @@
1
- import { n as defineCliFlags, r as parseCliFlags, t as createCac } from "../cac-B1LM3zit.mjs";
1
+ import { n as defineCliFlags, r as parseCliFlags, t as createCac } from "../cac-D4_9ok0z.mjs";
2
2
  export { createCac, defineCliFlags, parseCliFlags };
@@ -1,4 +1,4 @@
1
- import { Ft as InferCliFlags, It as defineCliFlags, Lt as parseCliFlags, Pt as CliFlagsSchema } from "../devframe-qgCKL683.mjs";
1
+ import { Ft as InferCliFlags, It as defineCliFlags, Lt as parseCliFlags, Pt as CliFlagsSchema } from "../devframe-mQ4qZAuo.mjs";
2
2
  import { CacHandle, CreateCacOptions, createCac } from "./cac.mjs";
3
3
  //#region src/adapters/cli.d.ts
4
4
  /** @deprecated Use `createCac` from `devframe/adapters/cac` instead. */
@@ -1,4 +1,4 @@
1
- import { n as defineCliFlags, r as parseCliFlags, t as createCac } from "../cac-B1LM3zit.mjs";
1
+ import { n as defineCliFlags, r as parseCliFlags, t as createCac } from "../cac-D4_9ok0z.mjs";
2
2
  //#region src/adapters/cli.ts
3
3
  /** @deprecated Use `createCac` from `devframe/adapters/cac` instead. */
4
4
  const createCli = createCac;
@@ -1,5 +1,7 @@
1
- import { _ as ConnectionMeta, d as McpRouteOptions, p as DevframeAuthHandler, r as DevframeDefinition, u as DevframeWsOptions } from "../devframe-qgCKL683.mjs";
2
- import { n as StartedServer } from "../server-E9z4ZWbd.mjs";
1
+ import { W as DevframeNodeRpcSession, _ as ConnectionMeta, d as McpRouteOptions, p as DevframeAuthHandler, r as DevframeDefinition, u as DevframeWsOptions } from "../devframe-mQ4qZAuo.mjs";
2
+ import { n as DevframeNodeRpcSessionMeta } from "../ws-server-uKQcClcJ.mjs";
3
+ import { n as StartedServer } from "../server-UHWae43Q.mjs";
4
+ import { Peer } from "crossws";
3
5
  import { H3 } from "h3";
4
6
  //#region src/adapters/dev.d.ts
5
7
  interface CreateDevServerOptions {
@@ -68,6 +70,17 @@ interface CreateDevServerOptions {
68
70
  * {@link McpRouteOptions}.
69
71
  */
70
72
  mcp?: boolean | McpRouteOptions;
73
+ /**
74
+ * Called once per new WS connection, right after its session is created.
75
+ * Forwarded verbatim to the underlying `startHttpAndWs`.
76
+ */
77
+ onPeerConnect?: (peer: Peer, session: DevframeNodeRpcSession) => void;
78
+ /**
79
+ * Called once per closed WS connection, right after its session's
80
+ * disconnect bookkeeping runs. Forwarded verbatim to the underlying
81
+ * `startHttpAndWs`.
82
+ */
83
+ onPeerDisconnect?: (peer: Peer, meta: DevframeNodeRpcSessionMeta) => void;
71
84
  /**
72
85
  * Called once the WS server is bound. Devframe stays headless
73
86
  * otherwise — wire this if you want a startup banner.
@@ -1,2 +1,2 @@
1
- import { n as resolveDevServerPort, r as resolveMcpConnectionMeta, t as createDevServer } from "../dev-BSHFZGZr.mjs";
1
+ import { n as resolveDevServerPort, r as resolveMcpConnectionMeta, t as createDevServer } from "../dev-Bc49u3qg.mjs";
2
2
  export { createDevServer, resolveDevServerPort, resolveMcpConnectionMeta };
@@ -1,4 +1,4 @@
1
- import { b as DevframeNodeContext, r as DevframeDefinition } from "../devframe-qgCKL683.mjs";
1
+ import { b as DevframeNodeContext, r as DevframeDefinition } from "../devframe-mQ4qZAuo.mjs";
2
2
  //#region src/adapters/embedded.d.ts
3
3
  interface CreateEmbeddedOptions {
4
4
  /** Target context the devframe is registered into. Required. */
@@ -1,4 +1,4 @@
1
- import { b as DevframeNodeContext, r as DevframeDefinition } from "../devframe-qgCKL683.mjs";
1
+ import { b as DevframeNodeContext, r as DevframeDefinition } from "../devframe-mQ4qZAuo.mjs";
2
2
  import "@modelcontextprotocol/server";
3
3
  //#region src/adapters/mcp/build-server.d.ts
4
4
  interface CreateMcpServerOptions {
@@ -1,2 +1,2 @@
1
- import { n as createMcpServer, t as createMcpFetchHandler } from "../fetch-CK0S253E.mjs";
1
+ import { n as createMcpServer, t as createMcpFetchHandler } from "../fetch-BKaD0Vb3.mjs";
2
2
  export { createMcpFetchHandler, createMcpServer };
@@ -1,6 +1,6 @@
1
1
  import { n as colors } from "./diagnostics-reporter-CsIG85Q5.mjs";
2
2
  import { createBuild } from "./adapters/build.mjs";
3
- import { n as resolveDevServerPort, t as createDevServer } from "./dev-BSHFZGZr.mjs";
3
+ import { n as resolveDevServerPort, t as createDevServer } from "./dev-Bc49u3qg.mjs";
4
4
  import process from "node:process";
5
5
  import cac$1 from "cac";
6
6
  //#region src/adapters/flags.ts
package/dist/cli/main.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as diagnostics } from "../diagnostics-B5-qHeqD.mjs";
2
- import { n as probeDevframeOrigin, t as listLiveDevframeInstances } from "../instance-registry-D6fxYu36.mjs";
1
+ import { t as diagnostics } from "../diagnostics-D7wM2cwM.mjs";
2
+ import { n as probeDevframeOrigin, t as listLiveDevframeInstances } from "../instance-registry-BnnA2Eoh.mjs";
3
3
  import { t as toAgentToolName } from "../agent-tool-name-C3b5vEwJ.mjs";
4
4
  import { Diagnostic } from "nostics";
5
5
  import process from "node:process";
@@ -1,4 +1,4 @@
1
- import { $ as DevframeRpcServerFunctions, F as ScopedSharedStates, I as SettingsForNamespace, J as RpcSharedStateHost, N as ScopedRpcFn, O as DevframeSettings, P as ScopedServerFunctions, Q as DevframeRpcClientFunctions, _ as ConnectionMeta, at as StreamReader, ht as SharedState, jt as EventEmitter, ot as StreamSink, q as RpcSharedStateGetOptions } from "../devframe-qgCKL683.mjs";
1
+ import { $ as DevframeRpcServerFunctions, F as ScopedSharedStates, I as SettingsForNamespace, J as RpcSharedStateHost, N as ScopedRpcFn, O as DevframeSettings, P as ScopedServerFunctions, Q as DevframeRpcClientFunctions, _ as ConnectionMeta, at as StreamReader, ht as SharedState, jt as EventEmitter, ot as StreamSink, q as RpcSharedStateGetOptions } from "../devframe-mQ4qZAuo.mjs";
2
2
  import { _ as RpcFunctionDefinition, w as RpcFunctionsCollector } from "../types-CnJSgRVa.mjs";
3
3
  import { E as RpcCacheOptions, T as RpcCacheManager } from "../index-Dbw1p5ch.mjs";
4
4
  import { t as WsRpcChannelOptions } from "../ws-client-B6Tnr0ic.mjs";
@@ -1,5 +1,5 @@
1
1
  import { n as randomToken } from "./crypto-token-XCqTSMg9.mjs";
2
- import { t as createStorage } from "./storage-Dzoc3NVC.mjs";
2
+ import { t as createStorage } from "./storage-CTNVbuFB.mjs";
3
3
  import { n as revokeAuthToken, t as revokeActiveConnectionsForToken } from "./revoke-DZbJ7Cl0.mjs";
4
4
  import { join } from "pathe";
5
5
  //#region src/node/hub-internals/context.ts
@@ -1,4 +1,4 @@
1
- import { b as DevframeNodeContext, ht as SharedState } from "./devframe-qgCKL683.mjs";
1
+ import { b as DevframeNodeContext, ht as SharedState } from "./devframe-mQ4qZAuo.mjs";
2
2
  //#region src/node/hub-internals/context.d.ts
3
3
  interface InternalAnonymousAuthStorage {
4
4
  trusted: Record<string, {
@@ -1,8 +1,8 @@
1
1
  import { DEVFRAME_CONNECTION_META_FILENAME } from "./constants.mjs";
2
- import { n as createHostContext, t as createH3DevframeHost } from "./host-h3-Kz7t5Xab.mjs";
3
- import { t as diagnostics } from "./diagnostics-B5-qHeqD.mjs";
4
- import { r as registerDevframeInstance } from "./instance-registry-D6fxYu36.mjs";
5
- import { i as normalizeHttpServerUrl, t as startHttpAndWs } from "./server-CXaDDUl0.mjs";
2
+ import { n as createHostContext, t as createH3DevframeHost } from "./host-h3-D2hYZvDK.mjs";
3
+ import { t as diagnostics } from "./diagnostics-D7wM2cwM.mjs";
4
+ import { r as registerDevframeInstance } from "./instance-registry-BnnA2Eoh.mjs";
5
+ import { i as normalizeHttpServerUrl, t as startHttpAndWs } from "./server-CD8XmBXl.mjs";
6
6
  import { n as resolveBasePath, t as normalizeBasePath } from "./_shared-bWRzeSa0.mjs";
7
7
  import { t as open } from "./open-Deb5xmIT.mjs";
8
8
  import { mountStaticHandler } from "./utils/serve-static.mjs";
@@ -295,7 +295,7 @@ async function createDevServer(def, options = {}) {
295
295
  const mcpPath = joinURL(basePath, mcpRoute);
296
296
  let mountMcpHttp;
297
297
  try {
298
- ({mountMcpHttp} = await import("./http-Dvgxujcu.mjs"));
298
+ ({mountMcpHttp} = await import("./http-C4T68YV6.mjs"));
299
299
  } catch (error) {
300
300
  const reason = error instanceof Error ? error.message : String(error);
301
301
  throw diagnostics.DF0017({
@@ -339,6 +339,8 @@ async function createDevServer(def, options = {}) {
339
339
  path: bindPath,
340
340
  wsPort,
341
341
  auth: resolvedAuth,
342
+ onPeerConnect: options.onPeerConnect,
343
+ onPeerDisconnect: options.onPeerDisconnect,
342
344
  onReady: async (info) => {
343
345
  authHandler?.printBanner();
344
346
  await options.onReady?.(info);
@@ -1,6 +1,6 @@
1
1
  import { _ as RpcFunctionDefinition, v as RpcFunctionDefinitionAny } from "./types-CnJSgRVa.mjs";
2
2
  import { w as RpcFunctionsCollectorBase } from "./index-Dbw1p5ch.mjs";
3
- import { n as DevframeNodeRpcSessionMeta } from "./ws-server-J-zkiOyp.mjs";
3
+ import { n as DevframeNodeRpcSessionMeta } from "./ws-server-uKQcClcJ.mjs";
4
4
  import { CAC } from "cac";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
6
  import { Peer } from "crossws";
@@ -87,6 +87,10 @@ const diagnostics = defineDiagnostics({
87
87
  DF0051: {
88
88
  why: (p) => `The devframe instance on port ${p.port} has no MCP endpoint.`,
89
89
  fix: "Restart the instance with the --mcp flag (or set `cli.mcp: true` on its definition) to expose its tools, then list instances again."
90
+ },
91
+ DF0052: {
92
+ why: (p) => `Failed to listen on ${p.host}:${p.port}: ${p.reason}`,
93
+ fix: "The port is likely already taken by another process (often a previous devframe instance). Free it, or pick another via `--port`, `cli.port` / `cli.portRange` on the definition, or `devMiddleware.port` on `viteDevBridge`. The original node error is available as `error.cause`."
90
94
  }
91
95
  }
92
96
  });
@@ -1,6 +1,6 @@
1
1
  import { isAllowedOrigin } from "./rpc/transports/ws-server.mjs";
2
- import { n as createHostContext } from "./host-h3-Kz7t5Xab.mjs";
3
- import { t as diagnostics } from "./diagnostics-B5-qHeqD.mjs";
2
+ import { n as createHostContext } from "./host-h3-D2hYZvDK.mjs";
3
+ import { t as diagnostics } from "./diagnostics-D7wM2cwM.mjs";
4
4
  import { t as toAgentToolName } from "./agent-tool-name-C3b5vEwJ.mjs";
5
5
  import { randomUUID } from "node:crypto";
6
6
  import { Diagnostic } from "nostics";
@@ -1,4 +1,4 @@
1
- import { d as McpRouteOptions, p as DevframeAuthHandler, r as DevframeDefinition } from "../devframe-qgCKL683.mjs";
1
+ import { d as McpRouteOptions, p as DevframeAuthHandler, r as DevframeDefinition } from "../devframe-mQ4qZAuo.mjs";
2
2
  //#region src/helpers/vite.d.ts
3
3
  interface ViteDevBridgeOptions {
4
4
  /**
@@ -1,8 +1,8 @@
1
1
  import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_WS_ROUTE } from "../constants.mjs";
2
- import { t as diagnostics } from "../diagnostics-B5-qHeqD.mjs";
2
+ import { t as diagnostics } from "../diagnostics-D7wM2cwM.mjs";
3
3
  import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-bWRzeSa0.mjs";
4
4
  import { serveStaticNodeMiddleware } from "../utils/serve-static.mjs";
5
- import { n as resolveDevServerPort, r as resolveMcpConnectionMeta, t as createDevServer } from "../dev-BSHFZGZr.mjs";
5
+ import { n as resolveDevServerPort, r as resolveMcpConnectionMeta, t as createDevServer } from "../dev-Bc49u3qg.mjs";
6
6
  import { resolve } from "pathe";
7
7
  //#region src/helpers/vite.ts
8
8
  /**
@@ -2,8 +2,8 @@ import { t as devframeReporter } from "./diagnostics-reporter-CsIG85Q5.mjs";
2
2
  import { t as diagnostics } from "./diagnostics-hwjXp_UV.mjs";
3
3
  import { RpcFunctionsCollectorBase } from "./rpc/index.mjs";
4
4
  import { defineRpcFunction } from "./index.mjs";
5
- import { t as diagnostics$1 } from "./diagnostics-B5-qHeqD.mjs";
6
- import { i as createEventEmitter, n as createSharedState, r as nanoid, t as createStorage } from "./storage-Dzoc3NVC.mjs";
5
+ import { t as diagnostics$1 } from "./diagnostics-D7wM2cwM.mjs";
6
+ import { i as createEventEmitter, n as createSharedState, r as nanoid, t as createStorage } from "./storage-CTNVbuFB.mjs";
7
7
  import { defineDiagnostics } from "nostics";
8
8
  import { isatty } from "node:tty";
9
9
  import { formatWithOptions, inspect } from "node:util";
@@ -1,4 +1,4 @@
1
- import { t as createMcpFetchHandler } from "./fetch-CK0S253E.mjs";
1
+ import { t as createMcpFetchHandler } from "./fetch-BKaD0Vb3.mjs";
2
2
  import { defineHandler } from "h3";
3
3
  //#region src/adapters/mcp/http.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { W as DevframeNodeRpcSession, b as DevframeNodeContext, ht as SharedState } from "./devframe-qgCKL683.mjs";
2
- import { n as InternalAnonymousAuthStorage } from "./context-DFzmxCLa.mjs";
1
+ import { W as DevframeNodeRpcSession, b as DevframeNodeContext, ht as SharedState } from "./devframe-mQ4qZAuo.mjs";
2
+ import { n as InternalAnonymousAuthStorage } from "./context-DoSozfvx.mjs";
3
3
  //#region src/node/auth/revoke.d.ts
4
4
  /**
5
5
  * Flip `isTrusted` to false on any live WS clients connected with `token`
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { $ as DevframeRpcServerFunctions, A as DevframeSettingsStore, At as DevframeAgentHostEvents, B as DevframeDefineDiagnosticsOptions, C as DevframeServicesHost, Ct as AgentResourceContent, D as DevframeScopedStreamingHost, Dt as AgentToolProvider, E as DevframeScopedNodeRpc, Et as AgentToolInput, F as ScopedSharedStates, G as RpcBroadcastOptions, H as DevframeDiagnosticsHost, I as SettingsForNamespace, J as RpcSharedStateHost, K as RpcFunctionsHost, L as DevframeViewHost, M as ScopedClientFunctions, Mt as EventUnsubscribe, N as ScopedRpcFn, Nt as EventsMap, O as DevframeSettings, Ot as AgentToolProviderHandle, P as ScopedServerFunctions, Q as DevframeRpcClientFunctions, R as DevframeHost, S as DevframeServiceOf, St as AgentResource, T as DevframeScopedNodeContext, Tt as AgentTool, U as DevframeDiagnosticsLogger, V as DevframeDiagnosticsDefinition, W as DevframeNodeRpcSession, X as RpcStreamingChannelOptions, Y as RpcStreamingChannel, Z as RpcStreamingHost, _ as ConnectionMeta, a as DevframeDockDefaults, b as DevframeNodeContext, bt as AgentHandle, c as DevframeSetupInfo, d as McpRouteOptions, et as DevframeRpcSharedStates, f as defineDevframe, g as Thenable, h as PartialWithoutId, i as DevframeDeploymentKind, j as ScopedBroadcastOptions, jt as EventEmitter, k as DevframeSettingsRegistry, kt as DevframeAgentHost, l as DevframeSpaOptions, m as EntriesToObject, n as DevframeCliOptions, o as DevframeDuplicationStrategy, q as RpcSharedStateGetOptions, r as DevframeDefinition, s as DevframeRuntime, t as DevframeBrowserContext, u as DevframeWsOptions, v as ConnectionMetaWebsocket, w as DevframeServicesRegistry, wt as AgentResourceInput, x as DevframeServiceId, xt as AgentManifest, y as DevframeCapabilities, z as DevframeStorageScope } from "./devframe-qgCKL683.mjs";
1
+ import { $ as DevframeRpcServerFunctions, A as DevframeSettingsStore, At as DevframeAgentHostEvents, B as DevframeDefineDiagnosticsOptions, C as DevframeServicesHost, Ct as AgentResourceContent, D as DevframeScopedStreamingHost, Dt as AgentToolProvider, E as DevframeScopedNodeRpc, Et as AgentToolInput, F as ScopedSharedStates, G as RpcBroadcastOptions, H as DevframeDiagnosticsHost, I as SettingsForNamespace, J as RpcSharedStateHost, K as RpcFunctionsHost, L as DevframeViewHost, M as ScopedClientFunctions, Mt as EventUnsubscribe, N as ScopedRpcFn, Nt as EventsMap, O as DevframeSettings, Ot as AgentToolProviderHandle, P as ScopedServerFunctions, Q as DevframeRpcClientFunctions, R as DevframeHost, S as DevframeServiceOf, St as AgentResource, T as DevframeScopedNodeContext, Tt as AgentTool, U as DevframeDiagnosticsLogger, V as DevframeDiagnosticsDefinition, W as DevframeNodeRpcSession, X as RpcStreamingChannelOptions, Y as RpcStreamingChannel, Z as RpcStreamingHost, _ as ConnectionMeta, a as DevframeDockDefaults, b as DevframeNodeContext, bt as AgentHandle, c as DevframeSetupInfo, d as McpRouteOptions, et as DevframeRpcSharedStates, f as defineDevframe, g as Thenable, h as PartialWithoutId, i as DevframeDeploymentKind, j as ScopedBroadcastOptions, jt as EventEmitter, k as DevframeSettingsRegistry, kt as DevframeAgentHost, l as DevframeSpaOptions, m as EntriesToObject, n as DevframeCliOptions, o as DevframeDuplicationStrategy, q as RpcSharedStateGetOptions, r as DevframeDefinition, s as DevframeRuntime, t as DevframeBrowserContext, u as DevframeWsOptions, v as ConnectionMetaWebsocket, w as DevframeServicesRegistry, wt as AgentResourceInput, x as DevframeServiceId, xt as AgentManifest, y as DevframeCapabilities, z as DevframeStorageScope } from "./devframe-mQ4qZAuo.mjs";
2
2
  import { C as RpcFunctionType, T as RpcReturnSchema, _ as RpcFunctionDefinition, g as RpcFunctionAgentOptions, i as RpcArgsSchema } from "./types-CnJSgRVa.mjs";
3
3
  import "./index-Dbw1p5ch.mjs";
4
- import { n as DevframeNodeRpcSessionMeta } from "./ws-server-J-zkiOyp.mjs";
4
+ import { n as DevframeNodeRpcSessionMeta } from "./ws-server-uKQcClcJ.mjs";
5
5
  //#region src/define.d.ts
6
6
  declare const defineRpcFunction: <NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends RpcArgsSchema | undefined = undefined, const RS extends RpcReturnSchema | undefined = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeNodeContext>) => RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeNodeContext>;
7
7
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as diagnostics } from "./diagnostics-B5-qHeqD.mjs";
1
+ import { t as diagnostics } from "./diagnostics-D7wM2cwM.mjs";
2
2
  import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { join } from "pathe";
4
4
  import process from "node:process";
@@ -1,3 +1,3 @@
1
- import { p as DevframeAuthHandler } from "../devframe-qgCKL683.mjs";
2
- import { a as verifyAuthToken, i as refreshTempAuthCode, n as exchangeTempAuthCode, o as revokeActiveConnectionsForToken, r as getTempAuthCode, s as revokeAuthToken, t as buildOtpAuthUrl } from "../index-B7RgLw--.mjs";
1
+ import { p as DevframeAuthHandler } from "../devframe-mQ4qZAuo.mjs";
2
+ import { a as verifyAuthToken, i as refreshTempAuthCode, n as exchangeTempAuthCode, o as revokeActiveConnectionsForToken, r as getTempAuthCode, s as revokeAuthToken, t as buildOtpAuthUrl } from "../index-b64Uuhy2.mjs";
3
3
  export { DevframeAuthHandler, buildOtpAuthUrl, exchangeTempAuthCode, getTempAuthCode, refreshTempAuthCode, revokeActiveConnectionsForToken, revokeAuthToken, verifyAuthToken };
@@ -1,5 +1,5 @@
1
- import { i as DevframeDeploymentKind, r as DevframeDefinition } from "../devframe-qgCKL683.mjs";
2
- import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-DFzmxCLa.mjs";
1
+ import { i as DevframeDeploymentKind, r as DevframeDefinition } from "../devframe-mQ4qZAuo.mjs";
2
+ import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-DoSozfvx.mjs";
3
3
  //#region src/adapters/_shared.d.ts
4
4
  /**
5
5
  * Resolve the mount base path for a devframe's SPA. Hosted adapters
@@ -1,3 +1,3 @@
1
- import { n as internalContextMap, t as getInternalContext } from "../context-CQefP2jR.mjs";
1
+ import { n as internalContextMap, t as getInternalContext } from "../context-CBg8iRbQ.mjs";
2
2
  import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-bWRzeSa0.mjs";
3
3
  export { getInternalContext, internalContextMap, normalizeBasePath, resolveBasePath };
@@ -1,7 +1,7 @@
1
- import { At as DevframeAgentHostEvents, C as DevframeServicesHost, Ct as AgentResourceContent, Dt as AgentToolProvider, Et as AgentToolInput, H as DevframeDiagnosticsHost$1, J as RpcSharedStateHost, K as RpcFunctionsHost, L as DevframeViewHost$1, O as DevframeSettings, Ot as AgentToolProviderHandle, R as DevframeHost, S as DevframeServiceOf, St as AgentResource, T as DevframeScopedNodeContext, Tt as AgentTool, U as DevframeDiagnosticsLogger, Z as RpcStreamingHost, b as DevframeNodeContext, bt as AgentHandle, ht as SharedState, jt as EventEmitter, kt as DevframeAgentHost$1, wt as AgentResourceInput, x as DevframeServiceId, xt as AgentManifest } from "../devframe-qgCKL683.mjs";
1
+ import { At as DevframeAgentHostEvents, C as DevframeServicesHost, Ct as AgentResourceContent, Dt as AgentToolProvider, Et as AgentToolInput, H as DevframeDiagnosticsHost$1, J as RpcSharedStateHost, K as RpcFunctionsHost, L as DevframeViewHost$1, O as DevframeSettings, Ot as AgentToolProviderHandle, R as DevframeHost, S as DevframeServiceOf, St as AgentResource, T as DevframeScopedNodeContext, Tt as AgentTool, U as DevframeDiagnosticsLogger, Z as RpcStreamingHost, b as DevframeNodeContext, bt as AgentHandle, ht as SharedState, jt as EventEmitter, kt as DevframeAgentHost$1, wt as AgentResourceInput, x as DevframeServiceId, xt as AgentManifest } from "../devframe-mQ4qZAuo.mjs";
2
2
  import { v as RpcFunctionDefinitionAny } from "../types-CnJSgRVa.mjs";
3
3
  import "../index-Dbw1p5ch.mjs";
4
- import { n as StartedServer, r as startHttpAndWs, t as StartHttpAndWsOptions } from "../server-E9z4ZWbd.mjs";
4
+ import { n as StartedServer, r as startHttpAndWs, t as StartHttpAndWsOptions } from "../server-UHWae43Q.mjs";
5
5
  import { BirpcGroup } from "birpc";
6
6
  //#region src/node/agent-args.d.ts
7
7
  /**
@@ -1,5 +1,5 @@
1
- import { a as DevframeViewHost, c as createRpcSharedStateServerHost, d as coerceAgentPositionalArgs, i as createNodeSettings, l as DevframeDiagnosticsHost, n as createHostContext, o as DevframeServicesHostImpl, r as createScopedNodeContext, s as createRpcStreamingServerHost, t as createH3DevframeHost, u as DevframeAgentHost } from "../host-h3-Kz7t5Xab.mjs";
2
- import { t as createStorage } from "../storage-Dzoc3NVC.mjs";
3
- import { r as registerDevframeInstance, t as listLiveDevframeInstances } from "../instance-registry-D6fxYu36.mjs";
4
- import { a as toDialableHost, i as normalizeHttpServerUrl, n as formatHostForUrl, r as isObject, t as startHttpAndWs } from "../server-CXaDDUl0.mjs";
1
+ import { a as DevframeViewHost, c as createRpcSharedStateServerHost, d as coerceAgentPositionalArgs, i as createNodeSettings, l as DevframeDiagnosticsHost, n as createHostContext, o as DevframeServicesHostImpl, r as createScopedNodeContext, s as createRpcStreamingServerHost, t as createH3DevframeHost, u as DevframeAgentHost } from "../host-h3-D2hYZvDK.mjs";
2
+ import { t as createStorage } from "../storage-CTNVbuFB.mjs";
3
+ import { r as registerDevframeInstance, t as listLiveDevframeInstances } from "../instance-registry-BnnA2Eoh.mjs";
4
+ import { a as toDialableHost, i as normalizeHttpServerUrl, n as formatHostForUrl, r as isObject, t as startHttpAndWs } from "../server-CD8XmBXl.mjs";
5
5
  export { DevframeAgentHost, DevframeDiagnosticsHost, DevframeServicesHostImpl, DevframeViewHost, coerceAgentPositionalArgs, createH3DevframeHost, createHostContext, createNodeSettings, createRpcSharedStateServerHost, createRpcStreamingServerHost, createScopedNodeContext, createStorage, formatHostForUrl, isObject, listLiveDevframeInstances, normalizeHttpServerUrl, registerDevframeInstance, startHttpAndWs, toDialableHost };
@@ -1,4 +1,4 @@
1
- import "../devframe-qgCKL683.mjs";
1
+ import "../devframe-mQ4qZAuo.mjs";
2
2
  import { E as Thenable, S as RpcFunctionSetupResult, c as RpcDump, g as RpcFunctionAgentOptions } from "../types-CnJSgRVa.mjs";
3
3
  import "../index-Dbw1p5ch.mjs";
4
4
  import { t as SimpleSchema } from "../simple-schema-BDzLeJDk.mjs";
@@ -1,5 +1,5 @@
1
- import { b as DevframeNodeContext, p as DevframeAuthHandler } from "../devframe-qgCKL683.mjs";
2
- import "../index-B7RgLw--.mjs";
1
+ import { b as DevframeNodeContext, p as DevframeAuthHandler } from "../devframe-mQ4qZAuo.mjs";
2
+ import "../index-b64Uuhy2.mjs";
3
3
  //#region src/recipes/interactive-auth.d.ts
4
4
  interface CreateInteractiveAuthOptions {
5
5
  /**
@@ -1,7 +1,7 @@
1
1
  import { n as colors } from "../diagnostics-reporter-CsIG85Q5.mjs";
2
2
  import { isAnonymousRpcMethod } from "../constants.mjs";
3
3
  import { n as defineRpcFunction } from "../define-BLWPsH6y.mjs";
4
- import { t as getInternalContext } from "../context-CQefP2jR.mjs";
4
+ import { t as getInternalContext } from "../context-CBg8iRbQ.mjs";
5
5
  import { a as verifyAuthToken, n as exchangeTempAuthCode, r as getTempAuthCode, t as buildOtpAuthUrl } from "../state-BeUHDDjk.mjs";
6
6
  import { t as s } from "../simple-schema-DQPZrAaZ.mjs";
7
7
  //#region src/recipes/interactive-auth.ts
@@ -1,2 +1,2 @@
1
- import { a as WsRpcTransportOptions, c as isAllowedOrigin, i as WsRpcTransport, l as isLoopbackHostname, n as DevframeNodeRpcSessionMeta, o as attachWsRpcTransport, r as WsOriginRegistry, s as createWsOriginRegistry, t as CreateWsOriginRegistryOptions } from "../../ws-server-J-zkiOyp.mjs";
1
+ import { a as WsRpcTransportOptions, c as isAllowedOrigin, i as WsRpcTransport, l as isLoopbackHostname, n as DevframeNodeRpcSessionMeta, o as attachWsRpcTransport, r as WsOriginRegistry, s as createWsOriginRegistry, t as CreateWsOriginRegistryOptions } from "../../ws-server-uKQcClcJ.mjs";
2
2
  export { CreateWsOriginRegistryOptions, DevframeNodeRpcSessionMeta, WsOriginRegistry, WsRpcTransport, WsRpcTransportOptions, attachWsRpcTransport, createWsOriginRegistry, isAllowedOrigin, isLoopbackHostname };
@@ -50,6 +50,21 @@ function createWsOriginRegistry(options = {}) {
50
50
  let sessionId = 0;
51
51
  const EMPTY_DEFS = /* @__PURE__ */ new Map();
52
52
  function NOOP() {}
53
+ function listen(server, port, host) {
54
+ return new Promise((resolve, reject) => {
55
+ const onError = (error) => reject(error);
56
+ server.once("error", onError);
57
+ try {
58
+ server.listen(port, host, () => {
59
+ server.off("error", onError);
60
+ resolve();
61
+ });
62
+ } catch (error) {
63
+ server.off("error", onError);
64
+ reject(error);
65
+ }
66
+ });
67
+ }
53
68
  /** Compare two URL paths ignoring a trailing slash. */
54
69
  function pathMatches(a, b) {
55
70
  const strip = (p) => p.length > 1 && p.endsWith("/") ? p.slice(0, -1) : p;
@@ -118,9 +133,9 @@ function routeUpgrades(server, ws, path, destroyUnmatched, allowedOrigins) {
118
133
  * `server` (sharing its port, optionally scoped to a `path`), or let this
119
134
  * helper create a standalone server from `port` / `host` / `https`.
120
135
  *
121
- * Returns the crossws node adapter plus `detach` (remove the upgrade
122
- * listener from a shared `server`) and `close` (full deterministic
123
- * teardown).
136
+ * Returns the crossws node adapter, standalone-server readiness/address
137
+ * accessors, `detach` (remove the upgrade listener from a shared `server`),
138
+ * and `close` (full deterministic teardown).
124
139
  */
125
140
  function attachWsRpcTransport(rpcGroup, options = {}) {
126
141
  const { server, port, host = "localhost", path, destroyUnmatched = false, https, allowedOrigins, onConnected = NOOP, onDisconnected = NOOP, definitions = EMPTY_DEFS, serialize: serializeOverride, deserialize: deserializeOverride } = options;
@@ -183,28 +198,34 @@ function attachWsRpcTransport(rpcGroup, options = {}) {
183
198
  }
184
199
  } });
185
200
  let detach = NOOP;
201
+ let ready = Promise.resolve();
186
202
  let ownedServer;
187
203
  if (server) detach = routeUpgrades(server, ws, path, destroyUnmatched, allowedOrigins);
188
204
  else if (https) {
189
205
  ownedServer = createServer$1(https);
190
206
  detach = routeUpgrades(ownedServer, ws, path, true, allowedOrigins);
191
- ownedServer.listen(port, host);
207
+ ready = listen(ownedServer, port ?? 0, host);
192
208
  } else {
193
209
  ownedServer = createServer((_req, res) => {
194
210
  res.writeHead(426, { "content-type": "text/plain" });
195
211
  res.end("Upgrade Required");
196
212
  });
197
213
  detach = routeUpgrades(ownedServer, ws, path, true, allowedOrigins);
198
- ownedServer.listen(port, host);
214
+ ready = listen(ownedServer, port ?? 0, host);
199
215
  }
216
+ const activeServer = server ?? ownedServer;
200
217
  return {
201
218
  ws,
219
+ ready,
220
+ address: () => activeServer?.address() ?? null,
202
221
  detach,
203
222
  async close() {
204
223
  detach();
205
224
  ws.closeAll(void 0, void 0, true);
206
225
  if (ownedServer) {
207
226
  const srv = ownedServer;
227
+ await ready.catch(() => {});
228
+ if (!srv.listening) return;
208
229
  await new Promise((r) => srv.close(() => r()));
209
230
  }
210
231
  }
@@ -1,7 +1,7 @@
1
1
  import { createRpcServer } from "./rpc/server.mjs";
2
2
  import { attachWsRpcTransport } from "./rpc/transports/ws-server.mjs";
3
- import { t as diagnostics } from "./diagnostics-B5-qHeqD.mjs";
4
- import { t as getInternalContext } from "./context-CQefP2jR.mjs";
3
+ import { t as diagnostics } from "./diagnostics-D7wM2cwM.mjs";
4
+ import { t as getInternalContext } from "./context-CBg8iRbQ.mjs";
5
5
  import { createServer } from "node:http";
6
6
  import { AsyncLocalStorage } from "node:async_hooks";
7
7
  import { H3, toNodeHandler } from "h3";
@@ -87,7 +87,8 @@ async function startHttpAndWs(options) {
87
87
  authHandler?.onConnect(peer, session);
88
88
  options.onPeerConnect?.(peer, session);
89
89
  } : void 0,
90
- onDisconnected: (_peer, meta) => {
90
+ onDisconnected: (peer, meta) => {
91
+ options.onPeerDisconnect?.(peer, meta);
91
92
  rpcHost._emitSessionDisconnected(meta);
92
93
  }
93
94
  });
@@ -103,9 +104,27 @@ async function startHttpAndWs(options) {
103
104
  return { isTrusted: true };
104
105
  }
105
106
  });
106
- if (ownsHttpServer) await new Promise((resolveListen) => {
107
- httpServer.listen(port, bindHost, () => resolveListen());
108
- });
107
+ if (ownsHttpServer) {
108
+ try {
109
+ await new Promise((resolve, reject) => {
110
+ const onError = (error) => reject(error);
111
+ httpServer.once("error", onError);
112
+ httpServer.listen(port, bindHost, () => {
113
+ httpServer.removeListener("error", onError);
114
+ resolve();
115
+ });
116
+ });
117
+ } catch (error) {
118
+ await closeWs().catch(() => {});
119
+ throw diagnostics.DF0052({
120
+ host: bindHost,
121
+ port,
122
+ reason: error instanceof Error ? error.message : String(error),
123
+ cause: error
124
+ });
125
+ }
126
+ if (options.onServerError) httpServer.on("error", options.onServerError);
127
+ }
109
128
  const address = httpServer.address();
110
129
  const resolvedPort = typeof address === "object" && address ? address.port : port;
111
130
  const origin = normalizeHttpServerUrl(bindHost, resolvedPort);
@@ -1,6 +1,6 @@
1
- import { $ as DevframeRpcServerFunctions, Q as DevframeRpcClientFunctions, W as DevframeNodeRpcSession, _ as ConnectionMeta, b as DevframeNodeContext, p as DevframeAuthHandler } from "./devframe-qgCKL683.mjs";
2
- import { r as WsOriginRegistry } from "./ws-server-J-zkiOyp.mjs";
3
- import "./index-B7RgLw--.mjs";
1
+ import { $ as DevframeRpcServerFunctions, Q as DevframeRpcClientFunctions, W as DevframeNodeRpcSession, _ as ConnectionMeta, b as DevframeNodeContext, p as DevframeAuthHandler } from "./devframe-mQ4qZAuo.mjs";
2
+ import { n as DevframeNodeRpcSessionMeta, r as WsOriginRegistry } from "./ws-server-uKQcClcJ.mjs";
3
+ import "./index-b64Uuhy2.mjs";
4
4
  import { Peer } from "crossws";
5
5
  import { BirpcGroup, EventOptions } from "birpc";
6
6
  import { NodeAdapter } from "crossws/adapters/node";
@@ -74,6 +74,13 @@ interface StartHttpAndWsOptions {
74
74
  * observe — but not override — the connect-time trust decision.
75
75
  */
76
76
  onPeerConnect?: (peer: Peer, session: DevframeNodeRpcSession) => void;
77
+ /**
78
+ * Called once per closed WS connection, right after the transport's own
79
+ * disconnect bookkeeping runs. Unlike {@link onPeerConnect} this receives
80
+ * the raw session meta, not a wrapped session — by the time a peer
81
+ * disconnects there is no live RPC client left to attach.
82
+ */
83
+ onPeerDisconnect?: (peer: Peer, meta: DevframeNodeRpcSessionMeta) => void;
77
84
  /**
78
85
  * Forwarded verbatim to the internal `createRpcServer`'s birpc
79
86
  * `rpcOptions`, alongside the resolver `startHttpAndWs` installs for
@@ -103,6 +110,16 @@ interface StartHttpAndWsOptions {
103
110
  port: number;
104
111
  app: H3;
105
112
  }) => void | Promise<void>;
113
+ /**
114
+ * Called for any error the HTTP server devframe owns emits after it starts
115
+ * listening — e.g. a transient `EMFILE` while accepting a connection.
116
+ * Without it such an error has no listener and crashes the process.
117
+ *
118
+ * Applies only to a server devframe created itself. When `server` is
119
+ * supplied the caller owns that object and attaches to it directly, so
120
+ * devframe leaves its error handling alone.
121
+ */
122
+ onServerError?: (error: Error) => void;
106
123
  }
107
124
  interface StartedServer {
108
125
  /** Listening origin, e.g. `http://localhost:9999`. */
@@ -1,4 +1,4 @@
1
- import { t as diagnostics } from "./diagnostics-B5-qHeqD.mjs";
1
+ import { t as diagnostics } from "./diagnostics-D7wM2cwM.mjs";
2
2
  import fs from "node:fs";
3
3
  import { dirname } from "pathe";
4
4
  import process$1 from "node:process";
@@ -1,4 +1,4 @@
1
- import { $ as DevframeRpcServerFunctions, A as DevframeSettingsStore, At as DevframeAgentHostEvents, B as DevframeDefineDiagnosticsOptions, C as DevframeServicesHost, Ct as AgentResourceContent, D as DevframeScopedStreamingHost, Dt as AgentToolProvider, E as DevframeScopedNodeRpc, Et as AgentToolInput, F as ScopedSharedStates, G as RpcBroadcastOptions, H as DevframeDiagnosticsHost, I as SettingsForNamespace, J as RpcSharedStateHost, K as RpcFunctionsHost, L as DevframeViewHost, M as ScopedClientFunctions, Mt as EventUnsubscribe, N as ScopedRpcFn, Nt as EventsMap, O as DevframeSettings, Ot as AgentToolProviderHandle, P as ScopedServerFunctions, Q as DevframeRpcClientFunctions, R as DevframeHost, S as DevframeServiceOf, St as AgentResource, T as DevframeScopedNodeContext, Tt as AgentTool, U as DevframeDiagnosticsLogger, V as DevframeDiagnosticsDefinition, W as DevframeNodeRpcSession, X as RpcStreamingChannelOptions, Y as RpcStreamingChannel, Z as RpcStreamingHost, _ as ConnectionMeta, a as DevframeDockDefaults, b as DevframeNodeContext, bt as AgentHandle, c as DevframeSetupInfo, d as McpRouteOptions, et as DevframeRpcSharedStates, f as defineDevframe, g as Thenable, h as PartialWithoutId, i as DevframeDeploymentKind, j as ScopedBroadcastOptions, jt as EventEmitter, k as DevframeSettingsRegistry, kt as DevframeAgentHost, l as DevframeSpaOptions, m as EntriesToObject, n as DevframeCliOptions, o as DevframeDuplicationStrategy, q as RpcSharedStateGetOptions, r as DevframeDefinition, s as DevframeRuntime, t as DevframeBrowserContext, u as DevframeWsOptions, v as ConnectionMetaWebsocket, w as DevframeServicesRegistry, wt as AgentResourceInput, x as DevframeServiceId, xt as AgentManifest, y as DevframeCapabilities, z as DevframeStorageScope } from "../devframe-qgCKL683.mjs";
1
+ import { $ as DevframeRpcServerFunctions, A as DevframeSettingsStore, At as DevframeAgentHostEvents, B as DevframeDefineDiagnosticsOptions, C as DevframeServicesHost, Ct as AgentResourceContent, D as DevframeScopedStreamingHost, Dt as AgentToolProvider, E as DevframeScopedNodeRpc, Et as AgentToolInput, F as ScopedSharedStates, G as RpcBroadcastOptions, H as DevframeDiagnosticsHost, I as SettingsForNamespace, J as RpcSharedStateHost, K as RpcFunctionsHost, L as DevframeViewHost, M as ScopedClientFunctions, Mt as EventUnsubscribe, N as ScopedRpcFn, Nt as EventsMap, O as DevframeSettings, Ot as AgentToolProviderHandle, P as ScopedServerFunctions, Q as DevframeRpcClientFunctions, R as DevframeHost, S as DevframeServiceOf, St as AgentResource, T as DevframeScopedNodeContext, Tt as AgentTool, U as DevframeDiagnosticsLogger, V as DevframeDiagnosticsDefinition, W as DevframeNodeRpcSession, X as RpcStreamingChannelOptions, Y as RpcStreamingChannel, Z as RpcStreamingHost, _ as ConnectionMeta, a as DevframeDockDefaults, b as DevframeNodeContext, bt as AgentHandle, c as DevframeSetupInfo, d as McpRouteOptions, et as DevframeRpcSharedStates, f as defineDevframe, g as Thenable, h as PartialWithoutId, i as DevframeDeploymentKind, j as ScopedBroadcastOptions, jt as EventEmitter, k as DevframeSettingsRegistry, kt as DevframeAgentHost, l as DevframeSpaOptions, m as EntriesToObject, n as DevframeCliOptions, o as DevframeDuplicationStrategy, q as RpcSharedStateGetOptions, r as DevframeDefinition, s as DevframeRuntime, t as DevframeBrowserContext, u as DevframeWsOptions, v as ConnectionMetaWebsocket, w as DevframeServicesRegistry, wt as AgentResourceInput, x as DevframeServiceId, xt as AgentManifest, y as DevframeCapabilities, z as DevframeStorageScope } from "../devframe-mQ4qZAuo.mjs";
2
2
  import { g as RpcFunctionAgentOptions } from "../types-CnJSgRVa.mjs";
3
- import { n as DevframeNodeRpcSessionMeta } from "../ws-server-J-zkiOyp.mjs";
3
+ import { n as DevframeNodeRpcSessionMeta } from "../ws-server-uKQcClcJ.mjs";
4
4
  export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeBrowserContext, DevframeCapabilities, DevframeCliOptions, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsDefinition, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeRuntime, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceId, DevframeServiceOf, DevframeServicesHost, DevframeServicesRegistry, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSpaOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, McpRouteOptions, PartialWithoutId, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, Thenable, defineDevframe };
@@ -1,4 +1,4 @@
1
- import { Nt as EventsMap, jt as EventEmitter } from "../devframe-qgCKL683.mjs";
1
+ import { Nt as EventsMap, jt as EventEmitter } from "../devframe-mQ4qZAuo.mjs";
2
2
  //#region src/utils/events.d.ts
3
3
  /**
4
4
  * Create event emitter.
@@ -1,2 +1,2 @@
1
- import { _t as SharedStateOptions, dt as ImmutableArray, ft as ImmutableMap, gt as SharedStateEvents, ht as SharedState, mt as ImmutableSet, pt as ImmutableObject, ut as Immutable, vt as SharedStatePatch, yt as createSharedState } from "../devframe-qgCKL683.mjs";
1
+ import { _t as SharedStateOptions, dt as ImmutableArray, ft as ImmutableMap, gt as SharedStateEvents, ht as SharedState, mt as ImmutableSet, pt as ImmutableObject, ut as Immutable, vt as SharedStatePatch, yt as createSharedState } from "../devframe-mQ4qZAuo.mjs";
2
2
  export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
@@ -1,2 +1,2 @@
1
- import { at as StreamReader, ct as createStreamReader, it as StreamErrorPayload, lt as createStreamSink, nt as CreateStreamReaderOptions, ot as StreamSink, rt as CreateStreamSinkOptions, st as StreamSinkEvents, tt as BufferedChunk } from "../devframe-qgCKL683.mjs";
1
+ import { at as StreamReader, ct as createStreamReader, it as StreamErrorPayload, lt as createStreamSink, nt as CreateStreamReaderOptions, ot as StreamSink, rt as CreateStreamSinkOptions, st as StreamSinkEvents, tt as BufferedChunk } from "../devframe-mQ4qZAuo.mjs";
2
2
  export { BufferedChunk, CreateStreamReaderOptions, CreateStreamSinkOptions, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, createStreamReader, createStreamSink };
@@ -4,6 +4,7 @@ import { BirpcGroup, ChannelOptions } from "birpc";
4
4
  import { NodeAdapter } from "crossws/adapters/node";
5
5
  import { Server } from "node:http";
6
6
  import { Server as Server$1, ServerOptions } from "node:https";
7
+ import { AddressInfo } from "node:net";
7
8
  //#region src/rpc/transports/ws-server.d.ts
8
9
  interface DevframeNodeRpcSessionMeta {
9
10
  id: number;
@@ -34,9 +35,12 @@ interface WsRpcTransportOptions {
34
35
  * this transport detaches the upgrade listener without closing the server.
35
36
  */
36
37
  server?: Server | Server$1;
37
- /** Port for a newly-created standalone WS server. */
38
+ /**
39
+ * Port for the standalone WebSocket server. Defaults to `0`, which lets the
40
+ * operating system assign an available port.
41
+ */
38
42
  port?: number;
39
- /** Host for a newly-created standalone WS server. Defaults to `localhost`. */
43
+ /** Host for the standalone WebSocket server. Defaults to `localhost`. */
40
44
  host?: string;
41
45
  /**
42
46
  * Restrict the WS endpoint to a single upgrade route (e.g. `/__devframe_ws`). When
@@ -106,6 +110,10 @@ interface WsRpcTransport {
106
110
  * `peers` and pub/sub. See https://crossws.h3.dev.
107
111
  */
108
112
  ws: NodeAdapter;
113
+ /** Resolves when the transport-owned server is listening. */
114
+ ready: Promise<void>;
115
+ /** Returns the bound address, or `null` when the server is not listening. */
116
+ address: () => AddressInfo | string | null;
109
117
  /** Remove the upgrade listener from a shared `server` (a no-op otherwise). */
110
118
  detach: () => void;
111
119
  /**
@@ -130,9 +138,9 @@ declare function isAllowedOrigin(origin: string | undefined, allowedOrigins: rea
130
138
  * `server` (sharing its port, optionally scoped to a `path`), or let this
131
139
  * helper create a standalone server from `port` / `host` / `https`.
132
140
  *
133
- * Returns the crossws node adapter plus `detach` (remove the upgrade
134
- * listener from a shared `server`) and `close` (full deterministic
135
- * teardown).
141
+ * Returns the crossws node adapter, standalone-server readiness/address
142
+ * accessors, `detach` (remove the upgrade listener from a shared `server`),
143
+ * and `close` (full deterministic teardown).
136
144
  */
137
145
  declare function attachWsRpcTransport<ClientFunctions extends object, ServerFunctions extends object>(rpcGroup: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: WsRpcTransportOptions): WsRpcTransport;
138
146
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "devframe",
3
3
  "type": "module",
4
- "version": "0.8.1",
4
+ "version": "0.8.2",
5
5
  "description": "Framework for building generic devframes",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -115,7 +115,7 @@
115
115
  "ua-parser-modern": "^0.1.1",
116
116
  "valibot": "^1.4.2",
117
117
  "whenexpr": "^0.1.2",
118
- "ws": "^8.21.1"
118
+ "ws": "^8.21.2"
119
119
  },
120
120
  "scripts": {
121
121
  "build": "tsdown",