stitchkit 0.136.3 → 0.136.5
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 +14 -0
- package/dist/browser/http-fetch.d.ts +6 -0
- package/dist/browser/http-fetch.d.ts.map +1 -1
- package/dist/browser/http-helpers.d.ts +21 -0
- package/dist/browser/http-helpers.d.ts.map +1 -1
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +5 -5
- package/dist/entrypoints/agent-executor/claude-sdk.js +7 -7
- package/dist/entrypoints/agent-executor/claude.js +7 -7
- package/dist/entrypoints/agent-executor/codex.js +9 -9
- package/dist/entrypoints/agent-executor/testing.js +9 -9
- package/dist/entrypoints/agent-executor.js +5 -5
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
- package/dist/entrypoints/agent-runtime/postgres.js +4 -4
- package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
- package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
- package/dist/entrypoints/agent-runtime/testing.js +4 -4
- package/dist/entrypoints/agent-runtime.js +4 -4
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +7 -7
- package/dist/entrypoints/cli/publish.d.ts +14 -6
- package/dist/entrypoints/cli/publish.d.ts.map +1 -1
- package/dist/entrypoints/cli/publish.js +685 -30
- package/dist/entrypoints/cli.js +7 -124
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/files.d.ts +1 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +9 -9
- package/dist/entrypoints/http.js +3 -3
- package/dist/entrypoints/index.js +3 -3
- package/dist/entrypoints/node.js +3 -3
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process.js +3 -3
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +2 -2
- package/dist/entrypoints/server.js +6 -6
- package/dist/entrypoints/service-host/macos.js +7 -7
- package/dist/entrypoints/service-host/work.js +6 -6
- package/dist/entrypoints/service-host.js +9 -9
- package/dist/entrypoints/spend.js +1 -1
- package/dist/entrypoints/telegram.js +3 -3
- package/dist/entrypoints/testing.js +2 -2
- package/dist/entrypoints/tools.js +1 -1
- package/dist/{index-05b65gj4.js → index-0s75mjh7.js} +1 -1
- package/dist/{index-s2e3h616.js → index-150b1qyw.js} +10 -1
- package/dist/{index-tcv71frn.js → index-1fhbe4e4.js} +1 -1
- package/dist/{index-8cek82ar.js → index-1h0dtfz3.js} +1 -1
- package/dist/{index-jwtmw39p.js → index-2qnqvq11.js} +1 -1
- package/dist/index-2rs7ze0q.js +376 -0
- package/dist/{index-2wm9b9vs.js → index-3cwq5byx.js} +2 -2
- package/dist/{index-mtpcax6d.js → index-5md04mwc.js} +3 -3
- package/dist/{index-b0mh2t9x.js → index-67mzzkdv.js} +3 -3
- package/dist/{index-nne3yxew.js → index-6f4fjygr.js} +1 -1
- package/dist/{index-d5mhgx72.js → index-8tn10tp6.js} +1 -1
- package/dist/{index-rw31t8sj.js → index-9fzjgg86.js} +1 -1
- package/dist/{index-0sxj3y45.js → index-afaq0nc4.js} +1 -1
- package/dist/{index-nfm15ej7.js → index-bbpygynk.js} +1 -1
- package/dist/{index-g04hszcm.js → index-chapre0y.js} +1 -1
- package/dist/{index-vh4291qh.js → index-ctaxjpa4.js} +1 -1
- package/dist/{index-mhgkzwxz.js → index-d01akj5n.js} +134 -25
- package/dist/{index-x1r7kxzd.js → index-e4zt2x70.js} +3 -3
- package/dist/{index-s0n0nnz5.js → index-f103md2v.js} +122 -3
- package/dist/{index-2c5w2d1d.js → index-gyfsh29t.js} +1 -1
- package/dist/{index-kgkevngs.js → index-kadgaw1s.js} +4 -4
- package/dist/{index-ca1v40d3.js → index-kd48gk7d.js} +1 -1
- package/dist/{index-ke6jtxkd.js → index-mr3njw67.js} +1 -1
- package/dist/{index-cmqvf0dz.js → index-ppy23bd2.js} +1 -1
- package/dist/{index-43k180c2.js → index-rnhp7je8.js} +2 -2
- package/dist/{index-2tgmggcm.js → index-smvmnz5y.js} +1 -1
- package/dist/{index-9m1m92rg.js → index-tjhhsnjv.js} +1 -1
- package/dist/{index-64t6pheq.js → index-w161azza.js} +1 -1
- package/dist/{index-mttkdm5a.js → index-xqppqn97.js} +1 -1
- package/dist/{index-sjq4akrx.js → index-xsrma0jd.js} +2 -2
- package/dist/{index-zqc64g69.js → index-ypm85xwe.js} +1 -1
- package/dist/{index-zagc12j1.js → index-zcq3dby3.js} +1 -1
- package/dist/{index-29v1p1f4.js → index-zhngww7q.js} +1 -1
- package/dist/internal/atomic-file-owner.d.ts +91 -0
- package/dist/internal/atomic-file-owner.d.ts.map +1 -0
- package/dist/internal/atomic-file.d.ts +29 -7
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/bounded-file-read.d.ts +6 -2
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/tools/cli/distribution-config.d.ts +56 -0
- package/dist/tools/cli/distribution-config.d.ts.map +1 -0
- package/dist/tools/cli/distribution-routes.d.ts +20 -0
- package/dist/tools/cli/distribution-routes.d.ts.map +1 -0
- package/dist/tools/cli/publication-source.d.ts +77 -0
- package/dist/tools/cli/publication-source.d.ts.map +1 -0
- package/llms/cli-publish.txt +15 -3
- package/llms/cli.2.txt +84 -63
- package/llms/cli.3.txt +67 -1
- package/llms/cli.txt +1 -1
- package/llms/files.txt +1 -1
- package/llms/process.txt +24 -4
- package/llms/stitchkit.txt +11 -3
- package/llms-full.txt +134 -11
- package/llms.txt +5 -5
- package/package.json +1 -1
- package/dist/index-pp97q86a.js +0 -221
- package/dist/{index-5c4m8zdf.js → index-tjakdpf2.js} +45 -45
|
@@ -14,11 +14,15 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
utf8ByteLength
|
|
16
16
|
} from "./index-f16b7rze.js";
|
|
17
|
+
import {
|
|
18
|
+
assertNonNegativeSafeInteger
|
|
19
|
+
} from "./index-gr0kxymw.js";
|
|
17
20
|
import {
|
|
18
21
|
assertTimerMs
|
|
19
22
|
} from "./index-e1y74yra.js";
|
|
20
23
|
import {
|
|
21
24
|
abortReason,
|
|
25
|
+
untilAborted,
|
|
22
26
|
linkAbortSignals
|
|
23
27
|
} from "./index-rptj3qnc.js";
|
|
24
28
|
import {
|
|
@@ -30,6 +34,87 @@ import {
|
|
|
30
34
|
} from "./index-ps3djm8d.js";
|
|
31
35
|
|
|
32
36
|
// src/browser/http-fetch.ts
|
|
37
|
+
function buildMaterializedInit(input, init, headers, signal, body, unix) {
|
|
38
|
+
const materialized = {
|
|
39
|
+
...init,
|
|
40
|
+
...unix !== undefined && { unix },
|
|
41
|
+
method: init?.method ?? input.method,
|
|
42
|
+
headers,
|
|
43
|
+
...body !== undefined && { body },
|
|
44
|
+
cache: init?.cache ?? input.cache,
|
|
45
|
+
credentials: init?.credentials ?? input.credentials,
|
|
46
|
+
integrity: init?.integrity ?? input.integrity,
|
|
47
|
+
keepalive: init?.keepalive ?? input.keepalive,
|
|
48
|
+
mode: init?.mode ?? input.mode,
|
|
49
|
+
redirect: init?.redirect ?? input.redirect,
|
|
50
|
+
referrer: init?.referrer ?? input.referrer,
|
|
51
|
+
referrerPolicy: init?.referrerPolicy ?? input.referrerPolicy,
|
|
52
|
+
...signal !== undefined && { signal }
|
|
53
|
+
};
|
|
54
|
+
if (init?.body === undefined && "duplex" in materialized) {
|
|
55
|
+
Reflect.deleteProperty(materialized, "duplex");
|
|
56
|
+
}
|
|
57
|
+
return materialized;
|
|
58
|
+
}
|
|
59
|
+
function concatChunks(chunks, totalBytes) {
|
|
60
|
+
if (totalBytes === 0)
|
|
61
|
+
return new ArrayBuffer(0);
|
|
62
|
+
if (chunks.length === 1) {
|
|
63
|
+
const [only] = chunks;
|
|
64
|
+
if (only) {
|
|
65
|
+
if (only.byteOffset === 0 && only.byteLength === only.buffer.byteLength && only.buffer instanceof ArrayBuffer) {
|
|
66
|
+
return only.buffer;
|
|
67
|
+
}
|
|
68
|
+
return only.slice().buffer;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const merged = new Uint8Array(totalBytes);
|
|
72
|
+
let offset = 0;
|
|
73
|
+
for (const chunk of chunks) {
|
|
74
|
+
merged.set(chunk, offset);
|
|
75
|
+
offset += chunk.byteLength;
|
|
76
|
+
}
|
|
77
|
+
return merged.buffer;
|
|
78
|
+
}
|
|
79
|
+
async function readRequestBodyBytes(input, signal) {
|
|
80
|
+
if (!signal || !input.body)
|
|
81
|
+
return input.arrayBuffer();
|
|
82
|
+
const reader = input.body.getReader();
|
|
83
|
+
const chunks = [];
|
|
84
|
+
let totalBytes = 0;
|
|
85
|
+
let cancelled = false;
|
|
86
|
+
try {
|
|
87
|
+
for (;; ) {
|
|
88
|
+
const outcome = await untilAborted(reader.read(), signal);
|
|
89
|
+
if (outcome.aborted) {
|
|
90
|
+
cancelled = true;
|
|
91
|
+
reader.cancel(abortReason(signal)).catch(() => {
|
|
92
|
+
return;
|
|
93
|
+
}).finally(() => {
|
|
94
|
+
try {
|
|
95
|
+
reader.releaseLock();
|
|
96
|
+
} catch {}
|
|
97
|
+
});
|
|
98
|
+
throw abortReason(signal);
|
|
99
|
+
}
|
|
100
|
+
if (outcome.value.done)
|
|
101
|
+
return concatChunks(chunks, totalBytes);
|
|
102
|
+
chunks.push(outcome.value.value);
|
|
103
|
+
totalBytes += outcome.value.value.byteLength;
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
if (!cancelled) {
|
|
107
|
+
try {
|
|
108
|
+
reader.releaseLock();
|
|
109
|
+
} catch {}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function dispatchMaterializedBody(runtimeFetch, input, init, signal, unix) {
|
|
114
|
+
const headers = init?.headers !== undefined ? new Headers(init.headers) : new Headers(input.headers);
|
|
115
|
+
const body = await readRequestBodyBytes(input, signal);
|
|
116
|
+
return runtimeFetch(input.url, buildMaterializedInit(input, init, headers, signal, body, unix));
|
|
117
|
+
}
|
|
33
118
|
function createRetryAwareFetch(transportFetch, unix) {
|
|
34
119
|
const runtimeFetch = transportFetch;
|
|
35
120
|
let attempt = 0;
|
|
@@ -44,24 +129,15 @@ function createRetryAwareFetch(transportFetch, unix) {
|
|
|
44
129
|
const unixInit = { ...init, unix };
|
|
45
130
|
return runtimeFetch(input, unixInit);
|
|
46
131
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
integrity: input.integrity,
|
|
57
|
-
keepalive: input.keepalive,
|
|
58
|
-
mode: input.mode,
|
|
59
|
-
redirect: input.redirect,
|
|
60
|
-
referrer: input.referrer,
|
|
61
|
-
referrerPolicy: input.referrerPolicy,
|
|
62
|
-
signal: input.signal
|
|
63
|
-
};
|
|
64
|
-
return runtimeFetch(input.url, materialized);
|
|
132
|
+
if (unix === undefined && input.body === undefined) {
|
|
133
|
+
return runtimeFetch(input, init);
|
|
134
|
+
}
|
|
135
|
+
const signal = init?.signal !== undefined ? init.signal : input.signal;
|
|
136
|
+
if (init?.body === undefined && input.body !== null && input.body !== undefined && !signal?.aborted) {
|
|
137
|
+
return dispatchMaterializedBody(runtimeFetch, input, init, signal, unix);
|
|
138
|
+
}
|
|
139
|
+
const headers = init?.headers !== undefined ? new Headers(init.headers) : new Headers(input.headers);
|
|
140
|
+
return runtimeFetch(input.url, buildMaterializedInit(input, init, headers, signal, undefined, unix));
|
|
65
141
|
};
|
|
66
142
|
}
|
|
67
143
|
function searchParamsOf(params) {
|
|
@@ -220,6 +296,37 @@ function responseTraceId(response) {
|
|
|
220
296
|
}
|
|
221
297
|
|
|
222
298
|
// src/browser/http-helpers.ts
|
|
299
|
+
var DEFAULT_RETRY_METHODS = ["get", "head"];
|
|
300
|
+
function normalizeClientRetryConfig(retry) {
|
|
301
|
+
if (retry !== undefined && (typeof retry !== "object" || retry === null || Array.isArray(retry))) {
|
|
302
|
+
throw new TypeError("HttpClientConfig.retry must be an object");
|
|
303
|
+
}
|
|
304
|
+
assertNonNegativeSafeInteger("HttpClientConfig.retry.limit", retry?.limit);
|
|
305
|
+
const limit = retry?.limit ?? 2;
|
|
306
|
+
const rawMethods = retry?.methods ?? DEFAULT_RETRY_METHODS;
|
|
307
|
+
if (!Array.isArray(rawMethods) || !rawMethods.every((entry) => typeof entry === "string")) {
|
|
308
|
+
throw new TypeError("HttpClientConfig.retry.methods must be an array of strings");
|
|
309
|
+
}
|
|
310
|
+
const methods = rawMethods.map((entry) => entry.toLowerCase());
|
|
311
|
+
const rawStatusCodes = retry?.statusCodes ?? [];
|
|
312
|
+
if (!Array.isArray(rawStatusCodes) || !rawStatusCodes.every((code) => Number.isSafeInteger(code))) {
|
|
313
|
+
throw new TypeError("HttpClientConfig.retry.statusCodes must be an array of integers");
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
limit,
|
|
317
|
+
methods,
|
|
318
|
+
methodSet: new Set(methods),
|
|
319
|
+
statusCodes: [...rawStatusCodes]
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function resolveCallRetry(retry, method, idempotent) {
|
|
323
|
+
const methodRetries = idempotent ?? retry.methodSet.has(method);
|
|
324
|
+
if (!methodRetries)
|
|
325
|
+
return { limit: 0 };
|
|
326
|
+
if (idempotent === true)
|
|
327
|
+
return { methods: [method] };
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
223
330
|
function assertTransportChoice(config) {
|
|
224
331
|
if (config.fetch && config.unix) {
|
|
225
332
|
throw new TypeError("HttpClientConfig.fetch and unix are mutually exclusive");
|
|
@@ -564,6 +671,7 @@ function resolveOutboundDeadlineAt(options, config, effectiveTimeoutMs) {
|
|
|
564
671
|
function createHttpClient2(config) {
|
|
565
672
|
assertTransportChoice(config);
|
|
566
673
|
assertTimerMs("HTTP client timeout", config.timeout);
|
|
674
|
+
const retryConfig = normalizeClientRetryConfig(config.retry);
|
|
567
675
|
let ssrCookies = null;
|
|
568
676
|
let isLoggedOut = false;
|
|
569
677
|
const listeners = new Set;
|
|
@@ -581,9 +689,9 @@ function createHttpClient2(config) {
|
|
|
581
689
|
credentials: config.credentials ?? "include",
|
|
582
690
|
timeout: false,
|
|
583
691
|
retry: {
|
|
584
|
-
limit:
|
|
585
|
-
methods:
|
|
586
|
-
statusCodes:
|
|
692
|
+
limit: retryConfig.limit,
|
|
693
|
+
methods: [...retryConfig.methods],
|
|
694
|
+
statusCodes: [...retryConfig.statusCodes],
|
|
587
695
|
shouldRetry: ({ error }) => shouldRetryBunNetworkError(error)
|
|
588
696
|
},
|
|
589
697
|
hooks: {
|
|
@@ -653,20 +761,21 @@ function createHttpClient2(config) {
|
|
|
653
761
|
throw cause;
|
|
654
762
|
});
|
|
655
763
|
};
|
|
764
|
+
const isFormData = typeof FormData === "function" && data instanceof FormData;
|
|
765
|
+
const callRetry = resolveCallRetry(retryConfig, method, options.idempotent);
|
|
656
766
|
const kyOptions = {
|
|
657
767
|
fetch: createRetryAwareFetch(options.onUploadProgress ? withUploadProgress(transport, options.onUploadProgress, {
|
|
658
768
|
route: uploadProgressRoute(config.fetch !== undefined || config.unix !== undefined),
|
|
659
|
-
nativeBody:
|
|
769
|
+
nativeBody: isFormData ? data : jsonBodyOf(data),
|
|
660
770
|
responseType: options.responseType
|
|
661
771
|
}) : transport, config.unix),
|
|
662
772
|
timeout: false,
|
|
663
|
-
...
|
|
664
|
-
...options.idempotent === false && { retry: { limit: 0 } }
|
|
773
|
+
...callRetry !== undefined && { retry: callRetry }
|
|
665
774
|
};
|
|
666
775
|
const searchParams = options.params ? searchParamsOf(options.params) : undefined;
|
|
667
776
|
if (searchParams)
|
|
668
777
|
kyOptions.searchParams = searchParams;
|
|
669
|
-
if (
|
|
778
|
+
if (isFormData) {
|
|
670
779
|
kyOptions.body = data;
|
|
671
780
|
} else if (data !== undefined) {
|
|
672
781
|
kyOptions.json = data;
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
writeAllBytes,
|
|
10
10
|
writeAtomicFileStaged
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-2rs7ze0q.js";
|
|
12
12
|
import {
|
|
13
13
|
AtomicFilePublicationError2
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-gyfsh29t.js";
|
|
15
15
|
import {
|
|
16
16
|
BoundedFileReadError,
|
|
17
17
|
readBoundedFile
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-150b1qyw.js";
|
|
19
19
|
import {
|
|
20
20
|
errnoOf
|
|
21
21
|
} from "./index-jj9228tt.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ExclusiveLockError2,
|
|
3
3
|
withExclusiveLock2
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-zhngww7q.js";
|
|
5
5
|
import {
|
|
6
6
|
writeFileAtomicSync2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-2rs7ze0q.js";
|
|
8
8
|
import {
|
|
9
9
|
fetchGuarded,
|
|
10
10
|
PrivateAddressRefusal,
|
|
@@ -24,6 +24,125 @@ import {
|
|
|
24
24
|
raceAbort
|
|
25
25
|
} from "./index-rptj3qnc.js";
|
|
26
26
|
|
|
27
|
+
// src/tools/cli/installer.ts
|
|
28
|
+
function shellQuote(value) {
|
|
29
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
30
|
+
}
|
|
31
|
+
function renderCliInstaller2(config) {
|
|
32
|
+
const binary = config.binaryName ?? config.manifest.name;
|
|
33
|
+
const installDir = config.installDir ?? "$HOME/.local/bin";
|
|
34
|
+
const assets = config.asset ? [config.asset] : config.manifest.assets;
|
|
35
|
+
if (assets.length === 0) {
|
|
36
|
+
throw new Error("[stitchkit] a build manifest with no assets installs nothing");
|
|
37
|
+
}
|
|
38
|
+
const selection = assets.length === 1 && assets[0] !== undefined ? singleTarget(assets[0]) : unameDispatch(assets);
|
|
39
|
+
return `#!/bin/sh
|
|
40
|
+
# ${binary} ${config.manifest.version} (${config.manifest.commit})
|
|
41
|
+
# Generated from the build manifest — it parses no JSON and needs no jq.
|
|
42
|
+
set -eu
|
|
43
|
+
|
|
44
|
+
binary=${shellQuote(binary)}
|
|
45
|
+
dir="\${INSTALL_DIR:-${installDir}}"
|
|
46
|
+
|
|
47
|
+
${selection}
|
|
48
|
+
|
|
49
|
+
fetch() {
|
|
50
|
+
if command -v curl >/dev/null 2>&1; then
|
|
51
|
+
curl -fsSL "$1" -o "$2"
|
|
52
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
53
|
+
wget -q "$1" -O "$2"
|
|
54
|
+
else
|
|
55
|
+
echo "need curl or wget" >&2
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
digest() {
|
|
61
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
62
|
+
sha256sum "$1" | cut -d' ' -f1
|
|
63
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
64
|
+
shasum -a 256 "$1" | cut -d' ' -f1
|
|
65
|
+
elif command -v openssl >/dev/null 2>&1; then
|
|
66
|
+
openssl dgst -sha256 "$1" | awk '{print $NF}'
|
|
67
|
+
else
|
|
68
|
+
echo "need sha256sum, shasum or openssl" >&2
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
tmp="$(mktemp -d)"
|
|
74
|
+
trap 'rm -rf "$tmp"' EXIT
|
|
75
|
+
|
|
76
|
+
fetch "$url" "$tmp/download"
|
|
77
|
+
if [ "$compression" = "gzip" ]; then
|
|
78
|
+
gzip -dc "$tmp/download" > "$tmp/binary"
|
|
79
|
+
else
|
|
80
|
+
mv "$tmp/download" "$tmp/binary"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
actual="$(digest "$tmp/binary")"
|
|
84
|
+
if [ "$actual" != "$sha256" ]; then
|
|
85
|
+
echo "checksum mismatch: expected $sha256, got $actual" >&2
|
|
86
|
+
exit 1
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
actual_size="$(wc -c < "$tmp/binary" | tr -d ' ')"
|
|
90
|
+
if [ "$actual_size" != "$size" ]; then
|
|
91
|
+
echo "size mismatch: expected $size bytes, got $actual_size" >&2
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
mkdir -p "$dir"
|
|
96
|
+
chmod 755 "$tmp/binary"
|
|
97
|
+
# A rename, never a write over the file in place: anything else can leave a
|
|
98
|
+
# half-written executable where a working one used to be.
|
|
99
|
+
mv "$tmp/binary" "$dir/$binary"
|
|
100
|
+
|
|
101
|
+
echo "installed $binary ${config.manifest.version} to $dir/$binary"
|
|
102
|
+
case ":$PATH:" in
|
|
103
|
+
*":$dir:"*) ;;
|
|
104
|
+
*) echo "note: $dir is not on your PATH" >&2 ;;
|
|
105
|
+
esac
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
function singleTarget(asset) {
|
|
109
|
+
return [
|
|
110
|
+
`url=${shellQuote(asset.url)}`,
|
|
111
|
+
`sha256=${shellQuote(asset.sha256)}`,
|
|
112
|
+
`size=${shellQuote(String(asset.size))}`,
|
|
113
|
+
`compression=${shellQuote(asset.compression)}`
|
|
114
|
+
].join(`
|
|
115
|
+
`);
|
|
116
|
+
}
|
|
117
|
+
function unameDispatch(assets) {
|
|
118
|
+
const cases = assets.map((asset) => ` ${asset.platform}/${asset.arch})
|
|
119
|
+
url=${shellQuote(asset.url)}
|
|
120
|
+
sha256=${shellQuote(asset.sha256)}
|
|
121
|
+
size=${shellQuote(String(asset.size))}
|
|
122
|
+
compression=${shellQuote(asset.compression)}
|
|
123
|
+
;;`).join(`
|
|
124
|
+
`);
|
|
125
|
+
const published = assets.map((asset) => `${asset.platform}/${asset.arch}`).join(", ");
|
|
126
|
+
return `case "$(uname -s)" in
|
|
127
|
+
Darwin) platform=darwin ;;
|
|
128
|
+
Linux) platform=linux ;;
|
|
129
|
+
*) platform="$(uname -s)" ;;
|
|
130
|
+
esac
|
|
131
|
+
case "$(uname -m)" in
|
|
132
|
+
x86_64|amd64) arch=x64 ;;
|
|
133
|
+
aarch64|arm64) arch=arm64 ;;
|
|
134
|
+
*) arch="$(uname -m)" ;;
|
|
135
|
+
esac
|
|
136
|
+
|
|
137
|
+
case "$platform/$arch" in
|
|
138
|
+
${cases}
|
|
139
|
+
*)
|
|
140
|
+
echo "no published build for $platform/$arch — published: ${published}" >&2
|
|
141
|
+
exit 1
|
|
142
|
+
;;
|
|
143
|
+
esac`;
|
|
144
|
+
}
|
|
145
|
+
|
|
27
146
|
// src/tools/cli/manifest.ts
|
|
28
147
|
import { z as z2 } from "zod";
|
|
29
148
|
|
|
@@ -648,4 +767,4 @@ function rollbackCliUpdate2(config) {
|
|
|
648
767
|
return { path: target, bytes: bytes.length, sha256 };
|
|
649
768
|
}
|
|
650
769
|
|
|
651
|
-
export { CliBuildSignatureSchema2, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
770
|
+
export { renderCliInstaller2, CliBuildSignatureSchema2, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withExclusiveLock2
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-zhngww7q.js";
|
|
4
4
|
import {
|
|
5
5
|
writeAtomicFileData
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-2rs7ze0q.js";
|
|
7
7
|
import {
|
|
8
8
|
publishAtomicFile
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-gyfsh29t.js";
|
|
10
10
|
import {
|
|
11
11
|
readBoundedFile
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-150b1qyw.js";
|
|
13
13
|
import {
|
|
14
14
|
errnoOf
|
|
15
15
|
} from "./index-jj9228tt.js";
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
reclaimable,
|
|
10
10
|
LockRecordError,
|
|
11
11
|
readLockRecord
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-2qnqvq11.js";
|
|
13
13
|
import {
|
|
14
14
|
AtomicFilePublicationError2,
|
|
15
15
|
publishAtomicFile
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-gyfsh29t.js";
|
|
17
17
|
import {
|
|
18
18
|
errnoOf
|
|
19
19
|
} from "./index-jj9228tt.js";
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
} from "./index-02kdtrcd.js";
|
|
10
10
|
import {
|
|
11
11
|
streamNativeCommand2
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-1h0dtfz3.js";
|
|
13
13
|
import {
|
|
14
14
|
runNativeCommand2
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-afaq0nc4.js";
|
|
16
16
|
import {
|
|
17
17
|
jsonDataRefusal
|
|
18
18
|
} from "./index-m6w6jtda.js";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POSIX ownership policy, validation and descriptor application for atomic file writes.
|
|
3
|
+
*
|
|
4
|
+
* Ownership is either left to the kernel (`'none'`), preserved from an existing regular file at
|
|
5
|
+
* `target` via `lstat` (`'preserve'`), or set explicitly (`{ uid, gid }`). Before calling `fchown`,
|
|
6
|
+
* the descriptor's actual `(uid, gid)` is read with `fstat(fd)` — never guessed from
|
|
7
|
+
* `process.getuid()`/`process.getgid()`, which disagree with the inode in setgid or BSD directories.
|
|
8
|
+
*/
|
|
9
|
+
/** Explicit POSIX numeric user and group IDs (`0`..`4294967294`) applied to an atomically written file. */
|
|
10
|
+
export interface WriteFileAtomicOwner {
|
|
11
|
+
/** Numeric POSIX user ID (`0`..`4294967294`; `0xffff_ffff` is refused as POSIX `(uid_t)-1` no-op). */
|
|
12
|
+
readonly uid: number;
|
|
13
|
+
/** Numeric POSIX group ID (`0`..`4294967294`; `0xffff_ffff` is refused as POSIX `(gid_t)-1` no-op). */
|
|
14
|
+
readonly gid: number;
|
|
15
|
+
}
|
|
16
|
+
/** Normalized ownership policy resolved once up front from `WriteFileAtomicOptions`. */
|
|
17
|
+
export type AtomicOwnerPolicy = {
|
|
18
|
+
readonly kind: 'none';
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'preserve';
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'explicit';
|
|
23
|
+
readonly owner: WriteFileAtomicOwner;
|
|
24
|
+
};
|
|
25
|
+
/** Minimal `lstat` view needed to inspect an existing target's file kind and ownership. */
|
|
26
|
+
export interface TargetLstatView {
|
|
27
|
+
isFile(): boolean;
|
|
28
|
+
uid: number;
|
|
29
|
+
gid: number;
|
|
30
|
+
}
|
|
31
|
+
/** Minimal `fstat(fd)` view needed to compare a staged descriptor's real `(uid, gid)`. */
|
|
32
|
+
export interface DescriptorOwnerView {
|
|
33
|
+
uid: number;
|
|
34
|
+
gid: number;
|
|
35
|
+
}
|
|
36
|
+
/** Maximum valid POSIX `uid`/`gid` for `fchown`; `0xffff_ffff` is the `(uid_t)-1` no-op sentinel. */
|
|
37
|
+
export declare const MAX_POSIX_OWNER_ID = 4294967294;
|
|
38
|
+
/** Exclusive create flags for staging files: refuses existing files and symbolic links. */
|
|
39
|
+
export declare function stagingOpenFlags(): number;
|
|
40
|
+
/** Validate `options.mode` eagerly before opening any staging file or narrowing bits. */
|
|
41
|
+
export declare function assertWriteMode(mode: unknown, defaultMode: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Validate and snapshot the ownership policy once up front. Option types and combinations throw
|
|
44
|
+
* `TypeError` before the Windows platform refusal so malformed inputs fail uniformly everywhere.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveAtomicOwnerPolicy(options: {
|
|
47
|
+
readonly replace?: boolean;
|
|
48
|
+
readonly owner?: unknown;
|
|
49
|
+
}, platform?: string): AtomicOwnerPolicy;
|
|
50
|
+
/**
|
|
51
|
+
* When ownership will be adjusted before publication, strip group/other bits at `open` time so
|
|
52
|
+
* the staging file is never readable by the process's prior group before `fchown` and `fchmod`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function initialCreateMode(mode: number, policy: AtomicOwnerPolicy): number;
|
|
55
|
+
/** Resolve the target `(uid, gid)` asynchronously; missing or non-regular targets yield `undefined`. */
|
|
56
|
+
export declare function resolveDesiredOwner(target: string, policy: AtomicOwnerPolicy, lstatTarget: (path: string) => Promise<TargetLstatView>): Promise<WriteFileAtomicOwner | undefined>;
|
|
57
|
+
/** Synchronous counterpart of {@link resolveDesiredOwner}. */
|
|
58
|
+
export declare function resolveDesiredOwnerSync(target: string, policy: AtomicOwnerPolicy, lstatTarget: (path: string) => TargetLstatView): WriteFileAtomicOwner | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Apply `desired` to an open staged descriptor after inspecting its real `fstat(fd)`. Skips
|
|
61
|
+
* `fchown` when the inode already matches, and refuses unchangeable sentinel IDs instead of
|
|
62
|
+
* letting POSIX `fchown` silently ignore `(uid_t)-1`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyAtomicFileOwner(file: {
|
|
65
|
+
stat(): Promise<DescriptorOwnerView>;
|
|
66
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
67
|
+
}, desired: WriteFileAtomicOwner | undefined): Promise<void>;
|
|
68
|
+
/** Synchronous counterpart of {@link applyAtomicFileOwner}. */
|
|
69
|
+
export declare function applyAtomicFileOwnerSync(file: {
|
|
70
|
+
stat(): DescriptorOwnerView;
|
|
71
|
+
chown(uid: number, gid: number): void;
|
|
72
|
+
}, desired: WriteFileAtomicOwner | undefined): void;
|
|
73
|
+
/** Normalized write options resolved once up front for both async and sync atomic writes. */
|
|
74
|
+
export interface ResolvedAtomicWriteOptions {
|
|
75
|
+
readonly mode: number;
|
|
76
|
+
readonly replace: boolean;
|
|
77
|
+
readonly idempotent: boolean;
|
|
78
|
+
readonly durability: 'none' | 'file' | 'directory';
|
|
79
|
+
readonly ownerPolicy: AtomicOwnerPolicy;
|
|
80
|
+
}
|
|
81
|
+
/** Validate and snapshot every atomic-write option once up front before touching the filesystem. */
|
|
82
|
+
export declare function resolveAtomicWriteOptions(options: {
|
|
83
|
+
readonly mode?: unknown;
|
|
84
|
+
readonly replace?: boolean;
|
|
85
|
+
readonly idempotent?: boolean;
|
|
86
|
+
readonly durability?: 'none' | 'file' | 'directory';
|
|
87
|
+
readonly owner?: unknown;
|
|
88
|
+
}, defaultMode: number, platform?: string): ResolvedAtomicWriteOptions;
|
|
89
|
+
/** Check whether an existing target's `(uid, gid)` satisfies an explicit `owner` for `idempotent: true`. */
|
|
90
|
+
export declare function ownerMatches(actualUid: number | undefined, actualGid: number | undefined, policy: AtomicOwnerPolicy): boolean;
|
|
91
|
+
//# sourceMappingURL=atomic-file-owner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-file-owner.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file-owner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,2GAA2G;AAC3G,MAAM,WAAW,oBAAoB;IACnC,sGAAsG;IACtG,QAAQ,C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