@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.
- package/CHANGELOG.md +120 -0
- package/README.md +62 -2
- package/dist/agent-jobs/entry.d.ts +4 -0
- package/dist/agent-jobs/entry.js +4 -0
- package/dist/agent-jobs/jobs.d.ts +25 -0
- package/dist/agent-jobs/jobs.js +115 -0
- package/dist/agent-jobs/node.d.ts +12 -0
- package/dist/agent-jobs/node.js +53 -0
- package/dist/agent-jobs/ports.d.ts +69 -0
- package/dist/agent-jobs/ports.js +2 -0
- package/dist/checks/coverage/diff.d.ts +57 -0
- package/dist/checks/coverage/diff.js +48 -0
- package/dist/checks/coverage/disk.d.ts +65 -0
- package/dist/checks/coverage/disk.js +136 -0
- package/dist/checks/coverage/floors.d.ts +31 -0
- package/dist/checks/coverage/floors.js +24 -0
- package/dist/checks/coverage/index.d.ts +7 -0
- package/dist/checks/coverage/index.js +6 -0
- package/dist/checks/coverage/integrity.d.ts +79 -0
- package/dist/checks/coverage/integrity.js +140 -0
- package/dist/checks/coverage/lcov.d.ts +65 -0
- package/dist/checks/coverage/lcov.js +64 -0
- package/dist/checks/node.d.ts +19 -0
- package/dist/checks/node.js +40 -0
- package/dist/checks/ports.d.ts +67 -0
- package/dist/checks/ports.js +2 -0
- package/dist/checks/published-types/index.d.ts +77 -0
- package/dist/checks/published-types/index.js +186 -0
- package/dist/deploy/host-kit.d.ts +27 -10
- package/dist/deploy/naming.d.ts +8 -4
- package/dist/deploy/naming.js +4 -5
- package/dist/deploy/node.d.ts +18 -0
- package/dist/deploy/node.js +57 -0
- package/dist/deploy/reachability.d.ts +42 -12
- package/dist/deploy/reachability.js +75 -69
- package/dist/deploy/redirect-guard.d.ts +7 -2
- package/dist/deploy/redirect-guard.js +3 -3
- package/dist/deploy/tokens.d.ts +14 -11
- package/dist/deploy/tokens.js +13 -13
- package/dist/deploy/tool.d.ts +9 -5
- package/dist/deploy/tool.js +5 -6
- package/dist/deploy/types.d.ts +22 -10
- package/dist/deploy/types.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/local-dev/index.d.ts +34 -0
- package/dist/local-dev/index.js +37 -0
- package/dist/packaging/electron/archive.d.ts +41 -0
- package/dist/packaging/electron/archive.js +77 -0
- package/dist/packaging/electron/asar-adapter.d.ts +13 -0
- package/dist/packaging/electron/asar-adapter.js +5 -0
- package/dist/packaging/electron/entry.d.ts +9 -0
- package/dist/packaging/electron/entry.js +9 -0
- package/dist/packaging/electron/imports.d.ts +13 -0
- package/dist/packaging/electron/imports.js +44 -0
- package/dist/packaging/electron/node.d.ts +8 -0
- package/dist/packaging/electron/node.js +51 -0
- package/dist/packaging/electron/policies.d.ts +64 -0
- package/dist/packaging/electron/policies.js +63 -0
- package/dist/packaging/electron/ports.d.ts +113 -0
- package/dist/packaging/electron/ports.js +2 -0
- package/dist/packaging/electron/stability.d.ts +9 -0
- package/dist/packaging/electron/stability.js +12 -0
- package/dist/packaging/electron/staging.d.ts +108 -0
- package/dist/packaging/electron/staging.js +249 -0
- package/dist/packaging/electron/typescript.d.ts +7 -0
- package/dist/packaging/electron/typescript.js +18 -0
- package/dist/source-control/commit.d.ts +11 -0
- package/dist/source-control/commit.js +71 -0
- package/dist/source-control/contracts.d.ts +327 -0
- package/dist/source-control/contracts.js +2 -0
- package/dist/source-control/entry.d.ts +6 -0
- package/dist/source-control/entry.js +6 -0
- package/dist/source-control/kit.d.ts +15 -0
- package/dist/source-control/kit.js +17 -0
- package/dist/source-control/registry.d.ts +100 -0
- package/dist/source-control/registry.js +174 -0
- package/dist/source-control/repository-target.d.ts +13 -0
- package/dist/source-control/repository-target.js +28 -0
- package/dist/static-export/contracts.d.ts +138 -0
- package/dist/static-export/contracts.js +5 -0
- package/dist/static-export/entry.d.ts +6 -0
- package/dist/static-export/entry.js +6 -0
- package/dist/static-export/failure-summary.d.ts +12 -0
- package/dist/static-export/failure-summary.js +12 -0
- package/dist/static-export/fetch-adapter.d.ts +6 -0
- package/dist/static-export/fetch-adapter.js +5 -0
- package/dist/static-export/node-adapters.d.ts +11 -0
- package/dist/static-export/node-adapters.js +111 -0
- package/dist/static-export/runner.d.ts +6 -0
- package/dist/static-export/runner.js +135 -0
- package/dist/static-export/transforms.d.ts +53 -0
- package/dist/static-export/transforms.js +154 -0
- package/package.json +82 -5
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { Agent } from 'undici';
|
|
2
|
-
import { assertSafePublicUrl, AssetCacheError, createValidatingLookup } from '@jini-ai/platform';
|
|
3
1
|
/**
|
|
4
2
|
* SEC-003: reachability probes fetch a *provider-returned* URL/alias
|
|
5
3
|
* (a deployment's `url`/`alias`/`aliases[]` from the host), so a compromised or
|
|
6
4
|
* malicious provider response is a live SSRF vector — the same trust-boundary
|
|
7
|
-
* shape
|
|
8
|
-
* Reused
|
|
5
|
+
* shape the Node default adapter's asset-cache guard solves for a caller-supplied media URL.
|
|
6
|
+
* Reused by `./node.ts` rather than reinvented (see
|
|
9
7
|
* ADS-memory/reports/security/SEC-backend-coverage-push-2026-07-20.md, SEC-003,
|
|
10
8
|
* which cites asset-cache as "a good model for deploy reachability"):
|
|
11
|
-
* `assertSafePublicUrl` fast-rejects bad schemes/credentials/localhost/literal
|
|
9
|
+
* The Node adapter pairs these ports: `assertSafePublicUrl` fast-rejects bad schemes/credentials/localhost/literal
|
|
12
10
|
* private IPs before any socket opens, and `createValidatingLookup` is wired
|
|
13
11
|
* as the fetch dispatcher's connection-time `lookup` so the address that is
|
|
14
12
|
* *validated* is the exact address the socket *connects to* — closing the
|
|
15
13
|
* DNS-rebinding/TOCTOU gap a separate pre-validation lookup would leave open.
|
|
16
14
|
*/
|
|
17
|
-
function assertSafeDeploymentUrl(raw) {
|
|
18
|
-
const url =
|
|
15
|
+
function assertSafeDeploymentUrl(raw, guard) {
|
|
16
|
+
const url = guard.assertSafeUrl({ raw, label: 'deployment url' });
|
|
19
17
|
if (url.protocol !== 'https:') {
|
|
20
18
|
// Deployment providers always serve over TLS; an http:// candidate is
|
|
21
19
|
// never legitimate and downgrading a probe to plaintext is its own risk.
|
|
22
|
-
throw new
|
|
20
|
+
throw new Error('deployment url must use https');
|
|
23
21
|
}
|
|
24
22
|
return url;
|
|
25
23
|
}
|
|
@@ -27,12 +25,12 @@ function assertSafeDeploymentUrl(raw) {
|
|
|
27
25
|
* Normalizes a raw provider-returned URL/hostname into an absolute
|
|
28
26
|
* `https://` URL (bare hostnames like `foo.example.app` are assumed https).
|
|
29
27
|
*
|
|
30
|
-
* @param
|
|
28
|
+
* @param requiredArgs - Raw `url` from a provider response; may be undefined/non-string.
|
|
31
29
|
* @returns The normalized absolute URL, or `''` if `url` was empty/non-string.
|
|
32
30
|
* @complexity O(1).
|
|
33
31
|
* @overallScore 100/100
|
|
34
32
|
*/
|
|
35
|
-
export function normalizeDeploymentUrl(url) {
|
|
33
|
+
export function normalizeDeploymentUrl({ url }) {
|
|
36
34
|
if (typeof url !== 'string')
|
|
37
35
|
return '';
|
|
38
36
|
const trimmed = url.trim();
|
|
@@ -53,71 +51,54 @@ export function normalizeDeploymentUrl(url) {
|
|
|
53
51
|
* @complexity O(1) network round-trip.
|
|
54
52
|
* @overallScore 100/100
|
|
55
53
|
*/
|
|
56
|
-
|
|
57
|
-
// (no test override) case shares one lazily-created dispatcher. A caller-supplied
|
|
58
|
-
// `lookupImpl` (tests only) always gets its own dispatcher instead of touching the shared one.
|
|
59
|
-
let defaultDispatcher = null;
|
|
60
|
-
function resolveDispatcher(lookupImpl) {
|
|
61
|
-
if (lookupImpl) {
|
|
62
|
-
return new Agent({ connect: { lookup: createValidatingLookup(lookupImpl) } });
|
|
63
|
-
}
|
|
64
|
-
defaultDispatcher ??= new Agent({ connect: { lookup: createValidatingLookup() } });
|
|
65
|
-
return defaultDispatcher;
|
|
66
|
-
}
|
|
67
|
-
async function requestDeploymentUrl(url, method, timeoutMs, options) {
|
|
54
|
+
async function requestDeploymentUrl(url, method, timeoutMs, options, fetchPort, guard) {
|
|
68
55
|
let safeUrl;
|
|
69
56
|
try {
|
|
70
|
-
safeUrl = assertSafeDeploymentUrl(url);
|
|
57
|
+
safeUrl = assertSafeDeploymentUrl(url, guard);
|
|
71
58
|
}
|
|
72
59
|
catch (err) {
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
// two throw sources are `assertSafePublicUrl` (which itself only ever
|
|
76
|
-
// throws `AssetCacheError`, per `packages/platform/src/asset-cache.ts` —
|
|
77
|
-
// every one of its conditionals is an explicit `throw new
|
|
78
|
-
// AssetCacheError(...)`, including the `new URL(raw)` parse failure
|
|
79
|
-
// case) and this function's own explicit `throw new AssetCacheError(...)`
|
|
80
|
-
// for a non-https URL. `AssetCacheError extends Error`, so `err` here can
|
|
81
|
-
// only ever be a real `Error` instance. Kept (not simplified to
|
|
82
|
-
// `err.message`) because `err` is typed `unknown`, and a future edit to
|
|
83
|
-
// this function's own throw sites, or to `assertSafePublicUrl`'s, could
|
|
84
|
-
// reintroduce a non-Error throw without this file changing at all — see
|
|
85
|
-
// packages/devops/source-map.md's 2026-07-22 addition for the full
|
|
86
|
-
// re-derivation.
|
|
60
|
+
// Keep unknown throw values readable: host guards may throw values other than Error.
|
|
61
|
+
// The old concrete guard only threw AssetCacheError, but ports cannot assume that contract.
|
|
87
62
|
return {
|
|
88
63
|
reachable: false,
|
|
89
64
|
statusMessage: `Public link is not reachable yet: ${err instanceof Error ? err.message : String(err)}`,
|
|
90
65
|
};
|
|
91
66
|
}
|
|
92
67
|
const controller = new AbortController();
|
|
93
|
-
|
|
68
|
+
let timer;
|
|
69
|
+
// Race the transport as well as signalling it: an injected fetch/body reader may ignore abort.
|
|
70
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
71
|
+
timer = setTimeout(() => {
|
|
72
|
+
reject(new Error(`probe timed out after ${timeoutMs}ms`));
|
|
73
|
+
controller.abort();
|
|
74
|
+
}, timeoutMs);
|
|
75
|
+
});
|
|
94
76
|
// Real refactor, not a padded test: this used to be `try { ... } catch {
|
|
95
77
|
// ... } finally { clearTimeout(timer); }`. A throwaway local repro (see
|
|
96
|
-
//
|
|
78
|
+
// the archived extraction source map's 2026-07-22 addition) proved that V8's own
|
|
97
79
|
// coverage instrumentation for a `try/catch/finally` where the `catch`
|
|
98
80
|
// always returns (never rethrows) emits a synthetic branch, at the
|
|
99
81
|
// `finally` keyword's own position, that no test can ever satisfy — a
|
|
100
82
|
// compiler/instrumentation artifact, not a real code path. Restructuring to
|
|
101
|
-
// `try/catch` with an explicit `clearTimeout(timer)`
|
|
102
|
-
//
|
|
83
|
+
// `try/catch` with an explicit `clearTimeout(timer)` after the complete
|
|
84
|
+
// response (headers and any body read) resolves (covering every path that can reach
|
|
103
85
|
// a return from inside the try) plus one in `catch` (covering the case
|
|
104
86
|
// `fetch` itself rejects, before that clear runs) has 100%-coverable
|
|
105
|
-
// branches
|
|
106
|
-
// every exit from this function either way.
|
|
87
|
+
// branches. That historical refactor preserved runtime behavior — the timer
|
|
88
|
+
// is cleared on every exit from this function either way. The deadline fix
|
|
89
|
+
// additionally keeps it active until body consumption finishes.
|
|
107
90
|
try {
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
// undici-types (bundled with @types/node) vs undici@7 Dispatcher version skew a typed
|
|
111
|
-
// field would trip over.
|
|
91
|
+
// The injected transport owns DNS pinning (the Node adapter attaches its validating dispatcher).
|
|
92
|
+
// A separate preflight resolver would leave the validation/connect TOCTOU gap open.
|
|
112
93
|
const init = { method, redirect: 'manual', signal: controller.signal };
|
|
113
|
-
|
|
114
|
-
const resp = await fetch(safeUrl.toString(), init);
|
|
115
|
-
clearTimeout(timer);
|
|
94
|
+
const resp = await Promise.race([fetchPort({ url: safeUrl.toString() }, { init }), timeout]);
|
|
116
95
|
if (resp.status >= 200 && resp.status < 400) {
|
|
96
|
+
clearTimeout(timer);
|
|
117
97
|
return { reachable: true, statusCode: resp.status };
|
|
118
98
|
}
|
|
119
|
-
const body = method === 'GET' || resp.status === 401 ? await resp.text() : '';
|
|
120
|
-
if (resp.status === 401 && options.detectProtected?.(resp, body)) {
|
|
99
|
+
const body = method === 'GET' || resp.status === 401 ? await Promise.race([resp.text(), timeout]) : '';
|
|
100
|
+
if (resp.status === 401 && options.detectProtected?.({ resp, body })) {
|
|
101
|
+
clearTimeout(timer);
|
|
121
102
|
return {
|
|
122
103
|
reachable: false,
|
|
123
104
|
status: 'protected',
|
|
@@ -125,6 +106,7 @@ async function requestDeploymentUrl(url, method, timeoutMs, options) {
|
|
|
125
106
|
statusMessage: options.protectedMessage ?? 'Deployment is protected by the provider.',
|
|
126
107
|
};
|
|
127
108
|
}
|
|
109
|
+
clearTimeout(timer);
|
|
128
110
|
return {
|
|
129
111
|
reachable: false,
|
|
130
112
|
statusCode: resp.status,
|
|
@@ -144,25 +126,30 @@ async function requestDeploymentUrl(url, method, timeoutMs, options) {
|
|
|
144
126
|
* GET when HEAD is rejected or ambiguous (some hosts don't implement HEAD
|
|
145
127
|
* correctly on generated static routes).
|
|
146
128
|
*
|
|
147
|
-
* @param
|
|
129
|
+
* @param requiredArgs - Raw URL/hostname and paired fetch and outbound-guard ports.
|
|
148
130
|
* @param options - Timeout (default 8s) and optional protected-response detector.
|
|
149
131
|
* @returns A `DeploymentUrlCheck` for the best of the HEAD/GET attempts.
|
|
150
132
|
* @complexity O(1)-O(2) network round-trips.
|
|
151
133
|
* @overallScore 100/100
|
|
152
134
|
*/
|
|
153
|
-
export async function checkDeploymentUrl(url, options = {}) {
|
|
154
|
-
const normalized = normalizeDeploymentUrl(url);
|
|
135
|
+
export async function checkDeploymentUrl({ url, fetch: fetchPort, guard }, options = {}) {
|
|
136
|
+
const normalized = normalizeDeploymentUrl({ url });
|
|
155
137
|
if (!normalized) {
|
|
156
138
|
return { reachable: false, statusMessage: 'Deployment URL is empty.' };
|
|
157
139
|
}
|
|
158
140
|
const timeoutMs = options.timeoutMs ?? 8_000;
|
|
159
|
-
const
|
|
141
|
+
const deadlineAt = Date.now() + timeoutMs;
|
|
142
|
+
const head = await requestDeploymentUrl(normalized, 'HEAD', timeoutMs, options, fetchPort, guard);
|
|
160
143
|
if (head.reachable)
|
|
161
144
|
return head;
|
|
162
145
|
if (head.status === 'protected')
|
|
163
146
|
return head;
|
|
147
|
+
// HEAD and its fallback share one probe budget; do not restart the clock for GET.
|
|
148
|
+
const remainingMs = deadlineAt - Date.now();
|
|
149
|
+
if (remainingMs <= 0)
|
|
150
|
+
return head;
|
|
164
151
|
if (head.statusCode && (head.statusCode === 405 || head.statusCode === 403 || head.statusCode >= 400)) {
|
|
165
|
-
const get = await requestDeploymentUrl(normalized, 'GET',
|
|
152
|
+
const get = await requestDeploymentUrl(normalized, 'GET', remainingMs, options, fetchPort, guard);
|
|
166
153
|
if (get.reachable)
|
|
167
154
|
return get;
|
|
168
155
|
if (get.status === 'protected')
|
|
@@ -177,11 +164,11 @@ export async function checkDeploymentUrl(url, options = {}) {
|
|
|
177
164
|
// remaining `reachable: false` shape (`status: 'protected'`) is already
|
|
178
165
|
// excluded by the `get.status === 'protected'` check just above. So the
|
|
179
166
|
// `: head` fallback branch could never actually be selected — see
|
|
180
|
-
//
|
|
167
|
+
// the archived extraction source map's 2026-07-22 addition for the exhaustive
|
|
181
168
|
// case-by-case proof this was re-derived from.
|
|
182
169
|
return get;
|
|
183
170
|
}
|
|
184
|
-
const get = await requestDeploymentUrl(normalized, 'GET',
|
|
171
|
+
const get = await requestDeploymentUrl(normalized, 'GET', remainingMs, options, fetchPort, guard);
|
|
185
172
|
// Same reasoning as the `get.statusMessage ? get : head` case just above,
|
|
186
173
|
// plus: when `get.reachable` is true, `get` is returned directly regardless
|
|
187
174
|
// (matching the removed ternary's consequent) — so this whole expression
|
|
@@ -195,7 +182,7 @@ export async function checkDeploymentUrl(url, options = {}) {
|
|
|
195
182
|
* publish call returns, since providers frequently accept the deploy before
|
|
196
183
|
* the URL is actually resolvable.
|
|
197
184
|
*
|
|
198
|
-
* @param
|
|
185
|
+
* @param requiredArgs - Candidate URLs/hostnames and required fetch, guard, clock and delay ports.
|
|
199
186
|
* @param options - `timeoutMs` (default 60s), `intervalMs` between sweeps (default 2s),
|
|
200
187
|
* `providerLabel` for messages, and the optional protected-response detector.
|
|
201
188
|
* @returns `{ status, url, statusMessage, reachableAt? }`. `status: 'link-delayed'`
|
|
@@ -204,9 +191,9 @@ export async function checkDeploymentUrl(url, options = {}) {
|
|
|
204
191
|
* @complexity O(candidates * timeoutMs/intervalMs) network round-trips, bounded by timeoutMs.
|
|
205
192
|
* @overallScore 100/100
|
|
206
193
|
*/
|
|
207
|
-
export async function waitForReachableDeploymentUrl(urls, options = {}) {
|
|
194
|
+
export async function waitForReachableDeploymentUrl({ urls, fetch: fetchPort, guard, now, sleep }, options = {}) {
|
|
208
195
|
const { timeoutMs = 60_000, intervalMs = 2_000, providerLabel = 'Deployment provider' } = options;
|
|
209
|
-
const candidates = [...new Set((urls || []).map(normalizeDeploymentUrl).filter(Boolean))];
|
|
196
|
+
const candidates = [...new Set((urls || []).map((url) => normalizeDeploymentUrl({ url })).filter(Boolean))];
|
|
210
197
|
const fallbackUrl = candidates[0] || '';
|
|
211
198
|
if (!fallbackUrl) {
|
|
212
199
|
return {
|
|
@@ -215,13 +202,16 @@ export async function waitForReachableDeploymentUrl(urls, options = {}) {
|
|
|
215
202
|
statusMessage: `${providerLabel} did not return a public deployment URL.`,
|
|
216
203
|
};
|
|
217
204
|
}
|
|
218
|
-
const startedAt =
|
|
205
|
+
const startedAt = now({});
|
|
219
206
|
let lastMessage = '';
|
|
220
|
-
while (
|
|
207
|
+
while (now({}) - startedAt < timeoutMs) {
|
|
221
208
|
for (const url of candidates) {
|
|
222
|
-
const
|
|
209
|
+
const remainingMs = timeoutMs - (now({}) - startedAt);
|
|
210
|
+
if (remainingMs <= 0)
|
|
211
|
+
break;
|
|
212
|
+
const result = await checkDeploymentUrl({ url, fetch: fetchPort, guard }, { ...options, timeoutMs: Math.min(options.timeoutMs ?? 8_000, remainingMs) });
|
|
223
213
|
if (result.reachable) {
|
|
224
|
-
return { status: 'ready', url, statusMessage: 'Public link is ready.', reachableAt:
|
|
214
|
+
return { status: 'ready', url, statusMessage: 'Public link is ready.', reachableAt: now({}) };
|
|
225
215
|
}
|
|
226
216
|
if (result.status === 'protected') {
|
|
227
217
|
return {
|
|
@@ -240,16 +230,18 @@ export async function waitForReachableDeploymentUrl(urls, options = {}) {
|
|
|
240
230
|
// handled by the two `return`s directly above this line, so neither
|
|
241
231
|
// can reach here. `|| lastMessage` (falling back to the *previous*
|
|
242
232
|
// sweep's message) could therefore never actually be selected — see
|
|
243
|
-
//
|
|
233
|
+
// the archived extraction source map's 2026-07-22 addition for the proof.
|
|
244
234
|
// Non-null assertion (not `||`/`??`, which would just reintroduce the
|
|
245
235
|
// same dead branch): the type is `string | undefined` because
|
|
246
236
|
// `DeploymentUrlCheck.statusMessage` is optional in general, but this
|
|
247
237
|
// exact call site's result is always defined per the proof above.
|
|
248
238
|
lastMessage = result.statusMessage;
|
|
249
239
|
}
|
|
250
|
-
|
|
240
|
+
const remainingMs = timeoutMs - (now({}) - startedAt);
|
|
241
|
+
if (remainingMs <= 0)
|
|
242
|
+
break;
|
|
243
|
+
if (!await sleepWithinBudget({ sleep, ms: Math.min(intervalMs, remainingMs), timeoutMs: remainingMs }))
|
|
251
244
|
break;
|
|
252
|
-
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
253
245
|
}
|
|
254
246
|
return {
|
|
255
247
|
status: 'link-delayed',
|
|
@@ -257,4 +249,18 @@ export async function waitForReachableDeploymentUrl(urls, options = {}) {
|
|
|
257
249
|
statusMessage: lastMessage || `${providerLabel} returned a deployment URL, but it is not reachable yet.`,
|
|
258
250
|
};
|
|
259
251
|
}
|
|
252
|
+
/** An injected delay can stall too; its completion cannot extend the whole polling deadline.
|
|
253
|
+
* @complexity O(1) time and space apart from the host's delay implementation. */
|
|
254
|
+
async function sleepWithinBudget({ sleep, ms, timeoutMs }) {
|
|
255
|
+
let timer;
|
|
256
|
+
try {
|
|
257
|
+
return await Promise.race([
|
|
258
|
+
sleep({ ms }).then(() => true),
|
|
259
|
+
new Promise((resolve) => { timer = setTimeout(() => resolve(false), timeoutMs); }),
|
|
260
|
+
]);
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
clearTimeout(timer);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
260
266
|
//# sourceMappingURL=reachability.js.map
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
* keeps this correct even if a future runtime implements manual mode differently).
|
|
19
19
|
*/
|
|
20
20
|
/** Adds `redirect: 'manual'` to `init` without mutating the caller's object. */
|
|
21
|
-
export declare function redirectGuardInit(init
|
|
21
|
+
export declare function redirectGuardInit({ init }: {
|
|
22
|
+
init: RequestInit;
|
|
23
|
+
}): RequestInit;
|
|
22
24
|
/**
|
|
23
25
|
* @throws {DeployError} `resp` is an opaque-redirect filtered response (the server tried to
|
|
24
26
|
* redirect this authenticated request elsewhere). Call immediately after every guarded
|
|
@@ -28,5 +30,8 @@ export declare function redirectGuardInit(init: RequestInit): RequestInit;
|
|
|
28
30
|
* `404` — but call ordering here still matters for every OTHER status-sensitive branch in
|
|
29
31
|
* a target.
|
|
30
32
|
*/
|
|
31
|
-
export declare function assertNotRedirected(resp
|
|
33
|
+
export declare function assertNotRedirected({ resp, providerLabel }: {
|
|
34
|
+
resp: Response;
|
|
35
|
+
providerLabel: string;
|
|
36
|
+
}): void;
|
|
32
37
|
//# sourceMappingURL=redirect-guard.d.ts.map
|
|
@@ -19,7 +19,7 @@ import { DeployError } from './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 }) {
|
|
23
23
|
return { ...init, redirect: 'manual' };
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
@@ -31,9 +31,9 @@ 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 }) {
|
|
35
35
|
if (resp.type === 'opaqueredirect' || (resp.status >= 300 && resp.status < 400)) {
|
|
36
|
-
throw new DeployError(`${providerLabel} attempted to redirect an authenticated request — refused to follow it (possible credential-leak vector)
|
|
36
|
+
throw new DeployError({ message: `${providerLabel} attempted to redirect an authenticated request — refused to follow it (possible credential-leak vector).` }, { status: 502 });
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
//# sourceMappingURL=redirect-guard.js.map
|
package/dist/deploy/tokens.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DeployFile, type DeployPublishResult, type DeployTarget, type
|
|
1
|
+
import { type DeployFile, type DeployPublishOptions, type DeployPublishResult, type DeployTarget, type UnknownRecord } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Many-bound composition token for deploy providers, per extraction-plan.md
|
|
4
4
|
* §2.2's own worked example (`DeployTarget = manyToken<DeployProvider>
|
|
@@ -24,34 +24,37 @@ export interface DeployPublishToolInput {
|
|
|
24
24
|
targetId: string;
|
|
25
25
|
files: DeployFile[];
|
|
26
26
|
projectName: string;
|
|
27
|
-
metadata?:
|
|
27
|
+
metadata?: UnknownRecord;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* `deploy.publish` as a plain async function.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* task 6, §2.5)
|
|
32
|
+
* Tool wiring is implemented by `createDeployPublishToolRegistration` in
|
|
33
|
+
* `tool.ts`, using `@jini-ai/core`'s `ToolRegistry` and `@jini-ai/daemon`'s
|
|
34
|
+
* `ToolExecutor` (extraction-plan.md §8 task 6, §2.5). The registration shape is:
|
|
35
35
|
*
|
|
36
36
|
* ```ts
|
|
37
37
|
* toolRegistry.register({
|
|
38
38
|
* descriptor: { id: 'deploy.publish', ... },
|
|
39
|
-
* handler: (
|
|
39
|
+
* handler: (ctx) => publishDeploy({ ...ctx.input, targets }),
|
|
40
40
|
* policy: { ... }, // e.g. requires confirmation before an external publish
|
|
41
41
|
* });
|
|
42
42
|
* ```
|
|
43
43
|
*
|
|
44
44
|
* so callers only ever reach it through `ToolExecutor.execute(principal,
|
|
45
45
|
* run, 'deploy.publish', input, signal)` — never by holding a direct
|
|
46
|
-
* reference to a handler.
|
|
47
|
-
*
|
|
46
|
+
* reference to a handler. This plain function remains available to trusted
|
|
47
|
+
* composition code; routes and agents use the registration so they cannot
|
|
48
|
+
* bypass authorization and the audit trail. The registration denies by default.
|
|
48
49
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
50
|
+
* @param requiredArgs - Target id, file set, project name and injected bound targets.
|
|
51
|
+
* @param options - Optional metadata and response headers forwarded to the selected target.
|
|
51
52
|
* @returns The chosen target's publish result.
|
|
52
53
|
* @throws {DeployError} (status 404) if no bound target matches `input.targetId`.
|
|
53
54
|
* @complexity O(targets) to find the match, then whatever the target's own `publish` costs.
|
|
54
55
|
* @overallScore 100/100
|
|
55
56
|
*/
|
|
56
|
-
export declare function publishDeploy(input: DeployPublishToolInput,
|
|
57
|
+
export declare function publishDeploy({ targets, ...input }: Omit<DeployPublishToolInput, 'metadata'> & {
|
|
58
|
+
targets: readonly DeployTarget[];
|
|
59
|
+
}, options?: DeployPublishOptions): Promise<DeployPublishResult>;
|
|
57
60
|
//# sourceMappingURL=tokens.d.ts.map
|
package/dist/deploy/tokens.js
CHANGED
|
@@ -16,43 +16,43 @@ import { DeployError } from './types.js';
|
|
|
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
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* task 6, §2.5)
|
|
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: (
|
|
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.
|
|
38
|
-
*
|
|
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
|
|
41
|
-
* @param
|
|
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,
|
|
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}
|
|
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
|
-
|
|
56
|
-
});
|
|
56
|
+
}, options);
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=tokens.js.map
|
package/dist/deploy/tool.d.ts
CHANGED
|
@@ -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
|
|
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
|
*
|
|
@@ -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?:
|
|
74
|
-
|
|
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
|
|
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(
|
|
107
|
+
export declare function createDeployPublishToolRegistration({ targets }: CreateDeployPublishToolRegistrationArgs, { policy, requiresConfirmation, timeoutMs }?: CreateDeployPublishToolRegistrationOptions): ToolRegistration;
|
|
104
108
|
//# sourceMappingURL=tool.d.ts.map
|
package/dist/deploy/tool.js
CHANGED
|
@@ -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,14 +75,13 @@ 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
|
|
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(
|
|
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,
|
|
@@ -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
|
}
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
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
|
|
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
|
-
/**
|
|
10
|
-
export type
|
|
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
|
*
|
|
@@ -38,7 +38,8 @@ 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.
|
|
41
|
+
* project/deployment name. In the separate optional-arguments object,
|
|
42
|
+
* `metadata` is an escape hatch for target-specific
|
|
42
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.
|
|
@@ -51,7 +52,10 @@ export interface DeploymentUrlCheck {
|
|
|
51
52
|
export interface DeployPublishInput {
|
|
52
53
|
files: DeployFile[];
|
|
53
54
|
projectName: string;
|
|
54
|
-
|
|
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. */
|
|
@@ -65,7 +69,7 @@ export interface DeployPublishResult {
|
|
|
65
69
|
statusMessage?: string;
|
|
66
70
|
reachableAt?: number;
|
|
67
71
|
/** Target-specific extras (e.g. a custom-domain/DNS outcome). */
|
|
68
|
-
providerMetadata?:
|
|
72
|
+
providerMetadata?: UnknownRecord;
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
71
75
|
* The port every deploy provider implements. Bound many-to-one against the
|
|
@@ -75,10 +79,12 @@ export interface DeployPublishResult {
|
|
|
75
79
|
*/
|
|
76
80
|
export interface DeployTarget {
|
|
77
81
|
readonly id: string;
|
|
78
|
-
publish(
|
|
79
|
-
checkReachability(
|
|
82
|
+
publish(requiredArgs: DeployPublishInput, optionalArgs?: DeployPublishOptions): Promise<DeployPublishResult>;
|
|
83
|
+
checkReachability(requiredArgs: {
|
|
84
|
+
url: string;
|
|
85
|
+
}): Promise<DeploymentUrlCheck>;
|
|
80
86
|
}
|
|
81
|
-
export type DeployErrorDetails =
|
|
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:
|
|
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
|
package/dist/deploy/types.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
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
|
|
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 =
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|