apcore-a2a 0.5.0 → 0.7.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.
- package/README.md +72 -1
- package/dist/adapters/card-visibility.d.ts +148 -0
- package/dist/adapters/card-visibility.d.ts.map +1 -0
- package/dist/adapters/card-visibility.js +237 -0
- package/dist/adapters/card-visibility.js.map +1 -0
- package/dist/adapters/errors.d.ts +39 -4
- package/dist/adapters/errors.d.ts.map +1 -1
- package/dist/adapters/errors.js +89 -7
- package/dist/adapters/errors.js.map +1 -1
- package/dist/adapters/skill-mapper.d.ts +27 -0
- package/dist/adapters/skill-mapper.d.ts.map +1 -1
- package/dist/adapters/skill-mapper.js +61 -0
- package/dist/adapters/skill-mapper.js.map +1 -1
- package/dist/cli.d.ts +63 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +279 -38
- package/dist/cli.js.map +1 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +16 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/exceptions.d.ts +31 -0
- package/dist/client/exceptions.d.ts.map +1 -1
- package/dist/client/exceptions.js +40 -0
- package/dist/client/exceptions.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/config.d.ts +38 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +71 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/openapi-backend.d.ts +203 -0
- package/dist/openapi-backend.d.ts.map +1 -0
- package/dist/openapi-backend.js +453 -0
- package/dist/openapi-backend.js.map +1 -0
- package/dist/serve.d.ts +12 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +1 -0
- package/dist/serve.js.map +1 -1
- package/dist/server/context.d.ts +12 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/context.js +14 -0
- package/dist/server/context.js.map +1 -1
- package/dist/server/executor.d.ts +8 -0
- package/dist/server/executor.d.ts.map +1 -1
- package/dist/server/executor.js +41 -9
- package/dist/server/executor.js.map +1 -1
- package/dist/server/factory.d.ts +12 -0
- package/dist/server/factory.d.ts.map +1 -1
- package/dist/server/factory.js +133 -25
- package/dist/server/factory.js.map +1 -1
- package/package.json +4 -3
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config namespace registration and resolution for `apcore-a2a`.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python binding's `apcore_a2a._config`. It lives in its own module
|
|
5
|
+
* rather than in `server/factory.ts` because the CLI has to read the
|
|
6
|
+
* `apcore-a2a.openapi` section *before* it builds a Registry, and therefore long
|
|
7
|
+
* before anything in the server stack is imported — pulling in the factory (and
|
|
8
|
+
* with it express and the whole A2A SDK) just to register a namespace would put
|
|
9
|
+
* the entire server on the startup path of `apcore-a2a serve --help`.
|
|
10
|
+
*
|
|
11
|
+
* Registration must happen from exactly ONE place: apcore's
|
|
12
|
+
* `Config.registerNamespace` throws `ConfigNamespaceDuplicateError` on a second
|
|
13
|
+
* call for the same name, so a second registration site would crash the process
|
|
14
|
+
* at import time rather than being ignored.
|
|
15
|
+
*/
|
|
16
|
+
export declare const A2A_NAMESPACE = "apcore-a2a";
|
|
17
|
+
export declare const A2A_ENV_PREFIX = "APCORE_A2A";
|
|
18
|
+
/** The registered namespace defaults (stable in apcore-js >= 0.22.0). */
|
|
19
|
+
export declare const A2A_DEFAULTS: Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Register the `apcore-a2a` config namespace. Safe to call repeatedly.
|
|
22
|
+
*
|
|
23
|
+
* The already-registered case is detected rather than caught: swallowing every
|
|
24
|
+
* exception here would also swallow a genuine `ConfigEnvPrefixConflictError`
|
|
25
|
+
* from another package claiming `APCORE_A2A`, which is a misconfiguration the
|
|
26
|
+
* operator needs to see.
|
|
27
|
+
*/
|
|
28
|
+
export declare function registerA2aNamespace(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve one `apcore-a2a` namespace setting through apcore's Config.
|
|
31
|
+
*
|
|
32
|
+
* Delegates to `Config.load` so that values from an apcore config file and
|
|
33
|
+
* `APCORE_A2A_*` environment overrides are applied by apcore itself (namespace
|
|
34
|
+
* mode), exactly like the other apcore bindings. Falls back to `fallback` when
|
|
35
|
+
* the key is unset.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getA2aSetting(key: string, fallback?: unknown): unknown;
|
|
38
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,eAAO,MAAM,aAAa,eAAe,CAAC;AAC1C,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,yEAAyE;AACzE,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAoBhD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAO3C;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAMtE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config namespace registration and resolution for `apcore-a2a`.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Python binding's `apcore_a2a._config`. It lives in its own module
|
|
5
|
+
* rather than in `server/factory.ts` because the CLI has to read the
|
|
6
|
+
* `apcore-a2a.openapi` section *before* it builds a Registry, and therefore long
|
|
7
|
+
* before anything in the server stack is imported — pulling in the factory (and
|
|
8
|
+
* with it express and the whole A2A SDK) just to register a namespace would put
|
|
9
|
+
* the entire server on the startup path of `apcore-a2a serve --help`.
|
|
10
|
+
*
|
|
11
|
+
* Registration must happen from exactly ONE place: apcore's
|
|
12
|
+
* `Config.registerNamespace` throws `ConfigNamespaceDuplicateError` on a second
|
|
13
|
+
* call for the same name, so a second registration site would crash the process
|
|
14
|
+
* at import time rather than being ignored.
|
|
15
|
+
*/
|
|
16
|
+
import { Config } from "apcore-js";
|
|
17
|
+
export const A2A_NAMESPACE = "apcore-a2a";
|
|
18
|
+
export const A2A_ENV_PREFIX = "APCORE_A2A";
|
|
19
|
+
/** The registered namespace defaults (stable in apcore-js >= 0.22.0). */
|
|
20
|
+
export const A2A_DEFAULTS = {
|
|
21
|
+
execution_timeout: 300,
|
|
22
|
+
cors_origins: [],
|
|
23
|
+
explorer: false,
|
|
24
|
+
metrics: false,
|
|
25
|
+
push_notifications: false,
|
|
26
|
+
// The OpenAPI backend's section (feature F-12) — {spec, base_url, prefix,
|
|
27
|
+
// include, exclude, include_deprecated, timeout, headers,
|
|
28
|
+
// acknowledge_unapproved_writes}. The first NESTED key in this namespace,
|
|
29
|
+
// whose five siblings are all scalars.
|
|
30
|
+
//
|
|
31
|
+
// `openapi.spec` is also the FIRST path-typed key here, and apcore 0.30.0's
|
|
32
|
+
// protections for path-typed keys do not reach it: `Config.pathTypedKeys()`
|
|
33
|
+
// is a fixed list of apcore's own five keys and never consults a namespace
|
|
34
|
+
// registered through `Config.registerNamespace` (verified against apcore
|
|
35
|
+
// 0.30.0), and the PROTOCOL_SPEC §9.2.1 requirement-5 empty-value discard is
|
|
36
|
+
// gated on that same set — so `APCORE_A2A_OPENAPI_SPEC=` would be treated as
|
|
37
|
+
// an ordinary override to `""`, a legal relative path to every filesystem
|
|
38
|
+
// API. `openapiBackend.resolveSpecLocation` owns the three rules instead.
|
|
39
|
+
openapi: null,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Register the `apcore-a2a` config namespace. Safe to call repeatedly.
|
|
43
|
+
*
|
|
44
|
+
* The already-registered case is detected rather than caught: swallowing every
|
|
45
|
+
* exception here would also swallow a genuine `ConfigEnvPrefixConflictError`
|
|
46
|
+
* from another package claiming `APCORE_A2A`, which is a misconfiguration the
|
|
47
|
+
* operator needs to see.
|
|
48
|
+
*/
|
|
49
|
+
export function registerA2aNamespace() {
|
|
50
|
+
if (Config.registeredNamespaces().some((ns) => ns.name === A2A_NAMESPACE))
|
|
51
|
+
return;
|
|
52
|
+
Config.registerNamespace({
|
|
53
|
+
name: A2A_NAMESPACE,
|
|
54
|
+
envPrefix: A2A_ENV_PREFIX,
|
|
55
|
+
defaults: A2A_DEFAULTS,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve one `apcore-a2a` namespace setting through apcore's Config.
|
|
60
|
+
*
|
|
61
|
+
* Delegates to `Config.load` so that values from an apcore config file and
|
|
62
|
+
* `APCORE_A2A_*` environment overrides are applied by apcore itself (namespace
|
|
63
|
+
* mode), exactly like the other apcore bindings. Falls back to `fallback` when
|
|
64
|
+
* the key is unset.
|
|
65
|
+
*/
|
|
66
|
+
export function getA2aSetting(key, fallback) {
|
|
67
|
+
registerA2aNamespace();
|
|
68
|
+
const value = Config.load(undefined, { validate: false }).get(`${A2A_NAMESPACE}.${key}`);
|
|
69
|
+
return value === undefined || value === null ? fallback : value;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,yEAAyE;AACzE,MAAM,CAAC,MAAM,YAAY,GAA4B;IACnD,iBAAiB,EAAE,GAAG;IACtB,YAAY,EAAE,EAAE;IAChB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,kBAAkB,EAAE,KAAK;IACzB,0EAA0E;IAC1E,0DAA0D;IAC1D,0EAA0E;IAC1E,uCAAuC;IACvC,EAAE;IACF,4EAA4E;IAC5E,4EAA4E;IAC5E,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,0EAA0E;IAC1E,OAAO,EAAE,IAAI;CACd,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,MAAM,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,aAAa,CAAC;QAAE,OAAO;IAClF,MAAM,CAAC,iBAAiB,CAAC;QACvB,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,cAAc;QACzB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,QAAkB;IAC3D,oBAAoB,EAAE,CAAC;IACvB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,GAAG,CAC3D,GAAG,aAAa,IAAI,GAAG,EAAE,CAC1B,CAAC;IACF,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;AAClE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.7.0";
|
|
2
2
|
export { serve, asyncServe } from "./serve.js";
|
|
3
3
|
export { A2AClient } from "./client/index.js";
|
|
4
|
+
export { A2AClientError, A2AConnectionError, A2ADiscoveryError, A2AServerError, AccessDeniedError, ApprovalDeniedError, ApprovalTimeoutError, GovernanceRefusedError, TaskNotCancelableError, TaskNotFoundError, } from "./client/index.js";
|
|
4
5
|
export type { Authenticator, ClaimMapping } from "./auth/index.js";
|
|
5
6
|
export { JWTAuthenticator } from "./auth/index.js";
|
|
6
7
|
export { createAuthMiddleware } from "./auth/index.js";
|
|
@@ -12,4 +13,6 @@ export { ErrorMapper } from "./adapters/index.js";
|
|
|
12
13
|
export { PartConverter } from "./adapters/index.js";
|
|
13
14
|
export { A2AServerFactory } from "./server/index.js";
|
|
14
15
|
export { ApCoreAgentExecutor } from "./server/index.js";
|
|
16
|
+
export { buildOpenapiBackendFromConfig, openapiBackend, projectModuleId, resolveSpecLocation, synthesizeDescription, MODULE_ID_SEGMENT, WRITE_METHODS, } from "./openapi-backend.js";
|
|
17
|
+
export type { GovernanceStateLike, OpenapiBackendLogger, OpenapiBackendOptions, } from "./openapi-backend.js";
|
|
15
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EACL,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.7.0";
|
|
2
2
|
// Public API: serve
|
|
3
3
|
export { serve, asyncServe } from "./serve.js";
|
|
4
4
|
// Client
|
|
5
5
|
export { A2AClient } from "./client/index.js";
|
|
6
|
+
export { A2AClientError, A2AConnectionError, A2ADiscoveryError, A2AServerError, AccessDeniedError, ApprovalDeniedError, ApprovalTimeoutError, GovernanceRefusedError, TaskNotCancelableError, TaskNotFoundError, } from "./client/index.js";
|
|
6
7
|
export { JWTAuthenticator } from "./auth/index.js";
|
|
7
8
|
export { createAuthMiddleware } from "./auth/index.js";
|
|
8
9
|
export { authIdentityStore, getAuthIdentity } from "./auth/index.js";
|
|
@@ -15,4 +16,7 @@ export { PartConverter } from "./adapters/index.js";
|
|
|
15
16
|
// Server
|
|
16
17
|
export { A2AServerFactory } from "./server/index.js";
|
|
17
18
|
export { ApCoreAgentExecutor } from "./server/index.js";
|
|
19
|
+
// OpenAPI backend (feature F-12) — turn an OpenAPI 3.0/3.1 document into a
|
|
20
|
+
// populated apcore Registry, which `serve` accepts like any other.
|
|
21
|
+
export { buildOpenapiBackendFromConfig, openapiBackend, projectModuleId, resolveSpecLocation, synthesizeDescription, MODULE_ID_SEGMENT, WRITE_METHODS, } from "./openapi-backend.js";
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,oBAAoB;AACpB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/C,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,oBAAoB;AACpB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/C,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAErE,WAAW;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,SAAS;AACT,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,2EAA2E;AAC3E,mEAAmE;AACnE,OAAO,EACL,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,GACd,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI backend — serve an OpenAPI 3.0/3.1 document as A2A Skills.
|
|
3
|
+
*
|
|
4
|
+
* Pipeline:
|
|
5
|
+
*
|
|
6
|
+
* loadSpec -> OpenAPIScanner.scan -> [repair] -> HTTPProxyRegistryWriter.write -> Registry
|
|
7
|
+
*
|
|
8
|
+
* The scanner and the writer live in apcore-toolkit; this module composes them
|
|
9
|
+
* and adds the two repairs the composition needs, neither of which the toolkit
|
|
10
|
+
* can make on its own:
|
|
11
|
+
*
|
|
12
|
+
* - **FR-OAS-002 module-ID projection.** The toolkit sanitizes a derived ID into
|
|
13
|
+
* `[A-Za-z0-9_.-]`; apcore's registry accepts only
|
|
14
|
+
* `^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$`. Without the projection the canonical
|
|
15
|
+
* Swagger Petstore scans cleanly and registers nothing — the server starts and
|
|
16
|
+
* serves an Agent Card with zero skills, and nothing in the path raises.
|
|
17
|
+
* - **FR-OAS-003 description repair.** An operation with neither `summary` nor
|
|
18
|
+
* `description` yields `""`, and `AgentCardBuilder` skips a module whose
|
|
19
|
+
* description is empty — so the operation would vanish from the Agent Card with
|
|
20
|
+
* no diagnostic.
|
|
21
|
+
*
|
|
22
|
+
* See `apcore-a2a/docs/features/openapi-backend.md` for the specification and
|
|
23
|
+
* `conformance/fixtures/openapi_backend.json` for the shared contract.
|
|
24
|
+
*/
|
|
25
|
+
import { Registry } from "apcore-js";
|
|
26
|
+
import { type ScannedModule } from "apcore-toolkit";
|
|
27
|
+
/**
|
|
28
|
+
* One dot-separated segment of an apcore-legal module ID. apcore enforces
|
|
29
|
+
* `^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$` at `Registry.register` and again at
|
|
30
|
+
* `Executor.call`; a segment may not begin with a digit, which is why some
|
|
31
|
+
* derived IDs cannot be repaired at all.
|
|
32
|
+
*/
|
|
33
|
+
export declare const MODULE_ID_SEGMENT: RegExp;
|
|
34
|
+
/** HTTP methods that change state. The population FR-OAS-005 warns about. */
|
|
35
|
+
export declare const WRITE_METHODS: ReadonlySet<string>;
|
|
36
|
+
/**
|
|
37
|
+
* The diagnostics sink.
|
|
38
|
+
*
|
|
39
|
+
* Injectable rather than hard-wired to `console` for two reasons: a host that
|
|
40
|
+
* already owns a logger should not have this module writing past it, and the
|
|
41
|
+
* conformance driver asserts the *text* of the FR-OAS-002 / FR-OAS-003 /
|
|
42
|
+
* FR-OAS-005 diagnostics, which it cannot do against an unaddressable sink.
|
|
43
|
+
*/
|
|
44
|
+
export interface OpenapiBackendLogger {
|
|
45
|
+
warn(message: string): void;
|
|
46
|
+
error(message: string): void;
|
|
47
|
+
info(message: string): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The fragment of apcore's `GovernanceState` this module reads.
|
|
51
|
+
*
|
|
52
|
+
* Both naming conventions are accepted so a duck-typed object from a test or a
|
|
53
|
+
* host framework works alongside apcore's own camelCase record.
|
|
54
|
+
*/
|
|
55
|
+
export interface GovernanceStateLike {
|
|
56
|
+
readonly builtinApprovalGateWired?: boolean;
|
|
57
|
+
readonly builtin_approval_gate_wired?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Options for {@link openapiBackend}. */
|
|
60
|
+
export interface OpenapiBackendOptions {
|
|
61
|
+
/** Where proxied requests go. Defaults to the document's `servers[0].url`. */
|
|
62
|
+
baseUrl?: string;
|
|
63
|
+
/** `basePathPrefix` — prepended to every derived module ID. */
|
|
64
|
+
prefix?: string;
|
|
65
|
+
/** Scanner include filter (regex over module IDs). */
|
|
66
|
+
include?: string;
|
|
67
|
+
/** Scanner exclude filter (regex over module IDs). */
|
|
68
|
+
exclude?: string;
|
|
69
|
+
/** When `false`, operations marked `deprecated: true` are skipped. Default `true`. */
|
|
70
|
+
includeDeprecated?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Headers for the **spec fetch only**. Never forwarded to proxied calls, and
|
|
73
|
+
* never logged: a document is often public while the API behind it is not.
|
|
74
|
+
*/
|
|
75
|
+
headers?: Record<string, string>;
|
|
76
|
+
/**
|
|
77
|
+
* Spec-fetch timeout in **SECONDS** — never the per-call proxy timeout.
|
|
78
|
+
*
|
|
79
|
+
* apcore-toolkit's `loadSpec` takes milliseconds (default `30_000`), so this
|
|
80
|
+
* value is multiplied by 1000 at the call site. The Config Bus key is seconds
|
|
81
|
+
* in all three SDKs; passing it straight through would turn a documented
|
|
82
|
+
* `timeout: 30` into a 30 ms fetch timeout.
|
|
83
|
+
*/
|
|
84
|
+
timeout?: number;
|
|
85
|
+
/** Passed to `HTTPProxyRegistryWriter` — the per-request credential hook. */
|
|
86
|
+
authHeaderFactory?: () => Record<string, string>;
|
|
87
|
+
/** Write into this registry instead of a fresh one. */
|
|
88
|
+
registry?: Registry;
|
|
89
|
+
/** True when an extensions directory (or another source) also populates the registry. */
|
|
90
|
+
hasOtherBackendSource?: boolean;
|
|
91
|
+
/** The base a relative `spec` resolves against (FR-OAS-004 rule 3). */
|
|
92
|
+
projectRoot?: string;
|
|
93
|
+
/** Records an explicit operator decision, suppressing FR-OAS-005's warning. */
|
|
94
|
+
acknowledgeUnapprovedWrites?: boolean;
|
|
95
|
+
/** Consulted only to word FR-OAS-005's warning; never to suppress it. */
|
|
96
|
+
governanceState?: GovernanceStateLike | null;
|
|
97
|
+
/** Scanner hook: patch an operation before extraction. */
|
|
98
|
+
transformOperation?: (p: string, method: string, operation: Record<string, unknown>) => Record<string, unknown> | null;
|
|
99
|
+
/**
|
|
100
|
+
* Caller hook: adjust the finished module. Runs **first**, before the
|
|
101
|
+
* description repair and the ID projection, so the invariants those two hold
|
|
102
|
+
* are unconditional whatever this returns.
|
|
103
|
+
*/
|
|
104
|
+
transformModule?: (module: ScannedModule) => ScannedModule | null;
|
|
105
|
+
/** Scanner hook: override the naming algorithm. */
|
|
106
|
+
deriveModuleId?: (p: string, method: string, operation: Record<string, unknown>) => string | null;
|
|
107
|
+
/** Diagnostics sink. Defaults to `console`. */
|
|
108
|
+
logger?: Partial<OpenapiBackendLogger>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Project a toolkit-derived module ID into apcore's registry alphabet.
|
|
112
|
+
*
|
|
113
|
+
* Lowercase, then `-` -> `_`. Returns `null` when the result still has a segment
|
|
114
|
+
* apcore would reject — such an ID cannot be repaired without *inventing* a
|
|
115
|
+
* character, which is a naming decision belonging to the operator's own hook
|
|
116
|
+
* rather than to a silent default. The module is dropped and reported by the
|
|
117
|
+
* caller.
|
|
118
|
+
*/
|
|
119
|
+
export declare function projectModuleId(moduleId: string): string | null;
|
|
120
|
+
/** The minimum surface {@link synthesizeDescription} reads off a scanned module. */
|
|
121
|
+
export interface DescribableModule {
|
|
122
|
+
readonly moduleId?: string;
|
|
123
|
+
readonly metadata?: Record<string, unknown> | null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Build a `{METHOD} {path}` description for an undocumented operation.
|
|
127
|
+
*
|
|
128
|
+
* Uses the `http_method` / `url_path` metadata keys `HTTPProxyRegistryWriter`
|
|
129
|
+
* already requires, so the value is factual and stable across scans of the same
|
|
130
|
+
* document. Deliberately terse so it reads as a placeholder rather than as
|
|
131
|
+
* documentation.
|
|
132
|
+
*/
|
|
133
|
+
export declare function synthesizeDescription(module: DescribableModule): string;
|
|
134
|
+
/**
|
|
135
|
+
* The base a relative `spec` resolves against (FR-OAS-004 rule 3).
|
|
136
|
+
*
|
|
137
|
+
* `Config.projectRoot` is apcore 0.30.0's public accessor. It reports a base and
|
|
138
|
+
* applies nothing, which is exactly the division of labour this key needs: the
|
|
139
|
+
* adapter owns the resolution because `Config.pathTypedKeys()` never reaches a
|
|
140
|
+
* consumer namespace.
|
|
141
|
+
*/
|
|
142
|
+
export declare function resolveProjectRoot(explicit?: string | null): string;
|
|
143
|
+
/**
|
|
144
|
+
* Resolve `apcore-a2a.openapi.spec` (FR-OAS-004).
|
|
145
|
+
*
|
|
146
|
+
* apcore 0.30.0 declared the closed set of path-typed configuration keys and the
|
|
147
|
+
* base a relative one resolves against, but `Config.pathTypedKeys()` is a fixed
|
|
148
|
+
* list of apcore's own keys and never consults a namespace registered through
|
|
149
|
+
* `Config.registerNamespace` — verified against apcore 0.30.0. The §9.2.1
|
|
150
|
+
* requirement-5 empty-value discard is gated on that same set, so
|
|
151
|
+
* `APCORE_A2A_OPENAPI_SPEC=` would otherwise become an ordinary override to `""`,
|
|
152
|
+
* a legal relative path to every filesystem API and never the one an operator
|
|
153
|
+
* meant. This binding therefore owns the three rules rather than inheriting them.
|
|
154
|
+
*
|
|
155
|
+
* 1. A value beginning `http://` / `https://` is a URL, used verbatim — never
|
|
156
|
+
* path-resolved, never made absolute.
|
|
157
|
+
* 2. A set-but-empty value is discarded with a WARNING and the caller falls
|
|
158
|
+
* through to the next configuration tier. It is never joined to a base, which
|
|
159
|
+
* would silently yield the project root.
|
|
160
|
+
* 3. A relative path resolves against `Config.projectRoot` — not the process CWD,
|
|
161
|
+
* and not the document's own directory.
|
|
162
|
+
*
|
|
163
|
+
* @returns the URL unchanged, an absolute path, the already-parsed document, or
|
|
164
|
+
* `null` when the value was empty and the caller should fall through.
|
|
165
|
+
*/
|
|
166
|
+
export declare function resolveSpecLocation(spec: unknown, options?: {
|
|
167
|
+
projectRoot?: string | null;
|
|
168
|
+
logger?: {
|
|
169
|
+
warn(message: string): void;
|
|
170
|
+
};
|
|
171
|
+
}): unknown;
|
|
172
|
+
/**
|
|
173
|
+
* Build an apcore `Registry` from an OpenAPI 3.0/3.1 document.
|
|
174
|
+
*
|
|
175
|
+
* `spec` is a URL, a filesystem path (resolved per FR-OAS-004), or an
|
|
176
|
+
* already-parsed document object. `timeout` is the **spec-fetch** timeout in
|
|
177
|
+
* seconds, never the per-call proxy timeout — the two are different concerns.
|
|
178
|
+
*
|
|
179
|
+
* Never returns a partially-populated registry: the collision preflight and
|
|
180
|
+
* every validation run before the first write.
|
|
181
|
+
*/
|
|
182
|
+
export declare function openapiBackend(spec: unknown, options?: OpenapiBackendOptions): Promise<Registry>;
|
|
183
|
+
/**
|
|
184
|
+
* Build the backend from an `apcore-a2a.openapi` Config Bus section.
|
|
185
|
+
*
|
|
186
|
+
* The raw Config Bus value is a plain object (from `apcore.yaml` or
|
|
187
|
+
* `APCORE_A2A_OPENAPI_*` env vars) in snake_case, not the camelCase options
|
|
188
|
+
* {@link openapiBackend} takes, so this is the one place that translates between
|
|
189
|
+
* them.
|
|
190
|
+
*
|
|
191
|
+
* Returns `null` when the section is absent or falsy, so a caller can treat "no
|
|
192
|
+
* OpenAPI configured" as an ordinary outcome.
|
|
193
|
+
*
|
|
194
|
+
* `authHeaderFactory` is deliberately not read from the section: it is a
|
|
195
|
+
* callable, and a value sourced from YAML/JSON/env can never carry one.
|
|
196
|
+
*/
|
|
197
|
+
export declare function buildOpenapiBackendFromConfig(openapiConfig: unknown, options?: {
|
|
198
|
+
registry?: Registry;
|
|
199
|
+
hasOtherBackendSource?: boolean;
|
|
200
|
+
governanceState?: GovernanceStateLike | null;
|
|
201
|
+
logger?: Partial<OpenapiBackendLogger>;
|
|
202
|
+
}): Promise<Registry | null>;
|
|
203
|
+
//# sourceMappingURL=openapi-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-backend.d.ts","sourceRoot":"","sources":["../src/openapi-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAU,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAAsB,CAAC;AAErD,6EAA6E;AAC7E,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAK5C,CAAC;AAIH;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAQD;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CAChD;AAQD,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,OAAO,CAAC,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