@adhd/apigen-engine-runtime 0.3.1 → 0.3.3

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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Listen-host policy shared by every apigen TypeScript host (fastify, express,
3
+ * mcp). Defaults to IPv4 loopback; binding anything else is a deliberate
4
+ * override (`--opt host=…` / `options.host`) and logs a warning. Node's
5
+ * `listen(port)` with no host — or with an empty string — binds ALL
6
+ * interfaces, so the empty/whitespace case is treated as unset.
7
+ *
8
+ * Pure (no sockets), so the default is unit-testable without binding a port.
9
+ */
10
+ /** Default listen address for every apigen host: IPv4 loopback. */
11
+ export declare const DEFAULT_LISTEN_HOST = "127.0.0.1";
12
+ /** True for `localhost`, `127.0.0.0/8`, `::1` and IPv4-mapped loopback. */
13
+ export declare function isLoopbackListenHost(host: string): boolean;
14
+ /**
15
+ * Resolve the effective listen host from the plugin `host` option. Non-string,
16
+ * empty and whitespace-only values fall back to {@link DEFAULT_LISTEN_HOST}.
17
+ */
18
+ export declare function resolveListenHost(raw: unknown): string;
19
+ /**
20
+ * Emit a warning when `host` is not loopback (unauthenticated-by-default
21
+ * hosts become network-reachable). Returns whether it warned.
22
+ */
23
+ export declare function warnIfNonLoopbackListen(host: string, label: string, logger?: {
24
+ warn: (obj: Record<string, unknown>, msg: string) => void;
25
+ }): boolean;
@@ -6,4 +6,4 @@ import { Call as RuntimeCall, InvokeFn, InvokeOptions, LayerResult } from './inv
6
6
  * (`InvokeFn`, e.g. from `createPackageInvoker`) and a partial runtime `Call`
7
7
  * (minus `operation`/`ctx`, per the `TransportAdapter` contract).
8
8
  */
9
- export declare function dispatchForPlan(plan: OpPlan, invoke: InvokeFn, call: Omit<RuntimeCall, 'operation' | 'ctx'>, opts: InvokeOptions): Promise<LayerResult>;
9
+ export declare function dispatchForPlan(plan: OpPlan, invoke: InvokeFn, call: Omit<RuntimeCall, 'operation' | 'ctx' | 'transport'>, opts: InvokeOptions): Promise<LayerResult>;
package/lib/invoke.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ComposedSchemas } from './types';
2
- import { Operation } from '@adhd/apigen-core-client';
2
+ import { Operation, Transport } from '@adhd/apigen-core-client';
3
3
 
4
4
  /**
5
5
  * A symbol-keyed or constructor-keyed typed extension map. Each value is
@@ -37,6 +37,13 @@ export interface Call {
37
37
  domainArgs: Record<string, unknown>;
38
38
  /** Cancellation signal (AbortSignal) — §11. */
39
39
  signal?: AbortSignal;
40
+ /**
41
+ * The canonical transport this call arrived on. Stamped by `dispatchForPlan`
42
+ * from `plan.transport` (F3), so it is guaranteed present on every call a
43
+ * Layer observes — never optional, never a silent `undefined`. A Layer that
44
+ * needs the transport reads it here; it never hunts for it elsewhere.
45
+ */
46
+ transport: Transport;
40
47
  }
41
48
  /**
42
49
  * The primitive result a Layer or dispatch can return.
@@ -7,12 +7,12 @@ export interface TransportAdapter<Raw = unknown> {
7
7
  * transport's underlying server/CLI/router, wiring inbound requests to
8
8
  * `dispatch`. Called ONCE per `OpPlan`, at server/CLI wiring time.
9
9
  */
10
- registerRoute(plan: OpPlan, dispatch: (call: Omit<Call, 'operation' | 'ctx'>) => Promise<LayerResult>): void;
10
+ registerRoute(plan: OpPlan, dispatch: (call: Omit<Call, 'operation' | 'ctx' | 'transport'>) => Promise<LayerResult>): void;
11
11
  /**
12
12
  * Marshal the transport-native inbound request `raw` into the runtime
13
13
  * `Call` shape (minus `operation`/`ctx`, filled in by the dispatch path).
14
14
  */
15
- readCall(raw: Raw, plan: OpPlan): Omit<Call, 'operation' | 'ctx'> | Promise<Omit<Call, 'operation' | 'ctx'>>;
15
+ readCall(raw: Raw, plan: OpPlan): Omit<Call, 'operation' | 'ctx' | 'transport'> | Promise<Omit<Call, 'operation' | 'ctx' | 'transport'>>;
16
16
  /**
17
17
  * Marshal a resolved `LayerResult` (the value `dispatch`'s returned
18
18
  * Promise resolved to — F1) back onto the transport-native outbound
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@adhd/apigen-engine-runtime",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "dependencies": {
5
5
  "ajv": "^8.20.0",
6
6
  "ajv-formats": "2.1.1",
7
7
  "pino": "10.3.1",
8
- "@adhd/apigen-core-client": "^0.3.3",
8
+ "@adhd/apigen-core-client": "^0.3.4",
9
9
  "@adhd/apigen-base-logical": "^0.1.4",
10
10
  "@adhd/apigen-base-errors": "^0.2.3",
11
11
  "@adhd/apigen-engine-naming": "^0.2.5",