@jini-ai/devops 0.3.3 → 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.
Files changed (104) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +65 -5
  3. package/dist/agent-jobs/entry.d.ts +4 -0
  4. package/dist/agent-jobs/entry.js +4 -0
  5. package/dist/agent-jobs/jobs.d.ts +25 -0
  6. package/dist/agent-jobs/jobs.js +115 -0
  7. package/dist/agent-jobs/node.d.ts +12 -0
  8. package/dist/agent-jobs/node.js +53 -0
  9. package/dist/agent-jobs/ports.d.ts +69 -0
  10. package/dist/agent-jobs/ports.js +2 -0
  11. package/dist/checks/coverage/diff.d.ts +57 -0
  12. package/dist/checks/coverage/diff.js +48 -0
  13. package/dist/checks/coverage/disk.d.ts +65 -0
  14. package/dist/checks/coverage/disk.js +136 -0
  15. package/dist/checks/coverage/floors.d.ts +31 -0
  16. package/dist/checks/coverage/floors.js +24 -0
  17. package/dist/checks/coverage/index.d.ts +7 -0
  18. package/dist/checks/coverage/index.js +6 -0
  19. package/dist/checks/coverage/integrity.d.ts +79 -0
  20. package/dist/checks/coverage/integrity.js +140 -0
  21. package/dist/checks/coverage/lcov.d.ts +65 -0
  22. package/dist/checks/coverage/lcov.js +64 -0
  23. package/dist/checks/node.d.ts +19 -0
  24. package/dist/checks/node.js +40 -0
  25. package/dist/checks/ports.d.ts +67 -0
  26. package/dist/checks/ports.js +2 -0
  27. package/dist/checks/published-types/index.d.ts +77 -0
  28. package/dist/checks/published-types/index.js +186 -0
  29. package/dist/deploy/host-kit.d.ts +27 -10
  30. package/dist/deploy/index.d.ts +0 -4
  31. package/dist/deploy/index.js +0 -4
  32. package/dist/deploy/naming.d.ts +9 -6
  33. package/dist/deploy/naming.js +5 -7
  34. package/dist/deploy/node.d.ts +18 -0
  35. package/dist/deploy/node.js +57 -0
  36. package/dist/deploy/reachability.d.ts +47 -18
  37. package/dist/deploy/reachability.js +77 -71
  38. package/dist/deploy/redirect-guard.d.ts +15 -11
  39. package/dist/deploy/redirect-guard.js +11 -12
  40. package/dist/deploy/tokens.d.ts +17 -14
  41. package/dist/deploy/tokens.js +16 -16
  42. package/dist/deploy/tool.d.ts +12 -8
  43. package/dist/deploy/tool.js +9 -10
  44. package/dist/deploy/types.d.ts +27 -15
  45. package/dist/deploy/types.js +3 -3
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +2 -1
  48. package/dist/local-dev/index.d.ts +34 -0
  49. package/dist/local-dev/index.js +37 -0
  50. package/dist/packaging/electron/archive.d.ts +41 -0
  51. package/dist/packaging/electron/archive.js +77 -0
  52. package/dist/packaging/electron/asar-adapter.d.ts +13 -0
  53. package/dist/packaging/electron/asar-adapter.js +5 -0
  54. package/dist/packaging/electron/entry.d.ts +9 -0
  55. package/dist/packaging/electron/entry.js +9 -0
  56. package/dist/packaging/electron/imports.d.ts +13 -0
  57. package/dist/packaging/electron/imports.js +44 -0
  58. package/dist/packaging/electron/node.d.ts +8 -0
  59. package/dist/packaging/electron/node.js +51 -0
  60. package/dist/packaging/electron/policies.d.ts +64 -0
  61. package/dist/packaging/electron/policies.js +63 -0
  62. package/dist/packaging/electron/ports.d.ts +113 -0
  63. package/dist/packaging/electron/ports.js +2 -0
  64. package/dist/packaging/electron/stability.d.ts +9 -0
  65. package/dist/packaging/electron/stability.js +12 -0
  66. package/dist/packaging/electron/staging.d.ts +108 -0
  67. package/dist/packaging/electron/staging.js +249 -0
  68. package/dist/packaging/electron/typescript.d.ts +7 -0
  69. package/dist/packaging/electron/typescript.js +18 -0
  70. package/dist/source-control/commit.d.ts +11 -0
  71. package/dist/source-control/commit.js +71 -0
  72. package/dist/source-control/contracts.d.ts +327 -0
  73. package/dist/source-control/contracts.js +2 -0
  74. package/dist/source-control/entry.d.ts +6 -0
  75. package/dist/source-control/entry.js +6 -0
  76. package/dist/source-control/kit.d.ts +15 -0
  77. package/dist/source-control/kit.js +17 -0
  78. package/dist/source-control/registry.d.ts +100 -0
  79. package/dist/source-control/registry.js +174 -0
  80. package/dist/source-control/repository-target.d.ts +13 -0
  81. package/dist/source-control/repository-target.js +28 -0
  82. package/dist/static-export/contracts.d.ts +138 -0
  83. package/dist/static-export/contracts.js +5 -0
  84. package/dist/static-export/entry.d.ts +6 -0
  85. package/dist/static-export/entry.js +6 -0
  86. package/dist/static-export/failure-summary.d.ts +12 -0
  87. package/dist/static-export/failure-summary.js +12 -0
  88. package/dist/static-export/fetch-adapter.d.ts +6 -0
  89. package/dist/static-export/fetch-adapter.js +5 -0
  90. package/dist/static-export/node-adapters.d.ts +11 -0
  91. package/dist/static-export/node-adapters.js +111 -0
  92. package/dist/static-export/runner.d.ts +6 -0
  93. package/dist/static-export/runner.js +135 -0
  94. package/dist/static-export/transforms.d.ts +53 -0
  95. package/dist/static-export/transforms.js +154 -0
  96. package/package.json +82 -5
  97. package/dist/deploy/cloudflare-pages.d.ts +0 -105
  98. package/dist/deploy/cloudflare-pages.js +0 -943
  99. package/dist/deploy/github-pages.d.ts +0 -62
  100. package/dist/deploy/github-pages.js +0 -373
  101. package/dist/deploy/netlify.d.ts +0 -40
  102. package/dist/deploy/netlify.js +0 -299
  103. package/dist/deploy/vercel.d.ts +0 -56
  104. package/dist/deploy/vercel.js +0 -258
