devframe 0.9.12 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/adapters/build.d.mts +4 -5
  2. package/dist/adapters/build.mjs +2 -2
  3. package/dist/adapters/cac.d.mts +4 -4
  4. package/dist/adapters/cac.mjs +1 -1
  5. package/dist/adapters/dev.d.mts +3 -3
  6. package/dist/adapters/dev.mjs +1 -1
  7. package/dist/adapters/embedded.d.mts +3 -4
  8. package/dist/adapters/initiate.d.mts +6 -7
  9. package/dist/adapters/initiate.mjs +1 -1
  10. package/dist/adapters/mcp.d.mts +4 -4
  11. package/dist/adapters/mcp.mjs +1 -1
  12. package/dist/cli/main.d.mts +2 -3
  13. package/dist/client/index.d.mts +133 -35
  14. package/dist/client/index.mjs +211 -34
  15. package/dist/constants.d.mts +20 -21
  16. package/dist/{context-DwGevWqT.mjs → context-Cdj9z9m2.mjs} +9 -2
  17. package/dist/{dev-CZ1fu4J1.mjs → dev-SPZzBTrH.mjs} +1 -1
  18. package/dist/in-page-channel/index.d.mts +75 -37
  19. package/dist/in-page-channel/index.mjs +56 -22
  20. package/dist/index.d.mts +4 -4
  21. package/dist/internal/index.d.mts +11 -11
  22. package/dist/node/index.d.mts +5 -5
  23. package/dist/node/index.mjs +1 -1
  24. package/dist/nostics-DD6gsDZA.mjs +108 -0
  25. package/dist/recipes/common-rpc-functions.d.mts +6 -7
  26. package/dist/recipes/interactive-auth.d.mts +7 -8
  27. package/dist/rpc/client.d.mts +2 -3
  28. package/dist/rpc/dump.d.mts +16 -17
  29. package/dist/rpc/dump.mjs +1 -1
  30. package/dist/rpc/server.d.mts +2 -3
  31. package/dist/rpc/transports/sse-server.d.mts +4 -5
  32. package/dist/rpc/transports/ws-bun.d.mts +5 -6
  33. package/dist/rpc/transports/ws-deno.d.mts +4 -5
  34. package/dist/{shared-state-CaxB1q0h.mjs → shared-state-eQVYHNqA.mjs} +4 -1
  35. package/dist/utils/agent-tool-name.d.mts +2 -3
  36. package/dist/utils/colors.d.mts +4 -5
  37. package/dist/utils/crypto-token.d.mts +4 -5
  38. package/dist/utils/events.d.mts +2 -3
  39. package/dist/utils/hash.d.mts +2 -3
  40. package/dist/utils/launch-editor.d.mts +2 -3
  41. package/dist/utils/nanoid.d.mts +2 -3
  42. package/dist/utils/open.d.mts +2 -3
  43. package/dist/utils/remote-assets.d.mts +2 -3
  44. package/dist/utils/serve-static.d.mts +6 -7
  45. package/dist/utils/shared-state.mjs +1 -1
  46. package/dist/utils/simple-schema.d.mts +17 -18
  47. package/dist/utils/streaming-channel.mjs +4 -1
  48. package/dist/utils/structured-clone.d.mts +5 -6
  49. package/dist/utils/when.d.mts +6 -7
  50. package/dist/{write-BuLCrn9h.mjs → write-D2AJqVT8.mjs} +1 -1
  51. package/package.json +4 -4
@@ -1,8 +1,17 @@
1
- import { t as DEVFRAME_EVENTS } from "../events-BV4Dj59a.mjs";
1
+ import { n as DEVFRAME_EVENTS, t as defineDiagnostics } from "../nostics-DD6gsDZA.mjs";
2
2
  import { createEventEmitter } from "../utils/events.mjs";
3
- import { t as createSharedState } from "../shared-state-CaxB1q0h.mjs";
3
+ import { t as createSharedState } from "../shared-state-eQVYHNqA.mjs";
4
4
  import { nanoid } from "../utils/nanoid.mjs";
5
5
  import { createBirpc } from "birpc";
6
+ //#region src/in-page-channel/diagnostics.ts
7
+ const diagnostics = /* #__PURE__ */ defineDiagnostics({
8
+ docsBase: "https://devfra.me/errors",
9
+ codes: { DF0077: {
10
+ why: (p) => `In-page channel function "${p.name}" is not registered on this endpoint.`,
11
+ fix: "Declare the function in this endpoint's `functions` option before subscribing with `on()`."
12
+ } }
13
+ });
14
+ //#endregion
6
15
  //#region src/in-page-channel/protocol.ts
7
16
  /**
8
17
  * Wire protocol of the in-page channel handshake and its port-level control
@@ -167,19 +176,39 @@ function deserializeResult(codec, result) {
167
176
  * then serialize hook + `jsonSerializable` enforcement on the result.
168
177
  */
