@akai-workflow-builder/cli-sdk 0.4.0 → 0.5.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 +14 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -3
- package/dist/ctx/build-ctx.d.ts.map +1 -1
- package/dist/ctx/build-ctx.js +6 -1
- package/dist/ctx/safe-fetch.d.ts +24 -0
- package/dist/ctx/safe-fetch.d.ts.map +1 -1
- package/dist/ctx/safe-fetch.js +66 -6
- package/dist/define-cli.d.ts.map +1 -1
- package/dist/define-cli.js +5 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest/json-schema.d.ts +2 -0
- package/dist/manifest/json-schema.d.ts.map +1 -1
- package/dist/manifest/json-schema.js +6 -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 +9 -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 +20 -2
- package/dist/runtime/registry/index.d.ts +3 -1
- package/dist/runtime/registry/index.d.ts.map +1 -1
- package/dist/runtime/registry/index.js +2 -0
- package/dist/runtime/registry/loader.d.ts +43 -0
- package/dist/runtime/registry/loader.d.ts.map +1 -1
- package/dist/runtime/registry/loader.js +260 -11
- package/dist/runtime/registry/manifest-wire.d.ts +49 -0
- package/dist/runtime/registry/manifest-wire.d.ts.map +1 -0
- package/dist/runtime/registry/manifest-wire.js +72 -0
- package/dist/runtime/registry/wire.d.ts +8 -0
- package/dist/runtime/registry/wire.d.ts.map +1 -1
- package/dist/runtime/registry/wire.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to `@akai-workflow-builder/cli-sdk` are documented here.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
|
|
7
|
+
## [0.5.0](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.4.1...cli-sdk-v0.5.0) (2026-08-20)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* lazy manifest tool loading (AKAI-2408) ([5ebbebb](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/5ebbebbc19615a28a323f24c226e8aa0b027b4b6))
|
|
13
|
+
|
|
14
|
+
## [0.4.1](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.4.0...cli-sdk-v0.4.1) (2026-08-13)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* cap ctx.fetch response size (AKAI-2325) ([#78](https://github.com/akai-workflow-builder/akai-cli-sdk/issues/78)) ([22dc513](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/22dc5130dfb1dea7eb1e5663a66da64041b29a18))
|
|
20
|
+
|
|
7
21
|
## [0.4.0](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.3.0...cli-sdk-v0.4.0) (2026-08-03)
|
|
8
22
|
|
|
9
23
|
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAiBzC,KAAK,UAAU,GACX;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC1D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAyB7D;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAiBzC,KAAK,UAAU,GACX;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC1D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAyB7D;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4DlE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;;;;;;;GAQG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAclE"}
|
package/dist/cli.js
CHANGED
|
@@ -93,9 +93,21 @@ export async function loadCli(packagePath) {
|
|
|
93
93
|
throw new Error(`failed to import ${entry}: ${msg}`);
|
|
94
94
|
}
|
|
95
95
|
const def = mod.default;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
// The default export is either a single defineCLI() result or an array mixing
|
|
97
|
+
// a CLI with a defineConnection() (a package may ship both, e.g. a tenant
|
|
98
|
+
// connector that exports `[cli, connection]`). build-manifest emits ONE
|
|
99
|
+
// manifest per package, so pick the sole CLI out of the array.
|
|
100
|
+
const isCli = (x) => x !== null && typeof x === 'object' && x.__akaiCLI === true;
|
|
101
|
+
if (Array.isArray(def)) {
|
|
102
|
+
const clis = def.filter(isCli);
|
|
103
|
+
if (clis.length === 1)
|
|
104
|
+
return clis[0];
|
|
105
|
+
if (clis.length === 0) {
|
|
106
|
+
throw new Error(`${packagePath}: default export array contains no CLIDef (missing __akaiCLI brand)`);
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`${packagePath}: default export array contains ${clis.length} CLIs — build-manifest expects exactly one CLI per package`);
|
|
109
|
+
}
|
|
110
|
+
if (!isCli(def)) {
|
|
99
111
|
throw new Error(`${packagePath}: default export is not a CLIDef (missing __akaiCLI brand)`);
|
|
100
112
|
}
|
|
101
113
|
return def;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-ctx.d.ts","sourceRoot":"","sources":["../../src/ctx/build-ctx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-ctx.d.ts","sourceRoot":"","sources":["../../src/ctx/build-ctx.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAc,MAAM,EAAiB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG1F;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6GAA6G;IAC7G,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,sGAAsG;IACtG,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,8CAA8C;IAC9C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC;AA4ED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAmExD"}
|
package/dist/ctx/build-ctx.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tmpdir } from 'node:os';
|
|
2
|
-
import { createSafeFetch } from './safe-fetch.js';
|
|
2
|
+
import { createSafeFetch, DEFAULT_MAX_RESPONSE_BYTES, PRODUCES_FILES_MAX_RESPONSE_BYTES, } from './safe-fetch.js';
|
|
3
3
|
import { createSafePath } from './safe-path.js';
|
|
4
4
|
import { buildScopedProperties, buildScopedSecrets, } from './secrets.js';
|
|
5
5
|
import { createReadFile } from './read-file.js';
|
|
@@ -89,6 +89,11 @@ export function buildCtx(params) {
|
|
|
89
89
|
cliId: params.cli.id,
|
|
90
90
|
toolName: params.toolName,
|
|
91
91
|
sdkVersion: params.sdkVersion,
|
|
92
|
+
// producesFiles tools stream the response to disk rather than
|
|
93
|
+
// parsing it into JS objects, so a much larger response is safe —
|
|
94
|
+
// see the constants' doc comments in safe-fetch.ts for the prod
|
|
95
|
+
// data behind both numbers.
|
|
96
|
+
maxResponseBytes: tool.options.producesFiles === true ? PRODUCES_FILES_MAX_RESPONSE_BYTES : DEFAULT_MAX_RESPONSE_BYTES,
|
|
92
97
|
...(params.tenantId !== undefined ? { tenantId: params.tenantId } : {}),
|
|
93
98
|
...(clientCert !== undefined ? { clientCert } : {}),
|
|
94
99
|
});
|
package/dist/ctx/safe-fetch.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default per-response byte cap for JSON/text `ctx.fetch` calls (override via
|
|
3
|
+
* {@link SafeFetchBinding.maxResponseBytes}). Grounded in prod trace data
|
|
4
|
+
* (Tempo, `akai-cli-service`, 6h window): typical tool responses are tiny
|
|
5
|
+
* (p50 ~90B, p99 ~230KB, observed max ~0.94MB). 8MB gives ~8x headroom above
|
|
6
|
+
* that observed max while still catching the class of bug this cap exists
|
|
7
|
+
* for — e.g. the >10MB unfiltered `employee-navigator` census report that
|
|
8
|
+
* wedged the executor (it parses the whole body into JS objects, so the
|
|
9
|
+
* *raw* bytes plus V8's per-object overhead is what exhausts memory, not
|
|
10
|
+
* just the wire size).
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_MAX_RESPONSE_BYTES: number;
|
|
13
|
+
/**
|
|
14
|
+
* Cap for tools that declare `options.producesFiles` — they stream the
|
|
15
|
+
* response to a file rather than parsing it into JS objects, so the same
|
|
16
|
+
* memory risk doesn't apply at the same byte count. Grounded in the same
|
|
17
|
+
* prod trace data: real `gdrive download` files up to 46MB were seen
|
|
18
|
+
* succeeding in a single day. 150MB gives >3x headroom above that observed
|
|
19
|
+
* max while still bounding a single call to a small fraction of the
|
|
20
|
+
* executor pod's 1Gi memory limit.
|
|
21
|
+
*/
|
|
22
|
+
export declare const PRODUCES_FILES_MAX_RESPONSE_BYTES: number;
|
|
1
23
|
/**
|
|
2
24
|
* Resolved mutual-TLS client identity — PEM values, not secret-key
|
|
3
25
|
* references. `buildCtx()` resolves `NetworkOptions.clientCert` key refs
|
|
@@ -15,6 +37,8 @@ export interface SafeFetchBinding {
|
|
|
15
37
|
readonly sdkVersion: string;
|
|
16
38
|
readonly tenantId?: string;
|
|
17
39
|
readonly clientCert?: ResolvedClientCert;
|
|
40
|
+
/** Overrides {@link DEFAULT_MAX_RESPONSE_BYTES} for this tool. */
|
|
41
|
+
readonly maxResponseBytes?: number;
|
|
18
42
|
}
|
|
19
43
|
export type SafeFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
20
44
|
export declare function createSafeFetch(binding: SafeFetchBinding): SafeFetch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-fetch.d.ts","sourceRoot":"","sources":["../../src/ctx/safe-fetch.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"safe-fetch.d.ts","sourceRoot":"","sources":["../../src/ctx/safe-fetch.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,QAAkB,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,QAAoB,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC,kEAAkE;IAClE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAyG/E,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAoGpE"}
|
package/dist/ctx/safe-fetch.js
CHANGED
|
@@ -3,7 +3,29 @@ import { request as httpsRequest } from 'node:https';
|
|
|
3
3
|
import { isIPv4, isIPv6 } from 'node:net';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
import { Readable } from 'node:stream';
|
|
6
|
-
import { AkaiEgressError } from '../errors.js';
|
|
6
|
+
import { AkaiEgressError, AkaiResponseTooLargeError } from '../errors.js';
|
|
7
|
+
/**
|
|
8
|
+
* Default per-response byte cap for JSON/text `ctx.fetch` calls (override via
|
|
9
|
+
* {@link SafeFetchBinding.maxResponseBytes}). Grounded in prod trace data
|
|
10
|
+
* (Tempo, `akai-cli-service`, 6h window): typical tool responses are tiny
|
|
11
|
+
* (p50 ~90B, p99 ~230KB, observed max ~0.94MB). 8MB gives ~8x headroom above
|
|
12
|
+
* that observed max while still catching the class of bug this cap exists
|
|
13
|
+
* for — e.g. the >10MB unfiltered `employee-navigator` census report that
|
|
14
|
+
* wedged the executor (it parses the whole body into JS objects, so the
|
|
15
|
+
* *raw* bytes plus V8's per-object overhead is what exhausts memory, not
|
|
16
|
+
* just the wire size).
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
19
|
+
/**
|
|
20
|
+
* Cap for tools that declare `options.producesFiles` — they stream the
|
|
21
|
+
* response to a file rather than parsing it into JS objects, so the same
|
|
22
|
+
* memory risk doesn't apply at the same byte count. Grounded in the same
|
|
23
|
+
* prod trace data: real `gdrive download` files up to 46MB were seen
|
|
24
|
+
* succeeding in a single day. 150MB gives >3x headroom above that observed
|
|
25
|
+
* max while still bounding a single call to a small fraction of the
|
|
26
|
+
* executor pod's 1Gi memory limit.
|
|
27
|
+
*/
|
|
28
|
+
export const PRODUCES_FILES_MAX_RESPONSE_BYTES = 150 * 1024 * 1024;
|
|
7
29
|
// Collapse expanded / partially compressed / leading-zero IPv6 forms to
|
|
8
30
|
// RFC 5952 via WHATWG URL (Ada in Node 24). `dns.lookup` passes numeric
|
|
9
31
|
// literals through verbatim, so an attacker-controlled URL like
|
|
@@ -103,7 +125,8 @@ const FORWARDED_INIT_FIELDS = [
|
|
|
103
125
|
'referrerPolicy',
|
|
104
126
|
];
|
|
105
127
|
export function createSafeFetch(binding) {
|
|
106
|
-
const { egress, cliId, toolName, sdkVersion, tenantId, clientCert } = binding;
|
|
128
|
+
const { egress, cliId, toolName, sdkVersion, tenantId, clientCert, maxResponseBytes } = binding;
|
|
129
|
+
const maxBytes = maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES;
|
|
107
130
|
return async function safeFetch(rawUrl, init = {}) {
|
|
108
131
|
// Coerce once. Otherwise `new URL(rawUrl)` (for validation) and
|
|
109
132
|
// `fetch(rawUrl, …)` would invoke `Symbol.toPrimitive`/`toString` twice,
|
|
@@ -187,12 +210,49 @@ export function createSafeFetch(binding) {
|
|
|
187
210
|
// this path rides `node:https` — same TLS stack, zero dependencies —
|
|
188
211
|
// and adapts back to a standard `Response`. Dev-mode `http:` URLs fall
|
|
189
212
|
// through to plain fetch: there is no TLS handshake to present a cert on.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return
|
|
213
|
+
const response = clientCert !== undefined && u.protocol === 'https:'
|
|
214
|
+
? await mtlsFetch(u, sanitized, clientCert)
|
|
215
|
+
: await fetch(url, sanitized);
|
|
216
|
+
return capResponseBody(response, maxBytes, { hostname: u.hostname, cliId, toolName });
|
|
194
217
|
};
|
|
195
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Wrap a `Response` body so it errors with {@link AkaiResponseTooLargeError}
|
|
221
|
+
* — instead of continuing to buffer — the moment the byte count crosses
|
|
222
|
+
* `maxBytes`. Streaming (not a post-hoc `content-length`/buffered check) so a
|
|
223
|
+
* chunked upstream that never declares its size is still bounded, and the
|
|
224
|
+
* source connection is cancelled on trip so the executor stops paying for a
|
|
225
|
+
* download nothing will read.
|
|
226
|
+
*/
|
|
227
|
+
function capResponseBody(res, maxBytes, info) {
|
|
228
|
+
if (res.body === null)
|
|
229
|
+
return res;
|
|
230
|
+
const reader = res.body.getReader();
|
|
231
|
+
let received = 0;
|
|
232
|
+
const tooLarge = () => new AkaiResponseTooLargeError(`Response from ${info.hostname} was too large (over ${Math.round(maxBytes / (1024 * 1024))}MB). ` +
|
|
233
|
+
`Narrow the request — add a filter, a date/id range, or a pagination/limit parameter — ` +
|
|
234
|
+
`and retry with a smaller result set.`, { hostname: info.hostname, cliId: info.cliId, toolName: info.toolName, maxBytes });
|
|
235
|
+
const body = new ReadableStream({
|
|
236
|
+
async pull(controller) {
|
|
237
|
+
const { done, value } = await reader.read();
|
|
238
|
+
if (done) {
|
|
239
|
+
controller.close();
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
received += value.byteLength;
|
|
243
|
+
if (received > maxBytes) {
|
|
244
|
+
controller.error(tooLarge());
|
|
245
|
+
await reader.cancel(tooLarge()).catch(() => { });
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
controller.enqueue(value);
|
|
249
|
+
},
|
|
250
|
+
cancel(reason) {
|
|
251
|
+
return reader.cancel(reason);
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
return new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
255
|
+
}
|
|
196
256
|
/** Response statuses that must not carry a body (Response ctor throws otherwise). */
|
|
197
257
|
const NULL_BODY_STATUSES = new Set([204, 205, 304]);
|
|
198
258
|
/**
|
package/dist/define-cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-cli.d.ts","sourceRoot":"","sources":["../src/define-cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,OAAO,EAA4B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"define-cli.d.ts","sourceRoot":"","sources":["../src/define-cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,OAAO,EAA4B,MAAM,YAAY,CAAC;AAyPxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAoD/C"}
|
package/dist/define-cli.js
CHANGED
|
@@ -9,6 +9,11 @@ const SecretDeclShape = z.object({
|
|
|
9
9
|
key: z.string({ error: 'key is required' }).min(1, { error: 'key is required' }),
|
|
10
10
|
injected: z.boolean().optional(),
|
|
11
11
|
adminManaged: z.boolean().optional(),
|
|
12
|
+
// serverOnly is part of SecretDecl and is emitted by both the branded and
|
|
13
|
+
// manifest wire projections; without it here zod strips the field at
|
|
14
|
+
// defineCLI, silently dropping a server-only credential's flag before it can
|
|
15
|
+
// reach /tools/list. Pass it through so the type, runtime, and wire agree.
|
|
16
|
+
serverOnly: z.boolean().optional(),
|
|
12
17
|
});
|
|
13
18
|
const PropertyDeclShape = z.object({
|
|
14
19
|
name: z.string({ error: 'name is required' }).min(1, { error: 'name is required' }),
|
package/dist/errors.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export declare class AkaiInputError extends AkaiError {
|
|
|
19
19
|
/** `ctx.fetch` egress allowlist violation. */
|
|
20
20
|
export declare class AkaiEgressError extends AkaiError {
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* `ctx.fetch` response exceeded the SDK's per-call byte cap. Thrown once the
|
|
24
|
+
* cap is crossed mid-stream — the underlying connection is cancelled, so the
|
|
25
|
+
* cap bounds memory even when the upstream never sends `content-length`.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AkaiResponseTooLargeError extends AkaiError {
|
|
28
|
+
}
|
|
22
29
|
/** Required secret is missing or empty at runtime. */
|
|
23
30
|
export declare class AkaiSecretError extends AkaiError {
|
|
24
31
|
}
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC5B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAK5D;AAED,2EAA2E;AAC3E,qBAAa,aAAc,SAAQ,SAAS;CAAG;AAE/C,2EAA2E;AAC3E,qBAAa,mBAAoB,SAAQ,aAAa;CAAG;AAEzD,+EAA+E;AAC/E,qBAAa,cAAe,SAAQ,SAAS;CAAG;AAEhD,8CAA8C;AAC9C,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AAEjD,sDAAsD;AACtD,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AAEjD,+DAA+D;AAC/D,qBAAa,iBAAkB,SAAQ,SAAS;CAAG;AAGnD,8EAA8E;AAC9E,qBAAa,aAAc,SAAQ,SAAS;CAAG;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAC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AM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,aAAa;CA4BjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,CAmBnE"}
|
package/dist/errors.js
CHANGED
|
@@ -23,6 +23,13 @@ export class AkaiInputError extends AkaiError {
|
|
|
23
23
|
/** `ctx.fetch` egress allowlist violation. */
|
|
24
24
|
export class AkaiEgressError extends AkaiError {
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* `ctx.fetch` response exceeded the SDK's per-call byte cap. Thrown once the
|
|
28
|
+
* cap is crossed mid-stream — the underlying connection is cancelled, so the
|
|
29
|
+
* cap bounds memory even when the upstream never sends `content-length`.
|
|
30
|
+
*/
|
|
31
|
+
export class AkaiResponseTooLargeError extends AkaiError {
|
|
32
|
+
}
|
|
26
33
|
/** Required secret is missing or empty at runtime. */
|
|
27
34
|
export class AkaiSecretError extends AkaiError {
|
|
28
35
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { BuildCtxParams } from './ctx/build-ctx.js';
|
|
|
9
9
|
export type { AnyToolDef, CLIDef, CLISpec, ClientCertOptions, ConnectionAuthKind, ConnectionDef, ConnectionOAuthConfig, ConnectionSpec, DynamicEgress, InputOf, NetworkOptions, OAuthAdminField, OutputOf, PropertiesOf, PropertyDecl, RefreshStrategy, SecretDecl, SecretsOf, TokenEndpointAuthMethod, ToolCtx, ToolDef, ToolLogger, ToolOptions, ToolSpec, } from './types.js';
|
|
10
10
|
export { createSafePath } from './ctx/safe-path.js';
|
|
11
11
|
export type { SafePath } from './ctx/safe-path.js';
|
|
12
|
-
export { AkaiConnectionError, AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiSecretError, AkaiSpecError, AkaiToolError, describeError, } from './errors.js';
|
|
12
|
+
export { AkaiConnectionError, AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiResponseTooLargeError, AkaiSecretError, AkaiSpecError, AkaiToolError, describeError, } from './errors.js';
|
|
13
13
|
export type { ToolErrorKind } from './errors.js';
|
|
14
14
|
export { ConnectionManifestSchema, ManifestJSONSchema, SCHEMA_VERSION, toSchema, validateManifest, } from './manifest/index.js';
|
|
15
15
|
export type { ClientCertManifest, ConnectionManifest, DynamicEgressManifest, HttpToolManifest, ManifestProperty, ManifestSecret, NativeToolManifest, SchemaVersion, ToolManifest, } from './manifest/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,YAAY,EACV,UAAU,EACV,MAAM,EACN,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,OAAO,EACP,cAAc,EACd,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,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EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,YAAY,EACV,UAAU,EACV,MAAM,EACN,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,OAAO,EACP,cAAc,EACd,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,5 +5,5 @@ export { defineConnection, isAkaiConnection } from './define-connection.js';
|
|
|
5
5
|
export { buildScopedSecrets, buildScopedProperties } from './ctx/secrets.js';
|
|
6
6
|
export { buildCtx } from './ctx/build-ctx.js';
|
|
7
7
|
export { createSafePath } from './ctx/safe-path.js';
|
|
8
|
-
export { AkaiConnectionError, AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiSecretError, AkaiSpecError, AkaiToolError, describeError, } from './errors.js';
|
|
8
|
+
export { AkaiConnectionError, AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiResponseTooLargeError, AkaiSecretError, AkaiSpecError, AkaiToolError, describeError, } from './errors.js';
|
|
9
9
|
export { ConnectionManifestSchema, ManifestJSONSchema, SCHEMA_VERSION, toSchema, validateManifest, } from './manifest/index.js';
|
|
@@ -25,6 +25,7 @@ export declare const ConnectionManifestSchema: z.ZodObject<{
|
|
|
25
25
|
required: z.ZodBoolean;
|
|
26
26
|
injected: z.ZodOptional<z.ZodBoolean>;
|
|
27
27
|
adminManaged: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
serverOnly: z.ZodOptional<z.ZodBoolean>;
|
|
28
29
|
}, z.core.$strip>>;
|
|
29
30
|
properties: z.ZodArray<z.ZodObject<{
|
|
30
31
|
key: z.ZodString;
|
|
@@ -36,6 +37,7 @@ export declare const ConnectionManifestSchema: z.ZodObject<{
|
|
|
36
37
|
}, z.core.$strip>>;
|
|
37
38
|
connectionSlug: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
39
|
vendorScopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
override: z.ZodOptional<z.ZodBoolean>;
|
|
39
41
|
tools: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
40
42
|
transport: z.ZodLiteral<"http">;
|
|
41
43
|
egress: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA8HrD;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoEnC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAsD,CAAC;AAExF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAE/D"}
|
|
@@ -20,6 +20,9 @@ const ManifestSecretSchema = z.object({
|
|
|
20
20
|
required: z.boolean(),
|
|
21
21
|
injected: z.boolean().optional(),
|
|
22
22
|
adminManaged: z.boolean().optional(),
|
|
23
|
+
// Server-only credential (e.g. a jwtRefresh refresh token). In the validator
|
|
24
|
+
// so validateManifest() round-trips it instead of stripping the flag.
|
|
25
|
+
serverOnly: z.boolean().optional(),
|
|
23
26
|
});
|
|
24
27
|
const ManifestPropertySchema = z.object({
|
|
25
28
|
key: z.string(),
|
|
@@ -105,6 +108,9 @@ const ConnectionManifestBaseSchema = z.object({
|
|
|
105
108
|
// crafted manifest can't smuggle an empty or malformed grouping value.
|
|
106
109
|
connectionSlug: z.string().regex(CONNECTION_SLUG_RE).nullable().optional(),
|
|
107
110
|
vendorScopes: z.array(z.string().min(1)).optional(),
|
|
111
|
+
// Cross-repo override opt-in — in the validator so validateManifest() round-
|
|
112
|
+
// trips it (a manifest-driven registry reads it for collision resolution).
|
|
113
|
+
override: z.boolean().optional(),
|
|
108
114
|
tools: z.array(ToolManifestSchema),
|
|
109
115
|
});
|
|
110
116
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/to-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"to-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/to-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAuCxD"}
|
|
@@ -35,6 +35,7 @@ export function toSchema(cli) {
|
|
|
35
35
|
required: s.required,
|
|
36
36
|
...(s.injected ? { injected: true } : {}),
|
|
37
37
|
...(s.adminManaged ? { adminManaged: true } : {}),
|
|
38
|
+
...(s.serverOnly ? { serverOnly: true } : {}),
|
|
38
39
|
})),
|
|
39
40
|
properties: cli.properties.map((p) => ({
|
|
40
41
|
key: p.key,
|
|
@@ -46,6 +47,7 @@ export function toSchema(cli) {
|
|
|
46
47
|
})),
|
|
47
48
|
connectionSlug: cli.connectionSlug ?? null,
|
|
48
49
|
vendorScopes: [...(cli.vendorScopes ?? [])],
|
|
50
|
+
...(cli.override ? { override: true } : {}),
|
|
49
51
|
tools,
|
|
50
52
|
};
|
|
51
53
|
}
|
package/dist/manifest/types.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface ManifestSecret {
|
|
|
19
19
|
readonly required: boolean;
|
|
20
20
|
readonly injected?: boolean;
|
|
21
21
|
readonly adminManaged?: boolean;
|
|
22
|
+
readonly serverOnly?: boolean;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Non-sensitive tenant property — wire shape of {@link PropertyDecl}.
|
|
@@ -136,6 +137,14 @@ export interface ConnectionManifest {
|
|
|
136
137
|
* `toSchema()` emits `[]` when undeclared — treat absent as no scope.
|
|
137
138
|
*/
|
|
138
139
|
readonly vendorScopes?: readonly string[];
|
|
140
|
+
/**
|
|
141
|
+
* Cross-repo override opt-in — a CUSTOMER package sets this so its CLI id
|
|
142
|
+
* intentionally REPLACES a colliding baseline one. Not emitted to `/tools/list`
|
|
143
|
+
* (the wire never carried it), but a manifest-driven (lazy) registry needs it
|
|
144
|
+
* to resolve collisions the same way the eager loader does. `toSchema()` emits
|
|
145
|
+
* it only when set.
|
|
146
|
+
*/
|
|
147
|
+
readonly override?: boolean;
|
|
139
148
|
readonly tools: readonly ToolManifest[];
|
|
140
149
|
}
|
|
141
150
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/manifest/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAG5B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/manifest/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAA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AQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;CACzC"}
|
|
@@ -2,7 +2,7 @@ import type { ToolLogger } from '../../types.js';
|
|
|
2
2
|
import { type ConvertedFile } from './image-compress.js';
|
|
3
3
|
import type { Registry } from '../registry/index.js';
|
|
4
4
|
import type { ExecuteRequestBody } from '../execute-request.js';
|
|
5
|
-
export type ExecuteErrorCode = 'unknown_tool' | 'invalid_input' | 'secret_unknown_key' | 'secret_missing' | 'property_unknown_key' | 'property_missing' | 'write_not_confirmed' | 'output_channel_missing' | 'egress_blocked' | 'spec_error' | 'handler_error' | 'upstream_not_found' | 'upstream_forbidden' | 'upstream_auth_expired' | 'upstream_invalid_input' | 'upstream_conflict' | 'upstream_rate_limited' | 'upstream_unavailable';
|
|
5
|
+
export type ExecuteErrorCode = 'unknown_tool' | 'invalid_input' | 'secret_unknown_key' | 'secret_missing' | 'property_unknown_key' | 'property_missing' | 'write_not_confirmed' | 'output_channel_missing' | 'egress_blocked' | 'response_too_large' | 'spec_error' | 'handler_error' | 'tool_load_failed' | 'upstream_not_found' | 'upstream_forbidden' | 'upstream_auth_expired' | 'upstream_invalid_input' | 'upstream_conflict' | 'upstream_rate_limited' | 'upstream_unavailable';
|
|
6
6
|
export interface ExecuteSuccess {
|
|
7
7
|
readonly ok: true;
|
|
8
8
|
readonly result: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/executor/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/executor/index.ts"],"names":[],"mappings":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C;IAC5B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAyR/E"}
|
|
@@ -15,7 +15,7 @@ import os from 'node:os';
|
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
import { createRequire } from 'node:module';
|
|
17
17
|
import { buildCtx } from '../../ctx/build-ctx.js';
|
|
18
|
-
import { AkaiError, AkaiEgressError, AkaiPropertyError, AkaiSecretError, AkaiSpecError } from '../../errors.js';
|
|
18
|
+
import { AkaiError, AkaiEgressError, AkaiPropertyError, AkaiResponseTooLargeError, AkaiSecretError, AkaiSpecError, } from '../../errors.js';
|
|
19
19
|
import { DYNAMIC_EGRESS_PREFIXES } from '../../tool.js';
|
|
20
20
|
import { create as tarCreate } from 'tar';
|
|
21
21
|
import { z } from 'zod';
|
|
@@ -29,7 +29,22 @@ import { redactSecrets } from './redact.js';
|
|
|
29
29
|
const { version: SDK_VERSION } = createRequire(import.meta.url)('../../../package.json');
|
|
30
30
|
export async function executeTool(params) {
|
|
31
31
|
const { registry, body, logger, signal, workdir, tenantId, localOutput } = params;
|
|
32
|
-
|
|
32
|
+
// resolveTool works in both eager and lazy mode: in lazy mode it imports the
|
|
33
|
+
// CLI's handler module on first use (and caches it). Eager mode is a plain map
|
|
34
|
+
// hit, same as lookupTool. The lazy import can throw (bad bundle, manifest/
|
|
35
|
+
// module drift) — catch it so a load failure returns a structured error
|
|
36
|
+
// envelope instead of escaping as an unhandled exception (the sync lookupTool
|
|
37
|
+
// it replaced could never throw).
|
|
38
|
+
let lookup;
|
|
39
|
+
try {
|
|
40
|
+
lookup = await registry.resolveTool(body.cli, body.tool);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
return failure('tool_load_failed', `failed to load tool '${body.cli}.${body.tool}': ${err instanceof Error ? err.message : String(err)}`, {
|
|
44
|
+
cli: body.cli,
|
|
45
|
+
tool: body.tool,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
33
48
|
if (!lookup) {
|
|
34
49
|
return failure('unknown_tool', `no tool '${body.cli}.${body.tool}' in registry`, {
|
|
35
50
|
cli: body.cli,
|
|
@@ -162,6 +177,9 @@ export async function executeTool(params) {
|
|
|
162
177
|
if (err instanceof AkaiEgressError) {
|
|
163
178
|
return failure('egress_blocked', err.message, err.meta);
|
|
164
179
|
}
|
|
180
|
+
if (err instanceof AkaiResponseTooLargeError) {
|
|
181
|
+
return failure('response_too_large', err.message, err.meta);
|
|
182
|
+
}
|
|
165
183
|
if (err instanceof AkaiSecretError) {
|
|
166
184
|
return failure('secret_missing', err.message, err.meta);
|
|
167
185
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
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 { manifestToWireCli, manifestToWireTools, manifestsToWireCatalog, } from './manifest-wire.js';
|
|
5
7
|
//# 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,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
@@ -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,61 @@ 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;
|
|
32
47
|
private constructor();
|
|
33
48
|
static load(opts: LoadRegistryOptions): Promise<Registry>;
|
|
49
|
+
/**
|
|
50
|
+
* Synchronous lookup — resolves only EAGERLY-loaded CLIs. In lazy mode a CLI
|
|
51
|
+
* catalogued from its manifest hasn't imported its handler module yet, so this
|
|
52
|
+
* returns `undefined` for it. Callers that must execute a tool should use the
|
|
53
|
+
* async {@link resolveTool}, which imports the module on demand and works in
|
|
54
|
+
* both modes. Kept for eager-mode callers and back-compat.
|
|
55
|
+
*/
|
|
34
56
|
lookupTool(cliId: string, toolKey: string): ToolLookup | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve a tool for execution in BOTH modes. Eager: identical to
|
|
59
|
+
* `lookupTool`. Lazy: if the CLI is only catalogued (manifest), import its
|
|
60
|
+
* handler module now (memoized, so concurrent calls import once) and then look
|
|
61
|
+
* up the tool on the freshly-loaded, branded CLI. Returns `undefined` for an
|
|
62
|
+
* unknown cli/tool exactly like `lookupTool`.
|
|
63
|
+
*/
|
|
64
|
+
resolveTool(cliId: string, toolKey: string): Promise<ToolLookup | undefined>;
|
|
65
|
+
/** Import (once) the module behind a lazy CLI entry and return its
|
|
66
|
+
* RegistryEntry. A failed import is evicted from the cache so a later call can
|
|
67
|
+
* retry rather than being permanently poisoned. */
|
|
68
|
+
private resolveLazyEntry;
|
|
35
69
|
entries(): ReadonlyArray<RegistryEntry>;
|
|
36
70
|
connections(): ReadonlyArray<ConnectionEntry>;
|
|
37
71
|
/** Packages skipped at load: failed brand/shape check, or the dropped side of
|
|
38
72
|
* a duplicate id/slug collision. */
|
|
39
73
|
failures(): ReadonlyArray<LoadFailure>;
|
|
40
74
|
stats(): RegistryStats;
|
|
75
|
+
/**
|
|
76
|
+
* Build the `/tools/list` wire payload in BOTH modes. Eager: delegates to the
|
|
77
|
+
* shared projection over loaded entries. Lazy: projects the manifest catalog
|
|
78
|
+
* (no imports) and merges it with any eagerly-loaded CLIs + connections,
|
|
79
|
+
* re-sorted to the same stable order the eager payload uses (CLIs by
|
|
80
|
+
* `id.localeCompare`; tools grouped by cli then tool key). The two are
|
|
81
|
+
* byte-identical per package — see test/registry/manifest-wire.test.ts.
|
|
82
|
+
*/
|
|
83
|
+
toWirePayload(tenant?: WireTenant | null): WireListPayload;
|
|
41
84
|
}
|
|
42
85
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry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AK,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;IAmCtB;;;;;;;OAOG;IACH,aAAa,CAAC,MAAM,GAAE,UAAU,GAAG,IAAW,GAAG,eAAe;CAgBjE"}
|
|
@@ -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 { 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,15 @@ 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
|
+
constructor(entries, connections, loadFailures, lazyClis = []) {
|
|
40
51
|
this.byCliId = new Map();
|
|
41
52
|
for (const e of entries)
|
|
42
53
|
this.byCliId.set(e.cli.id, e);
|
|
@@ -44,6 +55,10 @@ export class Registry {
|
|
|
44
55
|
for (const c of connections)
|
|
45
56
|
this.byConnectionSlug.set(c.connection.slug, c);
|
|
46
57
|
this.loadFailures = loadFailures;
|
|
58
|
+
this.lazyByCliId = new Map();
|
|
59
|
+
for (const l of lazyClis)
|
|
60
|
+
this.lazyByCliId.set(l.cliId, l);
|
|
61
|
+
this.resolvedCache = new Map();
|
|
47
62
|
}
|
|
48
63
|
static async load(opts) {
|
|
49
64
|
const failures = [];
|
|
@@ -134,18 +149,68 @@ export class Registry {
|
|
|
134
149
|
// not route baseline packages through `customerPath` (source is assigned by
|
|
135
150
|
// which path a package came from): either would let a customer shadow a
|
|
136
151
|
// first-party tool, the exact outage class this loader defends against.
|
|
137
|
-
if (opts.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
152
|
+
if (!opts.lazy) {
|
|
153
|
+
if (opts.baselinePath) {
|
|
154
|
+
const scan = await scanPath(opts.baselinePath, 'baseline', opts.logger);
|
|
155
|
+
ingest(scan.loaded);
|
|
156
|
+
failures.push(...scan.failures);
|
|
157
|
+
}
|
|
158
|
+
if (opts.customerPath) {
|
|
159
|
+
const scan = await scanPath(opts.customerPath, 'customer', opts.logger);
|
|
160
|
+
ingest(scan.loaded);
|
|
161
|
+
failures.push(...scan.failures);
|
|
162
|
+
}
|
|
163
|
+
return new Registry(Array.from(cliById.values()), Array.from(connBySlug.values()), failures);
|
|
141
164
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
165
|
+
const cliChoice = new Map();
|
|
166
|
+
const chooseCli = (cand) => {
|
|
167
|
+
const existing = cliChoice.get(cand.id);
|
|
168
|
+
if (!existing) {
|
|
169
|
+
cliChoice.set(cand.id, cand);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
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 });
|
|
173
|
+
if (replace)
|
|
174
|
+
cliChoice.set(cand.id, cand);
|
|
175
|
+
};
|
|
176
|
+
const ingestLazyScan = (scan) => {
|
|
145
177
|
failures.push(...scan.failures);
|
|
178
|
+
// Connections + manifest-less CLIs. Route connections through `ingest`
|
|
179
|
+
// (slug collision) and manifest-less CLIs through the unified chooser.
|
|
180
|
+
const conns = [];
|
|
181
|
+
for (const item of scan.eager) {
|
|
182
|
+
if (item.kind === 'connection')
|
|
183
|
+
conns.push(item);
|
|
184
|
+
else
|
|
185
|
+
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 });
|
|
186
|
+
}
|
|
187
|
+
ingest(conns);
|
|
188
|
+
for (const l of scan.lazyClis) {
|
|
189
|
+
chooseCli({ kind: 'lazy', id: l.cliId, source: l.source, packagePath: l.packagePath, override: l.override, lazy: l });
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
// Same baseline-before-customer invariant as the eager path.
|
|
193
|
+
if (opts.baselinePath)
|
|
194
|
+
ingestLazyScan(await scanPathLazy(opts.baselinePath, 'baseline', opts.logger));
|
|
195
|
+
if (opts.customerPath)
|
|
196
|
+
ingestLazyScan(await scanPathLazy(opts.customerPath, 'customer', opts.logger));
|
|
197
|
+
const eagerEntries = [];
|
|
198
|
+
const lazyEntries = [];
|
|
199
|
+
for (const cand of cliChoice.values()) {
|
|
200
|
+
if (cand.kind === 'eager')
|
|
201
|
+
eagerEntries.push(cand.entry);
|
|
202
|
+
else
|
|
203
|
+
lazyEntries.push(cand.lazy);
|
|
146
204
|
}
|
|
147
|
-
return new Registry(
|
|
148
|
-
}
|
|
205
|
+
return new Registry(eagerEntries, Array.from(connBySlug.values()), failures, lazyEntries);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Synchronous lookup — resolves only EAGERLY-loaded CLIs. In lazy mode a CLI
|
|
209
|
+
* catalogued from its manifest hasn't imported its handler module yet, so this
|
|
210
|
+
* returns `undefined` for it. Callers that must execute a tool should use the
|
|
211
|
+
* async {@link resolveTool}, which imports the module on demand and works in
|
|
212
|
+
* both modes. Kept for eager-mode callers and back-compat.
|
|
213
|
+
*/
|
|
149
214
|
lookupTool(cliId, toolKey) {
|
|
150
215
|
const entry = this.byCliId.get(cliId);
|
|
151
216
|
if (!entry)
|
|
@@ -155,6 +220,45 @@ export class Registry {
|
|
|
155
220
|
return undefined;
|
|
156
221
|
return { cli: entry.cli, toolKey, tool, source: entry.source };
|
|
157
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Resolve a tool for execution in BOTH modes. Eager: identical to
|
|
225
|
+
* `lookupTool`. Lazy: if the CLI is only catalogued (manifest), import its
|
|
226
|
+
* handler module now (memoized, so concurrent calls import once) and then look
|
|
227
|
+
* up the tool on the freshly-loaded, branded CLI. Returns `undefined` for an
|
|
228
|
+
* unknown cli/tool exactly like `lookupTool`.
|
|
229
|
+
*/
|
|
230
|
+
async resolveTool(cliId, toolKey) {
|
|
231
|
+
const eager = this.lookupTool(cliId, toolKey);
|
|
232
|
+
if (eager)
|
|
233
|
+
return eager;
|
|
234
|
+
const lazy = this.lazyByCliId.get(cliId);
|
|
235
|
+
if (!lazy)
|
|
236
|
+
return undefined;
|
|
237
|
+
const entry = await this.resolveLazyEntry(lazy);
|
|
238
|
+
const tool = entry.cli.tools[toolKey];
|
|
239
|
+
if (!tool)
|
|
240
|
+
return undefined;
|
|
241
|
+
return { cli: entry.cli, toolKey, tool, source: entry.source };
|
|
242
|
+
}
|
|
243
|
+
/** Import (once) the module behind a lazy CLI entry and return its
|
|
244
|
+
* RegistryEntry. A failed import is evicted from the cache so a later call can
|
|
245
|
+
* retry rather than being permanently poisoned. */
|
|
246
|
+
resolveLazyEntry(lazy) {
|
|
247
|
+
const cached = this.resolvedCache.get(lazy.cliId);
|
|
248
|
+
if (cached)
|
|
249
|
+
return cached;
|
|
250
|
+
const p = (async () => {
|
|
251
|
+
const loaded = await loadPackageEntry(lazy.entryPoint, lazy.packagePath, lazy.source);
|
|
252
|
+
for (const item of loaded) {
|
|
253
|
+
if (item.kind === 'cli' && item.entry.cli.id === lazy.cliId)
|
|
254
|
+
return item.entry;
|
|
255
|
+
}
|
|
256
|
+
throw new Error(`registry: lazy import of ${lazy.packagePath} did not yield a CLI with id '${lazy.cliId}' (manifest/module drift)`);
|
|
257
|
+
})();
|
|
258
|
+
p.catch(() => this.resolvedCache.delete(lazy.cliId));
|
|
259
|
+
this.resolvedCache.set(lazy.cliId, p);
|
|
260
|
+
return p;
|
|
261
|
+
}
|
|
158
262
|
entries() {
|
|
159
263
|
return Array.from(this.byCliId.values());
|
|
160
264
|
}
|
|
@@ -177,6 +281,15 @@ export class Registry {
|
|
|
177
281
|
customerCount++;
|
|
178
282
|
toolCount += Object.keys(e.cli.tools).length;
|
|
179
283
|
}
|
|
284
|
+
// Lazy CLIs count toward the same totals — tool count comes from the
|
|
285
|
+
// manifest (no import needed), so the boot log reports the true surface.
|
|
286
|
+
for (const l of this.lazyByCliId.values()) {
|
|
287
|
+
if (l.source === 'baseline')
|
|
288
|
+
baselineCount++;
|
|
289
|
+
else
|
|
290
|
+
customerCount++;
|
|
291
|
+
toolCount += l.manifest.tools.length;
|
|
292
|
+
}
|
|
180
293
|
for (const c of this.byConnectionSlug.values()) {
|
|
181
294
|
if (c.source === 'baseline')
|
|
182
295
|
baselineCount++;
|
|
@@ -190,7 +303,7 @@ export class Registry {
|
|
|
190
303
|
if (f.kind === 'overridden')
|
|
191
304
|
overriddenCount++;
|
|
192
305
|
return {
|
|
193
|
-
cliCount: this.byCliId.size,
|
|
306
|
+
cliCount: this.byCliId.size + this.lazyByCliId.size,
|
|
194
307
|
toolCount,
|
|
195
308
|
connectionCount: this.byConnectionSlug.size,
|
|
196
309
|
baselineCount,
|
|
@@ -199,6 +312,28 @@ export class Registry {
|
|
|
199
312
|
overriddenCount,
|
|
200
313
|
};
|
|
201
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Build the `/tools/list` wire payload in BOTH modes. Eager: delegates to the
|
|
317
|
+
* shared projection over loaded entries. Lazy: projects the manifest catalog
|
|
318
|
+
* (no imports) and merges it with any eagerly-loaded CLIs + connections,
|
|
319
|
+
* re-sorted to the same stable order the eager payload uses (CLIs by
|
|
320
|
+
* `id.localeCompare`; tools grouped by cli then tool key). The two are
|
|
321
|
+
* byte-identical per package — see test/registry/manifest-wire.test.ts.
|
|
322
|
+
*/
|
|
323
|
+
toWirePayload(tenant = null) {
|
|
324
|
+
const eager = toWireListPayloadFn(this.entries(), this.connections(), tenant);
|
|
325
|
+
if (this.lazyByCliId.size === 0)
|
|
326
|
+
return eager;
|
|
327
|
+
const lazyClis = [];
|
|
328
|
+
const lazyTools = [];
|
|
329
|
+
for (const l of this.lazyByCliId.values()) {
|
|
330
|
+
lazyClis.push(manifestToWireCli(l.manifest, l.source));
|
|
331
|
+
lazyTools.push(...manifestToWireTools(l.manifest, l.source));
|
|
332
|
+
}
|
|
333
|
+
const clis = [...eager.clis, ...lazyClis].sort((a, b) => a.id.localeCompare(b.id));
|
|
334
|
+
const tools = [...eager.tools, ...lazyTools].sort((a, b) => a.cli.localeCompare(b.cli) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
335
|
+
return { ...eager, clis, tools };
|
|
336
|
+
}
|
|
202
337
|
}
|
|
203
338
|
/**
|
|
204
339
|
* Scan one root directory for SDK-authored CLI packages. Each immediate
|
|
@@ -269,6 +404,120 @@ async function scanPath(root, source, logger) {
|
|
|
269
404
|
}
|
|
270
405
|
return { loaded, failures };
|
|
271
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Lazy variant of {@link scanPath}. Per package:
|
|
409
|
+
* - a valid `manifest.json` ⇒ catalog it as a lazy CLI (no module import); the
|
|
410
|
+
* entry point is resolved now so `resolveTool` can import it later.
|
|
411
|
+
* - no/invalid manifest ⇒ import eagerly, exactly as `scanPath` does (this is
|
|
412
|
+
* how connection packages and any manifest-less CLI keep working).
|
|
413
|
+
* Failure handling mirrors `scanPath`: a broken BASELINE package throws (bad
|
|
414
|
+
* deploy); a broken CUSTOMER package is recorded and skipped.
|
|
415
|
+
*/
|
|
416
|
+
async function scanPathLazy(root, source, logger) {
|
|
417
|
+
let dirents;
|
|
418
|
+
try {
|
|
419
|
+
dirents = await fs.readdir(root, { withFileTypes: true });
|
|
420
|
+
}
|
|
421
|
+
catch (err) {
|
|
422
|
+
if (err.code === 'ENOENT') {
|
|
423
|
+
logger?.warn({ root, source }, 'registry: package root does not exist; treating as empty');
|
|
424
|
+
return { lazyClis: [], eager: [], failures: [] };
|
|
425
|
+
}
|
|
426
|
+
throw err;
|
|
427
|
+
}
|
|
428
|
+
const lazyClis = [];
|
|
429
|
+
const eager = [];
|
|
430
|
+
const failures = [];
|
|
431
|
+
const subdirs = dirents
|
|
432
|
+
.filter((d) => d.isDirectory())
|
|
433
|
+
.map((d) => d.name)
|
|
434
|
+
.sort();
|
|
435
|
+
for (const name of subdirs) {
|
|
436
|
+
const packagePath = path.join(root, name);
|
|
437
|
+
const manifest = await readCliManifest(packagePath, logger);
|
|
438
|
+
if (manifest) {
|
|
439
|
+
const entryPoint = await resolveEntryPoint(packagePath);
|
|
440
|
+
if (!entryPoint) {
|
|
441
|
+
// A manifest we could serve on /tools/list but never execute is worse
|
|
442
|
+
// than absent. Match the eager loader, which SKIPS a package with no
|
|
443
|
+
// resolvable entry point (see scanPath) — so the lazy catalog advertises
|
|
444
|
+
// exactly the packages the eager one would load, never a phantom tool.
|
|
445
|
+
logger?.warn({ packagePath, source }, 'registry: manifest present but no resolvable entry point — skipping (cannot execute)');
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
lazyClis.push({
|
|
449
|
+
cliId: manifest.id,
|
|
450
|
+
manifest,
|
|
451
|
+
source,
|
|
452
|
+
packagePath,
|
|
453
|
+
entryPoint,
|
|
454
|
+
override: manifest.override === true,
|
|
455
|
+
});
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
// No usable manifest → eager import (connection packages + manifest-less
|
|
459
|
+
// CLIs), byte-for-byte the same per-package handling as `scanPath`.
|
|
460
|
+
const entryPoint = await resolveEntryPoint(packagePath);
|
|
461
|
+
if (!entryPoint) {
|
|
462
|
+
logger?.warn({ packagePath }, 'registry: skipping — no package.json or resolvable entry point');
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
466
|
+
for (const item of await loadPackageEntry(entryPoint, packagePath, source))
|
|
467
|
+
eager.push(item);
|
|
468
|
+
}
|
|
469
|
+
catch (err) {
|
|
470
|
+
if (source === 'baseline')
|
|
471
|
+
throw err;
|
|
472
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
473
|
+
logger?.error({ packagePath, source, error: message }, 'registry: customer package failed to load — skipping');
|
|
474
|
+
failures.push({ packagePath, source, error: message });
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return { lazyClis, eager, failures };
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Read + shallow-validate a package's `manifest.json`. Returns the parsed
|
|
481
|
+
* manifest when it looks like a CLI manifest (string `id` + `tools` array), or
|
|
482
|
+
* `undefined` when the file is absent, unreadable, unparseable, or the wrong
|
|
483
|
+
* shape — in every "undefined" case the caller falls back to eager import, so a
|
|
484
|
+
* bad manifest degrades to today's behavior rather than dropping the package.
|
|
485
|
+
*/
|
|
486
|
+
async function readCliManifest(packagePath, logger) {
|
|
487
|
+
const manifestPath = path.join(packagePath, 'manifest.json');
|
|
488
|
+
let raw;
|
|
489
|
+
try {
|
|
490
|
+
raw = await fs.readFile(manifestPath, 'utf8');
|
|
491
|
+
}
|
|
492
|
+
catch (err) {
|
|
493
|
+
if (err.code === 'ENOENT')
|
|
494
|
+
return undefined;
|
|
495
|
+
logger?.warn({ packagePath, error: err.message }, 'registry: manifest.json unreadable — importing eagerly');
|
|
496
|
+
return undefined;
|
|
497
|
+
}
|
|
498
|
+
let parsed;
|
|
499
|
+
try {
|
|
500
|
+
parsed = JSON.parse(raw);
|
|
501
|
+
}
|
|
502
|
+
catch {
|
|
503
|
+
logger?.warn({ packagePath }, 'registry: manifest.json is not valid JSON — importing eagerly');
|
|
504
|
+
return undefined;
|
|
505
|
+
}
|
|
506
|
+
// Validate against the full manifest schema, not a shallow shape check. A
|
|
507
|
+
// manifest missing required fields (instructions / secrets / a tool's
|
|
508
|
+
// secretKeys, …) or carrying a broken dynamic-egress ref must fall back to
|
|
509
|
+
// eager import here — otherwise it would slip through and throw later in the
|
|
510
|
+
// wire projection (`manifestToWireCli` / `manifestToWireTools`), which is the
|
|
511
|
+
// exact "bad manifest degrades, not crashes" contract this function promises.
|
|
512
|
+
try {
|
|
513
|
+
validateManifest(parsed);
|
|
514
|
+
}
|
|
515
|
+
catch (err) {
|
|
516
|
+
logger?.warn({ packagePath, error: err instanceof Error ? err.message : String(err) }, 'registry: manifest.json failed schema validation — importing eagerly');
|
|
517
|
+
return undefined;
|
|
518
|
+
}
|
|
519
|
+
return parsed;
|
|
520
|
+
}
|
|
272
521
|
async function resolveEntryPoint(packagePath) {
|
|
273
522
|
const manifestPath = path.join(packagePath, 'package.json');
|
|
274
523
|
let manifest;
|
|
@@ -0,0 +1,49 @@
|
|
|
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 } from '../../manifest/types.js';
|
|
23
|
+
import { type WireCliEntry, 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
|
+
* Assemble the CLI + tool halves of a `/tools/list` payload from a set of
|
|
36
|
+
* manifests, applying the SAME ordering as `toWireListPayload`: CLIs sorted by
|
|
37
|
+
* `id.localeCompare`, tools grouped per CLI in manifest (already key-sorted)
|
|
38
|
+
* order. Connections are NOT sourced from manifests (they carry no CLI
|
|
39
|
+
* manifest) — the caller supplies those from the eagerly-loaded connection
|
|
40
|
+
* packages, exactly as today.
|
|
41
|
+
*/
|
|
42
|
+
export declare function manifestsToWireCatalog(manifests: ReadonlyArray<{
|
|
43
|
+
manifest: ConnectionManifest;
|
|
44
|
+
source: WireSource;
|
|
45
|
+
}>): {
|
|
46
|
+
clis: WireCliEntry[];
|
|
47
|
+
tools: WireToolEntry[];
|
|
48
|
+
};
|
|
49
|
+
//# 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,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE9E,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;;;;;;;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"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { wireEgress } from './wire.js';
|
|
2
|
+
/** Project one manifest's CLI-level metadata to its wire entry. Mirrors `toWireCli`. */
|
|
3
|
+
export function manifestToWireCli(m, source) {
|
|
4
|
+
return {
|
|
5
|
+
id: m.id,
|
|
6
|
+
name: m.name,
|
|
7
|
+
vendor: m.vendor,
|
|
8
|
+
summary: m.summary,
|
|
9
|
+
description: m.description ?? null,
|
|
10
|
+
instructions: [...m.instructions],
|
|
11
|
+
secrets: m.secrets.map((s) => ({
|
|
12
|
+
name: s.name,
|
|
13
|
+
description: s.description,
|
|
14
|
+
required: s.required,
|
|
15
|
+
key: s.key,
|
|
16
|
+
...(s.adminManaged === true ? { adminManaged: true } : {}),
|
|
17
|
+
...(s.injected === true ? { injected: true } : {}),
|
|
18
|
+
...(s.serverOnly === true ? { serverOnly: true } : {}),
|
|
19
|
+
})),
|
|
20
|
+
properties: (m.properties ?? []).map((p) => ({
|
|
21
|
+
name: p.name,
|
|
22
|
+
description: p.description,
|
|
23
|
+
required: p.required,
|
|
24
|
+
key: p.key,
|
|
25
|
+
...(Array.isArray(p.options) && p.options.length ? { options: [...p.options] } : {}),
|
|
26
|
+
...(p.adminManaged === true ? { adminManaged: true } : {}),
|
|
27
|
+
})),
|
|
28
|
+
connectionSlug: typeof m.connectionSlug === 'string' && m.connectionSlug ? m.connectionSlug : null,
|
|
29
|
+
vendorScopes: Array.isArray(m.vendorScopes) ? m.vendorScopes.filter((s) => typeof s === 'string') : [],
|
|
30
|
+
source,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Project one manifest's tools to wire entries. Mirrors `toWireTool`.
|
|
35
|
+
* `manifest.tools` is already sorted by tool key at generation time (to-schema
|
|
36
|
+
* uses the same `Object.keys(tools).sort()` the wire assembly uses), so array
|
|
37
|
+
* order is preserved rather than re-sorted.
|
|
38
|
+
*/
|
|
39
|
+
export function manifestToWireTools(m, source) {
|
|
40
|
+
return m.tools.map((t) => ({
|
|
41
|
+
cli: m.id,
|
|
42
|
+
// wire `name` is the registry key, which the manifest stores as `id`.
|
|
43
|
+
name: t.id,
|
|
44
|
+
description: t.description ?? null,
|
|
45
|
+
isReadonly: t.isReadonly,
|
|
46
|
+
producesFiles: t.producesFiles === true,
|
|
47
|
+
secretKeys: [...t.secretKeys],
|
|
48
|
+
propertyKeys: [...t.propertyKeys],
|
|
49
|
+
// native manifests store `egress: null`; map to `undefined` so `wireEgress`
|
|
50
|
+
// yields `[]` exactly as the branded path does for network-less tools.
|
|
51
|
+
egress: wireEgress(t.egress ?? undefined),
|
|
52
|
+
inputSchema: t.inputSchema ?? null,
|
|
53
|
+
outputSchema: t.outputSchema ?? null,
|
|
54
|
+
source,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Assemble the CLI + tool halves of a `/tools/list` payload from a set of
|
|
59
|
+
* manifests, applying the SAME ordering as `toWireListPayload`: CLIs sorted by
|
|
60
|
+
* `id.localeCompare`, tools grouped per CLI in manifest (already key-sorted)
|
|
61
|
+
* order. Connections are NOT sourced from manifests (they carry no CLI
|
|
62
|
+
* manifest) — the caller supplies those from the eagerly-loaded connection
|
|
63
|
+
* packages, exactly as today.
|
|
64
|
+
*/
|
|
65
|
+
export function manifestsToWireCatalog(manifests) {
|
|
66
|
+
const sorted = [...manifests].sort((a, b) => a.manifest.id.localeCompare(b.manifest.id));
|
|
67
|
+
const clis = sorted.map((m) => manifestToWireCli(m.manifest, m.source));
|
|
68
|
+
const tools = [];
|
|
69
|
+
for (const m of sorted)
|
|
70
|
+
tools.push(...manifestToWireTools(m.manifest, m.source));
|
|
71
|
+
return { clis, tools };
|
|
72
|
+
}
|
|
@@ -149,4 +149,12 @@ export interface WireListPayload {
|
|
|
149
149
|
readonly tenant: WireTenant | null;
|
|
150
150
|
}
|
|
151
151
|
export declare function toWireListPayload(entries: ReadonlyArray<RegistryEntry>, connectionEntries?: ReadonlyArray<ConnectionEntry>, tenant?: WireTenant | null): WireListPayload;
|
|
152
|
+
/**
|
|
153
|
+
* Serialize a tool's egress for the wire. A static allowlist passes through;
|
|
154
|
+
* a dynamic ref `{ from: 'property:<KEY>' }` or `{ from: 'secret:<KEY>' }`
|
|
155
|
+
* becomes `['<prefix>:<KEY>']` so consumers see the per-tenant host source
|
|
156
|
+
* rather than an empty list. Anything else (native tools, malformed) yields
|
|
157
|
+
* `[]`. The accepted prefixes come from the SDK so the contract never drifts.
|
|
158
|
+
*/
|
|
159
|
+
export declare function wireEgress(egress: unknown): string[];
|
|
152
160
|
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/runtime/registry/wire.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAKV,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,yJAAyJ;IACzJ,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,qFAAqF;IACrF,QAAQ,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,kKAAkK;IAClK,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CAC1C;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAA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AW,eAAe;IAC9B,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,SAAS,YAAY,EAAE,CAAC;IACvC,oHAAoH;IACpH,QAAQ,CAAC,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACrD,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,aAAa,CAAC,aAAa,CAAC,EACrC,iBAAiB,GAAE,aAAa,CAAC,eAAe,CAAM,EACtD,MAAM,GAAE,UAAU,GAAG,IAAW,GAC/B,eAAe,CAyBjB;AAqOD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CASpD"}
|
|
@@ -261,7 +261,7 @@ function isWireSecretDecl(s) {
|
|
|
261
261
|
* rather than an empty list. Anything else (native tools, malformed) yields
|
|
262
262
|
* `[]`. The accepted prefixes come from the SDK so the contract never drifts.
|
|
263
263
|
*/
|
|
264
|
-
function wireEgress(egress) {
|
|
264
|
+
export function wireEgress(egress) {
|
|
265
265
|
if (Array.isArray(egress))
|
|
266
266
|
return egress.filter((h) => typeof h === 'string');
|
|
267
267
|
if (egress && typeof egress === 'object') {
|