@kitman-sh/cli 0.12.0-rc.7 → 0.12.0-rc.8

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-15geyg2d.js → chunk-3cgshf16.js} +98 -101
  2. package/dist/{chunk-j5t5nye5.js → chunk-3kxwb7qn.js} +7 -7
  3. package/dist/{chunk-bheg4ybe.js → chunk-6pqxsnk1.js} +22 -23
  4. package/dist/{chunk-e4an66v2.js → chunk-7959aeck.js} +5 -5
  5. package/dist/{chunk-xwya1er0.js → chunk-892qrkb3.js} +14 -60
  6. package/dist/{chunk-0346hwh6.js → chunk-8sz25ptv.js} +4 -5
  7. package/dist/{chunk-1t12wvv1.js → chunk-9c9vrbh4.js} +205 -216
  8. package/dist/{chunk-8twjqszj.js → chunk-9q7qc1dg.js} +1 -1
  9. package/dist/{chunk-z450wa10.js → chunk-bz4bp0q7.js} +3 -4
  10. package/dist/{chunk-znar1th3.js → chunk-d8qcmqh5.js} +4 -4
  11. package/dist/{chunk-2e91ymwn.js → chunk-det0tmx7.js} +1 -1
  12. package/dist/{chunk-xe8qf2xy.js → chunk-dh09wyed.js} +127 -129
  13. package/dist/{chunk-ewhzaqp3.js → chunk-e711ebdj.js} +2 -2
  14. package/dist/{chunk-wc2kba4z.js → chunk-ey4mf341.js} +6 -7
  15. package/dist/{chunk-qrm334c6.js → chunk-jg8n8z0z.js} +4 -4
  16. package/dist/{chunk-4w4spvb1.js → chunk-jwc8bdga.js} +5 -5
  17. package/dist/{chunk-nzjb36ad.js → chunk-mm2m3bys.js} +1 -1
  18. package/dist/{chunk-r5sw3fe0.js → chunk-mmpcdj8f.js} +10 -12
  19. package/dist/{chunk-0qz10ek8.js → chunk-s8m2tzdr.js} +4 -4
  20. package/dist/{chunk-xcf887a4.js → chunk-scb6qgy2.js} +47 -49
  21. package/dist/{chunk-5j848ckb.js → chunk-skqn4h13.js} +2 -2
  22. package/dist/{chunk-56knbdt6.js → chunk-vkchn89k.js} +23 -25
  23. package/dist/{chunk-pd2vz4bm.js → chunk-vrms6e1m.js} +13 -15
  24. package/dist/{chunk-vtfwjhzh.js → chunk-x3cc7dfc.js} +379 -63
  25. package/dist/{chunk-gspfm7qh.js → chunk-y7vjk8vv.js} +31 -165
  26. package/dist/index.js +4 -4
  27. package/package.json +1 -1
  28. package/dist/chunk-c6rbt85q.js +0 -141
@@ -1,17 +1,9 @@
1
1
  // @bun
2
- import {
3
- toJsonValue,
4
- isKeyOf,
5
- isNumber,
6
- isObject,
7
- isJsonObject,
8
- isString
9
- } from "./chunk-c6rbt85q.js";
10
2
  import {
11
3
  pipeArguments,
12
4
  dual,
13
5
  identity,
14
- isFunction2,
6
+ isFunction,
15
7
  hasProperty,
16
8
  isTagged,
17
9
  isUint8Array,
@@ -49,7 +41,7 @@ import {
49
41
  isFailure2,
50
42
  hasInterrupts,
51
43
  makeUnsafe5,
52
- make16,
44
+ make15,
53
45
  _await,
54
46
  fail5,
55
47
  isDoneUnsafe,
@@ -163,18 +155,25 @@ import {
163
155
  fromJsonString,
164
156
  TaggedError2,
165
157
  Json,
158
+ toJsonValue,
159
+ isKeyOf,
160
+ isNumber2,
161
+ isObject2,
162
+ isJsonObject,
163
+ isString2,
166
164
  decodeJsonString,
167
165
  decodeJsonStringOption,
168
166
  encodeJsonStringSync,
169
167
  encodePrettyJsonString,
170
168
  decodeJsonStringSync,
171
- encodeUnknownJsonStringSync
172
- } from "./chunk-vtfwjhzh.js";
169
+ encodeUnknownJsonStringSync,
170
+ storable
171
+ } from "./chunk-x3cc7dfc.js";
173
172
  import {
174
173
  Id,
175
174
  secretReference,
176
175
  secretPlaceholder
177
- } from "./chunk-0qz10ek8.js";
176
+ } from "./chunk-s8m2tzdr.js";
178
177
  import {
179
178
  currentTimeMillis,
180
179
  SecureRandom,
@@ -248,7 +247,7 @@ import {
248
247
  installCommand,
249
248
  checkServicesFile,
250
249
  checkServices
251
- } from "./chunk-1t12wvv1.js";
250
+ } from "./chunk-9c9vrbh4.js";
252
251
  import {
253
252
  join,
254
253
  interrupt,
@@ -257,7 +256,7 @@ import {
257
256
  unbounded2,
258
257
  offer,
259
258
  makeUnsafe3,
260
- make11,
259
+ make10,
261
260
  fromQueue,
262
261
  fromPubSub,
263
262
  map2,
@@ -289,7 +288,7 @@ import {
289
288
  writeSrtSettings2,
290
289
  srtStepArgv2,
291
290
  srtArgv2
292
- } from "./chunk-gspfm7qh.js";
291
+ } from "./chunk-y7vjk8vv.js";
293
292
  import {
294
293
  writeAgentEnvironmentConfigFile2,
295
294
  readManifestSkillPaths2,
@@ -305,8 +304,12 @@ import {
305
304
  applyAgentEnvironmentMaterialization2,
306
305
  isPathWithin2,
307
306
  skillIdentity2
308
- } from "./chunk-pd2vz4bm.js";
309
- import"./chunk-e4an66v2.js";
307
+ } from "./chunk-vrms6e1m.js";
308
+ import"./chunk-7959aeck.js";
309
+ import {
310
+ ChildProcessSpawner,
311
+ make2
312
+ } from "./chunk-892qrkb3.js";
310
313
  import {
311
314
  egressAllowed,
312
315
  writeSecretRegistry,
@@ -316,7 +319,7 @@ import {
316
319
  secretFilter2,
317
320
  opaqueTunnelRefusal2,
318
321
  isOpaqueConnectReason2
319
- } from "./chunk-5j848ckb.js";
322
+ } from "./chunk-skqn4h13.js";
320
323
  import {
321
324
  sliceBytes2,
322
325
  maxLineBytes2,
@@ -324,23 +327,19 @@ import {
324
327
  decodedOption2,
325
328
  decoded2,
326
329
  readOpencode2
327
- } from "./chunk-56knbdt6.js";
330
+ } from "./chunk-vkchn89k.js";
328
331
  import {
329
332
  uploadRunFile,
330
333
  programLease,
331
334
  rpcRunFiles,
332
335
  programHostsEnv,
333
336
  undeclaredHostsEnv
334
- } from "./chunk-qrm334c6.js";
335
- import"./chunk-j5t5nye5.js";
337
+ } from "./chunk-jg8n8z0z.js";
338
+ import"./chunk-3kxwb7qn.js";
336
339
  import {
337
340
  nextInt
338
- } from "./chunk-nzjb36ad.js";
339
- import {
340
- ChildProcessSpawner,
341
- make3
342
- } from "./chunk-xwya1er0.js";
343
- import"./chunk-4w4spvb1.js";
341
+ } from "./chunk-mm2m3bys.js";
342
+ import"./chunk-jwc8bdga.js";
344
343
 
