@jini-ai/devops 0.7.1 → 0.7.3-next.1

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 (108) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +8 -4
  3. package/dist/agent-jobs/jobs.d.ts +1 -1
  4. package/dist/agent-jobs/jobs.js +4 -3
  5. package/dist/agent-jobs/node.d.ts +2 -2
  6. package/dist/agent-jobs/node.js +2 -2
  7. package/dist/backup/plan-store.node.d.ts +73 -0
  8. package/dist/backup/plan-store.node.js +60 -0
  9. package/dist/backup/push-jobs.d.ts +88 -0
  10. package/dist/backup/push-jobs.js +95 -0
  11. package/dist/backup/upload.node.d.ts +71 -0
  12. package/dist/backup/upload.node.js +122 -0
  13. package/dist/checks/coverage/diff.d.ts +2 -2
  14. package/dist/checks/coverage/diff.js +2 -2
  15. package/dist/checks/coverage/disk.d.ts +5 -5
  16. package/dist/checks/coverage/disk.js +5 -5
  17. package/dist/checks/coverage/floors.d.ts +2 -2
  18. package/dist/checks/coverage/floors.js +2 -2
  19. package/dist/checks/coverage/integrity.d.ts +10 -5
  20. package/dist/checks/coverage/integrity.js +12 -5
  21. package/dist/checks/coverage/lcov.d.ts +8 -8
  22. package/dist/checks/coverage/lcov.js +8 -8
  23. package/dist/checks/env-access.d.ts +37 -0
  24. package/dist/checks/env-access.js +57 -0
  25. package/dist/checks/hardwiring-node.d.ts +6 -3
  26. package/dist/checks/hardwiring-node.js +7 -6
  27. package/dist/checks/hardwiring.d.ts +32 -8
  28. package/dist/checks/hardwiring.js +395 -338
  29. package/dist/checks/node.d.ts +2 -2
  30. package/dist/checks/node.js +2 -2
  31. package/dist/checks/published-types/index.d.ts +10 -4
  32. package/dist/checks/published-types/index.js +30 -9
  33. package/dist/core/redirect-guard.d.ts +2 -2
  34. package/dist/core/redirect-guard.js +2 -2
  35. package/dist/deploy/adapters/undici.d.ts +8 -0
  36. package/dist/deploy/adapters/undici.js +6 -0
  37. package/dist/deploy/config-injection.d.ts +43 -0
  38. package/dist/deploy/config-injection.js +60 -0
  39. package/dist/deploy/index.d.ts +1 -0
  40. package/dist/deploy/index.js +1 -0
  41. package/dist/deploy/naming.d.ts +2 -2
  42. package/dist/deploy/naming.js +2 -2
  43. package/dist/deploy/node.d.ts +17 -6
  44. package/dist/deploy/node.js +8 -9
  45. package/dist/deploy/ops-runner.d.ts +8 -6
  46. package/dist/deploy/ops-runner.js +7 -6
  47. package/dist/deploy/ops-tool-contracts.d.ts +2 -1
  48. package/dist/deploy/ops-tools.js +1 -1
  49. package/dist/deploy/reachability.d.ts +1 -1
  50. package/dist/deploy/reachability.js +1 -1
  51. package/dist/deploy/react/PublishRunResult.d.ts +24 -0
  52. package/dist/deploy/react/PublishRunResult.js +25 -0
  53. package/dist/deploy/react/index.d.ts +3 -0
  54. package/dist/deploy/react/index.js +2 -0
  55. package/dist/deploy/tool.d.ts +1 -1
  56. package/dist/deploy/tool.js +1 -1
  57. package/dist/dns/delegation.d.ts +2 -2
  58. package/dist/dns/delegation.js +5 -5
  59. package/dist/dns/node/resolver.js +30 -29
  60. package/dist/dns/verify.d.ts +1 -2
  61. package/dist/dns/verify.js +3 -3
  62. package/dist/local-dev/free-port.d.ts +25 -0
  63. package/dist/local-dev/free-port.js +44 -0
  64. package/dist/local-dev/index.d.ts +4 -3
  65. package/dist/local-dev/index.js +4 -3
  66. package/dist/local-dev/node-runtime.d.ts +2 -2
  67. package/dist/local-dev/node-runtime.js +1 -1
  68. package/dist/packaging/electron/archive.d.ts +5 -5
  69. package/dist/packaging/electron/archive.js +5 -5
  70. package/dist/packaging/electron/asar-adapter.d.ts +1 -1
  71. package/dist/packaging/electron/asar-adapter.js +1 -1
  72. package/dist/packaging/electron/entry.d.ts +4 -0
  73. package/dist/packaging/electron/entry.js +4 -0
  74. package/dist/packaging/electron/imports.d.ts +2 -2
  75. package/dist/packaging/electron/imports.js +2 -2
  76. package/dist/packaging/electron/isolation.d.ts +36 -0
  77. package/dist/packaging/electron/isolation.js +64 -0
  78. package/dist/packaging/electron/node.d.ts +2 -2
  79. package/dist/packaging/electron/node.js +2 -2
  80. package/dist/packaging/electron/payload-scan.d.ts +17 -0
  81. package/dist/packaging/electron/payload-scan.js +20 -0
  82. package/dist/packaging/electron/policies.d.ts +6 -6
  83. package/dist/packaging/electron/policies.js +6 -6
  84. package/dist/packaging/electron/stability.d.ts +1 -1
  85. package/dist/packaging/electron/stability.js +1 -1
  86. package/dist/packaging/electron/staging.d.ts +11 -11
  87. package/dist/packaging/electron/staging.js +11 -11
  88. package/dist/packaging/electron/tree-fingerprint.d.ts +31 -0
  89. package/dist/packaging/electron/tree-fingerprint.js +59 -0
  90. package/dist/packaging/electron/typescript.d.ts +8 -2
  91. package/dist/packaging/electron/typescript.js +108 -99
  92. package/dist/packaging/electron/update-manifest-merge.d.ts +53 -0
  93. package/dist/packaging/electron/update-manifest-merge.js +82 -0
  94. package/dist/source-control/commit.d.ts +19 -3
  95. package/dist/source-control/commit.js +99 -16
  96. package/dist/source-control/contracts.d.ts +20 -1
  97. package/dist/source-control/kit.d.ts +1 -1
  98. package/dist/source-control/kit.js +1 -1
  99. package/dist/source-control/registry.d.ts +2 -2
  100. package/dist/source-control/registry.js +2 -2
  101. package/dist/static-export/css-urls.d.ts +3 -1
  102. package/dist/static-export/css-urls.js +1 -1
  103. package/dist/static-export/fetch-adapter.d.ts +1 -1
  104. package/dist/static-export/fetch-adapter.js +1 -1
  105. package/dist/static-export/html-url-locations.js +1 -1
  106. package/dist/static-export/transforms.d.ts +4 -4
  107. package/dist/static-export/transforms.js +6 -6
  108. package/package.json +48 -14
