@kitman-sh/cli 0.12.0-rc.7 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-gspfm7qh.js → chunk-0h49y8gf.js} +1 -1
- package/dist/{chunk-pd2vz4bm.js → chunk-0wdm7br1.js} +13 -15
- package/dist/{chunk-xcf887a4.js → chunk-4k5jfyqd.js} +39 -41
- package/dist/{chunk-znar1th3.js → chunk-4x06mdcd.js} +4 -4
- package/dist/{chunk-0346hwh6.js → chunk-5zhh41gb.js} +4 -5
- package/dist/{chunk-ewhzaqp3.js → chunk-5zth85pj.js} +2 -2
- package/dist/{chunk-j5t5nye5.js → chunk-cb78rzqd.js} +4 -4
- package/dist/{chunk-56knbdt6.js → chunk-cbpb2rww.js} +19 -21
- package/dist/{chunk-nzjb36ad.js → chunk-gq7y5v3e.js} +1 -1
- package/dist/{chunk-z450wa10.js → chunk-gy9rf14f.js} +3 -4
- package/dist/{chunk-xe8qf2xy.js → chunk-h3em3y8r.js} +111 -113
- package/dist/{chunk-bheg4ybe.js → chunk-mjdt8wbv.js} +18 -19
- package/dist/{chunk-xwya1er0.js → chunk-mtkstrh3.js} +4 -4
- package/dist/{chunk-qrm334c6.js → chunk-pf13sv65.js} +4 -4
- package/dist/{chunk-0qz10ek8.js → chunk-q5w3v4k1.js} +4 -4
- package/dist/{chunk-15geyg2d.js → chunk-qj6gjtdd.js} +87 -90
- package/dist/{chunk-wc2kba4z.js → chunk-s6z4aqag.js} +6 -7
- package/dist/{chunk-1t12wvv1.js → chunk-shv2xs9y.js} +92 -94
- package/dist/{chunk-r5sw3fe0.js → chunk-vw462m91.js} +10 -12
- package/dist/{chunk-8twjqszj.js → chunk-wh2ep6fc.js} +1 -1
- package/dist/{chunk-4w4spvb1.js → chunk-wyhg9cyk.js} +3 -3
- package/dist/{chunk-2e91ymwn.js → chunk-xaspqegt.js} +1 -1
- package/dist/{chunk-e4an66v2.js → chunk-xsdceanv.js} +5 -5
- package/dist/{chunk-5j848ckb.js → chunk-y1krmnbv.js} +2 -2
- package/dist/{chunk-vtfwjhzh.js → chunk-zw3gf6r5.js} +154 -24
- package/dist/index.js +4 -4
- package/package.json +1 -1
- 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
|
-
|
|
6
|
+
isFunction,
|
|
15
7
|
hasProperty,
|
|
16
8
|
isTagged,
|
|
17
9
|
isUint8Array,
|
|
@@ -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
|
-
|
|
169
|
+
encodeUnknownJsonStringSync,
|
|
170
|
+
storable
|
|
171
|
+
} from "./chunk-zw3gf6r5.js";
|
|
173
172
|
import {
|
|
174
173
|
Id,
|
|
175
174
|
secretReference,
|
|
176
175
|
secretPlaceholder
|
|
177
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-q5w3v4k1.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-
|
|
250
|
+
} from "./chunk-shv2xs9y.js";
|
|
252
251
|
import {
|
|
253
252
|
join,
|
|
254
253
|
interrupt,
|
|
@@ -289,7 +288,7 @@ import {
|
|
|
289
288
|
writeSrtSettings2,
|
|
290
289
|
srtStepArgv2,
|
|
291
290
|
srtArgv2
|
|
292
|
-
} from "./chunk-
|
|
291
|
+
} from "./chunk-0h49y8gf.js";
|
|
293
292
|
import {
|
|
294
293
|
writeAgentEnvironmentConfigFile2,
|
|
295
294
|
readManifestSkillPaths2,
|
|
@@ -305,8 +304,8 @@ import {
|
|
|
305
304
|
applyAgentEnvironmentMaterialization2,
|
|
306
305
|
isPathWithin2,
|
|
307
306
|
skillIdentity2
|
|
308
|
-
} from "./chunk-
|
|
309
|
-
import"./chunk-
|
|
307
|
+
} from "./chunk-0wdm7br1.js";
|
|
308
|
+
import"./chunk-xsdceanv.js";
|
|
310
309
|
import {
|
|
311
310
|
egressAllowed,
|
|
312
311
|
writeSecretRegistry,
|
|
@@ -316,7 +315,7 @@ import {
|
|
|
316
315
|
secretFilter2,
|
|
317
316
|
opaqueTunnelRefusal2,
|
|
318
317
|
isOpaqueConnectReason2
|
|
319
|
-
} from "./chunk-
|
|
318
|
+
} from "./chunk-y1krmnbv.js";
|
|
320
319
|
import {
|
|
321
320
|
sliceBytes2,
|
|
322
321
|
maxLineBytes2,
|
|
@@ -324,23 +323,23 @@ import {
|
|
|
324
323
|
decodedOption2,
|
|
325
324
|
decoded2,
|
|
326
325
|
readOpencode2
|
|
327
|
-
} from "./chunk-
|
|
326
|
+
} from "./chunk-cbpb2rww.js";
|
|
328
327
|
import {
|
|
329
328
|
uploadRunFile,
|
|
330
329
|
programLease,
|
|
331
330
|
rpcRunFiles,
|
|
332
331
|
programHostsEnv,
|
|
333
332
|
undeclaredHostsEnv
|
|
334
|
-
} from "./chunk-
|
|
335
|
-
import"./chunk-
|
|
333
|
+
} from "./chunk-pf13sv65.js";
|
|
334
|
+
import"./chunk-cb78rzqd.js";
|
|
336
335
|
import {
|
|
337
336
|
nextInt
|
|
338
|
-
} from "./chunk-
|
|
337
|
+
} from "./chunk-gq7y5v3e.js";
|
|
339
338
|
import {
|
|
340
339
|
ChildProcessSpawner,
|
|
341
340
|
make3
|
|
342
|
-
} from "./chunk-
|
|
343
|
-
import"./chunk-
|
|
341
|
+
} from "./chunk-mtkstrh3.js";
|
|
342
|
+
import"./chunk-wyhg9cyk.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 (
|
|
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 (!
|
|
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 (!
|
|
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 (!
|
|
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 (
|
|
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 (
|
|
958
|
+
if (isString2(value))
|
|
960
959
|
candidate = value.trim();
|
|
961
|
-
else if (
|
|
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
|
|
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 =
|
|
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]) =>
|
|
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 },
|
|
2272
|
-
return value.type === "key" &&
|
|
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) => (
|
|
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
|
-
...
|
|
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 (
|
|
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 =
|
|
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) &&
|
|
2675
|
-
if (hosts === undefined && refreshHosts === undefined || field === undefined || !isJsonObject(credential) || !
|
|
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 &&
|
|
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) &&
|
|
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) &&
|
|
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) || !
|
|
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 (!
|
|
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) &&
|
|
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 (!
|
|
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 (!
|
|
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) &&
|
|
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 (!
|
|
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 (
|
|
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) &&
|
|
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" &&
|
|
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 (!
|
|
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) =>
|
|
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) &&
|
|
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 =
|
|
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(
|
|
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) &&
|
|
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 (
|
|
5247
|
-
const summary = bounded(
|
|
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 =
|
|
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) ||
|
|
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 =
|
|
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) =>
|
|
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 =
|
|
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 (
|
|
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
|
-
...
|
|
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) &&
|
|
5412
|
+
return isJsonObject(result) && isString2(result.answer) ? {
|
|
5416
5413
|
kind: "answer",
|
|
5417
5414
|
callId,
|
|
5418
|
-
...
|
|
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" &&
|
|
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" &&
|
|
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" &&
|
|
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 =
|
|
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" &&
|
|
5462
|
-
return called(callId, item.name,
|
|
5463
|
-
if (item.type === "custom_tool_call" &&
|
|
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" &&
|
|
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" &&
|
|
5477
|
+
if (block.type === "text" && isString2(block.text))
|
|
5481
5478
|
return [{ kind: "message", role: "assistant", text: bounded(block.text) }];
|
|
5482
|
-
if (block.type === "toolCall" &&
|
|
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" &&
|
|
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" || !
|
|
5491
|
+
if (part.type !== "tool" || !isString2(part.callID) || !isString2(part.tool) || !isJsonObject(state))
|
|
5495
5492
|
return [];
|
|
5496
|
-
const output =
|
|
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 ||
|
|
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
|
|
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
|
-
...
|
|
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 ?? (
|
|
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);
|
|
@@ -4,13 +4,12 @@ import {
|
|
|
4
4
|
runnerRpcUrl2,
|
|
5
5
|
makeRunnerRpcClient2,
|
|
6
6
|
makeProgramRpcClient2
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import"./chunk-
|
|
9
|
-
import"./chunk-
|
|
10
|
-
import"./chunk-
|
|
11
|
-
import"./chunk-
|
|
12
|
-
import"./chunk-
|
|
13
|
-
import"./chunk-vtfwjhzh.js";
|
|
7
|
+
} from "./chunk-cb78rzqd.js";
|
|
8
|
+
import"./chunk-wyhg9cyk.js";
|
|
9
|
+
import"./chunk-shv2xs9y.js";
|
|
10
|
+
import"./chunk-q5w3v4k1.js";
|
|
11
|
+
import"./chunk-0h49y8gf.js";
|
|
12
|
+
import"./chunk-zw3gf6r5.js";
|
|
14
13
|
export {
|
|
15
14
|
makeProgramRpcClient2 as makeProgramRpcClient,
|
|
16
15
|
makeRunnerRpcClient2 as makeRunnerRpcClient,
|