@kitman-sh/cli 0.16.1 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/{chunk-scwj3w7m.js → chunk-1j38xtvp.js} +2 -2
  2. package/dist/{chunk-9qfyb5r2.js → chunk-2bagaygt.js} +6 -6
  3. package/dist/{chunk-yja59yh8.js → chunk-4p1k3yyc.js} +17 -17
  4. package/dist/{chunk-x83q18w0.js → chunk-4qjfn1sa.js} +1 -1
  5. package/dist/{chunk-gwzzacep.js → chunk-5kqt4bqp.js} +1 -1
  6. package/dist/{chunk-bkteq6b3.js → chunk-63cyj9dh.js} +186 -28
  7. package/dist/{chunk-ft3gnwd1.js → chunk-9jffw2mk.js} +3 -3
  8. package/dist/{chunk-hwqecp0m.js → chunk-bqhfbng3.js} +12 -12
  9. package/dist/{chunk-bcqqrwsk.js → chunk-d3gs4jvd.js} +85 -69
  10. package/dist/{chunk-g1f0cjqe.js → chunk-gap0vmj7.js} +2 -2
  11. package/dist/{chunk-rfnasm3c.js → chunk-h2f26xbd.js} +93 -61
  12. package/dist/{chunk-8f632x21.js → chunk-hj8ex4x6.js} +4 -4
  13. package/dist/{chunk-tx7et9g7.js → chunk-jaa8qjky.js} +9 -9
  14. package/dist/{chunk-eavx040m.js → chunk-js64y97w.js} +4 -4
  15. package/dist/{chunk-tc7td60t.js → chunk-mca2zp8p.js} +4 -4
  16. package/dist/{chunk-1r026thg.js → chunk-mg3mxhxe.js} +6 -6
  17. package/dist/{chunk-4yjcehqr.js → chunk-mqsxwm53.js} +17 -17
  18. package/dist/{chunk-xy3hcdhr.js → chunk-my92qn4x.js} +8 -8
  19. package/dist/{chunk-e42hjb3j.js → chunk-n05bj55h.js} +29 -29
  20. package/dist/{chunk-b0b9v7t9.js → chunk-nfnw3dh1.js} +8 -8
  21. package/dist/{chunk-djdhep8n.js → chunk-samxkpbz.js} +3 -3
  22. package/dist/{chunk-f2y0z04q.js → chunk-tsx0347c.js} +1 -1
  23. package/dist/{chunk-sd8b4k1t.js → chunk-vz38kngm.js} +2 -2
  24. package/dist/{chunk-3b198ntn.js → chunk-wg6xkkcr.js} +1 -1
  25. package/dist/{chunk-5s4sgrak.js → chunk-x8zzax0f.js} +10 -10
  26. package/dist/{chunk-dxfab1aj.js → chunk-zmqm4mrm.js} +110 -274
  27. package/dist/index.js +4 -4
  28. package/package.json +1 -1
