@kitman-sh/cli 0.10.98 → 0.10.100

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 (26) hide show
  1. package/dist/{chunk-nym2zmz3.js → chunk-0rf10v29.js} +4 -4
  2. package/dist/{chunk-g1xmj2nb.js → chunk-1k3cvdbt.js} +4 -4
  3. package/dist/{chunk-qrxkpwzy.js → chunk-1kww1jdz.js} +1 -1
  4. package/dist/{chunk-7c3pgktm.js → chunk-1nw7sbtr.js} +8 -8
  5. package/dist/{chunk-gfqm22x7.js → chunk-4c78jfqk.js} +5 -5
  6. package/dist/{chunk-s90hj0mb.js → chunk-5z0cwmet.js} +348 -120
  7. package/dist/{chunk-n8c1wh6t.js → chunk-6sanfepb.js} +4 -4
  8. package/dist/{chunk-fd39ch4n.js → chunk-9xj0djtp.js} +8 -8
  9. package/dist/{chunk-07p2dcq3.js → chunk-ayfdkptb.js} +100 -338
  10. package/dist/{chunk-6dc0x5cg.js → chunk-cpx45jzk.js} +8 -8
  11. package/dist/{chunk-j8vq6sk1.js → chunk-cy7cy84h.js} +19 -19
  12. package/dist/{chunk-xwhybbj2.js → chunk-gs6qdy2k.js} +2 -2
  13. package/dist/{chunk-95mkdtzk.js → chunk-hcpjfshb.js} +4 -4
  14. package/dist/{chunk-s5p94z8x.js → chunk-mjrr0wzp.js} +44 -44
  15. package/dist/{chunk-7ya2q09c.js → chunk-mk8vsaj7.js} +1 -1
  16. package/dist/{chunk-797w5qe6.js → chunk-mtz8f1hn.js} +7 -7
  17. package/dist/{chunk-p83y21hp.js → chunk-p3kwtm82.js} +4 -4
  18. package/dist/{chunk-cgjyv52e.js → chunk-qv9te9gr.js} +2 -2
  19. package/dist/{chunk-sy8d7bfa.js → chunk-r3rap6hz.js} +117 -105
  20. package/dist/{chunk-aba9zdpb.js → chunk-tk85pw4z.js} +144 -48
  21. package/dist/{chunk-bqg9gy2e.js → chunk-tqw2rkc9.js} +7 -7
  22. package/dist/{chunk-c6h3fhtb.js → chunk-vatjyw59.js} +11 -11
  23. package/dist/{chunk-3bjekzn7.js → chunk-wyh06par.js} +501 -193
  24. package/dist/{chunk-d1sqb8rt.js → chunk-wzkdjdb7.js} +1 -1
  25. package/dist/index.js +4 -4
  26. package/package.json +1 -1
