@akai-workflow-builder/cli-sdk 0.7.0 → 0.8.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 CHANGED
@@ -4,6 +4,13 @@ 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.8.0](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.7.0...cli-sdk-v0.8.0) (2026-09-08)
8
+
9
+
10
+ ### Features
11
+
12
+ * resolve dynamic egress (secret:/property:) in buildCtx ([d72186a](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/d72186afce87a41045032ddbd302526b244ab57f))
13
+
7
14
  ## [0.7.0](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.6.2...cli-sdk-v0.7.0) (2026-08-25)
8
15
 
9
16
 
package/README.md CHANGED
@@ -331,7 +331,7 @@ options: {
331
331
  }
332
332
  ```
333
333
 
334
- `defineCLI()` cross-checks that the referenced key is declared in `properties[]` AND included in the tool's `propertyKeys`. The host runtime resolves the reference per invocation; SDK-side `buildCtx` throws `AkaiSpecError` to enforce that the host has resolved the egress before constructing `ctx`.
334
+ `defineCLI()` cross-checks that the referenced key is declared in `properties[]` AND included in the tool's `propertyKeys`. `buildCtx` resolves the reference itself — extracting the hostname from the bound secret or property value — so both the in-process step-fetcher path and the executor derive the same allowlisted host. Resolution throws `AkaiSpecError` on an unsupported prefix, `AkaiSecretError`/`AkaiPropertyError` when the value is unset or not a valid host.
335
335
 
336
336
  ### Egress allowlist
337
337
 
@@ -1 +1 @@
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,EA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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"}
@@ -4,7 +4,8 @@ import { createSafePath } from './safe-path.js';
4
4
  import { buildScopedProperties, buildScopedSecrets, } from './secrets.js';
5
5
  import { createReadFile } from './read-file.js';
6
6
  import { createWriteFile, unavailableWriteFile } from './write-file.js';
7
- import { AkaiSecretError, AkaiSpecError } from '../errors.js';
7
+ import { AkaiSecretError } from '../errors.js';
8
+ import { resolveDynamicEgressHost } from './dynamic-egress.js';
8
9
  function resolveTool(cli, toolName) {
9
10
  const t = cli.tools[toolName];
10
11
  if (!t) {
@@ -12,16 +13,16 @@ function resolveTool(cli, toolName) {
12
13
  }
13
14
  return t;
14
15
  }
15
- function staticEgress(egress, cliId, toolName) {
16
+ function toEgressList(egress, cliId, toolName, secrets, properties) {
16
17
  if (Array.isArray(egress))
17
18
  return egress;
18
- // Dynamic egress (`{ from: 'property:KEY' }`) is recorded by the SDK and
19
- // emitted in the manifest verbatim, but the SDK's own `buildCtx` does
20
- // not yet resolve it. The host runtime (DT service) is responsible for
21
- // building a ToolCtx with the resolved egress array when invoking a
22
- // tool that uses dynamic egress.
23
- const dyn = egress;
24
- throw new AkaiSpecError(`buildCtx: tool \`${cliId}.${toolName}\` declares dynamic egress (${dyn.from}); SDK-side resolution is not implemented. Resolve at the host runtime and pass a static egress list before constructing ctx.`);
19
+ // Dynamic egress (`{ from: 'secret:KEY' | 'property:KEY' }`) — resolve the bound
20
+ // secret/property to its host here, from the same scoped values this ctx was
21
+ // built with, so the step-fetcher path (which calls buildCtx directly) reaches
22
+ // the same host the executor derives. Throws AkaiSpecError on an unsupported
23
+ // prefix, AkaiSecretError/AkaiPropertyError when the binding is unset or not a
24
+ // valid host — fail closed, never a bare egress.
25
+ return [resolveDynamicEgressHost(egress, secrets, properties, cliId, toolName)];
25
26
  }