169
178
  function createLocalFunctionRegistry(codec) {
170
- const wrapped = /* @__PURE__ */ new Map();
179
+ const definitions = /* @__PURE__ */ new Map();
180
+ const listeners = /* @__PURE__ */ new Map();
171
181
  return {
172
182
  register(definition) {
173
- wrapped.set(definition.name, async (...rawArgs) => {
183
+ definitions.set(definition.name, definition);
184
+ },
185
+ on(name, listener) {
186
+ if (!definitions.has(name)) throw diagnostics.DF0077({ name });
187
+ let registered = listeners.get(name);
188
+ if (!registered) {
189
+ registered = /* @__PURE__ */ new Set();
190
+ listeners.set(name, registered);
191
+ }
192
+ registered.add(listener);
193
+ return () => {
194
+ registered.delete(listener);
195
+ if (registered.size === 0) listeners.delete(name);
196
+ };
197
+ },
198
+ resolve(name) {
199
+ const definition = definitions.get(name);
200
+ const registered = listeners.get(name);
201
+ if (!definition && !registered?.size) return void 0;
202
+ return async (...rawArgs) => {
174
203
  const args = codec.deserialize ? rawArgs.map(codec.deserialize) : rawArgs;
175
- if (definition.jsonSerializable) assertJsonSerializable(args, "its arguments", definition.name);
176
- if (definition.args?.length) await validateArgs(definition.name, definition.args, args);
177
- const result = await definition.handler(...args);
178
- if (definition.jsonSerializable) assertJsonSerializable(result, "its return value", definition.name);
204
+ if (definition?.jsonSerializable) assertJsonSerializable(args, "its arguments", definition.name);
205
+ if (definition?.args?.length) await validateArgs(definition.name, definition.args, args);
206
+ const result = await definition?.handler?.(...args);
207
+ for (const listener of [...listeners.get(name) ?? []]) listener(...args);
208
+ if (definition?.jsonSerializable) assertJsonSerializable(result, "its return value", definition.name);
179
209
  return codec.serialize && result !== void 0 ? codec.serialize(result) : result;
180
- });
181
- },
182
- resolve: (name) => wrapped.get(name)
210
+ };
211
+ }
183
212
  };
184
213
  }