@@ -13,7 +13,7 @@ import {
13
13
  provide2,
14
14
  provideMerge,
15
15
  squash,
16
- currentTimeMillis,
16
+ pretty,
17
17
  max2,
18
18
  during,
19
19
  min2,
@@ -35,12 +35,13 @@ import {
35
35
  flatMap3,
36
36
  andThen2,
37
37
  tap2,
38
- map7,
38
+ map8,
39
39
  as,
40
40
  asVoid,
41
41
  catch_,
42
42
  catchTag,
43
43
  catchTags,
44
+ catchCause2,
44
45
  catchIf,
45
46
  mapError2,
46
47
  tapError2,
@@ -86,8 +87,9 @@ import {
86
87
  decodeJsonString,
87
88
  encodeJsonStringSync,
88
89
  encodePrettyJsonString
89
- } from "./chunk-07p2dcq3.js";
90
+ } from "./chunk-ayfdkptb.js";
90
91
  import {
92
+ currentTimeMillis,
91
93
  SecureRandom,
92
94
  layerWebCrypto,
93
95
  runMain,
@@ -101,6 +103,7 @@ import {
101
103
  waitingOnWords,
102
104
  queueWords,
103
105
  redactResponseSurface,
106
+ NetworkHost,
104
107
  RepoBindingProviders,
105
108
  RepoBindingCredentialProviderTypes,
106
109
  ContextPackModes,
@@ -108,6 +111,13 @@ import {
108
111
  ProposalStatuses,
109
112
  ProposalTargetTypes,
110
113
  RunDisplayStates,
114
+ RunnerExecutionBackend,
115
+ MaxRunnerConcurrency,
116
+ PinnedImage,
117
+ RunnerSettingNames,
118
+ RunnerSettingsUpdate,
119
+ defaultRunnerSettings,
120
+ shownRunnerSetting,
111
121
  defaultRunnerCapabilities,
112
122
  MemoryStatuses,
113
123
  MemoryScopes,
@@ -185,10 +195,10 @@ import {
185
195
  harnessNames,
186
196
  herdrRunnerCapabilities2,
187
197
  declaredChecks
188
- } from "./chunk-3bjekzn7.js";
198
+ } from "./chunk-wyh06par.js";
189
199
  import {
190
200
  Id
191
- } from "./chunk-qrxkpwzy.js";
201
+ } from "./chunk-1kww1jdz.js";
192
202
  import {
193
203
  toJsonValue,
194
204
  isOneOf,
@@ -198,7 +208,7 @@ import {
198
208
  isObject,
199
209
  isJsonObject,
200
210
  isString
201
- } from "./chunk-d1sqb8rt.js";
211
+ } from "./chunk-wzkdjdb7.js";
202
212
  import {
203
213
  tap,
204
214
  mapError,
@@ -210,11 +220,11 @@ import {
210
220
  withDefault,
211
221
  option,
212
222
  String2
213
- } from "./chunk-s5p94z8x.js";
223
+ } from "./chunk-mjrr0wzp.js";
214
224
  import {
215
225
  ChildProcessSpawner,
216
226
  make3
217
- } from "./chunk-p83y21hp.js";
227
+ } from "./chunk-p3kwtm82.js";
218
228
 
219
229
  // apps/cli/src/cli-error.ts
220
230
  function cliErrorCode(error, status) {
@@ -384,7 +394,7 @@ function herdrRunnerCredentialName(runnerId) {
384
394
  return `herdr-runner:${runnerId}`;
385
395
  }
386
396
  function storedHerdrRunnerCredential(apiUrl, runnerId) {
387
- return map7(readAuthStore(), (auth) => agentCredentialForApi(auth, apiUrl, herdrRunnerCredentialName(runnerId)));
397
+ return map8(readAuthStore(), (auth) => agentCredentialForApi(auth, apiUrl, herdrRunnerCredentialName(runnerId)));
388
398
  }
389
399
  function writeRunnerCredentialFile(path, file) {
390
400
  return gen(function* () {
@@ -487,27 +497,20 @@ var runnerRemoved = {
487
497
  };
488
498
  var sandboxInstall = {
489
499
  srt: process.platform === "darwin" ? "Install what it needs with `brew install ripgrep`" : "Install what it needs with `sudo apt install bubblewrap socat ripgrep` (or your distribution\u2019s packages)",
490
- docker: "Install and start Docker (https://docs.docker.com/engine/install/), and set KITMAN_RUNNER_DOCKER_IMAGE to an image pinned by digest"
500
+ docker: "Install and start Docker (https://docs.docker.com/engine/install/), and give the Runner a Docker image pinned by digest in its settings"
491
501
  };
492
502
  var sandboxMissing = (sandbox, missing) => ({
493
503
  code: "sandbox_missing",
494
504
  message: `\`${sandbox}\` is not available on this host: ${missing.join("; ")}.`.slice(0, 500),
495
- fix: `${sandboxInstall[sandbox]}, or set KITMAN_RUNNER_SANDBOX=host to run agents on the host, with your own access.`
505
+ fix: `${sandboxInstall[sandbox]}, then restart the Runner; or choose another sandbox in its settings, with \`kitman runner settings\` or on its page in Kitman.`
496
506
  });
497
507
  var personalCheckBackend = (agentSandbox, dockerAvailable) => agentSandbox === "srt" || agentSandbox === "docker" && dockerAvailable ? agentSandbox : undefined;
498
- var checkHostsSetting = (value) => (value ?? "").split(",").map((host) => host.trim()).filter((host) => host !== "");
499
- var pinnedImage = (value) => {
500
- const image = value?.trim();
501
- return image !== undefined && /@sha256:[a-f0-9]{64}$/.test(image) ? image : undefined;
502
- };
503
- var checkDockerImageSetting = pinnedImage;
504
- var checkRegistryImageSetting = pinnedImage;
505
508
  var herdrCoreSession = (runnerId, personal) => personal ? undefined : `kitman-${sha2562(runnerId).slice(0, 16)}`;
506
509
  var OpenHerdrCore = Reference("kitman/cli/OpenHerdrCore", {
507
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-g1xmj2nb.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
510
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-1k3cvdbt.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
508
511
  });
509
512
  var UpdateHerdrCore = Reference("kitman/cli/UpdateHerdrCore", {
510
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-g1xmj2nb.js")), (module) => module.updateHerdrCore(options))
513
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-1k3cvdbt.js")), (module) => module.updateHerdrCore(options))
511
514
  });
512
515
  var herdrCoreMissing = (error) => {
513
516
  if (isTagged(error, "HerdrCoreMissing"))
@@ -559,6 +562,125 @@ var startupStep = (step, bound, attempt) => attempt.pipe(timeoutOrElse({ duratio
559
562
  });
560
563
  }));
561
564
 
565
+ // apps/cli/src/runner-settings.ts
566
+ var settingVariables = {
567
+ concurrency: "KITMAN_RUNNER_CONCURRENCY",
568
+ sandbox: "KITMAN_RUNNER_SANDBOX",
569
+ dockerImage: "KITMAN_RUNNER_DOCKER_IMAGE",
570
+ checkHosts: "KITMAN_RUNNER_CHECK_HOSTS",
571
+ checkDockerImage: "KITMAN_RUNNER_CHECK_DOCKER_IMAGE",
572
+ checkRegistryImage: "KITMAN_RUNNER_CHECK_REGISTRY_IMAGE"
573
+ };
574
+ var AllowFullAccessVariable = "KITMAN_RUNNER_ALLOW_FULL_ACCESS";
575
+ var isPinnedImage = is(PinnedImage);
576
+ var isNetworkHost = is(NetworkHost);
577
+ var isBackend = is(RunnerExecutionBackend);
578
+ var settingFromVariable = {
579
+ concurrency: (value) => {
580
+ const concurrency = Math.trunc(Number(value));
581
+ return Number.isFinite(concurrency) ? { concurrency: Math.min(MaxRunnerConcurrency, Math.max(1, concurrency)) } : {};
582
+ },
583
+ sandbox: (value) => isBackend(value) ? { sandbox: value } : {},
584
+ dockerImage: (value) => isPinnedImage(value) ? { dockerImage: value } : {},
585
+ checkHosts: (value) => ({
586
+ checkHosts: value.split(",").map((host) => host.trim()).filter(isNetworkHost)
587
+ }),
588
+ checkDockerImage: (value) => isPinnedImage(value) ? { checkDockerImage: value } : {},
589
+ checkRegistryImage: (value) => isPinnedImage(value) ? { checkRegistryImage: value } : {}
590
+ };
591
+ var variableValue = (environment, name) => {
592
+ const value = environment[name]?.trim();
593
+ return value === undefined || value === "" ? undefined : value;
594
+ };
595
+ var environmentSettings = (environment) => {
596
+ const settings = {};
597
+ const variables = [];
598
+ for (const setting of RunnerSettingNames) {
599
+ const value = variableValue(environment, settingVariables[setting]);
600
+ if (value === undefined)
601
+ continue;
602
+ variables.push(settingVariables[setting]);
603
+ Object.assign(settings, settingFromVariable[setting](value));
604
+ }
605
+ const reported = settings;
606
+ return { settings: reported, variables };
607
+ };
608
+ var fullAccessAllowed = (environment) => variableValue(environment, AllowFullAccessVariable) === "1" || variableValue(environment, settingVariables.sandbox) === "host";
609
+ var fullAccessRefused = {
610
+ code: "full_access_refused",
611
+ message: "Kitman asks this Runner to run agents on the host, which its machine does not allow, so they run in srt.",
612
+ fix: `To run them on the host, set ${AllowFullAccessVariable}=1 on that machine and restart the Runner; or choose srt or docker in its settings.`
613
+ };
614
+ var appliedSandbox = (input) => {
615
+ const runnable = (sandbox) => sandbox === "host" ? input.personal && input.fullAccessAllowed : input.available.includes(sandbox);
616
+ const refused = input.wanted === "host" && !(input.personal && input.fullAccessAllowed);
617
+ const wanted = refused ? input.personal ? "srt" : "docker" : input.wanted;
618
+ const refusal = refused && input.personal ? { problem: fullAccessRefused } : undefined;
619
+ if (runnable(wanted))
620
+ return { sandbox: wanted, ...refusal };
621
+ const missing = wanted === "host" || !input.personal ? undefined : sandboxMissing(wanted, missingFor(input, wanted));
622
+ const kept = input.current === undefined || input.current === "host" ? [] : [input.current];
623
+ const fallbacks = input.personal ? ["srt", "docker"] : ["docker", "srt"];
624
+ const fallback = [...kept, ...fallbacks].find(runnable);
625
+ if (fallback === undefined)
626
+ return { sandbox: wanted, ...missing === undefined ? undefined : { problem: missing } };
627
+ const problem = refusal?.problem ?? missing;
628
+ return { sandbox: fallback, ...problem === undefined ? undefined : { problem } };
629
+ };
630
+ var missingFor = (input, sandbox) => input.unavailable?.find((entry) => entry.backend === sandbox)?.missing ?? ["unsupported"];
631
+ var deprecationWarnings = (variables, settings) => RunnerSettingNames.flatMap((setting) => {
632
+ const variable = settingVariables[setting];
633
+ if (!variables.includes(variable))
634
+ return [];
635
+ const consent = setting === "sandbox" ? ` While it is host, it also lets this machine run agents on the host: set ${AllowFullAccessVariable}=1 instead to keep that.` : "";
636
+ return [
637
+ `${variable} is deprecated and ignored: Kitman keeps this Runner's ${setting} (${shownRunnerSetting(settings[setting])}). Change it on the Runner's page or with \`kitman runner settings\`, then remove the variable.${consent}`
638
+ ];
639
+ });
640
+ var settingFlags = {
641
+ "--concurrency": "concurrency",
642
+ "--sandbox": "sandbox",
643
+ "--docker-image": "dockerImage",
644
+ "--check-hosts": "checkHosts",
645
+ "--check-docker-image": "checkDockerImage",
646
+ "--check-registry-image": "checkRegistryImage"
647
+ };
648
+ var isRunnerSettingFlag = (flag) => (flag in settingFlags);
649
+ var isSettingsUpdate = is(RunnerSettingsUpdate);
650
+ var settingFromFlag = (flag, value) => {
651
+ const setting = settingFlags[flag];
652
+ const cleared = value.trim() === "none";
653
+ const parsed = setting === "concurrency" ? Number(value) : setting === "checkHosts" ? cleared ? [] : value.split(",").map((host) => host.trim()).filter((host) => host !== "") : setting === "sandbox" ? value.trim() : cleared ? null : value.trim();
654
+ const update = { [setting]: parsed };
655
+ if (!isSettingsUpdate(update))
656
+ throw new Error(settingFlagRefused[setting]);
657
+ return update;
658
+ };
659
+ var settingFlagRefused = {
660
+ concurrency: "--concurrency takes a whole number from 1 to 4",
661
+ sandbox: "--sandbox takes srt, docker or host",
662
+ dockerImage: "--docker-image takes an image pinned by digest (name@sha256:...), or none",
663
+ checkHosts: "--check-hosts takes comma-separated hosts, such as registry.npmjs.org,*.example.com, or none",
664
+ checkDockerImage: "--check-docker-image takes an image pinned by digest (name@sha256:...), or none",
665
+ checkRegistryImage: "--check-registry-image takes an image pinned by digest (name@sha256:...), or none"
666
+ };
667
+ var settingRows = (settings, applied) => RunnerSettingNames.map((setting) => {
668
+ const value = shownRunnerSetting(settings[setting]);
669
+ const inEffect = applied === undefined ? undefined : shownRunnerSetting(applied[setting]);
670
+ return {
671
+ setting,
672
+ value,
673
+ ...inEffect === undefined || inEffect === value ? undefined : { applied: inEffect }
674
+ };
675
+ });
676
+ var settingChangeRows = (history) => history.items.map((change) => ({
677
+ changedAt: change.changedAt,
678
+ setting: change.setting,
679
+ from: shownRunnerSetting(change.from),
680
+ to: shownRunnerSetting(change.to),
681
+ by: change.source === "environment" ? "environment variables" : `${change.actorType}:${change.actorId}`
682
+ }));
683
+
562
684
  // apps/cli/src/managed-install.ts
563
685
  var RunnerReleaseManifest = Struct({
564
686
  version: String4.check(isPattern(/^[\w.+-]+$/u)),
@@ -578,7 +700,7 @@ var managedKitmanPath = gen(function* () {
578
700
  var installedKitmanVersion = gen(function* () {
579
701
  const fs = yield* FileSystem;
580
702
  const path = yield* Path;
581
- return yield* fs.readLink(yield* managedKitmanPath).pipe(map7((target) => path.basename(path.dirname(target))), orElseSucceed(() => {
703
+ return yield* fs.readLink(yield* managedKitmanPath).pipe(map8((target) => path.basename(path.dirname(target))), orElseSucceed(() => {
582
704
  return;
583
705
  }));
584
706
  });
@@ -616,7 +738,7 @@ var downloadManagedKitman = (apiUrl, platform) => gen(function* () {
616
738
  const binary = yield* get(release.url).pipe(filterOrFail((downloaded) => downloaded.ok, (downloaded) => new CliError({ message: `Downloading kitman ${manifest.version} answered ${downloaded.status}` })), flatMap3((downloaded) => tryPromise({
617
739
  try: () => downloaded.arrayBuffer(),
618
740
  catch: (error) => new CliError({ message: `Downloading kitman ${manifest.version} failed: ${String(error)}` })
619
- })), map7((bytes) => new Uint8Array(bytes)));
741
+ })), map8((bytes) => new Uint8Array(bytes)));
620
742
  if (digestSha256(binary, "hex") !== release.sha256)
621
743
  return yield* new CliError({
622
744
  message: `The downloaded kitman ${manifest.version} for ${os}/${architecture} does not match its sha256; nothing was installed`
@@ -739,12 +861,12 @@ var syncTargets = (harness) => gen(function* () {
739
861
  });
740
862
  var syncKits = (input) => gen(function* () {
741
863
  const fs = yield* FileSystem;
742
- const { syncKitSetup } = yield* promise(() => import("./chunk-fd39ch4n.js"));
864
+ const { syncKitSetup } = yield* promise(() => import("./chunk-9xj0djtp.js"));
743
865
  const harnesses = yield* syncTargets(input.harness);
744
866
  const chain = yield* input.client.getKitChain(input.workspaceId);
745
867
  for (const { name, problem } of chain.skipped)
746
868
  yield* log(`Warning: skipped Kit ${name}: ${problem}`);
747
- const kits = yield* forEach(chain.kits, (kit) => map7(flatMap3(setupArchive(input.client, input.workspaceId, kit.setupDigest), decodeArchive), (archive) => ({ name: kit.name, version: kit.version, archive })));
869
+ const kits = yield* forEach(chain.kits, (kit) => map8(flatMap3(setupArchive(input.client, input.workspaceId, kit.setupDigest), decodeArchive), (archive) => ({ name: kit.name, version: kit.version, archive })));
748
870
  const manifest = yield* userHarnessSyncPath;
749
871
  const previous = yield* fs.readFileString(manifest).pipe(flatMap3(decodeEffect(SyncedHarnesses)), orElseSucceed(() => ({})));
750
872
  const kitman = (yield* runningManagedInstall(process.platform)) ? yield* managedKitmanPath : "kitman";
@@ -885,7 +1007,7 @@ function idempotencyKey(value, operation) {
885
1007
  const explicit = value?.trim();
886
1008
  if (explicit)
887
1009
  return succeed6(explicit);
888
- return SecureRandom.pipe(flatMap3((random) => random.uuidV4()), map7((id) => `kitman-cli:${operation}:${id}`), provide3(layerWebCrypto));
1010
+ return SecureRandom.pipe(flatMap3((random) => random.uuidV4()), map8((id) => `kitman-cli:${operation}:${id}`), provide3(layerWebCrypto));
889
1011
  }
890
1012
  function segment(value) {
891
1013
  return encodeURIComponent(value);
@@ -1003,7 +1125,7 @@ var machineRunnerServices = gen(function* () {
1003
1125
  return yield* forEach(files.flatMap((file) => {
1004
1126
  const runnerId = pattern.exec(file)?.[1];
1005
1127
  return runnerId === undefined ? [] : [{ runnerId, file: path.join(directory, file) }];
1006
- }), ({ runnerId, file }) => map7(fs.readFileString(file), (definition) => ({
1128
+ }), ({ runnerId, file }) => map8(fs.readFileString(file), (definition) => ({
1007
1129
  runnerId,
1008
1130
  command: serviceCommand(platform, definition)
1009
1131
  })));
@@ -1018,7 +1140,7 @@ var ownersRunners = (apiUrl) => gen(function* () {
1018
1140
  return;
1019
1141
  const client = yield* clientFor(apiUrl, session);
1020
1142
  const workspaces = (yield* client.listWorkspaces()).items;
1021
- const lists = yield* forEach(workspaces, (workspace) => map7(client.listRunners(workspace.id), (list) => list.items));
1143
+ const lists = yield* forEach(workspaces, (workspace) => map8(client.listRunners(workspace.id), (list) => list.items));
1022
1144
  return new Map(lists.flat().map((runner) => [runner.id, runner]));
1023
1145
  }).pipe(orElseSucceed(() => {
1024
1146
  return;
@@ -1140,7 +1262,7 @@ var machineRunnerCommand = (action, apiUrl, options) => gen(function* () {
1140
1262
 
1141
1263
  // apps/cli/src/repo-binding-setup.ts
1142
1264
  var Git = Reference("kitman/cli/Git", {
1143
- defaultValue: () => (args) => runCommand2("git", args).pipe(map7((stdout) => stdout.trim()))
1265
+ defaultValue: () => (args) => runCommand2("git", args).pipe(map8((stdout) => stdout.trim()))
1144
1266
  });
1145
1267
  var repoBindingInputFromCurrentRepo = flatMap3(Git, repoBindingInput);
1146
1268
  function repoBindingInput(git) {
@@ -1277,8 +1399,8 @@ function initCommand(args) {
1277
1399
  const apiUrl = yield* resolveApiUrl(flags.apiUrl);
1278
1400
  const steps = [];
1279
1401
  const step = (name, outcome, detail) => andThen2(sync2(() => steps.push({ name, outcome, detail })), log(`${name}: ${outcomeLabel[outcome]} (${detail})`));
1280
- const ask = (prompt, fallback) => flags.yes ? succeed6(fallback) : promptLine(fallback === "" ? `${prompt}: ` : `${prompt} [${fallback}]: `).pipe(map7((answer) => answer.trim() || fallback));
1281
- const confirm = (prompt, fallback) => map7(ask(`${prompt} (y/n)`, fallback ? "y" : "n"), (answer) => /^y(es)?$/i.test(answer));
1402
+ const ask = (prompt, fallback) => flags.yes ? succeed6(fallback) : promptLine(fallback === "" ? `${prompt}: ` : `${prompt} [${fallback}]: `).pipe(map8((answer) => answer.trim() || fallback));
1403
+ const confirm = (prompt, fallback) => map8(ask(`${prompt} (y/n)`, fallback ? "y" : "n"), (answer) => /^y(es)?$/i.test(answer));
1282
1404
  const existingSession = yield* sessionForApiWithRefresh(apiUrl);
1283
1405
  const session = existingSession ?? (yield* (yield* Login)(apiUrl));
1284
1406
  yield* step("Login", existingSession === undefined ? "set_up" : "already", apiUrl);
@@ -1463,7 +1585,7 @@ var runnerServiceStep = (apiUrl, runnerId, change, step) => gen(function* () {
1463
1585
  yield* step("Runner service", change.fresh ? "set_up" : "repaired", "started");
1464
1586
  });
1465
1587
  var credentialNote = { missing: ", credential restored", refused: ", credential re-keyed", accepted: "" };
1466
- var machineName = map7(option(String2("KITMAN_RUNNER_NAME")), (name) => getOrElse(name, () => hostname()));
1588
+ var machineName = map8(option(String2("KITMAN_RUNNER_NAME")), (name) => getOrElse(name, () => hostname()));
1467
1589
  var managedRunnerService = (runnerId, apiUrl) => gen(function* () {
1468
1590
  const kitman = yield* managedKitmanPath;
1469
1591
  const bin = (yield* Path).dirname(kitman);
@@ -1584,9 +1706,9 @@ function runnerServiceState(name) {
1584
1706
  return gen(function* () {
1585
1707
  const manager = yield* ServiceManager;
1586
1708
  if (manager.platform === "linux")
1587
- return yield* manager.run("systemctl", ["--user", "is-active", `${name}.service`]).pipe(map7((state) => `systemd: ${state.trim()}`), orElseSucceed(() => "systemd: not running"));
1709
+ return yield* manager.run("systemctl", ["--user", "is-active", `${name}.service`]).pipe(map8((state) => `systemd: ${state.trim()}`), orElseSucceed(() => "systemd: not running"));
1588
1710
  if (manager.platform === "darwin")
1589
- return yield* manager.run("launchctl", ["print", `${yield* launchdDomain}/${launchdLabel(name)}`]).pipe(map7((printed) => `launchd: ${/^\s*state = (\S+)/mu.exec(printed)?.[1] ?? "loaded"}`), orElseSucceed(() => "launchd: not installed"));
1711
+ return yield* manager.run("launchctl", ["print", `${yield* launchdDomain}/${launchdLabel(name)}`]).pipe(map8((printed) => `launchd: ${/^\s*state = (\S+)/mu.exec(printed)?.[1] ?? "loaded"}`), orElseSucceed(() => "launchd: not installed"));
1590
1712
  return;
1591
1713
  });
1592
1714
  }
@@ -1657,7 +1779,7 @@ var package_default = {
1657
1779
  };
1658
1780
 
1659
1781
  // apps/cli/src/scaffold.ts
1660
- var cliVersion = "0.10.98";
1782
+ var cliVersion = "0.10.100";
1661
1783
  var packageJson = (name, scaffold) => `${JSON.stringify({
1662
1784
  name,
1663
1785
  private: true,
@@ -1817,6 +1939,9 @@ var Usage = [
1817
1939
  " kitman pair [<pairing code>] [--api-url <url>] (what the command the web shows runs; no code finishes or re-keys with your session)",
1818
1940
  " kitman pair <runner pairing code> --credential-file <path> (writes a shared Runner's credential for a container or its replicas to mount)",
1819
1941
  " kitman runner start --credential-file <path> (or KITMAN_RUNNER_CREDENTIAL_FILE; starts the Runner the file holds)",
1942
+ " kitman runner settings <runner> [--concurrency <1-4>] [--sandbox srt|docker|host] [--docker-image <image@sha256:\u2026>|none]",
1943
+ " [--check-hosts <host,\u2026>|none] [--check-docker-image <image@sha256:\u2026>|none] [--check-registry-image <image@sha256:\u2026>|none]",
1944
+ " kitman runner settings history <runner> (each change: who, when, old and new value)",
1820
1945
  "",
1821
1946
  "Runs:",
1822
1947
  ' kitman run start <loop> "<words>" [--input <json>] [--team <team>] [--type <task type>] [--constraint <text>]... [--fresh] [--override-blockers]',
@@ -1907,7 +2032,7 @@ var Usage = [
1907
2032
  "Every run, loop, agent, verify, constraint, secret, claim, deploy, dev and kit command takes --json."
1908
2033
  ].join(`
1909
2034
  `);
1910
- var agentRuntime = promise(() => import("./chunk-sy8d7bfa.js"));
2035
+ var agentRuntime = promise(() => import("./chunk-r3rap6hz.js"));
1911
2036
  var TuiLauncher = Reference("kitman/cli/TuiLauncher", {
1912
2037
  defaultValue: () => gen(function* () {
1913
2038
  const tui = yield* tryPromise({
@@ -2101,6 +2226,11 @@ function parseCommand(args) {
2101
2226
  if (flags.closure !== undefined && flags.closure !== kind)
2102
2227
  throw new Error("run close takes one of --complete or --abandoned");
2103
2228
  flags.closure = kind;
2229
+ } else if (group === "runner" && action === "settings" && arg !== undefined && isRunnerSettingFlag(arg)) {
2230
+ const value = args[++index];
2231
+ if (value === undefined)
2232
+ throw new Error(`${arg} requires a value`);
2233
+ flags.runnerSettings = { ...flags.runnerSettings, ...settingFromFlag(arg, value) };
2104
2234
  } else if (arg === "--runner" || arg === "--credential-file") {
2105
2235
  const value = args[++index];
2106
2236
  if (!value)
@@ -2321,7 +2451,7 @@ function harnessSync(args) {
2321
2451
  });
2322
2452
  });
2323
2453
  }
2324
- var readStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map7((text) => text.trim()));
2454
+ var readStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map8((text) => text.trim()));
2325
2455
  function promptLine(prompt) {
2326
2456
  return gen(function* () {
2327
2457
  const terminal = yield* Terminal;
@@ -2648,6 +2778,19 @@ function runnerCommand(args) {
2648
2778
  const response = yield* client.listRunners(workspaceId);
2649
2779
  return yield* printRows(response.items.map(runnerRow), command.flags.json);
2650
2780
  }
2781
+ if (command.action === "settings") {
2782
+ const history = command.args[0] === "history";
2783
+ const runnerRef = command.flags.runnerId ?? command.args[history ? 1 : 0];
2784
+ if (runnerRef === undefined)
2785
+ return yield* new CliError({ message: "runner settings requires a Runner: kitman runner settings <runner>" });
2786
+ const runner = yield* resolveRunnerForCommand(client, workspaceId, runnerRef);
2787
+ if (history)
2788
+ return yield* printRows(settingChangeRows(yield* client.listRunnerSettingsHistory(runner.id)), command.flags.json);
2789
+ const changed = command.flags.runnerSettings === undefined ? yield* client.getRunner(runner.id) : yield* client.updateRunnerSettings(runner.id, command.flags.runnerSettings);
2790
+ if (changed.settings === undefined)
2791
+ return yield* new CliError({ message: `${apiUrl} keeps no Runner settings; update Kitman there first.` });
2792
+ return yield* printRows(settingRows(changed.settings, changed.appliedSettings), command.flags.json);
2793
+ }
2651
2794
  if (command.action === "rescope") {
2652
2795
  const runnerRef = command.flags.runnerId ?? requiredArg(command, "Runner");
2653
2796
  const runner = yield* resolveRunnerForCommand(client, workspaceId, runnerRef);
@@ -2783,7 +2926,7 @@ var SandboxHostProbe = Reference("kitman/cli/SandboxHostProbe", {
2783
2926
  });
2784
2927
  var OpenRunnerRpc = Reference("kitman/cli/OpenRunnerRpc", {
2785
2928
  defaultValue: () => (options) => gen(function* () {
2786
- const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-797w5qe6.js"));
2929
+ const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-mtz8f1hn.js"));
2787
2930
  return yield* makeRunnerRpcClient({
2788
2931
  runnerId: options.runnerId,
2789
2932
  bearer: options.bearer,
@@ -2791,23 +2934,19 @@ var OpenRunnerRpc = Reference("kitman/cli/OpenRunnerRpc", {
2791
2934
  });
2792
2935
  })
2793
2936
  });
2794
- var runnerSettings = gen(function* () {
2795
- const optional = (name) => String2(name).pipe(option, map7((value) => getOrUndefined(value)?.trim()));
2796
- const concurrency = Number(yield* optional("KITMAN_RUNNER_CONCURRENCY")) || 1;
2797
- const configuredSandbox = (yield* optional("KITMAN_RUNNER_SANDBOX")) || "srt";
2798
- const sandboxes = ["host", "srt", "docker"];
2799
- const sandbox = sandboxes.find((candidate) => candidate === configuredSandbox);
2800
- if (sandbox === undefined)
2801
- return yield* new CliError({ message: `KITMAN_RUNNER_SANDBOX is srt, docker or host, not ${configuredSandbox}` });
2937
+ var runnerHostSettings = gen(function* () {
2938
+ const names = [
2939
+ ...Object.values(settingVariables),
2940
+ AllowFullAccessVariable,
2941
+ "KITMAN_RUNNER_FULL_ACCESS",
2942
+ "SSH_AUTH_SOCK"
2943
+ ];
2944
+ const environment = Object.fromEntries(yield* forEach(names, (name) => String2(name).pipe(option, map8((value) => [name, getOrUndefined(value)?.trim()]))));
2802
2945
  return {
2803
- concurrency: Math.min(4, Math.max(1, concurrency)),
2804
- fullAccess: (yield* optional("KITMAN_RUNNER_FULL_ACCESS")) === "1",
2805
- sshAgentAvailable: (yield* optional("SSH_AUTH_SOCK")) !== undefined,
2806
- sandbox,
2807
- dockerImage: yield* optional("KITMAN_RUNNER_DOCKER_IMAGE"),
2808
- checkHosts: checkHostsSetting(yield* optional("KITMAN_RUNNER_CHECK_HOSTS")),
2809
- checkDockerImage: checkDockerImageSetting(yield* optional("KITMAN_RUNNER_CHECK_DOCKER_IMAGE")),
2810
- checkRegistryImage: checkRegistryImageSetting(yield* optional("KITMAN_RUNNER_CHECK_REGISTRY_IMAGE"))
2946
+ fullAccess: environment["KITMAN_RUNNER_FULL_ACCESS"] === "1",
2947
+ sshAgentAvailable: environment["SSH_AUTH_SOCK"] !== undefined,
2948
+ fullAccessAllowed: fullAccessAllowed(environment),
2949
+ environment: environmentSettings(environment)
2811
2950
  };
2812
2951
  });
2813
2952
  var herdrRunnerRootDir = gen(function* () {
@@ -2864,8 +3003,8 @@ function startCanonicalHerdrRunnerCommand(input) {
2864
3003
  verificationExecutor
2865
3004
  } = yield* agentRuntime;
2866
3005
  const openRunnerRpc = yield* OpenRunnerRpc;
2867
- const settings = yield* runnerSettings;
2868
- const { concurrency, fullAccess, sshAgentAvailable } = settings;
3006
+ const hostSettings = yield* runnerHostSettings;
3007
+ const { fullAccess, sshAgentAvailable } = hostSettings;
2869
3008
  const fs = yield* FileSystem;
2870
3009
  const container = input.credential !== undefined || (yield* fs.exists("/.dockerenv").pipe(orElseSucceed(() => false))) || (yield* fs.exists("/run/.containerenv").pipe(orElseSucceed(() => false)));
2871
3010
  const reported = { ...kitmanVersion === undefined ? undefined : { version: kitmanVersion }, container };
@@ -2873,13 +3012,32 @@ function startCanonicalHerdrRunnerCommand(input) {
2873
3012
  if (credential === undefined)
2874
3013
  return yield* new RunnerStopped({ problem: credentialMissing(input.runnerId) });
2875
3014
  const controlPlane = yield* createHerdrRunnerClient({ apiUrl: input.apiUrl, runnerId: input.runnerId, credential });
2876
- const runner = yield* startupStep("first heartbeat", "30 seconds", stopOnRefusal(controlPlane.client.heartbeatRunner(input.runnerId, reported)));
3015
+ const firstHeartbeat = yield* startupStep("first heartbeat", "30 seconds", stopOnRefusal(controlPlane.client.heartbeatRunner(input.runnerId, reported)));
3016
+ const keepsSettings = firstHeartbeat.settings !== undefined;
3017
+ const runner = keepsSettings && Object.keys(hostSettings.environment.settings).length > 0 ? yield* startupStep("report the environment settings", "30 seconds", stopOnRefusal(controlPlane.client.heartbeatRunner(input.runnerId, {
3018
+ ...reported,
3019
+ environmentSettings: hostSettings.environment.settings
3020
+ }))) : firstHeartbeat;
2877
3021
  const personal = runner.ownership.kind === "personal";
2878
- const host = yield* startupStep("check the sandbox", "30 seconds", probeSandboxHost(yield* yield* SandboxHostProbe, undefined, settings.dockerImage === undefined ? {} : { dockerImage: settings.dockerImage }));
2879
- const sandbox = personal ? settings.sandbox : host.backends.includes("docker") ? "docker" : "srt";
3022
+ const settings = runner.settings ?? {
3023
+ ...defaultRunnerSettings(personal),
3024
+ ...hostSettings.environment.settings
3025
+ };
3026
+ if (runner.settings !== undefined)
3027
+ for (const warning of deprecationWarnings(hostSettings.environment.variables, runner.settings))
3028
+ yield* error(`Runner start: ${warning}`);
3029
+ const host = yield* startupStep("check the sandbox", "30 seconds", probeSandboxHost(yield* yield* SandboxHostProbe, undefined, settings.dockerImage === null ? {} : { dockerImage: settings.dockerImage }));
3030
+ const chosen = appliedSandbox({
3031
+ wanted: settings.sandbox,
3032
+ personal,
3033
+ available: host.backends,
3034
+ unavailable: host.unavailable,
3035
+ fullAccessAllowed: hostSettings.fullAccessAllowed
3036
+ });
3037
+ const sandbox = chosen.sandbox;
2880
3038
  const stopOn = (problem) => startupStep("report the Runner Problem", "30 seconds", stopOnRefusal(controlPlane.client.heartbeatRunner(input.runnerId, { ...reported, problems: [problem] }))).pipe(andThen2(fail7(new RunnerStopped({ problem }))));
2881
- if (personal && sandbox !== "host" && !host.backends.includes(sandbox))
2882
- return yield* stopOn(sandboxMissing(sandbox, host.unavailable.find((entry) => entry.backend === sandbox)?.missing ?? ["unsupported"]));
3039
+ if (personal && chosen.problem !== undefined && sandbox !== "host" && !host.backends.includes(sandbox))
3040
+ return yield* stopOn(chosen.problem);
2883
3041
  const session = herdrCoreSession(input.runnerId, personal);
2884
3042
  const coreProblems = yield* (yield* UpdateHerdrCore)({
2885
3043
  ...session === undefined ? undefined : { session },
@@ -2892,8 +3050,6 @@ function startCanonicalHerdrRunnerCommand(input) {
2892
3050
  if (!personal)
2893
3051
  yield* addFinalizer2(() => core.stopServer.pipe(timeout("10 seconds"), ignore));
2894
3052
  const stepProcesses = makeStepProcesses(yield* systemProcessTable, { scopes: yield* systemdScopes });
2895
- const uncontained = stepProcessesUncontained({ sandbox, scoped: stepProcesses.scoped });
2896
- const startupProblems = uncontained === undefined ? coreProblems : [...coreProblems, uncontained];
2897
3053
  const unready = yield* startupStep("connect to herdr-core", "30 seconds", core.connect.pipe(flatMap3((connection) => removeRunnerTerminals(connection, input.runnerId)), scoped, andThen2(stepProcesses.reapRunner(input.runnerId)), as(undefined), catchTags({
2898
3054
  HerdrCoreMissing: (error) => succeed6(herdrCoreMissing(error)),
2899
3055
  HerdrCoreIncompatible: (error) => succeed6(herdrCoreMissing(error))
@@ -2920,35 +3076,57 @@ function startCanonicalHerdrRunnerCommand(input) {
2920
3076
  };
2921
3077
  const detected = yield* detectHarnesses;
2922
3078
  const inSrt = sandbox === "srt" ? yield* startupStep("start each Harness in srt", "120 seconds", harnessesInSrt({ detection: detected, runner: runnerState })) : undefined;
2923
- const harnesses = inSrt?.detection ?? detected;
2924
- const advertisedCapabilities = repoBinding === undefined ? herdrRunnerCapabilities({ harnesses, fullAccess, sandbox: host, shared: !personal, agentSandbox: sandbox }) : herdrRunnerCapabilitiesForRepoBinding(repoBinding, {
2925
- harnesses,
2926
- fullAccess,
2927
- sandbox: host,
2928
- shared: !personal,
2929
- agentSandbox: sandbox,
2930
- sshAgentAvailable
2931
- });
2932
- const capabilities = {
2933
- ...advertisedCapabilities,
2934
- resourceLimits: { ...advertisedCapabilities.resourceLimits, maxConcurrentRuns: concurrency }
3079
+ const live = { settings, sandbox, sandboxProblem: chosen.problem, inSrt };
3080
+ const srtBinaries = { ...inSrt?.binaries };
3081
+ const capabilitiesNow = () => {
3082
+ const harnesses = live.sandbox === "srt" && live.inSrt !== undefined ? live.inSrt.detection : detected;
3083
+ const profile = {
3084
+ harnesses,
3085
+ fullAccess,
3086
+ sandbox: host,
3087
+ shared: !personal,
3088
+ agentSandbox: live.sandbox
3089
+ };
3090
+ const advertised = repoBinding === undefined ? herdrRunnerCapabilities(profile) : herdrRunnerCapabilitiesForRepoBinding(repoBinding, { ...profile, sshAgentAvailable });
3091
+ return {
3092
+ ...advertised,
3093
+ resourceLimits: { ...advertised.resourceLimits, maxConcurrentRuns: live.settings.concurrency }
3094
+ };
3095
+ };
3096
+ const problemsNow = () => {
3097
+ const uncontained = stepProcessesUncontained({ sandbox: live.sandbox, scoped: stepProcesses.scoped });
3098
+ return [
3099
+ ...coreProblems,
3100
+ ...uncontained === undefined ? [] : [uncontained],
3101
+ ...live.sandboxProblem === undefined ? [] : [live.sandboxProblem]
3102
+ ];
2935
3103
  };
2936
- assertHerdrRunnerCapability(capabilities);
3104
+ assertHerdrRunnerCapability(capabilitiesNow());
2937
3105
  const replica = yield* startupStep("register the replica", "30 seconds", stopOnRefusal(controlPlane.client.registerRunnerReplica(input.runnerId, {
2938
3106
  name: `replica-${createId()}`,
2939
- capacity: { maxConcurrentRuns: concurrency },
3107
+ capacity: { maxConcurrentRuns: live.settings.concurrency },
2940
3108
  telemetry: { activeWorkUnits: 0 }
2941
3109
  })));
2942
3110
  const uid = process.getuid?.();
2943
3111
  const gid = process.getgid?.();
2944
- const docker = host.backends.includes("docker") && settings.dockerImage !== undefined ? {
3112
+ const docker = host.backends.includes("docker") && settings.dockerImage !== null ? {
2945
3113
  containers: yield* dockerContainerRunner,
2946
3114
  image: settings.dockerImage,
2947
3115
  ...uid === undefined || gid === undefined ? undefined : { user: `${uid}:${gid}` }
2948
3116
  } : undefined;
3117
+ const appliedSettings = () => ({
3118
+ concurrency: live.settings.concurrency,
3119
+ sandbox: live.sandbox,
3120
+ dockerImage: settings.dockerImage,
3121
+ checkHosts: live.settings.checkHosts,
3122
+ checkDockerImage: settings.checkDockerImage,
3123
+ checkRegistryImage: settings.checkRegistryImage,
3124
+ fullAccessAllowed: hostSettings.fullAccessAllowed
3125
+ });
3126
+ const appliedSettingsReport = () => keepsSettings ? { appliedSettings: appliedSettings() } : undefined;
2949
3127
  const root = herdrCoreAgentBackendLayer({
2950
3128
  sandboxBackends: host.backends,
2951
- ...inSrt === undefined ? undefined : { srtBinaries: inSrt.binaries },
3129
+ srtBinaries,
2952
3130
  ...docker === undefined ? undefined : { docker: { ...docker, runnerId: input.runnerId } }
2953
3131
  }).pipe(provide2(succeed5(HerdrCore, core)), provide2(succeed5(StepProcesses, stepProcesses)), provide2(layer3));
2954
3132
  const activeSlots = new Set;
@@ -2964,13 +3142,14 @@ function startCanonicalHerdrRunnerCommand(input) {
2964
3142
  const spawner = yield* ChildProcessSpawner;
2965
3143
  yield* startupStep("heartbeat", "30 seconds", stopOnRefusal(controlPlane.client.heartbeatRunner(input.runnerId, {
2966
3144
  ...reported,
2967
- problems: startupProblems,
2968
- capabilities,
2969
- labels: runner.labels
3145
+ problems: problemsNow(),
3146
+ capabilities: capabilitiesNow(),
3147
+ labels: runner.labels,
3148
+ ...appliedSettingsReport()
2970
3149
  }).pipe(andThen2(controlPlane.client.heartbeatRunnerReplica(input.runnerId, replica.id, {
2971
3150
  healthStatus: "healthy",
2972
3151
  drainState: "accepting",
2973
- capacity: { maxConcurrentRuns: concurrency },
3152
+ capacity: { maxConcurrentRuns: live.settings.concurrency },
2974
3153
  telemetry: { activeWorkUnits: 0 }
2975
3154
  })))));
2976
3155
  return yield* scoped(gen(function* () {
@@ -2981,7 +3160,7 @@ function startCanonicalHerdrRunnerCommand(input) {
2981
3160
  }).pipe(tap2((opened) => opened.settledRuns([])))));
2982
3161
  const signals = yield* makeReplicaSignals;
2983
3162
  const bundles = yield* kitmanBundles({
2984
- fetch: (digest) => rpc.bundle(digest).pipe(map7((found) => found.bundle)),
3163
+ fetch: (digest) => rpc.bundle(digest).pipe(map8((found) => found.bundle)),
2985
3164
  cacheDir: bundleCache
2986
3165
  });
2987
3166
  const checkouts = runCheckouts(path.join(runnerRootDir, ".kitman"), rpc.gitCredential);
@@ -3005,8 +3184,50 @@ function startCanonicalHerdrRunnerCommand(input) {
3005
3184
  runner: runnerState,
3006
3185
  ...docker !== undefined ? { backend: "docker", docker, runnerId: input.runnerId } : { backend: host.backends.includes("srt") ? "srt" : undefined }
3007
3186
  };
3008
- const personalChecks = personalCheckBackend(sandbox, docker !== undefined);
3009
- const checkSandbox = !personal ? sharedSandbox : personalChecks === "docker" && docker !== undefined ? { runner: runnerState, backend: "docker", docker, runnerId: input.runnerId } : personalChecks === "srt" ? { runner: runnerState, backend: "srt" } : undefined;
3187
+ const checkSandbox = () => {
3188
+ if (!personal)
3189
+ return live.sandbox === "srt" && host.backends.includes("srt") ? { runner: runnerState, backend: "srt" } : sharedSandbox;
3190
+ const personalChecks = personalCheckBackend(live.sandbox, docker !== undefined);
3191
+ if (personalChecks === "docker" && docker !== undefined)
3192
+ return { runner: runnerState, backend: "docker", docker, runnerId: input.runnerId };
3193
+ return personalChecks === "srt" ? { runner: runnerState, backend: "srt" } : undefined;
3194
+ };
3195
+ let preparingSrt = false;
3196
+ const applySettings = (next) => gen(function* () {
3197
+ if (next === undefined)
3198
+ return;
3199
+ live.settings = next;
3200
+ const wanted = appliedSandbox({
3201
+ wanted: next.sandbox,
3202
+ personal,
3203
+ available: host.backends,
3204
+ unavailable: host.unavailable,
3205
+ fullAccessAllowed: hostSettings.fullAccessAllowed,
3206
+ current: live.sandbox
3207
+ });
3208
+ if (wanted.sandbox === live.sandbox) {
3209
+ live.sandboxProblem = wanted.problem;
3210
+ return;
3211
+ }
3212
+ if (wanted.sandbox !== "host" && !host.backends.includes(wanted.sandbox)) {
3213
+ live.sandboxProblem = wanted.problem;
3214
+ return;
3215
+ }
3216
+ if (wanted.sandbox === "srt" && live.inSrt === undefined) {
3217
+ if (preparingSrt)
3218
+ return;
3219
+ preparingSrt = true;
3220
+ return yield* harnessesInSrt({ detection: detected, runner: runnerState }).pipe(flatMap3((prepared) => sync2(() => {
3221
+ Object.assign(srtBinaries, prepared.binaries);
3222
+ live.inSrt = prepared;
3223
+ })), catchCause2((cause) => logWarning("runner_srt_switch_failed", pretty(cause))), ensuring2(sync2(() => preparingSrt = false)), provideContext2(platform), forkIn(scope), asVoid);
3224
+ }
3225
+ live.sandbox = wanted.sandbox;
3226
+ live.sandboxProblem = wanted.problem;
3227
+ yield* error(`Runner: its settings run new Steps in ${wanted.sandbox} now`);
3228
+ });
3229
+ const stepSandboxes = new Map;
3230
+ const sandboxOf = (work) => stepSandboxes.get(work.id) ?? live.sandbox;
3010
3231
  const runKitProgram = programProcessExecutor({
3011
3232
  bundles,
3012
3233
  apiUrl: input.apiUrl,
@@ -3034,7 +3255,7 @@ function startCanonicalHerdrRunnerCommand(input) {
3034
3255
  const storage = yield* provide3(service(HttpClient), layer4);
3035
3256
  const runAgentStep = agentStepExecutor({
3036
3257
  rootDir: path.join(runnerRootDir, ".kitman"),
3037
- sandbox,
3258
+ sandbox: sandboxOf,
3038
3259
  heartbeat: heartbeatOf,
3039
3260
  gitCredentials: rpc.gitCredential,
3040
3261
  checkpoints: rpcStepCheckpoints(rpc, signals, storage),
@@ -3052,19 +3273,19 @@ function startCanonicalHerdrRunnerCommand(input) {
3052
3273
  ...work.secretDestinations === undefined ? undefined : { secretDestinations: work.secretDestinations }
3053
3274
  },
3054
3275
  recordRefusal: refused,
3055
- revokedSecrets: heartbeatOf(work).pipe(map7((state) => state.revokedSecrets ?? [])),
3276
+ revokedSecrets: heartbeatOf(work).pipe(map8((state) => state.revokedSecrets ?? [])),
3056
3277
  sandbox: {
3057
- backend: work.sandbox ?? sandbox,
3278
+ backend: work.sandbox ?? sandboxOf(work),
3058
3279
  policy: agentStepSandboxPolicy(work, input.apiUrl, runnerState)
3059
3280
  },
3060
- settled: heartbeatOf(work).pipe(map7((state) => state.settled || state.outputSubmitted === true)),
3281
+ settled: heartbeatOf(work).pipe(map8((state) => state.settled || state.outputSubmitted === true)),
3061
3282
  ...agentStepExecutionLimit(work, now),
3062
3283
  steering: {
3063
3284
  ...signals.steers(work.id),
3064
3285
  report: (note, delivered) => andThen2(delivered ? steered(note) : void_3, rpc.reportSteer({ workUnitId: work.id, messageId: note.messageId, delivered }).pipe(catch_((error) => logWarning("runner_steer_report_failed", error.message))))
3065
3286
  }
3066
- }).pipe(map7((outcome) => agentStepRunOutcome(outcome, {
3067
- sandbox: work.sandbox ?? sandbox,
3287
+ }).pipe(map8((outcome) => agentStepRunOutcome(outcome, {
3288
+ sandbox: work.sandbox ?? sandboxOf(work),
3068
3289
  lacksLoginSecret: lacksLoginSecret(work.brief.harness, work.secrets)
3069
3290
  })), catch_((refusal) => succeed6({ status: "failed", summary: refusal.summary }))))
3070
3291
  });
@@ -3077,22 +3298,24 @@ function startCanonicalHerdrRunnerCommand(input) {
3077
3298
  }).pipe(ignore);
3078
3299
  yield* removeOrphanedCheckPostgres;
3079
3300
  yield* removeOrphanedCheckPostgres.pipe(delay(checkPostgresSweepInterval), forever, forkScoped);
3080
- const runVerification = verificationExecutor({
3081
- rootDir: path.join(runnerRootDir, ".kitman"),
3082
- known: rpcKnownEvidence(rpc),
3083
- gitCredentials: rpc.gitCredential,
3084
- runFiles: { client: rpc, storage },
3085
- postgres: dockerCheckPostgres(input.runnerId, replica.id),
3086
- ...settings.checkDockerImage === undefined || settings.checkRegistryImage === undefined ? undefined : {
3087
- docker: dockerCheckDaemon({
3088
- runnerId: input.runnerId,
3089
- replicaId: replica.id,
3090
- image: settings.checkDockerImage,
3091
- registryImage: settings.checkRegistryImage
3092
- })
3093
- },
3094
- ...checkSandbox === undefined ? undefined : { sandbox: { ...checkSandbox, apiUrl: input.apiUrl, hosts: settings.checkHosts } }
3301
+ const checkDocker = settings.checkDockerImage === null || settings.checkRegistryImage === null ? undefined : dockerCheckDaemon({
3302
+ runnerId: input.runnerId,
3303
+ replicaId: replica.id,
3304
+ image: settings.checkDockerImage,
3305
+ registryImage: settings.checkRegistryImage
3095
3306
  });
3307
+ const runVerification = (work) => {
3308
+ const sandbox = checkSandbox();
3309
+ return verificationExecutor({
3310
+ rootDir: path.join(runnerRootDir, ".kitman"),
3311
+ known: rpcKnownEvidence(rpc),
3312
+ gitCredentials: rpc.gitCredential,
3313
+ runFiles: { client: rpc, storage },
3314
+ postgres: dockerCheckPostgres(input.runnerId, replica.id),
3315
+ ...checkDocker === undefined ? undefined : { docker: checkDocker },
3316
+ ...sandbox === undefined ? undefined : { sandbox: { ...sandbox, apiUrl: input.apiUrl, hosts: live.settings.checkHosts } }
3317
+ })(work);
3318
+ };
3096
3319
  const control = (capacitySlot) => {
3097
3320
  return {
3098
3321
  claim: (idempotencyKey) => suspend3(() => {
@@ -3112,13 +3335,14 @@ function startCanonicalHerdrRunnerCommand(input) {
3112
3335
  finished: () => sync2(() => activeSlots.delete(capacitySlot)),
3113
3336
  heartbeatReplica: () => flatMap3(stepProcesses.problems, (unreaped) => controlPlane.client.heartbeatRunner(input.runnerId, {
3114
3337
  ...reported,
3115
- problems: [...startupProblems, ...updater.problems(), ...unreaped],
3116
- capabilities,
3117
- labels: runner.labels
3118
- })).pipe(flatMap3(() => controlPlane.client.heartbeatRunnerReplica(input.runnerId, replica.id, {
3338
+ problems: [...problemsNow(), ...updater.problems(), ...unreaped],
3339
+ capabilities: capabilitiesNow(),
3340
+ labels: runner.labels,
3341
+ ...appliedSettingsReport()
3342
+ })).pipe(flatMap3((heartbeat) => applySettings(heartbeat.settings)), flatMap3(() => controlPlane.client.heartbeatRunnerReplica(input.runnerId, replica.id, {
3119
3343
  healthStatus: "healthy",
3120
3344
  drainState: updater.claiming() ? "accepting" : "draining",
3121
- capacity: { maxConcurrentRuns: concurrency },
3345
+ capacity: { maxConcurrentRuns: live.settings.concurrency },
3122
3346
  telemetry: { activeWorkUnits: activeSlots.size }
3123
3347
  }).pipe(asVoid))),
3124
3348
  heartbeatWork: (workUnitId, lease) => rpc.heartbeat({ workUnitId, lease }),
@@ -3131,7 +3355,8 @@ function startCanonicalHerdrRunnerCommand(input) {
3131
3355
  };
3132
3356
  };
3133
3357
  const supervised = superviseReplica({
3134
- slots: Array.from({ length: concurrency }, (_, index) => `slot-${index + 1}`),
3358
+ slots: Array.from({ length: MaxRunnerConcurrency }, (_, index) => `slot-${index + 1}`),
3359
+ concurrency: sync2(() => live.settings.concurrency),
3135
3360
  control,
3136
3361
  executor: {
3137
3362
  execute: (work) => {
@@ -3139,7 +3364,10 @@ function startCanonicalHerdrRunnerCommand(input) {
3139
3364
  case "orchestration":
3140
3365
  return runKitProgram(work).pipe(provideContext2(platform));
3141
3366
  case "agent_step":
3142
- return runAgentStep(work).pipe(provideContext2(platform), failedWhenUnrun("agent Step"));
3367
+ return suspend3(() => {
3368
+ stepSandboxes.set(work.id, live.sandbox);
3369
+ return runAgentStep(work);
3370
+ }).pipe(ensuring2(sync2(() => stepSandboxes.delete(work.id))), provideContext2(platform), failedWhenUnrun("agent Step"));
3143
3371
  case "verification":
3144
3372
  return runVerification(work).pipe(provideContext2(platform), failedWhenUnrun("verification"));
3145
3373
  }
@@ -3175,7 +3403,7 @@ function mcpCommand(args) {
3175
3403
  if (command.action === "run") {
3176
3404
  if (command.args.length > 0)
3177
3405
  return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
3178
- const { runMcpServerCommand } = yield* promise(() => import("./chunk-aba9zdpb.js"));
3406
+ const { runMcpServerCommand } = yield* promise(() => import("./chunk-tk85pw4z.js"));
3179
3407
  return yield* runMcpServerCommand({ flags: command.flags });
3180
3408
  }
3181
3409
  if (command.action !== "setup")
@@ -4016,7 +4244,7 @@ function transcriptCommand(args) {
4016
4244
  return yield* new CliError({
4017
4245
  message: `Run ${runId} has no ${stepKey === undefined ? "Step attempts" : `attempt of ${stepKey}`}${attempt === undefined ? "" : ` numbered ${attempt}`}`
4018
4246
  });
4019
- const items = yield* forEach(asked, (found) => map7(transcriptAfter(client, runId, found.id, 0), (entries) => ({
4247
+ const items = yield* forEach(asked, (found) => map8(transcriptAfter(client, runId, found.id, 0), (entries) => ({
4020
4248
  stepKey: found.stepKey,
4021
4249
  attempt: found.attempt,
4022
4250
  stepAttemptId: found.id,
@@ -4295,7 +4523,7 @@ function verifyCommand(args) {
4295
4523
  }
4296
4524
  });
4297
4525
  }
4298
- var secretValueFromStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map7((text) => text.replace(/\r?\n$/, "")));
4526
+ var secretValueFromStdin = Stdio.pipe(flatMap3((stdio) => mkString(decodeText(stdio.stdin))), map8((text) => text.replace(/\r?\n$/, "")));
4299
4527
  function secretCommand(args) {
4300
4528
  return gen(function* () {
4301
4529
  const command = parseCommand(args.length === 1 ? [...args, "list"] : args);
@@ -4386,9 +4614,9 @@ function claimCommand(args) {
4386
4614
  }
4387
4615
  });
4388
4616
  }
4389
- var KitWriter = map7(promise(() => import("./chunk-j8vq6sk1.js")), (build) => build.writeKit);
4617
+ var KitWriter = map8(promise(() => import("./chunk-cy7cy84h.js")), (build) => build.writeKit);
4390
4618
  var KitBuilder = Reference("kitman/cli/KitBuilder", {
4391
- defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-j8vq6sk1.js")), (build) => build.buildKit(directory))
4619
+ defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-cy7cy84h.js")), (build) => build.buildKit(directory))
4392
4620
  });
4393
4621
  var uploadKit = (client, workspaceId, built) => gen(function* () {
4394
4622
  yield* client.uploadKitBundle(workspaceId, built.digest, { bundle: encode2(built.bundle) });
@@ -4405,7 +4633,7 @@ var buildKitInto = (command) => gen(function* () {
4405
4633
  yield* (yield* KitWriter)(directory, built, out).pipe(mapError2(() => new CliError({ message: `${path.join(directory, "package.json")} is not a JSON object` })));
4406
4634
  yield* log(`Built ${built.name} ${built.version} into ${out}`);
4407
4635
  });
4408
- var optionalEnv = (name) => String2(name).pipe(option, map7(getOrUndefined));
4636
+ var optionalEnv = (name) => String2(name).pipe(option, map8(getOrUndefined));
4409
4637
  var ciIdToken = (apiUrl) => gen(function* () {
4410
4638
  const gitlab = yield* optionalEnv("KITMAN_ID_TOKEN");
4411
4639
  if (gitlab !== undefined)
@@ -5065,7 +5293,7 @@ function runnerDoctorRow(runner) {
5065
5293
  maxConcurrentRuns: runner.capabilities.resourceLimits?.maxConcurrentRuns
5066
5294
  };
5067
5295
  }
5068
- var runnerDoctorRowHere = (runner) => map7(runnerServiceState(runnerServiceName(runner.id)), (service) => ({
5296
+ var runnerDoctorRowHere = (runner) => map8(runnerServiceState(runnerServiceName(runner.id)), (service) => ({
5069
5297
  ...runnerDoctorRow(runner),
5070
5298
  ...service === undefined ? undefined : { service }
5071
5299
  }));