@@ -3,56 +3,56 @@ import { DeployError } from './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>
6
- * ('jini.deployTarget')`, `bindMany(DeployTarget, netlifyTarget)`). A host
6
+ * ('jini.deployTarget')`, `bindMany(DeployTarget, someTarget)`, paraphrased). A host
7
7
  * composition binds every deploy provider it wants available against this
8
8
  * one token:
9
9
  *
10
10
  * ```ts
11
- * bindings().bindMany(DeployTargetToken, new VercelDeployTarget(vercelConfig))
12
- * .bindMany(DeployTargetToken, new CloudflarePagesDeployTarget(cfConfig))
11
+ * bindings().bindMany(DeployTargetToken, hostTargetA)
12
+ * .bindMany(DeployTargetToken, hostTargetB)
13
13
  * ```
14
14
  *
15
15
  * A pack then resolves `c.getMany(DeployTargetToken)` to get every bound
16
16
  * target without this package (or `@jini-ai/core`) needing to know how many
17
17
  * providers exist or which ones a given host chose.
18
18
  */
19
- export const DeployTargetToken = manyToken('jini.deployTarget');
19
+ export const DeployTargetToken = manyToken({ id: 'jini.deployTarget' });
20
20
  /**
21
21
  * `deploy.publish` as a plain async function.
22
22
  *
23
- * This is deliberately **not** wired into a real tool-execution boundary
24
- * yet — `@jini-ai/core`'s `ToolRegistry`/`ToolExecutor` (extraction-plan.md §8
25
- * task 6, §2.5) doesn't exist yet. Once it does, the intended shape is:
23
+ * Tool wiring is implemented by `createDeployPublishToolRegistration` in
24
+ * `tool.ts`, using `@jini-ai/core`'s `ToolRegistry` and `@jini-ai/daemon`'s
25
+ * `ToolExecutor` (extraction-plan.md §8 task 6, §2.5). The registration shape is:
26
26
  *
27
27
  * ```ts
28
28
  * toolRegistry.register({
29
29
  * descriptor: { id: 'deploy.publish', ... },
30
- * handler: (principal, run, input, signal) => publishDeploy(input, targets),
30
+ * handler: (ctx) => publishDeploy({ ...ctx.input, targets }),
31
31
  * policy: { ... }, // e.g. requires confirmation before an external publish
32
32
  * });
33
33
  * ```
34
34
  *
35
35
  * so callers only ever reach it through `ToolExecutor.execute(principal,
36
36
  * run, 'deploy.publish', input, signal)` — never by holding a direct
37
- * reference to a handler. Until task 6 lands, this function is the whole
38
- * surface: a pack's app-service can call it directly.
37
+ * reference to a handler. This plain function remains available to trusted
38
+ * composition code; routes and agents use the registration so they cannot
39
+ * bypass authorization and the audit trail. The registration denies by default.
39
40
  *
40
- * @param input - Which bound target to publish through, plus the file set/project name/metadata.
41
- * @param targets - The full set of `DeployTarget`s a composition bound (typically `c.getMany(DeployTargetToken)`).
41
+ * @param requiredArgs - Target id, file set, project name and injected bound targets.
42
+ * @param options - Optional metadata and response headers forwarded to the selected target.
42
43
  * @returns The chosen target's publish result.
43
44
  * @throws {DeployError} (status 404) if no bound target matches `input.targetId`.
44
45
  * @complexity O(targets) to find the match, then whatever the target's own `publish` costs.
45
46
  * @overallScore 100/100
46
47
  */
