@adhd/apigen-engine-runtime 0.2.2 → 0.2.4
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/CHANGELOG.md +49 -0
- package/README.md +14 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.mjs +1057 -766
- package/lib/describe-params.d.ts +12 -1
- package/lib/op-plan.d.ts +7 -0
- package/lib/package-invoker.d.ts +17 -0
- package/lib/tool-description.d.ts +8 -5
- package/package.json +25 -5
- package/test-support/parity-harness.d.ts +37 -0
package/lib/describe-params.d.ts
CHANGED
|
@@ -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;
|
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).
|
package/lib/package-invoker.d.ts
CHANGED
|
@@ -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`
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { JsonSchemaLike } from '@adhd/apigen-base-logical';
|
|
2
|
+
|
|
3
|
+
/** The minimal shape this module reads off a composed (or mount) schema entry. */
|
|
2
4
|
export interface ToolDescriptionSchema {
|
|
3
|
-
input?: {
|
|
5
|
+
input?: JsonSchemaLike & {
|
|
4
6
|
description?: unknown;
|
|
5
7
|
};
|
|
6
8
|
}
|
|
@@ -9,9 +11,10 @@ export interface ToolDescriptionSchema {
|
|
|
9
11
|
* response.
|
|
10
12
|
*
|
|
11
13
|
* @param name - The MCP tool name (used as the final fallback).
|
|
12
|
-
* @param schema - The function's composed schema
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* @param schema - The function's composed (or mount) schema; `input` is
|
|
15
|
+
* read both for the envelope/data-wrapper documentation
|
|
16
|
+
* (`input.description`, when present) and for synthesizing a concrete
|
|
17
|
+
* worked example off its actual shape.
|
|
15
18
|
* @param override - An optional caller-supplied description (e.g. from the
|
|
16
19
|
* `toolDescriptions` plugin option), prepended when present.
|
|
17
20
|
*/
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhd/apigen-engine-runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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.
|
|
9
|
-
"@adhd/apigen-base-logical": "^0.1.
|
|
10
|
-
"@adhd/apigen-base-errors": "^0.2.
|
|
11
|
-
"@adhd/apigen-engine-naming": "^0.2.
|
|
8
|
+
"@adhd/apigen-core-client": "^0.3.1",
|
|
9
|
+
"@adhd/apigen-base-logical": "^0.1.2",
|
|
10
|
+
"@adhd/apigen-base-errors": "^0.2.1",
|
|
11
|
+
"@adhd/apigen-engine-naming": "^0.2.3",
|
|
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
|
}
|
|
@@ -88,6 +88,43 @@ export interface NegativeControlOptions {
|
|
|
88
88
|
* only mutation performed, and it is always undone in a `finally`.
|
|
89
89
|
*/
|
|
90
90
|
export declare function proveNegativeControl(runner: () => void | Promise<void>, patchPath: string, opts?: NegativeControlOptions): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Runs `git <args>` scoped to `cwd` via `-C` (never relying on the child's
|
|
93
|
+
* inherited working directory alone), with every `GIT_*` environment
|
|
94
|
+
* variable stripped so an ambient `GIT_DIR`/`GIT_WORK_TREE`/`GIT_INDEX_FILE`
|
|
95
|
+
* (as git sets when invoking hooks — see above) cannot silently redirect the
|
|
96
|
+
* command at a different repository than `cwd`.
|
|
97
|
+
*/
|
|
98
|
+
export declare function runGit(args: readonly string[], opts: {
|
|
99
|
+
cwd: string;
|
|
100
|
+
}): string;
|
|
101
|
+
/**
|
|
102
|
+
* Proves `dir` is itself a git repository root — not merely a subdirectory
|
|
103
|
+
* of some OTHER repository (which `git rev-parse --show-toplevel` would
|
|
104
|
+
* silently resolve to instead). Throws loudly on any mismatch, missing
|
|
105
|
+
* repo, or git failure — this is the assertion that turns "we assume the
|
|
106
|
+
* scratch repo is isolated" into "we proved it before touching it".
|
|
107
|
+
*/
|
|
108
|
+
export declare function assertIsolatedRepoRoot(dir: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Creates a throwaway, PROVABLY isolated git repository for tests that need
|
|
111
|
+
* to exercise real `git` mutations (init/config/add/commit) without any
|
|
112
|
+
* possibility of touching the enclosing repository.
|
|
113
|
+
*
|
|
114
|
+
* Isolation is structural, not incidental:
|
|
115
|
+
* - The scratch repo lives under `os.tmpdir()` (never nested inside any
|
|
116
|
+
* tracked working tree), so nothing that walks up looking for an
|
|
117
|
+
* enclosing `.git` can land on the real repo.
|
|
118
|
+
* - `git init` and every subsequent call go through {@link runGit}, which
|
|
119
|
+
* strips `GIT_*` env so ambient hook variables cannot redirect it.
|
|
120
|
+
* - {@link assertIsolatedRepoRoot} is run immediately after `init` and
|
|
121
|
+
* BEFORE this function returns — the caller only ever receives a dir
|
|
122
|
+
* that has already been proven isolated; a failure to isolate throws
|
|
123
|
+
* here rather than silently degrading into "isolated most of the time".
|
|
124
|
+
*/
|
|
125
|
+
export declare function createIsolatedScratchRepo(prefix: string): {
|
|
126
|
+
dir: string;
|
|
127
|
+
};
|
|
91
128
|
/**
|
|
92
129
|
* Bulletproof teardown for a spawned test server (`flask_server.py`,
|
|
93
130
|
* `grpc_server.py`, …): sends `SIGTERM`, waits for the process's real `exit`
|