stitchkit 0.136.4 → 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.
Files changed (88) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/entrypoints/agent-executor/acp.js +5 -5
  3. package/dist/entrypoints/agent-executor/claude-sdk.js +7 -7
  4. package/dist/entrypoints/agent-executor/claude.js +7 -7
  5. package/dist/entrypoints/agent-executor/codex.js +9 -9
  6. package/dist/entrypoints/agent-executor/testing.js +9 -9
  7. package/dist/entrypoints/agent-executor.js +5 -5
  8. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  9. package/dist/entrypoints/agent-runtime/postgres.js +4 -4
  10. package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
  11. package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
  12. package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
  13. package/dist/entrypoints/agent-runtime/testing.js +4 -4
  14. package/dist/entrypoints/agent-runtime.js +4 -4
  15. package/dist/entrypoints/application/diagnostic-journal.js +3 -3
  16. package/dist/entrypoints/application/directory-inbox.js +7 -7
  17. package/dist/entrypoints/cli/publish.d.ts +14 -6
  18. package/dist/entrypoints/cli/publish.d.ts.map +1 -1
  19. package/dist/entrypoints/cli/publish.js +685 -30
  20. package/dist/entrypoints/cli.js +7 -124
  21. package/dist/entrypoints/files/packaging.js +2 -2
  22. package/dist/entrypoints/files.d.ts +1 -0
  23. package/dist/entrypoints/files.d.ts.map +1 -1
  24. package/dist/entrypoints/files.js +9 -9
  25. package/dist/entrypoints/node.js +3 -3
  26. package/dist/entrypoints/observability.js +1 -1
  27. package/dist/entrypoints/process.js +3 -3
  28. package/dist/entrypoints/server.js +6 -6
  29. package/dist/entrypoints/service-host/macos.js +7 -7
  30. package/dist/entrypoints/service-host/work.js +6 -6
  31. package/dist/entrypoints/service-host.js +9 -9
  32. package/dist/entrypoints/spend.js +1 -1
  33. package/dist/entrypoints/telegram.js +3 -3
  34. package/dist/entrypoints/tools.js +1 -1
  35. package/dist/{index-05b65gj4.js → index-0s75mjh7.js} +1 -1
  36. package/dist/{index-s2e3h616.js → index-150b1qyw.js} +10 -1
  37. package/dist/{index-tcv71frn.js → index-1fhbe4e4.js} +1 -1
  38. package/dist/{index-8cek82ar.js → index-1h0dtfz3.js} +1 -1
  39. package/dist/{index-jwtmw39p.js → index-2qnqvq11.js} +1 -1
  40. package/dist/index-2rs7ze0q.js +376 -0
  41. package/dist/{index-2wm9b9vs.js → index-3cwq5byx.js} +2 -2
  42. package/dist/{index-mtpcax6d.js → index-5md04mwc.js} +3 -3
  43. package/dist/{index-b0mh2t9x.js → index-67mzzkdv.js} +3 -3
  44. package/dist/{index-d5mhgx72.js → index-8tn10tp6.js} +1 -1
  45. package/dist/{index-0sxj3y45.js → index-afaq0nc4.js} +1 -1
  46. package/dist/{index-nfm15ej7.js → index-bbpygynk.js} +1 -1
  47. package/dist/{index-g04hszcm.js → index-chapre0y.js} +1 -1
  48. package/dist/{index-vh4291qh.js → index-ctaxjpa4.js} +1 -1
  49. package/dist/{index-x1r7kxzd.js → index-e4zt2x70.js} +3 -3
  50. package/dist/{index-s0n0nnz5.js → index-f103md2v.js} +122 -3
  51. package/dist/{index-2c5w2d1d.js → index-gyfsh29t.js} +1 -1
  52. package/dist/{index-kgkevngs.js → index-kadgaw1s.js} +4 -4
  53. package/dist/{index-ca1v40d3.js → index-kd48gk7d.js} +1 -1
  54. package/dist/{index-ke6jtxkd.js → index-mr3njw67.js} +1 -1
  55. package/dist/{index-cmqvf0dz.js → index-ppy23bd2.js} +1 -1
  56. package/dist/{index-43k180c2.js → index-rnhp7je8.js} +2 -2
  57. package/dist/{index-2tgmggcm.js → index-smvmnz5y.js} +1 -1
  58. package/dist/{index-9m1m92rg.js → index-tjhhsnjv.js} +1 -1
  59. package/dist/{index-64t6pheq.js → index-w161azza.js} +1 -1
  60. package/dist/{index-mttkdm5a.js → index-xqppqn97.js} +1 -1
  61. package/dist/{index-sjq4akrx.js → index-xsrma0jd.js} +2 -2
  62. package/dist/{index-zqc64g69.js → index-ypm85xwe.js} +1 -1
  63. package/dist/{index-zagc12j1.js → index-zcq3dby3.js} +1 -1
  64. package/dist/{index-29v1p1f4.js → index-zhngww7q.js} +1 -1
  65. package/dist/internal/atomic-file-owner.d.ts +91 -0
  66. package/dist/internal/atomic-file-owner.d.ts.map +1 -0
  67. package/dist/internal/atomic-file.d.ts +29 -7
  68. package/dist/internal/atomic-file.d.ts.map +1 -1
  69. package/dist/internal/bounded-file-read.d.ts +6 -2
  70. package/dist/internal/bounded-file-read.d.ts.map +1 -1
  71. package/dist/tools/cli/distribution-config.d.ts +56 -0
  72. package/dist/tools/cli/distribution-config.d.ts.map +1 -0
  73. package/dist/tools/cli/distribution-routes.d.ts +20 -0
  74. package/dist/tools/cli/distribution-routes.d.ts.map +1 -0
  75. package/dist/tools/cli/publication-source.d.ts +77 -0
  76. package/dist/tools/cli/publication-source.d.ts.map +1 -0
  77. package/llms/cli-publish.txt +15 -3
  78. package/llms/cli.2.txt +84 -63
  79. package/llms/cli.3.txt +67 -1
  80. package/llms/cli.txt +1 -1
  81. package/llms/files.txt +1 -1
  82. package/llms/process.txt +24 -4
  83. package/llms/stitchkit.txt +1 -1
  84. package/llms-full.txt +124 -9
  85. package/llms.txt +5 -5
  86. package/package.json +1 -1
  87. package/dist/index-pp97q86a.js +0 -221
  88. package/dist/{index-5c4m8zdf.js → index-tjakdpf2.js} +45 -45