345
344
  // packages/core/src/sync-kit.ts
346
345
  import { createHash } from "crypto";
@@ -533,13 +532,13 @@ var SyncKitReferenceKeys = new Set([
533
532
  "syncKitHash"
534
533
  ]);
535
534
  function containsUnsafeSyncKitText(value, path = []) {
536
- if (isString(value)) {
535
+ if (isString2(value)) {
537
536
  const pattern = SyncKitReferenceKeys.has(path[path.length - 1] ?? "") ? UnsafeReferenceText : UnsafeText;
538
537
  return pattern.test(value);
539
538
  }
540
539
  if (Array.isArray(value))
541
540
  return value.some((item, index) => containsUnsafeSyncKitText(item, [...path, String(index)]));
542
- if (!isObject(value) || value === null)
541
+ if (!isObject2(value) || value === null)
543
542
  return false;
544
543
  return Object.entries(value).some(([key, item]) => containsUnsafeSyncKitText(item, [...path, key]));
545
544
  }
@@ -549,7 +548,7 @@ function stableJson(value) {
549
548
  function sortValue(value) {
550
549
  if (Array.isArray(value))
551
550
  return value.map(sortValue);
552
- if (!isObject(value) || value === null)
551
+ if (!isObject2(value) || value === null)
553
552
  return toJsonValue(value);
554
553
  const result = {};
555
554
  for (const key of Object.keys(value).sort())
@@ -768,7 +767,7 @@ function stableStringify(value) {
768
767
  function sortValue2(value) {
769
768
  if (Array.isArray(value))
770
769
  return value.map(sortValue2);
771
- if (!isObject(value) || value === null)
770
+ if (!isObject2(value) || value === null)
772
771
  return toJsonValue(value);
773
772
  const result = {};
774
773
  for (const key of Object.keys(value).sort()) {
@@ -825,7 +824,7 @@ var readJsonObject = (file) => gen(function* () {
825
824
  var optionalString = (value, label) => gen(function* () {
826
825
  if (value === undefined)
827
826
  return;
828
- if (isString(value) && value.trim().length > 0)
827
+ if (isString2(value) && value.trim().length > 0)
829
828
  return value;
830
829
  return yield* invalid(`${label} must be a non-empty string when provided`);
831
830
  });
@@ -956,9 +955,9 @@ function renderModelSetting(input, plan) {
956
955
  }
957
956
  const value = entry.item.value;
958
957
  let candidate;
959
- if (isString(value))
958
+ if (isString2(value))
960
959
  candidate = value.trim();
961
- else if (isObject(value) && value !== null) {
960
+ else if (isObject2(value) && value !== null) {
962
961
  candidate = readStringProperty(value, "model") ?? readStringProperty(value, "modelRef") ?? readStringProperty(value, "profileRef");
963
962
  }
964
963
  if (candidate === undefined || !SafeModelReference.test(candidate)) {
@@ -994,7 +993,7 @@ function renderModelSetting(input, plan) {
994
993
  }
995
994
  function readStringProperty(value, key) {
996
995
  const candidate = Object.getOwnPropertyDescriptor(value, key)?.value;
997
- return isString(candidate) && candidate.trim().length > 0 ? candidate.trim() : undefined;
996
+ return isString2(candidate) && candidate.trim().length > 0 ? candidate.trim() : undefined;
998
997
  }
999
998
  function renderOpenCode(input, plan) {
1000
999
  const mcp = objectMap(input.environment.mcpServers, (server) => renderOpenCodeMcpServer(input, server, plan));
@@ -1580,7 +1579,7 @@ function markdownSection(title, items) {
1580
1579
  }
1581
1580
  var UnsafeInstructionText = /(?:Bearer\s|(?:sk-|ghp_|glpat-)|secret|token|password|api[_ -]?key|(?:^|[\s])(?:\/|~\/|[A-Za-z]:\\\\))/iu;
1582
1581
  function safeInstructionValue(value) {
1583
- const text = isString(value) ? value : JSON.stringify(value);
1582
+ const text = isString2(value) ? value : JSON.stringify(value);
1584
1583
  if (text === undefined || UnsafeInstructionText.test(text))
1585
1584
  return "[REDACTED]";
1586
1585
  return text.slice(0, 240);
@@ -2265,11 +2264,11 @@ var decodeJwtExpiry = decodeUnknownOption(JwtExpiry);
2265
2264
  var CopilotAnswer = Struct({ token: String4, expires_at: Finite });
2266
2265
  var legacyCredential = (value) => {
2267
2266
  const metadata = isJsonObject(value.metadata) ? value.metadata : {};
2268
- const strings = Object.fromEntries(Object.entries(metadata).filter(([, entry]) => isString(entry)));
2267
+ const strings = Object.fromEntries(Object.entries(metadata).filter(([, entry]) => isString2(entry)));
2269
2268
  const carried = Object.keys(strings).length > 0 ? { metadata: strings } : undefined;
2270
2269
  if (value.type === "oauth")
2271
- return Object.assign({ type: "oauth", refresh: value.refresh ?? "", access: value.access ?? "", expires: value.expires ?? 0 }, isString(metadata.accountID) ? { accountId: metadata.accountID } : undefined, isString(metadata.enterpriseUrl) ? { enterpriseUrl: metadata.enterpriseUrl } : undefined, carried);
2272
- return value.type === "key" && isString(value.key) ? Object.assign({ type: "api", key: value.key }, carried) : undefined;
2270
+ return Object.assign({ type: "oauth", refresh: value.refresh ?? "", access: value.access ?? "", expires: value.expires ?? 0 }, isString2(metadata.accountID) ? { accountId: metadata.accountID } : undefined, isString2(metadata.enterpriseUrl) ? { enterpriseUrl: metadata.enterpriseUrl } : undefined, carried);
2271
+ return value.type === "key" && isString2(value.key) ? Object.assign({ type: "api", key: value.key }, carried) : undefined;
2273
2272
  };
2274
2273
  var activeCredentials = (entries) => {
2275
2274
  const chosen = {};
@@ -2322,7 +2321,7 @@ var xaiExpiry = (answered, now) => {
2322
2321
  return match(exp, { onNone: () => now + 3600000, onSome: ({ exp }) => exp * 1000 });
2323
2322
  };
2324
2323
  var openCodeConsole = "https://opencode.ai/console";
2325
- var consoleServer = (metadata) => (isString(metadata.server) ? metadata.server : openCodeConsole).replace(/^https:\/\/console\.opencode\.ai(?=\/|$)/, openCodeConsole);
2324
+ var consoleServer = (metadata) => (isString2(metadata.server) ? metadata.server : openCodeConsole).replace(/^https:\/\/console\.opencode\.ai(?=\/|$)/, openCodeConsole);
2326
2325
  var consoleMetadata = (credential) => isJsonObject(credential) && isJsonObject(credential.metadata) ? credential.metadata : {};
2327
2326
  var openCodeConsoleHosts = (credentials) => {
2328
2327
  if (credentials?.opencode === undefined)
@@ -2555,7 +2554,7 @@ var prepareHarness = (input) => gen(function* () {
2555
2554
  };
2556
2555
  const resolved = resolveHarnessLaunch({
2557
2556
  adapter: input.binary === undefined ? adapter : { ...adapter, binary: input.binary },
2558
- ...isString(model) ? { model } : undefined,
2557
+ ...isString2(model) ? { model } : undefined,
2559
2558
  ...effort === undefined ? undefined : { effort },
2560
2559
  mcp: { ...mcp, environment: Object.keys(mcp.env) },
2561
2560
  configDir,
@@ -2627,7 +2626,7 @@ var piResolved = (value, env = {}) => {
2627
2626
  if (name === undefined)
2628
2627
  return escaped ?? dollar;
2629
2628
  const found = env[name];
2630
- if (isString(found) && found !== "")
2629
+ if (isString2(found) && found !== "")
2631
2630
  return found;
2632
2631
  resolved = false;
2633
2632
  return dollar;
@@ -2654,7 +2653,7 @@ var piKey = (key, credential) => piResolved(key, isJsonObject(credential.env) ?
2654
2653
  var withConfiguringEnv = (credential, field) => {
2655
2654
  if (!isJsonObject(credential.env))
2656
2655
  return credential;
2657
- const named = isString(credential[field]) ? piNames(credential[field]) : [];
2656
+ const named = isString2(credential[field]) ? piNames(credential[field]) : [];
2658
2657
  return Object.assign({}, credential, {
2659
2658
  env: Object.fromEntries(Object.entries(credential.env).filter(([name]) => piConfiguringEnv.has(name) && !named.includes(name)))
2660
2659
  });
@@ -2671,8 +2670,8 @@ var perProviderPlaceholders = (tokenFields, keyValue = (key) => key, isCommand =
2671
2670
  const placed = Object.entries(credentials).flatMap(([provider, credential]) => {
2672
2671
  const hosts = login.hosts[provider];
2673
2672
  const refreshHosts = login.refreshTokenHosts?.[provider];
2674
- const field = isJsonObject(credential) && isString(credential.type) ? tokenFields[credential.type] : undefined;
2675
- if (hosts === undefined && refreshHosts === undefined || field === undefined || !isJsonObject(credential) || !isString(credential[field]) || !referenceNamePattern.test(provider))
2673
+ const field = isJsonObject(credential) && isString2(credential.type) ? tokenFields[credential.type] : undefined;
2674
+ if (hosts === undefined && refreshHosts === undefined || field === undefined || !isJsonObject(credential) || !isString2(credential[field]) || !referenceNamePattern.test(provider))
2676
2675
  return [];
2677
2676
  const token = credential.type === "oauth" ? credential[field] : keyValue(credential[field], credential);
2678
2677
  if (credential.type !== "oauth" && isCommand(credential[field]))
@@ -2685,7 +2684,7 @@ var perProviderPlaceholders = (tokenFields, keyValue = (key) => key, isCommand =
2685
2684
  const refresh = isOAuth(credential) ? credential.refresh : undefined;
2686
2685
  const tokenHosts = [...new Set([...hosts ?? [], ...refreshHosts ?? []])];
2687
2686
  const heldRefresh = !isOAuth(credential) ? undefined : {
2688
- refresh: refreshHosts !== undefined && isString(refresh) && refresh !== "" ? held(reference(`${login.referenceName}-${provider}-refresh`), refresh, refreshHosts) : ""
2687
+ refresh: refreshHosts !== undefined && isString2(refresh) && refresh !== "" ? held(reference(`${login.referenceName}-${provider}-refresh`), refresh, refreshHosts) : ""
2689
2688
  };
2690
2689
  return [
2691
2690
  [
@@ -2700,7 +2699,7 @@ var loginFormats = {
2700
2699
  pi: {
2701
2700
  expiry: (credentials, provider) => {
2702
2701
  const credential = credentials?.[provider];
2703
- return isOAuth(credential) && isNumber(credential.expires) ? credential.expires : undefined;
2702
+ return isOAuth(credential) && isNumber2(credential.expires) ? credential.expires : undefined;
2704
2703
  },
2705
2704
  withoutRefresh: (credentials) => Object.fromEntries(Object.entries(credentials).map(([provider, credential]) => [
2706
2705
  provider,
@@ -2712,7 +2711,7 @@ var loginFormats = {
2712
2711
  claude: {
2713
2712
  expiry: (credentials, provider) => {
2714
2713
  const credential = provider === claudeOAuth ? credentials?.[provider] : undefined;
2715
- return isJsonObject(credential) && isNumber(credential.expiresAt) ? credential.expiresAt : undefined;
2714
+ return isJsonObject(credential) && isNumber2(credential.expiresAt) ? credential.expiresAt : undefined;
2716
2715
  },
2717
2716
  withoutRefresh: (credentials) => {
2718
2717
  const credential = credentials[claudeOAuth];
@@ -2721,7 +2720,7 @@ var loginFormats = {
2721
2720
  byReference: (credentials, login, reference) => {
2722
2721
  const credential = credentials[claudeOAuth];
2723
2722
  const hosts = login.hosts[claudeOAuth];
2724
- if (!isJsonObject(credential) || !isString(credential.accessToken) || hosts === undefined)
2723
+ if (!isJsonObject(credential) || !isString2(credential.accessToken) || hosts === undefined)
2725
2724
  return;
2726
2725
  const name = reference(login.referenceName);
2727
2726
  return {
@@ -2821,7 +2820,7 @@ var renewableStepLogin = (login, referenced, http) => gen(function* () {
2821
2820
  });
2822
2821
  var loopbackHosts = new Set(["localhost", "127.0.0.1", "[::1]"]);
2823
2822
  var keyDestination = (baseUrl, fallback) => {
2824
- if (!isString(baseUrl))
2823
+ if (!isString2(baseUrl))
2825
2824
  return { hosts: fallback };
2826
2825
  const url = getOrUndefined(liftThrowable(() => new URL(baseUrl))());
2827
2826
  if (url?.protocol === "https:")
@@ -2845,7 +2844,7 @@ var providerDestinations = (config, hosts) => objectEntries(config?.providers).f
2845
2844
  if (!isJsonObject(provider))
2846
2845
  return [];
2847
2846
  const destination = keyDestination(provider.baseUrl, hosts[name]);
2848
- const models = (Array.isArray(provider.models) ? provider.models : []).map((model) => isJsonObject(model) && isString(model.baseUrl) ? keyDestination(model.baseUrl, destination.hosts) : destination);
2847
+ const models = (Array.isArray(provider.models) ? provider.models : []).map((model) => isJsonObject(model) && isString2(model.baseUrl) ? keyDestination(model.baseUrl, destination.hosts) : destination);
2849
2848
  return [{ name, provider, destination, models, inherited: inheritedDestination([destination, ...models]) }];
2850
2849
  });
2851
2850
  var loginHostsWithProviders = (operatorFiles) => gen(function* () {
@@ -2879,7 +2878,7 @@ var carriedProviders = (providers, referenced) => gen(function* () {
2879
2878
  return [{ path: providers.path, content: "{}" }];
2880
2879
  const tokens = {};
2881
2880
  const placeholder = (field, value, destination) => {
2882
- if (!isString(value))
2881
+ if (!isString2(value))
2883
2882
  return value;
2884
2883
  if (isPiCommand(value))
2885
2884
  return;
@@ -2946,7 +2945,7 @@ var carriedGlobalConfig = (config, referenced) => gen(function* () {
2946
2945
  if (operator === undefined)
2947
2946
  return [];
2948
2947
  const { [config.keyField]: key, ...rest } = withoutMcpServers(operator);
2949
- if (!isString(key) || referenced === undefined)
2948
+ if (!isString2(key) || referenced === undefined)
2950
2949
  return [{ path: config.path, content: encodeUnknownJsonStringSync(rest) }];
2951
2950
  const reference = referenced.reference(config.referenceName);
2952
2951
  yield* referenced.hold({ [reference]: { value: key, hosts: config.hosts } });
@@ -3543,7 +3542,7 @@ var rolloutDirectory = (file) => gen(function* () {
3543
3542
  const line = getOrUndefined(decodeJsonStringOption(start.split(`
3544
3543
  `, 1)[0] ?? ""));
3545
3544
  const payload = isJsonObject(line) ? line.payload : undefined;
3546
- return isJsonObject(payload) && isString(payload.cwd) ? payload.cwd : undefined;
3545
+ return isJsonObject(payload) && isString2(payload.cwd) ? payload.cwd : undefined;
3547
3546
  }).pipe(orElseSucceed(() => {
3548
3547
  return;
3549
3548
  }));
@@ -4845,7 +4844,7 @@ function controlFailureKind(error) {
4845
4844
  return "stale_lease";
4846
4845
  if (status === 401 || status === 403)
4847
4846
  return "unauthorized";
4848
- if (!isNumber(status) || status === 408 || status === 429 || status >= 500)
4847
+ if (!isNumber2(status) || status === 408 || status === 429 || status >= 500)
4849
4848
  return "transient";
4850
4849
  return "rejected";
4851
4850
  }
@@ -5112,7 +5111,7 @@ var shownArguments = (args) => {
5112
5111
  let room = maxTextChars;
5113
5112
  const shown = (value, depth) => {
5114
5113
  room -= 1;
5115
- if (isString(value)) {
5114
+ if (isString2(value)) {
5116
5115
  const fits = value.length <= room;
5117
5116
  const text = fits ? value : `[${value.length} characters left out]`;
5118
5117
  room -= text.length;
@@ -5161,17 +5160,15 @@ var sendRefusal = (error) => {
5161
5160
  const status = "status" in error ? error.status : undefined;
5162
5161
  return status === 500 ? "failed" : contentRefusals.has(status) ? "refused" : undefined;
5163
5162
  };
5164
- var sendFailure = (error) => ("code" in error) && isString(error.code) ? error.code : error.message;
5165
- var storableText = (text) => text.replaceAll("\x00", "").replaceAll(/\p{Cs}/gu, "");
5166
- var storable = (value) => isString(value) ? storableText(value) : Array.isArray(value) ? value.map(storable) : isJsonObject(value) ? Object.fromEntries(Object.entries(value).map(([key, field]) => [storableText(key), storable(field)])) : value;
5163
+ var sendFailure = (error) => ("code" in error) && isString2(error.code) ? error.code : error.message;
5167
5164
  var isKitmanAsk = (tool) => /kitman/.test(tool) && /(?:^|_|\.)ask$/.test(tool);
5168
5165
  var waitsOnPerson = (tool) => /kitman/.test(tool) && /(?:^|_|\.)(?:ask|submit_output)$/.test(tool);
5169
5166
  var filesOf = (tool, args) => {
5170
5167
  const patch = isJsonObject(args) ? args.patchText : args;
5171
- if (tool === "apply_patch" && isString(patch))
5168
+ if (tool === "apply_patch" && isString2(patch))
5172
5169
  return [...patch.matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].flatMap(([, path]) => path === undefined ? [] : [{ kind: "file", path: path.trim(), change: "changed" }]);
5173
5170
  const path = isJsonObject(args) ? args.file_path ?? args.filePath ?? args.path : undefined;
5174
- if (!isString(path) || path.length === 0)
5171
+ if (!isString2(path) || path.length === 0)
5175
5172
  return [];
5176
5173
  if (tool === "Read" || tool === "read")
5177
5174
  return [{ kind: "file", path, change: "read" }];
@@ -5179,7 +5176,7 @@ var filesOf = (tool, args) => {
5179
5176
  return [{ kind: "file", path, change: "changed" }];
5180
5177
  return [];
5181
5178
  };
5182
- var textOf = (content) => isString(content) ? content : Array.isArray(content) ? content.flatMap((block) => isJsonObject(block) && isString(block.text) ? [block.text] : []).join(`
5179
+ var textOf = (content) => isString2(content) ? content : Array.isArray(content) ? content.flatMap((block) => isJsonObject(block) && isString2(block.text) ? [block.text] : []).join(`
5183
5180
  `) : "";
5184
5181
  var resetTime = (seconds) => seconds !== undefined && Number.isFinite(seconds) && seconds > 0 ? { until: toIso(seconds * 1000) } : undefined;
5185
5182
  var claudeOutOfQuota = (line) => {
@@ -5192,7 +5189,7 @@ var claudeOutOfQuota = (line) => {
5192
5189
  if (line.apiError !== "usage_limit_reached")
5193
5190
  return;
5194
5191
  const info = isJsonObject(line.apiErrorParams) ? line.apiErrorParams.rate_limit_info : undefined;
5195
- const resetsAt = isJsonObject(info) && isNumber(info.resetsAt) ? info.resetsAt : undefined;
5192
+ const resetsAt = isJsonObject(info) && isNumber2(info.resetsAt) ? info.resetsAt : undefined;
5196
5193
  return { summary: bounded(text || "Usage limit reached"), ...resetTime(resetsAt) };
5197
5194
  };
5198
5195
  var claudeLoginLost = (line) => isJsonObject(line) && line.type === "assistant" && line.isApiErrorMessage === true && line.error === "authentication_failed" ? bounded((isJsonObject(line.message) ? textOf(line.message.content) : "") || "Authentication failed") : undefined;
@@ -5220,10 +5217,10 @@ var codexProviderRefusal = (line) => {
5220
5217
  if (!isJsonObject(error))
5221
5218
  return;
5222
5219
  const info = error.codex_error_info;
5223
- const tag = isString(info) ? info : isJsonObject(info) ? Object.keys(info)[0] : undefined;
5220
+ const tag = isString2(info) ? info : isJsonObject(info) ? Object.keys(info)[0] : undefined;
5224
5221
  const detail = isJsonObject(info) && tag !== undefined ? info[tag] : undefined;
5225
5222
  const status = isJsonObject(detail) ? detail.http_status_code : undefined;
5226
- const summary = bounded(isString(error.message) ? error.message : tag ?? "");
5223
+ const summary = bounded(isString2(error.message) ? error.message : tag ?? "");
5227
5224
  if (codexQuotaErrors.has(tag))
5228
5225
  return { summary, kind: "out_of_quota" };
5229
5226
  if (tag === "unauthorized" || status === 401)
@@ -5236,15 +5233,15 @@ var codexRateLimits = (line) => {
5236
5233
  return isJsonObject(limits) && (isJsonObject(limits.primary) || isJsonObject(limits.secondary)) ? limits : undefined;
5237
5234
  };
5238
5235
  var codexReset = (limits) => {
5239
- const resets = [limits?.primary, limits?.secondary].flatMap((window) => isJsonObject(window) && isNumber(window.used_percent) && window.used_percent >= 100 && isNumber(window.resets_at) ? [window.resets_at] : []);
5236
+ const resets = [limits?.primary, limits?.secondary].flatMap((window) => isJsonObject(window) && isNumber2(window.used_percent) && window.used_percent >= 100 && isNumber2(window.resets_at) ? [window.resets_at] : []);
5240
5237
  return resetTime(resets.length === 0 ? undefined : Math.max(...resets));
5241
5238
  };
5242
5239
  var opencodeQuotaErrors = /^provider\.(quota|free-limit|go-limit|budget-limit|model-budget-limit|chatgpt-limit)$/;
5243
5240
  var opencodeProviderRefusal = (error) => {
5244
5241
  if (!isJsonObject(error))
5245
5242
  return;
5246
- if (isString(error.type)) {
5247
- const summary = bounded(isString(error.message) ? error.message : error.type);
5243
+ if (isString2(error.type)) {
5244
+ const summary = bounded(isString2(error.message) ? error.message : error.type);
5248
5245
  if (opencodeQuotaErrors.test(error.type))
5249
5246
  return { summary, kind: "out_of_quota" };
5250
5247
  if (error.type === "provider.auth")
@@ -5252,13 +5249,13 @@ var opencodeProviderRefusal = (error) => {
5252
5249
  return error.type === "provider.rate-limit" ? { summary, kind: "rate_limited" } : undefined;
5253
5250
  }
5254
5251
  const data = isJsonObject(error.data) ? error.data : {};
5255
- const said = isString(data.message) ? data.message : isString(error.name) ? error.name : "";
5252
+ const said = isString2(data.message) ? data.message : isString2(error.name) ? error.name : "";
5256
5253
  const summary = bounded(said);
5257
5254
  if (error.name === "ProviderAuthError")
5258
5255
  return { summary, kind: "login_refused" };
5259
5256
  if (error.name !== "APIError")
5260
5257
  return;
5261
- if (quotaError.test(said) || isString(data.responseBody) && quotaError.test(data.responseBody))
5258
+ if (quotaError.test(said) || isString2(data.responseBody) && quotaError.test(data.responseBody))
5262
5259
  return { summary, kind: "out_of_quota" };
5263
5260
  if (data.statusCode === 401)
5264
5261
  return { summary, kind: "login_refused" };
@@ -5268,7 +5265,7 @@ var piProviderRefusal = (line) => {
5268
5265
  const message = isJsonObject(line) && line.type === "message" ? line.message : undefined;
5269
5266
  if (!isJsonObject(message) || message.role !== "assistant" || message.stopReason !== "error")
5270
5267
  return;
5271
- const said = isString(message.errorMessage) ? message.errorMessage : "";
5268
+ const said = isString2(message.errorMessage) ? message.errorMessage : "";
5272
5269
  const summary = bounded(said);
5273
5270
  if (passingLimit.test(said))
5274
5271
  return { summary, kind: "rate_limited", retried: true };
@@ -5284,7 +5281,7 @@ var sessionRefusals = new Map([
5284
5281
  ["codex", codexProviderRefusal],
5285
5282
  ["pi", piProviderRefusal]
5286
5283
  ]);
5287
- var count = (value) => isNumber(value) && value > 0 ? Math.floor(value) : 0;
5284
+ var count = (value) => isNumber2(value) && value > 0 ? Math.floor(value) : 0;
5288
5285
  var tokenCounter = (harness) => {
5289
5286
  const counted = { input: 0, output: 0, cached: 0 };
5290
5287
  let reported = false;
@@ -5301,7 +5298,7 @@ var tokenCounter = (harness) => {
5301
5298
  if (!isJsonObject(said) || !isJsonObject(said.usage))
5302
5299
  return;
5303
5300
  const { usage } = said;
5304
- const id = isString(said.id) ? said.id : undefined;
5301
+ const id = isString2(said.id) ? said.id : undefined;
5305
5302
  const spent = {
5306
5303
  input: count(usage.input_tokens) + count(usage.cache_creation_input_tokens),
5307
5304
  output: count(usage.output_tokens),
@@ -5397,7 +5394,7 @@ var sessionNormalizer = (harness) => {
5397
5394
  const called = (fullCallId, name, args) => {
5398
5395
  const callId = cutId(fullCallId);
5399
5396
  const question = isKitmanAsk(name) && isJsonObject(args) ? args.prompt : undefined;
5400
- if (isString(question))
5397
+ if (isString2(question))
5401
5398
  remembered(asks, callId);
5402
5399
  return [
5403
5400
  {
@@ -5406,16 +5403,16 @@ var sessionNormalizer = (harness) => {
5406
5403
  name: name.slice(0, maxToolNameChars) || "unnamed",
5407
5404
  arguments: shownArguments(args)
5408
5405
  },
5409
- ...isString(question) ? [{ kind: "question", text: bounded(question) }] : [],
5406
+ ...isString2(question) ? [{ kind: "question", text: bounded(question) }] : [],
5410
5407
  ...filesOf(name, args)
5411
5408
  ];
5412
5409
  };
5413
5410
  const answerOf = (callId, output) => {
5414
5411
  const result = decoded2(output);
5415
- return isJsonObject(result) && isString(result.answer) ? {
5412
+ return isJsonObject(result) && isString2(result.answer) ? {
5416
5413
  kind: "answer",
5417
5414
  callId,
5418
- ...isString(result.questionId) ? { questionId: result.questionId.slice(0, maxIdChars) } : undefined,
5415
+ ...isString2(result.questionId) ? { questionId: result.questionId.slice(0, maxIdChars) } : undefined,
5419
5416
  text: bounded(result.answer)
5420
5417
  } : { kind: "answer", callId, text: bounded(output) };
5421
5418
  };
@@ -5438,11 +5435,11 @@ var sessionNormalizer = (harness) => {
5438
5435
  return message.content.flatMap((block) => {
5439
5436
  if (!isJsonObject(block))
5440
5437
  return [];
5441
- if (line.type === "assistant" && block.type === "text" && isString(block.text))
5438
+ if (line.type === "assistant" && block.type === "text" && isString2(block.text))
5442
5439
  return [{ kind: "message", role: "assistant", text: bounded(block.text) }];
5443
- if (block.type === "tool_use" && isString(block.id) && isString(block.name))
5440
+ if (block.type === "tool_use" && isString2(block.id) && isString2(block.name))
5444
5441
  return called(block.id, block.name, block.input ?? null);
5445
- if (block.type === "tool_result" && isString(block.tool_use_id))
5442
+ if (block.type === "tool_result" && isString2(block.tool_use_id))
5446
5443
  return answered(block.tool_use_id, textOf(block.content), block.is_error === true);
5447
5444
  return [];
5448
5445
  });
@@ -5451,16 +5448,16 @@ var sessionNormalizer = (harness) => {
5451
5448
  const item = line.payload;
5452
5449
  if (line.type !== "response_item" || !isJsonObject(item))
5453
5450
  return [];
5454
- const callId = isString(item.call_id) ? item.call_id : undefined;
5451
+ const callId = isString2(item.call_id) ? item.call_id : undefined;
5455
5452
  if (item.type === "message" && item.role === "assistant") {
5456
5453
  const text = textOf(item.content);
5457
5454
  return text.length === 0 ? [] : [{ kind: "message", role: "assistant", text: bounded(text) }];
5458
5455
  }
5459
5456
  if (callId === undefined)
5460
5457
  return [];
5461
- if (item.type === "function_call" && isString(item.name))
5462
- return called(callId, item.name, isString(item.arguments) ? getOrElse(decodedOption2(item.arguments), () => item.arguments ?? null) : item.arguments ?? null);
5463
- if (item.type === "custom_tool_call" && isString(item.name))
5458
+ if (item.type === "function_call" && isString2(item.name))
5459
+ return called(callId, item.name, isString2(item.arguments) ? getOrElse(decodedOption2(item.arguments), () => item.arguments ?? null) : item.arguments ?? null);
5460
+ if (item.type === "custom_tool_call" && isString2(item.name))
5464
5461
  return called(callId, item.name, item.input ?? null);
5465
5462
  if (item.type === "function_call_output" || item.type === "custom_tool_call_output")
5466
5463
  return answered(callId, textOf(item.output), false);
@@ -5470,16 +5467,16 @@ var sessionNormalizer = (harness) => {
5470
5467
  const message = line.message;
5471
5468
  if (line.type !== "message" || !isJsonObject(message))
5472
5469
  return [];
5473
- if (message.role === "toolResult" && isString(message.toolCallId))
5470
+ if (message.role === "toolResult" && isString2(message.toolCallId))
5474
5471
  return answered(message.toolCallId, textOf(message.content), message.isError === true);
5475
5472
  if (message.role !== "assistant" || !Array.isArray(message.content))
5476
5473
  return [];
5477
5474
  return message.content.flatMap((block) => {
5478
5475
  if (!isJsonObject(block))
5479
5476
  return [];
5480
- if (block.type === "text" && isString(block.text))
5477
+ if (block.type === "text" && isString2(block.text))
5481
5478
  return [{ kind: "message", role: "assistant", text: bounded(block.text) }];
5482
- if (block.type === "toolCall" && isString(block.id) && isString(block.name))
5479
+ if (block.type === "toolCall" && isString2(block.id) && isString2(block.name))
5483
5480
  return called(block.id, block.name, block.arguments ?? null);
5484
5481
  return [];
5485
5482
  });
@@ -5488,12 +5485,12 @@ var sessionNormalizer = (harness) => {
5488
5485
  const { part, stage } = line;
5489
5486
  if (line.role !== "assistant" || !isJsonObject(part))
5490
5487
  return [];
5491
- if (part.type === "text" && isString(part.text))
5488
+ if (part.type === "text" && isString2(part.text))
5492
5489
  return [{ kind: "message", role: "assistant", text: bounded(part.text) }];
5493
5490
  const { state } = part;
5494
- if (part.type !== "tool" || !isString(part.callID) || !isString(part.tool) || !isJsonObject(state))
5491
+ if (part.type !== "tool" || !isString2(part.callID) || !isString2(part.tool) || !isJsonObject(state))
5495
5492
  return [];
5496
- const output = isString(state.output) ? state.output : isString(state.error) ? state.error : "";
5493
+ const output = isString2(state.output) ? state.output : isString2(state.error) ? state.error : "";
5497
5494
  return [
5498
5495
  ...line.callRecorded === true ? [] : called(part.callID, part.tool, state.input ?? null),
5499
5496
  ...stage === "settled" ? answered(part.callID, output, state.status === "error") : []
@@ -5525,7 +5522,7 @@ var opencodeV2Stage = (part, closed) => {
5525
5522
  if (!isJsonObject(part))
5526
5523
  return "settled";
5527
5524
  if (part.type === "text")
5528
- return closed || isString(part.text) && part.text.length > 0 ? "settled" : "open";
5525
+ return closed || isString2(part.text) && part.text.length > 0 ? "settled" : "open";
5529
5526
  if (part.type !== "tool")
5530
5527
  return "settled";
5531
5528
  const status = isJsonObject(part.state) ? part.state.status : undefined;
@@ -5537,7 +5534,7 @@ var opencodeV2Part = (part) => {
5537
5534
  if (!isJsonObject(part))
5538
5535
  return;
5539
5536
  if (part.type === "text")
5540
- return isString(part.text) && part.text.length > 0 ? part : undefined;
5537
+ return isString2(part.text) && part.text.length > 0 ? part : undefined;
5541
5538
  const { state } = part;
5542
5539
  if (part.type !== "tool" || !isJsonObject(state))
5543
5540
  return;
@@ -5549,7 +5546,7 @@ var opencodeV2Part = (part) => {
5549
5546
  state: {
5550
5547
  status: state.status ?? null,
5551
5548
  input: state.input ?? null,
5552
- ...isString(error) ? { error } : { output: textOf(state.content) }
5549
+ ...isString2(error) ? { error } : { output: textOf(state.content) }
5553
5550
  }
5554
5551
  };
5555
5552
  };
@@ -6262,7 +6259,7 @@ var stepAttempt = (input, resending) => (work) => gen(function* () {
6262
6259
  return yield* deliver(work.branch);
6263
6260
  const notes = [...work.resumeNotes ?? [], ...merge === undefined ? [] : [merge.note]];
6264
6261
  const configDir = yield* tempDirectoryScoped(yield* FileSystem, { prefix: "kitman-harness-" }).pipe(orDie);
6265
- const backend = work.sandbox ?? (isFunction2(input.sandbox) ? input.sandbox(work) : input.sandbox);
6262
+ const backend = work.sandbox ?? (isFunction(input.sandbox) ? input.sandbox(work) : input.sandbox);
6266
6263
  const writableSessions = adapter === undefined ? undefined : worktreeSessionDirectory(adapter, home, worktree);
6267
6264
  if (backend === "srt" && writableSessions !== undefined)
6268
6265
  yield* freshDirectory(writableSessions);
@@ -7041,7 +7038,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
7041
7038
  const input = yield* unbounded2();
7042
7039
  const pending = new Map;
7043
7040
  let lastId = 0;
7044
- const handle = yield* spawner.spawn(make3(binary, ["app-server"], {
7041
+ const handle = yield* spawner.spawn(make2(binary, ["app-server"], {
7045
7042
  cwd: env.home,
7046
7043
  extendEnv: true,
7047
7044
  env: { HOME: env.home, CODEX_HOME: env.codexHome },
@@ -7064,7 +7061,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
7064
7061
  return {
7065
7062
  request: (method, params) => gen(function* () {
7066
7063
  const id = ++lastId;
7067
- const deferred = yield* make16();
7064
+ const deferred = yield* make15();
7068
7065
  pending.set(id, deferred);
7069
7066
  yield* send({ id, method, params });
7070
7067
  return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
@@ -7204,10 +7201,10 @@ var handshake = [
7204
7201
  `).join("");
7205
7202
  var kitmanMcpPreflight = (mcp) => gen(function* () {
7206
7203
  const spawner = yield* ChildProcessSpawner;
7207
- const server = yield* spawner.spawn(make3(mcp.command, [...mcp.args], {
7204
+ const server = yield* spawner.spawn(make2(mcp.command, [...mcp.args], {
7208
7205
  extendEnv: true,
7209
7206
  env: mcp.env,
7210
- stdin: { stream: make11(new TextEncoder().encode(handshake)), endOnDone: false },
7207
+ stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
7211
7208
  stderr: "ignore"
7212
7209
  }));
7213
7210
  const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
@@ -7280,8 +7277,8 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
7280
7277
  };
7281
7278
  const exitCode = sandbox === undefined ? yield* gen(function* () {
7282
7279
  const spawner = yield* ChildProcessSpawner;
7283
- const handle = yield* spawner.spawn(make3(input.bun ?? process.execPath, [file], {
7284
- stdin: make11(new TextEncoder().encode(stdin)),
7280
+ const handle = yield* spawner.spawn(make2(input.bun ?? process.execPath, [file], {
7281
+ stdin: make10(new TextEncoder().encode(stdin)),
7285
7282
  stdout: "inherit",
7286
7283
  stderr: "inherit",
7287
7284
  extendEnv: false,