@jini-ai/devops 0.4.0 → 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 (94) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +62 -2
  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/naming.d.ts +8 -4
  31. package/dist/deploy/naming.js +4 -5
  32. package/dist/deploy/node.d.ts +18 -0
  33. package/dist/deploy/node.js +57 -0
  34. package/dist/deploy/reachability.d.ts +42 -12
  35. package/dist/deploy/reachability.js +75 -69
  36. package/dist/deploy/redirect-guard.d.ts +7 -2
  37. package/dist/deploy/redirect-guard.js +3 -3
  38. package/dist/deploy/tokens.d.ts +14 -11
  39. package/dist/deploy/tokens.js +13 -13
  40. package/dist/deploy/tool.d.ts +9 -5
  41. package/dist/deploy/tool.js +5 -6
  42. package/dist/deploy/types.d.ts +22 -10
  43. package/dist/deploy/types.js +2 -2
  44. package/dist/index.d.ts +2 -1
  45. package/dist/index.js +2 -1
  46. package/dist/local-dev/index.d.ts +34 -0
  47. package/dist/local-dev/index.js +37 -0
  48. package/dist/packaging/electron/archive.d.ts +41 -0
  49. package/dist/packaging/electron/archive.js +77 -0
  50. package/dist/packaging/electron/asar-adapter.d.ts +13 -0
  51. package/dist/packaging/electron/asar-adapter.js +5 -0
  52. package/dist/packaging/electron/entry.d.ts +9 -0
  53. package/dist/packaging/electron/entry.js +9 -0
  54. package/dist/packaging/electron/imports.d.ts +13 -0
  55. package/dist/packaging/electron/imports.js +44 -0
  56. package/dist/packaging/electron/node.d.ts +8 -0
  57. package/dist/packaging/electron/node.js +51 -0
  58. package/dist/packaging/electron/policies.d.ts +64 -0
  59. package/dist/packaging/electron/policies.js +63 -0
  60. package/dist/packaging/electron/ports.d.ts +113 -0
  61. package/dist/packaging/electron/ports.js +2 -0
  62. package/dist/packaging/electron/stability.d.ts +9 -0
  63. package/dist/packaging/electron/stability.js +12 -0
  64. package/dist/packaging/electron/staging.d.ts +108 -0
  65. package/dist/packaging/electron/staging.js +249 -0
  66. package/dist/packaging/electron/typescript.d.ts +7 -0
  67. package/dist/packaging/electron/typescript.js +18 -0
  68. package/dist/source-control/commit.d.ts +11 -0
  69. package/dist/source-control/commit.js +71 -0
  70. package/dist/source-control/contracts.d.ts +327 -0
  71. package/dist/source-control/contracts.js +2 -0
  72. package/dist/source-control/entry.d.ts +6 -0
  73. package/dist/source-control/entry.js +6 -0
  74. package/dist/source-control/kit.d.ts +15 -0
  75. package/dist/source-control/kit.js +17 -0
  76. package/dist/source-control/registry.d.ts +100 -0
  77. package/dist/source-control/registry.js +174 -0
  78. package/dist/source-control/repository-target.d.ts +13 -0
  79. package/dist/source-control/repository-target.js +28 -0
  80. package/dist/static-export/contracts.d.ts +138 -0
  81. package/dist/static-export/contracts.js +5 -0
  82. package/dist/static-export/entry.d.ts +6 -0
  83. package/dist/static-export/entry.js +6 -0
  84. package/dist/static-export/failure-summary.d.ts +12 -0
  85. package/dist/static-export/failure-summary.js +12 -0
  86. package/dist/static-export/fetch-adapter.d.ts +6 -0
  87. package/dist/static-export/fetch-adapter.js +5 -0
  88. package/dist/static-export/node-adapters.d.ts +11 -0
  89. package/dist/static-export/node-adapters.js +111 -0
  90. package/dist/static-export/runner.d.ts +6 -0
  91. package/dist/static-export/runner.js +135 -0
  92. package/dist/static-export/transforms.d.ts +53 -0
  93. package/dist/static-export/transforms.js +154 -0
  94. package/package.json +82 -5
