@jini-ai/devops 0.5.0 → 0.5.2

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
@@ -1,5 +1,16 @@
1
1
  # @jini-ai/devops
2
2
 
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Tovu clean-up release (2026-10-08): code Tovu moved into Jini, plus the Jini clean-up (see the commit log since 0.5.1).
8
+
9
+ ## 0.5.1 — 2026-10-04
10
+
11
+ - `@jini-ai/devops/local-dev` exports `listenServer`.
12
+ - Internal `@jini-ai/*` dependencies are caret ranges (`workspace:^`) instead of exact pins, so a host on a newer patch resolves a single copy without an override.
13
+
3
14
  ## 0.5.0 — 2026-10-02
4
15
 
5
16
  ### BREAKING
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Provider-agnostic shapes for publishing a static file set to a hosting
3
+ * target (any host-supplied adapter). None of these
4
+ * types know what a "project" is — the caller (a pack, a tool handler, a
5
+ * CLI command) resolves its own file set and hands over plain
6
+ * `DeployFile[]`. See the archived extraction source map for what was dropped
7
+ * from the OD origin file to get here.
8
+ */
9
+ /** Loose provider option bag; values need not be JSON-serializable. */
10
+ export type UnknownRecord = Record<string, unknown>;
11
+ /**
12
+ * One file to publish, keyed by its deploy-relative path.
13
+ *
14
+ * `sourcePath` is optional provenance the caller may attach (e.g. the path
15
+ * in its own file model) purely for diagnostics/logging — this package
16
+ * never reads it.
17
+ */
18
+ export interface DeployFile {
19
+ file: string;
20
+ data: Buffer | Uint8Array | string;
21
+ contentType?: string;
22
+ sourcePath?: string;
23
+ }
24
+ /**
25
+ * Coarse status of a deployment's public URL. `link-delayed` means the
26
+ * provider accepted the deploy but the URL is not yet reachable (DNS/CDN
27
+ * propagation); `protected` means the provider is gating the URL behind
28
+ * its own auth wall (e.g. a deployment-protection login page).
29
+ */
30
+ export type DeployLinkStatus = 'ready' | 'protected' | 'failed' | 'link-delayed';
31
+ /** Result of probing a deployment URL over HTTP. */
32
+ export interface DeploymentUrlCheck {
33
+ reachable: boolean;
34
+ status?: DeployLinkStatus;
35
+ statusCode?: number;
36
+ statusMessage?: string;
37
+ }
38
+ /**
39
+ * Input to `DeployTarget.publish`. Deliberately narrow: a file set plus a
40
+ * human/DNS-safe label the target may use to derive a provider-side
41
+ * project/deployment name. In the separate optional-arguments object,
42
+ * `metadata` is an escape hatch for target-specific
43
+ * options (e.g. custom-domain selection) that do not belong in
44
+ * the shared shape — each target documents the metadata keys it reads and
45
+ * ignores everything else.
46
+ *
47
+ * `responseHeaders` is the header set the caller wants every published page
48
+ * served with (e.g. security headers). Each target renders it into its own
49
+ * host format (a `_headers` file, a host config file, ...) or ignores it
50
+ * where the host offers no way to set headers.
51
+ */
52
+ export interface DeployPublishInput {
53
+ files: DeployFile[];
54
+ projectName: string;
55
+ }
56
+ /** Optional publish settings, passed separately from the file set and project name. */
57
+ export interface DeployPublishOptions {
58
+ metadata?: UnknownRecord;
59
+ responseHeaders?: ResponseHeaderSet;
60
+ }
61
+ /** HTTP response headers by name, as a caller asks a target to serve them. */
62
+ export type ResponseHeaderSet = Readonly<Record<string, string>>;
63
+ /** Result of a successful (or partially successful) publish call. */
64
+ export interface DeployPublishResult {
65
+ targetId: string;
66
+ url: string;
67
+ deploymentId?: string;
68
+ status: DeployLinkStatus;
69
+ statusMessage?: string;
70
+ reachableAt?: number;
71
+ /** Target-specific extras (e.g. a custom-domain/DNS outcome). */
72
+ providerMetadata?: UnknownRecord;
73
+ }
74
+ /**
75
+ * The port every deploy provider implements. Bound many-to-one against the
76
+ * `DeployTarget` many-token in `tokens.ts` (`bindMany(DeployTargetToken, ...)`)
77
+ * so any number of hosting targets can register against
78
+ * the same capability without a central union type.
79
+ */
80
+ export interface DeployTarget {
81
+ readonly id: string;
82
+ publish(requiredArgs: DeployPublishInput, optionalArgs?: DeployPublishOptions): Promise<DeployPublishResult>;
83
+ checkReachability(requiredArgs: {
84
+ url: string;
85
+ }): Promise<DeploymentUrlCheck>;
86
+ }
87
+ export type DeployErrorDetails = UnknownRecord | string | undefined;
88
+ /**
89
+ * Thrown by target implementations for both caller-input problems (bad
90
+ * config, missing token) and upstream provider failures (HTTP error,
91
+ * malformed response). `status` mirrors HTTP semantics so a transport layer
92
+ * can map it directly onto a response code.
93
+ */
94
+ export declare class DeployError extends Error {
95
+ status: number;
96
+ details: DeployErrorDetails;
97
+ code?: string | undefined;
98
+ constructor({ message }: {
99
+ message: string;
100
+ }, { status, details, code, }?: {
101
+ status?: number;
102
+ details?: DeployErrorDetails;
103
+ code?: string;
104
+ });
105
+ }
106
+ //# sourceMappingURL=deploy-types.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Provider-agnostic shapes for publishing a static file set to a hosting
3
+ * target (any host-supplied adapter). None of these
4
+ * types know what a "project" is — the caller (a pack, a tool handler, a
5
+ * CLI command) resolves its own file set and hands over plain
6
+ * `DeployFile[]`. See the archived extraction source map for what was dropped
7
+ * from the OD origin file to get here.
8
+ */
9
+ /**
10
+ * Thrown by target implementations for both caller-input problems (bad
11
+ * config, missing token) and upstream provider failures (HTTP error,
12
+ * malformed response). `status` mirrors HTTP semantics so a transport layer
13
+ * can map it directly onto a response code.
14
+ */
15
+ export class DeployError extends Error {
16
+ status;
17
+ details;
18
+ code;
19
+ constructor({ message }, { status = 400, details, code, } = {}) {
20
+ super(message);
21
+ this.name = 'DeployError';
22
+ this.status = status;
23
+ this.details = details;
24
+ this.code = code;
25
+ }
26
+ }
27
+ //# sourceMappingURL=deploy-types.js.map
@@ -0,0 +1,12 @@
1
+ import type { ExportReport } from '../static-export/contracts.js';
2
+ export interface ExportFailureSummary {
3
+ kind: 'route' | 'asset';
4
+ identifier: string;
5
+ reason: string;
6
+ count: number;
7
+ }
8
+ /** Runtime-leaf check of routes AND assets. Routes take precedence; the count is per collection. */
9
+ export declare function firstExportFailure(required: {
10
+ report: ExportReport;
11
+ }, _optional?: {}): ExportFailureSummary | undefined;
12
+ //# sourceMappingURL=export-failure-summary.d.ts.map
@@ -0,0 +1,12 @@
1
+ /** Runtime-leaf check of routes AND assets. Routes take precedence; the count is per collection. */
2
+ export function firstExportFailure(required, _optional = {}) {
3
+ const { report } = required;
4
+ const route = report.routes.failed[0];
5
+ if (route)
6
+ return { kind: 'route', identifier: route.path, reason: route.reason, count: report.routes.failed.length };
7
+ const asset = report.assets.failed[0];
8
+ if (asset)
9
+ return { kind: 'asset', identifier: asset.url, reason: asset.reason, count: report.assets.failed.length };
10
+ return undefined;
11
+ }
12
+ //# sourceMappingURL=export-failure-summary.js.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Shared redirect guard for deploy targets whose `fetch()` calls carry a live
3
+ * `Authorization: Bearer <token>` header. Without a `redirect` option, a 3xx response from a
4
+ * target's hardcoded, trusted API origin would be followed transparently by `fetch()`, replaying
5
+ * that Authorization header at whatever `Location` the response named. Under normal operation no
6
+ * such origin redirects these endpoints, but a redirect is exactly the mechanism a compromised edge,
7
+ * misconfigured origin, or MITM would use to exfiltrate the token to an attacker-controlled host —
8
+ * flagged 2026-08-15 (a downstream product's deploy-publishing dispatch) and fixed here, in the shared helper every target uses,
9
+ * rather than only papering over it from a caller.
10
+ *
11
+ * `redirectGuardInit` is the one place every call site adds `redirect: 'manual'`.
12
+ * `assertNotRedirected` is the one place that turns the resulting response into an honest, typed
13
+ * failure. Per the WHATWG Fetch spec (undici implements this identically for Node, not just
14
+ * browsers), `redirect: 'manual'` makes `fetch()` resolve to an "opaque-redirect filtered
15
+ * response" for ANY 3xx — `status` 0, `type: 'opaqueredirect'`, no readable headers/body — so this
16
+ * guard checks `type` first and `status` second (a `PROVIDER_ERROR`-shaped 3xx can never reach
17
+ * this function with `status` in the 300s once `redirect: 'manual'` is set, but checking both
18
+ * keeps this correct even if a future runtime implements manual mode differently).
19
+ */
20
+ /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
21
+ export declare function redirectGuardInit({ init }: {
22
+ init: RequestInit;
23
+ }): RequestInit;
24
+ /**
25
+ * @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
26
+ * redirect this authenticated request elsewhere). Call immediately after every guarded
27
+ * `fetch()`, before reading `resp.status`/`resp.json()` for any other reason — a caller that
28
+ * checks `resp.status === 404` (a real, expected branch in some targets) before this guard
29
+ * would never see that check misfire, since an opaque-redirect response's `status` is `0`, not
30
+ * `404` — but call ordering here still matters for every OTHER status-sensitive branch in
31
+ * a target.
32
+ */
33
+ export declare function assertNotRedirected({ resp, providerLabel }: {
34
+ resp: Response;
35
+ providerLabel: string;
36
+ }): void;
37
+ //# sourceMappingURL=redirect-guard.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { DeployError } from './deploy-types.js';
2
+ /**
3
+ * Shared redirect guard for deploy targets whose `fetch()` calls carry a live
4
+ * `Authorization: Bearer <token>` header. Without a `redirect` option, a 3xx response from a
5
+ * target's hardcoded, trusted API origin would be followed transparently by `fetch()`, replaying
6
+ * that Authorization header at whatever `Location` the response named. Under normal operation no
7
+ * such origin redirects these endpoints, but a redirect is exactly the mechanism a compromised edge,
8
+ * misconfigured origin, or MITM would use to exfiltrate the token to an attacker-controlled host —
9
+ * flagged 2026-08-15 (a downstream product's deploy-publishing dispatch) and fixed here, in the shared helper every target uses,
10
+ * rather than only papering over it from a caller.
11
+ *
12
+ * `redirectGuardInit` is the one place every call site adds `redirect: 'manual'`.
13
+ * `assertNotRedirected` is the one place that turns the resulting response into an honest, typed
14
+ * failure. Per the WHATWG Fetch spec (undici implements this identically for Node, not just
15
+ * browsers), `redirect: 'manual'` makes `fetch()` resolve to an "opaque-redirect filtered
16
+ * response" for ANY 3xx — `status` 0, `type: 'opaqueredirect'`, no readable headers/body — so this
17
+ * guard checks `type` first and `status` second (a `PROVIDER_ERROR`-shaped 3xx can never reach
18
+ * this function with `status` in the 300s once `redirect: 'manual'` is set, but checking both
19
+ * keeps this correct even if a future runtime implements manual mode differently).
20
+ */
21
+ /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
22
+ export function redirectGuardInit({ init }) {
23
+ return { ...init, redirect: 'manual' };
24
+ }
25
+ /**
26
+ * @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
27
+ * redirect this authenticated request elsewhere). Call immediately after every guarded
28
+ * `fetch()`, before reading `resp.status`/`resp.json()` for any other reason — a caller that
29
+ * checks `resp.status === 404` (a real, expected branch in some targets) before this guard
30
+ * would never see that check misfire, since an opaque-redirect response's `status` is `0`, not
31
+ * `404` — but call ordering here still matters for every OTHER status-sensitive branch in
32
+ * a target.
33
+ */
34
+ export function assertNotRedirected({ resp, providerLabel }) {
35
+ if (resp.type === 'opaqueredirect' || (resp.status >= 300 && resp.status < 400)) {
36
+ throw new DeployError({ message: `${providerLabel} attempted to redirect an authenticated request — refused to follow it (possible credential-leak vector).` }, { status: 502 });
37
+ }
38
+ }
39
+ //# sourceMappingURL=redirect-guard.js.map
@@ -11,10 +11,10 @@
11
11
  * other (`bindMany(DeployTargetToken, ...)` or passed straight to
12
12
  * `publishDeploy`). Nothing here names a hosting provider.
13
13
  */
14
- import type { assertNotRedirected, redirectGuardInit } from './redirect-guard.js';
14
+ import type { assertNotRedirected, redirectGuardInit } from '../core/redirect-guard.js';
15
15
  import type { safeDnsLabel, safeProjectLabel } from './naming.js';
16
16
  import type { checkDeploymentUrl, normalizeDeploymentUrl, waitForReachableDeploymentUrl } from './reachability.js';
17
- import type { DeployError, DeployTarget, UnknownRecord } from './types.js';
17
+ import type { DeployError, DeployTarget, UnknownRecord } from '../core/deploy-types.js';
18
18
  /**
19
19
  * The resolved saved credential a module builds its target from: always a
20
20
  * `token`, plus whatever extra fields that host's credential carries (an
@@ -1,7 +1,7 @@
1
- export * from './types.js';
1
+ export * from '../core/deploy-types.js';
2
2
  export * from './naming.js';
3
3
  export * from './reachability.js';
4
- export * from './redirect-guard.js';
4
+ export * from '../core/redirect-guard.js';
5
5
  export * from './host-kit.js';
6
6
  export * from './tokens.js';
7
7
  export * from './tool.js';
@@ -1,7 +1,7 @@
1
- export * from './types.js';
1
+ export * from '../core/deploy-types.js';
2
2
  export * from './naming.js';
3
3
  export * from './reachability.js';
4
- export * from './redirect-guard.js';
4
+ export * from '../core/redirect-guard.js';
5
5
  export * from './host-kit.js';
6
6
  export * from './tokens.js';
7
7
  export * from './tool.js';
@@ -1,4 +1,4 @@
1
- import type { DeployLinkStatus, DeploymentUrlCheck } from './types.js';
1
+ import type { DeployLinkStatus, DeploymentUrlCheck } from '../core/deploy-types.js';
2
2
  /**
3
3
  * Provider-supplied hook for recognizing a deployment URL that responded
4
4
  * but is gated behind the provider's own auth wall (a deployment-protection
@@ -1,37 +1,2 @@
1
- /**
2
- * Shared redirect guard for deploy targets whose `fetch()` calls carry a live
3
- * `Authorization: Bearer <token>` header. Without a `redirect` option, a 3xx response from a
4
- * target's hardcoded, trusted API origin would be followed transparently by `fetch()`, replaying
5
- * that Authorization header at whatever `Location` the response named. Under normal operation no
6
- * such origin redirects these endpoints, but a redirect is exactly the mechanism a compromised edge,
7
- * misconfigured origin, or MITM would use to exfiltrate the token to an attacker-controlled host —
8
- * flagged 2026-08-15 (a downstream product's deploy-publishing dispatch) and fixed here, in the shared helper every target uses,
9
- * rather than only papering over it from a caller.
10
- *
11
- * `redirectGuardInit` is the one place every call site adds `redirect: 'manual'`.
12
- * `assertNotRedirected` is the one place that turns the resulting response into an honest, typed
13
- * failure. Per the WHATWG Fetch spec (undici implements this identically for Node, not just
14
- * browsers), `redirect: 'manual'` makes `fetch()` resolve to an "opaque-redirect filtered
15
- * response" for ANY 3xx — `status` 0, `type: 'opaqueredirect'`, no readable headers/body — so this
16
- * guard checks `type` first and `status` second (a `PROVIDER_ERROR`-shaped 3xx can never reach
17
- * this function with `status` in the 300s once `redirect: 'manual'` is set, but checking both
18
- * keeps this correct even if a future runtime implements manual mode differently).
19
- */
20
- /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
21
- export declare function redirectGuardInit({ init }: {
22
- init: RequestInit;
23
- }): RequestInit;
24
- /**
25
- * @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
26
- * redirect this authenticated request elsewhere). Call immediately after every guarded
27
- * `fetch()`, before reading `resp.status`/`resp.json()` for any other reason — a caller that
28
- * checks `resp.status === 404` (a real, expected branch in some targets) before this guard
29
- * would never see that check misfire, since an opaque-redirect response's `status` is `0`, not
30
- * `404` — but call ordering here still matters for every OTHER status-sensitive branch in
31
- * a target.
32
- */
33
- export declare function assertNotRedirected({ resp, providerLabel }: {
34
- resp: Response;
35
- providerLabel: string;
36
- }): void;
1
+ export * from '../core/redirect-guard.js';
37
2
  //# sourceMappingURL=redirect-guard.d.ts.map
@@ -1,39 +1,3 @@
1
- import { DeployError } from './types.js';
2
- /**
3
- * Shared redirect guard for deploy targets whose `fetch()` calls carry a live
4
- * `Authorization: Bearer <token>` header. Without a `redirect` option, a 3xx response from a
5
- * target's hardcoded, trusted API origin would be followed transparently by `fetch()`, replaying
6
- * that Authorization header at whatever `Location` the response named. Under normal operation no
7
- * such origin redirects these endpoints, but a redirect is exactly the mechanism a compromised edge,
8
- * misconfigured origin, or MITM would use to exfiltrate the token to an attacker-controlled host —
9
- * flagged 2026-08-15 (a downstream product's deploy-publishing dispatch) and fixed here, in the shared helper every target uses,
10
- * rather than only papering over it from a caller.
11
- *
12
- * `redirectGuardInit` is the one place every call site adds `redirect: 'manual'`.
13
- * `assertNotRedirected` is the one place that turns the resulting response into an honest, typed
14
- * failure. Per the WHATWG Fetch spec (undici implements this identically for Node, not just
15
- * browsers), `redirect: 'manual'` makes `fetch()` resolve to an "opaque-redirect filtered
16
- * response" for ANY 3xx — `status` 0, `type: 'opaqueredirect'`, no readable headers/body — so this
17
- * guard checks `type` first and `status` second (a `PROVIDER_ERROR`-shaped 3xx can never reach
18
- * this function with `status` in the 300s once `redirect: 'manual'` is set, but checking both
19
- * keeps this correct even if a future runtime implements manual mode differently).
20
- */
21
- /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
22
- export function redirectGuardInit({ init }) {
23
- return { ...init, redirect: 'manual' };
24
- }
25
- /**
26
- * @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
27
- * redirect this authenticated request elsewhere). Call immediately after every guarded
28
- * `fetch()`, before reading `resp.status`/`resp.json()` for any other reason — a caller that
29
- * checks `resp.status === 404` (a real, expected branch in some targets) before this guard
30
- * would never see that check misfire, since an opaque-redirect response's `status` is `0`, not
31
- * `404` — but call ordering here still matters for every OTHER status-sensitive branch in
32
- * a target.
33
- */
34
- export function assertNotRedirected({ resp, providerLabel }) {
35
- if (resp.type === 'opaqueredirect' || (resp.status >= 300 && resp.status < 400)) {
36
- throw new DeployError({ message: `${providerLabel} attempted to redirect an authenticated request — refused to follow it (possible credential-leak vector).` }, { status: 502 });
37
- }
38
- }
1
+ // Compatibility path; the shared implementation lives in core.
2
+ export * from '../core/redirect-guard.js';
39
3
  //# sourceMappingURL=redirect-guard.js.map
@@ -1,4 +1,4 @@
1
- import { type DeployFile, type DeployPublishOptions, type DeployPublishResult, type DeployTarget, type UnknownRecord } from './types.js';
1
+ import { type DeployFile, type DeployPublishOptions, type DeployPublishResult, type DeployTarget, type UnknownRecord } from '../core/deploy-types.js';
2
2
  /**
3
3
  * Many-bound composition token for deploy providers, per extraction-plan.md
4
4
  * §2.2's own worked example (`DeployTarget = manyToken<DeployProvider>
@@ -1,5 +1,5 @@
1
1
  import { manyToken } from '@jini-ai/core';
2
- import { DeployError } from './types.js';
2
+ import { DeployError } from '../core/deploy-types.js';
3
3
  /**
4
4
  * Many-bound composition token for deploy providers, per extraction-plan.md
5
5
  * §2.2's own worked example (`DeployTarget = manyToken<DeployProvider>
@@ -18,7 +18,7 @@
18
18
  * `undici`).
19
19
  */
20
20
  import type { ToolPolicy, ToolRegistration } from '@jini-ai/core';
21
- import type { DeployTarget } from './types.js';
21
+ import type { DeployTarget } from '../core/deploy-types.js';
22
22
  /** The `ToolRegistry` id this file registers `deploy.publish` under. */
23
23
  export declare const DEPLOY_PUBLISH_TOOL_ID = "deploy.publish";
24
24
  /**
@@ -1,106 +1,2 @@
1
- /**
2
- * Provider-agnostic shapes for publishing a static file set to a hosting
3
- * target (any host-supplied adapter). None of these
4
- * types know what a "project" is — the caller (a pack, a tool handler, a
5
- * CLI command) resolves its own file set and hands over plain
6
- * `DeployFile[]`. See the archived extraction source map for what was dropped
7
- * from the OD origin file to get here.
8
- */
9
- /** Loose provider option bag; values need not be JSON-serializable. */
10
- export type UnknownRecord = Record<string, unknown>;
11
- /**
12
- * One file to publish, keyed by its deploy-relative path.
13
- *
14
- * `sourcePath` is optional provenance the caller may attach (e.g. the path
15
- * in its own file model) purely for diagnostics/logging — this package
16
- * never reads it.
17
- */
18
- export interface DeployFile {
19
- file: string;
20
- data: Buffer | Uint8Array | string;
21
- contentType?: string;
22
- sourcePath?: string;
23
- }
24
- /**
25
- * Coarse status of a deployment's public URL. `link-delayed` means the
26
- * provider accepted the deploy but the URL is not yet reachable (DNS/CDN
27
- * propagation); `protected` means the provider is gating the URL behind
28
- * its own auth wall (e.g. a deployment-protection login page).
29
- */
30
- export type DeployLinkStatus = 'ready' | 'protected' | 'failed' | 'link-delayed';
31
- /** Result of probing a deployment URL over HTTP. */
32
- export interface DeploymentUrlCheck {
33
- reachable: boolean;
34
- status?: DeployLinkStatus;
35
- statusCode?: number;
36
- statusMessage?: string;
37
- }
38
- /**
39
- * Input to `DeployTarget.publish`. Deliberately narrow: a file set plus a
40
- * human/DNS-safe label the target may use to derive a provider-side
41
- * project/deployment name. In the separate optional-arguments object,
42
- * `metadata` is an escape hatch for target-specific
43
- * options (e.g. custom-domain selection) that do not belong in
44
- * the shared shape — each target documents the metadata keys it reads and
45
- * ignores everything else.
46
- *
47
- * `responseHeaders` is the header set the caller wants every published page
48
- * served with (e.g. security headers). Each target renders it into its own
49
- * host format (a `_headers` file, a host config file, ...) or ignores it
50
- * where the host offers no way to set headers.
51
- */
52
- export interface DeployPublishInput {
53
- files: DeployFile[];
54
- projectName: string;
55
- }
56
- /** Optional publish settings, passed separately from the file set and project name. */
57
- export interface DeployPublishOptions {
58
- metadata?: UnknownRecord;
59
- responseHeaders?: ResponseHeaderSet;
60
- }
61
- /** HTTP response headers by name, as a caller asks a target to serve them. */
62
- export type ResponseHeaderSet = Readonly<Record<string, string>>;
63
- /** Result of a successful (or partially successful) publish call. */
64
- export interface DeployPublishResult {
65
- targetId: string;
66
- url: string;
67
- deploymentId?: string;
68
- status: DeployLinkStatus;
69
- statusMessage?: string;
70
- reachableAt?: number;
71
- /** Target-specific extras (e.g. a custom-domain/DNS outcome). */
72
- providerMetadata?: UnknownRecord;
73
- }
74
- /**
75
- * The port every deploy provider implements. Bound many-to-one against the
76
- * `DeployTarget` many-token in `tokens.ts` (`bindMany(DeployTargetToken, ...)`)
77
- * so any number of hosting targets can register against
78
- * the same capability without a central union type.
79
- */
80
- export interface DeployTarget {
81
- readonly id: string;
82
- publish(requiredArgs: DeployPublishInput, optionalArgs?: DeployPublishOptions): Promise<DeployPublishResult>;
83
- checkReachability(requiredArgs: {
84
- url: string;
85
- }): Promise<DeploymentUrlCheck>;
86
- }
87
- export type DeployErrorDetails = UnknownRecord | string | undefined;
88
- /**
89
- * Thrown by target implementations for both caller-input problems (bad
90
- * config, missing token) and upstream provider failures (HTTP error,
91
- * malformed response). `status` mirrors HTTP semantics so a transport layer
92
- * can map it directly onto a response code.
93
- */
94
- export declare class DeployError extends Error {
95
- status: number;
96
- details: DeployErrorDetails;
97
- code?: string | undefined;
98
- constructor({ message }: {
99
- message: string;
100
- }, { status, details, code, }?: {
101
- status?: number;
102
- details?: DeployErrorDetails;
103
- code?: string;
104
- });
105
- }
1
+ export * from '../core/deploy-types.js';
106
2
  //# sourceMappingURL=types.d.ts.map
@@ -1,27 +1,3 @@
1
- /**
2
- * Provider-agnostic shapes for publishing a static file set to a hosting
3
- * target (any host-supplied adapter). None of these
4
- * types know what a "project" is — the caller (a pack, a tool handler, a
5
- * CLI command) resolves its own file set and hands over plain
6
- * `DeployFile[]`. See the archived extraction source map for what was dropped
7
- * from the OD origin file to get here.
8
- */
9
- /**
10
- * Thrown by target implementations for both caller-input problems (bad
11
- * config, missing token) and upstream provider failures (HTTP error,
12
- * malformed response). `status` mirrors HTTP semantics so a transport layer
13
- * can map it directly onto a response code.
14
- */
15
- export class DeployError extends Error {
16
- status;
17
- details;
18
- code;
19
- constructor({ message }, { status = 400, details, code, } = {}) {
20
- super(message);
21
- this.name = 'DeployError';
22
- this.status = status;
23
- this.details = details;
24
- this.code = code;
25
- }
26
- }
1
+ // Compatibility path; the shared implementation lives in core.
2
+ export * from '../core/deploy-types.js';
27
3
  //# sourceMappingURL=types.js.map
@@ -31,4 +31,25 @@ export declare function listenersOn({ port, runner, listenerCommand }: {
31
31
  port: number;
32
32
  }) => ProcessRequest;
33
33
  }): Promise<PortListener[]>;
