@akai-workflow-builder/cli-sdk 0.18.0 → 0.20.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 +27 -0
- package/dist/ctx/blocked-domains.d.ts +23 -0
- package/dist/ctx/blocked-domains.d.ts.map +1 -0
- package/dist/ctx/blocked-domains.js +59 -0
- package/dist/ctx/build-ctx.d.ts.map +1 -1
- package/dist/ctx/build-ctx.js +9 -3
- package/dist/ctx/egress-refusal.d.ts +47 -0
- package/dist/ctx/egress-refusal.d.ts.map +1 -0
- package/dist/ctx/egress-refusal.js +85 -0
- package/dist/ctx/pinned-get.d.ts +16 -0
- package/dist/ctx/pinned-get.d.ts.map +1 -0
- package/dist/ctx/pinned-get.js +58 -0
- package/dist/ctx/read-file-stream.d.ts +5 -2
- package/dist/ctx/read-file-stream.d.ts.map +1 -1
- package/dist/ctx/read-file-stream.js +4 -10
- package/dist/ctx/read-file.d.ts +8 -3
- package/dist/ctx/read-file.d.ts.map +1 -1
- package/dist/ctx/read-file.js +7 -11
- package/dist/ctx/safe-fetch.d.ts +15 -0
- package/dist/ctx/safe-fetch.d.ts.map +1 -1
- package/dist/ctx/safe-fetch.js +70 -28
- package/dist/ctx/sftp-egress.d.ts +33 -6
- package/dist/ctx/sftp-egress.d.ts.map +1 -1
- package/dist/ctx/sftp-egress.js +86 -10
- package/dist/ctx/sftp.d.ts +6 -1
- package/dist/ctx/sftp.d.ts.map +1 -1
- package/dist/ctx/sftp.js +38 -2
- package/dist/ctx/url-input.d.ts +38 -0
- package/dist/ctx/url-input.d.ts.map +1 -0
- package/dist/ctx/url-input.js +107 -0
- package/dist/file-input.d.ts +3 -4
- package/dist/file-input.d.ts.map +1 -1
- package/dist/file-input.js +3 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest/to-schema.js +10 -4
- package/dist/manifest/types.d.ts +1 -1
- package/dist/runtime/executor/index.js +1 -1
- package/dist/runtime/registry/wire.js +8 -4
- package/dist/types.d.ts +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { blockedDomainOf } from './blocked-domains.js';
|
|
2
|
+
import { reportEgressRefusal } from './egress-refusal.js';
|
|
3
|
+
import { pinnedGet } from './pinned-get.js';
|
|
4
|
+
import { isPrivateIp, lookupWithSignal } from './safe-fetch.js';
|
|
5
|
+
/** How many redirects one URL input may follow. Each hop is checked like the first. */
|
|
6
|
+
export const MAX_URL_INPUT_REDIRECTS = 5;
|
|
7
|
+
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
8
|
+
function causeOf(err) {
|
|
9
|
+
return err instanceof Error ? err.message : String(err);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetch an `http(s)://` file input for `ctx.readFile` / `ctx.readFileStream`
|
|
13
|
+
* and return the final response, whatever its status — the caller reads it.
|
|
14
|
+
*
|
|
15
|
+
* The URL is whatever the agent passed for the file argument: the worker hands
|
|
16
|
+
* an `http(s)://` value to the tool unchanged. There is no per-tool egress
|
|
17
|
+
* allowlist here — a file can live anywhere public — but the URL may not reach
|
|
18
|
+
* inside Akai's network, the same rule ctx.fetch and ctx.sftp apply:
|
|
19
|
+
*
|
|
20
|
+
* - a host on the blocked-domain list is refused by name, before any lookup;
|
|
21
|
+
* - the host is resolved and EVERY address checked: one private address
|
|
22
|
+
* (loopback, RFC 1918, link-local incl. the cloud metadata address, cluster
|
|
23
|
+
* service ranges, IPv6 ULA, …) refuses the call;
|
|
24
|
+
* - the connection goes only to the addresses that were checked (`pinnedGet`),
|
|
25
|
+
* so a second DNS answer cannot redirect it;
|
|
26
|
+
* - a redirect is followed by hand, at most {@link MAX_URL_INPUT_REDIRECTS}
|
|
27
|
+
* times, and every hop is checked the same way before it is dialled.
|
|
28
|
+
*
|
|
29
|
+
* Each refusal is reported through `onEgressRefused` as `sdk_read_file`, with
|
|
30
|
+
* the host and never the URL (a presigned URL carries its signature).
|
|
31
|
+
*
|
|
32
|
+
* With `NODE_ENV=development` only the blocked-domain check applies and the
|
|
33
|
+
* request goes through global fetch, so the local stack's object store on
|
|
34
|
+
* localhost keeps working.
|
|
35
|
+
*/
|
|
36
|
+
export async function fetchUrlInput(value, opts) {
|
|
37
|
+
const { label, signal } = opts;
|
|
38
|
+
const fail = (why) => new Error(`${label}: ${value}: ${why}`);
|
|
39
|
+
let url;
|
|
40
|
+
try {
|
|
41
|
+
url = new URL(value);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw fail('not a valid URL');
|
|
45
|
+
}
|
|
46
|
+
const refuseBlockedDomain = (hop) => {
|
|
47
|
+
const blocked = blockedDomainOf(hop.hostname);
|
|
48
|
+
if (blocked === null)
|
|
49
|
+
return;
|
|
50
|
+
reportEgressRefusal(opts.onEgressRefused, { via: 'sdk_read_file', host: hop.hostname, reason: 'blocked_domain' });
|
|
51
|
+
throw fail(`${blocked} is on Akai's blocked-domain list`);
|
|
52
|
+
};
|
|
53
|
+
if (process.env.NODE_ENV === 'development') {
|
|
54
|
+
refuseBlockedDomain(url);
|
|
55
|
+
try {
|
|
56
|
+
return await fetch(value, { signal });
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
throw fail(causeOf(err));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (let redirects = 0;; redirects++) {
|
|
63
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
64
|
+
throw fail(`refusing a redirect to a ${url.protocol} URL`);
|
|
65
|
+
}
|
|
66
|
+
refuseBlockedDomain(url);
|
|
67
|
+
// WHATWG URL keeps an IPv6 literal's brackets; the resolver wants the bare address.
|
|
68
|
+
const hostname = url.hostname.replace(/^\[|\]$/g, '');
|
|
69
|
+
let addresses;
|
|
70
|
+
try {
|
|
71
|
+
addresses = await lookupWithSignal(hostname, signal);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
throw fail(signal.aborted ? causeOf(err) : `DNS lookup failed for ${url.hostname}: ${causeOf(err)}`);
|
|
75
|
+
}
|
|
76
|
+
for (const { address } of addresses) {
|
|
77
|
+
if (isPrivateIp(address)) {
|
|
78
|
+
reportEgressRefusal(opts.onEgressRefused, {
|
|
79
|
+
via: 'sdk_read_file',
|
|
80
|
+
host: url.hostname,
|
|
81
|
+
reason: 'private_address',
|
|
82
|
+
address,
|
|
83
|
+
});
|
|
84
|
+
throw fail(`${url.hostname} resolves to the private address ${address}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let response;
|
|
88
|
+
try {
|
|
89
|
+
response = await pinnedGet(url, addresses.map((entry) => entry.address), signal);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
throw fail(causeOf(err));
|
|
93
|
+
}
|
|
94
|
+
const location = response.headers.get('location');
|
|
95
|
+
if (!REDIRECT_STATUSES.has(response.status) || location === null)
|
|
96
|
+
return response;
|
|
97
|
+
await response.body?.cancel().catch(() => { });
|
|
98
|
+
if (redirects >= MAX_URL_INPUT_REDIRECTS)
|
|
99
|
+
throw fail(`more than ${MAX_URL_INPUT_REDIRECTS} redirects`);
|
|
100
|
+
try {
|
|
101
|
+
url = new URL(location, url);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
throw fail(`HTTP ${response.status} redirects to an invalid URL`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
package/dist/file-input.d.ts
CHANGED
|
@@ -13,10 +13,9 @@ export declare const FILE_INPUT_META_KEY = "x-akai-file-input";
|
|
|
13
13
|
* - An absolute path (resolved via `ctx.safePath`).
|
|
14
14
|
* - A relative path (resolved against the worker's `workdir` allowlist).
|
|
15
15
|
* - A `file://` URL (prefix stripped, then resolved as a path).
|
|
16
|
-
* - An `http(s)://` URL
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* fetches without an egress allowlist.
|
|
16
|
+
* - An `http(s)://` URL, as the agent passed it. `ctx.readFile` fetches it
|
|
17
|
+
* without an egress allowlist but refuses a blocked-domain host and any
|
|
18
|
+
* host that resolves to a private address.
|
|
20
19
|
*
|
|
21
20
|
* The schema is a plain `z.string().min(1)` (so existing path-only
|
|
22
21
|
* consumers keep working), branded with `x-akai-file-input: true` in its
|
package/dist/file-input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-input.d.ts","sourceRoot":"","sources":["../src/file-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"file-input.d.ts","sourceRoot":"","sources":["../src/file-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,IAAI,SAAS,CAEpC"}
|
package/dist/file-input.js
CHANGED
|
@@ -13,10 +13,9 @@ export const FILE_INPUT_META_KEY = 'x-akai-file-input';
|
|
|
13
13
|
* - An absolute path (resolved via `ctx.safePath`).
|
|
14
14
|
* - A relative path (resolved against the worker's `workdir` allowlist).
|
|
15
15
|
* - A `file://` URL (prefix stripped, then resolved as a path).
|
|
16
|
-
* - An `http(s)://` URL
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* fetches without an egress allowlist.
|
|
16
|
+
* - An `http(s)://` URL, as the agent passed it. `ctx.readFile` fetches it
|
|
17
|
+
* without an egress allowlist but refuses a blocked-domain host and any
|
|
18
|
+
* host that resolves to a private address.
|
|
20
19
|
*
|
|
21
20
|
* The schema is a plain `z.string().min(1)` (so existing path-only
|
|
22
21
|
* consumers keep working), branded with `x-akai-file-input: true` in its
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export type { BuildCtxParams } from './ctx/build-ctx.js';
|
|
|
9
9
|
export { createSafeFetch } from './ctx/safe-fetch.js';
|
|
10
10
|
export type { SafeFetch, SafeFetchBinding } from './ctx/safe-fetch.js';
|
|
11
11
|
export type { PrivateEgressPin } from './ctx/private-egress.js';
|
|
12
|
-
export { parseSftpEgress, parseSftpEgressEntry, formatSftpEgressEntry, normalizeHostKeyFingerprint, DEFAULT_SFTP_PORT, } from './ctx/sftp-egress.js';
|
|
13
|
-
export type { SftpEgressEntry } from './ctx/sftp-egress.js';
|
|
12
|
+
export { parseSftpEgress, parseSftpEgressEntry, formatSftpEgressEntry, normalizeHostKeyFingerprint, DEFAULT_SFTP_PORT, SFTP_HOST_KEY_TYPES, } from './ctx/sftp-egress.js';
|
|
13
|
+
export type { SftpEgressEntry, SftpHostKeyType } from './ctx/sftp-egress.js';
|
|
14
14
|
export type { SftpApi, SftpSession, SftpEntry, SftpEntryType, SftpConnectOptions } from './ctx/sftp.js';
|
|
15
15
|
export type { AnyToolDef, CLIDef, CLISpec, ClientCertOptions, ConnectionAuthKind, ConnectionDef, ConnectionOAuthConfig, ConnectionSpec, DynamicEgress, InputOf, NetworkOptions, OAuthAdminField, OutputOf, PropertiesOf, PropertyDecl, RefreshStrategy, SecretDecl, SecretsOf, StepFetcher, TokenEndpointAuthMethod, ToolCtx, ToolDef, ToolLogger, ToolOptions, ToolSpec, } from './types.js';
|
|
16
16
|
export { createSafePath } from './ctx/safe-path.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,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BAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,+BAA+B,EAC/B,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ 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 { createSafeFetch } from './ctx/safe-fetch.js';
|
|
8
|
-
export { parseSftpEgress, parseSftpEgressEntry, formatSftpEgressEntry, normalizeHostKeyFingerprint, DEFAULT_SFTP_PORT, } from './ctx/sftp-egress.js';
|
|
8
|
+
export { parseSftpEgress, parseSftpEgressEntry, formatSftpEgressEntry, normalizeHostKeyFingerprint, DEFAULT_SFTP_PORT, SFTP_HOST_KEY_TYPES, } from './ctx/sftp-egress.js';
|
|
9
9
|
export { createSafePath } from './ctx/safe-path.js';
|
|
10
10
|
export { AkaiConnectionError, AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiResponseTooLargeError, AkaiSecretError, AkaiSpecError, AkaiToolError, describeError, } from './errors.js';
|
|
11
11
|
export { ConnectionManifestSchema, ManifestJSONSchema, SCHEMA_VERSION, toSchema, validateManifest, } from './manifest/index.js';
|
|
@@ -64,8 +64,8 @@ function toToolManifest(id, t) {
|
|
|
64
64
|
streamsFileInput: t.options.streamsFileInput,
|
|
65
65
|
secretKeys: [...t.options.secretKeys],
|
|
66
66
|
propertyKeys: [...t.options.propertyKeys],
|
|
67
|
-
inputSchema: tryJsonSchema(t.input),
|
|
68
|
-
outputSchema: tryJsonSchema(t.jsonOutput),
|
|
67
|
+
inputSchema: tryJsonSchema(t.input, 'input'),
|
|
68
|
+
outputSchema: tryJsonSchema(t.jsonOutput, 'output'),
|
|
69
69
|
};
|
|
70
70
|
if (t.transport === 'native') {
|
|
71
71
|
const native = {
|
|
@@ -108,11 +108,17 @@ function toToolManifest(id, t) {
|
|
|
108
108
|
};
|
|
109
109
|
return http;
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
/**
|
|
112
|
+
* `io` picks which side of the schema to describe. Inputs use 'input' so a
|
|
113
|
+
* `.default()` / `.catch()` field is optional, as it is to the caller; zod's
|
|
114
|
+
* default ('output') lists it in `required`, and the worker turns required
|
|
115
|
+
* scalars into mandatory positional arguments.
|
|
116
|
+
*/
|
|
117
|
+
function tryJsonSchema(schema, io) {
|
|
112
118
|
if (!schema)
|
|
113
119
|
return null;
|
|
114
120
|
try {
|
|
115
|
-
return z.toJSONSchema(schema);
|
|
121
|
+
return z.toJSONSchema(schema, { io });
|
|
116
122
|
}
|
|
117
123
|
catch {
|
|
118
124
|
return null;
|
package/dist/manifest/types.d.ts
CHANGED
|
@@ -128,7 +128,7 @@ export interface NativeToolManifest extends BaseToolManifest {
|
|
|
128
128
|
/**
|
|
129
129
|
* SFTP-transport tool. Opens SSH/SFTP connections through `ctx.sftp`, never
|
|
130
130
|
* `ctx.fetch`. Egress is always a dynamic reference whose value is a
|
|
131
|
-
* `host[:port][ SHA256:<fingerprint>]` allowlist the host runtime injects.
|
|
131
|
+
* `host[:port][ [keyType] SHA256:<fingerprint>]` allowlist the host runtime injects.
|
|
132
132
|
*/
|
|
133
133
|
export interface SftpToolManifest extends BaseToolManifest {
|
|
134
134
|
readonly transport: 'sftp';
|
|
@@ -347,7 +347,7 @@ function resolveEgress(cli, toolName, body) {
|
|
|
347
347
|
if (tool.transport === 'sftp') {
|
|
348
348
|
const parsed = parseSftpEgress(raw);
|
|
349
349
|
if (parsed === undefined) {
|
|
350
|
-
const message = `${isSecret ? 'secret' : 'property'} '${key}' must be a list of host[:port] entries, each optionally followed by a
|
|
350
|
+
const message = `${isSecret ? 'secret' : 'property'} '${key}' must be a list of host[:port] entries, each optionally followed by a host-key pin: SHA256:<fingerprint>, <keyType> SHA256:<fingerprint>, or an OpenSSH public-key line (<keyType> <base64>)`;
|
|
351
351
|
return failure(isSecret ? 'secret_missing' : 'property_missing', message, { key });
|
|
352
352
|
}
|
|
353
353
|
return { ok: true, cli: withResolvedEgress(cli, toolName, tool, parsed.map(formatSftpEgressEntry)) };
|
|
@@ -184,8 +184,8 @@ function toWireTool(cliId, toolKey, tool, source) {
|
|
|
184
184
|
// catalog/admin UI surfaces the per-tenant host source instead of a
|
|
185
185
|
// misleading empty list.
|
|
186
186
|
egress: wireEgress(tool.options.network?.egress),
|
|
187
|
-
inputSchema: tryJsonSchema(tool.input),
|
|
188
|
-
outputSchema: tryJsonSchema(tool.jsonOutput),
|
|
187
|
+
inputSchema: tryJsonSchema(tool.input, 'input'),
|
|
188
|
+
outputSchema: tryJsonSchema(tool.jsonOutput, 'output'),
|
|
189
189
|
source,
|
|
190
190
|
};
|
|
191
191
|
}
|
|
@@ -296,12 +296,16 @@ export function wireEgress(egress) {
|
|
|
296
296
|
* isn't a zod schema (e.g. test fixtures using plain placeholders, or a
|
|
297
297
|
* package whose `input` field is malformed — the loader's brand check
|
|
298
298
|
* doesn't validate `input` deeply).
|
|
299
|
+
*
|
|
300
|
+
* `io: 'input'` for tool inputs: a `.default()` field is optional to the
|
|
301
|
+
* caller, but zod's default ('output') view lists it in `required`, and the
|
|
302
|
+
* worker turns required scalars into mandatory positional arguments.
|
|
299
303
|
*/
|
|
300
|
-
function tryJsonSchema(input) {
|
|
304
|
+
function tryJsonSchema(input, io) {
|
|
301
305
|
if (!isLikelyZodSchema(input))
|
|
302
306
|
return null;
|
|
303
307
|
try {
|
|
304
|
-
return z.toJSONSchema(input);
|
|
308
|
+
return z.toJSONSchema(input, { io });
|
|
305
309
|
}
|
|
306
310
|
catch {
|
|
307
311
|
return null;
|
package/dist/types.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ export interface NetworkOptions {
|
|
|
98
98
|
* handler in-process — no network, no egress, no `ctx.fetch`. `'sftp'` opens
|
|
99
99
|
* SSH/SFTP connections via `ctx.sftp` instead of `ctx.fetch`; its egress must be
|
|
100
100
|
* a dynamic `{ from: 'property:KEY' | 'secret:KEY' }` reference whose value is a
|
|
101
|
-
* `host[:port][ SHA256:<fingerprint>]` allowlist (see `ctx/sftp-egress.ts`).
|
|
101
|
+
* `host[:port][ [keyType] SHA256:<fingerprint>]` allowlist (see `ctx/sftp-egress.ts`).
|
|
102
102
|
* Per-tool setting; CLIs can mix transports.
|
|
103
103
|
*/
|
|
104
104
|
export type Transport = 'http' | 'native' | 'sftp';
|
|
@@ -164,9 +164,9 @@ export interface ToolCtx<S extends string = string, P extends string = string> {
|
|
|
164
164
|
safePath: (userPath: string) => string;
|
|
165
165
|
/**
|
|
166
166
|
* Read a file referenced by either a local path (resolved via {@link safePath})
|
|
167
|
-
* or an `http(s)://` URL (fetched
|
|
168
|
-
*
|
|
169
|
-
*
|
|
167
|
+
* or an `http(s)://` URL (fetched with no egress allowlist, but a host on the
|
|
168
|
+
* blocked-domain list or one that resolves to a private address is refused,
|
|
169
|
+
* as in {@link fetch}; the URL is whatever the agent passed). Strips `file://`
|
|
170
170
|
* before resolving as a local path.
|
|
171
171
|
*
|
|
172
172
|
* Pairs with `filePath()` from the SDK: tool authors switch
|