@adhd/apigen-engine-runtime 0.2.3 → 0.3.0

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.
@@ -4,11 +4,22 @@ export interface ParamInfo {
4
4
  required: boolean;
5
5
  }
6
6
  /**
7
- * Extract a composed schema entry's domain parameters for logging.
7
+ * Extract a composed schema entry's domain parameters for logging AND for a
8
+ * per-command `--help` rendering.
8
9
  *
9
10
  * Params live under `input.properties.data.properties` — the `data` envelope
10
11
  * wrapper is always present (see [def:ComposedSchemas]). Returns both a
11
12
  * structured list (for JSON logs) and a `name?: type` summary string.
13
+ *
14
+ * Every TOP-LEVEL param's type is expanded one level deep — an integer `depth`
15
+ * budget of 2 is passed to `typeName` (see its doc comment for the exact
16
+ * contract) — so an `object` with declared `properties` renders its fields and
17
+ * a `oneOf`/`anyOf` union renders its member shapes, e.g. `update`'s single
18
+ * `input` param renders as `input: { repo: string, humanId: string, patch:
19
+ * object, by: string }` instead of the placebo `input: object` that told a
20
+ * reader nothing about what the command actually accepts (the surviving half of
21
+ * FEAT-BACKLOG-003 / the `--help` finding in P5-cli-serve-transport). Nested
22
+ * unions/objects collapse to their placeholders, keeping the render bounded.
12
23
  */
