devframe 0.9.8 → 0.9.9
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/{_shared-BM3PdYli.mjs → _shared-C08SdQRl.mjs} +15 -4
- package/dist/{_shared-mtXpcJIv.d.mts → _shared-CK3czkH4.d.mts} +25 -2
- package/dist/adapters/build.d.mts +6 -6
- package/dist/adapters/build.mjs +32 -22
- package/dist/adapters/cac.d.mts +16 -1
- package/dist/adapters/cac.mjs +8 -7
- package/dist/adapters/dev.d.mts +13 -13
- package/dist/adapters/dev.mjs +2 -2
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +28 -26
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +28 -14
- package/dist/adapters/mcp.mjs +75 -39
- package/dist/{agent-tool-name-EgfoFO8C.mjs → agent-tool-name-DGzeuWcO.mjs} +2 -2
- package/dist/cli/main.d.mts +1 -1
- package/dist/cli/main.mjs +41 -17
- package/dist/client/index.d.mts +36 -36
- package/dist/client/index.mjs +83 -51
- package/dist/{client-assets-C7SXgTWY.mjs → client-assets-DNdhagGm.mjs} +2 -2
- package/dist/constants.d.mts +8 -7
- package/dist/constants.mjs +7 -6
- package/dist/{context-CLF4-8Pp.d.mts → context-4AIVRLYF.d.mts} +158 -122
- package/dist/{context-omlma_1n.mjs → context-CwPUinjn.mjs} +126 -88
- package/dist/{context-KUqAfawQ.mjs → context-DIUvJW4D.mjs} +3 -3
- package/dist/{context-DftYyXaR.d.mts → context-rgBSPFHS.d.mts} +5 -5
- package/dist/{crypto-token-XCqTSMg9.mjs → crypto-token-TVbGGFuj.mjs} +1 -1
- package/dist/{dev-CzkPCJwi.mjs → dev-Eqq5PX0k.mjs} +37 -18
- package/dist/{diagnostics-BXWW3VK-.mjs → diagnostics-BMfN8mb1.mjs} +30 -17
- package/dist/{diagnostics-CD8nlgll.mjs → diagnostics-D0EVm5M6.mjs} +2 -2
- package/dist/{events-4daw0uK9.mjs → events-BV4Dj59a.mjs} +2 -2
- package/dist/{host-h3-fRbF9yor.mjs → host-h3-BJ4siyz7.mjs} +1 -1
- package/dist/in-page-channel/index.d.mts +14 -14
- package/dist/in-page-channel/index.mjs +63 -54
- package/dist/{index-BzyopqxV.d.mts → index-pIVt92jP.d.mts} +9 -9
- package/dist/{index-D3k0BIhe.d.mts → index-pKl67H6w.d.mts} +4 -4
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +2 -2
- package/dist/{instance-registry-BjlMQbFB.mjs → instance-registry-C7-41RSp.mjs} +8 -8
- package/dist/{instance-shell-Tcp5hGoq.d.mts → instance-shell-7Z52PE4_.d.mts} +18 -18
- package/dist/{instance-shell-CpVW4zG0.mjs → instance-shell-cdVETpfz.mjs} +227 -58
- package/dist/internal/index.d.mts +40 -23
- package/dist/internal/index.mjs +10 -10
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/auth.mjs +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/hub-internals.mjs +2 -2
- package/dist/node/index.d.mts +5 -5
- package/dist/node/index.mjs +2 -2
- package/dist/{nostics-SPGDgHEP.d.mts → nostics-0sKe5HIj.d.mts} +2 -2
- package/dist/{nostics-CzECRXpE.mjs → nostics-D0PvLZsn.mjs} +1 -1
- package/dist/origin-DGDH8BI9.d.mts +45 -0
- package/dist/origin-DZit9g29.mjs +80 -0
- package/dist/recipes/common-rpc-functions.d.mts +5 -5
- package/dist/recipes/common-rpc-functions.mjs +3 -3
- package/dist/recipes/interactive-auth.d.mts +6 -6
- package/dist/recipes/interactive-auth.mjs +6 -6
- package/dist/{remote-assets-DezQmPQU.mjs → remote-assets-BIFWOlBW.mjs} +26 -6
- package/dist/{remote-assets-B13_vRkJ.d.mts → remote-assets-eBvSKZMS.d.mts} +7 -7
- package/dist/{revoke-COLW0cOi.mjs → revoke-cqztiCX4.mjs} +1 -1
- package/dist/rpc/dump.d.mts +2 -11
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.d.mts +2 -2
- package/dist/rpc/index.mjs +3 -3
- package/dist/rpc/transports/sse-client.d.mts +1 -1
- package/dist/rpc/transports/sse-client.mjs +30 -14
- package/dist/rpc/transports/sse-server.d.mts +4 -4
- package/dist/rpc/transports/sse-server.mjs +7 -7
- package/dist/rpc/transports/ws-bun.d.mts +5 -5
- package/dist/rpc/transports/ws-bun.mjs +8 -2
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +2 -2
- package/dist/rpc/transports/ws-deno.d.mts +4 -4
- package/dist/rpc/transports/ws-deno.mjs +8 -2
- package/dist/rpc/transports/ws-server.d.mts +2 -1
- package/dist/rpc/transports/ws-server.mjs +232 -1
- package/dist/{rpc-core-B3W3z9ff.d.mts → rpc-core-Ceu6AUz8.d.mts} +4 -4
- package/dist/{rpc-core-DlHd276T.mjs → rpc-core-DVQ7xi89.mjs} +14 -2
- package/dist/{serialization-BGzEwAdr.mjs → serialization-DTZnPQ1-.mjs} +20 -18
- package/dist/{services-install-CqqQVls5.mjs → services-install-P_DV7VYL.mjs} +32 -21
- package/dist/session-DPfj6zQG.mjs +16 -0
- package/dist/{shared-state--sduc6Xi.mjs → shared-state-CaxB1q0h.mjs} +2 -2
- package/dist/{simple-schema-DQPZrAaZ.mjs → simple-schema-Bi40l-P6.mjs} +2 -2
- package/dist/{sse-client-DwX021ST.d.mts → sse-client-BQ4jS3eO.d.mts} +4 -4
- package/dist/{state-CK9LjrnT.mjs → state-CeQQWzM-.mjs} +4 -4
- package/dist/{static-DV_qUSRS.mjs → static-DZ8P2Kn7.mjs} +130 -135
- package/dist/{storage-BXNVhKyR.mjs → storage-Dccf_IyD.mjs} +1 -1
- package/dist/types/index.d.mts +6 -6
- package/dist/{types-CMdPYhOx.d.mts → types-Dq4i156u.d.mts} +17 -17
- package/dist/utils/agent-tool-name.d.mts +2 -2
- package/dist/utils/agent-tool-name.mjs +2 -2
- package/dist/utils/colors.d.mts +1 -1
- package/dist/utils/crypto-token.d.mts +1 -1
- package/dist/utils/crypto-token.mjs +1 -1
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/nostics.d.mts +1 -1
- package/dist/utils/nostics.mjs +1 -1
- package/dist/utils/open.mjs +1 -1
- package/dist/utils/origin.d.mts +2 -0
- package/dist/utils/origin.mjs +80 -0
- package/dist/utils/remote-assets.d.mts +2 -2
- package/dist/utils/remote-assets.mjs +1 -1
- package/dist/utils/serve-static.d.mts +4 -4
- package/dist/utils/serve-static.mjs +56 -19
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/shared-state.mjs +1 -1
- package/dist/utils/simple-schema.d.mts +5 -5
- package/dist/utils/simple-schema.mjs +2 -2
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/utils/streaming-channel.mjs +2 -2
- package/dist/utils/when.d.mts +5 -5
- package/dist/{validation-YrZH6atx.mjs → validation-BOy8IoFZ.mjs} +2 -2
- package/dist/{wire-codec-0K-o5MYW.mjs → wire-codec-dcCeXcSo.mjs} +3 -3
- package/dist/{ws-client-7_lZi-B9.d.mts → ws-client-Xpxt0oPA.d.mts} +3 -3
- package/dist/{ws-server-VyHlanzy.d.mts → ws-server-D2nv68Hg.d.mts} +13 -37
- package/package.json +2 -1
- package/dist/ws-server-Y_AumUQH.mjs +0 -294
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/events.ts
|
|
2
2
|
/**
|
|
3
|
-
* Centralized registry of the core devframe event names
|
|
3
|
+
* Centralized registry of the core devframe event names: the node-side host
|
|
4
4
|
* bus events, the client RPC connection events, and the server→client
|
|
5
|
-
* broadcast notifications
|
|
5
|
+
* broadcast notifications, so these names live in one place instead of
|
|
6
6
|
* scattered string literals.
|
|
7
7
|
*
|
|
8
8
|
* **Keep this in sync with [`docs/content/8.references/3.events.md`](../../../docs/content/8.references/3.events.md)**
|
|
@@ -3,7 +3,7 @@ import { join } from "pathe";
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
//#region src/node/host-h3.ts
|
|
5
5
|
/**
|
|
6
|
-
* h3-backed {@link DevframeHost}
|
|
6
|
+
* h3-backed {@link DevframeHost}, used by the standalone CLI adapter.
|
|
7
7
|
*/
|
|
8
8
|
function createH3DevframeHost(options) {
|
|
9
9
|
const workspaceRoot = options.workspaceRoot ?? process.cwd();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { D as InferArgsType, E as Thenable, O as InferReturnType, T as RpcReturnSchema, i as RpcArgsSchema } from "../types-
|
|
2
|
-
import {
|
|
1
|
+
import { D as InferArgsType, E as Thenable, O as InferReturnType, T as RpcReturnSchema, i as RpcArgsSchema } from "../types-Dq4i156u.mjs";
|
|
2
|
+
import { Bt as EventEmitter, k as SharedState } from "../context-4AIVRLYF.mjs";
|
|
3
3
|
import { BirpcReturn } from "birpc";
|
|
4
4
|
//#region src/in-page-channel/types.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* The shared contract of one in-page channel, declared once (usually in a
|
|
7
7
|
* `shared/protocol.ts` both sides import) and passed to both endpoints as a
|
|
8
|
-
* type parameter. Purely a type
|
|
8
|
+
* type parameter. Purely a type; the only runtime companion is the
|
|
9
9
|
* channel-name constant declared next to it.
|
|
10
10
|
*/
|
|
11
11
|
interface InPageChannelProtocol {
|
|
@@ -33,13 +33,13 @@ type FnReturn<F> = F extends ((...args: any[]) => infer R) ? Awaited<R> : never;
|
|
|
33
33
|
*/
|
|
34
34
|
type ProtocolHandler<F> = F extends ((...args: any[]) => any) ? (...args: FnArgs<F>) => Thenable<FnReturn<F>> : never;
|
|
35
35
|
/**
|
|
36
|
-
* Types of an in-page channel function
|
|
36
|
+
* Types of an in-page channel function: `RpcFunctionType` minus the
|
|
37
37
|
* server-only `static`: `event` is fire-and-forget (the only type valid for
|
|
38
38
|
* fan-out), `action` performs, `query` requests data (the default).
|
|
39
39
|
*/
|
|
40
40
|
type InPageFunctionType = 'action' | 'event' | 'query';
|
|
41
41
|
/**
|
|
42
|
-
* An in-page channel function definition
|
|
42
|
+
* An in-page channel function definition: the `defineRpcFunction` authoring
|
|
43
43
|
* shape (`name`, `type`, Standard-Schema `args`/`returns`,
|
|
44
44
|
* `jsonSerializable`, `handler`) narrowed to the browser: there is no
|
|
45
45
|
* `dump`/`snapshot`/`cacheable`/`agent`. When `jsonSerializable` is `true`,
|
|
@@ -122,7 +122,7 @@ interface InPageChannelCommonOptions {
|
|
|
122
122
|
callTimeoutMs?: number;
|
|
123
123
|
/**
|
|
124
124
|
* Liveness heartbeat guarding against silently dead ports. Defaults to a
|
|
125
|
-
* 5s ping / 12s silence window; pass `false` to disable
|
|
125
|
+
* 5s ping / 12s silence window; pass `false` to disable, on both
|
|
126
126
|
* endpoints together.
|
|
127
127
|
*/
|
|
128
128
|
heartbeat?: {
|
|
@@ -130,7 +130,7 @@ interface InPageChannelCommonOptions {
|
|
|
130
130
|
timeoutMs?: number;
|
|
131
131
|
} | false;
|
|
132
132
|
/**
|
|
133
|
-
* Applied to each outgoing argument and handler result before posting
|
|
133
|
+
* Applied to each outgoing argument and handler result before posting;
|
|
134
134
|
* the place to unwrap framework reactivity (Vue `toRaw`, Solid `unwrap`)
|
|
135
135
|
* into plain structured-cloneable values.
|
|
136
136
|
*/
|
|
@@ -160,7 +160,7 @@ interface ConnectPanelChannelOptions<Protocol extends InPageChannelProtocol = In
|
|
|
160
160
|
window?: Window | false;
|
|
161
161
|
/**
|
|
162
162
|
* Windows the hello is posted to. Defaults to the panel's ancestor chain
|
|
163
|
-
* plus its `opener
|
|
163
|
+
* plus its `opener`, the places a same-tab page script can live. When
|
|
164
164
|
* empty and no `transport` is given, the endpoint stays `connecting` and
|
|
165
165
|
* warns once.
|
|
166
166
|
*/
|
|
@@ -169,7 +169,7 @@ interface ConnectPanelChannelOptions<Protocol extends InPageChannelProtocol = In
|
|
|
169
169
|
transport?: MessagePort;
|
|
170
170
|
/**
|
|
171
171
|
* Pin this panel to one page-script instance id. By default the panel
|
|
172
|
-
* auto-pairs with the most recent page script that answers
|
|
172
|
+
* auto-pairs with the most recent page script that answers, almost
|
|
173
173
|
* always "my own tab's page script".
|
|
174
174
|
*/
|
|
175
175
|
instanceId?: string;
|
|
@@ -188,7 +188,7 @@ interface ConnectPanelChannelOptions<Protocol extends InPageChannelProtocol = In
|
|
|
188
188
|
eventBufferLimit?: number;
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
|
-
* The channel shared-state accessor
|
|
191
|
+
* The channel shared-state accessor, mirroring `rpc.sharedState`, with the
|
|
192
192
|
* page script playing the server's role as rendezvous and authority. The
|
|
193
193
|
* page script's first `get` of a key must provide `initialValue`; a panel's
|
|
194
194
|
* `get` without one resolves once the authority's first replay arrives.
|
|
@@ -260,7 +260,7 @@ interface PanelChannel<P extends InPageChannelProtocol> {
|
|
|
260
260
|
/**
|
|
261
261
|
* Resolves once connected. With `timeoutMs`, rejects with an
|
|
262
262
|
* `InPageChannelError` (code `timeout`) when no page script answered in
|
|
263
|
-
* time
|
|
263
|
+
* time; the hook for a "no page script found" fallback UI.
|
|
264
264
|
*/
|
|
265
265
|
whenConnected: (timeoutMs?: number) => Promise<void>;
|
|
266
266
|
/**
|
|
@@ -308,7 +308,7 @@ declare class InPageChannelError extends Error {
|
|
|
308
308
|
*
|
|
309
309
|
* It listens for panel hellos on the host page's window and answers each
|
|
310
310
|
* with a dedicated `MessageChannel` port (same-origin enforced both ways),
|
|
311
|
-
* keeping one live peer per panel
|
|
311
|
+
* keeping one live peer per panel: dock iframe, popup, and Document-PiP
|
|
312
312
|
* panels all handshake the same way, and a panel reload is simply a new
|
|
313
313
|
* handshake. No server is involved at any point.
|
|
314
314
|
*/
|
|
@@ -320,7 +320,7 @@ declare function createPageScriptChannel<P extends InPageChannelProtocol>(option
|
|
|
320
320
|
*
|
|
321
321
|
* The panel initiates: it posts a versioned hello to every window a
|
|
322
322
|
* same-tab page script can live in (its ancestor chain and its `opener`),
|
|
323
|
-
* retrying with backoff until one answers with a dedicated port
|
|
323
|
+
* retrying with backoff until one answers with a dedicated port, so boot
|
|
324
324
|
* order never matters, and a reload of either side is just a re-handshake
|
|
325
325
|
* (`WindowProxy` references survive navigations). While `connecting`,
|
|
326
326
|
* outgoing calls and events are buffered; when no page script exists at all
|
|
@@ -331,7 +331,7 @@ declare function connectPanelChannel<P extends InPageChannelProtocol>(options: C
|
|
|
331
331
|
//#endregion
|
|
332
332
|
//#region src/in-page-channel/index.d.ts
|
|
333
333
|
/**
|
|
334
|
-
* Define one in-page channel function
|
|
334
|
+
* Define one in-page channel function, the `defineRpcFunction` authoring
|
|
335
335
|
* shape narrowed to the browser (see {@link InPageFunctionDefinition}).
|
|
336
336
|
* Pure identity: it only types the definition. Functions live in
|
|
337
337
|
* side-specific files and are passed to their endpoint via `functions`; the
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { t as DEVFRAME_EVENTS } from "../events-
|
|
1
|
+
import { t as DEVFRAME_EVENTS } from "../events-BV4Dj59a.mjs";
|
|
2
2
|
import { createEventEmitter } from "../utils/events.mjs";
|
|
3
|
-
import { t as createSharedState } from "../shared-state
|
|
3
|
+
import { t as createSharedState } from "../shared-state-CaxB1q0h.mjs";
|
|
4
4
|
import { nanoid } from "../utils/nanoid.mjs";
|
|
5
5
|
import { createBirpc } from "birpc";
|
|
6
6
|
//#region src/in-page-channel/protocol.ts
|
|
7
7
|
/**
|
|
8
8
|
* Wire protocol of the in-page channel handshake and its port-level control
|
|
9
|
-
* frames. The envelope is transport-neutral by design
|
|
9
|
+
* frames. The envelope is transport-neutral by design: it identifies the
|
|
10
10
|
* protocol (`channel` tag + `v`), the user channel (`name`), and the peers
|
|
11
|
-
* (`panelId`, `instanceId`)
|
|
11
|
+
* (`panelId`, `instanceId`), so a future cross-tab transport (e.g. a
|
|
12
12
|
* `BroadcastChannel`) can reuse it unchanged.
|
|
13
13
|
*/
|
|
14
14
|
/** `postMessage` tag every handshake message carries. */
|
|
@@ -26,7 +26,7 @@ let memoryInstanceId;
|
|
|
26
26
|
/**
|
|
27
27
|
* The page context's instance id: one nanoid per browser tab, persisted in
|
|
28
28
|
* `sessionStorage` so it survives page-script reloads. It scopes handshakes
|
|
29
|
-
* when the same app is open in several tabs
|
|
29
|
+
* when the same app is open in several tabs, since a panel pinned to an instance
|
|
30
30
|
* id ignores grants from every other tab's page script.
|
|
31
31
|
*/
|
|
32
32
|
function resolveInstanceId(win) {
|
|
@@ -52,7 +52,7 @@ function resolveAllowedOrigins(allowedOrigins, win) {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Default handshake targets of a panel: its ancestor chain plus its
|
|
55
|
-
* `opener
|
|
55
|
+
* `opener`, every same-tab window a page script can live in. `WindowProxy`
|
|
56
56
|
* references stay valid across navigations, so hellos posted to these reach
|
|
57
57
|
* a page script even after the host page reloads.
|
|
58
58
|
*/
|
|
@@ -93,7 +93,7 @@ var InPageChannelError = class extends Error {
|
|
|
93
93
|
};
|
|
94
94
|
const warned = /* @__PURE__ */ new Set();
|
|
95
95
|
/**
|
|
96
|
-
* `console.warn` once per distinct message
|
|
96
|
+
* `console.warn` once per distinct message, since handshake noise (foreign
|
|
97
97
|
* origins, version mismatches, missing targets) repeats on every retry tick.
|
|
98
98
|
*/
|
|
99
99
|
function warnOnce(message) {
|
|
@@ -102,19 +102,13 @@ function warnOnce(message) {
|
|
|
102
102
|
console.warn(`[devframe] ${message}`);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (seen.has(value)) return `${path} is circular`;
|
|
110
|
-
seen.add(value);
|
|
111
|
-
if (Array.isArray(value)) {
|
|
112
|
-
for (let i = 0; i < value.length; i++) {
|
|
113
|
-
const violation = jsonViolation(value[i], `${path}[${i}]`, seen);
|
|
114
|
-
if (violation) return violation;
|
|
115
|
-
}
|
|
116
|
-
return;
|
|
105
|
+
function jsonArrayViolation(value, path, seen) {
|
|
106
|
+
for (let i = 0; i < value.length; i++) {
|
|
107
|
+
const violation = jsonViolation(value[i], `${path}[${i}]`, seen);
|
|
108
|
+
if (violation) return violation;
|
|
117
109
|
}
|
|
110
|
+
}
|
|
111
|
+
function jsonObjectViolation(value, path, seen) {
|
|
118
112
|
const proto = Object.getPrototypeOf(value);
|
|
119
113
|
if (proto !== Object.prototype && proto !== null) return `${path} is an instance of ${value.constructor?.name ?? "an exotic class"}`;
|
|
120
114
|
for (const [key, entry] of Object.entries(value)) {
|
|
@@ -122,10 +116,18 @@ function jsonViolation(value, path, seen) {
|
|
|
122
116
|
if (violation) return violation;
|
|
123
117
|
}
|
|
124
118
|
}
|
|
119
|
+
function jsonViolation(value, path, seen) {
|
|
120
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return void 0;
|
|
121
|
+
if (typeof value === "number") return Number.isFinite(value) ? void 0 : `${path} is ${value}`;
|
|
122
|
+
if (typeof value !== "object") return `${path} is ${value === void 0 ? "`undefined`" : `a ${typeof value}`}`;
|
|
123
|
+
if (seen.has(value)) return `${path} is circular`;
|
|
124
|
+
seen.add(value);
|
|
125
|
+
return Array.isArray(value) ? jsonArrayViolation(value, path, seen) : jsonObjectViolation(value, path, seen);
|
|
126
|
+
}
|
|
125
127
|
/**
|
|
126
128
|
* Enforce a `jsonSerializable: true` contract: throws code
|
|
127
129
|
* `not-serializable` naming the offending path when the value contains
|
|
128
|
-
* anything strict JSON can't represent
|
|
130
|
+
* anything strict JSON can't represent, surfacing the bug at the offending
|
|
129
131
|
* call instead of a silent coercion later.
|
|
130
132
|
*/
|
|
131
133
|
function assertJsonSerializable(value, what, functionName) {
|
|
@@ -181,14 +183,35 @@ function createLocalFunctionRegistry(codec) {
|
|
|
181
183
|
};
|
|
182
184
|
}
|
|
183
185
|
function wrapPostError(error) {
|
|
184
|
-
if (error instanceof DOMException && error.name === "DataCloneError") return new InPageChannelError("not-cloneable", `a payload could not be structured-cloned across the in-page channel: ${error.message}. Strip non-cloneable values (functions, DOM nodes, framework reactivity proxies) before sending
|
|
186
|
+
if (error instanceof DOMException && error.name === "DataCloneError") return new InPageChannelError("not-cloneable", `a payload could not be structured-cloned across the in-page channel: ${error.message}. Strip non-cloneable values (functions, DOM nodes, framework reactivity proxies) before sending: declare the function \`jsonSerializable: true\` for a precise error, or provide a \`serialize\` hook.`, { cause: error });
|
|
185
187
|
return error;
|
|
186
188
|
}
|
|
187
189
|
function attachChannelPort(port, options) {
|
|
188
190
|
let birpcHandler;
|
|
189
191
|
let disposed = false;
|
|
190
192
|
const attached = {
|
|
191
|
-
rpc:
|
|
193
|
+
rpc: createBirpc({}, {
|
|
194
|
+
post: (data) => {
|
|
195
|
+
try {
|
|
196
|
+
port.postMessage(data);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
throw wrapPostError(error);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
on: (fn) => {
|
|
202
|
+
birpcHandler = fn;
|
|
203
|
+
},
|
|
204
|
+
off: () => {
|
|
205
|
+
birpcHandler = void 0;
|
|
206
|
+
},
|
|
207
|
+
/**
|
|
208
|
+
* Deadlines live at the endpoint layer (`withCallDeadline`) with
|
|
209
|
+
* status-aware errors; birpc's own timer stays off.
|
|
210
|
+
*/
|
|
211
|
+
timeout: -1,
|
|
212
|
+
proxify: false,
|
|
213
|
+
resolver: (name, resolved) => resolved ?? options.resolveLocal(name)
|
|
214
|
+
}),
|
|
192
215
|
lastActivity: Date.now(),
|
|
193
216
|
postControl(kind) {
|
|
194
217
|
try {
|
|
@@ -222,24 +245,6 @@ function attachChannelPort(port, options) {
|
|
|
222
245
|
function onClose() {
|
|
223
246
|
options.onPeerClosed();
|
|
224
247
|
}
|
|
225
|
-
attached.rpc = createBirpc({}, {
|
|
226
|
-
post: (data) => {
|
|
227
|
-
try {
|
|
228
|
-
port.postMessage(data);
|
|
229
|
-
} catch (error) {
|
|
230
|
-
throw wrapPostError(error);
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
on: (fn) => {
|
|
234
|
-
birpcHandler = fn;
|
|
235
|
-
},
|
|
236
|
-
off: () => {
|
|
237
|
-
birpcHandler = void 0;
|
|
238
|
-
},
|
|
239
|
-
timeout: -1,
|
|
240
|
-
proxify: false,
|
|
241
|
-
resolver: (name, resolved) => resolved ?? options.resolveLocal(name)
|
|
242
|
-
});
|
|
243
248
|
port.addEventListener("message", onMessage);
|
|
244
249
|
port.addEventListener("close", onClose);
|
|
245
250
|
port.start?.();
|
|
@@ -265,7 +270,7 @@ function withCallDeadline(promise, ms, describeTimeout) {
|
|
|
265
270
|
//#endregion
|
|
266
271
|
//#region src/in-page-channel/state.ts
|
|
267
272
|
/**
|
|
268
|
-
* The channel shared-state layer
|
|
273
|
+
* The channel shared-state layer: `createSharedState` pumped over the
|
|
269
274
|
* in-page channel, mirroring the RPC shared-state wire design with the page
|
|
270
275
|
* script playing the server's role: it owns the canonical value, replays a
|
|
271
276
|
* snapshot to every (re)subscribing panel, and fans syncId-deduplicated
|
|
@@ -290,7 +295,7 @@ function createPageScriptStateHost(peers) {
|
|
|
290
295
|
get: async (key, options) => {
|
|
291
296
|
const existing = states.get(key);
|
|
292
297
|
if (existing) return existing;
|
|
293
|
-
if (options?.initialValue === void 0) throw new InPageChannelError("state-uninitialized", `in-page shared state "${key}" was accessed before initialization
|
|
298
|
+
if (options?.initialValue === void 0) throw new InPageChannelError("state-uninitialized", `in-page shared state "${key}" was accessed before initialization; the page script is the authority, so its first \`sharedState.get("${key}")\` must provide \`initialValue\``);
|
|
294
299
|
const state = createSharedState({
|
|
295
300
|
initialValue: options.initialValue,
|
|
296
301
|
enablePatches: true
|
|
@@ -337,7 +342,7 @@ function createPanelStateHost(options) {
|
|
|
337
342
|
const seedWaiters = /* @__PURE__ */ new Map();
|
|
338
343
|
/**
|
|
339
344
|
* SyncIds of snapshot adoptions. Adopting the authority's replay must not
|
|
340
|
-
* echo straight back up as a `set
|
|
345
|
+
* echo straight back up as a `set`; the authority already has the value.
|
|
341
346
|
*/
|
|
342
347
|
const adoptedSyncIds = /* @__PURE__ */ new Set();
|
|
343
348
|
function markSeeded(key) {
|
|
@@ -381,6 +386,10 @@ function createPanelStateHost(options) {
|
|
|
381
386
|
const existing = states.get(key);
|
|
382
387
|
if (existing) return Promise.resolve(existing);
|
|
383
388
|
const state = createSharedState({
|
|
389
|
+
/**
|
|
390
|
+
* Without an initial value the state stays empty until the
|
|
391
|
+
* authority's first replay resolves the returned promise.
|
|
392
|
+
*/
|
|
384
393
|
initialValue: getOptions?.initialValue,
|
|
385
394
|
enablePatches: true
|
|
386
395
|
});
|
|
@@ -420,7 +429,7 @@ function createPanelStateHost(options) {
|
|
|
420
429
|
*
|
|
421
430
|
* It listens for panel hellos on the host page's window and answers each
|
|
422
431
|
* with a dedicated `MessageChannel` port (same-origin enforced both ways),
|
|
423
|
-
* keeping one live peer per panel
|
|
432
|
+
* keeping one live peer per panel: dock iframe, popup, and Document-PiP
|
|
424
433
|
* panels all handshake the same way, and a panel reload is simply a new
|
|
425
434
|
* handshake. No server is involved at any point.
|
|
426
435
|
*/
|
|
@@ -513,7 +522,7 @@ function createPageScriptChannel(options) {
|
|
|
513
522
|
const data = event.data;
|
|
514
523
|
if (!isHandshakeMessage(data) || data.kind !== "hello" || data.name !== name) return;
|
|
515
524
|
if (data.v !== 1) {
|
|
516
|
-
warnOnce(`in-page channel "${name}": ignoring a hello with protocol version ${data.v} (this side speaks 1)
|
|
525
|
+
warnOnce(`in-page channel "${name}": ignoring a hello with protocol version ${data.v} (this side speaks 1); align the devframe versions of the page script and the panel`);
|
|
517
526
|
return;
|
|
518
527
|
}
|
|
519
528
|
if (!allowedOrigins.includes("*") && !allowedOrigins.includes(event.origin)) {
|
|
@@ -583,7 +592,7 @@ const DEFAULT_EVENT_BUFFER_LIMIT = 64;
|
|
|
583
592
|
*
|
|
584
593
|
* The panel initiates: it posts a versioned hello to every window a
|
|
585
594
|
* same-tab page script can live in (its ancestor chain and its `opener`),
|
|
586
|
-
* retrying with backoff until one answers with a dedicated port
|
|
595
|
+
* retrying with backoff until one answers with a dedicated port, so boot
|
|
587
596
|
* order never matters, and a reload of either side is just a re-handshake
|
|
588
597
|
* (`WindowProxy` references survive navigations). While `connecting`,
|
|
589
598
|
* outgoing calls and events are buffered; when no page script exists at all
|
|
@@ -648,7 +657,7 @@ function connectPanelChannel(options) {
|
|
|
648
657
|
eventBuffer.shift();
|
|
649
658
|
if (!droppedEventsWarned) {
|
|
650
659
|
droppedEventsWarned = true;
|
|
651
|
-
console.warn(`[devframe] in-page channel "${name}": event buffer overflowed while connecting
|
|
660
|
+
console.warn(`[devframe] in-page channel "${name}": event buffer overflowed while connecting, so the oldest events are being dropped (limit ${eventBufferLimit})`);
|
|
652
661
|
}
|
|
653
662
|
}
|
|
654
663
|
eventBuffer.push({
|
|
@@ -657,7 +666,7 @@ function connectPanelChannel(options) {
|
|
|
657
666
|
});
|
|
658
667
|
}
|
|
659
668
|
function enqueueCall(method, args) {
|
|
660
|
-
if (status === "closed") return Promise.reject(new InPageChannelError("closed", `in-page channel "${name}": call "${method}" rejected
|
|
669
|
+
if (status === "closed") return Promise.reject(new InPageChannelError("closed", `in-page channel "${name}": call "${method}" rejected because the channel is closed`));
|
|
661
670
|
return withCallDeadline(new Promise((resolve, reject) => {
|
|
662
671
|
const run = () => {
|
|
663
672
|
attached.rpc.$call(method, ...args).then((result) => resolve(deserializeResult(codec, result)), reject);
|
|
@@ -667,7 +676,7 @@ function connectPanelChannel(options) {
|
|
|
667
676
|
run,
|
|
668
677
|
reject
|
|
669
678
|
});
|
|
670
|
-
}), callTimeoutMs, () => `in-page channel "${name}": call "${method}" timed out after ${callTimeoutMs}ms (status: ${status}${status === "connecting" ? "
|
|
679
|
+
}), callTimeoutMs, () => `in-page channel "${name}": call "${method}" timed out after ${callTimeoutMs}ms (status: ${status}${status === "connecting" ? "; is the page script loaded?" : ""})`);
|
|
671
680
|
}
|
|
672
681
|
function adoptPort(port, info) {
|
|
673
682
|
attached?.dispose({
|
|
@@ -712,7 +721,7 @@ function connectPanelChannel(options) {
|
|
|
712
721
|
stopTimers();
|
|
713
722
|
setStatus("connecting");
|
|
714
723
|
if (canHandshake) startHelloLoop();
|
|
715
|
-
else warnOnce(`in-page channel "${name}": transport lost (${reason}) and the panel has no handshake targets
|
|
724
|
+
else warnOnce(`in-page channel "${name}": transport lost (${reason}) and the panel has no handshake targets, so it stays disconnected`);
|
|
716
725
|
}
|
|
717
726
|
function startHelloLoop() {
|
|
718
727
|
if (helloTimer || !canHandshake || status !== "connecting") return;
|
|
@@ -739,7 +748,7 @@ function connectPanelChannel(options) {
|
|
|
739
748
|
const data = event.data;
|
|
740
749
|
if (!isHandshakeMessage(data) || data.kind !== "grant" || data.name !== name || data.panelId !== panelId) return;
|
|
741
750
|
if (data.v !== 1) {
|
|
742
|
-
warnOnce(`in-page channel "${name}": ignoring a grant with protocol version ${data.v} (this side speaks 1)
|
|
751
|
+
warnOnce(`in-page channel "${name}": ignoring a grant with protocol version ${data.v} (this side speaks 1); align the devframe versions of the page script and the panel`);
|
|
743
752
|
return;
|
|
744
753
|
}
|
|
745
754
|
if (!allowedOrigins.includes("*") && !allowedOrigins.includes(event.origin)) {
|
|
@@ -753,7 +762,7 @@ function connectPanelChannel(options) {
|
|
|
753
762
|
win?.addEventListener("message", onWindowMessage);
|
|
754
763
|
if (options.transport) adoptPort(options.transport);
|
|
755
764
|
else if (canHandshake) startHelloLoop();
|
|
756
|
-
else warnOnce(`in-page channel "${name}": the panel has no handshake targets (not embedded, no opener) and no transport
|
|
765
|
+
else warnOnce(`in-page channel "${name}": the panel has no handshake targets (not embedded, no opener) and no transport, so calls will buffer until a transport appears or the channel is closed`);
|
|
757
766
|
return {
|
|
758
767
|
name,
|
|
759
768
|
get status() {
|
|
@@ -779,7 +788,7 @@ function connectPanelChannel(options) {
|
|
|
779
788
|
const index = connectedWaiters.indexOf(waiter);
|
|
780
789
|
if (index >= 0) {
|
|
781
790
|
connectedWaiters.splice(index, 1);
|
|
782
|
-
reject(new InPageChannelError("timeout", `in-page channel "${name}": no page script answered within ${timeoutMs}ms
|
|
791
|
+
reject(new InPageChannelError("timeout", `in-page channel "${name}": no page script answered within ${timeoutMs}ms; it may not be loaded in this context (render a fallback state)`));
|
|
783
792
|
}
|
|
784
793
|
}, timeoutMs);
|
|
785
794
|
});
|
|
@@ -808,7 +817,7 @@ function connectPanelChannel(options) {
|
|
|
808
817
|
//#endregion
|
|
809
818
|
//#region src/in-page-channel/index.ts
|
|
810
819
|
/**
|
|
811
|
-
* Define one in-page channel function
|
|
820
|
+
* Define one in-page channel function, the `defineRpcFunction` authoring
|
|
812
821
|
* shape narrowed to the browser (see {@link InPageFunctionDefinition}).
|
|
813
822
|
* Pure identity: it only types the definition. Functions live in
|
|
814
823
|
* side-specific files and are passed to their endpoint via `functions`; the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as RpcFunctionType, S as RpcFunctionSetupResult, T as RpcReturnSchema, _ as RpcFunctionDefinition, i as RpcArgsSchema, v as RpcFunctionDefinitionAny, w as RpcFunctionsCollector } from "./types-
|
|
1
|
+
import { C as RpcFunctionType, S as RpcFunctionSetupResult, T as RpcReturnSchema, _ as RpcFunctionDefinition, i as RpcArgsSchema, v as RpcFunctionDefinitionAny, w as RpcFunctionsCollector } from "./types-Dq4i156u.mjs";
|
|
2
2
|
//#region src/rpc/cache.d.ts
|
|
3
3
|
interface RpcCacheOptions {
|
|
4
4
|
functions: string[];
|
|
@@ -66,7 +66,7 @@ declare function getRpcHandler<NAME extends string, TYPE extends RpcFunctionType
|
|
|
66
66
|
*
|
|
67
67
|
* birpc envelopes always start with `{`, so a leading byte that is not
|
|
68
68
|
* `s` is unambiguously JSON. Each direction independently chooses its
|
|
69
|
-
* encoding from local definitions
|
|
69
|
+
* encoding from local definitions; request and response are not
|
|
70
70
|
* coupled by a mirror rule.
|
|
71
71
|
*/
|
|
72
72
|
declare const STRUCTURED_CLONE_PREFIX = "s:";
|
|
@@ -78,16 +78,16 @@ declare const STRUCTURED_CLONE_PREFIX = "s:";
|
|
|
78
78
|
* instances, or `undefined` inside an array (silently becomes `null`).
|
|
79
79
|
*
|
|
80
80
|
* Native pass-throughs (no extra work needed):
|
|
81
|
-
* - circular references
|
|
82
|
-
* - `BigInt` at top level
|
|
81
|
+
* - circular references: `JSON.stringify` raises `TypeError`.
|
|
82
|
+
* - `BigInt` at top level: caught here for a friendlier error path.
|
|
83
83
|
*
|
|
84
84
|
* Lenient cases (allowed without throwing):
|
|
85
|
-
* - `undefined` as an object property
|
|
85
|
+
* - `undefined` as an object property: legitimate optional field;
|
|
86
86
|
* JSON.stringify just omits it.
|
|
87
|
-
* - `undefined` at the root
|
|
88
|
-
* - `Symbol` / `Function` values
|
|
87
|
+
* - `undefined` at the root: legitimate "action returned nothing".
|
|
88
|
+
* - `Symbol` / `Function` values: semantically "drop me" in JSON.
|
|
89
89
|
*
|
|
90
|
-
* `fnName` is used only for the diagnostic message
|
|
90
|
+
* `fnName` is used only for the diagnostic message; pass the RPC
|
|
91
91
|
* function name when calling from a wire serializer / dump writer so
|
|
92
92
|
* the error points at the offending function.
|
|
93
93
|
*/
|
|
@@ -110,7 +110,7 @@ declare function validateRpcArgs(name: string, argsSchema: RpcArgsSchema | undef
|
|
|
110
110
|
/**
|
|
111
111
|
* Validate a handler's resolved return value against its declared schema.
|
|
112
112
|
* Throws `DF0039` when the value fails the schema, otherwise returns the
|
|
113
|
-
* original value unchanged (guard-only, never rewriting the payload
|
|
113
|
+
* original value unchanged (guard-only, never rewriting the payload; see
|
|
114
114
|
* {@link validateRpcArgs}). Passes through when no return schema is set.
|
|
115
115
|
*
|
|
116
116
|
* @internal
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context-
|
|
2
|
-
import { n as InternalAnonymousAuthStorage } from "./context-
|
|
1
|
+
import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context-4AIVRLYF.mjs";
|
|
2
|
+
import { n as InternalAnonymousAuthStorage } from "./context-rgBSPFHS.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`
|
|
@@ -29,13 +29,13 @@ declare function getTempAuthCode(): string;
|
|
|
29
29
|
declare function refreshTempAuthCode(): string;
|
|
30
30
|
/**
|
|
31
31
|
* Build a "magic link" authentication URL that embeds a one-time code (OTP) in
|
|
32
|
-
* the URL **fragment**. Opening it authenticates the client without typing
|
|
32
|
+
* the URL **fragment**. Opening it authenticates the client without typing;
|
|
33
33
|
* print it on startup (devframe stays headless, so the host prints its own
|
|
34
34
|
* banner). Defaults to the current code; the link is subject to the same TTL.
|
|
35
35
|
*
|
|
36
36
|
* The code rides the fragment (`#devframe_otp=…`), not the query string, so it
|
|
37
37
|
* is never sent to the server, written to an access log, or leaked in a
|
|
38
|
-
* `Referer` header
|
|
38
|
+
* `Referer` header; the browser client reads it locally (see
|
|
39
39
|
* `consumeOtpFromUrl`). Any existing fragment parameters are preserved.
|
|
40
40
|
*/
|
|
41
41
|
declare function buildOtpAuthUrl(baseUrl: string, code?: string): string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { C as RpcFunctionType, T as RpcReturnSchema, _ as RpcFunctionDefinition, g as RpcFunctionAgentOptions, i as RpcArgsSchema } from "./types-
|
|
3
|
-
import {
|
|
4
|
-
import { $ as
|
|
5
|
-
import { a as RemoteAssetsStore, i as RemoteAssetsProviderCustom, n as RemoteAssetsErrorMessage, o as StaticAssetsSource, r as RemoteAssetsProvider, t as RemoteAssets } from "./remote-assets-
|
|
6
|
-
import { i as DevframeDefineDiagnosticsOptions } from "./nostics-
|
|
1
|
+
import "./index-pIVt92jP.mjs";
|
|
2
|
+
import { C as RpcFunctionType, T as RpcReturnSchema, _ as RpcFunctionDefinition, g as RpcFunctionAgentOptions, i as RpcArgsSchema } from "./types-Dq4i156u.mjs";
|
|
3
|
+
import { c as DevframeNodeRpcSessionMeta, d as DevframeRpcTransportKind, l as DevframeRpcConnection, u as DevframeRpcConnectionRequest } from "./ws-server-D2nv68Hg.mjs";
|
|
4
|
+
import { $ as DevframeServiceScopeOf, At as AgentManifest, B as DevframeSetupInfo, Bt as EventEmitter, Ct as DevframeDiagnosticsLogger, F as DevframeDefinition, Ft as AgentToolInput, G as McpAuthorization, H as DevframeSnapshotRpcInputs, Ht as EventsMap, I as DevframeDeploymentKind, It as AgentToolProvider, J as DevframeServiceDescriptor, K as McpRouteOptions, L as DevframeDockDefaults, Lt as AgentToolProviderHandle, Mt as AgentResourceContent, Nt as AgentResourceInput, P as DevframeCliOptions, Pt as AgentTool, Q as DevframeServiceOf, R as DevframeDuplicationStrategy, Rt as DevframeAgentHost, St as DevframeDiagnosticsHost, U as DevframeSseOptions, V as DevframeSnapshotRpcEntry, Vt as EventUnsubscribe, W as DevframeWsOptions, X as DevframeServiceInput, Y as DevframeServiceId, Z as DevframeServiceMeta, _t as DevframeRpcClientFunctions, a as DevframeConnectionConfigsRegistry, at as DevframeScopedNodeRpc, bt as DevframeHost, c as RpcBroadcastOptions, ct as DevframeSettingsRegistry, d as RpcSharedStateHost, dt as ScopedClientFunctions, et as DevframeServicesHost, f as RpcStreamingChannel, ft as ScopedRpcFn, gt as DevframeViewHost, ht as SettingsForNamespace, i as DevframeCapabilities, it as DevframeScopedNodeContext, jt as AgentResource, kt as AgentHandle, l as RpcFunctionsHost, lt as DevframeSettingsStore, m as RpcStreamingHost, mt as ScopedSharedStates, n as ConnectionMetaSse, nt as DevframeServicesScopeRegistry, o as DevframeNodeContext, ot as DevframeScopedStreamingHost, p as RpcStreamingChannelOptions, pt as ScopedServerFunctions, q as DevframeServiceDefinition, r as ConnectionMetaWebsocket, rt as DevframeServicesState, s as DevframeNodeRpcSession, st as DevframeSettings, t as ConnectionMeta, tt as DevframeServicesRegistry, u as RpcSharedStateGetOptions, ut as ScopedBroadcastOptions, vt as DevframeRpcServerFunctions, xt as DevframeStorageScope, yt as DevframeRpcSharedStates, z as DevframeRpcOptions, zt as DevframeAgentHostEvents } from "./context-4AIVRLYF.mjs";
|
|
5
|
+
import { a as RemoteAssetsStore, i as RemoteAssetsProviderCustom, n as RemoteAssetsErrorMessage, o as StaticAssetsSource, r as RemoteAssetsProvider, t as RemoteAssets } from "./remote-assets-eBvSKZMS.mjs";
|
|
6
|
+
import { i as DevframeDefineDiagnosticsOptions } from "./nostics-0sKe5HIj.mjs";
|
|
7
7
|
//#region src/define.d.ts
|
|
8
8
|
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>;
|
|
9
9
|
/**
|
|
10
|
-
* Identity helper that types a devframe definition
|
|
10
|
+
* Identity helper that types a devframe definition, the primary authoring
|
|
11
11
|
* entry point. Import it from the package root: `import { defineDevframe } from 'devframe'`.
|
|
12
12
|
*/
|
|
13
13
|
declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
|
|
@@ -18,4 +18,4 @@ declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
|
|
|
18
18
|
*/
|
|
19
19
|
declare function resolveClientAssets(d: DevframeDefinition): StaticAssetsSource | undefined;
|
|
20
20
|
//#endregion
|
|
21
|
-
export { type AgentHandle, type AgentManifest, type AgentResource, type AgentResourceContent, type AgentResourceInput, type AgentTool, type AgentToolInput, type AgentToolProvider, type AgentToolProviderHandle, type ConnectionMeta, type ConnectionMetaSse, type ConnectionMetaWebsocket, type DevframeAgentHost, type DevframeAgentHostEvents, type DevframeCapabilities, type DevframeCliOptions, type DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, type DevframeDefinition, type DevframeDeploymentKind, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockDefaults, type DevframeDuplicationStrategy, type DevframeHost, type DevframeNodeContext, type DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, type DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcOptions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeRpcTransportKind, type DevframeScopedNodeContext, type DevframeScopedNodeRpc, type DevframeScopedStreamingHost, type DevframeServiceDefinition, type DevframeServiceDescriptor, type DevframeServiceId, type DevframeServiceInput, type DevframeServiceMeta, type DevframeServiceOf, type DevframeServiceScopeOf, type DevframeServicesHost, type DevframeServicesRegistry, type DevframeServicesScopeRegistry, type DevframeServicesState, type DevframeSettings, type DevframeSettingsRegistry, type DevframeSettingsStore, type DevframeSetupInfo, type DevframeSnapshotRpcEntry, type DevframeSnapshotRpcInputs, type DevframeSseOptions, type DevframeStorageScope, type DevframeViewHost, type DevframeWsOptions, type EventEmitter, type EventUnsubscribe, type EventsMap, type McpRouteOptions, type RemoteAssets, type RemoteAssetsErrorMessage, type RemoteAssetsProvider, type RemoteAssetsProviderCustom, type RemoteAssetsStore, type RpcBroadcastOptions, type RpcFunctionAgentOptions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type ScopedBroadcastOptions, type ScopedClientFunctions, type ScopedRpcFn, type ScopedServerFunctions, type ScopedSharedStates, type SettingsForNamespace, type StaticAssetsSource, defineDevframe, defineRpcFunction, resolveClientAssets };
|
|
21
|
+
export { type AgentHandle, type AgentManifest, type AgentResource, type AgentResourceContent, type AgentResourceInput, type AgentTool, type AgentToolInput, type AgentToolProvider, type AgentToolProviderHandle, type ConnectionMeta, type ConnectionMetaSse, type ConnectionMetaWebsocket, type DevframeAgentHost, type DevframeAgentHostEvents, type DevframeCapabilities, type DevframeCliOptions, type DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, type DevframeDefinition, type DevframeDeploymentKind, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockDefaults, type DevframeDuplicationStrategy, type DevframeHost, type DevframeNodeContext, type DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, type DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcOptions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeRpcTransportKind, type DevframeScopedNodeContext, type DevframeScopedNodeRpc, type DevframeScopedStreamingHost, type DevframeServiceDefinition, type DevframeServiceDescriptor, type DevframeServiceId, type DevframeServiceInput, type DevframeServiceMeta, type DevframeServiceOf, type DevframeServiceScopeOf, type DevframeServicesHost, type DevframeServicesRegistry, type DevframeServicesScopeRegistry, type DevframeServicesState, type DevframeSettings, type DevframeSettingsRegistry, type DevframeSettingsStore, type DevframeSetupInfo, type DevframeSnapshotRpcEntry, type DevframeSnapshotRpcInputs, type DevframeSseOptions, type DevframeStorageScope, type DevframeViewHost, type DevframeWsOptions, type EventEmitter, type EventUnsubscribe, type EventsMap, type McpAuthorization, type McpRouteOptions, type RemoteAssets, type RemoteAssetsErrorMessage, type RemoteAssetsProvider, type RemoteAssetsProviderCustom, type RemoteAssetsStore, type RpcBroadcastOptions, type RpcFunctionAgentOptions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type ScopedBroadcastOptions, type ScopedClientFunctions, type ScopedRpcFn, type ScopedServerFunctions, type ScopedSharedStates, type SettingsForNamespace, type StaticAssetsSource, defineDevframe, defineRpcFunction, resolveClientAssets };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as createDefineWrapperWithContext } from "./define-BLWPsH6y.mjs";
|
|
2
|
-
import { t as resolveClientAssets$1 } from "./client-assets-
|
|
2
|
+
import { t as resolveClientAssets$1 } from "./client-assets-DNdhagGm.mjs";
|
|
3
3
|
//#region src/define.ts
|
|
4
4
|
const defineRpcFunction = createDefineWrapperWithContext();
|
|
5
5
|
/**
|
|
6
|
-
* Identity helper that types a devframe definition
|
|
6
|
+
* Identity helper that types a devframe definition, the primary authoring
|
|
7
7
|
* entry point. Import it from the package root: `import { defineDevframe } from 'devframe'`.
|
|
8
8
|
*/
|
|
9
9
|
function defineDevframe(d) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
|
|
2
|
-
import { t as diagnostics } from "./diagnostics-
|
|
2
|
+
import { t as diagnostics } from "./diagnostics-BMfN8mb1.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { join } from "pathe";
|
|
5
5
|
import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -16,9 +16,9 @@ const DEVFRAME_INSTANCES_DIR_ENV = "DEVFRAME_INSTANCES_DIR";
|
|
|
16
16
|
/** Environment variable disabling instance registration entirely. */
|
|
17
17
|
const DEVFRAME_DISABLE_INSTANCE_REGISTRY_ENV = "DEVFRAME_DISABLE_INSTANCE_REGISTRY";
|
|
18
18
|
/**
|
|
19
|
-
* Resolve the registry directory: `~/.devframe/instances/` by default
|
|
20
|
-
* the framework's own global dir, deliberately outside the per-app
|
|
21
|
-
* `~/.<appName>/devframe/` storage convention since the registry spans apps
|
|
19
|
+
* Resolve the registry directory: `~/.devframe/instances/` by default
|
|
20
|
+
* (the framework's own global dir, deliberately outside the per-app
|
|
21
|
+
* `~/.<appName>/devframe/` storage convention since the registry spans apps),
|
|
22
22
|
* overridable via `DEVFRAME_INSTANCES_DIR`.
|
|
23
23
|
*/
|
|
24
24
|
function resolveInstancesDir(override) {
|
|
@@ -40,7 +40,7 @@ function isRegistryDisabled() {
|
|
|
40
40
|
* The record is written atomically to `<dir>/<pid>-<port>.json` and removed
|
|
41
41
|
* by {@link DevframeInstanceRegistration.unregister}. Records surviving a
|
|
42
42
|
* crash are pruned by readers whose liveness probe fails. Registration never
|
|
43
|
-
* throws
|
|
43
|
+
* throws; a write failure degrades to a coded warning (`DF0045`), since a
|
|
44
44
|
* dev server must not die over discovery metadata.
|
|
45
45
|
*/
|
|
46
46
|
function registerDevframeInstance(record, options = {}) {
|
|
@@ -75,7 +75,7 @@ function registerDevframeInstance(record, options = {}) {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Read every record in the registry directory, dropping unparseable files.
|
|
78
|
-
* Liveness is the caller's concern
|
|
78
|
+
* Liveness is the caller's concern; see {@link probeDevframeInstance}.
|
|
79
79
|
*/
|
|
80
80
|
function readDevframeInstances(options = {}) {
|
|
81
81
|
const dir = resolveInstancesDir(options.instancesDir);
|
|
@@ -94,8 +94,8 @@ function readDevframeInstances(options = {}) {
|
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* Dialable-origin candidates for a recorded origin. A `localhost` bind is
|
|
97
|
-
* ambiguous
|
|
98
|
-
* HTTP clients differ in which family they try
|
|
97
|
+
* ambiguous: the server may listen on `127.0.0.1`, `::1`, or both, and
|
|
98
|
+
* HTTP clients differ in which family they try, so probe the explicit
|
|
99
99
|
* addresses too and adopt whichever answers.
|
|
100
100
|
*/
|
|
101
101
|
function originCandidates(origin) {
|