@@ -0,0 +1,376 @@
1
+ import {
2
+ AtomicFilePublicationError2,
3
+ assertDirectoryDurability,
4
+ syncDirectory,
5
+ publishAtomicFile,
6
+ publishAtomicFileSync
7
+ } from "./index-gyfsh29t.js";
8
+ import {
9
+ closeAfter,
10
+ closeAfterSync,
11
+ readBoundedFile,
12
+ readBoundedFileSync
13
+ } from "./index-150b1qyw.js";
14
+ import {
15
+ stagingPath
16
+ } from "./index-psye60qn.js";
17
+ import {
18
+ errnoOf
19
+ } from "./index-jj9228tt.js";
20
+ import {
21
+ assertNonNegativeSafeInteger
22
+ } from "./index-gr0kxymw.js";
23
+ import {
24
+ isRecord
25
+ } from "./index-ps3djm8d.js";
26
+
27
+ // src/internal/atomic-file.ts
28
+ import {
29
+ closeSync,
30
+ fchmodSync,
31
+ fchownSync,
32
+ fstatSync,
33
+ fsyncSync,
34
+ lstatSync,
35
+ openSync,
36
+ unlinkSync,
37
+ writeSync
38
+ } from "node:fs";
39
+ import { lstat, open, unlink } from "node:fs/promises";
40
+ import { dirname } from "node:path";
41
+
42
+ // src/internal/atomic-file-owner.ts
43
+ import { constants } from "node:fs";
44
+ var MAX_POSIX_OWNER_ID = 4294967294;
45
+ var MAX_POSIX_MODE = 4294967295;
46
+ function stagingOpenFlags() {
47
+ return constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW ?? 0);
48
+ }
49
+ function assertOwnerId(field, value) {
50
+ const name = `writeFileAtomic option "owner.${field}"`;
51
+ if (typeof value !== "number") {
52
+ throw new TypeError(`${name} must be a non-negative safe integer, received ${String(value)}`);
53
+ }
54
+ assertNonNegativeSafeInteger(name, value, TypeError, { absent: "refused" });
55
+ if (value > MAX_POSIX_OWNER_ID) {
56
+ throw new TypeError(`${name} must be at most ${MAX_POSIX_OWNER_ID} (0xffff_fffe), received ${value}`);
57
+ }
58
+ return value === 0 ? 0 : value;
59
+ }
60
+ function assertWriteMode(mode, defaultMode) {
61
+ if (mode === undefined)
62
+ return defaultMode;
63
+ const name = 'writeFileAtomic option "mode"';
64
+ if (typeof mode !== "number") {
65
+ throw new TypeError(`${name} must be a non-negative safe integer, received ${String(mode)}`);
66
+ }
67
+ assertNonNegativeSafeInteger(name, mode, TypeError, { absent: "refused" });
68
+ if (mode > MAX_POSIX_MODE) {
69
+ throw new TypeError(`${name} must be a 32-bit unsigned integer (0..${MAX_POSIX_MODE}), received ${mode}`);
70
+ }
71
+ return mode === 0 ? 0 : mode;
72
+ }
73
+ function resolveAtomicOwnerPolicy(options, platform = process.platform) {
74
+ const rawOwner = options.owner;
75
+ let policy;
76
+ if (rawOwner === undefined) {
77
+ policy = { kind: "none" };
78
+ } else if (rawOwner === "preserve") {
79
+ if (options.replace === false) {
80
+ throw new TypeError(`writeFileAtomic option "owner: 'preserve'" cannot be combined with "replace: false"`);
81
+ }
82
+ policy = { kind: "preserve" };
83
+ } else {
84
+ if (!isRecord(rawOwner)) {
85
+ throw new TypeError('writeFileAtomic option "owner" must be "preserve" or { uid, gid }');
86
+ }
87
+ const rawUid = Object.hasOwn(rawOwner, "uid") ? rawOwner.uid : undefined;
88
+ const rawGid = Object.hasOwn(rawOwner, "gid") ? rawOwner.gid : undefined;
89
+ const uid = assertOwnerId("uid", rawUid);
90
+ const gid = assertOwnerId("gid", rawGid);
91
+ policy = { kind: "explicit", owner: { uid, gid } };
92
+ }
93
+ if (policy.kind !== "none" && platform === "win32") {
94
+ throw new Error("File ownership options are unsupported on Windows");
95
+ }
96
+ return policy;
97
+ }
98
+ function initialCreateMode(mode, policy) {
99
+ return policy.kind === "none" ? mode : mode & 448;
100
+ }
101
+ async function resolveDesiredOwner(target, policy, lstatTarget) {
102
+ if (policy.kind === "none")
103
+ return;
104
+ if (policy.kind === "explicit")
105
+ return policy.owner;
106
+ let info;
107
+ try {
108
+ info = await lstatTarget(target);
109
+ } catch (error) {
110
+ if (errnoOf(error) === "ENOENT")
111
+ return;
112
+ throw error;
113
+ }
114
+ if (!info.isFile())
115
+ return;
116
+ return { uid: info.uid, gid: info.gid };
117
+ }
118
+ function resolveDesiredOwnerSync(target, policy, lstatTarget) {
119
+ if (policy.kind === "none")
120
+ return;
121
+ if (policy.kind === "explicit")
122
+ return policy.owner;
123
+ let info;
124
+ try {
125
+ info = lstatTarget(target);
126
+ } catch (error) {
127
+ if (errnoOf(error) === "ENOENT")
128
+ return;
129
+ throw error;
130
+ }
131
+ if (!info.isFile())
132
+ return;
133
+ return { uid: info.uid, gid: info.gid };
134
+ }
135
+ function assertChangeableOwnerId(field, desired, current) {
136
+ if (desired === current)
137
+ return;
138
+ if (!Number.isInteger(desired) || desired < 0 || desired > MAX_POSIX_OWNER_ID) {
139
+ throw new RangeError(`Cannot apply file owner ${field} ${String(desired)}: POSIX fchown requires 0..${MAX_POSIX_OWNER_ID}`);
140
+ }
141
+ }
142
+ function needsOwnerChange(current, desired) {
143
+ if (current.uid === desired.uid && current.gid === desired.gid)
144
+ return false;
145
+ assertChangeableOwnerId("uid", desired.uid, current.uid);
146
+ assertChangeableOwnerId("gid", desired.gid, current.gid);
147
+ return true;
148
+ }
149
+ async function applyAtomicFileOwner(file, desired) {
150
+ if (desired === undefined)
151
+ return;
152
+ if (!needsOwnerChange(await file.stat(), desired))
153
+ return;
154
+ await file.chown(desired.uid, desired.gid);
155
+ }
156
+ function applyAtomicFileOwnerSync(file, desired) {
157
+ if (desired === undefined)
158
+ return;
159
+ if (!needsOwnerChange(file.stat(), desired))
160
+ return;
161
+ file.chown(desired.uid, desired.gid);
162
+ }
163
+ function resolveAtomicWriteOptions(options, defaultMode, platform = process.platform) {
164
+ const replace = options.replace ?? true;
165
+ const idempotent = options.idempotent ?? false;
166
+ const durability = options.durability ?? "file";
167
+ if (idempotent && replace) {
168
+ throw new TypeError('writeFileAtomic option "idempotent: true" requires "replace: false"');
169
+ }
170
+ const mode = assertWriteMode(options.mode, defaultMode);
171
+ const ownerPolicy = resolveAtomicOwnerPolicy({ replace, owner: options.owner }, platform);
172
+ return { mode, replace, idempotent, durability, ownerPolicy };
173
+ }
174
+ function ownerMatches(actualUid, actualGid, policy) {
175
+ if (policy.kind !== "explicit")
176
+ return true;
177
+ return actualUid === policy.owner.uid && actualGid === policy.owner.gid;
178
+ }
179
+
180
+ // src/internal/atomic-file.ts
181
+ var DEFAULT_MODE = 384;
182
+ function bytesOf(data) {
183
+ return typeof data === "string" ? new TextEncoder().encode(data) : data;
184
+ }
185
+ function bytesEqual(left, right) {
186
+ if (left.byteLength !== right.byteLength)
187
+ return false;
188
+ for (let index = 0;index < left.byteLength; index += 1) {
189
+ if (left[index] !== right[index])
190
+ return false;
191
+ }
192
+ return true;
193
+ }
194
+ function modeMatches(actualMode, expectedMode) {
195
+ if (process.platform === "win32")
196
+ return true;
197
+ return actualMode !== undefined && (actualMode & 4095) === (expectedMode & 4095);
198
+ }
199
+ function syncDirectorySync(dir) {
200
+ assertDirectoryDurability();
201
+ const descriptor = openSync(dir, "r");
202
+ closeAfterSync(() => closeSync(descriptor), () => fsyncSync(descriptor));
203
+ }
204
+ async function writeAllBytes(file, bytes) {
205
+ for (let offset = 0;offset < bytes.byteLength; ) {
206
+ const { bytesWritten } = await file.write(bytes, offset, bytes.byteLength - offset);
207
+ if (bytesWritten === 0)
208
+ throw new Error("zero-byte atomic-file write");
209
+ offset += bytesWritten;
210
+ }
211
+ }
212
+ async function writeFileAtomic2(target, data, options = {}) {
213
+ return writeAtomicFileData(target, data, options);
214
+ }
215
+ function isMissing(error) {
216
+ return errnoOf(error) === "ENOENT";
217
+ }
218
+ async function publishMaybeIdempotent(staged, target, resolved, expectedBytes, io) {
219
+ const publishOptions = {
220
+ replace: resolved.replace,
221
+ durability: resolved.durability
222
+ };
223
+ try {
224
+ await io.publish(staged, target, publishOptions);
225
+ return;
226
+ } catch (error) {
227
+ if (!resolved.idempotent || errnoOf(error) !== "EEXIST" || expectedBytes === undefined) {
228
+ throw error;
229
+ }
230
+ const readExisting = io.readExisting ?? ((path, maxBytes) => readBoundedFile(path, maxBytes, { rejectSymlinks: true }));
231
+ let existing;
232
+ try {
233
+ existing = await readExisting(target, expectedBytes.byteLength);
234
+ } catch (readError) {
235
+ if (isMissing(readError)) {
236
+ await io.publish(staged, target, publishOptions);
237
+ return;
238
+ }
239
+ throw error;
240
+ }
241
+ if (!modeMatches(existing.mode, resolved.mode) || !ownerMatches(existing.uid, existing.gid, resolved.ownerPolicy) || !bytesEqual(existing.bytes, expectedBytes)) {
242
+ throw error;
243
+ }
244
+ try {
245
+ await io.unlink(staged);
246
+ } catch (cleanup) {
247
+ if (!isMissing(cleanup))
248
+ throw new AtomicFilePublicationError2("cleanup", cleanup);
249
+ }
250
+ if (publishOptions.durability === "directory") {
251
+ try {
252
+ const syncDir = io.syncDir ?? syncDirectory;
253
+ await syncDir(dirname(target));
254
+ } catch (syncError) {
255
+ throw new AtomicFilePublicationError2("directory-sync", syncError);
256
+ }
257
+ }
258
+ }
259
+ }
260
+ async function writeAtomicFileStaged(target, stage, options, io = { open, unlink, publish: publishAtomicFile }) {
261
+ const resolved = resolveAtomicWriteOptions(options, DEFAULT_MODE, io.platform);
262
+ const staged = stagingPath(target);
263
+ const file = await io.open(staged, stagingOpenFlags(), initialCreateMode(resolved.mode, resolved.ownerPolicy));
264
+ try {
265
+ const value = await closeAfter(file, async () => {
266
+ const filled = await stage.fill(file);
267
+ const desiredOwner = await resolveDesiredOwner(target, resolved.ownerPolicy, io.lstat ?? lstat);
268
+ await applyAtomicFileOwner(file, desiredOwner);
269
+ await file.chmod(resolved.mode);
270
+ if (resolved.durability !== "none")
271
+ await file.sync();
272
+ return filled;
273
+ });
274
+ await publishMaybeIdempotent(staged, target, resolved, stage.expectedBytes, io);
275
+ return value;
276
+ } catch (error) {
277
+ await io.unlink(staged).catch((cleanup) => {
278
+ if (!isMissing(cleanup))
279
+ stage.onCleanupError?.(cleanup);
280
+ });
281
+ throw error;
282
+ }
283
+ }
284
+ async function writeAtomicFileData(target, data, options, io) {
285
+ const bytes = bytesOf(data);
286
+ await writeAtomicFileStaged(target, { fill: (file) => writeAllBytes(file, bytes), expectedBytes: bytes }, options, io);
287
+ }
288
+ var nativeSync = {
289
+ open(path, flags, mode) {
290
+ const descriptor = openSync(path, flags, mode);
291
+ return {
292
+ write: (bytes, offset, length) => writeSync(descriptor, bytes, offset, length),
293
+ stat: () => fstatSync(descriptor),
294
+ chown: (uid, gid) => fchownSync(descriptor, uid, gid),
295
+ chmod: (bits) => fchmodSync(descriptor, bits),
296
+ sync: () => fsyncSync(descriptor),
297
+ close: () => closeSync(descriptor)
298
+ };
299
+ },
300
+ unlink: unlinkSync,
301
+ publish: publishAtomicFileSync
302
+ };
303
+ function publishMaybeIdempotentSync(staged, target, resolved, expectedBytes, io) {
304
+ const publishOptions = {
305
+ replace: resolved.replace,
306
+ durability: resolved.durability
307
+ };
308
+ try {
309
+ io.publish(staged, target, publishOptions);
310
+ return;
311
+ } catch (error) {
312
+ if (!resolved.idempotent || errnoOf(error) !== "EEXIST") {
313
+ throw error;
314
+ }
315
+ const readExisting = io.readExisting ?? ((path, maxBytes) => readBoundedFileSync(path, maxBytes, { rejectSymlinks: true }));
316
+ let existing;
317
+ try {
318
+ existing = readExisting(target, expectedBytes.byteLength);
319
+ } catch (readError) {
320
+ if (isMissing(readError)) {
321
+ io.publish(staged, target, publishOptions);
322
+ return;
323
+ }
324
+ throw error;
325
+ }
326
+ if (!modeMatches(existing.mode, resolved.mode) || !ownerMatches(existing.uid, existing.gid, resolved.ownerPolicy) || !bytesEqual(existing.bytes, expectedBytes)) {
327
+ throw error;
328
+ }
329
+ try {
330
+ io.unlink(staged);
331
+ } catch (cleanup) {
332
+ if (!isMissing(cleanup))
333
+ throw new AtomicFilePublicationError2("cleanup", cleanup);
334
+ }
335
+ if (publishOptions.durability === "directory") {
336
+ try {
337
+ const syncDir = io.syncDir ?? syncDirectorySync;
338
+ syncDir(dirname(target));
339
+ } catch (syncError) {
340
+ throw new AtomicFilePublicationError2("directory-sync", syncError);
341
+ }
342
+ }
343
+ }
344
+ }
345
+ function writeAtomicFileDataSync(target, data, options, io = nativeSync) {
346
+ const resolved = resolveAtomicWriteOptions(options, DEFAULT_MODE, io.platform);
347
+ const bytes = bytesOf(data);
348
+ const staged = stagingPath(target);
349
+ const file = io.open(staged, stagingOpenFlags(), initialCreateMode(resolved.mode, resolved.ownerPolicy));
350
+ try {
351
+ closeAfterSync(() => file.close(), () => {
352
+ for (let offset = 0;offset < bytes.byteLength; ) {
353
+ const written = file.write(bytes, offset, bytes.byteLength - offset);
354
+ if (written === 0)
355
+ throw new Error("zero-byte atomic-file write");
356
+ offset += written;
357
+ }
358
+ const desiredOwner = resolveDesiredOwnerSync(target, resolved.ownerPolicy, io.lstat ?? lstatSync);
359
+ applyAtomicFileOwnerSync(file, desiredOwner);
360
+ file.chmod(resolved.mode);
361
+ if (resolved.durability !== "none")
362
+ file.sync();
363
+ });
364
+ publishMaybeIdempotentSync(staged, target, resolved, bytes, io);
365
+ } catch (error) {
366
+ try {
367
+ io.unlink(staged);
368
+ } catch {}
369
+ throw error;
370
+ }
371
+ }
372
+ function writeFileAtomicSync2(target, data, options = {}) {
373
+ writeAtomicFileDataSync(target, data, options);
374
+ }
375
+
376
+ export { writeAllBytes, writeFileAtomic2, writeAtomicFileStaged, writeAtomicFileData, writeFileAtomicSync2 };
@@ -9,7 +9,7 @@ import {
9
9
  nextEventSeqByMaximum,
10
10
  agentSqlTables,
11
11
  createAgentRuntimeStore2
12
- } from "./index-d5mhgx72.js";
12
+ } from "./index-8tn10tp6.js";
13
13
  import {
14
14
  canonicalAgentJson2
15
15
  } from "./index-kaq9nb7h.js";