34
+ /** Minimal listener port; adapters may supply HTTP, HTTPS, or a deterministic socket double. */
35
+ export interface ServerListenerPort {
36
+ once(event: 'error' | 'listening', handler: (...args: unknown[]) => void): unknown;
37
+ off(event: 'error' | 'listening', handler: (...args: unknown[]) => void): unknown;
38
+ listen(input: {
39
+ port: number;
40
+ host?: string;
41
+ }): unknown;
42
+ address(): {
43
+ port: number;
44
+ } | string | null;
45
+ }
46
+ /** Bind the actual listener, retaining it across boot. Only address collisions may try the next
47
+ * port; explicit addresses use the default single attempt. No probe/release/bind race. */
48
+ export declare function listenServer({ server, port }: {
49
+ server: ServerListenerPort;
50
+ port: number;
51
+ }, { host, attempts }?: {
52
+ host?: string;
53
+ attempts?: number;
54
+ }): Promise<number>;
34
55
  //# sourceMappingURL=index.d.ts.map
@@ -34,4 +34,35 @@ export async function listenersOn({ port, runner, listenerCommand }) {
34
34
  return [];
35
35
  }
36
36
  }
37
+ /** Bind the actual listener, retaining it across boot. Only address collisions may try the next
38
+ * port; explicit addresses use the default single attempt. No probe/release/bind race. */
39
+ export async function listenServer({ server, port }, { host, attempts = 1 } = {}) {
40
+ if (!Number.isInteger(attempts) || attempts < 1 || !Number.isInteger(port) || port < 0 || port + attempts - 1 > 65535) {
41
+ throw new RangeError('Invalid listener port or attempt range');
42
+ }
43
+ for (let offset = 0; offset < attempts; offset++) {
44
+ try {
45
+ await new Promise((resolve, reject) => {
46
+ const cleanup = () => { server.off('error', onError); server.off('listening', onListening); };
47
+ const onError = (error) => { cleanup(); reject(error); };
48
+ const onListening = () => { cleanup(); resolve(); };
49
+ server.once('error', onError);
50
+ server.once('listening', onListening);
51
+ try {
52
+ server.listen({ port: port + offset, ...(host === undefined ? {} : { host }) });
53
+ }
54
+ catch (error) {
55
+ onError(error);
56
+ }
57
+ });
58
+ const address = server.address();
59
+ return typeof address === 'object' && address !== null ? address.port : port + offset;
60
+ }
61
+ catch (error) {
62
+ if (error?.code !== 'EADDRINUSE' || offset === attempts - 1)
63
+ throw error;
64
+ }
65
+ }
66
+ throw new Error('Listener range exhausted');
67
+ }
37
68
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { firstExportFailure } from '../static-export/failure-summary.js';
1
+ import { firstExportFailure } from '../core/export-failure-summary.js';
2
2
  import { validateCommitTarget } from './repository-target.js';