47
- export async function publishDeploy(input, targets) {
48
+ export async function publishDeploy({ targets, ...input }, options = {}) {
48
49
  const target = targets.find((candidate) => candidate.id === input.targetId);
49
50
  if (!target) {
50
- throw new DeployError(`Unknown deploy target: ${input.targetId}`, 404, { errorCode: 'deploy_target_not_found' });
51
+ throw new DeployError({ message: `Unknown deploy target: ${input.targetId}` }, { status: 404, details: { errorCode: 'deploy_target_not_found' } });
51
52
  }
52
53
  return target.publish({
53
54
  files: input.files,
54
55
  projectName: input.projectName,
55
- ...(input.metadata !== undefined ? { metadata: input.metadata } : {}),
56
- });
56
+ }, options);
57
57
  }
58
58
  //# sourceMappingURL=tokens.js.map
@@ -7,7 +7,7 @@
7
7
  * and `packages/daemon/src/tool-executor.ts`). This file follows the same
8
8
  * `{descriptor, handler, policy}` shape `packages/daemon/src/
9
9
  * delegated-tool-bridge.ts` established for wiring an existing capability
10
- * into that boundary — see `source-map.md`'s "2026-07-21 addition" section
10
+ * into that boundary — see the archived extraction source map's "2026-07-21 addition" section
11
11
  * for the full design rationale, in particular why the default policy below
12
12
  * denies every call rather than allowing one.
13
13
  *
@@ -40,9 +40,9 @@ export declare const DEFAULT_DEPLOY_PUBLISH_ROLE = "deploy:publish";
40
40
  * Why deny-by-default specifically (not e.g. "allow same-principal-as-run"
41
41
  * or some other partial default): `deploy.publish` is the one tool in this
42
42
  * codebase that reaches real external infrastructure under the caller's own
43
- * cloud account — a successful call spends the operator's Vercel/Cloudflare
44
- * quota, publishes content to a public, internet-reachable URL, and (for
45
- * Cloudflare custom domains) can create real DNS records. Unlike most tool
43
+ * cloud account — a successful call spends the operator's hosting-provider
44
+ * quota, publishes content to a public, internet-reachable URL, and (for a
45
+ * target that manages custom domains) can create real DNS records. Unlike most tool
46
46
  * calls, a wrongly-allowed `deploy.publish` is not cheaply reversible and
47
47
  * has an externally visible blast radius. That is a strictly stronger case
48
48
  * for deny-by-default than `@jini-ai/media`'s `DEFAULT_MEDIA_EXECUTION_POLICY`
@@ -70,10 +70,14 @@ export declare const denyAllDeployPublishPolicy: ToolPolicy;
70
70
  * @complexity O(principal.roles) to check membership against `allowedRoles`.
71
71
  * @overallScore 100/100
72
72
  */