@@ -43,7 +43,7 @@ import {
43
43
  isFailure2,
44
44
  hasInterrupts,
45
45
  makeUnsafe5,
46
- make15,
46
+ make16,
47
47
  _await,
48
48
  fail5,
49
49
  isDoneUnsafe,
@@ -60,7 +60,9 @@ import {
60
60
  exponential,
61
61
  jittered,
62
62
  spaced,
63
+ upTo,
63
64
  all3,
65
+ validate,
64
66
  findFirst,
65
67
  forEach,
66
68
  promise,
@@ -170,7 +172,53 @@ import {
170
172
  decodeJsonStringSync,
171
173
  encodeUnknownJsonStringSync,
172
174
  storable
173
- } from "./chunk-rfnasm3c.js";
175
+ } from "./chunk-h2f26xbd.js";
176
+ import {
177
+ join,
178
+ interrupt,
179
+ unbounded,
180
+ publishUnsafe,
181
+ unbounded2,
182
+ offer,
183
+ makeUnsafe3,
184
+ make11,
185
+ fromQueue,
186
+ fromPubSub,
187
+ map2,
188
+ filter,
189
+ take2,
190
+ mapAccum,
191
+ decodeText,
192
+ encodeText,
193
+ splitLines,
194
+ run,
195
+ runCollect,
196
+ runFold,
197
+ runHead,
198
+ runForEach,
199
+ FileSystem,
200
+ Path,
201
+ embeddedFile,
202
+ extractEmbeddedFile,
203
+ optionalEnv,
204
+ operatorConfigHome,
205
+ tempDirectoryScoped,
206
+ harnessesUnsupportedInSrt2,
207
+ harnessesUnsupportedInDocker2,
208
+ compiled2,
209
+ pinnedSrtCommand2,
210
+ pinnedSrtStepCommand2,
211
+ runSrtCli2,
212
+ kitmanCacheDirectory2,
213
+ srtSettings2,
214
+ srtCacheEnvironment2,
215
+ srtInheritedEnv2,
216
+ inheritedEnvironment2,
217
+ withOnlyEnvironment2,
218
+ writeSrtSettings2,
219
+ srtStepArgv2,
220
+ srtArgv2
221
+ } from "./chunk-63cyj9dh.js";
174
222
  import {
175
223
  currentTimeMillis,
176
224
  SecureRandom,
@@ -259,53 +307,7 @@ import {
259
307
  checkServicesFile,
260
308
  checkServices,
261
309
  serviceChecks
262
- } from "./chunk-dxfab1aj.js";
263
- import {
264
- join,
265
- interrupt,
266
- unbounded,
267
- publishUnsafe,
268
- unbounded2,
269
- offer,
270
- makeUnsafe3,
271
- make10,
272
- fromQueue,
273
- fromPubSub,
274
- map2,
275
- filter,
276
- take2,
277
- mapAccum,
278
- decodeText,
279
- encodeText,
280
- splitLines,
281
- run,
282
- runCollect,
283
- runFold,
284
- runHead,
285
- runForEach,
286
- FileSystem,
287
- Path,
288
- embeddedFile,
289
- extractEmbeddedFile,
290
- optionalEnv,
291
- operatorConfigHome,
292
- tempDirectoryScoped,
293
- harnessesUnsupportedInSrt2,
294
- harnessesUnsupportedInDocker2,
295
- compiled2,
296
- pinnedSrtCommand2,
297
- pinnedSrtStepCommand2,
298
- runSrtCli2,
299
- kitmanCacheDirectory2,
300
- srtSettings2,
301
- srtCacheEnvironment2,
302
- srtInheritedEnv2,
303
- inheritedEnvironment2,
304
- withOnlyEnvironment2,
305
- writeSrtSettings2,
306
- srtStepArgv2,
307
- srtArgv2
308
- } from "./chunk-bkteq6b3.js";
310
+ } from "./chunk-zmqm4mrm.js";
309
311
  import {
310
312
  writeAgentEnvironmentConfigFile2,
311
313
  readManifestSkillPaths2,
@@ -321,8 +323,8 @@ import {
321
323
  applyAgentEnvironmentMaterialization2,
322
324
  isPathWithin2,
323
325
  skillIdentity2
324
- } from "./chunk-tx7et9g7.js";
325
- import"./chunk-ft3gnwd1.js";
326
+ } from "./chunk-jaa8qjky.js";
327
+ import"./chunk-9jffw2mk.js";
326
328
  import {
327
329
  egressAllowed,
328
330
  writeSecretRegistry,
@@ -332,7 +334,7 @@ import {
332
334
  secretFilter2,
333
335
  opaqueTunnelRefusal2,
334
336
  isOpaqueConnectReason2
335
- } from "./chunk-sd8b4k1t.js";
337
+ } from "./chunk-vz38kngm.js";
336
338
  import {
337
339
  sliceBytes2,
338
340
  maxLineBytes2,
@@ -340,29 +342,29 @@ import {
340
342
  decodedOption2,
341
343
  decoded2,
342
344
  readOpencode2
343
- } from "./chunk-xy3hcdhr.js";
345
+ } from "./chunk-my92qn4x.js";
344
346
  import {
345
347
  uploadRunFile,
346
348
  programLease,
347
349
  rpcRunFiles,
348
350
  programHostsEnv,
349
351
  undeclaredHostsEnv
350
- } from "./chunk-hwqecp0m.js";
351
- import"./chunk-1r026thg.js";
352
+ } from "./chunk-bqhfbng3.js";
353
+ import"./chunk-mg3mxhxe.js";
352
354
  import {
353
355
  nextInt
354
- } from "./chunk-gwzzacep.js";
355
- import"./chunk-f2y0z04q.js";
356
+ } from "./chunk-5kqt4bqp.js";
357
+ import"./chunk-tsx0347c.js";
356
358
  import {
357
359
  ChildProcessSpawner,
358
360
  make3
359
- } from "./chunk-g1f0cjqe.js";
360
- import"./chunk-4yjcehqr.js";
361
+ } from "./chunk-gap0vmj7.js";
362
+ import"./chunk-mqsxwm53.js";
361
363
  import {
362
364
  Id,
363
365
  secretReference,
364
366
  secretPlaceholder
365
- } from "./chunk-x83q18w0.js";
367
+ } from "./chunk-4qjfn1sa.js";
366
368
 