185
214
  function wrapPostError(error) {
@@ -449,7 +478,7 @@ function createPageScriptChannel(options) {
449
478
  let closed = false;
450
479
  let heartbeatTimer;
451
480
  const registry = createLocalFunctionRegistry(codec);
452
- for (const [fnName, definition] of Object.entries(options.functions ?? {})) registry.register({
481
+ for (const [fnName, definition] of Object.entries(options.functions)) registry.register({
453
482
  ...definition,
454
483
  name: fnName
455
484
  });
@@ -550,6 +579,15 @@ function createPageScriptChannel(options) {
550
579
  }
551
580
  };
552
581
  win?.addEventListener("message", onWindowMessage);
582
+ const emit = (fnName, ...args) => {
583
+ const wireArgs = serializeArgs(codec, args);
584
+ for (const peer of peers.values()) peer.attached.rpc.$callRaw({
585
+ method: fnName,
586
+ args: wireArgs,
587
+ event: true,
588
+ optional: true
589
+ }).catch(() => {});
590
+ };
553
591
  return {
554
592
  name,
555
593
  instanceId,
@@ -560,15 +598,9 @@ function createPageScriptChannel(options) {
560
598
  on: events.on,
561
599
  once: events.once
562
600
  },
563
- callEvent: (fnName, ...args) => {
564
- const wireArgs = serializeArgs(codec, args);
565
- for (const peer of peers.values()) peer.attached.rpc.$callRaw({
566
- method: fnName,
567
- args: wireArgs,
568
- event: true,
569
- optional: true
570
- }).catch(() => {});
571
- },
601
+ emit,
602
+ callEvent: emit,
603
+ on: (fnName, listener) => registry.on(fnName, listener),
572
604
  sharedState: stateHost,
573
605
  addPanelPort: (port) => addPeer(port, `transport:${nanoid(8)}`),
574
606
  close: () => {
@@ -615,7 +647,7 @@ function connectPanelChannel(options) {
615
647
  const canHandshake = !!win && targets.length > 0;
616
648
  const events = createEventEmitter();
617
649
  const registry = createLocalFunctionRegistry(codec);
618
- for (const [fnName, definition] of Object.entries(options.functions ?? {})) registry.register({
650
+ for (const [fnName, definition] of Object.entries(options.functions)) registry.register({
619
651
  ...definition,
620
652
  name: fnName
621
653
  });
@@ -794,7 +826,9 @@ function connectPanelChannel(options) {
794
826
  });
795
827
  },
796
828
  call: (fnName, ...args) => enqueueCall(fnName, serializeArgs(codec, args)),
829
+ emit: (fnName, ...args) => sendEvent(fnName, serializeArgs(codec, args)),
797
830
  callEvent: (fnName, ...args) => sendEvent(fnName, serializeArgs(codec, args)),
831
+ on: (fnName, listener) => registry.on(fnName, listener),
798
832
  sharedState: stateHost,
799
833
  close: () => {
800
834
  if (status === "closed") return;
package/dist/index.d.mts CHANGED
@@ -5,17 +5,17 @@ import { $ as DevframeServiceOf, At as AgentHandle, B as DevframeSetupInfo, Bt a
5
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
6
  import { i as DevframeDefineDiagnosticsOptions } from "./nostics-0sKe5HIj.mjs";
7
7
  //#region src/define.d.ts
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>;
8
+ export 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
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
- declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
13
+ export declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
14
14
  /**
15
15
  * @deprecated Read {@link DevframeDefinition.clientAssets} from the definition
16
16
  * directly. This helper is internal machinery that was never meant to be part
17
17
  * of the public API and is scheduled for removal.
18
18
  */
19
- declare function resolveClientAssets(d: DevframeDefinition): StaticAssetsSource | undefined;
19
+ export 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 McpAuthorization, type McpRouteOptions, type McpSetting, 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, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, DevframeRpcConnection, DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpRouteOptions, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
@@ -15,7 +15,7 @@ import { n as CreateContextRpcServerOptions, r as createContextRpcServer, t as C
15
15
  * Internal: exposed to first-party integrations via `devframe/internal`, not
16
16
  * part of the stable public API.
17
17
  */
18
- declare function resolveClientAssets(d: DevframeDefinition): StaticAssetsSource | undefined;
18
+ export declare function resolveClientAssets(d: DevframeDefinition): StaticAssetsSource | undefined;
19
19
  //#endregion
20
20
  //#region src/node/agent-args.d.ts
21
21
  /**
@@ -43,7 +43,7 @@ type AgentArgsFallback = 'wrap' | 'drop';
43
43
  * - an empty object becomes a zero-argument call
44
44
  * - anything else follows the {@link AgentArgsFallback}
45
45
  */
46
- declare function coerceAgentPositionalArgs(args: unknown, schemas: readonly unknown[] | undefined, fallback?: AgentArgsFallback): unknown[];
46
+ export declare function coerceAgentPositionalArgs(args: unknown, schemas: readonly unknown[] | undefined, fallback?: AgentArgsFallback): unknown[];
47
47
  //#endregion
48
48
  //#region src/node/diagnostics.d.ts
49
49
  /**
@@ -51,7 +51,7 @@ declare function coerceAgentPositionalArgs(args: unknown, schemas: readonly unkn
51
51
  * owns DF0037–DF0041), so this file alone doesn't show the next free
52
52
  * number; check `docs/content/6.errors/` for the full allocation before adding one.
53
53
  */
54
- declare const diagnostics: import("nostics").Diagnostics<{
54
+ export declare const diagnostics: import("nostics").Diagnostics<{
55
55
  readonly DF0006: {
56
56
  readonly why: (p: {
57
57
  name: string;
@@ -363,7 +363,7 @@ declare const diagnostics: import("nostics").Diagnostics<{
363
363
  * `ctx.rpc.definitions`, and accepts plugin-registered tools /
364
364
  * resources via `registerTool` / `registerResource`.
365
365
  */
366
- declare class DevframeAgentHost implements DevframeAgentHost$1 {
366
+ export declare class DevframeAgentHost implements DevframeAgentHost$1 {
367
367
  readonly context: DevframeNodeContext;
368
368
  readonly events: EventEmitter<DevframeAgentHostEvents>;
369
369
  private readonly tools;
@@ -393,7 +393,7 @@ declare class DevframeAgentHost implements DevframeAgentHost$1 {
393
393
  }
394
394
  //#endregion
395
395
  //#region src/node/host-h3.d.ts
396
- interface CreateH3DevframeHostOptions {
396
+ export interface CreateH3DevframeHostOptions {
397
397
  /**
398
398
  * Host the standalone server listens on, e.g. `http://localhost:9999`.
399
399
  * Consumed by `resolveOrigin` for dock entries that need an absolute URL.
@@ -427,7 +427,7 @@ interface CreateH3DevframeHostOptions {
427
427
  /**
428
428
  * h3-backed {@link DevframeHost}, used by the standalone CLI adapter.
429
429
  */
430
- declare function createH3DevframeHost(options: CreateH3DevframeHostOptions): DevframeHost;
430
+ export declare function createH3DevframeHost(options: CreateH3DevframeHostOptions): DevframeHost;
431
431
  //#endregion
432
432
  //#region src/node/import-runtime-module.d.ts
433
433
  /**
@@ -438,10 +438,10 @@ declare function createH3DevframeHost(options: CreateH3DevframeHostOptions): Dev
438
438
  *
439
439
  * @internal
440
440
  */
441
- declare function importRuntimeModule<T = unknown>(specifier: string): Promise<T>;
441
+ export declare function importRuntimeModule<T = unknown>(specifier: string): Promise<T>;
442
442
  //#endregion
443
443
  //#region src/node/utils.d.ts
444
- declare function normalizeHttpServerUrl(host: string, port: number | string): string;
444
+ export declare function normalizeHttpServerUrl(host: string, port: number | string): string;
445
445
  //#endregion
446
446
  //#region src/rpc/wire-codec.d.ts
447
447
  /**
@@ -464,7 +464,7 @@ interface RpcWireCodec {
464
464
  *
465
465
  * @internal
466
466
  */
467
- declare function createRpcWireCodec(definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>): RpcWireCodec;
467
+ export declare function createRpcWireCodec(definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>): RpcWireCodec;
468
468
  /**
469
469
  * Peek at a wire frame's birpc envelope without engaging a codec's
470
470
  * request-id bookkeeping; used by the SSE transport to route a frame
@@ -473,9 +473,9 @@ declare function createRpcWireCodec(definitions?: ReadonlyMap<string, Pick<RpcFu
473
473
  *
474
474
  * @internal
475
475
  */
476
- declare function peekRpcWireFrame(raw: string): {
476
+ export declare function peekRpcWireFrame(raw: string): {
477
477
  t?: string;
478
478
  i?: string;
479
479
  };
480
480
  //#endregion
481
- export { type AgentArgsFallback, type ContextRpcServer, type CreateContextRpcServerOptions, CreateH3DevframeHostOptions, type CreateInstanceShellOptions, DevframeAgentHost, type DevframeInstanceRecord, type DevframeInstanceRegistration, type InstanceRegisterConfig, type InstanceShell, type InstanceShellApi, type InstanceShellInit, type InstanceShellInternals, type InstanceWsTier, type ResolvedMcpConfig, type RpcWireCodec, type StartedServer, coerceAgentPositionalArgs, createContextRpcServer, createH3DevframeHost, createInstanceShell, createRpcWireCodec, diagnostics, importRuntimeModule, listLiveDevframeInstances, loadAutoMcpAdapter, normalizeBasePath, normalizeHttpServerUrl, peekRpcWireFrame, registerDevframeInstance, resolveBasePath, resolveClientAssets, resolveInstanceRegister, resolveMcpConfig, samePath };
481
+ export { type AgentArgsFallback, type ContextRpcServer, type CreateContextRpcServerOptions, type CreateInstanceShellOptions, type DevframeInstanceRecord, type DevframeInstanceRegistration, type InstanceRegisterConfig, type InstanceShell, type InstanceShellApi, type InstanceShellInit, type InstanceShellInternals, type InstanceWsTier, type ResolvedMcpConfig, type RpcWireCodec, type StartedServer, createContextRpcServer, createInstanceShell, listLiveDevframeInstances, loadAutoMcpAdapter, normalizeBasePath, registerDevframeInstance, resolveBasePath, resolveInstanceRegister, resolveMcpConfig, samePath };
@@ -3,7 +3,7 @@ import { v as RpcFunctionDefinitionAny } from "../types-Dq4i156u.mjs";
3
3
  import { k as SharedState, l as RpcFunctionsHost, o as DevframeNodeContext, xt as DevframeHost } from "../context-BBWPLDHh.mjs";
4
4
  import { BirpcGroup } from "birpc";
5
5
  //#region src/node/context.d.ts
6
- interface CreateHostContextOptions {
6
+ export interface CreateHostContextOptions {
7
7
  cwd: string;
8
8
  workspaceRoot?: string;
9
9
  mode: 'dev' | 'build';
@@ -32,15 +32,15 @@ interface CreateHostContextOptions {
32
32
  * `createKitContext` attaches `docks`, `terminals`, `messages`, and
33
33
  * `commands` when mounted into Vite DevTools.
34
34
  */
35
- declare function createHostContext(options: CreateHostContextOptions): Promise<DevframeNodeContext>;
35
+ export declare function createHostContext(options: CreateHostContextOptions): Promise<DevframeNodeContext>;
36
36
  //#endregion
37
37
  //#region src/node/storage.d.ts
38
- interface CreateStorageOptions<T extends object> {
38
+ export interface CreateStorageOptions<T extends object> {
39
39
  filepath: string;
40
40
  initialValue: T;
41
41
  mergeInitialValue?: false | ((initialValue: T, savedValue: T) => T);
42
42
  debounce?: number;
43
43
  }
44
- declare function createStorage<T extends object>(options: CreateStorageOptions<T>): SharedState<T>;
44
+ export declare function createStorage<T extends object>(options: CreateStorageOptions<T>): SharedState<T>;
45
45
  //#endregion
46
- export { CreateHostContextOptions, CreateStorageOptions, type RpcFunctionsHost, createHostContext, createStorage };
46
+ export type { RpcFunctionsHost };
@@ -1,3 +1,3 @@
1
- import { t as createHostContext } from "../context-DwGevWqT.mjs";
1
+ import { t as createHostContext } from "../context-Cdj9z9m2.mjs";
2
2
  import { t as createStorage } from "../storage-B70AXK64.mjs";
3
3
  export { createHostContext, createStorage };
@@ -0,0 +1,108 @@
1
+ import { colors } from "./utils/colors.mjs";
2
+ import { defineDiagnostics } from "nostics";
3
+ import { ansiFormatter } from "nostics/formatters/ansi";
4
+ //#region src/events.ts
5
+ /**
6
+ * Centralized registry of the core devframe event names: the node-side host
7
+ * bus events, the client RPC connection events, and the server→client
8
+ * broadcast notifications, so these names live in one place instead of
9
+ * scattered string literals.
10
+ *
11
+ * **Keep this in sync with [`docs/content/8.references/3.events.md`](../../../docs/content/8.references/3.events.md)**
12
+ * (the "Core devframe events" section): every name here appears in that page's
13
+ * tables, and every name there resolves to an entry here. Add, rename, or
14
+ * remove a name in both places in the same change, and reference
15
+ * `DEVFRAME_EVENTS.*` from call sites instead of re-typing a literal.
16
+ *
17
+ * This map covers **notifications** (events, broadcasts). The request/response
18
+ * RPC endpoints of the shared-state, streaming, and auth-handshake protocols
19
+ * (`devframe:rpc:server-state:*`, `devframe:streaming:subscribe`,
20
+ * `anonymous:devframe:auth`, …) are defined at their handlers and typed in
21
+ * `types/rpc-augments.ts`; they aren't events and stay out of this map.
22
+ *
23
+ * The `EventEmitter` maps (`RpcClientEvents`, `DevframeAgentHostEvents`) and the
24
+ * `DevframeRpcClientFunctions` augmentation declare these names as type-level
25
+ * keys (a literal is unavoidable in a type position); those declarations mirror
26
+ * this map and move with it.
27
+ */
28
+ const DEVFRAME_EVENTS = {
29
+ /**
30
+ * Node-side host `EventEmitter` events. The agent host (`ctx.agent.events`)
31
+ * emits these as its tool/resource surface changes; protocol adapters (e.g.
32
+ * MCP) subscribe to re-publish their manifest.
33
+ */
34
+ bus: {
35
+ agentManifestChanged: "agent:manifest:changed",
36
+ agentToolRegistered: "agent:tool:registered",
37
+ agentToolUnregistered: "agent:tool:unregistered",
38
+ agentResourceRegistered: "agent:resource:registered",
39
+ agentResourceUnregistered: "agent:resource:unregistered"
40
+ },
41
+ /**
42
+ * Client-side RPC connection `EventEmitter` events (`rpc.events`) a UI
43
+ * subscribes to for connection lifecycle and error surfacing.
44
+ */
45
+ client: {
46
+ isTrustedUpdated: "rpc:is-trusted:updated",
47
+ error: "rpc:error",
48
+ connectionStatus: "connection:status",
49
+ connectionError: "connection:error"
50
+ },
51
+ /**
52
+ * Broadcast notifications the server pushes to clients (server → client),
53
+ * `devframe:` prefix. The paired request methods (subscribe/get/set/…) are
54
+ * RPC endpoints, not events, and are omitted deliberately.
55
+ */
56
+ broadcast: {
57
+ authRevoked: "devframe:auth:revoked",
58
+ clientStateUpdated: "devframe:rpc:client-state:updated",
59
+ clientStatePatch: "devframe:rpc:client-state:patch",
60
+ streamingChunk: "devframe:streaming:chunk",
61
+ streamingEnd: "devframe:streaming:end",
62
+ streamingUploadCancel: "devframe:streaming:upload-cancel"
63
+ },
64
+ /**
65
+ * In-page channel notifications the page script pushes to its panels
66
+ * (page script → panel), `devframe:` prefix. The paired request methods
67
+ * (`devframe:in-page:page-state:subscribe`/`set`/`patch`) are call
68
+ * endpoints, not events, and are defined at their handlers
69
+ * (`in-page-channel/state.ts`).
70
+ */
71
+ inPageChannel: {
72
+ panelStateUpdated: "devframe:in-page:panel-state:updated",
73
+ panelStatePatch: "devframe:in-page:panel-state:patch"
74
+ },
75
+ /** `postMessage` channels the runtime posts across window boundaries. */
76
+ postMessage: {
77
+ remoteAssetsError: "devframe:remote-assets-error",
78
+ inPageChannel: "devframe:in-page-channel"
79
+ }
80
+ };
81
+ //#endregion
82
+ //#region src/utils/nostics.ts
83
+ const formatAnsi = ansiFormatter(colors);
84
+ /**
85
+ * The reporter every {@link defineDiagnostics} call below wires in ahead of
86
+ * any caller-supplied ones: prints the diagnostic through devframe's own
87
+ * ANSI colors via `console[method]` (default `'warn'`).
88
+ */
89
+ function devframeReporter(d, { method = "warn" } = {}) {
90
+ console[method](formatAnsi(d));
91
+ }
92
+ /**
93
+ * Drop-in replacement for `nostics`'s `defineDiagnostics()` with devframe's
94
+ * ANSI console reporter pre-wired ahead of any `reporters` passed in. Every
95
+ * `diagnostics.ts` in devframe core, `@devframes/hub`, `@devframes/json-render`,
96
+ * and the built-in plugins defines its codes through this instead of
97
+ * `nostics`'s own `defineDiagnostics`; the reporter registration lives
98
+ * here, once, so none of them need to build their own reporter (`colors`,
99
+ * `ansiFormatter`) or take a direct dependency on `nostics` themselves.
100
+ */
101
+ function defineDiagnostics$1(options) {
102
+ return defineDiagnostics({
103
+ ...options,
104
+ reporters: [devframeReporter, ...options.reporters ?? []]
105
+ });
106
+ }
107
+ //#endregion
108
+ export { DEVFRAME_EVENTS as n, defineDiagnostics$1 as t };
@@ -10,9 +10,9 @@ import { SimpleSchema } from "../utils/simple-schema.mjs";
10
10
  * is restricted to this union, so the RPC surface can't be used to spawn an
11
11
  * arbitrary command.
12
12
  */
13
- type KnownEditor = 'atom' | 'subl' | 'sublime' | 'sublime_text' | 'wstorm' | 'charm' | 'zed' | 'notepad++' | 'vim' | 'mvim' | 'joe' | 'gvim' | 'emacs' | 'emacsclient' | 'rmate' | 'mate' | 'code' | 'code-insiders' | 'codium' | 'vscodium' | 'trae' | 'antigravity' | 'cursor' | 'appcode' | 'clion' | 'idea' | 'phpstorm' | 'pycharm' | 'rubymine' | 'webstorm' | 'goland' | 'rider';
13
+ export type KnownEditor = 'atom' | 'subl' | 'sublime' | 'sublime_text' | 'wstorm' | 'charm' | 'zed' | 'notepad++' | 'vim' | 'mvim' | 'joe' | 'gvim' | 'emacs' | 'emacsclient' | 'rmate' | 'mate' | 'code' | 'code-insiders' | 'codium' | 'vscodium' | 'trae' | 'antigravity' | 'cursor' | 'appcode' | 'clion' | 'idea' | 'phpstorm' | 'pycharm' | 'rubymine' | 'webstorm' | 'goland' | 'rider';
14
14
  /** Runtime list of every {@link KnownEditor}. */
15
- declare const KNOWN_EDITORS: KnownEditor[];
15
+ export declare const KNOWN_EDITORS: KnownEditor[];
16
16
  /**
17
17
  * Prebuilt RPC action that opens a file in the user's configured editor.
18
18
  *
@@ -38,7 +38,7 @@ declare const KNOWN_EDITORS: KnownEditor[];
38
38
  * host-level installation shared by every plugin and feature-detectable from
39
39
  * clients, with workspace-root path containment on top of the editor gating.
40
40
  */
41
- declare const openInEditor: {
41
+ export declare const openInEditor: {
42
42
  name: "devframe:open-in-editor";
43
43
  type?: "action" | undefined;
44
44
  cacheable?: boolean;
@@ -68,7 +68,7 @@ declare const openInEditor: {
68
68
  * host-level installation shared by every plugin and feature-detectable from
69
69
  * clients, with workspace-root path containment.
70
70
  */
71
- declare const openInFinder: {
71
+ export declare const openInFinder: {
72
72
  name: "devframe:open-in-finder";
73
73
  type?: "action" | undefined;
74
74
  cacheable?: boolean;
@@ -95,7 +95,7 @@ declare const openInFinder: {
95
95
  *
96
96
  * @deprecated Use the `@devframes/service-open` wire service instead.
97
97
  */
98
- declare const commonRpcFunctions: readonly [{
98
+ export declare const commonRpcFunctions: readonly [{
99
99
  name: "devframe:open-in-editor";
100
100
  type?: "action" | undefined;
101
101
  cacheable?: boolean;
@@ -124,5 +124,4 @@ declare const commonRpcFunctions: readonly [{
124
124
  __cache?: WeakMap<object, Thenable<RpcFunctionSetupResult<[string], Thenable<void>>>> | undefined;
125
125
  __promise?: Thenable<RpcFunctionSetupResult<[string], Thenable<void>>> | undefined;
126
126
  }];
127
- //#endregion
128
- export { KNOWN_EDITORS, KnownEditor, commonRpcFunctions, openInEditor, openInFinder };
127
+ //#endregion
@@ -2,7 +2,7 @@ import { Tt as DevframeAuthHandler, o as DevframeNodeContext, s as DevframeNodeR
2
2
  import "../index-1ezCLThh.mjs";
3
3
  import { ColorFn } from "../utils/colors.mjs";
4
4
  //#region src/recipes/interactive-auth.d.ts
5
- interface CreateInteractiveAuthOptions {
5
+ export interface CreateInteractiveAuthOptions {
6
6
  /**
7
7
  * Static, pre-shared bearer tokens that are always trusted, for CI runs
8
8
  * or shared machines where the interactive code prompt would only get in
@@ -37,19 +37,19 @@ interface CreateInteractiveAuthOptions {
37
37
  serverUrl?: () => string;
38
38
  }
39
39
  /** Signature of `options.banner`: render the current auth code + magic-link URL. */
40
- type AuthBannerFunction = (info: {
40
+ export type AuthBannerFunction = (info: {
41
41
  code: string;
42
42
  url: string;
43
43
  }) => void;
44
44
  /** Palette for {@link createAuthBanner}'s box - one color per part, so a host can rebrand a subset. */
45
- interface CreateAuthBannerColorsOptions {
45
+ export interface CreateAuthBannerColorsOptions {
46
46
  border: ColorFn;
47
47
  title: ColorFn;
48
48
  label: ColorFn;
49
49
  code: ColorFn;
50
50
  url: ColorFn;
51
51
  }
52
- interface CreateAuthBannerOptions {
52
+ export interface CreateAuthBannerOptions {
53
53
  /** Box title. Defaults to `'Devframe'` - set to your product name for branding. */
54
54
  title?: string;
55
55
  /** Palette overrides; unset colors fall back to dim/bold/cyan defaults. */
@@ -62,7 +62,7 @@ interface CreateAuthBannerOptions {
62
62
  * yourself to rebrand the box (`title` / `colors`) and pass the result as
63
63
  * `options.banner`.
64
64
  */
65
- declare function createAuthBanner(options?: CreateAuthBannerOptions): AuthBannerFunction;
65
+ export declare function createAuthBanner(options?: CreateAuthBannerOptions): AuthBannerFunction;
66
66
  /**
67
67
  * Package the interactive OTP auth protocol devframe's primitives
68
68
  * (`exchangeTempAuthCode`, `verifyAuthToken`, `revokeAuthToken`,
@@ -84,6 +84,5 @@ declare function createAuthBanner(options?: CreateAuthBannerOptions): AuthBanner
84
84
  * // the whole handler to `initDevframe` / `initHub` via their `auth` option.
85
85
  * ```
86
86
  */
87
- declare function createInteractiveAuth(context: DevframeNodeContext, options?: CreateInteractiveAuthOptions): DevframeAuthHandler;
88
- //#endregion
89
- export { AuthBannerFunction, CreateAuthBannerColorsOptions, CreateAuthBannerOptions, CreateInteractiveAuthOptions, createAuthBanner, createInteractiveAuth };
87
+ export declare function createInteractiveAuth(context: DevframeNodeContext, options?: CreateInteractiveAuthOptions): DevframeAuthHandler;
88
+ //#endregion
@@ -1,8 +1,7 @@
1
1
  import { BirpcOptions, BirpcReturn, ChannelOptions } from "birpc";
2
2
  //#region src/rpc/client.d.ts
3
- declare function createRpcClient<ServerFunctions extends object = Record<string, never>, ClientFunctions extends object = Record<string, never>>(functions: ClientFunctions, options: {
3
+ export declare function createRpcClient<ServerFunctions extends object = Record<string, never>, ClientFunctions extends object = Record<string, never>>(functions: ClientFunctions, options: {
4
4
  channel: ChannelOptions;
5
5
  rpcOptions?: Partial<BirpcOptions<ServerFunctions, ClientFunctions, boolean>>;
6
6
  }): BirpcReturn<ServerFunctions, ClientFunctions, false>;
7
- //#endregion
8
- export { createRpcClient };
7
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  import { h as RpcDumpStore, l as RpcDumpClientOptions, m as RpcDumpRecordError, n as BirpcReturn, o as RpcDefinitionsToFunctions, u as RpcDumpCollectionOptions, v as RpcFunctionDefinitionAny } from "../types-Dq4i156u.mjs";
2
2
  //#region src/rpc/dump/collect.d.ts
3
- declare function dumpFunctions<T extends readonly RpcFunctionDefinitionAny[]>(definitions: T, context?: any, options?: RpcDumpCollectionOptions): Promise<RpcDumpStore<RpcDefinitionsToFunctions<T>>>;
3
+ export declare function dumpFunctions<T extends readonly RpcFunctionDefinitionAny[]>(definitions: T, context?: any, options?: RpcDumpCollectionOptions): Promise<RpcDumpStore<RpcDefinitionsToFunctions<T>>>;
4
4
  /**
5
5
  * Creates a client that serves pre-computed results from a dump store.
6
6
  * Uses argument hashing to match calls to stored records.
@@ -11,12 +11,12 @@ declare function dumpFunctions<T extends readonly RpcFunctionDefinitionAny[]>(de
11
11
  * await client.greet('Alice')
12
12
  * ```
13
13
  */
14
- declare function createClientFromDump<T extends Record<string, any>>(store: RpcDumpStore<T>, options?: RpcDumpClientOptions): BirpcReturn<T>;
14
+ export declare function createClientFromDump<T extends Record<string, any>>(store: RpcDumpStore<T>, options?: RpcDumpClientOptions): BirpcReturn<T>;
15
15
  /**
16
16
  * Filters function definitions to only those with dump definitions.
17
17
  * Note: Only checks the definition itself, not setup results.
18
18
  */
19
- declare function getDefinitionsWithDumps<T extends readonly RpcFunctionDefinitionAny[]>(definitions: T): RpcFunctionDefinitionAny[];
19
+ export declare function getDefinitionsWithDumps<T extends readonly RpcFunctionDefinitionAny[]>(definitions: T): RpcFunctionDefinitionAny[];
20
20
  //#endregion
21
21
  //#region src/rpc/dump/error.d.ts
22
22
  /**
@@ -27,32 +27,32 @@ declare function getDefinitionsWithDumps<T extends readonly RpcFunctionDefinitio
27
27
  *
28
28
  * Non-`Error` throws are wrapped as `{ name: 'Error', message: String(thrown) }`.
29
29
  */
30
- declare function serializeDumpError(error: unknown): RpcDumpRecordError;
30
+ export declare function serializeDumpError(error: unknown): RpcDumpRecordError;
31
31
  /**
32
32
  * Inverse of {@link serializeDumpError}: rebuild a thrown `Error` from
33
33
  * the plain object stored in a dump record. Preserves `cause`, restores
34
34
  * the original `name`, and re-attaches any custom own properties.
35
35
  */
36
- declare function reviveDumpError(stored: RpcDumpRecordError): Error;
36
+ export declare function reviveDumpError(stored: RpcDumpRecordError): Error;
37
37
  //#endregion
38
38
  //#region src/rpc/dump/static.d.ts
39
- type StaticRpcDumpSerialization = 'json' | 'structured-clone';
40
- interface StaticRpcDumpManifestStaticEntry {
39
+ export type StaticRpcDumpSerialization = 'json' | 'structured-clone';
40
+ export interface StaticRpcDumpManifestStaticEntry {
41
41
  type: 'static';
42
42
  path: string;
43
43
  /** Encoder used when this entry's file was written. Default: `'json'`. */
44
44
  serialization?: StaticRpcDumpSerialization;
45
45
  }
46
- interface StaticRpcDumpManifestQueryEntry {
46
+ export interface StaticRpcDumpManifestQueryEntry {
47
47
  type: 'query';
48
48
  records: Record<string, string>;
49
49
  fallback?: string;
50
50
  /** Encoder used when each record/fallback file was written. Default: `'json'`. */
51
51
  serialization?: StaticRpcDumpSerialization;
52
52
  }
53
- type StaticRpcDumpManifestValue = StaticRpcDumpManifestStaticEntry | StaticRpcDumpManifestQueryEntry | any;
54
- type StaticRpcDumpManifest = Record<string, StaticRpcDumpManifestValue>;
55
- interface StaticRpcDumpFile {
53
+ export type StaticRpcDumpManifestValue = StaticRpcDumpManifestStaticEntry | StaticRpcDumpManifestQueryEntry | any;
54
+ export type StaticRpcDumpManifest = Record<string, StaticRpcDumpManifestValue>;
55
+ export interface StaticRpcDumpFile {
56
56
  /** Whether this file was written via `JSON.stringify` or `structured-clone-es.stringify`. */
57
57
  serialization: StaticRpcDumpSerialization;
58
58
  /** Function name the file belongs to, used to scope `DF0019` errors during write. */
@@ -60,14 +60,14 @@ interface StaticRpcDumpFile {
60
60
  /** Payload to encode. */
61
61
  data: unknown;
62
62
  }
63
- interface StaticRpcDumpCollection {
63
+ export interface StaticRpcDumpCollection {
64
64
  manifest: StaticRpcDumpManifest;
65
65
  files: Record<string, StaticRpcDumpFile>;
66
66
  }
67
- declare function collectStaticRpcDump(definitions: Iterable<RpcFunctionDefinitionAny>, context: any): Promise<StaticRpcDumpCollection>;
67
+ export declare function collectStaticRpcDump(definitions: Iterable<RpcFunctionDefinitionAny>, context: any): Promise<StaticRpcDumpCollection>;
68
68
  //#endregion
69
69
  //#region src/rpc/dump/write.d.ts
70
- interface WriteStaticRpcDumpOptions {
70
+ export interface WriteStaticRpcDumpOptions {
71
71
  /**
72
72
  * Pretty-print RPC dump JSON files. Defaults to `false` so payload
73
73
  * shards (which can be multiple MB for graph-heavy tools) ship
@@ -80,6 +80,5 @@ interface WriteStaticRpcDumpOptions {
80
80
  * the `__rpc-dump/index.json` manifest, under `outDir`. Shared by the build
81
81
  * adapter (`createBuild`) and `@devframes/hub`'s `buildHub`.
82
82
  */
83
- declare function writeStaticRpcDump(dump: StaticRpcDumpCollection, outDir: string, options?: WriteStaticRpcDumpOptions): Promise<void>;
84
- //#endregion
85
- export { StaticRpcDumpCollection, StaticRpcDumpFile, StaticRpcDumpManifest, StaticRpcDumpManifestQueryEntry, StaticRpcDumpManifestStaticEntry, StaticRpcDumpManifestValue, StaticRpcDumpSerialization, WriteStaticRpcDumpOptions, collectStaticRpcDump, createClientFromDump, dumpFunctions, getDefinitionsWithDumps, reviveDumpError, serializeDumpError, writeStaticRpcDump };
83
+ export declare function writeStaticRpcDump(dump: StaticRpcDumpCollection, outDir: string, options?: WriteStaticRpcDumpOptions): Promise<void>;
84
+ //#endregion
package/dist/rpc/dump.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as getDefinitionsWithDumps, i as dumpFunctions, n as collectStaticRpcDump, o as reviveDumpError, r as createClientFromDump, s as serializeDumpError, t as writeStaticRpcDump } from "../write-BuLCrn9h.mjs";
1
+ import { a as getDefinitionsWithDumps, i as dumpFunctions, n as collectStaticRpcDump, o as reviveDumpError, r as createClientFromDump, s as serializeDumpError, t as writeStaticRpcDump } from "../write-D2AJqVT8.mjs";
2
2
  export { collectStaticRpcDump, createClientFromDump, dumpFunctions, getDefinitionsWithDumps, reviveDumpError, serializeDumpError, writeStaticRpcDump };
@@ -1,7 +1,6 @@
1
1
  import { BirpcGroup, EventOptions } from "birpc";
2
2
  //#region src/rpc/server.d.ts
3
- declare function createRpcServer<ClientFunctions extends object = Record<string, never>, ServerFunctions extends object = Record<string, never>>(functions: ServerFunctions, options?: {
3
+ export declare function createRpcServer<ClientFunctions extends object = Record<string, never>, ServerFunctions extends object = Record<string, never>>(functions: ServerFunctions, options?: {
4
4
  rpcOptions?: EventOptions<ClientFunctions, ServerFunctions, false>;
5
5
  }): BirpcGroup<ClientFunctions, ServerFunctions, false>;
6
- //#endregion
7
- export { createRpcServer };
6
+ //#endregion
@@ -2,7 +2,7 @@ import { v as RpcFunctionDefinitionAny } from "../../types-Dq4i156u.mjs";
2
2
  import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "../../ws-server-D2nv68Hg.mjs";
3
3
  import { BirpcGroup } from "birpc";
4
4
  //#region src/rpc/transports/sse-server.d.ts
5
- interface SseRpcTransportOptions {
5
+ export interface SseRpcTransportOptions {
6
6
  /**
7
7
  * Same contract as `WsRpcTransportOptions.allowedOrigins`: extra origins
8
8
  * to accept beyond the loopback default, a live origin registry, or
@@ -28,7 +28,7 @@ interface SseRpcTransportOptions {
28
28
  /** Mint a session id. Default: `crypto.randomUUID`. */
29
29
  generateSessionId?: () => string;
30
30
  }
31
- interface SseRpcTransport {
31
+ export interface SseRpcTransport {
32
32
  /**
33
33
  * Web-standard handler for the SSE route: `GET` opens the event stream,
34
34
  * `POST` carries RPC frames (session id in the `x-birpc-session` header),
@@ -56,6 +56,5 @@ interface SseRpcTransport {
56
56
  * - server-initiated calls/events stream down as `event: message`
57
57
  * frames, and the client's replies up via `POST` get a bare `202`.
58
58
  */
59
- declare function attachSseRpcTransport<ClientFunctions extends object, ServerFunctions extends object>(rpcGroup: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: SseRpcTransportOptions): SseRpcTransport;
60
- //#endregion
61
- export { SseRpcTransport, SseRpcTransportOptions, attachSseRpcTransport };
59
+ export declare function attachSseRpcTransport<ClientFunctions extends object, ServerFunctions extends object>(rpcGroup: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: SseRpcTransportOptions): SseRpcTransport;
60
+ //#endregion