13
24
  export declare function describeParams(schema: {
14
25
  input?: unknown;
@@ -1,8 +1,23 @@
1
1
  /** Result of adapting a composed-schema `output` fragment for MCP's `outputSchema` field. */
2
2
  export interface McpOutputAdapter {
3
- /** The MCP `Tool.outputSchema` value, or `undefined` when `output` carries no usable schema. */
3
+ /** The MCP `Tool.outputSchema` value, or `undefined` when the return is not
4
+ * already a top-level `type:"object"` (nothing protocol-representable to
5
+ * advertise — see ADR-0004). */
4
6
  outputSchema: Record<string, unknown> | undefined;
5
- /** True when the output wasn't top-level `type:"object"` and had to be wrapped under `result`. */
7
+ /**
8
+ * Whether a matching `structuredContent` should be emitted for this output.
9
+ *
10
+ * `true` iff the return is already a top-level `type:"object"` — the only
11
+ * case in which an `outputSchema` is emitted at all; `false` for a
12
+ * union/array/scalar/void return, which is passed through flat on `content`
13
+ * alone (ADR-0004).
14
+ *
15
+ * Retained under its historical name because the generated host templates
16
+ * destructure `wrapped` and pass it straight to `wrapMcpStructuredContent`
17
+ * (as do already-generated hosts out in the wild). Since ADR-0004 it no
18
+ * longer means "the schema was wrapped under `result`" — nothing is ever
19
+ * wrapped. Read it as `emitStructuredContent`.
20
+ */
6
21
  wrapped: boolean;
7
22
  }
8
23
  /**
@@ -14,8 +29,13 @@ export interface McpOutputAdapter {
14
29
  */
15
30
  export declare function buildMcpOutputSchema(output: unknown): McpOutputAdapter;
16
31
  /**
17
- * Wraps a tool's actual return value to match the `outputSchema` shape built by
18
- * `buildMcpOutputSchema` for the SAME `output` fragment, for use as MCP's
19
- * `structuredContent` (also constrained to a plain object by the SDK).
32
+ * Returns the MCP `structuredContent` for a tool's actual return value.
33
+ *
34
+ * `emit` is `McpOutputAdapter.wrapped` for the SAME `output` fragment: only an
35
+ * already-object return emits `structuredContent`, and it is the value itself
36
+ * — never wrapped under `result` (ADR-0004). A non-plain-object value (or an
37
+ * `emit:false` non-object return) yields `undefined`: `structuredContent`
38
+ * (like `outputSchema`) is constrained to a plain object by the SDK, so an
39
+ * array/scalar must not be emitted there.
20
40
  */
21
- export declare function wrapMcpStructuredContent(wrapped: boolean, value: unknown): Record<string, unknown> | undefined;
41
+ export declare function wrapMcpStructuredContent(emit: boolean, value: unknown): Record<string, unknown> | undefined;
package/lib/op-plan.d.ts CHANGED
@@ -30,6 +30,13 @@ export interface OpPlanCliFlag {
30
30
  valueKind: 'boolean' | 'json' | 'string';
31
31
  /** (envelope only) `APIGEN_<PLUGINID>_<FIELD>` fallback when the flag is absent. */
32
32
  envVar?: string;
33
+ /**
34
+ * Set ONLY on a camelCase alias entry, naming the canonical kebab-case key it
35
+ * resolves to (BUG-BACKLOG-CLI-FLAG-CASE-MISMATCH-001). Transports must
36
+ * exclude aliased entries when LISTING available flags — kebab-case remains
37
+ * the single advertised spelling — while still accepting them on input.
38
+ */
39
+ aliasOf?: string;
33
40
  }
34
41
  /**
35
42
  * A fully-resolved, transport-complete plan for one `Operation` (proposal §3a).
@@ -47,6 +47,23 @@ export type UseOptions = Record<string, Record<string, unknown>>;
47
47
  * carries no dedicated field, so they ride on `options.usePlugins`).
48
48
  */
49
49
  export declare function readUsePlugins(options: Record<string, unknown>): UsePlugin[];
50
+ /**
51
+ * Optional `options.exitCode` hook: maps a SUCCESSFULLY-RETURNED result to a
52
+ * process exit code.
53
+ *
54
+ * A host whose operations return a result-shaped outcome (`{ok:false, error}`)
55
+ * rather than throwing looks like unqualified success to a transport, so the
56
+ * CLI exits 0 on a reported failure — a caller's `&&` chain then proceeds and
57
+ * `set -e` never trips. This hook is the seam that lets such a host state its
58
+ * own mapping without apigen having to know the envelope shape.
59
+ *
60
+ * Opt-in and absent by default: a host that does not pass it keeps the
61
+ * existing "returned normally ⇒ exit 0" behaviour exactly.
62
+ *
63
+ * Thrown `ApiError`s are unaffected — those already map through
64
+ * `CLI_EXIT_CODE`.
65
+ */
66
+ export declare function readExitCodeHook(options: Record<string, unknown>): ((result: unknown) => number | undefined) | undefined;
50
67
  export declare function readUseOptions(options: Record<string, unknown>): UseOptions;
51
68
  /**
52
69
  * Adapt a core `LayerCapability.layer` (which receives the SPEC §7.1 `Call`
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@adhd/apigen-engine-runtime",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
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.0",
9
- "@adhd/apigen-base-logical": "^0.1.1",
10
- "@adhd/apigen-base-errors": "^0.2.0",
11
- "@adhd/apigen-engine-naming": "^0.2.2",
8
+ "@adhd/apigen-core-client": "^0.3.2",
9
+ "@adhd/apigen-base-logical": "^0.1.3",
10
+ "@adhd/apigen-base-errors": "^0.2.2",
11
+ "@adhd/apigen-engine-naming": "^0.2.4",
12
12
  "better-sqlite3": "12.10.0"
13
13
  },
14
14
  "main": "./index.js",
@@ -16,5 +16,25 @@
16
16
  "typings": "./index.d.ts",
17
17
  "publishConfig": {
18
18
  "access": "public"
19
+ },
20
+ "description": "Runtime executor for apigen - dispatch derived operations with pluggable concurrency and transports",
21
+ "keywords": [
22
+ "api",
23
+ "runtime",
24
+ "typescript",
25
+ "schema",
26
+ "dispatch",
27
+ "concurrency",
28
+ "codegen"
29
+ ],
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/PseudoSky/adhd.git",
34
+ "directory": "packages/apigen/apigen-engine-runtime"
35
+ },
36
+ "homepage": "https://github.com/PseudoSky/adhd/tree/main/packages/apigen/apigen-engine-runtime#readme",
37
+ "bugs": {
38
+ "url": "https://github.com/PseudoSky/adhd/issues"
19
39
  }
20
40
  }