367
369
  // packages/core/src/sync-kit.ts
368
370
  import { createHash } from "crypto";
@@ -7873,6 +7875,19 @@ var daemonLogs = (container) => gen(function* () {
7873
7875
  return `${state.trim()}
7874
7876
  ${logs.trim().slice(-3000)}`;
7875
7877
  }).pipe(orElseSucceed(() => "nothing, since docker could not show its state or logs"));
7878
+ var addressPoolsExhausted = /address pools have been fully subnetted/;
7879
+ var networkGone = /not found|no such network/i;
7880
+ var unusedNetworks = (own) => gen(function* () {
7881
+ const names = (yield* runCommand2("docker", ["network", "ls", "--filter", "type=custom", "--format", "{{.Name}}"])).split(`
7882
+ `).map((name) => name.trim()).filter((name) => name !== "" && !own.includes(name));
7883
+ const unused = yield* forEach(names, (name) => runCommand2("docker", ["network", "inspect", "--format", "{{len .Containers}}", name]).pipe(map9((containers) => containers.trim() === "0" ? [name] : []), orElseSucceed(() => [])), { concurrency: 8 });
7884
+ return unused.flat();
7885
+ }).pipe(orElseSucceed(() => {
7886
+ return;
7887
+ }));
7888
+ var noAddressPool = (unused) => fail7(new CheckDockerUnavailable({
7889
+ reason: `Docker has no free address pool for the check's networks, as all predefined address pools have been fully subnetted. ${unused === undefined ? "Docker could not list its networks to show which are left behind." : unused.length === 0 ? "Each network of its own has a container attached, so none looks left behind." : `These networks have no container attached, and may have been left behind: ${unused.join(", ")}. Remove the ones nothing uses with docker network rm.`}`
7890
+ }));
7876
7891
  var randomHex2 = () => Array.from(crypto.getRandomValues(new Uint8Array(4)), (byte) => byte.toString(16).padStart(2, "0")).join("");