@@ -24,7 +24,7 @@ import {
24
24
  scanSqlRecoverable,
25
25
  listSqlConversations,
26
26
  pageSqlConversationMessages
27
- } from "./index-zagc12j1.js";
27
+ } from "./index-zcq3dby3.js";
28
28
  import {
29
29
  rollbackSqliteFailure
30
30
  } from "./index-ttexdtjj.js";
@@ -9,16 +9,16 @@ import {
9
9
  offerTurnDelta,
10
10
  safeJsonValue,
11
11
  clampUniqueWindowName
12
- } from "./index-sjq4akrx.js";
12
+ } from "./index-xsrma0jd.js";
13
13
  import {
14
14
  isSupportedImageMediaType
15
15
  } from "./index-65p8v81y.js";
16
16
  import {
17
17
  mergeRateLimitEvent2
18
- } from "./index-9m1m92rg.js";
18
+ } from "./index-tjhhsnjv.js";
19
19
  import {
20
20
  endEngineTurn
21
- } from "./index-tcv71frn.js";
21
+ } from "./index-1fhbe4e4.js";
22
22
  import {
23
23
  errnoOf
24
24
  } from "./index-jj9228tt.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  RegularFileError2,
3
3
  readRegularFile2
4
- } from "./index-vh4291qh.js";
4
+ } from "./index-ctaxjpa4.js";
5
5
  import {
6
6
  runNativeCommand2
7
- } from "./index-0sxj3y45.js";
7
+ } from "./index-afaq0nc4.js";
8
8
  import {
9
9
  writeFileAtomic2
10
- } from "./index-pp97q86a.js";
10
+ } from "./index-2rs7ze0q.js";
11
11
  import {
12
12
  errnoOf
13
13
  } from "./index-jj9228tt.js";