26
27
  /**
27
28
  * Resolve a tool's `network.clientCert` secret-key references to PEM values
@@ -85,7 +86,7 @@ export function buildCtx(params) {
85
86
  const fetch = tool.transport === 'native' || tool.options.network === undefined
86
87
  ? nativeFetch
87
88
  : createSafeFetch({
88
- egress: staticEgress(tool.options.network.egress, params.cli.id, params.toolName),
89
+ egress: toEgressList(tool.options.network.egress, params.cli.id, params.toolName, secrets, properties),
89
90
  cliId: params.cli.id,
90
91
  toolName: params.toolName,
91
92
  sdkVersion: params.sdkVersion,
@@ -0,0 +1,18 @@
1
+ import type { DynamicEgress } from '../types.js';
2
+ /**
3
+ * Resolve a tool's dynamic egress (`{ from: 'secret:KEY' | 'property:KEY' }`) to
4
+ * the single static host it points at, reading `KEY` from the tool-scoped secret
5
+ * or property record. Connectors whose upstream host is per-connection (each
6
+ * customer's payroll system lives at its own URL — sunfish, kontek, primavera, …)
7
+ * declare egress this way instead of a static list.
8
+ *
9
+ * Mirrors the host runtime executor's own resolution so `buildCtx` (the
10
+ * step-fetcher path) and `executeTool` agree on the derived host. Throws a typed
11
+ * error the caller maps to its own failure shape:
12
+ * - `AkaiSecretError` — a `secret:` binding that is unset or not a host/URL,
13
+ * - `AkaiPropertyError` — the same for a `property:` binding,
14
+ * - `AkaiSpecError` — an unsupported `from` prefix (should be caught earlier by
15
+ * `defineCLI`/manifest validation; guarded here for hand-built CLIDefs).
16
+ */
17
+ export declare function resolveDynamicEgressHost(egress: DynamicEgress, secrets: Readonly<Record<string, string | undefined>>, properties: Readonly<Record<string, string | undefined>>, cliId: string, toolName: string): string;
18
+ //# sourceMappingURL=dynamic-egress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-egress.d.ts","sourceRoot":"","sources":["../../src/ctx/dynamic-egress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACrD,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACxD,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,MAAM,CA+BR"}
@@ -0,0 +1,71 @@
1
+ import { DYNAMIC_EGRESS_PREFIXES } from '../tool.js';
2
+ import { AkaiPropertyError, AkaiSecretError, AkaiSpecError } from '../errors.js';
3
+ /**
4
+ * Resolve a tool's dynamic egress (`{ from: 'secret:KEY' | 'property:KEY' }`) to
5
+ * the single static host it points at, reading `KEY` from the tool-scoped secret
6
+ * or property record. Connectors whose upstream host is per-connection (each
7
+ * customer's payroll system lives at its own URL — sunfish, kontek, primavera, …)
8
+ * declare egress this way instead of a static list.
9
+ *
10
+ * Mirrors the host runtime executor's own resolution so `buildCtx` (the
11
+ * step-fetcher path) and `executeTool` agree on the derived host. Throws a typed
12
+ * error the caller maps to its own failure shape:
13
+ * - `AkaiSecretError` — a `secret:` binding that is unset or not a host/URL,
14
+ * - `AkaiPropertyError` — the same for a `property:` binding,
15
+ * - `AkaiSpecError` — an unsupported `from` prefix (should be caught earlier by
16
+ * `defineCLI`/manifest validation; guarded here for hand-built CLIDefs).
17
+ */
18
+ export function resolveDynamicEgressHost(egress, secrets, properties, cliId, toolName) {
19
+ const from = egress.from;
20
+ // Match the SDK's prefix set and strip it by LENGTH — do NOT split on ':', the
21
+ // value is a URL whose host:port also contains colons.
22
+ const prefix = DYNAMIC_EGRESS_PREFIXES.find((p) => from.startsWith(p) && from.length > p.length);
23
+ if (prefix === undefined) {
24
+ throw new AkaiSpecError(`buildCtx: tool \`${cliId}.${toolName}\` has unsupported dynamic egress '${from}'`);
25
+ }
26
+ const key = from.slice(prefix.length);
27
+ const isSecret = prefix === 'secret:';
28
+ const raw = (isSecret ? secrets[key] : properties[key])?.trim();
29
+ if (raw === undefined || raw === '') {
30
+ throw isSecret
31
+ ? new AkaiSecretError(`tool \`${cliId}.${toolName}\` egress is bound to secret \`${key}\` but it is unset; set the '${key}' secret on the connection`, { key })
32
+ : new AkaiPropertyError(`tool \`${cliId}.${toolName}\` egress is bound to property \`${key}\` but it is unset; set the connection's base URL`, { key });
33
+ }
34
+ const host = hostFromValue(raw);
35
+ if (host === undefined) {
36
+ throw isSecret
37
+ ? new AkaiSecretError(`secret \`${key}\` must be a hostname or absolute URL`, { key })
38
+ : new AkaiPropertyError(`property \`${key}\` must be a hostname or absolute URL`, { key });
39
+ }
40
+ return host;
41
+ }
42
+ /**
43
+ * Derive the hostname from a dynamic-egress value: an absolute URL yields its
44
+ * hostname; a bare `host[:port]` (e.g. sunfish's `SUNFISH_HOST`) parses as a bogus
45
+ * scheme with an empty hostname, so it is retried under an `https://` prefix and
46
+ * accepted only as a clean bare authority (no credentials/path/query/fragment).
47
+ * Returns `undefined` when the value is neither — the caller fails closed.
48
+ */
49
+ function hostFromValue(raw) {
50
+ try {
51
+ const h = new URL(raw).hostname;
52
+ if (h !== '')
53
+ return h;
54
+ }
55
+ catch {
56
+ /* fall through to the bare host[:port] attempt */
57
+ }
58
+ let fallback;
59
+ try {
60
+ fallback = new URL(`https://${raw}`);
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ const isBareHost = fallback.username === '' &&
66
+ fallback.password === '' &&
67
+ fallback.pathname === '/' &&
68
+ fallback.search === '' &&
69
+ fallback.hash === '';
70
+ return isBareHost && fallback.hostname !== '' ? fallback.hostname : undefined;
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akai-workflow-builder/cli-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Authoring SDK for atomic, agent-executable CLIs and tools.",
5
5
  "keywords": [
6
6
  "akai",