7877
7892
  var dockerCheckDaemon = (input) => ({ id, network: allowed }) => gen(function* () {
7878
7893
  const run = `${dockerName2(id)}-${randomHex2()}`;
@@ -7890,16 +7905,17 @@ var dockerCheckDaemon = (input) => ({ id, network: allowed }) => gen(function* (
7890
7905
  ];
7891
7906
  const labelArgs = labels.flatMap(([key, value]) => ["--label", `${key}=${value}`]);
7892
7907
  const docker = (args, timeout = "30 seconds") => runCommand2("docker", args, { timeout }).pipe(mapError2((error) => new CheckDockerUnavailable({ reason: error.message })));
7893
- yield* acquireRelease(void_3, () => gen(function* () {
7908
+ const removeContainers = gen(function* () {
7894
7909
  const ids = (yield* docker(["ps", "--all", "--quiet", "--filter", `label=${runLabel}=${run}`])).split(`
7895
7910
  `).filter((line) => line.trim() !== "");
7896
7911
  if (ids.length > 0)
7897
7912
  yield* docker(["rm", "--force", "--volumes", ...ids], "2 minutes");
7898
- yield* ignore(docker(["network", "rm", network]));
7899
- yield* ignore(docker(["network", "rm", outside]));
7900
- }).pipe(ignore));
7901
- yield* docker(["network", "create", "--opt", "com.docker.network.bridge.enable_icc=false", ...labelArgs, outside]);
7902
- yield* docker(["network", "create", ...allowed === "open" ? [] : ["--internal"], ...labelArgs, network]);
7913
+ });
7914
+ const removeNetwork = (name) => docker(["network", "rm", name]).pipe(catchIf((error) => networkGone.test(error.reason), () => void_3));
7915
+ yield* acquireRelease(void_3, () => ignore(removeContainers).pipe(andThen2(validate([network, outside], removeNetwork, { discard: true })), retry(spaced("2 seconds").pipe(upTo({ duration: "3 minutes" }))), ignore));
7916
+ const createNetwork = (args) => docker(["network", "create", ...args]).pipe(catchIf((error) => addressPoolsExhausted.test(error.reason), () => flatMap3(unusedNetworks([network, outside]), noAddressPool)));
7917
+ yield* createNetwork(["--opt", "com.docker.network.bridge.enable_icc=false", ...labelArgs, outside]);
7918
+ yield* createNetwork([...allowed === "open" ? [] : ["--internal"], ...labelArgs, network]);
7903
7919
  const addressOn = (container) => gen(function* () {
7904
7920
  yield* docker(["network", "connect", network, container]);
7905
7921
  const address = (yield* docker([
@@ -8011,7 +8027,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
8011
8027
  return {
8012
8028
  request: (method, params) => gen(function* () {
8013
8029
  const id = ++lastId;
8014
- const deferred = yield* make15();
8030
+ const deferred = yield* make16();
8015
8031
  pending.set(id, deferred);
8016
8032
  yield* send({ id, method, params });
8017
8033
  return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
@@ -8154,7 +8170,7 @@ var kitmanMcpPreflight = (mcp) => gen(function* () {
8154
8170
  const server = yield* spawner.spawn(make3(mcp.command, [...mcp.args], {
8155
8171
  extendEnv: true,
8156
8172
  env: mcp.env,
8157
- stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
8173
+ stdin: { stream: make11(new TextEncoder().encode(handshake)), endOnDone: false },
8158
8174
  stderr: "ignore"
8159
8175
  }));
8160
8176
  const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
@@ -8228,7 +8244,7 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
8228
8244
  const exitCode = sandbox === undefined ? yield* gen(function* () {
8229
8245
  const spawner = yield* ChildProcessSpawner;
8230
8246
  const handle = yield* spawner.spawn(make3(input.bun ?? process.execPath, [file], {
8231
- stdin: make10(new TextEncoder().encode(stdin)),
8247
+ stdin: make11(new TextEncoder().encode(stdin)),
8232
8248
  stdout: "inherit",
8233
8249
  stderr: "inherit",
8234
8250
  extendEnv: false,
@@ -22,7 +22,7 @@ import {
22
22
  map9,
23
23
  raceFirst,
24
24
  scoped
25
- } from "./chunk-rfnasm3c.js";
25
+ } from "./chunk-h2f26xbd.js";
26
26
  import {
27
27
  unwrap,
28
28
  drainFork,
@@ -31,7 +31,7 @@ import {
31
31
  runCollect,
32
32
  runDrain,
33
33
  mkString
34
- } from "./chunk-bkteq6b3.js";
34
+ } from "./chunk-63cyj9dh.js";
35
35
 
36
36
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/redacted.js
37
37
  var redactedRegistry = /* @__PURE__ */ new WeakMap;