@@ -0,0 +1,67 @@
1
+ /** A shell-free executable request. Paths and executables belong to the host. */
2
+ export interface ProcessRequest {
3
+ readonly command: string;
4
+ readonly args: readonly string[];
5
+ readonly cwd: string;
6
+ }
7
+ /** Null means the executable could not complete, including signals and spawn failures. */
8
+ export interface ProcessResult {
9
+ readonly exitCode: number | null;
10
+ readonly stdout: string;
11
+ readonly stderr: string;
12
+ }
13
+ export interface ProcessRunnerPort {
14
+ run(args: ProcessRequest): Promise<ProcessResult>;
15
+ }
16
+ export interface SourceReaderPort {
17
+ readText(args: {
18
+ path: string;
19
+ }): string;
20
+ }
21
+ /** Synchronous filesystem operations; createDirectory must fail when the path already exists. */
22
+ export interface FilesystemPort extends SourceReaderPort {
23
+ exists(args: {
24
+ path: string;
25
+ }): boolean;
26
+ isSymbolicLink(args: {
27
+ path: string;
28
+ }): boolean;
29
+ readDirectory(args: {
30
+ path: string;
31
+ }): readonly string[];
32
+ writeText(args: {
33
+ path: string;
34
+ text: string;
35
+ }): void;
36
+ createTempDirectory(args: {
37
+ parent: string;
38
+ prefix: string;
39
+ }): string;
40
+ createDirectory(args: {
41
+ path: string;
42
+ }): void;
43
+ ensureDirectory(args: {
44
+ path: string;
45
+ }): void;
46
+ copyDirectory(args: {
47
+ source: string;
48
+ destination: string;
49
+ }): void;
50
+ removeDirectory(args: {
51
+ path: string;
52
+ }): void;
53
+ }
54
+ export interface PackageInstallerPort {
55
+ /** Install the manifest already written in directory; return captured output, never exit. */
56
+ install(args: {
57
+ directory: string;
58
+ }): Promise<ProcessResult>;
59
+ }
60
+ export interface CheckLoggerPort {
61
+ log(args: {
62
+ projectKey: string;
63
+ status: string;
64
+ message: string;
65
+ }): void;
66
+ }
67
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1,77 @@
1
+ import type { CheckLoggerPort, FilesystemPort, PackageInstallerPort, ProcessRequest, ProcessResult, ProcessRunnerPort } from '../ports.js';
2
+ export type { CheckLoggerPort, FilesystemPort, PackageInstallerPort, ProcessRequest, ProcessResult, ProcessRunnerPort } from '../ports.js';
3
+ export interface DependencyManifest {
4
+ dependencies?: Record<string, string>;
5
+ devDependencies?: Record<string, string>;
6
+ overrides?: Record<string, unknown>;
7
+ }
8
+ interface ProjectBase {
9
+ key: string;
10
+ directory: string;
11
+ manifestPath: string;
12
+ }
13
+ export interface LinksProject extends ProjectBase {
14
+ mode: 'links';
15
+ }
16
+ export interface CompileProject extends ProjectBase {
17
+ mode: 'drift' | 'published';
18
+ /** Must be a closer source ancestor than the real install; the host owns this assertion. */
19
+ shadowAnchor: string;
20
+ /** Existing writable scratch parent; unique temporary directories prevent run collisions. */
21
+ scratchParent: string;
22
+ prerequisites: readonly ProcessRequest[];
23
+ /** Runs against the real project config; the library never substitutes tsconfig paths. */
24
+ compiler: ProcessRequest;
25
+ }
26
+ export type PublishedTypesProject = LinksProject | CompileProject;
27
+ export type PublishedTypesStatus = 'pass' | 'skipped' | 'linked' | 'drift' | 'install-error' | 'prerequisite-error' | 'typecheck-error' | 'operation-error';
28
+ export interface PublishedTypesResult {
29
+ projectKey: string;
30
+ status: PublishedTypesStatus;
31
+ versions: Readonly<Record<string, string>>;
32
+ linkedPackages: readonly string[];
33
+ diagnostics: readonly string[];
34
+ baselineDiagnostics: readonly string[];
35
+ output: string;
36
+ }
37
+ export interface PublishedTypesReport {
38
+ ok: boolean;
39
+ projects: readonly PublishedTypesResult[];
40
+ }
41
+ /** Select registry-resolved dependencies from the required scope; explicit local specs are exempt. */
42
+ export declare function registryDependencies({ manifest, scope }: {
43
+ manifest: DependencyManifest;
44
+ scope: string;
45
+ }): Record<string, string>;
46
+ /** Split compiler output into whole diagnostics; wrapped details stay attached to their first line. */
47
+ export declare function parseDiagnosticBlocks({ output }: {
48
+ output: string;
49
+ }): string[];
50
+ /**
51
+ * Check projects sequentially so overlapping source trees cannot see each other's shadows.
52
+ * Ports never exit the host process. Operational failures remain failures, including cleanup errors.
53
+ */
54
+ export declare function check({ projects, scope, fs, runner, installer }: {
55
+ projects: readonly PublishedTypesProject[];
56
+ scope: string;
57
+ fs: FilesystemPort;
58
+ runner: ProcessRunnerPort;
59
+ installer: PackageInstallerPort;
60
+ }, { logger }?: {
61
+ logger?: CheckLoggerPort;
62
+ }): Promise<PublishedTypesReport>;
63
+ export interface TypecheckLog extends ProcessResult {
64
+ projectKey: string;
65
+ }
66
+ export interface TypecheckDiagnosis {
67
+ ok: boolean;
68
+ failures: readonly (TypecheckLog & {
69
+ hits: readonly string[];
70
+ })[];
71
+ }
72
+ /** Diagnose captured CI results for the supplied scope without reading files or running commands. */
73
+ export declare function diagnosePublishedTypes({ scope, logs }: {
74
+ scope: string;
75
+ logs: readonly TypecheckLog[];
76
+ }): TypecheckDiagnosis;
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,186 @@
1
+ import path from 'node:path';
2
+ function validateScope(scope) {
3
+ if (!/^@[a-z0-9][a-z0-9._-]*$/.test(scope))
4
+ throw new TypeError('scope must be an npm scope such as @example');
5
+ }
6
+ /** Select registry-resolved dependencies from the required scope; explicit local specs are exempt. */
7
+ export function registryDependencies({ manifest, scope }) {
8
+ validateScope(scope);
9
+ const dependencies = {};
10
+ for (const [name, spec] of Object.entries({ ...manifest.dependencies, ...manifest.devDependencies })) {
11
+ if (!name.startsWith(`${scope}/`) || /^(file:|workspace:|link:)/.test(spec))
12
+ continue;
13
+ if (!new RegExp(`^${escapeRegex(scope)}/[a-z0-9][a-z0-9._-]*$`).test(name))
14
+ throw new TypeError(`invalid dependency name: ${name}`);
15
+ dependencies[name] = spec;
16
+ }
17
+ return dependencies;
18
+ }
19
+ /** Split compiler output into whole diagnostics; wrapped details stay attached to their first line. */
20
+ export function parseDiagnosticBlocks({ output }) {
21
+ const blocks = [];
22
+ let current = [];
23
+ for (const line of output.replace(/\r\n/g, '\n').split('\n')) {
24
+ if (/^\S.*\(\d+,\d+\): error TS\d+:/.test(line) || /^error TS\d+:/.test(line)) {
25
+ if (current.length)
26
+ blocks.push(current.join('\n').trimEnd());
27
+ current = [line];
28
+ }
29
+ else if (current.length)
30
+ current.push(line);
31
+ }
32
+ if (current.length)
33
+ blocks.push(current.join('\n').trimEnd());
34
+ return blocks;
35
+ }
36
+ function emptyResult(projectKey, status, output = '') {
37
+ return { projectKey, status, output, versions: {}, linkedPackages: [], diagnostics: [], baselineDiagnostics: [] };
38
+ }
39
+ function combined(result) { return `${result.stdout}${result.stderr}`; }
40
+ function escapeRegex(text) { return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
41
+ function checkLinks(project, deps, fs) {
42
+ const linkedPackages = Object.keys(deps).filter((name) => {
43
+ const location = path.join(project.directory, 'node_modules', name);
44
+ // lstat also sees broken symlinks; exists() alone does not.
45
+ try {
46
+ return fs.isSymbolicLink({ path: location });
47
+ }
48
+ catch (error) {
49
+ if (isMissingPath(error))
50
+ return false;
51
+ throw error;
52
+ }
53
+ });
54
+ return { ...emptyResult(project.key, linkedPackages.length ? 'linked' : 'pass'), linkedPackages };
55
+ }
56
+ function isMissingPath(error) {
57
+ return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';
58
+ }
59
+ /** Acquire ownership before copying. Existing scope directories are never removed or replaced. */
60
+ function createShadow(project, source, scope, fs) {
61
+ const nodeModules = path.join(project.shadowAnchor, 'node_modules');
62
+ const scopeDir = path.join(nodeModules, scope);
63
+ const parentExisted = fs.exists({ path: nodeModules });
64
+ if (parentExisted && fs.isSymbolicLink({ path: nodeModules }))
65
+ throw new Error('shadow node_modules must not be a symlink');
66
+ if (!parentExisted)
67
+ fs.createDirectory({ path: nodeModules });
68
+ let scopeOwned = false;
69
+ const cleanup = () => {
70
+ if (scopeOwned)
71
+ fs.removeDirectory({ path: scopeDir });
72
+ // Preserve any entries another process added while the compiler ran.
73
+ if (!parentExisted && fs.readDirectory({ path: nodeModules }).length === 0)
74
+ fs.removeDirectory({ path: nodeModules });
75
+ };
76
+ try {
77
+ fs.createDirectory({ path: scopeDir });
78
+ scopeOwned = true;
79
+ fs.copyDirectory({ source, destination: scopeDir });
80
+ return cleanup;
81
+ }
82
+ catch (error) {
83
+ cleanup();
84
+ throw error;
85
+ }
86
+ }
87
+ function evaluateCompile(project, registry, baseline, versions) {
88
+ const output = combined(registry);
89
+ const baselineDiagnostics = parseDiagnosticBlocks({ output: combined(baseline) });
90
+ const diagnostics = parseDiagnosticBlocks({ output });
91
+ const base = { ...emptyResult(project.key, 'pass', output), versions, diagnostics, baselineDiagnostics };
92
+ if (registry.exitCode === 0)
93
+ return base;
94
+ if (project.mode === 'published' || registry.exitCode === null || diagnostics.length === 0)
95
+ return { ...base, status: 'typecheck-error' };
96
+ // A broken baseline is not valid evidence for suppressing registry failures.
97
+ if (baseline.exitCode === null || (baseline.exitCode !== 0 && baselineDiagnostics.length === 0))
98
+ return { ...base, status: 'typecheck-error' };
99
+ const known = new Set(baselineDiagnostics);
100
+ const drift = diagnostics.filter((block) => !known.has(block));
101
+ return { ...base, status: drift.length ? 'drift' : 'pass', diagnostics: drift };
102
+ }
103
+ async function checkCompile(project, manifest, deps, scope, fs, runner, installer) {
104
+ if (Object.keys(deps).length === 0)
105
+ return emptyResult(project.key, 'skipped', 'no registry-resolved scoped dependencies');
106
+ for (const command of project.prerequisites) {
107
+ const result = await runner.run(command);
108
+ if (result.exitCode !== 0)
109
+ return emptyResult(project.key, 'prerequisite-error', combined(result));
110
+ }
111
+ const scratch = fs.createTempDirectory({ parent: project.scratchParent, prefix: 'published-types-' });
112
+ try {
113
+ const overrides = Object.fromEntries(Object.entries(manifest.overrides ?? {}).filter(([name]) => name.startsWith(`${scope}/`)));
114
+ fs.writeText({ path: path.join(scratch, 'package.json'), text: JSON.stringify({ name: 'published-types-scratch', private: true, dependencies: deps, overrides }, null, 2) });
115
+ const installed = await installer.install({ directory: scratch });
116
+ if (installed.exitCode !== 0)
117
+ return emptyResult(project.key, 'install-error', combined(installed));
118
+ const source = path.join(scratch, 'node_modules', scope);
119
+ if (fs.isSymbolicLink({ path: source }))
120
+ throw new Error('installed scope must not be linked');
121
+ for (const entry of fs.readDirectory({ path: source })) {
122
+ if (fs.isSymbolicLink({ path: path.join(source, entry) }))
123
+ throw new Error(`installed scoped package is linked: ${entry}`);
124
+ }
125
+ const versions = {};
126
+ for (const name of Object.keys(deps)) {
127
+ const pkg = JSON.parse(fs.readText({ path: path.join(scratch, 'node_modules', name, 'package.json') }));
128
+ versions[name] = pkg.version;
129
+ }
130
+ const baseline = project.mode === 'drift' ? await runner.run(project.compiler) : { exitCode: 0, stdout: '', stderr: '' };
131
+ // Copy the entire installed scope, including hoisted transitive packages.
132
+ const cleanup = createShadow(project, source, scope, fs);
133
+ let registry;
134
+ try {
135
+ registry = await runner.run(project.compiler);
136
+ }
137
+ finally {
138
+ cleanup();
139
+ }
140
+ return evaluateCompile(project, registry, baseline, versions);
141
+ }
142
+ finally {
143
+ fs.removeDirectory({ path: scratch });
144
+ }
145
+ }
146
+ /**
147
+ * Check projects sequentially so overlapping source trees cannot see each other's shadows.
148
+ * Ports never exit the host process. Operational failures remain failures, including cleanup errors.
149
+ */
150
+ export async function check({ projects, scope, fs, runner, installer }, { logger } = {}) {
151
+ validateScope(scope);
152
+ if (projects.length === 0)
153
+ throw new TypeError('at least one project is required');
154
+ const results = [];
155
+ for (const project of projects) {
156
+ let result;
157
+ try {
158
+ const manifest = JSON.parse(fs.readText({ path: project.manifestPath }));
159
+ const deps = registryDependencies({ manifest, scope });
160
+ result = project.mode === 'links' ? checkLinks(project, deps, fs) : await checkCompile(project, manifest, deps, scope, fs, runner, installer);
161
+ }
162
+ catch (error) {
163
+ result = emptyResult(project.key, 'operation-error', error instanceof Error ? error.message : String(error));
164
+ }
165
+ results.push(result);
166
+ logger?.log({ projectKey: project.key, status: result.status, message: result.output });
167
+ }
168
+ return { ok: results.every((result) => result.status === 'pass' || result.status === 'skipped'), projects: results };
169
+ }
170
+ /** Diagnose captured CI results for the supplied scope without reading files or running commands. */
171
+ export function diagnosePublishedTypes({ scope, logs }) {
172
+ validateScope(scope);
173
+ const escapedScope = escapeRegex(scope);
174
+ const missingExport = new RegExp(`Module ["']{1,2}${escapedScope}/[^"']+["']{1,2} has no exported member ["']([^"']+)["']`, 'g');
175
+ const missingModule = new RegExp(`Cannot find module ["']{1,2}(${escapedScope}/[^"']+)["']{1,2} or its corresponding type declarations`, 'g');
176
+ const failures = logs.filter((log) => log.exitCode !== 0).map((log) => {
177
+ const text = combined(log);
178
+ const hits = [
179
+ ...[...text.matchAll(missingExport)].map((match) => `missing export '${match[1]}'`),
180
+ ...[...text.matchAll(missingModule)].map((match) => `missing module '${match[1]}'`),
181
+ ];
182
+ return { ...log, hits };
183
+ });
184
+ return { ok: failures.length === 0, failures };
185
+ }
186
+ //# sourceMappingURL=index.js.map
@@ -14,7 +14,7 @@
14
14
  import type { assertNotRedirected, redirectGuardInit } from './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, JsonObject } from './types.js';
17
+ import type { DeployError, DeployTarget, UnknownRecord } from './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
@@ -47,19 +47,32 @@ export interface SigV4ClientOptions {
47
47
  * before sending it, retrying a 5xx/429 with backoff.
48
48
  */
49
49
  export interface SigV4Client {
50
- fetch(input: string, init?: RequestInit): Promise<Response>;
50
+ fetch(requiredArgs: {
51
+ input: string;
52
+ }, optionalArgs?: {
53
+ init?: RequestInit;
54
+ }): Promise<Response>;
51
55
  /** Signs a request without sending it, so the caller can send it through `DeployHostKit.fetch`. */
52
- sign(input: string, init?: RequestInit): Promise<Request>;
56
+ sign(requiredArgs: {
57
+ input: string;
58
+ }, optionalArgs?: {
59
+ init?: RequestInit;
60
+ }): Promise<Request>;
53
61
  }
54
62
  /** Everything a module may call that is not a runtime builtin. The host builds it and passes it in. */
55
63
  export interface DeployHostKit {
56
- /** `fetch`, aborted after `options.timeoutMs`. */
57
- fetch(url: string, init: RequestInit, options: {
58
- readonly timeoutMs: number;
64
+ /** `fetch`, aborted after `requiredArgs.timeoutMs`. */
65
+ fetch(requiredArgs: {
66
+ url: string;
67
+ timeoutMs: number;
68
+ }, optionalArgs?: {
69
+ init?: RequestInit;
59
70
  }): Promise<Response>;
60
71
  readonly timeouts: DeployFetchTimeouts;
61
72
  /** Delay between poll attempts. Injected so a test never waits in real time. */
62
- sleep(ms: number): Promise<void>;
73
+ sleep(requiredArgs: {
74
+ ms: number;
75
+ }): Promise<void>;
63
76
  readonly checkDeploymentUrl: typeof checkDeploymentUrl;
64
77
  readonly waitForReachableDeploymentUrl: typeof waitForReachableDeploymentUrl;
65
78
  readonly normalizeDeploymentUrl: typeof normalizeDeploymentUrl;
@@ -75,7 +88,7 @@ export interface DeployHostKit {
75
88
  }
76
89
  export interface DeployTargetCreateContext {
77
90
  readonly credential: DeployTargetCredential;
78
- readonly config: JsonObject;
91
+ readonly config: UnknownRecord;
79
92
  readonly kit: DeployHostKit;
80
93
  }
81
94
  /**
@@ -105,9 +118,13 @@ export interface DeployCredentialCheckContext {
105
118
  export interface DeployTargetModule {
106
119
  create(context: DeployTargetCreateContext): DeployTarget;
107
120
  /** A human-readable config error, or `null` when `config` is usable. */
108
- validateConfig?(config: JsonObject): string | null;
121
+ validateConfig?(requiredArgs: {
122
+ config: UnknownRecord;
123
+ }): string | null;
109
124
  /** The path prefix the host serves the site from, when it is not the root. */
110
- basePath?(config: JsonObject): string | undefined;
125
+ basePath?(requiredArgs: {
126
+ config: UnknownRecord;
127
+ }): string | undefined;
111
128
  /** One bounded, read-only authenticated request against the host's own API.
112
129
  * May throw: the caller folds any throw into `unreachable`. Never returns
113
130
  * the credential or a response body. */
@@ -4,14 +4,18 @@
4
4
  * verbatim from `apps/daemon/src/deploy.ts`'s `safeProjectLabel` — pure
5
5
  * string logic, no OD dependency to strip.
6
6
  *
7
- * @param raw - Arbitrary caller input (may be empty, non-ASCII, etc).
8
- * @param maxLength - Hard cap on the returned label's length.
7
+ * @param requiredArgs - Arbitrary `raw` input and the required `maxLength` cap.
9
8
  * @returns A label containing only `[a-z0-9-]`, with no leading/trailing/
10
9
  * duplicate hyphens, truncated to `maxLength`.
11
10
  * @complexity O(n) in the length of `raw`.
12
11
  * @overallScore 100/100
13
12
  */
14
- export declare function safeProjectLabel(raw: unknown, maxLength: number): string;
13
+ export declare function safeProjectLabel({ raw, maxLength }: {
14
+ raw: unknown;
15
+ maxLength: number;
16
+ }): string;
15
17
  /** DNS-label-safe variant (63-char cap, the DNS label limit). */
16
- export declare function safeDnsLabel(raw: unknown): string;
18
+ export declare function safeDnsLabel({ raw }: {
19
+ raw: unknown;
20
+ }): string;
17
21
  //# sourceMappingURL=naming.d.ts.map
@@ -4,14 +4,13 @@
4
4
  * verbatim from `apps/daemon/src/deploy.ts`'s `safeProjectLabel` — pure
5
5
  * string logic, no OD dependency to strip.
6
6
  *
7
- * @param raw - Arbitrary caller input (may be empty, non-ASCII, etc).
8
- * @param maxLength - Hard cap on the returned label's length.
7
+ * @param requiredArgs - Arbitrary `raw` input and the required `maxLength` cap.
9
8
  * @returns A label containing only `[a-z0-9-]`, with no leading/trailing/
10
9
  * duplicate hyphens, truncated to `maxLength`.
11
10
  * @complexity O(n) in the length of `raw`.
12
11
  * @overallScore 100/100
13
12
  */
14
- export function safeProjectLabel(raw, maxLength) {
13
+ export function safeProjectLabel({ raw, maxLength }) {
15
14
  return String(raw)
16
15
  .normalize('NFKD')
17
16
  .toLowerCase()
@@ -22,7 +21,7 @@ export function safeProjectLabel(raw, maxLength) {
22
21
  .replace(/-+$/g, '');
23
22
  }
24
23
  /** DNS-label-safe variant (63-char cap, the DNS label limit). */
25
- export function safeDnsLabel(raw) {
26
- return safeProjectLabel(raw, 63);
24
+ export function safeDnsLabel({ raw }) {
25
+ return safeProjectLabel({ raw, maxLength: 63 });
27
26
  }
28
27
  //# sourceMappingURL=naming.js.map
@@ -0,0 +1,18 @@
1
+ import type { lookup } from 'node:dns';
2
+ import type { ReachabilityArgs } from './reachability.js';
3
+ /**
4
+ * Node default for deployment probes: URL rejection plus connection-time DNS validation.
5
+ * The address validated by platform's lookup is the address the socket connects to; a
6
+ * preflight DNS check would permit rebinding between validation and connection (SEC-003).
7
+ * Share the lazily-created default dispatcher to retain connection pooling. A host/test
8
+ * lookup override owns a separate dispatcher and never changes that shared policy.
9
+ * Native fetch remains a framework ABI, including undici's dispatcher extension.
10
+ * Attach the dispatcher as a runtime extension so the @types/node bundled
11
+ * undici-types Dispatcher version need not match the runtime undici Agent.
12
+ * Native fetch uses that Agent's dispatch method; no port casts are needed.
13
+ */
14
+ export declare function createNodeReachabilityPorts(_required: Record<string, never>, options?: {
15
+ fetch?: typeof globalThis.fetch;
16
+ lookupImpl?: typeof lookup;
17
+ }): Pick<ReachabilityArgs, 'fetch' | 'guard'>;
18
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1,57 @@
1
+ import { Agent } from 'undici';
2
+ import { assertSafePublicUrl, createValidatingLookup } from '@jini-ai/platform';
3
+ let defaultDispatcher;
4
+ function isLookupAddress(value) {
5
+ return value !== null && typeof value === 'object' && 'address' in value &&
6
+ typeof value.address === 'string' && 'family' in value && typeof value.family === 'number';
7
+ }
8
+ function createDispatcher(lookupImpl) {
9
+ const validatingLookup = createValidatingLookup(lookupImpl);
10
+ const connectionLookup = (hostname, options, callback) => {
11
+ validatingLookup(hostname, options, (error, address, family) => {
12
+ if (error) {
13
+ callback(error, '');
14
+ return;
15
+ }
16
+ if (typeof address === 'string') {
17
+ callback(null, address, family);
18
+ return;
19
+ }
20
+ if (Array.isArray(address) && address.every(isLookupAddress)) {
21
+ callback(null, address, family);
22
+ return;
23
+ }
24
+ callback(new Error('DNS lookup returned an invalid address'), '');
25
+ });
26
+ };
27
+ return new Agent({ connect: { lookup: connectionLookup } });
28
+ }
29
+ /**
30
+ * Node default for deployment probes: URL rejection plus connection-time DNS validation.
31
+ * The address validated by platform's lookup is the address the socket connects to; a
32
+ * preflight DNS check would permit rebinding between validation and connection (SEC-003).
33
+ * Share the lazily-created default dispatcher to retain connection pooling. A host/test
34
+ * lookup override owns a separate dispatcher and never changes that shared policy.
35
+ * Native fetch remains a framework ABI, including undici's dispatcher extension.
36
+ * Attach the dispatcher as a runtime extension so the @types/node bundled
37
+ * undici-types Dispatcher version need not match the runtime undici Agent.
38
+ * Native fetch uses that Agent's dispatch method; no port casts are needed.
39
+ */
40
+ export function createNodeReachabilityPorts(_required, options = {}) {
41
+ let dispatcher;
42
+ return {
43
+ guard: { assertSafeUrl: ({ raw }) => assertSafePublicUrl(raw) },
44
+ fetch: ({ url }, { init } = {}) => {
45
+ if (options.lookupImpl)
46
+ dispatcher ??= createDispatcher(options.lookupImpl);
47
+ else
48
+ dispatcher = defaultDispatcher ??= createDispatcher();
49
+ const guardedInit = { ...init };
50
+ Object.defineProperty(guardedInit, 'dispatcher', {
51
+ value: dispatcher, enumerable: true, configurable: true, writable: true,
52
+ });
53
+ return (options.fetch ?? globalThis.fetch)(url, guardedInit);
54
+ },
55
+ };
56
+ }
57
+ //# sourceMappingURL=node.js.map
@@ -1,4 +1,3 @@
1
- import { createValidatingLookup } from '@jini-ai/platform';
2
1
  import type { DeployLinkStatus, DeploymentUrlCheck } from './types.js';
3
2
  /**
4
3
  * Provider-supplied hook for recognizing a deployment URL that responded
@@ -7,13 +6,44 @@ import type { DeployLinkStatus, DeploymentUrlCheck } from './types.js';
7
6
  * instead of hardcoding one provider's SSO-nonce/header sniffing here, so
8
7
  * each target can supply its own detector or omit one entirely.
9
8
  */
10
- export type ProtectedResponseDetector = (resp: Response, body: string) => boolean;
9
+ export type ProtectedResponseDetector = (requiredArgs: {
10
+ resp: Response;
11
+ body: string;
12
+ }) => boolean;
13
+ /** Synchronous outbound URL policy, shaped like the OAuth guard without an OAuth dependency.
14
+ * Connection-time DNS enforcement belongs to the paired transport, never a preflight lookup. */
15
+ export interface DeploymentUrlGuard {
16
+ assertSafeUrl(requiredArgs: {
17
+ raw: string;
18
+ label: string;
19
+ }): URL;
20
+ }
21
+ /** HTTP transport port. Hosts must enforce connection-time DNS policy and honor redirects/signals. */
22
+ export type ReachabilityFetchPort = (requiredArgs: {
23
+ url: string;
24
+ }, optionalArgs?: {
25
+ init?: RequestInit;
26
+ }) => Promise<Response>;
27
+ /** The caller supplies the paired URL guard and connection-time policy-enforcing transport. */
28
+ export interface ReachabilityArgs {
29
+ url: unknown;
30
+ fetch: ReachabilityFetchPort;
31
+ guard: DeploymentUrlGuard;
32
+ }
33
+ /** Polling uses host-supplied time and delay ports for deterministic scheduling. */
34
+ export interface ReachabilityWaitArgs {
35
+ urls: unknown[];
36
+ fetch: ReachabilityFetchPort;
37
+ guard: DeploymentUrlGuard;
38
+ now(requiredArgs: Record<string, never>): number;
39
+ sleep(requiredArgs: {
40
+ ms: number;
41
+ }): Promise<void>;
42
+ }
11
43
  export interface ReachabilityOptions {
12
44
  timeoutMs?: number;
13
45
  detectProtected?: ProtectedResponseDetector;
14
46
  protectedMessage?: string;
15
- /** Injectable `dns.lookup` for the connection-time SSRF guard (tests only — see `assertSafeDeploymentUrl`). */
16
- lookupImpl?: Parameters<typeof createValidatingLookup>[0];
17
47
  }
18
48
  export interface ReachabilityWaitOptions {
19
49
  timeoutMs?: number;
@@ -21,8 +51,6 @@ export interface ReachabilityWaitOptions {
21
51
  providerLabel?: string;
22
52
  detectProtected?: ProtectedResponseDetector;
23
53
  protectedMessage?: string;
24
- /** Injectable `dns.lookup` for the connection-time SSRF guard (tests only). */
25
- lookupImpl?: Parameters<typeof createValidatingLookup>[0];
26
54
  }
27
55
  export interface ReachabilityWaitResult {
28
56
  status: DeployLinkStatus;
@@ -34,31 +62,33 @@ export interface ReachabilityWaitResult {
34
62
  * Normalizes a raw provider-returned URL/hostname into an absolute
35
63
  * `https://` URL (bare hostnames like `foo.example.app` are assumed https).
36
64
  *
37
- * @param url - Raw value from a provider response; may be `undefined`/non-string.
65
+ * @param requiredArgs - Raw `url` from a provider response; may be undefined/non-string.
38
66
  * @returns The normalized absolute URL, or `''` if `url` was empty/non-string.
39
67
  * @complexity O(1).
40
68
  * @overallScore 100/100
41
69
  */
42
- export declare function normalizeDeploymentUrl(url: unknown): string;
70
+ export declare function normalizeDeploymentUrl({ url }: {
71
+ url: unknown;
72
+ }): string;
43
73
  /**
44
74
  * Probes a single deployment URL, trying HEAD first and falling back to
45
75
  * GET when HEAD is rejected or ambiguous (some hosts don't implement HEAD
46
76
  * correctly on generated static routes).
47
77
  *
48
- * @param url - Raw URL/hostname from a provider response (normalized internally).
78
+ * @param requiredArgs - Raw URL/hostname and paired fetch and outbound-guard ports.
49
79
  * @param options - Timeout (default 8s) and optional protected-response detector.
50
80
  * @returns A `DeploymentUrlCheck` for the best of the HEAD/GET attempts.
51
81
  * @complexity O(1)-O(2) network round-trips.
52
82
  * @overallScore 100/100
53
83
  */
54
- export declare function checkDeploymentUrl(url: unknown, options?: ReachabilityOptions): Promise<DeploymentUrlCheck>;
84
+ export declare function checkDeploymentUrl({ url, fetch: fetchPort, guard }: ReachabilityArgs, options?: ReachabilityOptions): Promise<DeploymentUrlCheck>;
55
85
  /**
56
86
  * Polls a set of deployment URL candidates until one becomes reachable, one
57
87
  * reports as provider-protected, or `timeoutMs` elapses. Used right after a
58
88
  * publish call returns, since providers frequently accept the deploy before
59
89
  * the URL is actually resolvable.
60
90
  *
61
- * @param urls - Candidate URLs/hostnames in preference order (duplicates and empties are dropped).
91
+ * @param requiredArgs - Candidate URLs/hostnames and required fetch, guard, clock and delay ports.
62
92
  * @param options - `timeoutMs` (default 60s), `intervalMs` between sweeps (default 2s),
63
93
  * `providerLabel` for messages, and the optional protected-response detector.
64
94
  * @returns `{ status, url, statusMessage, reachableAt? }`. `status: 'link-delayed'`
@@ -67,5 +97,5 @@ export declare function checkDeploymentUrl(url: unknown, options?: ReachabilityO
67
97
  * @complexity O(candidates * timeoutMs/intervalMs) network round-trips, bounded by timeoutMs.
68
98
  * @overallScore 100/100
69
99
  */
70
- export declare function waitForReachableDeploymentUrl(urls: unknown[], options?: ReachabilityWaitOptions): Promise<ReachabilityWaitResult>;
100
+ export declare function waitForReachableDeploymentUrl({ urls, fetch: fetchPort, guard, now, sleep }: ReachabilityWaitArgs, options?: ReachabilityWaitOptions): Promise<ReachabilityWaitResult>;
71
101
  //# sourceMappingURL=reachability.d.ts.map