3
3
  /** Normalize platform separators without changing the retained byte payload. */
4
4
  export function toCommitFile(required) {
@@ -1,4 +1,5 @@
1
- import { assertNotRedirected, DeployError, redirectGuardInit } from '../deploy/index.js';
1
+ import { assertNotRedirected, redirectGuardInit } from '../core/redirect-guard.js';
2
+ import { DeployError } from '../core/deploy-types.js';
2
3
  /** Build a kit without globals or a silently missing guarded HTTP client. */
3
4
  export function createSourceControlProviderKit(required) {
4
5
  return {
@@ -120,7 +120,12 @@ export interface ExportSiteArgs {
120
120
  acceptStatus(required: {
121
121
  status: number;
122
122
  }): boolean;
123
+ rejectionReason?(required: {
124
+ status: number;
125
+ }): string;
123
126
  };
127
+ /** Host terminology for an asset rejected before network/filesystem access. */
128
+ assetPathFailureReason?: string;
124
129
  /** Caller-safe error description; used for failed network, body or artifact writes. */
125
130
  describeError(required: {
126
131
  error: unknown;
@@ -1,6 +1,6 @@
1
1
  export * from './contracts.js';
2
2
  export * from './fetch-adapter.js';
3
- export * from './failure-summary.js';
3
+ export * from '../core/export-failure-summary.js';
4
4
  export * from './transforms.js';
5
5
  export * from './runner.js';
6
6
  //# sourceMappingURL=entry.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export * from './contracts.js';
2
2
  export * from './fetch-adapter.js';
3
- export * from './failure-summary.js';
3
+ export * from '../core/export-failure-summary.js';
4
4
  export * from './transforms.js';
5
5
  export * from './runner.js';
6
6
  //# sourceMappingURL=entry.js.map
@@ -1,12 +1,2 @@
1
- import type { ExportReport } from './contracts.js';
2
- export interface ExportFailureSummary {
3
- kind: 'route' | 'asset';
4
- identifier: string;
5
- reason: string;
6
- count: number;
7
- }
8
- /** Runtime-leaf check of routes AND assets. Routes take precedence; the count is per collection. */
9
- export declare function firstExportFailure(required: {
10
- report: ExportReport;
11
- }): ExportFailureSummary | undefined;
1
+ export * from '../core/export-failure-summary.js';
12
2
  //# sourceMappingURL=failure-summary.d.ts.map
@@ -1,12 +1,3 @@
1
- /** Runtime-leaf check of routes AND assets. Routes take precedence; the count is per collection. */
2
- export function firstExportFailure(required) {
3
- const { report } = required;
4
- const route = report.routes.failed[0];
5
- if (route)
6
- return { kind: 'route', identifier: route.path, reason: route.reason, count: report.routes.failed.length };
7
- const asset = report.assets.failed[0];
8
- if (asset)
9
- return { kind: 'asset', identifier: asset.url, reason: asset.reason, count: report.assets.failed.length };
10
- return undefined;
11
- }
1
+ // Compatibility path; the shared implementation lives in core.
2
+ export * from '../core/export-failure-summary.js';
12
3
  //# sourceMappingURL=failure-summary.js.map
@@ -1,11 +1,16 @@
1
1
  import { type RequestListener } from 'node:http';
2
2
  import { type AppFactoryPort, type ArtifactWriterPort, type AssetSourcePort } from './contracts.js';
3
3
  /** Caller-owned output directory, explicit clean, and no-follow regular-file writes. */
4
- export declare function createNodeArtifactWriter(_required: Record<string, never>): ArtifactWriterPort;
4
+ export declare function createNodeArtifactWriter(_required: Record<string, never>, optional?: {
5
+ nonemptyReason?: (required: {
6
+ outputDir: string;
7
+ count: number;
8
+ }) => string;
9
+ }): ArtifactWriterPort;
5
10
  /** Independent Node loopback adapter. The app factory is required and remains owned by the host. */
6
11
  export declare function createNodeAppFactory(required: {
7
12
  createApp(required: Record<string, never>): RequestListener | Promise<RequestListener>;
8
- }): AppFactoryPort;
13
+ }, _optional?: {}): AppFactoryPort;
9
14
  /** Inventory only regular theme files. Rendering and API-version layout stay injected. */
10
- export declare function createNodeAssetSource(_required: Record<string, never>): AssetSourcePort;
15
+ export declare function createNodeAssetSource(_required: Record<string, never>, _optional?: {}): AssetSourcePort;
11
16
  //# sourceMappingURL=node-adapters.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { once } from 'node:events';
2
2
  import { constants } from 'node:fs';
3
- import { lstat, mkdir, open, readdir, rm } from 'node:fs/promises';
3
+ import { lstat, mkdir, open, readdir, realpath, rm } from 'node:fs/promises';
4
4
  import { createServer } from 'node:http';
5
5
  import path from 'node:path';
6
6
  import { ExportOutputNotEmptyError, ExportPathError } from './contracts.js';
@@ -26,19 +26,23 @@ async function ensureDirectory({ directory, label }, optional = {}) {
26
26
  }
27
27
  }
28
28
  const info = await lstat(current);
29
- if (!info.isDirectory() || info.isSymbolicLink())
29
+ // macOS exposes its system temporary roots through these fixed OS aliases. Arbitrary
30
+ // symlinks still fail closed; rejecting /var would reject Node's own tmpdir() output.
31
+ const systemAlias = process.platform === 'darwin' && (current === '/tmp' || current === '/var')
32
+ && info.isSymbolicLink() && await realpath(current) === '/private' + current;
33
+ if (!systemAlias && (!info.isDirectory() || info.isSymbolicLink()))
30
34
  throw new ExportPathError(`${label} path must be a regular directory.`);
31
35
  }
32
36
  }
