devframe 0.9.1 → 0.9.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.
- package/dist/{_shared-DqbKCAew.d.mts → _shared-BAGBgTUO.d.mts} +1 -1
- package/dist/adapters/build.d.mts +1 -1
- package/dist/adapters/build.mjs +9 -8
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +1 -1
- package/dist/adapters/dev.d.mts +3 -3
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/embedded.mjs +2 -1
- package/dist/adapters/initiate.d.mts +2 -2
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.mjs +1 -1
- package/dist/cli/main.mjs +2 -2
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.mjs +2 -2
- package/dist/{context-CXhjygJU.mjs → context-af2w_F0_.mjs} +1 -1
- package/dist/{context-dqyXS6o3.d.mts → context-al99DDJ8.d.mts} +1 -1
- package/dist/{context-Bdkakk8S.mjs → context-riPPHGiu.mjs} +34 -19
- package/dist/{dev-C8VHtuPP.mjs → dev-BKm_HisC.mjs} +10 -9
- package/dist/{devframe-BlLEZR-x.d.mts → devframe-mbfgpQQC.d.mts} +55 -21
- package/dist/{diagnostics-Di8ytitn.mjs → diagnostics-DI1HGj2I.mjs} +0 -4
- package/dist/hash-DdPnc4k3.mjs +360 -0
- package/dist/{host-agent-BDdcOXhG.mjs → host-agent-DVDLqjvj.mjs} +1 -1
- package/dist/{http-BbHCU5Zs.mjs → http-POepPnaQ.mjs} +6 -5
- package/dist/{index-BKFT9-jA.d.mts → index-Dipgo9ji.d.mts} +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/{instance-registry-CHunhMi5.mjs → instance-registry-Dy28drtm.mjs} +1 -1
- package/dist/{instance-shell-DbDoozNM.mjs → instance-shell-GqTY93gC.mjs} +4 -4
- package/dist/{instance-shell-0iw-cQ5V.d.mts → instance-shell-mU5j5xWn.d.mts} +2 -2
- package/dist/internal/index.d.mts +4 -10
- package/dist/internal/index.mjs +5 -5
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/hub-internals.mjs +1 -1
- package/dist/node/index.d.mts +10 -1
- package/dist/node/index.mjs +2 -2
- package/dist/recipes/common-rpc-functions.d.mts +11 -1
- package/dist/recipes/common-rpc-functions.mjs +10 -0
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/recipes/interactive-auth.mjs +1 -1
- package/dist/{remote-assets-DRfY2RjX.mjs → remote-assets-CqxiyltC.mjs} +13 -3
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.mjs +1 -1
- package/dist/rpc/transports/ws-bun.d.mts +1 -1
- package/dist/rpc/transports/ws-deno.d.mts +26 -0
- package/dist/rpc/transports/ws-deno.mjs +30 -0
- package/dist/{rpc-core-Dru9uoM0.mjs → rpc-core-DRYnbxdD.mjs} +3 -10
- package/dist/{rpc-core-CR8o34O9.d.mts → rpc-core-dV69u4lY.d.mts} +2 -2
- package/dist/{shared-state-fRRbRUtD.mjs → shared-state-DoXutg_U.mjs} +1 -1
- package/dist/{static-BPZ1_OPA.mjs → static-DV_qUSRS.mjs} +1 -1
- package/dist/{storage-D4a99Ung.mjs → storage-BNqSAOxA.mjs} +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/hash.mjs +1 -1
- package/dist/utils/remote-assets.d.mts +7 -1
- package/dist/utils/remote-assets.mjs +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/shared-state.mjs +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/validation-YrZH6atx.mjs +311 -0
- package/package.json +4 -3
- package/skills/devframe/SKILL.md +1 -1
- package/dist/hash-KtDZYXDN.mjs +0 -266
- package/dist/validation-CpXFB6Dz.mjs +0 -266
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as diagnostics } from "./diagnostics-
|
|
1
|
+
import { t as diagnostics } from "./diagnostics-DI1HGj2I.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { isatty } from "node:tty";
|
|
4
4
|
import { formatWithOptions, inspect } from "node:util";
|
|
@@ -627,11 +627,21 @@ function assertValidRemoteAssets(assets) {
|
|
|
627
627
|
*
|
|
628
628
|
* A remote source's `package`/`version` are validated first (`DF0065`) — both
|
|
629
629
|
* are interpolated into CDN URLs and the cache path.
|
|
630
|
+
*
|
|
631
|
+
* `defaultResolveFrom` (typically the declaring devframe's `importMetaUrl`)
|
|
632
|
+
* supplies a `resolveFrom` base for a remote source that doesn't set one:
|
|
633
|
+
* it is applied only when `source.resolveFrom` is `undefined`, so an explicit
|
|
634
|
+
* per-source string still wins and an explicit `null` still opts out of the
|
|
635
|
+
* installed-copy lookup.
|
|
630
636
|
*/
|
|
631
|
-
function resolveStaticAssetsSource(source, projectStorageDir) {
|
|
637
|
+
function resolveStaticAssetsSource(source, projectStorageDir, defaultResolveFrom) {
|
|
632
638
|
if (typeof source === "string") return source;
|
|
633
639
|
assertValidRemoteAssets(source);
|
|
634
|
-
|
|
640
|
+
const resolved = source.resolveFrom === void 0 && defaultResolveFrom != null ? {
|
|
641
|
+
...source,
|
|
642
|
+
resolveFrom: defaultResolveFrom
|
|
643
|
+
} : source;
|
|
644
|
+
return resolveInstalled(resolved) ?? createStore(resolved, join(projectStorageDir, ".remote-assets", `${resolved.package.replace(/\//g, "+")}@${resolved.version}`));
|
|
635
645
|
}
|
|
636
646
|
//#endregion
|
|
637
647
|
export { createDebug as n, resolveStaticAssetsSource as t };
|
package/dist/rpc/dump.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as reviveDumpError, i as getDefinitionsWithDumps, n as createClientFromDump, o as serializeDumpError, r as dumpFunctions, t as collectStaticRpcDump } from "../static-
|
|
1
|
+
import { a as reviveDumpError, i as getDefinitionsWithDumps, n as createClientFromDump, o as serializeDumpError, r as dumpFunctions, t as collectStaticRpcDump } from "../static-DV_qUSRS.mjs";
|
|
2
2
|
export { collectStaticRpcDump, createClientFromDump, dumpFunctions, getDefinitionsWithDumps, reviveDumpError, serializeDumpError };
|
package/dist/rpc/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as validateRpcArgs, i as getRpcResolvedSetupResult, n as validateDefinitions, o as validateRpcReturn, r as getRpcHandler, s as hash, t as validateDefinition } from "../validation-
|
|
1
|
+
import { a as validateRpcArgs, i as getRpcResolvedSetupResult, n as validateDefinitions, o as validateRpcReturn, r as getRpcHandler, s as hash, t as validateDefinition } from "../validation-YrZH6atx.mjs";
|
|
2
2
|
import { t as diagnostics } from "../diagnostics-CD8nlgll.mjs";
|
|
3
3
|
import { n as defineRpcFunction, t as createDefineWrapperWithContext } from "../define-BLWPsH6y.mjs";
|
|
4
4
|
import { n as strictJsonStringify, t as STRUCTURED_CLONE_PREFIX } from "../serialization-BGzEwAdr.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as WsOriginRegistry } from "../../ws-server-D1d3QM9f.mjs";
|
|
2
|
-
import { t as ContextRpcServer } from "../../rpc-core-
|
|
2
|
+
import { t as ContextRpcServer } from "../../rpc-core-dV69u4lY.mjs";
|
|
3
3
|
//#region src/rpc/transports/ws-bun.d.ts
|
|
4
4
|
interface AttachBunWsTransportOptions {
|
|
5
5
|
/** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { n as WsOriginRegistry } from "../../ws-server-D1d3QM9f.mjs";
|
|
2
|
+
import { t as ContextRpcServer } from "../../rpc-core-dV69u4lY.mjs";
|
|
3
|
+
//#region src/rpc/transports/ws-deno.d.ts
|
|
4
|
+
interface AttachDenoWsTransportOptions {
|
|
5
|
+
/** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
|
|
6
|
+
allowedOrigins?: readonly string[] | WsOriginRegistry | false;
|
|
7
|
+
}
|
|
8
|
+
interface DenoWsTier {
|
|
9
|
+
/**
|
|
10
|
+
* Complete a WS upgrade request — `Deno.serve`'s handler info as the 2nd
|
|
11
|
+
* argument. Unlike Bun, Deno's adapter attaches the socket to the returned
|
|
12
|
+
* `Response` itself, so there is no `websocket` handler object to register.
|
|
13
|
+
*/
|
|
14
|
+
handleUpgrade: (request: Request, info: unknown) => Promise<Response>;
|
|
15
|
+
close: () => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The Deno fetch-upgrade WebSocket tier for `initDevframe` / `initHub` — the
|
|
19
|
+
* same RPC peer wiring as `attachWsRpcTransport`, driven by crossws's Deno
|
|
20
|
+
* adapter so upgrades complete through `handleUpgrade(request, info)` on the
|
|
21
|
+
* app's own origin, with no side-car server. Load it dynamically so the Deno
|
|
22
|
+
* adapter never enters a Node-only bundle path.
|
|
23
|
+
*/
|
|
24
|
+
declare function attachDenoWsTransport(core: ContextRpcServer, options?: AttachDenoWsTransportOptions): Promise<DenoWsTier>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AttachDenoWsTransportOptions, DenoWsTier, attachDenoWsTransport };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { i as isAllowedOrigin, r as createWsRpcPeerHooks } from "../../ws-server-BdSLrhxE.mjs";
|
|
2
|
+
//#region src/rpc/transports/ws-deno.ts
|
|
3
|
+
/**
|
|
4
|
+
* The Deno fetch-upgrade WebSocket tier for `initDevframe` / `initHub` — the
|
|
5
|
+
* same RPC peer wiring as `attachWsRpcTransport`, driven by crossws's Deno
|
|
6
|
+
* adapter so upgrades complete through `handleUpgrade(request, info)` on the
|
|
7
|
+
* app's own origin, with no side-car server. Load it dynamically so the Deno
|
|
8
|
+
* adapter never enters a Node-only bundle path.
|
|
9
|
+
*/
|
|
10
|
+
async function attachDenoWsTransport(core, options = {}) {
|
|
11
|
+
const { default: denoAdapter } = await import("crossws/adapters/deno");
|
|
12
|
+
const { allowedOrigins } = options;
|
|
13
|
+
const ws = denoAdapter({ hooks: {
|
|
14
|
+
...createWsRpcPeerHooks(core.rpcGroup, {
|
|
15
|
+
onConnected: core.onConnected,
|
|
16
|
+
onDisconnected: core.onDisconnected
|
|
17
|
+
}),
|
|
18
|
+
upgrade(request) {
|
|
19
|
+
const origin = request.headers.get("origin") ?? void 0;
|
|
20
|
+
const allowed = allowedOrigins && !Array.isArray(allowedOrigins) ? allowedOrigins.isAllowed(origin) : isAllowedOrigin(origin, allowedOrigins || []);
|
|
21
|
+
if (allowedOrigins !== false && !allowed) return new Response("Forbidden", { status: 403 });
|
|
22
|
+
}
|
|
23
|
+
} });
|
|
24
|
+
return {
|
|
25
|
+
handleUpgrade: (request, info) => ws.handleUpgrade(request, info),
|
|
26
|
+
close: () => ws.close()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { attachDenoWsTransport };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
|
|
2
2
|
import { createRpcServer } from "./rpc/server.mjs";
|
|
3
|
-
import { t as diagnostics } from "./diagnostics-
|
|
3
|
+
import { t as diagnostics } from "./diagnostics-DI1HGj2I.mjs";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
//#region src/node/rpc-core.ts
|
|
6
6
|
var rpc_core_exports = /* @__PURE__ */ __exportAll({ createContextRpcServer: () => createContextRpcServer });
|
|
@@ -58,21 +58,14 @@ function createContextRpcServer(options) {
|
|
|
58
58
|
return { isTrusted: true };
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
const onConnected = (connection, meta) => {
|
|
62
|
-
Promise.resolve().then(() => context.services.ready?.()).catch((error) => {
|
|
63
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
64
|
-
diagnostics.DF0071({
|
|
65
|
-
reason,
|
|
66
|
-
cause: error
|
|
67
|
-
}, { method: "error" });
|
|
68
|
-
});
|
|
61
|
+
const onConnected = authHandler || options.onPeerConnect ? (connection, meta) => {
|
|
69
62
|
const session = {
|
|
70
63
|
meta,
|
|
71
64
|
rpc: rpcGroup.clients.find((client) => client.$meta === meta)
|
|
72
65
|
};
|
|
73
66
|
authHandler?.onConnect(connection, session);
|
|
74
67
|
options.onPeerConnect?.(connection, session);
|
|
75
|
-
};
|
|
68
|
+
} : void 0;
|
|
76
69
|
const onDisconnected = (connection, meta) => {
|
|
77
70
|
options.onPeerDisconnect?.(connection, meta);
|
|
78
71
|
rpcHost._emitSessionDisconnected(meta);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as DevframeRpcServerFunctions, T as DevframeRpcClientFunctions, _ as DevframeNodeRpcSession, g as DevframeNodeContext, u as DevframeAuthHandler } from "./devframe-
|
|
1
|
+
import { E as DevframeRpcServerFunctions, T as DevframeRpcClientFunctions, _ as DevframeNodeRpcSession, g as DevframeNodeContext, u as DevframeAuthHandler } from "./devframe-mbfgpQQC.mjs";
|
|
2
2
|
import { d as DevframeRpcConnection, u as DevframeNodeRpcSessionMeta } from "./ws-server-D1d3QM9f.mjs";
|
|
3
|
-
import "./index-
|
|
3
|
+
import "./index-Dipgo9ji.mjs";
|
|
4
4
|
import { BirpcGroup, EventOptions } from "birpc";
|
|
5
5
|
//#region src/node/rpc-core.d.ts
|
|
6
6
|
interface CreateContextRpcServerOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createEventEmitter } from "./utils/events.mjs";
|
|
2
2
|
import { nanoid } from "./utils/nanoid.mjs";
|
|
3
|
-
//#region ../../node_modules/.pnpm/immer@11.1.
|
|
3
|
+
//#region ../../node_modules/.pnpm/immer@11.1.17/node_modules/immer/dist/immer.mjs
|
|
4
4
|
var NOTHING = Symbol.for("immer-nothing");
|
|
5
5
|
var DRAFTABLE = Symbol.for("immer-draftable");
|
|
6
6
|
var DRAFT_STATE = Symbol.for("immer-state");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as validateDefinitions, r as getRpcHandler, s as hash } from "./validation-
|
|
1
|
+
import { n as validateDefinitions, r as getRpcHandler, s as hash } from "./validation-YrZH6atx.mjs";
|
|
2
2
|
import { t as diagnostics } from "./diagnostics-CD8nlgll.mjs";
|
|
3
3
|
import { DEVFRAME_RPC_DUMP_DIRNAME } from "./constants.mjs";
|
|
4
4
|
//#region ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as DevframeStorageScope, A as DevframeServiceId, At as DevframeAgentHost, B as DevframeScopedNodeRpc, C as RpcStreamingChannelOptions, Ct as AgentResource, D as DevframeRpcSharedStates, Dt as AgentToolInput, E as DevframeRpcServerFunctions, Et as AgentTool, F as DevframeServicesHost, G as ScopedBroadcastOptions, H as DevframeSettings, I as DevframeServicesRegistry, J as ScopedServerFunctions, K as ScopedClientFunctions, L as DevframeServicesScopeRegistry, M as DevframeServiceMeta, Mt as EventEmitter, N as DevframeServiceOf, Nt as EventUnsubscribe, O as DevframeServiceDefinition, Ot as AgentToolProvider, P as DevframeServiceScopeOf, Pt as EventsMap, Q as DevframeHost, R as DevframeServicesState, S as RpcStreamingChannel, St as AgentManifest, T as DevframeRpcClientFunctions, Tt as AgentResourceInput, U as DevframeSettingsRegistry, V as DevframeScopedStreamingHost, W as DevframeSettingsStore, X as SettingsForNamespace, Y as ScopedSharedStates, Z as DevframeViewHost, _ as DevframeNodeRpcSession, a as DevframeDuplicationStrategy, b as RpcSharedStateGetOptions, c as DevframeWsOptions, d as ConnectionMeta, et as DevframeDiagnosticsHost, f as ConnectionMetaSse, g as DevframeNodeContext, h as DevframeConnectionConfigsRegistry, i as DevframeDockDefaults, j as DevframeServiceInput, jt as DevframeAgentHostEvents, k as DevframeServiceDescriptor, kt as AgentToolProviderHandle, l as McpRouteOptions, m as DevframeCapabilities, n as DevframeDefinition, o as DevframeSetupInfo, p as ConnectionMetaWebsocket, q as ScopedRpcFn, r as DevframeDeploymentKind, s as DevframeSseOptions, t as DevframeCliOptions, tt as DevframeDiagnosticsLogger, v as RpcBroadcastOptions, w as RpcStreamingHost, wt as AgentResourceContent, x as RpcSharedStateHost, xt as AgentHandle, y as RpcFunctionsHost, z as DevframeScopedNodeContext } from "../devframe-
|
|
1
|
+
import { $ as DevframeStorageScope, A as DevframeServiceId, At as DevframeAgentHost, B as DevframeScopedNodeRpc, C as RpcStreamingChannelOptions, Ct as AgentResource, D as DevframeRpcSharedStates, Dt as AgentToolInput, E as DevframeRpcServerFunctions, Et as AgentTool, F as DevframeServicesHost, G as ScopedBroadcastOptions, H as DevframeSettings, I as DevframeServicesRegistry, J as ScopedServerFunctions, K as ScopedClientFunctions, L as DevframeServicesScopeRegistry, M as DevframeServiceMeta, Mt as EventEmitter, N as DevframeServiceOf, Nt as EventUnsubscribe, O as DevframeServiceDefinition, Ot as AgentToolProvider, P as DevframeServiceScopeOf, Pt as EventsMap, Q as DevframeHost, R as DevframeServicesState, S as RpcStreamingChannel, St as AgentManifest, T as DevframeRpcClientFunctions, Tt as AgentResourceInput, U as DevframeSettingsRegistry, V as DevframeScopedStreamingHost, W as DevframeSettingsStore, X as SettingsForNamespace, Y as ScopedSharedStates, Z as DevframeViewHost, _ as DevframeNodeRpcSession, a as DevframeDuplicationStrategy, b as RpcSharedStateGetOptions, c as DevframeWsOptions, d as ConnectionMeta, et as DevframeDiagnosticsHost, f as ConnectionMetaSse, g as DevframeNodeContext, h as DevframeConnectionConfigsRegistry, i as DevframeDockDefaults, j as DevframeServiceInput, jt as DevframeAgentHostEvents, k as DevframeServiceDescriptor, kt as AgentToolProviderHandle, l as McpRouteOptions, m as DevframeCapabilities, n as DevframeDefinition, o as DevframeSetupInfo, p as ConnectionMetaWebsocket, q as ScopedRpcFn, r as DevframeDeploymentKind, s as DevframeSseOptions, t as DevframeCliOptions, tt as DevframeDiagnosticsLogger, v as RpcBroadcastOptions, w as RpcStreamingHost, wt as AgentResourceContent, x as RpcSharedStateHost, xt as AgentHandle, y as RpcFunctionsHost, z as DevframeScopedNodeContext } from "../devframe-mbfgpQQC.mjs";
|
|
2
2
|
import { g as RpcFunctionAgentOptions } from "../types-Djq7CBXh.mjs";
|
|
3
3
|
import { d as DevframeRpcConnection, f as DevframeRpcConnectionRequest, p as DevframeRpcTransportKind, u as DevframeNodeRpcSessionMeta } from "../ws-server-D1d3QM9f.mjs";
|
|
4
4
|
import { i as DevframeDefineDiagnosticsOptions } from "../nostics-SPGDgHEP.mjs";
|
package/dist/utils/events.d.mts
CHANGED
package/dist/utils/hash.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as hash } from "../hash-
|
|
1
|
+
import { t as hash } from "../hash-DdPnc4k3.mjs";
|
|
2
2
|
export { hash };
|
|
@@ -9,7 +9,13 @@ import { a as RemoteAssetsStore, o as StaticAssetsSource } from "../remote-asset
|
|
|
9
9
|
*
|
|
10
10
|
* A remote source's `package`/`version` are validated first (`DF0065`) — both
|
|
11
11
|
* are interpolated into CDN URLs and the cache path.
|
|
12
|
+
*
|
|
13
|
+
* `defaultResolveFrom` (typically the declaring devframe's `importMetaUrl`)
|
|
14
|
+
* supplies a `resolveFrom` base for a remote source that doesn't set one:
|
|
15
|
+
* it is applied only when `source.resolveFrom` is `undefined`, so an explicit
|
|
16
|
+
* per-source string still wins and an explicit `null` still opts out of the
|
|
17
|
+
* installed-copy lookup.
|
|
12
18
|
*/
|
|
13
|
-
declare function resolveStaticAssetsSource(source: StaticAssetsSource, projectStorageDir: string): string | RemoteAssetsStore;
|
|
19
|
+
declare function resolveStaticAssetsSource(source: StaticAssetsSource, projectStorageDir: string, defaultResolveFrom?: string | null): string | RemoteAssetsStore;
|
|
14
20
|
//#endregion
|
|
15
21
|
export { resolveStaticAssetsSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as resolveStaticAssetsSource } from "../remote-assets-
|
|
1
|
+
import { t as resolveStaticAssetsSource } from "../remote-assets-CqxiyltC.mjs";
|
|
2
2
|
export { resolveStaticAssetsSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _t as SharedStateEvents, bt as createSharedState, dt as Immutable, ft as ImmutableArray, gt as SharedState, ht as ImmutableSet, mt as ImmutableObject, pt as ImmutableMap, vt as SharedStateOptions, yt as SharedStatePatch } from "../devframe-
|
|
1
|
+
import { _t as SharedStateEvents, bt as createSharedState, dt as Immutable, ft as ImmutableArray, gt as SharedState, ht as ImmutableSet, mt as ImmutableObject, pt as ImmutableMap, vt as SharedStateOptions, yt as SharedStatePatch } from "../devframe-mbfgpQQC.mjs";
|
|
2
2
|
export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createSharedState } from "../shared-state-
|
|
1
|
+
import { t as createSharedState } from "../shared-state-DoXutg_U.mjs";
|
|
2
2
|
export { createSharedState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { at as StreamErrorPayload, ct as StreamSinkEvents, it as CreateStreamSinkOptions, lt as createStreamReader, nt as BufferedChunk, ot as StreamReader, rt as CreateStreamReaderOptions, st as StreamSink, ut as createStreamSink } from "../devframe-
|
|
1
|
+
import { at as StreamErrorPayload, ct as StreamSinkEvents, it as CreateStreamSinkOptions, lt as createStreamReader, nt as BufferedChunk, ot as StreamReader, rt as CreateStreamReaderOptions, st as StreamSink, ut as createStreamSink } from "../devframe-mbfgpQQC.mjs";
|
|
2
2
|
export { BufferedChunk, CreateStreamReaderOptions, CreateStreamSinkOptions, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, createStreamReader, createStreamSink };
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { t as diagnostics } from "./diagnostics-CD8nlgll.mjs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
//#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/_chunks/is-equal.mjs
|
|
4
|
+
function serialize(input) {
|
|
5
|
+
if (typeof input === "string") return `'${input}'`;
|
|
6
|
+
return new Serializer().serialize(input);
|
|
7
|
+
}
|
|
8
|
+
const asciiOrder = " _-,;:!?.'\"()[]{}@*/\\&#%`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz";
|
|
9
|
+
const asciiWeights = /*@__PURE__*/ (function() {
|
|
10
|
+
const weights = /* @__PURE__ */ new Uint8Array(128);
|
|
11
|
+
for (let i = 0; i < 69; i++) weights[asciiOrder.charCodeAt(i)] = i + 1;
|
|
12
|
+
for (let code = 65; code <= 90; code++) weights[code] = weights[code + 32];
|
|
13
|
+
return weights;
|
|
14
|
+
})();
|
|
15
|
+
function compareStrings(a, b) {
|
|
16
|
+
if (a === b) return 0;
|
|
17
|
+
const length = Math.min(a.length, b.length);
|
|
18
|
+
let tieBreaker = 0;
|
|
19
|
+
for (let i = 0; i < length; i++) {
|
|
20
|
+
const codeA = a.charCodeAt(i);
|
|
21
|
+
const codeB = b.charCodeAt(i);
|
|
22
|
+
if (codeA === codeB) continue;
|
|
23
|
+
const weightA = codeA < 128 && asciiWeights[codeA] ? asciiWeights[codeA] : codeA + 128;
|
|
24
|
+
const weightB = codeB < 128 && asciiWeights[codeB] ? asciiWeights[codeB] : codeB + 128;
|
|
25
|
+
if (weightA !== weightB) return weightA < weightB ? -1 : 1;
|
|
26
|
+
if (tieBreaker === 0) tieBreaker = codeA > codeB ? -1 : 1;
|
|
27
|
+
}
|
|
28
|
+
if (a.length !== b.length) return a.length < b.length ? -1 : 1;
|
|
29
|
+
return tieBreaker;
|
|
30
|
+
}
|
|
31
|
+
const Serializer = /*@__PURE__*/ (function() {
|
|
32
|
+
class Serializer {
|
|
33
|
+
#context = /* @__PURE__ */ new Map();
|
|
34
|
+
compare(a, b) {
|
|
35
|
+
const typeA = typeof a;
|
|
36
|
+
const typeB = typeof b;
|
|
37
|
+
if (typeA === "string" && typeB === "string") return compareStrings(a, b);
|
|
38
|
+
if (typeA === "number" && typeB === "number") return a - b;
|
|
39
|
+
return compareStrings(this.serialize(a, true), this.serialize(b, true));
|
|
40
|
+
}
|
|
41
|
+
serialize(value, noQuotes) {
|
|
42
|
+
if (value === null) return "null";
|
|
43
|
+
switch (typeof value) {
|
|
44
|
+
case "string": return noQuotes ? value : `'${value}'`;
|
|
45
|
+
case "bigint": return `${value}n`;
|
|
46
|
+
case "object": return this.$object(value);
|
|
47
|
+
case "function": return this.$function(value);
|
|
48
|
+
}
|
|
49
|
+
return String(value);
|
|
50
|
+
}
|
|
51
|
+
serializeObject(object) {
|
|
52
|
+
const objString = Object.prototype.toString.call(object);
|
|
53
|
+
if (objString !== "[object Object]") return this.serializeBuiltInType(objString.length < 10 ? `unknown:${objString}` : objString.slice(8, -1), object);
|
|
54
|
+
const constructor = object.constructor;
|
|
55
|
+
const objName = constructor === Object || constructor === void 0 ? "" : constructor.name;
|
|
56
|
+
if (objName !== "" && globalThis[objName] === constructor) return this.serializeBuiltInType(objName, object);
|
|
57
|
+
if ("toJSON" in object && typeof object.toJSON === "function") {
|
|
58
|
+
const json = object.toJSON();
|
|
59
|
+
return objName + (json !== null && typeof json === "object" ? this.$object(json) : `(${this.serialize(json)})`);
|
|
60
|
+
}
|
|
61
|
+
const keys = Object.keys(object).sort(compareStrings);
|
|
62
|
+
let content = `${objName}{`;
|
|
63
|
+
for (let i = 0; i < keys.length; i++) {
|
|
64
|
+
const key = keys[i];
|
|
65
|
+
content += `${key}:${this.serialize(object[key])}`;
|
|
66
|
+
if (i < keys.length - 1) content += ",";
|
|
67
|
+
}
|
|
68
|
+
return content + "}";
|
|
69
|
+
}
|
|
70
|
+
serializeBuiltInType(type, object) {
|
|
71
|
+
const handler = this["$" + type];
|
|
72
|
+
if (handler) return handler.call(this, object);
|
|
73
|
+
if (typeof object.entries === "function") return this.serializeObjectEntries(type, object.entries());
|
|
74
|
+
throw new Error(`Cannot serialize ${type}`);
|
|
75
|
+
}
|
|
76
|
+
serializeObjectEntries(type, entries) {
|
|
77
|
+
const sortedEntries = Array.from(entries).sort((a, b) => this.compare(a[0], b[0]));
|
|
78
|
+
let content = `${type}{`;
|
|
79
|
+
for (let i = 0; i < sortedEntries.length; i++) {
|
|
80
|
+
const [key, value] = sortedEntries[i];
|
|
81
|
+
content += `${this.serialize(key, true)}:${this.serialize(value)}`;
|
|
82
|
+
if (i < sortedEntries.length - 1) content += ",";
|
|
83
|
+
}
|
|
84
|
+
return content + "}";
|
|
85
|
+
}
|
|
86
|
+
$object(object) {
|
|
87
|
+
let content = this.#context.get(object);
|
|
88
|
+
if (content === void 0) {
|
|
89
|
+
this.#context.set(object, `#${this.#context.size}`);
|
|
90
|
+
content = this.serializeObject(object);
|
|
91
|
+
this.#context.set(object, content);
|
|
92
|
+
}
|
|
93
|
+
return content;
|
|
94
|
+
}
|
|
95
|
+
$function(fn) {
|
|
96
|
+
const fnStr = Function.prototype.toString.call(fn);
|
|
97
|
+
if (fnStr.slice(-15) === "[native code] }") return `${fn.name || ""}()[native]`;
|
|
98
|
+
return `${fn.name}(${fn.length})${fnStr.replace(/\s*\n\s*/g, "")}`;
|
|
99
|
+
}
|
|
100
|
+
$Array(arr) {
|
|
101
|
+
let content = "[";
|
|
102
|
+
for (let i = 0; i < arr.length; i++) {
|
|
103
|
+
content += this.serialize(arr[i]);
|
|
104
|
+
if (i < arr.length - 1) content += ",";
|
|
105
|
+
}
|
|
106
|
+
return content + "]";
|
|
107
|
+
}
|
|
108
|
+
$Date(date) {
|
|
109
|
+
try {
|
|
110
|
+
return `Date(${date.toISOString()})`;
|
|
111
|
+
} catch {
|
|
112
|
+
return `Date(null)`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
$ArrayBuffer(arr) {
|
|
116
|
+
return `ArrayBuffer[${new Uint8Array(arr).join(",")}]`;
|
|
117
|
+
}
|
|
118
|
+
$Set(set) {
|
|
119
|
+
return `Set${this.$Array(Array.from(set).sort((a, b) => this.compare(a, b)))}`;
|
|
120
|
+
}
|
|
121
|
+
$Map(map) {
|
|
122
|
+
return this.serializeObjectEntries("Map", map.entries());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const type of [
|
|
126
|
+
"Error",
|
|
127
|
+
"RegExp",
|
|
128
|
+
"URL"
|
|
129
|
+
]) Serializer.prototype["$" + type] = function(val) {
|
|
130
|
+
return `${type}(${val})`;
|
|
131
|
+
};
|
|
132
|
+
for (const type of [
|
|
133
|
+
"Int8Array",
|
|
134
|
+
"Uint8Array",
|
|
135
|
+
"Uint8ClampedArray",
|
|
136
|
+
"Int16Array",
|
|
137
|
+
"Uint16Array",
|
|
138
|
+
"Int32Array",
|
|
139
|
+
"Uint32Array",
|
|
140
|
+
"Float32Array",
|
|
141
|
+
"Float64Array"
|
|
142
|
+
]) Serializer.prototype["$" + type] = function(arr) {
|
|
143
|
+
return `${type}[${arr.join(",")}]`;
|
|
144
|
+
};
|
|
145
|
+
for (const type of ["BigInt64Array", "BigUint64Array"]) Serializer.prototype["$" + type] = function(arr) {
|
|
146
|
+
return `${type}[${arr.join("n,")}${arr.length > 0 ? "n" : ""}]`;
|
|
147
|
+
};
|
|
148
|
+
return Serializer;
|
|
149
|
+
})();
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/crypto/node/index.mjs
|
|
152
|
+
const fastHash = /*@__PURE__*/ (() => globalThis.process?.getBuiltinModule?.("crypto")?.hash)();
|
|
153
|
+
const algorithm = "sha256";
|
|
154
|
+
const encoding = "base64url";
|
|
155
|
+
function digest(data) {
|
|
156
|
+
if (fastHash) return fastHash(algorithm, data, encoding);
|
|
157
|
+
const h = createHash(algorithm).update(data);
|
|
158
|
+
return globalThis.process?.versions?.webcontainer ? h.digest().toString(encoding) : h.digest(encoding);
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/index.mjs
|
|
162
|
+
function hash$1(input) {
|
|
163
|
+
return digest(serialize(input));
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/utils/hash.ts
|
|
167
|
+
/**
|
|
168
|
+
* Stable, deterministic hash of any structured-cloneable value.
|
|
169
|
+
*/
|
|
170
|
+
function hash(value) {
|
|
171
|
+
return hash$1(value);
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/rpc/validate-io.ts
|
|
175
|
+
/**
|
|
176
|
+
* Run a single [Standard Schema](https://standardschema.dev) validator,
|
|
177
|
+
* awaiting the result when the validator is asynchronous.
|
|
178
|
+
*/
|
|
179
|
+
async function runStandardSchema(schema, value) {
|
|
180
|
+
const result = schema["~standard"].validate(value);
|
|
181
|
+
return result instanceof Promise ? await result : result;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Render Standard Schema issues into a single human-readable line for a
|
|
185
|
+
* diagnostic message, prefixing each with its dotted path when present.
|
|
186
|
+
*/
|
|
187
|
+
function formatIssues(issues) {
|
|
188
|
+
return issues.map((issue) => {
|
|
189
|
+
const path = issue.path?.map((segment) => typeof segment === "object" ? segment.key : segment).join(".");
|
|
190
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
191
|
+
}).join("; ");
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Validate positional arguments against their declared schemas. Only
|
|
195
|
+
* indices with a schema are checked; extra arguments pass through
|
|
196
|
+
* untouched. Throws `DF0038` on the first failing argument.
|
|
197
|
+
*
|
|
198
|
+
* Validation guards the payload without rewriting it: the original values
|
|
199
|
+
* are handed to the handler unchanged, so a schema that describes a subset
|
|
200
|
+
* of an object never silently strips the sender's extra fields (and any
|
|
201
|
+
* declared transforms stay a purely type-level concern).
|
|
202
|
+
*
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
async function validateRpcArgs(name, argsSchema, args) {
|
|
206
|
+
const original = args.slice();
|
|
207
|
+
if (!argsSchema || argsSchema.length === 0) return original;
|
|
208
|
+
for (let index = 0; index < argsSchema.length; index++) {
|
|
209
|
+
const schema = argsSchema[index];
|
|
210
|
+
if (!schema) continue;
|
|
211
|
+
const result = await runStandardSchema(schema, args[index]);
|
|
212
|
+
if (result.issues) throw diagnostics.DF0043({
|
|
213
|
+
name,
|
|
214
|
+
index,
|
|
215
|
+
issues: formatIssues(result.issues)
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return original;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Validate a handler's resolved return value against its declared schema.
|
|
222
|
+
* Throws `DF0039` when the value fails the schema, otherwise returns the
|
|
223
|
+
* original value unchanged (guard-only, never rewriting the payload — see
|
|
224
|
+
* {@link validateRpcArgs}). Passes through when no return schema is set.
|
|
225
|
+
*
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
async function validateRpcReturn(name, returnSchema, value) {
|
|
229
|
+
if (!returnSchema) return value;
|
|
230
|
+
const result = await runStandardSchema(returnSchema, value);
|
|
231
|
+
if (result.issues) throw diagnostics.DF0044({
|
|
232
|
+
name,
|
|
233
|
+
issues: formatIssues(result.issues)
|
|
234
|
+
});
|
|
235
|
+
return value;
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/rpc/handler.ts
|
|
239
|
+
async function getRpcResolvedSetupResult(definition, context) {
|
|
240
|
+
if (!definition.setup) return {};
|
|
241
|
+
if (typeof context === "object" && context !== null) {
|
|
242
|
+
definition.__cache ??= /* @__PURE__ */ new WeakMap();
|
|
243
|
+
const cache = definition.__cache;
|
|
244
|
+
let promise = cache.get(context);
|
|
245
|
+
if (!promise) {
|
|
246
|
+
promise = Promise.resolve(definition.setup(context));
|
|
247
|
+
promise.catch(() => {
|
|
248
|
+
if (cache.get(context) === promise) cache.delete(context);
|
|
249
|
+
});
|
|
250
|
+
cache.set(context, promise);
|
|
251
|
+
}
|
|
252
|
+
return await promise;
|
|
253
|
+
}
|
|
254
|
+
if (!definition.__promise) {
|
|
255
|
+
const promise = Promise.resolve(definition.setup(context));
|
|
256
|
+
promise.catch(() => {
|
|
257
|
+
if (definition.__promise === promise) definition.__promise = void 0;
|
|
258
|
+
});
|
|
259
|
+
definition.__promise = promise;
|
|
260
|
+
}
|
|
261
|
+
return await definition.__promise;
|
|
262
|
+
}
|
|
263
|
+
async function getRpcHandler(definition, context) {
|
|
264
|
+
let handler = definition.handler;
|
|
265
|
+
if (!handler) {
|
|
266
|
+
const result = await getRpcResolvedSetupResult(definition, context);
|
|
267
|
+
if (!result.handler) throw diagnostics.DF0024({ name: definition.name });
|
|
268
|
+
handler = result.handler;
|
|
269
|
+
}
|
|
270
|
+
const argsSchema = definition.args;
|
|
271
|
+
const returnSchema = definition.returns;
|
|
272
|
+
if (!argsSchema && !returnSchema) return handler;
|
|
273
|
+
const inner = handler;
|
|
274
|
+
const validating = async (...args) => {
|
|
275
|
+
const validatedArgs = await validateRpcArgs(definition.name, argsSchema, args);
|
|
276
|
+
const output = await inner(...validatedArgs);
|
|
277
|
+
return await validateRpcReturn(definition.name, returnSchema, output);
|
|
278
|
+
};
|
|
279
|
+
return validating;
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/rpc/validation.ts
|
|
283
|
+
/**
|
|
284
|
+
* Validates RPC function definitions.
|
|
285
|
+
* Action and event functions cannot have dumps (side effects should not be cached).
|
|
286
|
+
*
|
|
287
|
+
* @throws {Error} If an action or event function has a dump configuration
|
|
288
|
+
*/
|
|
289
|
+
function validateDefinitions(definitions) {
|
|
290
|
+
for (const definition of definitions) {
|
|
291
|
+
const type = definition.type || "query";
|
|
292
|
+
if ((type === "action" || type === "event") && definition.dump) throw diagnostics.DF0027({
|
|
293
|
+
name: definition.name,
|
|
294
|
+
type
|
|
295
|
+
});
|
|
296
|
+
if (definition.snapshot && type !== "query") throw diagnostics.DF0028({
|
|
297
|
+
name: definition.name,
|
|
298
|
+
type
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Validates a single RPC function definition.
|
|
304
|
+
*
|
|
305
|
+
* @throws {Error} If an action or event function has a dump configuration
|
|
306
|
+
*/
|
|
307
|
+
function validateDefinition(definition) {
|
|
308
|
+
validateDefinitions([definition]);
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
export { validateRpcArgs as a, getRpcResolvedSetupResult as i, validateDefinitions as n, validateRpcReturn as o, getRpcHandler as r, hash as s, validateDefinition as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devframe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.2",
|
|
5
5
|
"description": "Framework for building one portable devtool integration that runs in any viewer.",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"./rpc/transports/sse-client": "./dist/rpc/transports/sse-client.mjs",
|
|
42
42
|
"./rpc/transports/sse-server": "./dist/rpc/transports/sse-server.mjs",
|
|
43
43
|
"./rpc/transports/ws-bun": "./dist/rpc/transports/ws-bun.mjs",
|
|
44
|
+
"./rpc/transports/ws-deno": "./dist/rpc/transports/ws-deno.mjs",
|
|
44
45
|
"./rpc/transports/ws-client": "./dist/rpc/transports/ws-client.mjs",
|
|
45
46
|
"./rpc/transports/ws-server": "./dist/rpc/transports/ws-server.mjs",
|
|
46
47
|
"./types": "./dist/types/index.mjs",
|
|
@@ -103,11 +104,11 @@
|
|
|
103
104
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
104
105
|
"cac": "^7.0.0",
|
|
105
106
|
"get-port-please": "^3.2.0",
|
|
106
|
-
"immer": "^11.1.
|
|
107
|
+
"immer": "^11.1.17",
|
|
107
108
|
"launch-editor": "^2.14.1",
|
|
108
109
|
"mlly": "^1.8.2",
|
|
109
110
|
"obug": "^2.1.4",
|
|
110
|
-
"ohash": "^2.0.
|
|
111
|
+
"ohash": "^2.0.12",
|
|
111
112
|
"p-limit": "^7.3.1",
|
|
112
113
|
"perfect-debounce": "^2.1.0",
|
|
113
114
|
"structured-clone-es": "^2.0.1",
|
package/skills/devframe/SKILL.md
CHANGED
|
@@ -558,7 +558,7 @@ Devframe re-exports a curated set of helpers under `devframe/utils/*`. They are
|
|
|
558
558
|
| `createStreamSink` / `createStreamReader` from `devframe/utils/streaming-channel` | - | Low-level streaming primitives |
|
|
559
559
|
| `evaluateWhen` / `WhenExpression` from `devframe/utils/when` | `whenexpr` | When-clause expressions |
|
|
560
560
|
|
|
561
|
-
For "open file in editor" + "reveal in finder", prefer the
|
|
561
|
+
For "open file in editor" + "reveal in finder", prefer the `@devframes/service-open` wire service (declare `services: [{ package: '@devframes/service-open' }]` on the definition, gate client UI on `rpc.services.has(...)`) - one host-level installation shared by every plugin, with workspace-root path containment. The older `commonRpcFunctions` recipe (`devframe/recipes/common-rpc-functions`) still works but is deprecated.
|
|
562
562
|
|
|
563
563
|
## Security (secure by default)
|
|
564
564
|
|