73
- export declare function createRoleGatedDeployPublishPolicy(allowedRoles?: readonly string[]): ToolPolicy;
74
- export interface CreateDeployPublishToolRegistrationOptions {
73
+ export declare function createRoleGatedDeployPublishPolicy(_requiredArgs: Record<string, never>, { allowedRoles }?: {
74
+ allowedRoles?: readonly string[];
75
+ }): ToolPolicy;
76
+ export interface CreateDeployPublishToolRegistrationArgs {
75
77
  /** Every bound `DeployTarget` the resulting tool call may dispatch to — typically `c.getMany(DeployTargetToken)`. */
76
78
  readonly targets: readonly DeployTarget[];
79
+ }
80
+ export interface CreateDeployPublishToolRegistrationOptions {
77
81
  /** Defaults to {@link denyAllDeployPublishPolicy} — see its doc comment for why a permissive default was rejected. */
78
82
  readonly policy?: ToolPolicy;
79
83
  /** Forwarded to `ToolDescriptor.requiresConfirmation` — an extra transport-level "are you sure" gate `ToolExecutor` applies after authorization. Omitted (not forced `true`) because this file already denies by default; a host layering its own confirmation UI on top opts in explicitly. */
@@ -94,11 +98,11 @@ export interface CreateDeployPublishToolRegistrationOptions {
94
98
  * `timeoutMs`/external cancellation still aborts the *call* from the
95
99
  * executor's perspective (the audit trail records `timed-out`/`cancelled`),
96
100
  * it just cannot interrupt an in-flight HTTP request inside a target's own
97
- * `publish` implementation — flagged as a follow-up in `source-map.md`
101
+ * `publish` implementation — flagged as a follow-up in the archived extraction source map
98
102
  * rather than silently assumed away.
99
103
  *
100
104
  * @complexity O(1) to build the registration; the handler's own cost is `publishDeploy`'s (O(targets) dispatch plus the matched target's `publish`).
101
105
  * @overallScore 100/100
102
106
  */
103
- export declare function createDeployPublishToolRegistration(options: CreateDeployPublishToolRegistrationOptions): ToolRegistration;
107
+ export declare function createDeployPublishToolRegistration({ targets }: CreateDeployPublishToolRegistrationArgs, { policy, requiresConfirmation, timeoutMs }?: CreateDeployPublishToolRegistrationOptions): ToolRegistration;
104
108
  //# sourceMappingURL=tool.d.ts.map
@@ -20,9 +20,9 @@ export const DEFAULT_DEPLOY_PUBLISH_ROLE = 'deploy:publish';
20
20
  * Why deny-by-default specifically (not e.g. "allow same-principal-as-run"
21
21
  * or some other partial default): `deploy.publish` is the one tool in this
22
22
  * codebase that reaches real external infrastructure under the caller's own
23
- * cloud account — a successful call spends the operator's Vercel/Cloudflare
24
- * quota, publishes content to a public, internet-reachable URL, and (for
25
- * Cloudflare custom domains) can create real DNS records. Unlike most tool
23
+ * cloud account — a successful call spends the operator's hosting-provider
24
+ * quota, publishes content to a public, internet-reachable URL, and (for a
25
+ * target that manages custom domains) can create real DNS records. Unlike most tool
26
26
  * calls, a wrongly-allowed `deploy.publish` is not cheaply reversible and
27
27
  * has an externally visible blast radius. That is a strictly stronger case
28
28
  * for deny-by-default than `@jini-ai/media`'s `DEFAULT_MEDIA_EXECUTION_POLICY`
@@ -52,7 +52,7 @@ export const denyAllDeployPublishPolicy = {
52
52
  * @complexity O(principal.roles) to check membership against `allowedRoles`.
53
53
  * @overallScore 100/100
54
54
  */
55
- export function createRoleGatedDeployPublishPolicy(allowedRoles = [DEFAULT_DEPLOY_PUBLISH_ROLE]) {
55
+ export function createRoleGatedDeployPublishPolicy(_requiredArgs, { allowedRoles = [DEFAULT_DEPLOY_PUBLISH_ROLE] } = {}) {
56
56
  return {
57
57
  authorize(ctx) {
58
58
  const roles = ctx.principal.roles;
@@ -75,18 +75,17 @@ export function createRoleGatedDeployPublishPolicy(allowedRoles = [DEFAULT_DEPLO
75
75
  * `timeoutMs`/external cancellation still aborts the *call* from the
76
76
  * executor's perspective (the audit trail records `timed-out`/`cancelled`),
77
77
  * it just cannot interrupt an in-flight HTTP request inside a target's own
78
- * `publish` implementation — flagged as a follow-up in `source-map.md`
78
+ * `publish` implementation — flagged as a follow-up in the archived extraction source map
79
79
  * rather than silently assumed away.
80
80
  *
81
81
  * @complexity O(1) to build the registration; the handler's own cost is `publishDeploy`'s (O(targets) dispatch plus the matched target's `publish`).
82
82
  * @overallScore 100/100
83
83
  */
84
- export function createDeployPublishToolRegistration(options) {
85
- const { targets, policy = denyAllDeployPublishPolicy, requiresConfirmation, timeoutMs } = options;
84
+ export function createDeployPublishToolRegistration({ targets }, { policy = denyAllDeployPublishPolicy, requiresConfirmation, timeoutMs } = {}) {
86
85
  return {
87
86
  descriptor: {
88
87
  id: DEPLOY_PUBLISH_TOOL_ID,
89
- description: 'Publishes a file set to a bound deploy target (e.g. Vercel, Cloudflare Pages, Netlify, GitHub Pages).',
88
+ description: 'Publishes a file set to a bound deploy target (a hosting provider the host registered).',
90
89
  ...(requiresConfirmation !== undefined ? { requiresConfirmation } : {}),
91
90
  ...(timeoutMs !== undefined ? { timeoutMs } : {}),
92
91
  },
@@ -100,8 +99,8 @@ export function createDeployPublishToolRegistration(options) {
100
99
  // is introduced here; `publishDeploy`/the matched `DeployTarget`
101
100
  // already reject a malformed `targetId`/`files`/`projectName` on
102
101
  // their own terms (e.g. `DeployError` for an unknown target).
103
- const input = ctx.input;
104
- return publishDeploy(input, targets);
102
+ const { metadata, ...input } = ctx.input;
103
+ return publishDeploy({ ...input, targets }, metadata === undefined ? {} : { metadata });
105
104
  },
106
105
  };
107
106
  }
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Provider-agnostic shapes for publishing a static file set to a hosting
3
- * target (Vercel, Cloudflare Pages, and future adapters). None of these
3
+ * target (any host-supplied adapter). None of these
4
4
  * types know what a "project" is — the caller (a pack, a tool handler, a
5
5
  * CLI command) resolves its own file set and hands over plain
6
- * `DeployFile[]`. See `packages/devops/source-map.md` for what was dropped
6
+ * `DeployFile[]`. See the archived extraction source map for what was dropped
7
7
  * from the OD origin file to get here.
8
8
  */
9
- /** Generic JSON-shaped object; mirrors the loose bag used by provider APIs. */
10
- export type JsonObject = Record<string, unknown>;
9
+ /** Loose provider option bag; values need not be JSON-serializable. */
10
+ export type UnknownRecord = Record<string, unknown>;
11
11
  /**
12
12
  * One file to publish, keyed by its deploy-relative path.
13
13
  *
@@ -25,7 +25,7 @@ export interface DeployFile {
25
25
  * Coarse status of a deployment's public URL. `link-delayed` means the
26
26
  * provider accepted the deploy but the URL is not yet reachable (DNS/CDN
27
27
  * propagation); `protected` means the provider is gating the URL behind
28
- * its own auth wall (e.g. Vercel Deployment Protection).
28
+ * its own auth wall (e.g. a deployment-protection login page).
29
29
  */
30
30
  export type DeployLinkStatus = 'ready' | 'protected' | 'failed' | 'link-delayed';
31
31
  /** Result of probing a deployment URL over HTTP. */
@@ -38,8 +38,9 @@ export interface DeploymentUrlCheck {
38
38
  /**
39
39
  * Input to `DeployTarget.publish`. Deliberately narrow: a file set plus a
40
40
  * human/DNS-safe label the target may use to derive a provider-side
41
- * project/deployment name. `metadata` is an escape hatch for target-specific
42
- * options (e.g. Cloudflare custom-domain selection) that do not belong in
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
43
44
  * the shared shape — each target documents the metadata keys it reads and
44
45
  * ignores everything else.
45
46
  *
@@ -51,7 +52,10 @@ export interface DeploymentUrlCheck {
51
52
  export interface DeployPublishInput {
52
53
  files: DeployFile[];
53
54
  projectName: string;
54
- metadata?: JsonObject;
55
+ }
56
+ /** Optional publish settings, passed separately from the file set and project name. */
57
+ export interface DeployPublishOptions {
58
+ metadata?: UnknownRecord;
55
59
  responseHeaders?: ResponseHeaderSet;
56
60
  }
57
61
  /** HTTP response headers by name, as a caller asks a target to serve them. */
@@ -64,21 +68,23 @@ export interface DeployPublishResult {
64
68
  status: DeployLinkStatus;
65
69
  statusMessage?: string;
66
70
  reachableAt?: number;
67
- /** Target-specific extras (e.g. Cloudflare custom-domain/DNS outcome). */
68
- providerMetadata?: JsonObject;
71
+ /** Target-specific extras (e.g. a custom-domain/DNS outcome). */
72
+ providerMetadata?: UnknownRecord;
69
73
  }
70
74
  /**
71
75
  * The port every deploy provider implements. Bound many-to-one against the
72
76
  * `DeployTarget` many-token in `tokens.ts` (`bindMany(DeployTargetToken, ...)`)
73
- * so Vercel, Cloudflare Pages, and later targets can all register against
77
+ * so any number of hosting targets can register against
74
78
  * the same capability without a central union type.
75
79
  */
76
80
  export interface DeployTarget {
77
81
  readonly id: string;
78
- publish(input: DeployPublishInput): Promise<DeployPublishResult>;
79
- checkReachability(url: string): Promise<DeploymentUrlCheck>;
82
+ publish(requiredArgs: DeployPublishInput, optionalArgs?: DeployPublishOptions): Promise<DeployPublishResult>;
83
+ checkReachability(requiredArgs: {
84
+ url: string;
85
+ }): Promise<DeploymentUrlCheck>;
80
86
  }
81
- export type DeployErrorDetails = JsonObject | string | undefined;
87
+ export type DeployErrorDetails = UnknownRecord | string | undefined;
82
88
  /**
83
89
  * Thrown by target implementations for both caller-input problems (bad
84
90
  * config, missing token) and upstream provider failures (HTTP error,
@@ -89,6 +95,12 @@ export declare class DeployError extends Error {
89
95
  status: number;
90
96
  details: DeployErrorDetails;
91
97
  code?: string | undefined;
92
- constructor(message: string, status?: number, details?: DeployErrorDetails, code?: string);
98
+ constructor({ message }: {
99
+ message: string;
100
+ }, { status, details, code, }?: {
101
+ status?: number;
102
+ details?: DeployErrorDetails;
103
+ code?: string;
104
+ });
93
105
  }
94
106
  //# sourceMappingURL=types.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Provider-agnostic shapes for publishing a static file set to a hosting
3
- * target (Vercel, Cloudflare Pages, and future adapters). None of these
3
+ * target (any host-supplied adapter). None of these
4
4
  * types know what a "project" is — the caller (a pack, a tool handler, a
5
5
  * CLI command) resolves its own file set and hands over plain
6
- * `DeployFile[]`. See `packages/devops/source-map.md` for what was dropped
6
+ * `DeployFile[]`. See the archived extraction source map for what was dropped
7
7
  * from the OD origin file to get here.
8
8
  */
9
9
  /**
@@ -16,7 +16,7 @@ export class DeployError extends Error {
16
16
  status;
17
17
  details;
18
18
  code;
19
- constructor(message, status = 400, details = undefined, code) {
19
+ constructor({ message }, { status = 400, details, code, } = {}) {
20
20
  super(message);
21
21
  this.name = 'DeployError';
22
22
  this.status = status;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * DevOps domain marker. Import a concrete capability from an explicit
3
3
  * subpath, such as `@jini-ai/devops/deploy`.
4
4
  *
5
- * Planned sibling capabilities: `./source-control` and `./ci-cd`.
5
+ * Source control, static export, packaging, agent jobs and checks have explicit
6
+ * subpaths. `./ci-cd` remains planned.
6
7
  */
7
8
  export {};
8
9
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2,7 +2,8 @@
2
2
  * DevOps domain marker. Import a concrete capability from an explicit
3
3
  * subpath, such as `@jini-ai/devops/deploy`.
4
4
  *
5
- * Planned sibling capabilities: `./source-control` and `./ci-cd`.
5
+ * Source control, static export, packaging, agent jobs and checks have explicit
6
+ * subpaths. `./ci-cd` remains planned.
6
7
  */
7
8
  export {};
8
9
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,34 @@
1
+ import type { ProcessRequest, ProcessRunnerPort } from '../checks/ports.js';
2
+ export interface EnvLoaderPort {
3
+ load(args: {
4
+ path: string;
5
+ }): void;
6
+ }
7
+ export interface EnvironmentFilesystemPort {
8
+ exists(args: {
9
+ path: string;
10
+ }): boolean;
11
+ }
12
+ export interface PortListener {
13
+ pid: string;
14
+ command: string;
15
+ }
16
+ /** Load the required environment-file path, if present. Loader errors propagate to the caller. */
17
+ export declare function loadRepoRootEnvFile({ environmentFile, fs, loader }: {
18
+ environmentFile: string;
19
+ fs: EnvironmentFilesystemPort;
20
+ loader: EnvLoaderPort;
21
+ }): boolean;
22
+ /** Parse lsof's field format, dropping incomplete records. Does not spawn a process. */
23
+ export declare function parseLsofListeners({ stdout }: {
24
+ stdout: string;
25
+ }): PortListener[];
26
+ /** Best-effort TCP-listener lookup. The host supplies the platform's listener executable/args. */
27
+ export declare function listenersOn({ port, runner, listenerCommand }: {
28
+ port: number;
29
+ runner: ProcessRunnerPort;
30
+ listenerCommand: (args: {
31
+ port: number;
32
+ }) => ProcessRequest;
33
+ }): Promise<PortListener[]>;
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,37 @@
1
+ /** Load the required environment-file path, if present. Loader errors propagate to the caller. */
2
+ export function loadRepoRootEnvFile({ environmentFile, fs, loader }) {
3
+ if (!fs.exists({ path: environmentFile }))
4
+ return false;
5
+ loader.load({ path: environmentFile });
6
+ return true;
7
+ }
8
+ /** Parse lsof's field format, dropping incomplete records. Does not spawn a process. */
9
+ export function parseLsofListeners({ stdout }) {
10
+ const found = [];
11
+ let pid;
12
+ for (const line of stdout.replace(/\r\n/g, '\n').split('\n')) {
13
+ if (line.startsWith('p'))
14
+ pid = line.slice(1);
15
+ else if (line.startsWith('c') && pid) {
16
+ found.push({ pid, command: line.slice(1) });
17
+ pid = undefined;
18
+ }
19
+ }
20
+ return found;
21
+ }
22
+ /** Best-effort TCP-listener lookup. The host supplies the platform's listener executable/args. */
23
+ export async function listenersOn({ port, runner, listenerCommand }) {
24
+ if (!Number.isInteger(port) || port < 1 || port > 65535)
25
+ throw new RangeError('port must be an integer from 1 to 65535');
26
+ const request = listenerCommand({ port });
27
+ try {
28
+ const output = await runner.run(request);
29
+ if (output.exitCode !== 0 || !output.stdout)
30
+ return [];
31
+ return parseLsofListeners({ stdout: output.stdout });
32
+ }
33
+ catch {
34
+ return [];
35
+ }
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,41 @@
1
+ import type { AsarHeaderNode, ArchiveReaderPort, PackagingFilesystemPort } from './ports.js';
2
+ export interface AsarMismatch {
3
+ relPath: string;
4
+ reason: string;
5
+ }
6
+ export interface AsarVerification {
7
+ checkedCount: number;
8
+ mismatches: AsarMismatch[];
9
+ }
10
+ /** Enumerate files only; symlinks carry no content. Missing prefixes are checked by verification. */
11
+ export declare function filesUnderPrefixes({ headerFiles, prefixes }: {
12
+ headerFiles: Record<string, AsarHeaderNode> | undefined;
13
+ prefixes: readonly string[];
14
+ }): string[];
15
+ /** The reader's separator is host supplied, keeping archive enumeration in POSIX form. */
16
+ export declare function toArchiveEntryPath({ relPath, separator }: {
17
+ relPath: string;
18
+ separator: string;
19
+ }): string;
20
+ /** Compare actual content: equal sizes and an archive's own hash cannot detect shifted offsets. */
21
+ export declare function verifyAsarAgainstSource(required: {
22
+ archivePath: string;
23
+ sourceRoot: string;
24
+ prefixes: readonly string[];
25
+ separator: string;
26
+ fs: PackagingFilesystemPort;
27
+ archive: ArchiveReaderPort;
28
+ }): AsarVerification;
29
+ export declare function isEmptyVerification({ checkedCount }: {
30
+ checkedCount: number;
31
+ }): boolean;
32
+ export declare function formatMismatchReport({ mismatches }: {
33
+ mismatches: readonly AsarMismatch[];
34
+ }): string;
35
+ /** Resources inventory is caller supplied; an empty inventory is a failure. */
36
+ export declare function bundledNpmFailures(required: {
37
+ resourcesDirs: readonly string[];
38
+ requiredFiles: readonly string[];
39
+ fs: PackagingFilesystemPort;
40
+ }): string[];
41
+ //# sourceMappingURL=archive.d.ts.map
@@ -0,0 +1,77 @@
1
+ import path from 'node:path';
2
+ function safeEntry(value) {
3
+ if (!value || value.includes('\\') || value.includes('\0') || value.split('/').some(segment => !segment || segment === '.' || segment === '..'))
4
+ throw new Error(`Unsafe archive entry: ${value}`);
5
+ }
6
+ /** Enumerate files only; symlinks carry no content. Missing prefixes are checked by verification. */
7
+ export function filesUnderPrefixes({ headerFiles, prefixes }) {
8
+ const paths = new Set();
9
+ function walk(node, current) {
10
+ safeEntry(current);
11
+ if ('link' in node)
12
+ return;
13
+ if (node.files)
14
+ for (const [name, child] of Object.entries(node.files))
15
+ walk(child, current + '/' + name);
16
+ else
17
+ paths.add(current);
18
+ }
19
+ for (const prefix of prefixes) {
20
+ safeEntry(prefix);
21
+ let node = { files: headerFiles ?? {} };
22
+ for (const segment of prefix.split('/'))
23
+ node = node?.files?.[segment];
24
+ if (node)
25
+ walk(node, prefix);
26
+ }
27
+ return [...paths];
28
+ }
29
+ /** The reader's separator is host supplied, keeping archive enumeration in POSIX form. */
30
+ export function toArchiveEntryPath({ relPath, separator }) {
31
+ safeEntry(relPath);
32
+ return relPath.split('/').join(separator);
33
+ }
34
+ /** Compare actual content: equal sizes and an archive's own hash cannot detect shifted offsets. */
35
+ export function verifyAsarAgainstSource(required) {
36
+ const { archivePath, sourceRoot, prefixes, separator, fs, archive } = required;
37
+ if (!prefixes.length)
38
+ return { checkedCount: 0, mismatches: [{ relPath: '', reason: 'no checked archive prefixes supplied' }] };
39
+ const { files: headerFiles } = archive.header({ archivePath });
40
+ const relPaths = filesUnderPrefixes({ headerFiles, prefixes });
41
+ const mismatches = prefixes.filter(prefix => !filesUnderPrefixes({ headerFiles, prefixes: [prefix] }).length)
42
+ .map(relPath => ({ relPath, reason: 'nothing under this checked prefix is in app.asar' }));
43
+ for (const relPath of relPaths) {
44
+ let source;
45
+ try {
46
+ source = fs.read({ path: path.join(sourceRoot, relPath) });
47
+ }
48
+ catch {
49
+ mismatches.push({ relPath, reason: 'shipped in app.asar but missing from the source tree' });
50
+ continue;
51
+ }
52
+ let shipped;
53
+ try {
54
+ shipped = archive.read({ archivePath, entryPath: toArchiveEntryPath({ relPath, separator }) });
55
+ }
56
+ catch (error) {
57
+ mismatches.push({ relPath, reason: `present in the asar header but could not read it (${String(error)})` });
58
+ continue;
59
+ }
60
+ if (source.length !== shipped.length || !source.every((byte, index) => byte === shipped[index]))
61
+ mismatches.push({ relPath, reason: 'content differs from source (compared byte-for-byte, never by length alone)' });
62
+ }
63
+ return { checkedCount: relPaths.length, mismatches };
64
+ }
65
+ export function isEmptyVerification({ checkedCount }) { return checkedCount === 0; }
66
+ export function formatMismatchReport({ mismatches }) {
67
+ return [`${mismatches.length} file(s) in app.asar do NOT match source, byte-for-byte:`, ...mismatches.map(item => ` MISMATCH ${item.relPath} — ${item.reason}`), 'Equal sizes can hide a packaging race that shifts archive offsets.'].join('\n');
68
+ }
69
+ /** Resources inventory is caller supplied; an empty inventory is a failure. */
70
+ export function bundledNpmFailures(required) {
71
+ if (!required.resourcesDirs.length)
72
+ return ['no packaged resources directory was found to check for the bundled npm'];
73
+ if (!required.requiredFiles.length)
74
+ return ['no bundled npm files were specified to check'];
75
+ return required.resourcesDirs.flatMap(dir => required.requiredFiles.map(relative => { safeEntry(relative); return path.join(dir, relative); }).filter(file => !required.fs.exists({ path: file })));
76
+ }
77
+ //# sourceMappingURL=archive.js.map
@@ -0,0 +1,13 @@
1
+ import type { ArchiveReaderPort, AsarHeaderNode } from './ports.js';
2
+ /** Bind @electron/asar in the host rather than depending on the packaging SDK in core. */
3
+ export declare function createAsarArchiveReader({ asar }: {
4
+ asar: {
5
+ getRawHeader(archivePath: string): {
6
+ header: {
7
+ files?: Record<string, AsarHeaderNode>;
8
+ };
9
+ };
10
+ extractFile(archivePath: string, entryPath: string): Uint8Array;
11
+ };
12
+ }): ArchiveReaderPort;
13
+ //# sourceMappingURL=asar-adapter.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Bind @electron/asar in the host rather than depending on the packaging SDK in core. */
2
+ export function createAsarArchiveReader({ asar }) {
3
+ return { header: ({ archivePath }) => asar.getRawHeader(archivePath).header, read: ({ archivePath, entryPath }) => asar.extractFile(archivePath, entryPath) };
4
+ }
5
+ //# sourceMappingURL=asar-adapter.js.map
@@ -0,0 +1,9 @@
1
+ export * from './ports.js';
2
+ export * from './policies.js';
3
+ export * from './archive.js';
4
+ export * from './staging.js';
5
+ export * from './imports.js';
6
+ export * from './stability.js';
7
+ export * from './node.js';
8
+ export * from './asar-adapter.js';
9
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1,9 @@
1
+ export * from './ports.js';
2
+ export * from './policies.js';
3
+ export * from './archive.js';
4
+ export * from './staging.js';
5
+ export * from './imports.js';
6
+ export * from './stability.js';
7
+ export * from './node.js';
8
+ export * from './asar-adapter.js';
9
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1,13 @@
1
+ import type { PackagingFilesystemPort, ImportReaderPort, ImportAliasPort } from './ports.js';
2
+ export interface DistImportInput {
3
+ distDir: string;
4
+ entry: string;
5
+ declared: ReadonlySet<string>;
6
+ fs: PackagingFilesystemPort;
7
+ imports: ImportReaderPort;
8
+ aliases: ImportAliasPort;
9
+ }
10
+ /** Walk reachable files once. The injected AST parser owns import syntax and comment handling. */
11
+ export declare function undeclaredDistImports(required: DistImportInput): string[];
12
+ export declare function assertDistImportsDeclared(required: DistImportInput): void;
13
+ //# sourceMappingURL=imports.d.ts.map
@@ -0,0 +1,44 @@
1
+ import path from 'node:path';
2
+ import { builtinModules } from 'node:module';
3
+ const builtins = new Set(builtinModules);
4
+ /** Walk reachable files once. The injected AST parser owns import syntax and comment handling. */
5
+ export function undeclaredDistImports(required) {
6
+ const { distDir, entry, declared, fs, imports, aliases } = required;
7
+ const queue = [path.resolve(entry)];
8
+ const seen = new Set(queue);
9
+ const problems = [];
10
+ for (let index = 0; index < queue.length; index++) {
11
+ const file = queue[index];
12
+ if (!fs.exists({ path: file })) {
13
+ problems.push(`${path.relative(distDir, file)} (entry file not found)`);
14
+ continue;
15
+ }
16
+ const source = Buffer.from(fs.read({ path: file })).toString('utf8');
17
+ for (const specifier of imports.imports({ file, source })) {
18
+ const alias = aliases.resolve({ specifier, fromFile: file, distDir });
19
+ const target = alias ?? (specifier.startsWith('.') || path.isAbsolute(specifier) ? path.resolve(path.dirname(file), specifier) : undefined);
20
+ const relative = path.relative(distDir, file);
21
+ if (target !== undefined) {
22
+ const absolute = path.resolve(target);
23
+ if (seen.has(absolute))
24
+ continue;
25
+ seen.add(absolute);
26
+ if (fs.exists({ path: absolute }))
27
+ queue.push(absolute);
28
+ else
29
+ problems.push(`${specifier} (${relative}: file not found)`);
30
+ continue;
31
+ }
32
+ const name = specifier.split('/').slice(0, specifier.startsWith('@') ? 2 : 1).join('/');
33
+ if (!specifier.startsWith('node:') && !builtins.has(name) && !declared.has(name))
34
+ problems.push(`${name} (${relative})`);
35
+ }
36
+ }
37
+ return problems;
38
+ }
39
+ export function assertDistImportsDeclared(required) {
40
+ const problems = undeclaredDistImports(required);
41
+ if (problems.length)
42
+ throw new Error(`built entry imports ${problems.length} undeclared packages or missing files:\n ${problems.join('\n ')}`);
43
+ }
44
+ //# sourceMappingURL=imports.js.map
@@ -0,0 +1,8 @@
1
+ import type { PackagingFilesystemPort, PackageResolverPort } from './ports.js';
2
+ /** Explicit Node filesystem adapter. No effects occur until a port method is called. */
3
+ export declare function createNodePackagingFilesystem(_required: Record<string, never>): PackagingFilesystemPort;
4
+ /** Node's upward node_modules walk resolves pnpm links to real package roots. */
5
+ export declare function createNodePackageResolver({ fs }: {
6
+ fs: PackagingFilesystemPort;
7
+ }): PackageResolverPort;
8
+ //# sourceMappingURL=node.d.ts.map