@@ -18,7 +18,7 @@ import {
18
18
  AgentSandboxRestrictionSchema2,
19
19
  AgentSandboxGradeSchema2,
20
20
  AGENT_CODING_TOOL_NAMES
21
- } from "./index-64t6pheq.js";
21
+ } from "./index-w161azza.js";
22
22
  import {
23
23
  runStateForTerminalReason2,
24
24
  AgentRunSchema2,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  startNativeCommand
3
- } from "./index-5c4m8zdf.js";
3
+ } from "./index-tjakdpf2.js";
4
4
 
5
5
  // src/process/command.ts
6
6
  function runNativeCommand2(input) {
@@ -7,7 +7,7 @@ import {
7
7
  decodeJsonText,
8
8
  parseJsonText,
9
9
  validateJsonValue
10
- } from "./index-vh4291qh.js";
10
+ } from "./index-ctaxjpa4.js";
11
11
  import {
12
12
  messageOf
13
13
  } from "./index-r9kq5ark.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runNativeCommand2
3
- } from "./index-0sxj3y45.js";
3
+ } from "./index-afaq0nc4.js";
4
4
 
5
5
  // src/service-host/macos/runner.ts
6
6
  import { realpath } from "node:fs/promises";
@@ -2,7 +2,7 @@ import {
2
2
  BoundedFileReadError,
3
3
  readBoundedFileFrom,
4
4
  readBoundedFileSync
5
- } from "./index-s2e3h616.js";
5
+ } from "./index-150b1qyw.js";
6
6
  import {
7
7
  messageOf
8
8
  } from "./index-r9kq5ark.js";
