devframe 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/adapters/build.d.mts +2 -2
- package/dist/adapters/build.mjs +9 -9
- package/dist/adapters/cli.d.mts +1 -1
- package/dist/adapters/cli.mjs +1 -1
- package/dist/adapters/dev.d.mts +2 -2
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +2 -2
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.mjs +3 -3
- package/dist/client/index.d.mts +28 -28
- package/dist/client/index.mjs +27 -23
- package/dist/constants.d.mts +10 -10
- package/dist/constants.mjs +10 -10
- package/dist/{context-C9oW88gr.d.mts → context-DTRcO_UH.d.mts} +6 -6
- package/dist/{storage-CZVTPKsw.mjs → context-DaKmhhHY.mjs} +48 -3
- package/dist/{dev-C2wjXjGB.mjs → dev-Cv43GfqM.mjs} +5 -5
- package/dist/{devframe-K4IxpM4a.d.mts → devframe-BuR6n9ZD.d.mts} +44 -44
- package/dist/{dump-B1wd4u68.mjs → dump-9lKIJTLh.mjs} +15 -11
- package/dist/helpers/vite.d.mts +1 -1
- package/dist/helpers/vite.mjs +4 -4
- package/dist/{host-h3-Div5Vp8R.mjs → host-h3-Dgpgr1Ul.mjs} +16 -16
- package/dist/{index-CBSBvT9K.d.mts → index-C7M1hnvL.d.mts} +2 -2
- package/dist/{index-BhtRKN7X.d.mts → index-DH2sBIwd.d.mts} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/node/auth.d.mts +5 -5
- package/dist/node/auth.mjs +1 -1
- package/dist/node/{internal.d.mts → hub-internals.d.mts} +3 -3
- package/dist/node/hub-internals.mjs +3 -0
- package/dist/node/index.d.mts +34 -34
- package/dist/node/index.mjs +4 -4
- package/dist/recipes/open-helpers.d.mts +5 -5
- package/dist/{human-id-Dq-qgtES.mjs → revoke-CL0LSAN9.mjs} +35 -35
- package/dist/rpc/dump.d.mts +1 -1
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.d.mts +2 -2
- package/dist/rpc/index.mjs +1 -1
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +1 -1
- package/dist/rpc/transports/ws-server.d.mts +2 -2
- package/dist/{server-BO8IDVsJ.mjs → server-BBaBJaUL.mjs} +12 -5
- package/dist/{server-KzCqriO9.d.mts → server-wHlpcdZ9.d.mts} +3 -3
- package/dist/{shared-state-CasqoUba.mjs → shared-state-BlBNYziY.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-dNW3UmMl.d.mts → types-BkkQ0Txg.d.mts} +4 -4
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/{ws-client-BZptK_Mf.d.mts → ws-client-CVYX9niP.d.mts} +1 -1
- package/dist/{ws-server-CTeMCO1r.d.mts → ws-server-C1LjmRnp.d.mts} +5 -5
- package/package.json +5 -5
- package/skills/devframe/SKILL.md +82 -5
- package/dist/node/internal.mjs +0 -49
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as RpcFunctionsCollectorBase } from "./index-
|
|
2
|
-
import { t as
|
|
1
|
+
import { S as RpcFunctionsCollectorBase } from "./index-C7M1hnvL.mjs";
|
|
2
|
+
import { t as DevframeNodeRpcSessionMeta } from "./ws-server-C1LjmRnp.mjs";
|
|
3
3
|
import { CAC } from "cac";
|
|
4
4
|
import { GenericSchema, InferOutput } from "valibot";
|
|
5
5
|
import { BirpcReturn } from "birpc";
|
|
@@ -148,7 +148,7 @@ interface AgentTool {
|
|
|
148
148
|
}[];
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
* Input accepted by `
|
|
151
|
+
* Input accepted by `DevframeAgentHost.registerTool()`. Handler is
|
|
152
152
|
* stripped from the serializable `AgentTool` projection.
|
|
153
153
|
*
|
|
154
154
|
* @experimental
|
|
@@ -170,7 +170,7 @@ interface AgentToolInput {
|
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Serializable description of an agent-readable resource. Resources
|
|
173
|
-
* surface structured or textual snapshots of
|
|
173
|
+
* surface structured or textual snapshots of devframe state.
|
|
174
174
|
*
|
|
175
175
|
* @experimental
|
|
176
176
|
*/
|
|
@@ -184,7 +184,7 @@ interface AgentResource {
|
|
|
184
184
|
mimeType?: string;
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
|
-
* Input accepted by `
|
|
187
|
+
* Input accepted by `DevframeAgentHost.registerResource()`.
|
|
188
188
|
*
|
|
189
189
|
* @experimental
|
|
190
190
|
*/
|
|
@@ -227,11 +227,11 @@ interface AgentHandle {
|
|
|
227
227
|
unregister: () => void;
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
|
-
* Events emitted by `
|
|
230
|
+
* Events emitted by `DevframeAgentHost`.
|
|
231
231
|
*
|
|
232
232
|
* @experimental
|
|
233
233
|
*/
|
|
234
|
-
interface
|
|
234
|
+
interface DevframeAgentHostEvents {
|
|
235
235
|
'agent:tool:registered': (tool: AgentTool) => void;
|
|
236
236
|
'agent:tool:unregistered': (id: string) => void;
|
|
237
237
|
'agent:resource:registered': (resource: AgentResource) => void;
|
|
@@ -251,8 +251,8 @@ interface DevToolsAgentHostEvents {
|
|
|
251
251
|
* @experimental The agent-native surface is experimental and may change
|
|
252
252
|
* without a major version bump until it stabilizes.
|
|
253
253
|
*/
|
|
254
|
-
interface
|
|
255
|
-
readonly events: EventEmitter<
|
|
254
|
+
interface DevframeAgentHost {
|
|
255
|
+
readonly events: EventEmitter<DevframeAgentHostEvents>;
|
|
256
256
|
/**
|
|
257
257
|
* Register a tool not backed by an RPC function. Use this when you
|
|
258
258
|
* want a plain agent action (e.g. a synthesized summary) that
|
|
@@ -292,7 +292,7 @@ interface DevToolsAgentHost {
|
|
|
292
292
|
* types don't allow assigning a narrow-keyed result to a generically-keyed
|
|
293
293
|
* one. The host stores them in a heterogeneous registry.
|
|
294
294
|
*/
|
|
295
|
-
type
|
|
295
|
+
type DevframeDiagnosticsDefinition = ReturnType<typeof defineDiagnostics<any, any>>;
|
|
296
296
|
/**
|
|
297
297
|
* The shared diagnostics lookup exposed by the host. A `Proxy` that resolves
|
|
298
298
|
* any registered code name to its `nostics` handle (a callable that builds
|
|
@@ -300,13 +300,13 @@ type DevToolsDiagnosticsDefinition = ReturnType<typeof defineDiagnostics<any, an
|
|
|
300
300
|
* because it spans heterogeneous definitions registered by different
|
|
301
301
|
* integrations.
|
|
302
302
|
*/
|
|
303
|
-
type
|
|
303
|
+
type DevframeDiagnosticsLogger = Record<string, any>;
|
|
304
304
|
/**
|
|
305
305
|
* Options accepted by the host's `defineDiagnostics()` factory — mirrors
|
|
306
306
|
* `nostics`'s shape but the host pre-wires its ANSI console reporter, so
|
|
307
307
|
* plugins typically omit `reporters`.
|
|
308
308
|
*/
|
|
309
|
-
interface
|
|
309
|
+
interface DevframeDefineDiagnosticsOptions<Codes extends Record<string, DiagnosticDefinition>> {
|
|
310
310
|
docsBase?: string | ((code: keyof Codes) => string | undefined);
|
|
311
311
|
codes: Codes;
|
|
312
312
|
reporters?: ReadonlyArray<(d: Diagnostic, o?: any) => void>;
|
|
@@ -334,7 +334,7 @@ interface DevToolsDefineDiagnosticsOptions<Codes extends Record<string, Diagnost
|
|
|
334
334
|
* throw myDiagnostics.MYP0001()
|
|
335
335
|
* ```
|
|
336
336
|
*/
|
|
337
|
-
interface
|
|
337
|
+
interface DevframeDiagnosticsHost {
|
|
338
338
|
/**
|
|
339
339
|
* Proxy-backed lookup of every registered diagnostic handle by code name.
|
|
340
340
|
* Resolves to a `nostics` `DiagnosticHandle` — a callable that builds a
|
|
@@ -342,7 +342,7 @@ interface DevToolsDiagnosticsHost {
|
|
|
342
342
|
* `throw` to raise. Loosely typed — for autocompletion, keep a reference
|
|
343
343
|
* to the typed result of `defineDiagnostics()` instead.
|
|
344
344
|
*/
|
|
345
|
-
readonly logger:
|
|
345
|
+
readonly logger: DevframeDiagnosticsLogger;
|
|
346
346
|
/**
|
|
347
347
|
* Register additional diagnostic definitions with this host. After
|
|
348
348
|
* registration, codes from the new definition are reachable via
|
|
@@ -356,14 +356,14 @@ interface DevToolsDiagnosticsHost {
|
|
|
356
356
|
* pre-wired. Mirrors `nostics`'s `defineDiagnostics` so integrations don't
|
|
357
357
|
* need to take a direct dependency on `nostics`.
|
|
358
358
|
*/
|
|
359
|
-
defineDiagnostics: <const Codes extends Record<string, DiagnosticDefinition>>(options:
|
|
359
|
+
defineDiagnostics: <const Codes extends Record<string, DiagnosticDefinition>>(options: DevframeDefineDiagnosticsOptions<Codes>) => ReturnType<typeof defineDiagnostics<Codes, any>>;
|
|
360
360
|
}
|
|
361
361
|
//#endregion
|
|
362
362
|
//#region src/types/host.d.ts
|
|
363
|
-
interface
|
|
363
|
+
interface DevframeHost {
|
|
364
364
|
/**
|
|
365
365
|
* Serve a static directory at the given URL base. Called by
|
|
366
|
-
* `
|
|
366
|
+
* `DevframeViewHost.hostStatic`. Implementations map this to whatever
|
|
367
367
|
* the underlying runtime expects (Vite middleware, h3 handler, no-op
|
|
368
368
|
* for build snapshots).
|
|
369
369
|
*/
|
|
@@ -377,16 +377,16 @@ interface DevToolsHost {
|
|
|
377
377
|
*/
|
|
378
378
|
resolveOrigin: () => string;
|
|
379
379
|
/**
|
|
380
|
-
* Resolve a directory the host owns for persisted
|
|
380
|
+
* Resolve a directory the host owns for persisted devframe state.
|
|
381
381
|
* Each host picks its own app-name namespace so storage doesn't
|
|
382
|
-
* collide between, say, the Vite host (`.vite/
|
|
383
|
-
* standalone CLI host (`.<appName>/
|
|
382
|
+
* collide between, say, the Vite host (`.vite/devframe`) and a
|
|
383
|
+
* standalone CLI host (`.<appName>/devframe`).
|
|
384
384
|
*
|
|
385
385
|
* - `workspace` — per-project state (settings, caches). Typically
|
|
386
|
-
* under `${workspaceRoot}/node_modules/.<appName>/
|
|
386
|
+
* under `${workspaceRoot}/node_modules/.<appName>/devframe/`.
|
|
387
387
|
* - `global` — per-user state (auth tokens, machine-wide
|
|
388
388
|
* preferences). Typically under
|
|
389
|
-
* `${homedir()}/.<appName>/
|
|
389
|
+
* `${homedir()}/.<appName>/devframe/`.
|
|
390
390
|
*
|
|
391
391
|
* Implementations should ensure the directory exists or be safe to
|
|
392
392
|
* pass to a downstream `createStorage(...)` call that creates it
|
|
@@ -399,7 +399,7 @@ interface DevToolsHost {
|
|
|
399
399
|
/**
|
|
400
400
|
* To be extended
|
|
401
401
|
*/
|
|
402
|
-
interface
|
|
402
|
+
interface DevframeRpcClientFunctions {
|
|
403
403
|
/**
|
|
404
404
|
* Streaming chunk pushed from server to subscribed clients. Wired by
|
|
405
405
|
* `RpcStreamingHost`; do not register manually.
|
|
@@ -428,7 +428,7 @@ interface DevToolsRpcClientFunctions {
|
|
|
428
428
|
/**
|
|
429
429
|
* To be extended
|
|
430
430
|
*/
|
|
431
|
-
interface
|
|
431
|
+
interface DevframeRpcServerFunctions {
|
|
432
432
|
/**
|
|
433
433
|
* Subscribe a client to a shared-state key. Wired by
|
|
434
434
|
* `RpcSharedStateHost`; do not register manually.
|
|
@@ -501,7 +501,7 @@ interface DevToolsRpcServerFunctions {
|
|
|
501
501
|
/**
|
|
502
502
|
* To be extended
|
|
503
503
|
*/
|
|
504
|
-
interface
|
|
504
|
+
interface DevframeRpcSharedStates {}
|
|
505
505
|
//#endregion
|
|
506
506
|
//#region src/types/utils.d.ts
|
|
507
507
|
type Thenable<T> = T | Promise<T>;
|
|
@@ -513,7 +513,7 @@ type PartialWithoutId<T extends {
|
|
|
513
513
|
};
|
|
514
514
|
//#endregion
|
|
515
515
|
//#region src/types/views.d.ts
|
|
516
|
-
interface
|
|
516
|
+
interface DevframeViewHost {
|
|
517
517
|
/**
|
|
518
518
|
* @internal
|
|
519
519
|
*/
|
|
@@ -710,34 +710,34 @@ declare function createStreamSink<T>(options?: CreateStreamSinkOptions): StreamS
|
|
|
710
710
|
declare function createStreamReader<T>(options?: CreateStreamReaderOptions): StreamReader<T>;
|
|
711
711
|
//#endregion
|
|
712
712
|
//#region src/types/rpc.d.ts
|
|
713
|
-
interface
|
|
714
|
-
meta:
|
|
715
|
-
rpc: BirpcReturn<
|
|
713
|
+
interface DevframeNodeRpcSession {
|
|
714
|
+
meta: DevframeNodeRpcSessionMeta;
|
|
715
|
+
rpc: BirpcReturn<DevframeRpcClientFunctions, DevframeRpcServerFunctions, false>;
|
|
716
716
|
}
|
|
717
717
|
interface RpcBroadcastOptions<METHOD, Args extends any[]> {
|
|
718
718
|
method: METHOD;
|
|
719
719
|
args: Args;
|
|
720
720
|
optional?: boolean;
|
|
721
721
|
event?: boolean;
|
|
722
|
-
filter?: (client: BirpcReturn<
|
|
722
|
+
filter?: (client: BirpcReturn<DevframeRpcClientFunctions, DevframeRpcServerFunctions, false>) => boolean | void;
|
|
723
723
|
}
|
|
724
|
-
type RpcFunctionsHost = RpcFunctionsCollectorBase<
|
|
724
|
+
type RpcFunctionsHost = RpcFunctionsCollectorBase<DevframeRpcServerFunctions, DevframeNodeContext> & {
|
|
725
725
|
/**
|
|
726
726
|
* Invoke a locally registered server RPC function directly.
|
|
727
727
|
*
|
|
728
728
|
* This bypasses transport and is useful for server-side cross-function calls.
|
|
729
729
|
*/
|
|
730
|
-
invokeLocal: <T extends keyof
|
|
730
|
+
invokeLocal: <T extends keyof DevframeRpcServerFunctions, Args extends Parameters<DevframeRpcServerFunctions[T]>>(method: T, ...args: Args) => Promise<Awaited<ReturnType<DevframeRpcServerFunctions[T]>>>;
|
|
731
731
|
/**
|
|
732
732
|
* Broadcast a message to all connected clients
|
|
733
733
|
*/
|
|
734
|
-
broadcast: <T extends keyof
|
|
734
|
+
broadcast: <T extends keyof DevframeRpcClientFunctions, Args extends Parameters<DevframeRpcClientFunctions[T]>>(options: RpcBroadcastOptions<T, Args>) => Promise<void>;
|
|
735
735
|
/**
|
|
736
736
|
* Get the current RPC client
|
|
737
737
|
*
|
|
738
738
|
* Available in RPC functions to get the current RPC client
|
|
739
739
|
*/
|
|
740
|
-
getCurrentRpcSession: () =>
|
|
740
|
+
getCurrentRpcSession: () => DevframeNodeRpcSession | undefined;
|
|
741
741
|
/**
|
|
742
742
|
* The shared state host
|
|
743
743
|
*/
|
|
@@ -755,7 +755,7 @@ interface RpcSharedStateGetOptions<T> {
|
|
|
755
755
|
initialValue?: T;
|
|
756
756
|
}
|
|
757
757
|
interface RpcSharedStateHost {
|
|
758
|
-
get: <T extends keyof
|
|
758
|
+
get: <T extends keyof DevframeRpcSharedStates>(key: T, options?: RpcSharedStateGetOptions<DevframeRpcSharedStates[T]>) => Promise<SharedState<DevframeRpcSharedStates[T]>>;
|
|
759
759
|
keys: () => string[];
|
|
760
760
|
/**
|
|
761
761
|
* Subscribe to new shared-state keys becoming available. Fires when
|
|
@@ -866,11 +866,11 @@ interface RpcStreamingHost {
|
|
|
866
866
|
*
|
|
867
867
|
* @internal
|
|
868
868
|
*/
|
|
869
|
-
_onSessionDisconnected: (meta:
|
|
869
|
+
_onSessionDisconnected: (meta: DevframeNodeRpcSessionMeta) => void;
|
|
870
870
|
}
|
|
871
871
|
//#endregion
|
|
872
872
|
//#region src/types/context.d.ts
|
|
873
|
-
interface
|
|
873
|
+
interface DevframeCapabilities {
|
|
874
874
|
rpc?: boolean;
|
|
875
875
|
views?: boolean;
|
|
876
876
|
}
|
|
@@ -881,7 +881,7 @@ interface DevToolsCapabilities {
|
|
|
881
881
|
* `createKitContext` adds `docks`, `terminals`, `messages`, and
|
|
882
882
|
* `commands` when mounted into Vite DevTools.
|
|
883
883
|
*/
|
|
884
|
-
interface
|
|
884
|
+
interface DevframeNodeContext {
|
|
885
885
|
readonly workspaceRoot: string;
|
|
886
886
|
readonly cwd: string;
|
|
887
887
|
/**
|
|
@@ -903,20 +903,20 @@ interface DevToolsNodeContext {
|
|
|
903
903
|
* Host runtime abstraction — exposes `mountStatic` / `resolveOrigin` /
|
|
904
904
|
* `getStorageDir`.
|
|
905
905
|
*/
|
|
906
|
-
host:
|
|
906
|
+
host: DevframeHost;
|
|
907
907
|
rpc: RpcFunctionsHost;
|
|
908
|
-
views:
|
|
908
|
+
views: DevframeViewHost;
|
|
909
909
|
/**
|
|
910
910
|
* Structured diagnostics host — wraps `nostics` and lets integrations
|
|
911
911
|
* register their own coded errors/warnings into the shared lookup.
|
|
912
912
|
*/
|
|
913
|
-
diagnostics:
|
|
913
|
+
diagnostics: DevframeDiagnosticsHost;
|
|
914
914
|
/**
|
|
915
915
|
* Agent host — aggregates the agent-exposed surface of this devtool.
|
|
916
916
|
*
|
|
917
917
|
* @experimental
|
|
918
918
|
*/
|
|
919
|
-
agent:
|
|
919
|
+
agent: DevframeAgentHost;
|
|
920
920
|
}
|
|
921
921
|
interface ConnectionMeta {
|
|
922
922
|
backend: 'websocket' | 'static';
|
|
@@ -1048,7 +1048,7 @@ interface DevframeDefinition {
|
|
|
1048
1048
|
spa?: boolean | Record<string, boolean>;
|
|
1049
1049
|
};
|
|
1050
1050
|
/** Server-side setup — the primary entrypoint. Runs in every runtime. */
|
|
1051
|
-
setup: (ctx:
|
|
1051
|
+
setup: (ctx: DevframeNodeContext, info?: DevframeSetupInfo) => void | Promise<void>;
|
|
1052
1052
|
/** Browser-only setup for the SPA adapter (bundled into the client). */
|
|
1053
1053
|
setupBrowser?: (ctx: DevframeBrowserContext) => void | Promise<void>;
|
|
1054
1054
|
cli?: DevframeCliOptions;
|
|
@@ -1056,4 +1056,4 @@ interface DevframeDefinition {
|
|
|
1056
1056
|
}
|
|
1057
1057
|
declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
|
|
1058
1058
|
//#endregion
|
|
1059
|
-
export { AgentResource as $, ImmutableArray as A, EntriesToObject as B, StreamErrorPayload as C, createStreamReader as D, StreamSinkEvents as E, SharedStateEvents as F,
|
|
1059
|
+
export { AgentResource as $, ImmutableArray as A, EntriesToObject as B, StreamErrorPayload as C, createStreamReader as D, StreamSinkEvents as E, SharedStateEvents as F, DevframeRpcSharedStates as G, Thenable as H, SharedStateOptions as I, DevframeDiagnosticsDefinition as J, DevframeHost as K, SharedStatePatch as L, ImmutableObject as M, ImmutableSet as N, createStreamSink as O, SharedState as P, AgentManifest as Q, createSharedState as R, CreateStreamSinkOptions as S, StreamSink as T, DevframeRpcClientFunctions as U, PartialWithoutId as V, DevframeRpcServerFunctions as W, DevframeDiagnosticsLogger as X, DevframeDiagnosticsHost as Y, AgentHandle as Z, RpcStreamingChannel as _, DevframeRuntime as a, DevframeAgentHostEvents as at, BufferedChunk as b, defineDevframe as c, EventsMap as ct, DevframeNodeContext as d, defineCliFlags as dt, AgentResourceContent as et, DevframeNodeRpcSession as f, parseCliFlags as ft, RpcSharedStateHost as g, RpcSharedStateGetOptions as h, DevframeDeploymentKind as i, DevframeAgentHost as it, ImmutableMap as j, Immutable as k, ConnectionMeta as l, CliFlagsSchema as lt, RpcFunctionsHost as m, DevframeCliOptions as n, AgentTool as nt, DevframeSetupInfo as o, EventEmitter as ot, RpcBroadcastOptions as p, DevframeDefineDiagnosticsOptions as q, DevframeDefinition as r, AgentToolInput as rt, DevframeSpaOptions as s, EventUnsubscribe as st, DevframeBrowserContext as t, AgentResourceInput as tt, DevframeCapabilities as u, InferCliFlags as ut, RpcStreamingChannelOptions as v, StreamReader as w, CreateStreamReaderOptions as x, RpcStreamingHost as y, DevframeViewHost as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as diagnostics } from "./diagnostics-GitRGKbr.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { DEVFRAME_RPC_DUMP_DIRNAME } from "./constants.mjs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
//#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/shared/ohash.D__AXeF1.mjs
|
|
5
5
|
function serialize(o) {
|
|
@@ -498,14 +498,18 @@ function getDefinitionsWithDumps(definitions) {
|
|
|
498
498
|
//#endregion
|
|
499
499
|
//#region src/rpc/handler.ts
|
|
500
500
|
async function getRpcResolvedSetupResult(definition, context) {
|
|
501
|
-
if (definition.__resolved) return definition.__resolved;
|
|
502
501
|
if (!definition.setup) return {};
|
|
503
|
-
|
|
504
|
-
definition.
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
502
|
+
if (typeof context === "object" && context !== null) {
|
|
503
|
+
definition.__cache ??= /* @__PURE__ */ new WeakMap();
|
|
504
|
+
let promise = definition.__cache.get(context);
|
|
505
|
+
if (!promise) {
|
|
506
|
+
promise = Promise.resolve(definition.setup(context));
|
|
507
|
+
definition.__cache.set(context, promise);
|
|
508
|
+
}
|
|
509
|
+
return await promise;
|
|
510
|
+
}
|
|
511
|
+
definition.__promise ??= Promise.resolve(definition.setup(context));
|
|
512
|
+
return await definition.__promise;
|
|
509
513
|
}
|
|
510
514
|
async function getRpcHandler(definition, context) {
|
|
511
515
|
if (definition.handler) return definition.handler;
|
|
@@ -519,13 +523,13 @@ function makeDumpKey(name) {
|
|
|
519
523
|
return encodeURIComponent(name.replaceAll(":", "~"));
|
|
520
524
|
}
|
|
521
525
|
function makeStaticPath(name) {
|
|
522
|
-
return `${
|
|
526
|
+
return `${DEVFRAME_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.static.json`;
|
|
523
527
|
}
|
|
524
528
|
function makeQueryRecordPath(name, hash) {
|
|
525
|
-
return `${
|
|
529
|
+
return `${DEVFRAME_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.record.${hash}.json`;
|
|
526
530
|
}
|
|
527
531
|
function makeQueryFallbackPath(name) {
|
|
528
|
-
return `${
|
|
532
|
+
return `${DEVFRAME_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.fallback.json`;
|
|
529
533
|
}
|
|
530
534
|
async function resolveRecord(record) {
|
|
531
535
|
return typeof record === "function" ? await record() : record;
|
package/dist/helpers/vite.d.mts
CHANGED
package/dist/helpers/vite.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as diagnostics } from "../shared-state-
|
|
1
|
+
import { DEVFRAME_CONNECTION_META_FILENAME } from "../constants.mjs";
|
|
2
|
+
import { i as diagnostics } from "../shared-state-BlBNYziY.mjs";
|
|
3
3
|
import { n as resolveBasePath } from "../_shared-CUFqO4kJ.mjs";
|
|
4
4
|
import { serveStaticNodeMiddleware } from "../utils/serve-static.mjs";
|
|
5
|
-
import { n as resolveDevServerPort, t as createDevServer } from "../dev-
|
|
5
|
+
import { n as resolveDevServerPort, t as createDevServer } from "../dev-Cv43GfqM.mjs";
|
|
6
6
|
import { resolve } from "pathe";
|
|
7
7
|
//#region src/helpers/vite.ts
|
|
8
8
|
/**
|
|
@@ -61,7 +61,7 @@ function viteDevBridge(d, options = {}) {
|
|
|
61
61
|
}, { method: "warn" });
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const metaPath = `${base}${
|
|
64
|
+
const metaPath = `${base}${DEVFRAME_CONNECTION_META_FILENAME}`;
|
|
65
65
|
server.middlewares.use(metaPath, (_req, res) => {
|
|
66
66
|
res.setHeader("Content-Type", "application/json");
|
|
67
67
|
res.end(JSON.stringify({
|
|
@@ -2,7 +2,7 @@ import { t as devframeReporter } from "./diagnostics-reporter-CBBZwoMv.mjs";
|
|
|
2
2
|
import { t as diagnostics } from "./diagnostics-GitRGKbr.mjs";
|
|
3
3
|
import { RpcFunctionsCollectorBase } from "./rpc/index.mjs";
|
|
4
4
|
import { defineRpcFunction } from "./index.mjs";
|
|
5
|
-
import { i as diagnostics$1, n as nanoid, r as createEventEmitter, t as createSharedState } from "./shared-state-
|
|
5
|
+
import { i as diagnostics$1, n as nanoid, r as createEventEmitter, t as createSharedState } from "./shared-state-BlBNYziY.mjs";
|
|
6
6
|
import { defineDiagnostics } from "nostics";
|
|
7
7
|
import { isatty } from "node:tty";
|
|
8
8
|
import { formatWithOptions, inspect } from "node:util";
|
|
@@ -19,7 +19,7 @@ import { join } from "pathe";
|
|
|
19
19
|
*
|
|
20
20
|
* @experimental
|
|
21
21
|
*/
|
|
22
|
-
var
|
|
22
|
+
var DevframeAgentHost = class {
|
|
23
23
|
context;
|
|
24
24
|
events = createEventEmitter();
|
|
25
25
|
tools = /* @__PURE__ */ new Map();
|
|
@@ -184,7 +184,7 @@ function hasPositionalKeys(obj) {
|
|
|
184
184
|
}
|
|
185
185
|
//#endregion
|
|
186
186
|
//#region src/node/host-diagnostics.ts
|
|
187
|
-
var
|
|
187
|
+
var DevframeDiagnosticsHost = class {
|
|
188
188
|
context;
|
|
189
189
|
_registry = {};
|
|
190
190
|
logger = new Proxy({}, { get: (_, code) => this._registry[code] });
|
|
@@ -458,8 +458,8 @@ function createDebug(namespace, options) {
|
|
|
458
458
|
enable(process.env.DEBUG || "");
|
|
459
459
|
//#endregion
|
|
460
460
|
//#region src/node/rpc-shared-state.ts
|
|
461
|
-
const debug$1 = createDebug("
|
|
462
|
-
const debugSubscribe = createDebug("
|
|
461
|
+
const debug$1 = createDebug("devframe:rpc:state:changed");
|
|
462
|
+
const debugSubscribe = createDebug("devframe:rpc:state:subscribe");
|
|
463
463
|
function createRpcSharedStateServerHost(rpc) {
|
|
464
464
|
const sharedState = /* @__PURE__ */ new Map();
|
|
465
465
|
const keyAddedListeners = /* @__PURE__ */ new Set();
|
|
@@ -817,7 +817,7 @@ function toErrorPayload(reason) {
|
|
|
817
817
|
}
|
|
818
818
|
//#endregion
|
|
819
819
|
//#region src/node/rpc-streaming.ts
|
|
820
|
-
const debug = createDebug("
|
|
820
|
+
const debug = createDebug("devframe:rpc:streaming");
|
|
821
821
|
const STREAM_KEY_SEPARATOR = "";
|
|
822
822
|
function streamKey(channel, id) {
|
|
823
823
|
return `${channel}${STREAM_KEY_SEPARATOR}${id}`;
|
|
@@ -1117,7 +1117,7 @@ function createRpcStreamingServerHost(rpc) {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
//#endregion
|
|
1119
1119
|
//#region src/node/host-functions.ts
|
|
1120
|
-
const debugBroadcast = createDebug("
|
|
1120
|
+
const debugBroadcast = createDebug("devframe:rpc:broadcast");
|
|
1121
1121
|
var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
|
|
1122
1122
|
/**
|
|
1123
1123
|
* @internal
|
|
@@ -1165,7 +1165,7 @@ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
|
|
|
1165
1165
|
};
|
|
1166
1166
|
//#endregion
|
|
1167
1167
|
//#region src/node/host-views.ts
|
|
1168
|
-
var
|
|
1168
|
+
var DevframeViewHost = class {
|
|
1169
1169
|
context;
|
|
1170
1170
|
/**
|
|
1171
1171
|
* @internal
|
|
@@ -1242,7 +1242,7 @@ const BUILTIN_AGENT_RPC = [
|
|
|
1242
1242
|
//#endregion
|
|
1243
1243
|
//#region src/node/context.ts
|
|
1244
1244
|
/**
|
|
1245
|
-
* Framework- and build-tool-agnostic core of the
|
|
1245
|
+
* Framework- and build-tool-agnostic core of the Devframe node context.
|
|
1246
1246
|
* Wires the RPC host, view (HTTP file-serving) host, diagnostics, and
|
|
1247
1247
|
* agent subsystems. Host adapters can wrap this to augment `ctx` with
|
|
1248
1248
|
* extra surfaces — for example, `@vitejs/devtools-kit`'s
|
|
@@ -1262,12 +1262,12 @@ async function createHostContext(options) {
|
|
|
1262
1262
|
agent: void 0
|
|
1263
1263
|
};
|
|
1264
1264
|
const rpcHost = new RpcFunctionsHost(context);
|
|
1265
|
-
const viewsHost = new
|
|
1266
|
-
const diagnosticsHost = new
|
|
1265
|
+
const viewsHost = new DevframeViewHost(context);
|
|
1266
|
+
const diagnosticsHost = new DevframeDiagnosticsHost(context, [diagnostics$1, diagnostics]);
|
|
1267
1267
|
context.rpc = rpcHost;
|
|
1268
1268
|
context.views = viewsHost;
|
|
1269
1269
|
context.diagnostics = diagnosticsHost;
|
|
1270
|
-
context.agent = new
|
|
1270
|
+
context.agent = new DevframeAgentHost(context);
|
|
1271
1271
|
for (const fn of BUILTIN_AGENT_RPC) rpcHost.register(fn);
|
|
1272
1272
|
for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
|
|
1273
1273
|
return context;
|
|
@@ -1275,9 +1275,9 @@ async function createHostContext(options) {
|
|
|
1275
1275
|
//#endregion
|
|
1276
1276
|
//#region src/node/host-h3.ts
|
|
1277
1277
|
/**
|
|
1278
|
-
* h3-backed {@link
|
|
1278
|
+
* h3-backed {@link DevframeHost} — used by the standalone CLI adapter.
|
|
1279
1279
|
*/
|
|
1280
|
-
function
|
|
1280
|
+
function createH3DevframeHost(options) {
|
|
1281
1281
|
const workspaceRoot = options.workspaceRoot ?? process$1.cwd();
|
|
1282
1282
|
return {
|
|
1283
1283
|
mountStatic(base, distDir) {
|
|
@@ -1287,10 +1287,10 @@ function createH3DevToolsHost(options) {
|
|
|
1287
1287
|
return options.origin;
|
|
1288
1288
|
},
|
|
1289
1289
|
getStorageDir(scope) {
|
|
1290
|
-
const namespace = `.${options.appName}/
|
|
1290
|
+
const namespace = `.${options.appName}/devframe`;
|
|
1291
1291
|
return scope === "workspace" ? join(workspaceRoot, "node_modules", namespace) : join(homedir(), namespace);
|
|
1292
1292
|
}
|
|
1293
1293
|
};
|
|
1294
1294
|
}
|
|
1295
1295
|
//#endregion
|
|
1296
|
-
export { createRpcStreamingServerHost as a,
|
|
1296
|
+
export { createRpcStreamingServerHost as a, DevframeAgentHost as c, RpcFunctionsHost as i, createHostContext as n, createRpcSharedStateServerHost as o, DevframeViewHost as r, DevframeDiagnosticsHost as s, createH3DevframeHost as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as RpcFunctionsCollector, S as RpcFunctionType, _ as RpcFunctionDefinitionAny, g as RpcFunctionDefinition, i as RpcArgsSchema, w as RpcReturnSchema, x as RpcFunctionSetupResult } from "./types-
|
|
2
|
-
import { a as getDefinitionsWithDumps$1, c as StaticRpcDumpManifest$1, d as StaticRpcDumpManifestValue$1, f as StaticRpcDumpSerialization$1, i as dumpFunctions$1, l as StaticRpcDumpManifestQueryEntry$1, n as serializeDumpError$1, o as StaticRpcDumpCollection$1, p as collectStaticRpcDump$1, r as createClientFromDump$1, s as StaticRpcDumpFile$1, t as reviveDumpError$1, u as StaticRpcDumpManifestStaticEntry$1 } from "./index-
|
|
1
|
+
import { C as RpcFunctionsCollector, S as RpcFunctionType, _ as RpcFunctionDefinitionAny, g as RpcFunctionDefinition, i as RpcArgsSchema, w as RpcReturnSchema, x as RpcFunctionSetupResult } from "./types-BkkQ0Txg.mjs";
|
|
2
|
+
import { a as getDefinitionsWithDumps$1, c as StaticRpcDumpManifest$1, d as StaticRpcDumpManifestValue$1, f as StaticRpcDumpSerialization$1, i as dumpFunctions$1, l as StaticRpcDumpManifestQueryEntry$1, n as serializeDumpError$1, o as StaticRpcDumpCollection$1, p as collectStaticRpcDump$1, r as createClientFromDump$1, s as StaticRpcDumpFile$1, t as reviveDumpError$1, u as StaticRpcDumpManifestStaticEntry$1 } from "./index-DH2sBIwd.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/rpc/cache.d.ts
|
|
5
5
|
interface RpcCacheOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as RpcFunctionDefinitionAny, c as RpcDumpClientOptions, l as RpcDumpCollectionOptions, m as RpcDumpStore, n as BirpcReturn, o as RpcDefinitionsToFunctions, p as RpcDumpRecordError } from "./types-
|
|
1
|
+
import { _ as RpcFunctionDefinitionAny, c as RpcDumpClientOptions, l as RpcDumpCollectionOptions, m as RpcDumpStore, n as BirpcReturn, o as RpcDefinitionsToFunctions, p as RpcDumpRecordError } from "./types-BkkQ0Txg.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/rpc/dump/static.d.ts
|
|
4
4
|
type StaticRpcDumpSerialization = 'json' | 'structured-clone';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as AgentResource, B as EntriesToObject, G as
|
|
2
|
-
import { S as RpcFunctionType, g as RpcFunctionDefinition, h as RpcFunctionAgentOptions, i as RpcArgsSchema, w as RpcReturnSchema } from "./types-
|
|
3
|
-
import { t as
|
|
1
|
+
import { $ as AgentResource, B as EntriesToObject, G as DevframeRpcSharedStates, H as Thenable, J as DevframeDiagnosticsDefinition, K as DevframeHost, Q as AgentManifest, U as DevframeRpcClientFunctions, V as PartialWithoutId, W as DevframeRpcServerFunctions, X as DevframeDiagnosticsLogger, Y as DevframeDiagnosticsHost, Z as AgentHandle, _ as RpcStreamingChannel, a as DevframeRuntime, at as DevframeAgentHostEvents, c as defineDevframe, ct as EventsMap, d as DevframeNodeContext, et as AgentResourceContent, f as DevframeNodeRpcSession, g as RpcSharedStateHost, h as RpcSharedStateGetOptions, i as DevframeDeploymentKind, it as DevframeAgentHost, l as ConnectionMeta, m as RpcFunctionsHost, n as DevframeCliOptions, nt as AgentTool, o as DevframeSetupInfo, ot as EventEmitter, p as RpcBroadcastOptions, q as DevframeDefineDiagnosticsOptions, r as DevframeDefinition, rt as AgentToolInput, s as DevframeSpaOptions, st as EventUnsubscribe, t as DevframeBrowserContext, tt as AgentResourceInput, u as DevframeCapabilities, v as RpcStreamingChannelOptions, y as RpcStreamingHost, z as DevframeViewHost } from "./devframe-BuR6n9ZD.mjs";
|
|
2
|
+
import { S as RpcFunctionType, g as RpcFunctionDefinition, h as RpcFunctionAgentOptions, i as RpcArgsSchema, w as RpcReturnSchema } from "./types-BkkQ0Txg.mjs";
|
|
3
|
+
import { t as DevframeNodeRpcSessionMeta } from "./ws-server-C1LjmRnp.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/define.d.ts
|
|
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,
|
|
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
|
|
8
|
-
export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, ConnectionMeta,
|
|
8
|
+
export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, ConnectionMeta, DevframeAgentHost, DevframeAgentHostEvents, DevframeBrowserContext, DevframeCapabilities, DevframeCliOptions, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsDefinition, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeRuntime, DevframeSetupInfo, DevframeSpaOptions, DevframeViewHost, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, PartialWithoutId, RpcBroadcastOptions, RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, Thenable, defineDevframe, defineRpcFunction };
|
package/dist/node/auth.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as SharedState, d as
|
|
2
|
-
import { n as InternalAnonymousAuthStorage } from "../context-
|
|
1
|
+
import { P as SharedState, d as DevframeNodeContext, f as DevframeNodeRpcSession } from "../devframe-BuR6n9ZD.mjs";
|
|
2
|
+
import { n as InternalAnonymousAuthStorage } from "../context-DTRcO_UH.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/node/auth/revoke.d.ts
|
|
5
5
|
/**
|
|
@@ -8,17 +8,17 @@ import { n as InternalAnonymousAuthStorage } from "../context-C9oW88gr.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* Shared between persisted-auth revocation and remote-dock token revocation.
|
|
10
10
|
*/
|
|
11
|
-
declare function revokeActiveConnectionsForToken(context:
|
|
11
|
+
declare function revokeActiveConnectionsForToken(context: DevframeNodeContext, token: string): Promise<void>;
|
|
12
12
|
/**
|
|
13
13
|
* Revoke an auth token: remove from storage and notify all connected clients
|
|
14
14
|
* using this token that they are no longer trusted.
|
|
15
15
|
*/
|
|
16
|
-
declare function revokeAuthToken(context:
|
|
16
|
+
declare function revokeAuthToken(context: DevframeNodeContext, storage: SharedState<InternalAnonymousAuthStorage>, token: string): Promise<void>;
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/node/auth/state.d.ts
|
|
19
19
|
interface PendingAuthRequest {
|
|
20
20
|
clientAuthToken: string;
|
|
21
|
-
session:
|
|
21
|
+
session: DevframeNodeRpcSession;
|
|
22
22
|
ua: string;
|
|
23
23
|
origin: string;
|
|
24
24
|
resolve: (result: {
|
package/dist/node/auth.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as revokeAuthToken, r as humanId, t as revokeActiveConnectionsForToken } from "../revoke-CL0LSAN9.mjs";
|
|
2
2
|
//#region src/node/auth/state.ts
|
|
3
3
|
let pendingAuth = null;
|
|
4
4
|
let tempAuthToken = generateTempId();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as DevframeDeploymentKind, r as DevframeDefinition } from "../devframe-
|
|
2
|
-
import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as
|
|
1
|
+
import { i as DevframeDeploymentKind, r as DevframeDefinition } from "../devframe-BuR6n9ZD.mjs";
|
|
2
|
+
import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-DTRcO_UH.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/_shared.d.ts
|
|
5
5
|
/**
|
|
@@ -13,4 +13,4 @@ import { a as internalContextMap, i as getInternalContext, n as InternalAnonymou
|
|
|
13
13
|
declare function resolveBasePath(def: DevframeDefinition, kind: DevframeDeploymentKind): string;
|
|
14
14
|
declare function normalizeBasePath(base: string): string;
|
|
15
15
|
//#endregion
|
|
16
|
-
export { type
|
|
16
|
+
export { type DevframeInternalContext, type InternalAnonymousAuthStorage, type RemoteTokenRecord, getInternalContext, internalContextMap, normalizeBasePath, resolveBasePath };
|