@akai-workflow-builder/cli-sdk 0.4.1 → 0.6.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/CHANGELOG.md +19 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -3
- package/dist/define-cli.d.ts.map +1 -1
- package/dist/define-cli.js +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/manifest/json-schema.d.ts +79 -0
- package/dist/manifest/json-schema.d.ts.map +1 -1
- package/dist/manifest/json-schema.js +108 -0
- package/dist/manifest/to-schema.d.ts.map +1 -1
- package/dist/manifest/to-schema.js +2 -0
- package/dist/manifest/types.d.ts +137 -0
- package/dist/manifest/types.d.ts.map +1 -1
- package/dist/runtime/executor/index.d.ts +1 -1
- package/dist/runtime/executor/index.d.ts.map +1 -1
- package/dist/runtime/executor/index.js +16 -1
- package/dist/runtime/registry/connection-manifest.d.ts +27 -0
- package/dist/runtime/registry/connection-manifest.d.ts.map +1 -0
- package/dist/runtime/registry/connection-manifest.js +76 -0
- package/dist/runtime/registry/index.d.ts +4 -1
- package/dist/runtime/registry/index.d.ts.map +1 -1
- package/dist/runtime/registry/index.js +3 -0
- package/dist/runtime/registry/loader.d.ts +44 -0
- package/dist/runtime/registry/loader.d.ts.map +1 -1
- package/dist/runtime/registry/loader.js +329 -12
- package/dist/runtime/registry/manifest-wire.d.ts +65 -0
- package/dist/runtime/registry/manifest-wire.d.ts.map +1 -0
- package/dist/runtime/registry/manifest-wire.js +152 -0
- package/dist/runtime/registry/wire.d.ts +35 -1
- package/dist/runtime/registry/wire.d.ts.map +1 -1
- package/dist/runtime/registry/wire.js +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Project a built {@link BrandedConnection} to its pure, serialisable
|
|
2
|
+
* {@link ManifestConnection}. Deterministic, no I/O — safe to call at build time. */
|
|
3
|
+
export function connectionToManifest(conn) {
|
|
4
|
+
return {
|
|
5
|
+
slug: conn.slug,
|
|
6
|
+
name: conn.name,
|
|
7
|
+
vendor: conn.vendor,
|
|
8
|
+
blurb: conn.blurb,
|
|
9
|
+
longDesc: conn.longDesc,
|
|
10
|
+
instructions: [...conn.instructions],
|
|
11
|
+
authKind: conn.authKind,
|
|
12
|
+
...(conn.secrets !== undefined ? { secrets: conn.secrets.map(copySecret) } : {}),
|
|
13
|
+
...(conn.apiKeyHeader !== undefined ? { apiKeyHeader: conn.apiKeyHeader } : {}),
|
|
14
|
+
...(conn.hosts !== undefined ? { hosts: { ...conn.hosts } } : {}),
|
|
15
|
+
...(conn.oauth !== undefined ? { oauth: copyOAuth(conn.oauth) } : {}),
|
|
16
|
+
...(conn.jwtRefresh !== undefined ? { jwtRefresh: copyJwtRefresh(conn.jwtRefresh) } : {}),
|
|
17
|
+
...(conn.nativeBuiltin !== undefined ? { nativeBuiltin: conn.nativeBuiltin } : {}),
|
|
18
|
+
...(conn.override !== undefined ? { override: conn.override } : {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function copySecret(s) {
|
|
22
|
+
return {
|
|
23
|
+
key: s.key,
|
|
24
|
+
name: s.name,
|
|
25
|
+
description: s.description,
|
|
26
|
+
required: s.required,
|
|
27
|
+
...(s.injected !== undefined ? { injected: s.injected } : {}),
|
|
28
|
+
...(s.adminManaged !== undefined ? { adminManaged: s.adminManaged } : {}),
|
|
29
|
+
...(s.serverOnly !== undefined ? { serverOnly: s.serverOnly } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function copyOAuth(o) {
|
|
33
|
+
return {
|
|
34
|
+
authorizeUrl: o.authorizeUrl,
|
|
35
|
+
tokenUrl: o.tokenUrl,
|
|
36
|
+
...(o.scopes !== undefined ? { scopes: [...o.scopes] } : {}),
|
|
37
|
+
...(o.pkce !== undefined ? { pkce: o.pkce } : {}),
|
|
38
|
+
...(o.tokenEndpointAuthMethod !== undefined ? { tokenEndpointAuthMethod: o.tokenEndpointAuthMethod } : {}),
|
|
39
|
+
...(o.extraAuthorizeParams !== undefined ? { extraAuthorizeParams: { ...o.extraAuthorizeParams } } : {}),
|
|
40
|
+
...(o.refreshStrategy !== undefined ? { refreshStrategy: o.refreshStrategy } : {}),
|
|
41
|
+
adminFields: o.adminFields.map((f) => ({
|
|
42
|
+
key: f.key,
|
|
43
|
+
label: f.label,
|
|
44
|
+
...(f.secret !== undefined ? { secret: f.secret } : {}),
|
|
45
|
+
})),
|
|
46
|
+
...(o.hasCustomConnectFlow !== undefined ? { hasCustomConnectFlow: o.hasCustomConnectFlow } : {}),
|
|
47
|
+
...(o.tokenResponsePath !== undefined ? { tokenResponsePath: o.tokenResponsePath } : {}),
|
|
48
|
+
...(o.appToken !== undefined
|
|
49
|
+
? {
|
|
50
|
+
appToken: {
|
|
51
|
+
tokenUrl: o.appToken.tokenUrl,
|
|
52
|
+
...(o.appToken.requestStyle !== undefined ? { requestStyle: o.appToken.requestStyle } : {}),
|
|
53
|
+
...(o.appToken.credentialParams !== undefined
|
|
54
|
+
? { credentialParams: { ...o.appToken.credentialParams } }
|
|
55
|
+
: {}),
|
|
56
|
+
...(o.appToken.tokenField !== undefined ? { tokenField: o.appToken.tokenField } : {}),
|
|
57
|
+
...(o.appToken.expiresField !== undefined ? { expiresField: o.appToken.expiresField } : {}),
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function copyJwtRefresh(j) {
|
|
64
|
+
return {
|
|
65
|
+
name: j.name,
|
|
66
|
+
envs: j.envs.map((e) => ({
|
|
67
|
+
env: e.env,
|
|
68
|
+
accessKey: e.accessKey,
|
|
69
|
+
refreshKey: e.refreshKey,
|
|
70
|
+
refreshUrl: e.refreshUrl,
|
|
71
|
+
})),
|
|
72
|
+
...(j.defaultAtTtlMs !== undefined ? { defaultAtTtlMs: j.defaultAtTtlMs } : {}),
|
|
73
|
+
...(j.revocationBackoffMs !== undefined ? { revocationBackoffMs: j.revocationBackoffMs } : {}),
|
|
74
|
+
...(j.claimTtlSeconds !== undefined ? { claimTtlSeconds: j.claimTtlSeconds } : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { Registry } from './loader.js';
|
|
2
2
|
export type { LoadRegistryOptions } from './loader.js';
|
|
3
3
|
export type { BrandedCLI, BrandedConnection, BrandedConnectionOAuth, BrandedOAuthAdminField, BrandedTool, BrandedToolOptions, BrandedSecretDecl, ConnectionAuthKind, ConnectionEntry, ConnectionRefreshStrategy, ConnectionTokenEndpointAuthMethod, RegistryEntry, RegistrySource, RegistryStats, ToolLookup, } from './types.js';
|
|
4
|
-
export type { WireConnectionEntry, WireConnectionOAuth, WireTenant, } from './wire.js';
|
|
4
|
+
export type { WireCliEntry, WireConnectionEntry, WireConnectionOAuth, WireListPayload, WireTenant, WireToolEntry, } from './wire.js';
|
|
5
|
+
export { toWireListPayload } from './wire.js';
|
|
6
|
+
export { manifestConnectionToWire, manifestToWireCli, manifestToWireTools, manifestsToWireCatalog, } from './manifest-wire.js';
|
|
7
|
+
export { connectionToManifest } from './connection-manifest.js';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,iCAAiC,EACjC,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,iCAAiC,EACjC,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export { Registry } from './loader.js';
|
|
2
|
+
export { toWireListPayload } from './wire.js';
|
|
3
|
+
export { manifestConnectionToWire, manifestToWireCli, manifestToWireTools, manifestsToWireCatalog, } from './manifest-wire.js';
|
|
4
|
+
export { connectionToManifest } from './connection-manifest.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ConnectionEntry, LoadFailure, RegistryEntry, RegistryStats, ToolLookup } from './types.js';
|
|
2
2
|
import type { ToolLogger } from '../../types.js';
|
|
3
|
+
import type { WireListPayload, WireTenant } from './wire.js';
|
|
3
4
|
export interface LoadRegistryOptions {
|
|
4
5
|
/** Absolute path to the baseline packages root (e.g. `/app/tools/packages`). */
|
|
5
6
|
readonly baselinePath?: string;
|
|
@@ -24,19 +25,62 @@ export interface LoadRegistryOptions {
|
|
|
24
25
|
* and the baseline self-check.
|
|
25
26
|
*/
|
|
26
27
|
readonly strict?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Lazy tool loading. When `true`, packages that ship a `manifest.json` are
|
|
30
|
+
* catalogued from that JSON alone (no module import) — enough to serve
|
|
31
|
+
* `/tools/list` — and their handler module is imported on first
|
|
32
|
+
* `resolveTool()` and cached. Packages WITHOUT a manifest (connection
|
|
33
|
+
* packages, and any CLI whose manifest wasn't generated) are imported eagerly
|
|
34
|
+
* exactly as in the default mode, so lazy mode is a safe superset: a
|
|
35
|
+
* manifest-less package degrades to today's behavior rather than disappearing.
|
|
36
|
+
*
|
|
37
|
+
* Off (default): every package is imported at boot (the current behavior).
|
|
38
|
+
*/
|
|
39
|
+
readonly lazy?: boolean;
|
|
27
40
|
}
|
|
28
41
|
export declare class Registry {
|
|
29
42
|
private readonly byCliId;
|
|
30
43
|
private readonly byConnectionSlug;
|
|
31
44
|
private readonly loadFailures;
|
|
45
|
+
private readonly lazyByCliId;
|
|
46
|
+
private readonly resolvedCache;
|
|
47
|
+
private readonly manifestConnBySlug;
|
|
32
48
|
private constructor();
|
|
33
49
|
static load(opts: LoadRegistryOptions): Promise<Registry>;
|
|
50
|
+
/**
|
|
51
|
+
* Synchronous lookup — resolves only EAGERLY-loaded CLIs. In lazy mode a CLI
|
|
52
|
+
* catalogued from its manifest hasn't imported its handler module yet, so this
|
|
53
|
+
* returns `undefined` for it. Callers that must execute a tool should use the
|
|
54
|
+
* async {@link resolveTool}, which imports the module on demand and works in
|
|
55
|
+
* both modes. Kept for eager-mode callers and back-compat.
|
|
56
|
+
*/
|
|
34
57
|
lookupTool(cliId: string, toolKey: string): ToolLookup | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a tool for execution in BOTH modes. Eager: identical to
|
|
60
|
+
* `lookupTool`. Lazy: if the CLI is only catalogued (manifest), import its
|
|
61
|
+
* handler module now (memoized, so concurrent calls import once) and then look
|
|
62
|
+
* up the tool on the freshly-loaded, branded CLI. Returns `undefined` for an
|
|
63
|
+
* unknown cli/tool exactly like `lookupTool`.
|
|
64
|
+
*/
|
|
65
|
+
resolveTool(cliId: string, toolKey: string): Promise<ToolLookup | undefined>;
|
|
66
|
+
/** Import (once) the module behind a lazy CLI entry and return its
|
|
67
|
+
* RegistryEntry. A failed import is evicted from the cache so a later call can
|
|
68
|
+
* retry rather than being permanently poisoned. */
|
|
69
|
+
private resolveLazyEntry;
|
|
35
70
|
entries(): ReadonlyArray<RegistryEntry>;
|
|
36
71
|
connections(): ReadonlyArray<ConnectionEntry>;
|
|
37
72
|
/** Packages skipped at load: failed brand/shape check, or the dropped side of
|
|
38
73
|
* a duplicate id/slug collision. */
|
|
39
74
|
failures(): ReadonlyArray<LoadFailure>;
|
|
40
75
|
stats(): RegistryStats;
|
|
76
|
+
/**
|
|
77
|
+
* Build the `/tools/list` wire payload in BOTH modes. Eager: delegates to the
|
|
78
|
+
* shared projection over loaded entries. Lazy: projects the manifest catalog
|
|
79
|
+
* (no imports) and merges it with any eagerly-loaded CLIs + connections,
|
|
80
|
+
* re-sorted to the same stable order the eager payload uses (CLIs by
|
|
81
|
+
* `id.localeCompare`; tools grouped by cli then tool key). The two are
|
|
82
|
+
* byte-identical per package — see test/registry/manifest-wire.test.ts.
|
|
83
|
+
*/
|
|
84
|
+
toWirePayload(tenant?: WireTenant | null): WireListPayload;
|
|
41
85
|
}
|
|
42
86
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry/loader.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAMV,eAAe,EACf,WAAW,EACX,aAAa,EAEb,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry/loader.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAMV,eAAe,EACf,WAAW,EACX,aAAa,EAEb,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD,OAAO,KAAK,EAAgB,eAAe,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AAyD1F,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,QAAQ;IAGnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IAGrD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA+B;IAKhE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAI1D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IAIxD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsC;IAOpE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAiC;IAEpE,OAAO;WAmBM,IAAI,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA+M/D;;;;;;OAMG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAQlE;;;;;;OAMG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAWlF;;uDAEmD;IACnD,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,IAAI,aAAa,CAAC,aAAa,CAAC;IAIvC,WAAW,IAAI,aAAa,CAAC,eAAe,CAAC;IAI7C;wCACoC;IACpC,QAAQ,IAAI,aAAa,CAAC,WAAW,CAAC;IAItC,KAAK,IAAI,aAAa;IAyCtB;;;;;;;OAOG;IACH,aAAa,CAAC,MAAM,GAAE,UAAU,GAAG,IAAW,GAAG,eAAe;CA2BjE"}
|
|
@@ -24,6 +24,9 @@ import { promises as fs } from 'node:fs';
|
|
|
24
24
|
import path from 'node:path';
|
|
25
25
|
import { pathToFileURL } from 'node:url';
|
|
26
26
|
import { DYNAMIC_EGRESS_PREFIXES } from '../../tool.js';
|
|
27
|
+
import { validateManifest } from '../../manifest/json-schema.js';
|
|
28
|
+
import { manifestConnectionToWire, manifestToWireCli, manifestToWireTools } from './manifest-wire.js';
|
|
29
|
+
import { toWireListPayload as toWireListPayloadFn } from './wire.js';
|
|
27
30
|
export class Registry {
|
|
28
31
|
// Map keyed by `cli.id`. Stable iteration order matches insertion which
|
|
29
32
|
// matches directory-listing order from `fs.readdir` (sorted).
|
|
@@ -36,7 +39,22 @@ export class Registry {
|
|
|
36
39
|
// later definition was dropped (see `resolveCollision`). A *malformed* baseline
|
|
37
40
|
// package still fails the boot hard; a *duplicate* never does (non-strict).
|
|
38
41
|
loadFailures;
|
|
39
|
-
|
|
42
|
+
// Lazy mode only: CLIs catalogued from manifest.json, keyed by cli id. Their
|
|
43
|
+
// handler modules are imported on first `resolveTool` (see `resolvedCache`).
|
|
44
|
+
// Empty in eager mode.
|
|
45
|
+
lazyByCliId;
|
|
46
|
+
// Lazy mode only: memoizes the in-flight/settled import of a lazy CLI's module
|
|
47
|
+
// so concurrent `resolveTool` calls for the same CLI import it once. A rejected
|
|
48
|
+
// import is evicted so a later call can retry.
|
|
49
|
+
resolvedCache;
|
|
50
|
+
// Lazy mode only (AKAI-2408): connections embedded in a MIXED package's
|
|
51
|
+
// manifest.json, keyed by slug. Identity-only (no handlers), so they never
|
|
52
|
+
// import a module — they are projected onto `/tools/list` via
|
|
53
|
+
// `manifestConnectionToWire`, byte-identically to an eager ConnectionEntry.
|
|
54
|
+
// Empty in eager mode. Their slug space is UNIFIED with eager connections'
|
|
55
|
+
// (see `chooseConn` in `load`), so a duplicate collides the same way.
|
|
56
|
+
manifestConnBySlug;
|
|
57
|
+
constructor(entries, connections, loadFailures, lazyClis = [], manifestConns = []) {
|
|
40
58
|
this.byCliId = new Map();
|
|
41
59
|
for (const e of entries)
|
|
42
60
|
this.byCliId.set(e.cli.id, e);
|
|
@@ -44,6 +62,13 @@ export class Registry {
|
|
|
44
62
|
for (const c of connections)
|
|
45
63
|
this.byConnectionSlug.set(c.connection.slug, c);
|
|
46
64
|
this.loadFailures = loadFailures;
|
|
65
|
+
this.lazyByCliId = new Map();
|
|
66
|
+
for (const l of lazyClis)
|
|
67
|
+
this.lazyByCliId.set(l.cliId, l);
|
|
68
|
+
this.resolvedCache = new Map();
|
|
69
|
+
this.manifestConnBySlug = new Map();
|
|
70
|
+
for (const m of manifestConns)
|
|
71
|
+
this.manifestConnBySlug.set(m.slug, m);
|
|
47
72
|
}
|
|
48
73
|
static async load(opts) {
|
|
49
74
|
const failures = [];
|
|
@@ -134,18 +159,90 @@ export class Registry {
|
|
|
134
159
|
// not route baseline packages through `customerPath` (source is assigned by
|
|
135
160
|
// which path a package came from): either would let a customer shadow a
|
|
136
161
|
// first-party tool, the exact outage class this loader defends against.
|
|
137
|
-
if (opts.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
162
|
+
if (!opts.lazy) {
|
|
163
|
+
if (opts.baselinePath) {
|
|
164
|
+
const scan = await scanPath(opts.baselinePath, 'baseline', opts.logger);
|
|
165
|
+
ingest(scan.loaded);
|
|
166
|
+
failures.push(...scan.failures);
|
|
167
|
+
}
|
|
168
|
+
if (opts.customerPath) {
|
|
169
|
+
const scan = await scanPath(opts.customerPath, 'customer', opts.logger);
|
|
170
|
+
ingest(scan.loaded);
|
|
171
|
+
failures.push(...scan.failures);
|
|
172
|
+
}
|
|
173
|
+
return new Registry(Array.from(cliById.values()), Array.from(connBySlug.values()), failures);
|
|
141
174
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
175
|
+
const cliChoice = new Map();
|
|
176
|
+
const chooseCli = (cand) => {
|
|
177
|
+
const existing = cliChoice.get(cand.id);
|
|
178
|
+
if (!existing) {
|
|
179
|
+
cliChoice.set(cand.id, cand);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const replace = resolveCollision('CLI id', cand.id, { packagePath: existing.packagePath, source: existing.source, override: existing.override }, { packagePath: cand.packagePath, source: cand.source, override: cand.override });
|
|
183
|
+
if (replace)
|
|
184
|
+
cliChoice.set(cand.id, cand);
|
|
185
|
+
};
|
|
186
|
+
const connChoice = new Map();
|
|
187
|
+
const chooseConn = (cand) => {
|
|
188
|
+
const existing = connChoice.get(cand.slug);
|
|
189
|
+
if (!existing) {
|
|
190
|
+
connChoice.set(cand.slug, cand);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const replace = resolveCollision('connection slug', cand.slug, { packagePath: existing.packagePath, source: existing.source, override: existing.override }, { packagePath: cand.packagePath, source: cand.source, override: cand.override });
|
|
194
|
+
if (replace)
|
|
195
|
+
connChoice.set(cand.slug, cand);
|
|
196
|
+
};
|
|
197
|
+
const ingestLazyScan = (scan) => {
|
|
145
198
|
failures.push(...scan.failures);
|
|
199
|
+
// Manifest-less CLIs → unified CLI chooser; eager connections → unified
|
|
200
|
+
// connection chooser (slug space is independent of the cli-id space).
|
|
201
|
+
for (const item of scan.eager) {
|
|
202
|
+
if (item.kind === 'connection') {
|
|
203
|
+
chooseConn({ kind: 'eager', slug: item.entry.connection.slug, source: item.entry.source, packagePath: item.entry.packagePath, override: item.entry.connection.override === true, entry: item.entry });
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
chooseCli({ kind: 'eager', id: item.entry.cli.id, source: item.entry.source, packagePath: item.entry.packagePath, override: item.entry.cli.override === true, entry: item.entry });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
for (const l of scan.lazyClis) {
|
|
210
|
+
chooseCli({ kind: 'lazy', id: l.cliId, source: l.source, packagePath: l.packagePath, override: l.override, lazy: l });
|
|
211
|
+
}
|
|
212
|
+
for (const m of scan.manifestConns) {
|
|
213
|
+
chooseConn({ kind: 'manifest', slug: m.slug, source: m.source, packagePath: m.packagePath, override: m.override, manifest: m });
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
// Same baseline-before-customer invariant as the eager path.
|
|
217
|
+
if (opts.baselinePath)
|
|
218
|
+
ingestLazyScan(await scanPathLazy(opts.baselinePath, 'baseline', opts.logger));
|
|
219
|
+
if (opts.customerPath)
|
|
220
|
+
ingestLazyScan(await scanPathLazy(opts.customerPath, 'customer', opts.logger));
|
|
221
|
+
const eagerEntries = [];
|
|
222
|
+
const lazyEntries = [];
|
|
223
|
+
for (const cand of cliChoice.values()) {
|
|
224
|
+
if (cand.kind === 'eager')
|
|
225
|
+
eagerEntries.push(cand.entry);
|
|
226
|
+
else
|
|
227
|
+
lazyEntries.push(cand.lazy);
|
|
146
228
|
}
|
|
147
|
-
|
|
148
|
-
|
|
229
|
+
const eagerConns = [];
|
|
230
|
+
const manifestConns = [];
|
|
231
|
+
for (const cand of connChoice.values()) {
|
|
232
|
+
if (cand.kind === 'eager')
|
|
233
|
+
eagerConns.push(cand.entry);
|
|
234
|
+
else
|
|
235
|
+
manifestConns.push(cand.manifest);
|
|
236
|
+
}
|
|
237
|
+
return new Registry(eagerEntries, eagerConns, failures, lazyEntries, manifestConns);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Synchronous lookup — resolves only EAGERLY-loaded CLIs. In lazy mode a CLI
|
|
241
|
+
* catalogued from its manifest hasn't imported its handler module yet, so this
|
|
242
|
+
* returns `undefined` for it. Callers that must execute a tool should use the
|
|
243
|
+
* async {@link resolveTool}, which imports the module on demand and works in
|
|
244
|
+
* both modes. Kept for eager-mode callers and back-compat.
|
|
245
|
+
*/
|
|
149
246
|
lookupTool(cliId, toolKey) {
|
|
150
247
|
const entry = this.byCliId.get(cliId);
|
|
151
248
|
if (!entry)
|
|
@@ -155,6 +252,45 @@ export class Registry {
|
|
|
155
252
|
return undefined;
|
|
156
253
|
return { cli: entry.cli, toolKey, tool, source: entry.source };
|
|
157
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Resolve a tool for execution in BOTH modes. Eager: identical to
|
|
257
|
+
* `lookupTool`. Lazy: if the CLI is only catalogued (manifest), import its
|
|
258
|
+
* handler module now (memoized, so concurrent calls import once) and then look
|
|
259
|
+
* up the tool on the freshly-loaded, branded CLI. Returns `undefined` for an
|
|
260
|
+
* unknown cli/tool exactly like `lookupTool`.
|
|
261
|
+
*/
|
|
262
|
+
async resolveTool(cliId, toolKey) {
|
|
263
|
+
const eager = this.lookupTool(cliId, toolKey);
|
|
264
|
+
if (eager)
|
|
265
|
+
return eager;
|
|
266
|
+
const lazy = this.lazyByCliId.get(cliId);
|
|
267
|
+
if (!lazy)
|
|
268
|
+
return undefined;
|
|
269
|
+
const entry = await this.resolveLazyEntry(lazy);
|
|
270
|
+
const tool = entry.cli.tools[toolKey];
|
|
271
|
+
if (!tool)
|
|
272
|
+
return undefined;
|
|
273
|
+
return { cli: entry.cli, toolKey, tool, source: entry.source };
|
|
274
|
+
}
|
|
275
|
+
/** Import (once) the module behind a lazy CLI entry and return its
|
|
276
|
+
* RegistryEntry. A failed import is evicted from the cache so a later call can
|
|
277
|
+
* retry rather than being permanently poisoned. */
|
|
278
|
+
resolveLazyEntry(lazy) {
|
|
279
|
+
const cached = this.resolvedCache.get(lazy.cliId);
|
|
280
|
+
if (cached)
|
|
281
|
+
return cached;
|
|
282
|
+
const p = (async () => {
|
|
283
|
+
const loaded = await loadPackageEntry(lazy.entryPoint, lazy.packagePath, lazy.source);
|
|
284
|
+
for (const item of loaded) {
|
|
285
|
+
if (item.kind === 'cli' && item.entry.cli.id === lazy.cliId)
|
|
286
|
+
return item.entry;
|
|
287
|
+
}
|
|
288
|
+
throw new Error(`registry: lazy import of ${lazy.packagePath} did not yield a CLI with id '${lazy.cliId}' (manifest/module drift)`);
|
|
289
|
+
})();
|
|
290
|
+
p.catch(() => this.resolvedCache.delete(lazy.cliId));
|
|
291
|
+
this.resolvedCache.set(lazy.cliId, p);
|
|
292
|
+
return p;
|
|
293
|
+
}
|
|
158
294
|
entries() {
|
|
159
295
|
return Array.from(this.byCliId.values());
|
|
160
296
|
}
|
|
@@ -177,12 +313,29 @@ export class Registry {
|
|
|
177
313
|
customerCount++;
|
|
178
314
|
toolCount += Object.keys(e.cli.tools).length;
|
|
179
315
|
}
|
|
316
|
+
// Lazy CLIs count toward the same totals — tool count comes from the
|
|
317
|
+
// manifest (no import needed), so the boot log reports the true surface.
|
|
318
|
+
for (const l of this.lazyByCliId.values()) {
|
|
319
|
+
if (l.source === 'baseline')
|
|
320
|
+
baselineCount++;
|
|
321
|
+
else
|
|
322
|
+
customerCount++;
|
|
323
|
+
toolCount += l.manifest.tools.length;
|
|
324
|
+
}
|
|
180
325
|
for (const c of this.byConnectionSlug.values()) {
|
|
181
326
|
if (c.source === 'baseline')
|
|
182
327
|
baselineCount++;
|
|
183
328
|
else
|
|
184
329
|
customerCount++;
|
|
185
330
|
}
|
|
331
|
+
// Manifest-embedded connections (AKAI-2408) count toward the same totals —
|
|
332
|
+
// no import needed, the slug/source come straight from the manifest.
|
|
333
|
+
for (const m of this.manifestConnBySlug.values()) {
|
|
334
|
+
if (m.source === 'baseline')
|
|
335
|
+
baselineCount++;
|
|
336
|
+
else
|
|
337
|
+
customerCount++;
|
|
338
|
+
}
|
|
186
339
|
// An intentional override is not a load failure — split it out so
|
|
187
340
|
// `failedCount` means "something actually went wrong" (safe to alert on).
|
|
188
341
|
let overriddenCount = 0;
|
|
@@ -190,15 +343,45 @@ export class Registry {
|
|
|
190
343
|
if (f.kind === 'overridden')
|
|
191
344
|
overriddenCount++;
|
|
192
345
|
return {
|
|
193
|
-
cliCount: this.byCliId.size,
|
|
346
|
+
cliCount: this.byCliId.size + this.lazyByCliId.size,
|
|
194
347
|
toolCount,
|
|
195
|
-
connectionCount: this.byConnectionSlug.size,
|
|
348
|
+
connectionCount: this.byConnectionSlug.size + this.manifestConnBySlug.size,
|
|
196
349
|
baselineCount,
|
|
197
350
|
customerCount,
|
|
198
351
|
failedCount: this.loadFailures.length - overriddenCount,
|
|
199
352
|
overriddenCount,
|
|
200
353
|
};
|
|
201
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Build the `/tools/list` wire payload in BOTH modes. Eager: delegates to the
|
|
357
|
+
* shared projection over loaded entries. Lazy: projects the manifest catalog
|
|
358
|
+
* (no imports) and merges it with any eagerly-loaded CLIs + connections,
|
|
359
|
+
* re-sorted to the same stable order the eager payload uses (CLIs by
|
|
360
|
+
* `id.localeCompare`; tools grouped by cli then tool key). The two are
|
|
361
|
+
* byte-identical per package — see test/registry/manifest-wire.test.ts.
|
|
362
|
+
*/
|
|
363
|
+
toWirePayload(tenant = null) {
|
|
364
|
+
const eager = toWireListPayloadFn(this.entries(), this.connections(), tenant);
|
|
365
|
+
if (this.lazyByCliId.size === 0 && this.manifestConnBySlug.size === 0)
|
|
366
|
+
return eager;
|
|
367
|
+
const lazyClis = [];
|
|
368
|
+
const lazyTools = [];
|
|
369
|
+
for (const l of this.lazyByCliId.values()) {
|
|
370
|
+
lazyClis.push(manifestToWireCli(l.manifest, l.source));
|
|
371
|
+
lazyTools.push(...manifestToWireTools(l.manifest, l.source));
|
|
372
|
+
}
|
|
373
|
+
const clis = [...eager.clis, ...lazyClis].sort((a, b) => a.id.localeCompare(b.id));
|
|
374
|
+
const tools = [...eager.tools, ...lazyTools].sort((a, b) => a.cli.localeCompare(b.cli) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
375
|
+
// Manifest-embedded connections (AKAI-2408) project via `manifestConnectionToWire`
|
|
376
|
+
// — byte-identical to `toWireConnection` — and merge with the eager ones,
|
|
377
|
+
// re-sorted by slug to match `toWireListPayload`'s connection ordering. The
|
|
378
|
+
// merged array is indistinguishable from an all-eager one.
|
|
379
|
+
const manifestConns = [...this.manifestConnBySlug.values()].map((m) => manifestConnectionToWire(m.connection, m.source));
|
|
380
|
+
const connections = manifestConns.length === 0
|
|
381
|
+
? eager.connections
|
|
382
|
+
: [...eager.connections, ...manifestConns].sort((a, b) => a.slug.localeCompare(b.slug));
|
|
383
|
+
return { ...eager, clis, tools, connections };
|
|
384
|
+
}
|
|
202
385
|
}
|
|
203
386
|
/**
|
|
204
387
|
* Scan one root directory for SDK-authored CLI packages. Each immediate
|
|
@@ -269,6 +452,140 @@ async function scanPath(root, source, logger) {
|
|
|
269
452
|
}
|
|
270
453
|
return { loaded, failures };
|
|
271
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* Lazy variant of {@link scanPath}. Per package:
|
|
457
|
+
* - a valid `manifest.json` ⇒ catalog it as a lazy CLI (no module import); the
|
|
458
|
+
* entry point is resolved now so `resolveTool` can import it later.
|
|
459
|
+
* - no/invalid manifest ⇒ import eagerly, exactly as `scanPath` does (this is
|
|
460
|
+
* how connection packages and any manifest-less CLI keep working).
|
|
461
|
+
* Failure handling mirrors `scanPath`: a broken BASELINE package throws (bad
|
|
462
|
+
* deploy); a broken CUSTOMER package is recorded and skipped.
|
|
463
|
+
*/
|
|
464
|
+
async function scanPathLazy(root, source, logger) {
|
|
465
|
+
let dirents;
|
|
466
|
+
try {
|
|
467
|
+
dirents = await fs.readdir(root, { withFileTypes: true });
|
|
468
|
+
}
|
|
469
|
+
catch (err) {
|
|
470
|
+
if (err.code === 'ENOENT') {
|
|
471
|
+
logger?.warn({ root, source }, 'registry: package root does not exist; treating as empty');
|
|
472
|
+
return { lazyClis: [], manifestConns: [], eager: [], failures: [] };
|
|
473
|
+
}
|
|
474
|
+
throw err;
|
|
475
|
+
}
|
|
476
|
+
const lazyClis = [];
|
|
477
|
+
const manifestConns = [];
|
|
478
|
+
const eager = [];
|
|
479
|
+
const failures = [];
|
|
480
|
+
const subdirs = dirents
|
|
481
|
+
.filter((d) => d.isDirectory())
|
|
482
|
+
.map((d) => d.name)
|
|
483
|
+
.sort();
|
|
484
|
+
for (const name of subdirs) {
|
|
485
|
+
const packagePath = path.join(root, name);
|
|
486
|
+
const manifest = await readCliManifest(packagePath, logger);
|
|
487
|
+
if (manifest) {
|
|
488
|
+
const entryPoint = await resolveEntryPoint(packagePath);
|
|
489
|
+
if (!entryPoint) {
|
|
490
|
+
// A manifest we could serve on /tools/list but never execute is worse
|
|
491
|
+
// than absent. Match the eager loader, which SKIPS a package with no
|
|
492
|
+
// resolvable entry point (see scanPath) — so the lazy catalog advertises
|
|
493
|
+
// exactly the packages the eager one would load, never a phantom tool.
|
|
494
|
+
logger?.warn({ packagePath, source }, 'registry: manifest present but no resolvable entry point — skipping (cannot execute)');
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
lazyClis.push({
|
|
498
|
+
cliId: manifest.id,
|
|
499
|
+
manifest,
|
|
500
|
+
source,
|
|
501
|
+
packagePath,
|
|
502
|
+
entryPoint,
|
|
503
|
+
override: manifest.override === true,
|
|
504
|
+
});
|
|
505
|
+
// MIXED package (AKAI-2408): the CLI manifest embeds its sibling connection
|
|
506
|
+
// so a mixed package loads LAZILY instead of falling back to eager import.
|
|
507
|
+
// Surface it as a manifest-sourced connection so it participates in the
|
|
508
|
+
// catalog + slug-collision detection exactly like an eager ConnectionEntry.
|
|
509
|
+
// Its handler-less identity needs no module import — only the CLI's does.
|
|
510
|
+
if (manifest.connection) {
|
|
511
|
+
manifestConns.push({
|
|
512
|
+
slug: manifest.connection.slug,
|
|
513
|
+
connection: manifest.connection,
|
|
514
|
+
source,
|
|
515
|
+
packagePath,
|
|
516
|
+
override: manifest.connection.override === true,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
// No usable manifest → eager import (connection packages + manifest-less
|
|
522
|
+
// CLIs), byte-for-byte the same per-package handling as `scanPath`.
|
|
523
|
+
const entryPoint = await resolveEntryPoint(packagePath);
|
|
524
|
+
if (!entryPoint) {
|
|
525
|
+
logger?.warn({ packagePath }, 'registry: skipping — no package.json or resolvable entry point');
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
for (const item of await loadPackageEntry(entryPoint, packagePath, source))
|
|
530
|
+
eager.push(item);
|
|
531
|
+
}
|
|
532
|
+
catch (err) {
|
|
533
|
+
if (source === 'baseline')
|
|
534
|
+
throw err;
|
|
535
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
536
|
+
logger?.error({ packagePath, source, error: message }, 'registry: customer package failed to load — skipping');
|
|
537
|
+
failures.push({ packagePath, source, error: message });
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return { lazyClis, manifestConns, eager, failures };
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Read + shallow-validate a package's `manifest.json`. Returns the parsed
|
|
544
|
+
* manifest when it looks like a CLI manifest (string `id` + `tools` array), or
|
|
545
|
+
* `undefined` when the file is absent, unreadable, unparseable, or the wrong
|
|
546
|
+
* shape — in every "undefined" case the caller falls back to eager import, so a
|
|
547
|
+
* bad manifest degrades to today's behavior rather than dropping the package.
|
|
548
|
+
*
|
|
549
|
+
* A MIXED package's `manifest.connection` block (AKAI-2408) is validated as part
|
|
550
|
+
* of the full-schema check below, so a returned manifest with `connection` set is
|
|
551
|
+
* safe for the caller to surface as a manifest-sourced connection; a malformed
|
|
552
|
+
* connection block fails validation and the whole package falls back to eager.
|
|
553
|
+
*/
|
|
554
|
+
async function readCliManifest(packagePath, logger) {
|
|
555
|
+
const manifestPath = path.join(packagePath, 'manifest.json');
|
|
556
|
+
let raw;
|
|
557
|
+
try {
|
|
558
|
+
raw = await fs.readFile(manifestPath, 'utf8');
|
|
559
|
+
}
|
|
560
|
+
catch (err) {
|
|
561
|
+
if (err.code === 'ENOENT')
|
|
562
|
+
return undefined;
|
|
563
|
+
logger?.warn({ packagePath, error: err.message }, 'registry: manifest.json unreadable — importing eagerly');
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
566
|
+
let parsed;
|
|
567
|
+
try {
|
|
568
|
+
parsed = JSON.parse(raw);
|
|
569
|
+
}
|
|
570
|
+
catch {
|
|
571
|
+
logger?.warn({ packagePath }, 'registry: manifest.json is not valid JSON — importing eagerly');
|
|
572
|
+
return undefined;
|
|
573
|
+
}
|
|
574
|
+
// Validate against the full manifest schema, not a shallow shape check. A
|
|
575
|
+
// manifest missing required fields (instructions / secrets / a tool's
|
|
576
|
+
// secretKeys, …) or carrying a broken dynamic-egress ref must fall back to
|
|
577
|
+
// eager import here — otherwise it would slip through and throw later in the
|
|
578
|
+
// wire projection (`manifestToWireCli` / `manifestToWireTools`), which is the
|
|
579
|
+
// exact "bad manifest degrades, not crashes" contract this function promises.
|
|
580
|
+
try {
|
|
581
|
+
validateManifest(parsed);
|
|
582
|
+
}
|
|
583
|
+
catch (err) {
|
|
584
|
+
logger?.warn({ packagePath, error: err instanceof Error ? err.message : String(err) }, 'registry: manifest.json failed schema validation — importing eagerly');
|
|
585
|
+
return undefined;
|
|
586
|
+
}
|
|
587
|
+
return parsed;
|
|
588
|
+
}
|
|
272
589
|
async function resolveEntryPoint(packagePath) {
|
|
273
590
|
const manifestPath = path.join(packagePath, 'package.json');
|
|
274
591
|
let manifest;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest → wire projection.
|
|
3
|
+
*
|
|
4
|
+
* The registry's `/tools/list` payload can be produced two ways from the exact
|
|
5
|
+
* same CLI definition:
|
|
6
|
+
* 1. from the in-memory branded CLI object (`toWireCli`/`toWireTool` in
|
|
7
|
+
* wire.ts) — requires importing every package's module graph at boot, and
|
|
8
|
+
* 2. from the package's `manifest.json` (`cli.toSchema()` output) — a pure
|
|
9
|
+
* JSON read, no module import.
|
|
10
|
+
*
|
|
11
|
+
* These helpers implement (2). They MUST stay byte-identical to (1) so a
|
|
12
|
+
* manifest-driven catalog is indistinguishable on the wire from the eager one —
|
|
13
|
+
* `test/registry/manifest-wire.test.ts` asserts exactly that. The manifest is
|
|
14
|
+
* the same projection `/tools/list` was always
|
|
15
|
+
* documented to consume (see to-schema.ts), so this is completing that path,
|
|
16
|
+
* not inventing a second source of truth.
|
|
17
|
+
*
|
|
18
|
+
* Egress normalization is delegated to the shared `wireEgress` so the dynamic
|
|
19
|
+
* (`{ from: 'secret:KEY' }`) and native (`null` ⇒ `[]`) cases can never drift
|
|
20
|
+
* from the branded projection.
|
|
21
|
+
*/
|
|
22
|
+
import type { ConnectionManifest, ManifestConnection } from '../../manifest/types.js';
|
|
23
|
+
import { type WireCliEntry, type WireConnectionEntry, type WireToolEntry } from './wire.js';
|
|
24
|
+
export type WireSource = 'baseline' | 'customer';
|
|
25
|
+
/** Project one manifest's CLI-level metadata to its wire entry. Mirrors `toWireCli`. */
|
|
26
|
+
export declare function manifestToWireCli(m: ConnectionManifest, source: WireSource): WireCliEntry;
|
|
27
|
+
/**
|
|
28
|
+
* Project one manifest's tools to wire entries. Mirrors `toWireTool`.
|
|
29
|
+
* `manifest.tools` is already sorted by tool key at generation time (to-schema
|
|
30
|
+
* uses the same `Object.keys(tools).sort()` the wire assembly uses), so array
|
|
31
|
+
* order is preserved rather than re-sorted.
|
|
32
|
+
*/
|
|
33
|
+
export declare function manifestToWireTools(m: ConnectionManifest, source: WireSource): WireToolEntry[];
|
|
34
|
+
/**
|
|
35
|
+
* Project a MIXED package's embedded {@link ManifestConnection} to its wire
|
|
36
|
+
* entry (AKAI-2408). Mirrors `toWireConnection` (wire.ts) byte-for-byte — same
|
|
37
|
+
* defensive validation and optional-field elision rules — so a connection
|
|
38
|
+
* registered FROM A MANIFEST is indistinguishable on `/tools/list` from one
|
|
39
|
+
* loaded eagerly from its module. `test/registry/connection-manifest.test.ts`
|
|
40
|
+
* asserts exactly that byte-identity across every connection shape (a
|
|
41
|
+
* dropped/diverging connection is auth-breaking).
|
|
42
|
+
*
|
|
43
|
+
* The elision that matters most: jwtRefresh is dropped whenever an `oauth` block
|
|
44
|
+
* is present OR `authKind === 'oauth2'` (the two are mutually exclusive on the
|
|
45
|
+
* wire), and apiKeyHeader is only emitted for `authKind` `apiKey` — identical to
|
|
46
|
+
* the branded path. Host-map/secret/jwtRefresh validation is delegated to the
|
|
47
|
+
* SAME shared helpers wire.ts uses, so those cases can never drift.
|
|
48
|
+
*/
|
|
49
|
+
export declare function manifestConnectionToWire(mc: ManifestConnection, source: WireSource): WireConnectionEntry;
|
|
50
|
+
/**
|
|
51
|
+
* Assemble the CLI + tool halves of a `/tools/list` payload from a set of
|
|
52
|
+
* manifests, applying the SAME ordering as `toWireListPayload`: CLIs sorted by
|
|
53
|
+
* `id.localeCompare`, tools grouped per CLI in manifest (already key-sorted)
|
|
54
|
+
* order. Connections are NOT sourced from manifests (they carry no CLI
|
|
55
|
+
* manifest) — the caller supplies those from the eagerly-loaded connection
|
|
56
|
+
* packages, exactly as today.
|
|
57
|
+
*/
|
|
58
|
+
export declare function manifestsToWireCatalog(manifests: ReadonlyArray<{
|
|
59
|
+
manifest: ConnectionManifest;
|
|
60
|
+
source: WireSource;
|
|
61
|
+
}>): {
|
|
62
|
+
clis: WireCliEntry[];
|
|
63
|
+
tools: WireToolEntry[];
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=manifest-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-wire.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry/manifest-wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAEjD,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,GAAG,YAAY,CA6BzF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,GAAG,aAAa,EAAE,CAiB9F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,GAAG,mBAAmB,CA+DxG;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,aAAa,CAAC;IAAE,QAAQ,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,GAC7E;IAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAMlD"}
|