@@ -8,14 +8,14 @@ import {
8
8
  import {
9
9
  writeAllBytes,
10
10
  writeAtomicFileStaged
11
- } from "./index-pp97q86a.js";
11
+ } from "./index-2rs7ze0q.js";
12
12
  import {
13
13
  AtomicFilePublicationError2
14
- } from "./index-2c5w2d1d.js";
14
+ } from "./index-gyfsh29t.js";
15
15
  import {
16
16
  BoundedFileReadError,
17
17
  readBoundedFile
18
- } from "./index-s2e3h616.js";
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-29v1p1f4.js";
4
+ } from "./index-zhngww7q.js";
5
5
  import {
6
6
  writeFileAtomicSync2
7
- } from "./index-pp97q86a.js";
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,7 +1,7 @@
1
1
  import {
2
2
  closeAfter,
3
3
  closeAfterSync
4
- } from "./index-s2e3h616.js";
4
+ } from "./index-150b1qyw.js";
5
5
 
6
6
  // src/internal/atomic-publication.ts
7
7
  import { closeSync, fsyncSync, linkSync, openSync, renameSync, unlinkSync } from "node:fs";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  withExclusiveLock2
3
- } from "./index-29v1p1f4.js";
3
+ } from "./index-zhngww7q.js";
4
4
  import {
5
5
  writeAtomicFileData
6
- } from "./index-pp97q86a.js";
6
+ } from "./index-2rs7ze0q.js";
7
7
  import {
8
8
  publishAtomicFile
9
- } from "./index-2c5w2d1d.js";
9
+ } from "./index-gyfsh29t.js";
10
10
  import {
11
11
  readBoundedFile
12
- } from "./index-s2e3h616.js";
12
+ } from "./index-150b1qyw.js";
13
13
  import {
14
14
  errnoOf
15
15
  } from "./index-jj9228tt.js";
@@ -8,7 +8,7 @@ import {
8
8
  diagnoseSync,
9
9
  reclaimable,
10
10
  OWNER_RECORD_BYTES
11
- } from "./index-jwtmw39p.js";
11
+ } from "./index-2qnqvq11.js";
12
12
  import {
13
13
  errnoOf
14
14
  } from "./index-jj9228tt.js";