@@ -4,9 +4,9 @@ export { createHardwiringInspector, diffHardwiringDebt, HARDWIRING_RULES } from
4
4
  export { sourceFiles, createResolver, displayGraphFile, installedPublicFunctions, runHardwiring } from './hardwiring-node.js';
5
5
  export type { HardwiringSource, HardwiringViolation } from './hardwiring.js';
6
6
  /** Explicit Node filesystem adapter. Temporary parents must already exist. */
7
- export declare function createNodeFilesystem(_args: Record<string, never>): FilesystemPort;
7
+ export declare function createNodeFilesystem(_args: Record<string, never>, _optional?: Record<string, never>): FilesystemPort;
8
8
  /** Uses Node's environment precedence: exported variables win over file values. Requires Node 20.12+. */
9
- export declare function createNodeEnvLoader(_args: Record<string, never>): EnvLoaderPort;
9
+ export declare function createNodeEnvLoader(_args: Record<string, never>, _optional?: Record<string, never>): EnvLoaderPort;
10
10
  export declare function createNodeProcessRunner(_args: Record<string, never>, { maxBuffer, timeoutMs }?: {
11
11
  maxBuffer?: number;
12
12
  timeoutMs?: number;
@@ -5,7 +5,7 @@ import path from 'node:path';
5
5
  export { createHardwiringInspector, diffHardwiringDebt, HARDWIRING_RULES } from './hardwiring.js';
6
6
  export { sourceFiles, createResolver, displayGraphFile, installedPublicFunctions, runHardwiring } from './hardwiring-node.js';
7
7
  /** Explicit Node filesystem adapter. Temporary parents must already exist. */
8
- export function createNodeFilesystem(_args) {
8
+ export function createNodeFilesystem(_args, _optional = {}) {
9
9
  return {
10
10
  exists: ({ path: file }) => existsSync(file),
11
11
  isSymbolicLink: ({ path: file }) => lstatSync(file).isSymbolicLink(),
@@ -25,7 +25,7 @@ export function createNodeFilesystem(_args) {
25
25
  };
26
26
  }
27
27
  /** Uses Node's environment precedence: exported variables win over file values. Requires Node 20.12+. */
28
- export function createNodeEnvLoader(_args) {
28
+ export function createNodeEnvLoader(_args, _optional = {}) {
29
29
  return { load: ({ path: file }) => { process.loadEnvFile(file); } };
30
30
  }
31
31
  /** Shell-free runner; captures compiler output and reports signals/spawn failures as null exits. */
@@ -3,6 +3,8 @@ export type { CheckLoggerPort, FilesystemPort, PackageInstallerPort, ProcessRequ
3
3
  export interface DependencyManifest {
4
4
  dependencies?: Record<string, string>;
5
5
  devDependencies?: Record<string, string>;
6
+ optionalDependencies?: Record<string, string>;
7
+ peerDependencies?: Record<string, string>;
6
8
  overrides?: Record<string, unknown>;
7
9
  }
8
10
  interface ProjectBase {
@@ -42,11 +44,11 @@ export interface PublishedTypesReport {
42
44
  export declare function registryDependencies({ manifest, scope }: {
43
45
  manifest: DependencyManifest;
44
46
  scope: string;
45
- }): Record<string, string>;
47
+ }, _optional?: Record<string, never>): Record<string, string>;
46
48
  /** Split compiler output into whole diagnostics; wrapped details stay attached to their first line. */
47
49
  export declare function parseDiagnosticBlocks({ output }: {
48
50
  output: string;
49
- }): string[];
51
+ }, _optional?: Record<string, never>): string[];
50
52
  /**
51
53
  * Check projects sequentially so overlapping source trees cannot see each other's shadows.
52
54
  * Ports never exit the host process. Operational failures remain failures, including cleanup errors.
@@ -57,8 +59,12 @@ export declare function check({ projects, scope, fs, runner, installer }: {
57
59
  fs: FilesystemPort;
58
60
  runner: ProcessRunnerPort;
59
61
  installer: PackageInstallerPort;
60
- }, { logger }?: {
62
+ }, { logger, pins, keepScratch }?: {
61
63
  logger?: CheckLoggerPort;
64
+ /** Registry specs that add to or replace the manifest's scoped dependencies for compile projects (e.g. to prove the gate fails on a known-bad version). */
65
+ pins?: Readonly<Record<string, string>>;
66
+ /** Leave each scratch install on disk for inspection instead of removing it. */
67
+ keepScratch?: boolean;
62
68
  }): Promise<PublishedTypesReport>;
63
69
  export interface TypecheckLog extends ProcessResult {
64
70
  projectKey: string;
@@ -73,5 +79,5 @@ export interface TypecheckDiagnosis {
73
79
  export declare function diagnosePublishedTypes({ scope, logs }: {
74
80
  scope: string;
75
81
  logs: readonly TypecheckLog[];
76
- }): TypecheckDiagnosis;
82
+ }, _optional?: Record<string, never>): TypecheckDiagnosis;
77
83
  //# sourceMappingURL=index.d.ts.map
@@ -3,11 +3,18 @@ function validateScope(scope) {
3
3
  if (!/^@[a-z0-9][a-z0-9._-]*$/.test(scope))
4
4
  throw new TypeError('scope must be an npm scope such as @example');
5
5
  }
6
+ /** Pins must name packages inside the checked scope; anything else is a caller error, not a project failure. */
7
+ function validatePins({ pins, scope }) {
8
+ const name = new RegExp(`^${escapeRegex(scope)}/[a-z0-9][a-z0-9._-]*$`);
9
+ for (const pinned of Object.keys(pins))
10
+ if (!name.test(pinned))
11
+ throw new TypeError(`pin outside scope ${scope}: ${pinned}`);
12
+ }
6
13
  /** Select registry-resolved dependencies from the required scope; explicit local specs are exempt. */
7
- export function registryDependencies({ manifest, scope }) {
14
+ export function registryDependencies({ manifest, scope }, _optional = {}) {
8
15
  validateScope(scope);
9
16
  const dependencies = {};
10
- for (const [name, spec] of Object.entries({ ...manifest.dependencies, ...manifest.devDependencies })) {
17
+ for (const [name, spec] of Object.entries({ ...manifest.dependencies, ...manifest.optionalDependencies, ...manifest.peerDependencies, ...manifest.devDependencies })) {
11
18
  if (!name.startsWith(`${scope}/`) || /^(file:|workspace:|link:)/.test(spec))
12
19
  continue;
13
20
  if (!new RegExp(`^${escapeRegex(scope)}/[a-z0-9][a-z0-9._-]*$`).test(name))
@@ -17,7 +24,7 @@ export function registryDependencies({ manifest, scope }) {
17
24
  return dependencies;
18
25
  }
19
26
  /** Split compiler output into whole diagnostics; wrapped details stay attached to their first line. */
20
- export function parseDiagnosticBlocks({ output }) {
27
+ export function parseDiagnosticBlocks({ output }, _optional = {}) {
21
28
  const blocks = [];
22
29
  let current = [];
23
30
  for (const line of output.replace(/\r\n/g, '\n').split('\n')) {
@@ -99,6 +106,7 @@ function evaluateCompile(project, registry, baseline, versions) {
99
106
  // A broken baseline is not valid evidence for suppressing registry failures.
100
107
  if (baseline.exitCode === null || (baseline.exitCode !== 0 && baselineDiagnostics.length === 0))
101
108
  return { ...base, status: 'typecheck-error' };
109
+ // Only diagnostics absent from the local run count as registry drift. Diagnostics already present locally represent pre-existing project failures.
102
110
  const known = new Set(baselineDiagnostics);
103
111
  const drift = diagnostics.filter((block) => !known.has(block));
104
112
  return { ...base, status: drift.length ? 'drift' : 'pass', diagnostics: drift };
@@ -121,6 +129,7 @@ function assertUnlinkedScope({ source, fs }) {
121
129
  throw new Error(`installed scoped package is linked: ${entry}`);
122
130
  }
123
131
  }
132
+ /** Reads the exact installed version of each package from a scratch install, for reporting. */
124
133
  function installedVersions({ scratch, deps, fs }) {
125
134
  const versions = {};
126
135
  for (const name of Object.keys(deps)) {
@@ -129,7 +138,11 @@ function installedVersions({ scratch, deps, fs }) {
129
138
  }
130
139
  return versions;
131
140
  }
132
- async function checkCompile(project, manifest, deps, scope, fs, runner, installer) {
141
+ /** Pins apply to compile projects only: a links project inspects what the host installed. */
142
+ function projectDependencies({ project, manifest, scope, pins }) {
143
+ return { ...registryDependencies({ manifest, scope }), ...(project.mode === 'links' ? {} : pins) };
144
+ }
145
+ async function checkCompile({ project, manifest, deps, scope, fs, runner, installer, keepScratch }) {
133
146
  if (Object.keys(deps).length === 0)
134
147
  return emptyResult(project.key, 'skipped', 'no registry-resolved scoped dependencies');
135
148
  const failed = await failedPrerequisite({ project, runner });
@@ -137,6 +150,7 @@ async function checkCompile(project, manifest, deps, scope, fs, runner, installe
137
150
  return emptyResult(project.key, 'prerequisite-error', combined(failed));
138
151
  const scratch = fs.createTempDirectory({ parent: project.scratchParent, prefix: 'published-types-' });
139
152
  try {
153
+ // Keep the project's scoped npm overrides so the scratch install resolves the same graph as the project's own install. The scoped `$` references resolve against the dependencies declared in the scratch manifest.
140
154
  const overrides = Object.fromEntries(Object.entries(manifest.overrides ?? {}).filter(([name]) => name.startsWith(`${scope}/`)));
141
155
  fs.writeText({ path: path.join(scratch, 'package.json'), text: JSON.stringify({ name: 'published-types-scratch', private: true, dependencies: deps, overrides }, null, 2) });
142
156
  const installed = await installer.install({ directory: scratch });
@@ -145,7 +159,9 @@ async function checkCompile(project, manifest, deps, scope, fs, runner, installe
145
159
  const source = path.join(scratch, 'node_modules', scope);
146
160
  assertUnlinkedScope({ source, fs });
147
161
  const versions = installedVersions({ scratch, deps, fs });
162
+ // Run the baseline before creating the shadow so ordinary module resolution sees the project's real install. The second compile then measures the registry install against that baseline.
148
163
  const baseline = project.mode === 'drift' ? await runner.run(project.compiler) : { exitCode: 0, stdout: '', stderr: '' };
164
+ // Shadow the whole installed scope so imports of hoisted transitive packages cannot fall through to a linked checkout and produce a mixed registry/local typecheck.
149
165
  // Copy the entire installed scope, including hoisted transitive packages.
150
166
  const cleanup = createShadow(project, source, scope, fs);
151
167
  let registry;
@@ -158,15 +174,18 @@ async function checkCompile(project, manifest, deps, scope, fs, runner, installe
158
174
  return evaluateCompile(project, registry, baseline, versions);
159
175
  }
160
176
  finally {
161
- fs.removeDirectory({ path: scratch });
177
+ // Clean up the scratch install on success or failure so the check leaves nothing behind, unless the caller explicitly requests it for debugging.
178
+ if (!keepScratch)
179
+ fs.removeDirectory({ path: scratch });
162
180
  }
163
181
  }
164
182
  /**
165
183
  * Check projects sequentially so overlapping source trees cannot see each other's shadows.
166
184
  * Ports never exit the host process. Operational failures remain failures, including cleanup errors.
167
185
  */
168
- export async function check({ projects, scope, fs, runner, installer }, { logger } = {}) {
186
+ export async function check({ projects, scope, fs, runner, installer }, { logger, pins = {}, keepScratch = false } = {}) {
169
187
  validateScope(scope);
188
+ validatePins({ pins, scope });
170
189
  if (projects.length === 0)
171
190
  throw new TypeError('at least one project is required');
172
191
  const results = [];
@@ -174,8 +193,8 @@ export async function check({ projects, scope, fs, runner, installer }, { logger
174
193
  let result;
175
194
  try {
176
195
  const manifest = JSON.parse(fs.readText({ path: project.manifestPath }));
177
- const deps = registryDependencies({ manifest, scope });
178
- result = project.mode === 'links' ? checkLinks(project, deps, fs) : await checkCompile(project, manifest, deps, scope, fs, runner, installer);
196
+ const deps = projectDependencies({ project, manifest, scope, pins });
197
+ result = project.mode === 'links' ? checkLinks(project, deps, fs) : await checkCompile({ project, manifest, deps, scope, fs, runner, installer, keepScratch });
179
198
  }
180
199
  catch (error) {
181
200
  result = emptyResult(project.key, 'operation-error', error instanceof Error ? error.message : String(error));
@@ -186,12 +205,14 @@ export async function check({ projects, scope, fs, runner, installer }, { logger
186
205
  return { ok: results.every((result) => result.status === 'pass' || result.status === 'skipped'), projects: results };
187
206
  }
188
207
  /** Diagnose captured CI results for the supplied scope without reading files or running commands. */
189
- export function diagnosePublishedTypes({ scope, logs }) {
208
+ export function diagnosePublishedTypes({ scope, logs }, _optional = {}) {
190
209
  validateScope(scope);
191
210
  const escapedScope = escapeRegex(scope);
211
+ // tsc wraps a module specifier in its own single quotes around the source's double quotes ('"@scope/pkg"'), so match one or two quote characters on each side.
192
212
  const missingExport = new RegExp(`Module ["']{1,2}${escapedScope}/[^"']+["']{1,2} has no exported member ["']([^"']+)["']`, 'g');
193
213
  const missingModule = new RegExp(`Cannot find module ["']{1,2}(${escapedScope}/[^"']+)["']{1,2} or its corresponding type declarations`, 'g');
194
214
  const failures = logs.filter((log) => log.exitCode !== 0).map((log) => {
215
+ // Scan the raw combined stdout and stderr from each failed `tsc` run. Return a description for every signature hit, including duplicates. Work is linear in the captured output.
195
216
  const text = combined(log);
196
217
  const hits = [
197
218
  ...[...text.matchAll(missingExport)].map((match) => `missing export '${match[1]}'`),
@@ -20,7 +20,7 @@
20
20
  /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
21
21
  export declare function redirectGuardInit({ init }: {
22
22
  init: RequestInit;
23
- }): RequestInit;
23
+ }, _optional?: Record<string, never>): RequestInit;
24
24
  /**
25
25
  * @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
26
26
  * redirect this authenticated request elsewhere). Call immediately after every guarded
@@ -33,5 +33,5 @@ export declare function redirectGuardInit({ init }: {
33
33
  export declare function assertNotRedirected({ resp, providerLabel }: {
34
34
  resp: Response;
35
35
  providerLabel: string;
36
- }): void;
36
+ }, _optional?: Record<string, never>): void;
37
37
  //# sourceMappingURL=redirect-guard.d.ts.map
@@ -19,7 +19,7 @@ import { DeployError } from './deploy-types.js';
19
19
  * keeps this correct even if a future runtime implements manual mode differently).
20
20
  */
21
21
  /** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
22
- export function redirectGuardInit({ init }) {
22
+ export function redirectGuardInit({ init }, _optional = {}) {
23
23
  return { ...init, redirect: 'manual' };
24
24
  }
25
25
  /**
@@ -31,7 +31,7 @@ export function redirectGuardInit({ init }) {
31
31
  * `404` — but call ordering here still matters for every OTHER status-sensitive branch in
32
32
  * a target.
33
33
  */
34
- export function assertNotRedirected({ resp, providerLabel }) {
34
+ export function assertNotRedirected({ resp, providerLabel }, _optional = {}) {
35
35
  if (resp.type === 'opaqueredirect' || (resp.status >= 300 && resp.status < 400)) {
36
36
  throw new DeployError({ message: `${providerLabel} attempted to redirect an authenticated request — refused to follow it (possible credential-leak vector).` }, { status: 502 });
37
37
  }
@@ -0,0 +1,8 @@
1
+ import type { LookupFunction } from 'node:net';
2
+ import { Agent, type Dispatcher } from 'undici';
3
+ export type ReachabilityDispatcher = Dispatcher;
4
+ /** Connect with the host's validating lookup; the caller owns this dispatcher. */
5
+ export declare function createUndiciReachabilityDispatcher({ lookup }: {
6
+ lookup: LookupFunction;
7
+ }, _options?: Record<string, never>): Agent;
8
+ //# sourceMappingURL=undici.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Agent } from 'undici';
2
+ /** Connect with the host's validating lookup; the caller owns this dispatcher. */
3
+ export function createUndiciReachabilityDispatcher({ lookup }, _options = {}) {
4
+ return new Agent({ connect: { lookup } });
5
+ }
6
+ //# sourceMappingURL=undici.js.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @file The guard a deploy-config generator runs on a value it is about to interpolate, unescaped, into a
3
+ * generated TOML or YAML file. Security-relevant: one unchecked value can inject a whole new key into a file a
4
+ * hosting platform will then act on.
5
+ */
6
+ /**
7
+ * Guards a value about to be interpolated, unescaped, into a generated TOML/YAML config file (a deploy-config
8
+ * generator that builds its file from a hand-written template string). A generator that builds its file through
9
+ * `JSON.stringify` is safe by construction and does not need it. Two distinct sink shapes call this, so it covers
10
+ * two distinct hazards:
11
+ *
12
+ * 1. QUOTED sinks (a TOML `key = "${...}"`, or a YAML value after the generator's own allow-list already passed
13
+ * it). A value containing a double-quote can close the quoted string early; one also containing a newline can
14
+ * then inject an entirely new top-level key on the next line (the reproduction and its regression test live
15
+ * with the TOML-emitting generator).
16
+ * 2. UNQUOTED YAML plain-scalar sinks (a `name: ${...}` line: YAML, unlike the TOML sinks above, is rendered with
17
+ * no surrounding quotes at all). Here a quote or newline is not the only hazard: `:`, `#`, `{`, `[`, `&`, `*`, a
18
+ * leading `-`, or leading/trailing whitespace are each YAML indicator or structural characters that change what
19
+ * an unquoted plain scalar means (`:` or `#` can end the scalar and start a new key or a comment mid-line;
20
+ * `{`/`[` open a flow collection; `&`/`*` are anchor and alias indicators; a leading `-` reads as a
21
+ * block-sequence entry). A guard that let these through was the original bug.
22
+ *
23
+ * Rejecting outright is the reliable fix for both. A per-host region allow-list is each generator's own choice, and
24
+ * one host's catalog had no authoritative source to enumerate against (its generator says why). The same reasoning
25
+ * extends to app and volume names: quoting the two unquoted YAML sinks at render time was considered instead of
26
+ * widening this check, but every generator's exact-string golden test already pins the CURRENT unquoted rendering
27
+ * for a safe name, so unconditionally quoting would change output for every already-safe name, not just unsafe
28
+ * ones, which is a real caller-visible behaviour change. Widening the reject-list here never changes what an
29
+ * already-accepted value renders as; it only ever accepts fewer values, exactly the tradeoff already made for the
30
+ * quote and newline above.
31
+ *
32
+ * The error is the host's own class, built by `fail`, so a bad value surfaces through the host's validation path.
33
+ * @throws whatever `fail` returns, with a message naming `fieldLabel` and the JSON-quoted value.
34
+ * @complexity O(n) in the value's length.
35
+ */
36
+ export declare function assertNoConfigInjection(required: {
37
+ fieldLabel: string;
38
+ value: string;
39
+ fail: (required: {
40
+ message: string;
41
+ }) => Error;
42
+ }, _optional?: {}): void;
43
+ //# sourceMappingURL=config-injection.d.ts.map
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @file The guard a deploy-config generator runs on a value it is about to interpolate, unescaped, into a
3
+ * generated TOML or YAML file. Security-relevant: one unchecked value can inject a whole new key into a file a
4
+ * hosting platform will then act on.
5
+ */
6
+ /** QUOTED-sink hazard characters (hazard 1 in {@link assertNoConfigInjection}'s own doc). A bare array and
7
+ * `.some()` keep this predicate free of branches of its own: the complexity ceiling applies per FUNCTION, and a
8
+ * 3-character alternation hand-written as `||` chains was most of the guard's earlier complexity. */
9
+ const QUOTE_OR_NEWLINE_CHARS = ['"', '\n', '\r'];
10
+ /** UNQUOTED-YAML-plain-scalar indicator and structural characters (hazard 2 in the guard's own doc). */
11
+ const YAML_SIGNIFICANT_CHARS = [':', '#', '{', '[', '&', '*'];
12
+ function containsAnyOf(required, _optional = {}) {
13
+ return required.chars.some((char) => required.value.includes(char));
14
+ }
15
+ function hasLeadingHyphenOrSurroundingWhitespace(required, _optional = {}) {
16
+ return required.value.startsWith('-') || required.value !== required.value.trim();
17
+ }
18
+ /**
19
+ * Guards a value about to be interpolated, unescaped, into a generated TOML/YAML config file (a deploy-config
20
+ * generator that builds its file from a hand-written template string). A generator that builds its file through
21
+ * `JSON.stringify` is safe by construction and does not need it. Two distinct sink shapes call this, so it covers
22
+ * two distinct hazards:
23
+ *
24
+ * 1. QUOTED sinks (a TOML `key = "${...}"`, or a YAML value after the generator's own allow-list already passed
25
+ * it). A value containing a double-quote can close the quoted string early; one also containing a newline can
26
+ * then inject an entirely new top-level key on the next line (the reproduction and its regression test live
27
+ * with the TOML-emitting generator).
28
+ * 2. UNQUOTED YAML plain-scalar sinks (a `name: ${...}` line: YAML, unlike the TOML sinks above, is rendered with
29
+ * no surrounding quotes at all). Here a quote or newline is not the only hazard: `:`, `#`, `{`, `[`, `&`, `*`, a
30
+ * leading `-`, or leading/trailing whitespace are each YAML indicator or structural characters that change what
31
+ * an unquoted plain scalar means (`:` or `#` can end the scalar and start a new key or a comment mid-line;
32
+ * `{`/`[` open a flow collection; `&`/`*` are anchor and alias indicators; a leading `-` reads as a
33
+ * block-sequence entry). A guard that let these through was the original bug.
34
+ *
35
+ * Rejecting outright is the reliable fix for both. A per-host region allow-list is each generator's own choice, and
36
+ * one host's catalog had no authoritative source to enumerate against (its generator says why). The same reasoning
37
+ * extends to app and volume names: quoting the two unquoted YAML sinks at render time was considered instead of
38
+ * widening this check, but every generator's exact-string golden test already pins the CURRENT unquoted rendering
39
+ * for a safe name, so unconditionally quoting would change output for every already-safe name, not just unsafe
40
+ * ones, which is a real caller-visible behaviour change. Widening the reject-list here never changes what an
41
+ * already-accepted value renders as; it only ever accepts fewer values, exactly the tradeoff already made for the
42
+ * quote and newline above.
43
+ *
44
+ * The error is the host's own class, built by `fail`, so a bad value surfaces through the host's validation path.
45
+ * @throws whatever `fail` returns, with a message naming `fieldLabel` and the JSON-quoted value.
46
+ * @complexity O(n) in the value's length.
47
+ */
48
+ export function assertNoConfigInjection(required, _optional = {}) {
49
+ const { fieldLabel, value, fail } = required;
50
+ if (containsAnyOf({ value, chars: QUOTE_OR_NEWLINE_CHARS })) {
51
+ throw fail({ message: `${fieldLabel} (${JSON.stringify(value)}) contains a quote or newline character, which would corrupt the generated config file` });
52
+ }
53
+ if (containsAnyOf({ value, chars: YAML_SIGNIFICANT_CHARS })) {
54
+ throw fail({ message: `${fieldLabel} (${JSON.stringify(value)}) contains a YAML-significant character (one of : # { [ & *), which would corrupt an unquoted YAML scalar in the generated config file` });
55
+ }
56
+ if (hasLeadingHyphenOrSurroundingWhitespace({ value })) {
57
+ throw fail({ message: `${fieldLabel} (${JSON.stringify(value)}) starts with "-" or has leading/trailing whitespace, which would corrupt an unquoted YAML scalar in the generated config file` });
58
+ }
59
+ }
60
+ //# sourceMappingURL=config-injection.js.map
@@ -13,6 +13,7 @@ export * from './ops-contracts.js';
13
13
  export * from './ops-descriptors.js';
14
14
  export * from './config-contracts.js';
15
15
  export * from './config-descriptors.js';
16
+ export * from './config-injection.js';
16
17
  export * from './ops-tool-contracts.js';
17
18
  export * from './ops-runner.js';
18
19
  export * from './ops-secrets.js';
@@ -12,6 +12,7 @@ export * from './ops-contracts.js';
12
12
  export * from './ops-descriptors.js';
13
13
  export * from './config-contracts.js';
14
14
  export * from './config-descriptors.js';
15
+ export * from './config-injection.js';
15
16
  export * from './ops-tool-contracts.js';
16
17
  export * from './ops-runner.js';
17
18
  export * from './ops-secrets.js';
@@ -13,9 +13,9 @@
13
13
  export declare function safeProjectLabel({ raw, maxLength }: {
14
14
  raw: unknown;
15
15
  maxLength: number;
16
- }): string;
16
+ }, _optional?: Record<string, never>): string;
17
17
  /** DNS-label-safe variant (63-char cap, the DNS label limit). */
18
18
  export declare function safeDnsLabel({ raw }: {
19
19
  raw: unknown;
20
- }): string;
20
+ }, _optional?: Record<string, never>): string;
21
21
  //# sourceMappingURL=naming.d.ts.map
@@ -11,7 +11,7 @@ import { trimChars, trimCharsEnd } from '@jini-ai/core/primitives';
11
11
  * @complexity O(n) in the length of `raw`.
12
12
  * @overallScore 100/100
13
13
  */
14
- export function safeProjectLabel({ raw, maxLength }) {
14
+ export function safeProjectLabel({ raw, maxLength }, _optional = {}) {
15
15
  const collapsed = String(raw)
16
16
  .normalize('NFKD')
17
17
  .toLowerCase()
@@ -20,7 +20,7 @@ export function safeProjectLabel({ raw, maxLength }) {
20
20
  return trimCharsEnd({ text: trimChars({ text: collapsed, chars: '-' }).slice(0, maxLength), chars: '-' });
21
21
  }
22
22
  /** DNS-label-safe variant (63-char cap, the DNS label limit). */
23
- export function safeDnsLabel({ raw }) {
23
+ export function safeDnsLabel({ raw }, _optional = {}) {
24
24
  return safeProjectLabel({ raw, maxLength: 63 });
25
25
  }
26
26
  //# sourceMappingURL=naming.js.map
@@ -1,19 +1,30 @@
1
1
  import type { lookup } from 'node:dns';
2
2
  import type { LookupFunction } from 'node:net';
3
- import { Agent, type Dispatcher } from 'undici';
3
+ import { type ReachabilityDispatcher } from './adapters/undici.js';
4
4
  import type { ReachabilityArgs } from './reachability.js';
5
+ /** The lookup platform's `createValidatingLookup` returns: it resolves, then refuses private addresses. */
6
+ export type ValidatingLookup = (hostname: string, options: unknown, callback: (error: Error | null, address?: unknown, family?: number) => void) => void;
7
+ /** What the Node reachability transport needs from the host's platform binding. The host passes
8
+ * platform's `createValidatingLookup`; the policy of using it at connection time stays here. */
9
+ export interface ReachabilityLookupRequired {
10
+ readonly createValidatingLookup: (lookupImpl?: typeof lookup) => ValidatingLookup;
11
+ }
12
+ /** `ReachabilityLookupRequired` plus platform's `assertSafePublicUrl` (the synchronous URL guard). */
13
+ export interface NodeReachabilityRequired extends ReachabilityLookupRequired {
14
+ readonly assertSafeUrl: (raw: string) => URL;
15
+ }
5
16
  /**
6
17
  * Socket-level lookup for deployment probes: platform's validating lookup (private-address
7
18
  * refusal) narrowed to the shapes Node's `net.connect` accepts — a single address string, or the
8
19
  * `{ address, family }[]` list returned for `all: true` lookups. Anything else is refused rather
9
20
  * than forwarded untyped to the socket.
10
21
  */
11
- export declare function createReachabilityLookup(_required: Record<string, never>, { lookupImpl }?: {
22
+ export declare function createReachabilityLookup(required: ReachabilityLookupRequired, { lookupImpl }?: {
12
23
  lookupImpl?: typeof lookup;
13
24
  }): LookupFunction;
14
- export declare function createReachabilityDispatcher(_required: Record<string, never>, { lookupImpl }?: {
25
+ export declare function createReachabilityDispatcher(required: ReachabilityLookupRequired, { lookupImpl }?: {
15
26
  lookupImpl?: typeof lookup;
16
- }): Agent;
27
+ }): import("undici").Agent;
17
28
  /**
18
29
  * Node default for deployment probes: URL rejection plus connection-time DNS validation.
19
30
  * The address validated by platform's lookup is the address the socket connects to; a
@@ -25,10 +36,10 @@ export declare function createReachabilityDispatcher(_required: Record<string, n
25
36
  * undici-types Dispatcher version need not match the runtime undici Agent.
26
37
  * Native fetch uses that Agent's dispatch method; no port casts are needed.
27
38
  */
28
- export declare function createNodeReachabilityPorts(_required: Record<string, never>, options?: {
39
+ export declare function createNodeReachabilityPorts(required: NodeReachabilityRequired, options?: {
29
40
  fetch?: typeof globalThis.fetch;
30
41
  lookupImpl?: typeof lookup;
31
- dispatcher?: Dispatcher;
42
+ dispatcher?: ReachabilityDispatcher;
32
43
  }): Pick<ReachabilityArgs, 'fetch' | 'guard'> & {
33
44
  close(): Promise<void>;
34
45
  };
@@ -1,5 +1,4 @@
1
- import { Agent } from 'undici';
2
- import { assertSafePublicUrl, createValidatingLookup } from '@jini-ai/platform';
1
+ import { createUndiciReachabilityDispatcher } from './adapters/undici.js';
3
2
  function isLookupAddress(value) {
4
3
  if (value === null || typeof value !== 'object')
5
4
  return false;
@@ -12,8 +11,8 @@ function isLookupAddress(value) {
12
11
  * `{ address, family }[]` list returned for `all: true` lookups. Anything else is refused rather
13
12
  * than forwarded untyped to the socket.
14
13
  */
15
- export function createReachabilityLookup(_required, { lookupImpl } = {}) {
16
- const validatingLookup = createValidatingLookup(lookupImpl);
14
+ export function createReachabilityLookup(required, { lookupImpl } = {}) {
15
+ const validatingLookup = required.createValidatingLookup(lookupImpl);
17
16
  return (hostname, options, callback) => {
18
17
  validatingLookup(hostname, options, (error, address, family) => {
19
18
  if (error) {
@@ -32,8 +31,8 @@ export function createReachabilityLookup(_required, { lookupImpl } = {}) {
32
31
  });
33
32
  };
34
33
  }
35
- export function createReachabilityDispatcher(_required, { lookupImpl } = {}) {
36
- return new Agent({ connect: { lookup: createReachabilityLookup({}, lookupImpl ? { lookupImpl } : {}) } });
34
+ export function createReachabilityDispatcher(required, { lookupImpl } = {}) {
35
+ return createUndiciReachabilityDispatcher({ lookup: createReachabilityLookup(required, lookupImpl ? { lookupImpl } : {}) });
37
36
  }
38
37
  /**
39
38
  * Node default for deployment probes: URL rejection plus connection-time DNS validation.
@@ -46,14 +45,14 @@ export function createReachabilityDispatcher(_required, { lookupImpl } = {}) {
46
45
  * undici-types Dispatcher version need not match the runtime undici Agent.
47
46
  * Native fetch uses that Agent's dispatch method; no port casts are needed.
48
47
  */
49
- export function createNodeReachabilityPorts(_required, options = {}) {
48
+ export function createNodeReachabilityPorts(required, options = {}) {
50
49
  let dispatcher = options.dispatcher;
51
50
  return {
52
51
  close: async () => { if (!options.dispatcher)
53
52
  await dispatcher?.close(); },
54
- guard: { assertSafeUrl: ({ raw }) => assertSafePublicUrl(raw) },
53
+ guard: { assertSafeUrl: ({ raw }) => required.assertSafeUrl(raw) },
55
54
  fetch: ({ url }, { init } = {}) => {
56
- dispatcher ??= createReachabilityDispatcher({}, options.lookupImpl ? { lookupImpl: options.lookupImpl } : {});
55
+ dispatcher ??= createReachabilityDispatcher(required, options.lookupImpl ? { lookupImpl: options.lookupImpl } : {});
57
56
  const guardedInit = { ...init };
58
57
  Object.defineProperty(guardedInit, 'dispatcher', {
59
58
  value: dispatcher, enumerable: true, configurable: true, writable: true,
@@ -88,14 +88,16 @@ export declare function runDeploy(required: {
88
88
  * @returns Reached flag, elapsed seconds, attempted poll count and last observation; timeout is a result.
89
89
  * @throws {ToolInputError} Cancellation or a refusal from the status reader.
90
90
  * @complexity Time: O(timeout / 10s) polls. Space: O(one status response).
91
- * @example await waitForDeployOps({ status }, { until: "healthy", timeoutSeconds: 180, signal });
91
+ * @example await waitForDeployOps({ deps: { status }, until: "healthy" }, { timeoutSeconds: 180, signal });
92
92
  */
93
- export declare function waitForDeployOps(deps: {
94
- status(signal: AbortSignal): Promise<DeployOpsStatus>;
95
- clock?: WaitClock | undefined;
96
- initial?: DeployOpsStatus;
97
- }, input: {
93
+ export declare function waitForDeployOps({ deps, until }: {
94
+ deps: {
95
+ status(signal: AbortSignal): Promise<DeployOpsStatus>;
96
+ clock?: WaitClock | undefined;
97
+ initial?: DeployOpsStatus;
98
+ };
98
99
  until: "healthy" | "finished";
100
+ }, input?: {
99
101
  timeoutSeconds?: number;
100
102
  signal?: AbortSignal | undefined;
101
103
  }): Promise<DeployOpsWaitResult>;
@@ -1,5 +1,5 @@
1
1
  // Mechanical extraction provenance is recorded in this package's source-map.md.
2
- import { nowIso } from '@jini-ai/core/primitives';
2
+ import { createConsoleLogger, nowIso } from '@jini-ai/core/primitives';
3
3
  import { ToolInputError } from '@jini-ai/core';
4
4
  import { requireDeployPlatform } from './ops-registry.js';
5
5
  /** Response text is capped before parsing; the credential layer has already redacted secrets. */
@@ -240,10 +240,11 @@ async function recordAcceptedDeploy({ deps, platform, normalized }, _optional =
240
240
  reachable: false, status: "started", publishedAt: nowIso({ clock: deps.clock }), triggeredBy: "agent_tool",
241
241
  } });
242
242
  }
243
- catch {
243
+ catch (error) {
244
244
  // Dispatch already succeeded; never turn a ledger failure into a duplicate deploy retry.
245
245
  // No raw error: database parameters can contain credentials or provider response data.
246
- console.warn("[deploy-ops] destination history write failed after accepted deploy");
246
+ const logger = deps.report ?? createConsoleLogger({ prefix: '' });
247
+ logger.warn({ message: "[deploy-ops] destination history write failed after accepted deploy" }, { error });
247
248
  }
248
249
  }
249
250
  }
@@ -308,9 +309,9 @@ function waitSettings({ deps, input }, _optional = {}) {
308
309
  * @returns Reached flag, elapsed seconds, attempted poll count and last observation; timeout is a result.
309
310
  * @throws {ToolInputError} Cancellation or a refusal from the status reader.
310
311
  * @complexity Time: O(timeout / 10s) polls. Space: O(one status response).
311
- * @example await waitForDeployOps({ status }, { until: "healthy", timeoutSeconds: 180, signal });
312
+ * @example await waitForDeployOps({ deps: { status }, until: "healthy" }, { timeoutSeconds: 180, signal });
312
313
  */
313
- export async function waitForDeployOps(deps, input) {
314
+ export async function waitForDeployOps({ deps, until }, input = {}) {
314
315
  const { clock, started, deadline, initial } = waitSettings({ deps, input }, {});
315
316
  let polls = 0;
316
317
  let last = initial;
@@ -325,7 +326,7 @@ export async function waitForDeployOps(deps, input) {
325
326
  last = observation;
326
327
  if (clock.now() > deadline)
327
328
  return result(false);
328
- if (reachedCondition({ until: input.until, state: last.state }, {}))
329
+ if (reachedCondition({ until, state: last.state }, {}))
329
330
  return result(true);
330
331
  await sleepBeforeDeadline({ clock, deadline }, { signal: input.signal });
331
332
  }
@@ -1,5 +1,5 @@
1
1
  import type { AgentToolDefinition, DerivedRiskByToolId, ToolMetadataById, ToolExecutionContext, ToolExecutionOptions, SurfaceAskThenReport, SurfaceExchangeStore } from '@jini-ai/core';
2
- import type { Clock } from '@jini-ai/core/primitives';
2
+ import type { Clock, Logger } from '@jini-ai/core/primitives';
3
3
  import type { SurfaceCardsPort, SurfaceCardSecretForm } from '@jini-ai/core/contracts/cards';
4
4
  import type { CredentialedRequestRequired, CredentialedRequestOptional, CredentialedRequestResult, CredentialedRequestPort } from '@jini-ai/core/contracts/credentials';
5
5
  import type { DeployOpsRegistry, DeployOpsSecretAppliesOn } from './ops-contracts.js';
@@ -108,6 +108,7 @@ export interface DeployOpsToolIds {
108
108
  }
109
109
  /** @agent-note Use the SAME workspace and saved store as host request routes so inventory and target authorization describe the same credentials. */
110
110
  export interface DeployOpsRuntime {
111
+ report?: Pick<Logger, 'warn'>;
111
112
  workspaceId: string;
112
113
  clock: Clock;
113
114
  loadDeployOps(input: {
@@ -88,7 +88,7 @@ async function observationHandler({ deps, input, name }, { signal } = {}) {
88
88
  return await runDeployOps({ deps, input: args, operation: "status" }, { signal });
89
89
  if (input.until !== "healthy" && input.until !== "finished")
90
90
  throw new ToolInputError({ message: "until must be 'healthy' or 'finished'." });
91
- return await waitForDeployOps({ status: signal => runDeployOps({ deps, input: args, operation: "status" }, { signal }), clock: deps.waitClock, initial: { platform: args.platform, target: args.target, state: "unknown", summary: "No status received before timeout.", items: [], checkedAt: nowIso({ clock: deps.clock }) } }, { until: input.until, timeoutSeconds: integer(input, "timeoutSeconds", 180, 10, MAX_WAIT_SECONDS), signal });
91
+ return await waitForDeployOps({ deps: { status: signal => runDeployOps({ deps, input: args, operation: "status" }, { signal }), clock: deps.waitClock, initial: { platform: args.platform, target: args.target, state: "unknown", summary: "No status received before timeout.", items: [], checkedAt: nowIso({ clock: deps.clock }) } }, until: input.until }, { timeoutSeconds: integer(input, "timeoutSeconds", 180, 10, MAX_WAIT_SECONDS), signal });
92
92
  }
93
93
  /** Permission precedes any plugin/credential read. Handler input validation is independent of the schema. */
94
94
  export function buildDeployOpsRegistrations({ deps, host }, _optional = {}) {
@@ -69,7 +69,7 @@ export interface ReachabilityWaitResult {
69
69
  */
70
70
  export declare function normalizeDeploymentUrl({ url }: {
71
71
  url: unknown;
72
- }): string;
72
+ }, _optional?: Record<string, never>): string;
73
73
  /**
74
74
  * Probes a single deployment URL, trying HEAD first and falling back to
75
75
  * GET when HEAD is rejected or ambiguous (some hosts don't implement HEAD
@@ -30,7 +30,7 @@ function assertSafeDeploymentUrl(raw, guard) {
30
30
  * @complexity O(1).
31
31
  * @overallScore 100/100
32
32
  */
33
- export function normalizeDeploymentUrl({ url }) {
33
+ export function normalizeDeploymentUrl({ url }, _optional = {}) {
34
34
  if (typeof url !== 'string')
35
35
  return '';
36
36
  const trimmed = url.trim();