33
37
  /** Caller-owned output directory, explicit clean, and no-follow regular-file writes. */
34
- export function createNodeArtifactWriter(_required) {
38
+ export function createNodeArtifactWriter(_required, optional = {}) {
35
39
  return {
36
- async prepare({ outputDir }, optional = {}) {
40
+ async prepare({ outputDir }, options = {}) {
37
41
  await ensureDirectory({ directory: outputDir, label: 'Output' }, { create: true });
38
42
  const entries = await readdir(outputDir);
39
- if (entries.length && !optional.clean)
40
- throw new ExportOutputNotEmptyError(`export output directory '${outputDir}' is not empty (${entries.length} existing ${entries.length === 1 ? 'entry' : 'entries'}) — pass clean: true to remove its contents first, or select an empty/new directory`);
41
- if (optional.clean)
43
+ if (entries.length && !options.clean)
44
+ throw new ExportOutputNotEmptyError(optional.nonemptyReason?.({ outputDir, count: entries.length }) ?? `export output directory '${outputDir}' is not empty (${entries.length} existing ${entries.length === 1 ? 'entry' : 'entries'}) — pass clean: true to remove its contents first, or select an empty/new directory`);
45
+ if (options.clean)
42
46
  for (const entry of entries)
43
47
  await rm(path.join(outputDir, entry), { recursive: true, force: true });
44
48
  },
@@ -70,7 +74,7 @@ export function createNodeArtifactWriter(_required) {
70
74
  };
71
75
  }
72
76
  /** Independent Node loopback adapter. The app factory is required and remains owned by the host. */
73
- export function createNodeAppFactory(required) {
77
+ export function createNodeAppFactory(required, _optional = {}) {
74
78
  return { async open() {
75
79
  const server = createServer(await required.createApp({}));
76
80
  let closed = false;
@@ -94,7 +98,7 @@ export function createNodeAppFactory(required) {
94
98
  } };
95
99
  }
96
100
  /** Inventory only regular theme files. Rendering and API-version layout stay injected. */
97
- export function createNodeAssetSource(_required) {
101
+ export function createNodeAssetSource(_required, _optional = {}) {
98
102
  async function list(directory, prefix) {
99
103
  const files = [];
100
104
  for (const entry of await readdir(directory, { withFileTypes: true })) {
@@ -1,3 +1,4 @@
1
+ import { ExportPathError } from "./contracts.js";
1
2
  import { extractAssetUrls, extractCssUrls, normalizeBasePath, outputFileForUrl, redirectOutcomeFor, renderRedirectStub, rewriteRouteBodyForBasePath, safeRelativeOutputFile } from './transforms.js';
2
3
  const BASE_PATH_REWRITE_WARNING = "base-path rewriting is a best-effort TEXT rewrite over already-rendered responses — it cannot rewrite a path a theme's own JavaScript constructs at runtime from a string (same category of gap as the unreferenced-theme-file warning, just invisible to this rewrite instead of to the asset crawl).";
3
4
  async function request(ctx, url) {
@@ -28,7 +29,7 @@ async function writeRoute(ctx, route) {
28
29
  else {
29
30
  if (route.kind === 'not-found' ? !ctx.args.errorPage.acceptStatus({ status: response.status }) : response.status !== 200) {
30
31
  await response.body?.cancel();
31
- return { reason: route.kind === 'not-found' ? `expected an accepted response for the error-page probe, got ${response.status}` : `expected 200, got ${response.status}` };
32
+ return { reason: route.kind === 'not-found' ? (ctx.args.errorPage.rejectionReason?.({ status: response.status }) ?? `expected an accepted response for the error-page probe, got ${response.status}`) : `expected 200, got ${response.status}` };
32
33
  }
33
34
  rawBody = await response.text();
34
35
  body = rewriteRouteBodyForBasePath({ path: route.path, body: rawBody, basePath: ctx.basePath });
@@ -86,7 +87,7 @@ async function writeAssets(ctx, initial) {
86
87
  }
87
88
  }
88
89
  catch (error) {
89
- failed.push({ url, reason: failureReason(ctx, url, error) });
90
+ failed.push({ url, reason: error instanceof ExportPathError && ctx.args.assetPathFailureReason !== undefined ? ctx.args.assetPathFailureReason : failureReason(ctx, url, error) });
90
91
  }
91
92
  }
92
93
  return { succeeded, failed };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/devops",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "DevOps capabilities for deployment, source control, and CI/CD, exposed through independent subpaths.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -25,7 +25,8 @@
25
25
  "./checks/coverage": "node",
26
26
  "./checks/node": "node",
27
27
  "./local-dev": "node",
28
- "./deploy/node": "node"
28
+ "./deploy/node": "node",
29
+ "./static-export/failure-summary": "universal"
29
30
  }
30
31
  },
31
32
  "type": "module",
@@ -97,6 +98,11 @@
97
98
  "types": "./dist/deploy/node.d.ts",
98
99
  "import": "./dist/deploy/node.js",
99
100
  "default": "./dist/deploy/node.js"
101
+ },
102
+ "./static-export/failure-summary": {
103
+ "types": "./dist/core/export-failure-summary.d.ts",
104
+ "import": "./dist/core/export-failure-summary.js",
105
+ "default": "./dist/core/export-failure-summary.js"
100
106
  }
101
107
  },
102
108
  "files": [
@@ -115,21 +121,30 @@
115
121
  "access": "public",
116
122
  "registry": "https://registry.npmjs.org"
117
123
  },
118
- "dependencies": {
119
- "undici": "^7.25.0",
120
- "@jini-ai/core": "0.4.0",
121
- "@jini-ai/platform": "0.5.0"
122
- },
123
124
  "devDependencies": {
124
125
  "@vitest/coverage-v8": "^2.1.9",
125
- "@jini-ai/daemon": "0.5.0"
126
+ "undici": "^7.25.0",
127
+ "@jini-ai/core": "^0.4.2",
128
+ "@jini-ai/daemon": "0.5.4",
129
+ "@jini-ai/platform": "^0.5.2"
130
+ },
131
+ "dependencies": {
132
+ "@jini-ai/core": "^0.4.2"
126
133
  },
127
134
  "peerDependencies": {
128
- "typescript": "^5.6.0"
135
+ "typescript": "^5.6.0",
136
+ "@jini-ai/platform": "^0.5.1",
137
+ "undici": "^7.25.0"
129
138
  },
130
139
  "peerDependenciesMeta": {
131
140
  "typescript": {
132
141
  "optional": true
142
+ },
143
+ "@jini-ai/platform": {
144
+ "optional": true
145
+ },
146
+ "undici": {
147
+ "optional": true
133
148
  }
134
149
  },
135
150
  "scripts": {