@liberseek/boft-cli-win32-arm64 0.7.8 → 0.8.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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +8 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +16801 -16440
- package/app/console-web.js +9774 -3685
- package/app/desktop-controller.mjs +16475 -374
- package/app/host-runtime.mjs +9052 -1793
- package/app/plugins/antigravity/manifest.json +18 -1
- package/app/plugins/antigravity/plugin.mjs +357 -42
- package/app/plugins/claude-code/manifest.json +28 -0
- package/app/plugins/claude-code/plugin.mjs +1448 -491
- package/app/plugins/codebuddy/manifest.json +17 -0
- package/app/plugins/codebuddy/plugin.mjs +6589 -5423
- package/app/plugins/codex-usage/manifest.json +9 -0
- package/app/plugins/codex-usage/plugin.mjs +16750 -0
- package/app/plugins/cursor-cli/manifest.json +18 -1
- package/app/plugins/cursor-cli/plugin.mjs +782 -197
- package/app/plugins/deepseek-harness/assets/icon.svg +1 -0
- package/app/plugins/deepseek-harness/manifest.json +35 -2
- package/app/plugins/deepseek-harness/plugin.mjs +879 -242
- package/app/plugins/enabled.json +3 -1
- package/app/plugins/grok/manifest.json +21 -1
- package/app/plugins/grok/plugin.mjs +1274 -241
- package/app/plugins/hermes/assets/icon.png +0 -0
- package/app/plugins/hermes/manifest.json +30 -2
- package/app/plugins/hermes/plugin.mjs +3493 -7686
- package/app/plugins/kimi-code/assets/icon.svg +5 -0
- package/app/plugins/kimi-code/manifest.json +25 -2
- package/app/plugins/kimi-code/plugin.mjs +922 -76
- package/app/plugins/kiro-cli/assets/kiro-agent.svg +11 -0
- package/app/plugins/kiro-cli/manifest.json +18 -1
- package/app/plugins/kiro-cli/plugin.mjs +658 -57
- package/app/plugins/muse/manifest.json +18 -1
- package/app/plugins/muse/plugin.mjs +332 -17
- package/app/plugins/omp/manifest.json +21 -1
- package/app/plugins/omp/plugin.mjs +2320 -1131
- package/app/plugins/opencode/manifest.json +18 -1
- package/app/plugins/opencode/plugin.mjs +979 -184
- package/app/plugins/pi/manifest.json +32 -0
- package/app/plugins/pi/plugin.mjs +2785 -2090
- package/app/plugins/qoder/manifest.json +18 -1
- package/app/plugins/qoder/plugin.mjs +832 -82
- package/app/plugins/qoder-cn/manifest.json +18 -1
- package/app/plugins/qoder-cn/plugin.mjs +832 -82
- package/app/plugins/workbuddy/manifest.json +18 -0
- package/app/plugins/workbuddy/plugin.mjs +6947 -5773
- package/app/plugins/zcode/assets/icon.svg +8 -0
- package/app/plugins/zcode/manifest.json +32 -0
- package/app/plugins/zcode/plugin.mjs +20110 -0
- package/app/renderer-extension.js +4762 -2470
- package/bin/boft.exe +0 -0
- package/libexec/boft-node-repl.exe +0 -0
- package/libexec/boft-shim.exe +0 -0
- package/libexec/boft-updater.exe +0 -0
- package/licenses/Cordis-LICENSE.txt +21 -0
- package/licenses/Cosmokit-LICENSE.txt +21 -0
- package/package.json +1 -1
- package/app/plugins/kiro-cli/assets/icon.svg +0 -5
|
@@ -396,7 +396,7 @@ async function npmInstallation(command, packages, environment) {
|
|
|
396
396
|
const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
397
397
|
let globalInstall = modules === globalRoot;
|
|
398
398
|
if (process.platform === "win32") {
|
|
399
|
-
const
|
|
399
|
+
const project2 = (await Promise.all(["package.json", "package-lock.json", "npm-shrinkwrap.json"].map((file2) => readFile(path4.join(prefix, file2), "utf8").then(() => true, (error51) => error51.code !== "ENOENT")))).some(Boolean);
|
|
400
400
|
const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
|
|
401
401
|
const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
|
|
402
402
|
if (path4.basename(bin) !== bin || entry.includes(".."))
|
|
@@ -407,7 +407,7 @@ async function npmInstallation(command, packages, environment) {
|
|
|
407
407
|
const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
|
|
408
408
|
return referencesNpmBin(shim, name, entry);
|
|
409
409
|
}));
|
|
410
|
-
globalInstall = globalInstall && !
|
|
410
|
+
globalInstall = globalInstall && !project2 && launchers.some(Boolean);
|
|
411
411
|
}
|
|
412
412
|
const canUpdate = globalInstall && !!npm;
|
|
413
413
|
return {
|
|
@@ -488,8 +488,8 @@ function createHarnessInstaller(environment, source) {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
// dist/kimi-adapter.js
|
|
491
|
-
import { readFile as
|
|
492
|
-
import
|
|
491
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
492
|
+
import path9 from "node:path";
|
|
493
493
|
import { isDeepStrictEqual } from "node:util";
|
|
494
494
|
|
|
495
495
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
@@ -1258,10 +1258,10 @@ function mergeDefs(...defs) {
|
|
|
1258
1258
|
function cloneDef(schema) {
|
|
1259
1259
|
return mergeDefs(schema._zod.def);
|
|
1260
1260
|
}
|
|
1261
|
-
function getElementAtPath(obj,
|
|
1262
|
-
if (!
|
|
1261
|
+
function getElementAtPath(obj, path10) {
|
|
1262
|
+
if (!path10)
|
|
1263
1263
|
return obj;
|
|
1264
|
-
return
|
|
1264
|
+
return path10.reduce((acc, key) => acc?.[key], obj);
|
|
1265
1265
|
}
|
|
1266
1266
|
function promiseAllObject(promisesObj) {
|
|
1267
1267
|
const keys = Object.keys(promisesObj);
|
|
@@ -1670,11 +1670,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1670
1670
|
}
|
|
1671
1671
|
return false;
|
|
1672
1672
|
}
|
|
1673
|
-
function prefixIssues(
|
|
1673
|
+
function prefixIssues(path10, issues) {
|
|
1674
1674
|
return issues.map((iss) => {
|
|
1675
1675
|
var _a3;
|
|
1676
1676
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1677
|
-
iss.path.unshift(
|
|
1677
|
+
iss.path.unshift(path10);
|
|
1678
1678
|
return iss;
|
|
1679
1679
|
});
|
|
1680
1680
|
}
|
|
@@ -1821,16 +1821,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1821
1821
|
}
|
|
1822
1822
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1823
1823
|
const fieldErrors = { _errors: [] };
|
|
1824
|
-
const processError = (error52,
|
|
1824
|
+
const processError = (error52, path10 = []) => {
|
|
1825
1825
|
for (const issue2 of error52.issues) {
|
|
1826
1826
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1827
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1827
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
1828
1828
|
} else if (issue2.code === "invalid_key") {
|
|
1829
|
-
processError({ issues: issue2.issues }, [...
|
|
1829
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1830
1830
|
} else if (issue2.code === "invalid_element") {
|
|
1831
|
-
processError({ issues: issue2.issues }, [...
|
|
1831
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1832
1832
|
} else {
|
|
1833
|
-
const fullpath = [...
|
|
1833
|
+
const fullpath = [...path10, ...issue2.path];
|
|
1834
1834
|
if (fullpath.length === 0) {
|
|
1835
1835
|
fieldErrors._errors.push(mapper(issue2));
|
|
1836
1836
|
} else {
|
|
@@ -1857,17 +1857,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1857
1857
|
}
|
|
1858
1858
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1859
1859
|
const result = { errors: [] };
|
|
1860
|
-
const processError = (error52,
|
|
1860
|
+
const processError = (error52, path10 = []) => {
|
|
1861
1861
|
var _a3, _b;
|
|
1862
1862
|
for (const issue2 of error52.issues) {
|
|
1863
1863
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1864
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1864
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
1865
1865
|
} else if (issue2.code === "invalid_key") {
|
|
1866
|
-
processError({ issues: issue2.issues }, [...
|
|
1866
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1867
1867
|
} else if (issue2.code === "invalid_element") {
|
|
1868
|
-
processError({ issues: issue2.issues }, [...
|
|
1868
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1869
1869
|
} else {
|
|
1870
|
-
const fullpath = [...
|
|
1870
|
+
const fullpath = [...path10, ...issue2.path];
|
|
1871
1871
|
if (fullpath.length === 0) {
|
|
1872
1872
|
result.errors.push(mapper(issue2));
|
|
1873
1873
|
continue;
|
|
@@ -1899,8 +1899,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1899
1899
|
}
|
|
1900
1900
|
function toDotPath(_path) {
|
|
1901
1901
|
const segs = [];
|
|
1902
|
-
const
|
|
1903
|
-
for (const seg of
|
|
1902
|
+
const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1903
|
+
for (const seg of path10) {
|
|
1904
1904
|
if (typeof seg === "number")
|
|
1905
1905
|
segs.push(`[${seg}]`);
|
|
1906
1906
|
else if (typeof seg === "symbol")
|
|
@@ -5128,8 +5128,8 @@ function az_default() {
|
|
|
5128
5128
|
}
|
|
5129
5129
|
|
|
5130
5130
|
// ../../../node_modules/zod/v4/locales/be.js
|
|
5131
|
-
function getBelarusianPlural(
|
|
5132
|
-
const absCount = Math.abs(
|
|
5131
|
+
function getBelarusianPlural(count2, one, few, many) {
|
|
5132
|
+
const absCount = Math.abs(count2);
|
|
5133
5133
|
const lastDigit = absCount % 10;
|
|
5134
5134
|
const lastTwoDigits = absCount % 100;
|
|
5135
5135
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -7207,8 +7207,8 @@ function hu_default() {
|
|
|
7207
7207
|
}
|
|
7208
7208
|
|
|
7209
7209
|
// ../../../node_modules/zod/v4/locales/hy.js
|
|
7210
|
-
function getArmenianPlural(
|
|
7211
|
-
return Math.abs(
|
|
7210
|
+
function getArmenianPlural(count2, one, many) {
|
|
7211
|
+
return Math.abs(count2) === 1 ? one : many;
|
|
7212
7212
|
}
|
|
7213
7213
|
function withDefiniteArticle(word) {
|
|
7214
7214
|
if (!word)
|
|
@@ -9336,8 +9336,8 @@ function ro_default() {
|
|
|
9336
9336
|
}
|
|
9337
9337
|
|
|
9338
9338
|
// ../../../node_modules/zod/v4/locales/ru.js
|
|
9339
|
-
function getRussianPlural(
|
|
9340
|
-
const absCount = Math.abs(
|
|
9339
|
+
function getRussianPlural(count2, one, few, many) {
|
|
9340
|
+
const absCount = Math.abs(count2);
|
|
9341
9341
|
const lastDigit = absCount % 10;
|
|
9342
9342
|
const lastTwoDigits = absCount % 100;
|
|
9343
9343
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -14592,13 +14592,13 @@ function resolveRef(ref, ctx) {
|
|
|
14592
14592
|
if (!ref.startsWith("#")) {
|
|
14593
14593
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14594
14594
|
}
|
|
14595
|
-
const
|
|
14596
|
-
if (
|
|
14595
|
+
const path10 = ref.slice(1).split("/").filter(Boolean);
|
|
14596
|
+
if (path10.length === 0) {
|
|
14597
14597
|
return ctx.rootSchema;
|
|
14598
14598
|
}
|
|
14599
14599
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14600
|
-
if (
|
|
14601
|
-
const key =
|
|
14600
|
+
if (path10[0] === defsKey) {
|
|
14601
|
+
const key = path10[1];
|
|
14602
14602
|
if (!key || !ctx.defs[key]) {
|
|
14603
14603
|
throw new Error(`Reference not found: ${ref}`);
|
|
14604
14604
|
}
|
|
@@ -15006,6 +15006,15 @@ function date4(params) {
|
|
|
15006
15006
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
15007
15007
|
config(en_default());
|
|
15008
15008
|
|
|
15009
|
+
// ../../shared-contracts/dist/delegation-read.js
|
|
15010
|
+
var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
15011
|
+
var delegationReadParamsSchema = external_exports.strictObject({
|
|
15012
|
+
threadId: external_exports.string().min(1).max(1024),
|
|
15013
|
+
view: external_exports.enum(["result", "messages"]),
|
|
15014
|
+
cursor: external_exports.string().min(1).max(8192).optional(),
|
|
15015
|
+
limit: external_exports.number().int().min(1).max(100).optional()
|
|
15016
|
+
});
|
|
15017
|
+
|
|
15009
15018
|
// ../../shared-contracts/dist/credential-imports.js
|
|
15010
15019
|
var credentialSourceSchema = external_exports.object({
|
|
15011
15020
|
id: external_exports.string().min(1).max(256),
|
|
@@ -15076,6 +15085,153 @@ var harnessDisplaySetSchema = external_exports.strictObject({
|
|
|
15076
15085
|
initializeOnly: external_exports.boolean().optional()
|
|
15077
15086
|
});
|
|
15078
15087
|
|
|
15088
|
+
// ../../shared-contracts/dist/model-price-overrides.js
|
|
15089
|
+
var usdPerMillionTokens = external_exports.number().finite().nonnegative();
|
|
15090
|
+
var modelPriceOverrideSchema = external_exports.strictObject({
|
|
15091
|
+
input: usdPerMillionTokens,
|
|
15092
|
+
output: usdPerMillionTokens,
|
|
15093
|
+
cacheRead: usdPerMillionTokens.optional(),
|
|
15094
|
+
cacheWrite: usdPerMillionTokens.optional(),
|
|
15095
|
+
cacheWrite1h: usdPerMillionTokens.optional()
|
|
15096
|
+
});
|
|
15097
|
+
var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
|
|
15098
|
+
var modelPriceOverridesSchema = external_exports.strictObject({
|
|
15099
|
+
/** Absolute path of the Host's `pricing.json`. */
|
|
15100
|
+
path: external_exports.string(),
|
|
15101
|
+
entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
|
|
15102
|
+
/** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
|
|
15103
|
+
error: external_exports.string().nullable()
|
|
15104
|
+
});
|
|
15105
|
+
var modelPriceOverridesGetSchema = external_exports.strictObject({});
|
|
15106
|
+
var modelPriceOverridesSetSchema = external_exports.strictObject({
|
|
15107
|
+
key: modelPriceKeySchema,
|
|
15108
|
+
price: modelPriceOverrideSchema.nullable(),
|
|
15109
|
+
previousKey: modelPriceKeySchema.optional()
|
|
15110
|
+
});
|
|
15111
|
+
var modelPriceDefaultParamsSchema = external_exports.strictObject({
|
|
15112
|
+
model: modelPriceKeySchema
|
|
15113
|
+
});
|
|
15114
|
+
var modelPriceSuggestionSchema = external_exports.strictObject({
|
|
15115
|
+
/** Verified from catalog canonical links, not inferred from names or equal prices. */
|
|
15116
|
+
official: external_exports.boolean().optional(),
|
|
15117
|
+
canonicalModelId: external_exports.string().min(1).optional(),
|
|
15118
|
+
provider: external_exports.string().min(1).max(512),
|
|
15119
|
+
model: external_exports.string().min(1).max(512),
|
|
15120
|
+
price: modelPriceOverrideSchema
|
|
15121
|
+
});
|
|
15122
|
+
var modelPriceDefaultResultSchema = external_exports.strictObject({
|
|
15123
|
+
price: modelPriceOverrideSchema.nullable(),
|
|
15124
|
+
/** Local catalog suggestions only; never used automatically for pricing. */
|
|
15125
|
+
suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
|
|
15126
|
+
});
|
|
15127
|
+
|
|
15128
|
+
// ../../shared-contracts/dist/usage-statistics.js
|
|
15129
|
+
var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
|
|
15130
|
+
var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
15131
|
+
var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
|
|
15132
|
+
var harness = external_exports.string().min(1).max(128);
|
|
15133
|
+
var model = external_exports.string().min(1).max(512);
|
|
15134
|
+
var project = external_exports.string().min(1).max(4096);
|
|
15135
|
+
var usageStatisticsParamsSchema = external_exports.strictObject({
|
|
15136
|
+
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
15137
|
+
harness: harness.optional(),
|
|
15138
|
+
model: model.nullable().optional(),
|
|
15139
|
+
project: project.nullable().optional(),
|
|
15140
|
+
/** One local date inside the range. */
|
|
15141
|
+
date: localDate.optional()
|
|
15142
|
+
});
|
|
15143
|
+
var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
15144
|
+
requests: count,
|
|
15145
|
+
inputTokens: count,
|
|
15146
|
+
cachedInputTokens: count,
|
|
15147
|
+
cacheWriteInputTokens: count,
|
|
15148
|
+
cacheKnownInputTokens: count,
|
|
15149
|
+
outputTokens: count,
|
|
15150
|
+
reasoningOutputTokens: count,
|
|
15151
|
+
/** USD at the public price, summed over the priced requests only. */
|
|
15152
|
+
costUsd: external_exports.number().finite().min(0),
|
|
15153
|
+
/** Requests without a price (or the cache data the price needs); not in `costUsd`. */
|
|
15154
|
+
unpricedRequests: count,
|
|
15155
|
+
/**
|
|
15156
|
+
* Requests whose storage gave no token counts: counted as requests, with neither tokens nor
|
|
15157
|
+
* cost, and not as unpriced.
|
|
15158
|
+
*/
|
|
15159
|
+
unmeteredRequests: count
|
|
15160
|
+
});
|
|
15161
|
+
var totals = usageStatisticsTotalsSchema.shape;
|
|
15162
|
+
var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
15163
|
+
harness,
|
|
15164
|
+
sessionId: external_exports.string().min(1).max(512),
|
|
15165
|
+
project: project.nullable(),
|
|
15166
|
+
/** Models the session used, most requests first. */
|
|
15167
|
+
models: external_exports.array(model).max(16),
|
|
15168
|
+
firstAtMs: count,
|
|
15169
|
+
lastAtMs: count,
|
|
15170
|
+
...totals
|
|
15171
|
+
});
|
|
15172
|
+
var usageStatisticsResultSchema = external_exports.strictObject({
|
|
15173
|
+
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
15174
|
+
/** First local date of the range; null for all time. */
|
|
15175
|
+
from: localDate.nullable(),
|
|
15176
|
+
to: localDate,
|
|
15177
|
+
/** The filters these figures apply, echoed so a late answer to older filters is recognised. */
|
|
15178
|
+
filters: external_exports.strictObject({
|
|
15179
|
+
harness: harness.nullable(),
|
|
15180
|
+
model: model.nullable(),
|
|
15181
|
+
unknownModel: external_exports.boolean(),
|
|
15182
|
+
project: project.nullable(),
|
|
15183
|
+
unknownProject: external_exports.boolean(),
|
|
15184
|
+
date: localDate.nullable()
|
|
15185
|
+
}),
|
|
15186
|
+
/** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
|
|
15187
|
+
reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
|
|
15188
|
+
/** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
|
|
15189
|
+
failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
|
|
15190
|
+
/** Every value seen in the range, ignoring the filters, to choose filters from. */
|
|
15191
|
+
options: external_exports.strictObject({
|
|
15192
|
+
harnesses: external_exports.array(harness).max(256),
|
|
15193
|
+
models: external_exports.array(model.nullable()).max(4096),
|
|
15194
|
+
projects: external_exports.array(project.nullable()).max(4096)
|
|
15195
|
+
}),
|
|
15196
|
+
/** Current display metadata, scoped by Harness. Never a pricing or filter identity.
|
|
15197
|
+
* Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
|
|
15198
|
+
*/
|
|
15199
|
+
modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
|
|
15200
|
+
/** Native credits, all filters applied, never combined across Harnesses or treated as USD.
|
|
15201
|
+
* Only groups with at least one reported value appear; reportedRequests exposes partial data.
|
|
15202
|
+
*/
|
|
15203
|
+
credits: external_exports.array(external_exports.strictObject({
|
|
15204
|
+
harness,
|
|
15205
|
+
model: model.nullable(),
|
|
15206
|
+
credits: external_exports.number().finite().min(0),
|
|
15207
|
+
reportedRequests: count,
|
|
15208
|
+
requests: count
|
|
15209
|
+
})).max(4096).optional(),
|
|
15210
|
+
/** All filters applied. */
|
|
15211
|
+
totals: usageStatisticsTotalsSchema,
|
|
15212
|
+
/** Each date and Harness of the range: every filter except the day. */
|
|
15213
|
+
daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
|
|
15214
|
+
/** Local weekday (0 = Sunday) and hour, all filters applied. */
|
|
15215
|
+
hourly: external_exports.array(external_exports.strictObject({
|
|
15216
|
+
weekday: external_exports.number().int().min(0).max(6),
|
|
15217
|
+
hour: external_exports.number().int().min(0).max(23),
|
|
15218
|
+
...totals
|
|
15219
|
+
})).max(168),
|
|
15220
|
+
byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
|
|
15221
|
+
byModel: external_exports.array(external_exports.strictObject({
|
|
15222
|
+
model: model.nullable(),
|
|
15223
|
+
...totals,
|
|
15224
|
+
/** Requests priced by what the Harness recorded they cost, not by a price list. */
|
|
15225
|
+
harnessPricedRequests: count
|
|
15226
|
+
})).max(4096),
|
|
15227
|
+
byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
|
|
15228
|
+
/**
|
|
15229
|
+
* The sessions that spent the most, by cost and by tokens without cache, all filters applied;
|
|
15230
|
+
* requests without a native session are not listed here but count everywhere else.
|
|
15231
|
+
*/
|
|
15232
|
+
sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
|
|
15233
|
+
});
|
|
15234
|
+
|
|
15079
15235
|
// ../../shared-contracts/dist/ids.js
|
|
15080
15236
|
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15081
15237
|
message: "Identifier must not be empty or whitespace"
|
|
@@ -15086,6 +15242,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
15086
15242
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15087
15243
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15088
15244
|
|
|
15245
|
+
// ../../shared-contracts/dist/thread-prewarm.js
|
|
15246
|
+
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
15247
|
+
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
15248
|
+
|
|
15089
15249
|
// ../../shared-contracts/dist/harness-plugins.js
|
|
15090
15250
|
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15091
15251
|
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
@@ -15093,13 +15253,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
|
|
|
15093
15253
|
var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
|
|
15094
15254
|
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
15095
15255
|
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15256
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
15257
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
15258
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
15259
|
+
before: localizedTextSchema.optional(),
|
|
15260
|
+
after: localizedTextSchema.optional(),
|
|
15261
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
15262
|
+
}).strict();
|
|
15096
15263
|
var pluginPresentationShape = {
|
|
15097
15264
|
id: harnessPluginIdSchema,
|
|
15098
15265
|
name: external_exports.string().trim().min(1).max(128),
|
|
15099
15266
|
version: external_exports.string().min(1).max(128),
|
|
15267
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
15268
|
+
kind: external_exports.literal("usage").optional(),
|
|
15269
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
15270
|
+
iconStyle: external_exports.object({
|
|
15271
|
+
vector: external_exports.object({
|
|
15272
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
15273
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
15274
|
+
paths: external_exports.array(external_exports.object({
|
|
15275
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
15276
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
15277
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
15278
|
+
}).strict()).min(1).max(32)
|
|
15279
|
+
}).strict().optional(),
|
|
15280
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
15281
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
15282
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
15283
|
+
}).strict().optional(),
|
|
15284
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
15285
|
+
notice: localizedTextSchema.optional(),
|
|
15100
15286
|
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15101
15287
|
launchCommand: external_exports.literal(true).optional(),
|
|
15102
15288
|
links: external_exports.object({
|
|
15289
|
+
website: documentationUrlSchema.optional(),
|
|
15103
15290
|
documentation: documentationUrlSchema.optional(),
|
|
15104
15291
|
installation: documentationUrlSchema.optional()
|
|
15105
15292
|
}).strict().optional()
|
|
@@ -15153,6 +15340,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
|
|
|
15153
15340
|
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
15154
15341
|
});
|
|
15155
15342
|
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
15343
|
+
"codexhost/console/remote-connections",
|
|
15344
|
+
"codexhost/runtime/status",
|
|
15345
|
+
"codexhost/remote/ssh-setup",
|
|
15156
15346
|
"codexhost/harness/plugins/list",
|
|
15157
15347
|
"codexhost/harness/display-settings/get",
|
|
15158
15348
|
"codexhost/harness/display-settings/set",
|
|
@@ -15173,6 +15363,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
|
|
|
15173
15363
|
"codexhost/account/list",
|
|
15174
15364
|
"codexhost/account/refresh",
|
|
15175
15365
|
"codexhost/account/usage/inspect",
|
|
15366
|
+
"codexhost/usage/model-prices/get",
|
|
15367
|
+
"codexhost/usage/model-prices/set",
|
|
15368
|
+
"codexhost/usage/model-prices/default",
|
|
15369
|
+
"codexhost/usage/statistics/get",
|
|
15176
15370
|
"codexhost/update/check",
|
|
15177
15371
|
"codexhost/update/start",
|
|
15178
15372
|
"codexhost/update/status"
|
|
@@ -15237,6 +15431,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15237
15431
|
cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15238
15432
|
outputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15239
15433
|
outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
15434
|
+
apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
15240
15435
|
reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15241
15436
|
totalTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15242
15437
|
totalCostUsd: finiteNonNegativeNumberSchema.optional(),
|
|
@@ -15248,7 +15443,11 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15248
15443
|
planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
15249
15444
|
planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15250
15445
|
planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
15251
|
-
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
|
|
15446
|
+
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15447
|
+
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15448
|
+
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15449
|
+
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15450
|
+
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15252
15451
|
}).strict().superRefine((usage, context) => {
|
|
15253
15452
|
if (Object.keys(usage).length === 0) {
|
|
15254
15453
|
context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
|
|
@@ -15269,6 +15468,20 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15269
15468
|
path: ["contextWindowTokens"]
|
|
15270
15469
|
});
|
|
15271
15470
|
}
|
|
15471
|
+
if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
|
|
15472
|
+
context.addIssue({
|
|
15473
|
+
code: "custom",
|
|
15474
|
+
message: "Thread Usage costSource must be provided with totalCostUsd",
|
|
15475
|
+
path: ["costSource"]
|
|
15476
|
+
});
|
|
15477
|
+
}
|
|
15478
|
+
if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
|
|
15479
|
+
context.addIssue({
|
|
15480
|
+
code: "custom",
|
|
15481
|
+
message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
|
|
15482
|
+
path: ["unpricedModels"]
|
|
15483
|
+
});
|
|
15484
|
+
}
|
|
15272
15485
|
if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
|
|
15273
15486
|
context.addIssue({
|
|
15274
15487
|
code: "custom",
|
|
@@ -15538,27 +15751,27 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15538
15751
|
}).strict().superRefine((catalog, context) => {
|
|
15539
15752
|
const refs = /* @__PURE__ */ new Set();
|
|
15540
15753
|
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
|
|
15541
|
-
for (const [index,
|
|
15542
|
-
if (refs.has(
|
|
15754
|
+
for (const [index, model2] of catalog.models.entries()) {
|
|
15755
|
+
if (refs.has(model2.ref.id)) {
|
|
15543
15756
|
context.addIssue({
|
|
15544
15757
|
code: "custom",
|
|
15545
15758
|
message: "Model Catalog refs must be unique",
|
|
15546
15759
|
path: ["models", index, "ref", "id"]
|
|
15547
15760
|
});
|
|
15548
15761
|
}
|
|
15549
|
-
refs.add(
|
|
15550
|
-
if (
|
|
15551
|
-
if (refs.has(
|
|
15762
|
+
refs.add(model2.ref.id);
|
|
15763
|
+
if (model2.fastModel) {
|
|
15764
|
+
if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
|
|
15552
15765
|
context.addIssue({
|
|
15553
15766
|
code: "custom",
|
|
15554
15767
|
message: "Fast Model refs must be distinct and unique",
|
|
15555
15768
|
path: ["models", index, "fastModel"]
|
|
15556
15769
|
});
|
|
15557
15770
|
}
|
|
15558
|
-
refs.add(
|
|
15771
|
+
refs.add(model2.fastModel.id);
|
|
15559
15772
|
}
|
|
15560
15773
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
15561
|
-
for (const [optionIndex, optionId] of (
|
|
15774
|
+
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
15562
15775
|
if (supportedThinkingIds.has(optionId)) {
|
|
15563
15776
|
context.addIssue({
|
|
15564
15777
|
code: "custom",
|
|
@@ -16098,6 +16311,85 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16098
16311
|
status: updateStatusSchema.nullable()
|
|
16099
16312
|
});
|
|
16100
16313
|
|
|
16314
|
+
// ../../shared-contracts/dist/remote-runtime.js
|
|
16315
|
+
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
16316
|
+
"idle",
|
|
16317
|
+
"installing",
|
|
16318
|
+
"restarting",
|
|
16319
|
+
"succeeded",
|
|
16320
|
+
"failed"
|
|
16321
|
+
]);
|
|
16322
|
+
var runtimeStatusSchema = external_exports.object({
|
|
16323
|
+
runningVersion: external_exports.string().nullable(),
|
|
16324
|
+
installedVersion: external_exports.string().nullable(),
|
|
16325
|
+
restartRequired: external_exports.boolean(),
|
|
16326
|
+
remote: external_exports.boolean(),
|
|
16327
|
+
updateSupported: external_exports.boolean(),
|
|
16328
|
+
update: external_exports.object({
|
|
16329
|
+
phase: remoteUpdatePhaseSchema,
|
|
16330
|
+
targetVersion: external_exports.string().nullable(),
|
|
16331
|
+
error: external_exports.string().nullable()
|
|
16332
|
+
})
|
|
16333
|
+
});
|
|
16334
|
+
var remoteUpdateParamsSchema = external_exports.object({
|
|
16335
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
|
|
16336
|
+
}).strict();
|
|
16337
|
+
var remoteSshSetupParamsSchema = external_exports.object({
|
|
16338
|
+
hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
|
|
16339
|
+
port: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16340
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16341
|
+
action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
|
|
16342
|
+
uninstallPackage: external_exports.boolean().optional(),
|
|
16343
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
|
|
16344
|
+
}).strict();
|
|
16345
|
+
var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
|
|
16346
|
+
|
|
16347
|
+
// ../../shared-contracts/dist/remote-connections.js
|
|
16348
|
+
var hostId = external_exports.string().min(1).max(1024);
|
|
16349
|
+
var codexSshConnectionSchema = external_exports.object({
|
|
16350
|
+
hostId,
|
|
16351
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16352
|
+
source: external_exports.enum(["codex-managed", "discovered"]),
|
|
16353
|
+
sshAlias: external_exports.string().max(1024).nullable(),
|
|
16354
|
+
sshHost: external_exports.string().min(1).max(1024),
|
|
16355
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16356
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16357
|
+
autoConnect: external_exports.boolean(),
|
|
16358
|
+
connectionAnalyticsId: external_exports.string().max(1024).optional()
|
|
16359
|
+
});
|
|
16360
|
+
var codexSshDraftSchema = external_exports.strictObject({
|
|
16361
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16362
|
+
hostname: external_exports.string().min(1).max(1024),
|
|
16363
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16364
|
+
identity: external_exports.string().max(4096).nullable()
|
|
16365
|
+
});
|
|
16366
|
+
var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
|
|
16367
|
+
external_exports.strictObject({ action: external_exports.literal("list") }),
|
|
16368
|
+
external_exports.strictObject({
|
|
16369
|
+
action: external_exports.literal("read-thread"),
|
|
16370
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
16371
|
+
input: delegationReadParamsSchema
|
|
16372
|
+
}),
|
|
16373
|
+
external_exports.strictObject({
|
|
16374
|
+
action: external_exports.literal("save"),
|
|
16375
|
+
draft: codexSshDraftSchema,
|
|
16376
|
+
previous: codexSshConnectionSchema.nullable()
|
|
16377
|
+
}),
|
|
16378
|
+
external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
|
|
16379
|
+
external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
|
|
16380
|
+
external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
|
|
16381
|
+
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
16382
|
+
external_exports.strictObject({
|
|
16383
|
+
action: external_exports.literal("update"),
|
|
16384
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
16385
|
+
version: remoteUpdateParamsSchema.shape.version
|
|
16386
|
+
})
|
|
16387
|
+
]);
|
|
16388
|
+
var remoteConnectionsReplySchema = external_exports.union([
|
|
16389
|
+
external_exports.strictObject({ result: jsonValueSchema }),
|
|
16390
|
+
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
16391
|
+
]);
|
|
16392
|
+
|
|
16101
16393
|
// ../../shared-contracts/dist/index.js
|
|
16102
16394
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
16103
16395
|
|
|
@@ -16213,7 +16505,6 @@ var tokenFields = [
|
|
|
16213
16505
|
"cachedInputTokens",
|
|
16214
16506
|
"cacheWriteInputTokens",
|
|
16215
16507
|
"outputTokens",
|
|
16216
|
-
"outputTokensPerSecond",
|
|
16217
16508
|
"reasoningOutputTokens",
|
|
16218
16509
|
"totalTokens",
|
|
16219
16510
|
"contextWindowTokens",
|
|
@@ -16221,10 +16512,12 @@ var tokenFields = [
|
|
|
16221
16512
|
];
|
|
16222
16513
|
var safeIntegerFields = [
|
|
16223
16514
|
"planFiveHourResetsAtUnix",
|
|
16224
|
-
"planSevenDayResetsAtUnix"
|
|
16515
|
+
"planSevenDayResetsAtUnix",
|
|
16516
|
+
"timeToFirstOutputMs"
|
|
16225
16517
|
];
|
|
16226
16518
|
var percentFields = [
|
|
16227
16519
|
"cacheHitRatePercent",
|
|
16520
|
+
"sessionCacheHitRatePercent",
|
|
16228
16521
|
"planFiveHourUsedPercent",
|
|
16229
16522
|
"planSevenDayUsedPercent"
|
|
16230
16523
|
];
|
|
@@ -16232,9 +16525,14 @@ var usageFields = /* @__PURE__ */ new Set([
|
|
|
16232
16525
|
...tokenFields,
|
|
16233
16526
|
...safeIntegerFields,
|
|
16234
16527
|
...percentFields,
|
|
16528
|
+
"sessionCacheUsage",
|
|
16235
16529
|
"totalCostUsd",
|
|
16236
16530
|
"totalCredits",
|
|
16237
|
-
"contextUsagePercent"
|
|
16531
|
+
"contextUsagePercent",
|
|
16532
|
+
"outputTokensPerSecond",
|
|
16533
|
+
"apiOutputTokensPerSecond",
|
|
16534
|
+
"costSource",
|
|
16535
|
+
"unpricedModels"
|
|
16238
16536
|
]);
|
|
16239
16537
|
function isRecord(value) {
|
|
16240
16538
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -16250,7 +16548,11 @@ function parseHostUsage(value) {
|
|
|
16250
16548
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
16251
16549
|
}
|
|
16252
16550
|
}
|
|
16253
|
-
for (const field of [
|
|
16551
|
+
for (const field of [
|
|
16552
|
+
"totalCredits",
|
|
16553
|
+
"contextUsagePercent",
|
|
16554
|
+
"apiOutputTokensPerSecond"
|
|
16555
|
+
]) {
|
|
16254
16556
|
const candidate = value[field];
|
|
16255
16557
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16256
16558
|
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
@@ -16286,6 +16588,12 @@ function parseHostUsage(value) {
|
|
|
16286
16588
|
throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
|
|
16287
16589
|
}
|
|
16288
16590
|
}
|
|
16591
|
+
if (value.sessionCacheUsage !== void 0) {
|
|
16592
|
+
const totals2 = value.sessionCacheUsage;
|
|
16593
|
+
if (!isRecord(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
|
|
16594
|
+
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
16595
|
+
}
|
|
16596
|
+
}
|
|
16289
16597
|
const hasContextUsed = value.contextUsedTokens !== void 0;
|
|
16290
16598
|
const hasContextWindow = value.contextWindowTokens !== void 0;
|
|
16291
16599
|
if (hasContextUsed !== hasContextWindow) {
|
|
@@ -16300,8 +16608,43 @@ function parseHostUsage(value) {
|
|
|
16300
16608
|
if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
|
|
16301
16609
|
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
16302
16610
|
}
|
|
16611
|
+
if (value.costSource !== void 0) {
|
|
16612
|
+
if (value.costSource !== "publicPrice" && value.costSource !== "native") {
|
|
16613
|
+
throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
|
|
16614
|
+
}
|
|
16615
|
+
if (value.totalCostUsd === void 0) {
|
|
16616
|
+
throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
|
|
16617
|
+
}
|
|
16618
|
+
}
|
|
16619
|
+
if (value.unpricedModels !== void 0) {
|
|
16620
|
+
const models = value.unpricedModels;
|
|
16621
|
+
if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
|
|
16622
|
+
throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
|
|
16623
|
+
}
|
|
16624
|
+
if (value.costSource !== "publicPrice") {
|
|
16625
|
+
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
16626
|
+
}
|
|
16627
|
+
return { ...value, unpricedModels: [...models] };
|
|
16628
|
+
}
|
|
16303
16629
|
return { ...value };
|
|
16304
16630
|
}
|
|
16631
|
+
var requestTokenFields = [
|
|
16632
|
+
"inputTokens",
|
|
16633
|
+
"cachedInputTokens",
|
|
16634
|
+
"cacheWriteInputTokens",
|
|
16635
|
+
"cacheWrite1hInputTokens",
|
|
16636
|
+
"outputTokens",
|
|
16637
|
+
"reasoningOutputTokens",
|
|
16638
|
+
"startedAtMs",
|
|
16639
|
+
"completedAtMs"
|
|
16640
|
+
];
|
|
16641
|
+
var requestFields = /* @__PURE__ */ new Set([
|
|
16642
|
+
...requestTokenFields,
|
|
16643
|
+
"requestId",
|
|
16644
|
+
"historical",
|
|
16645
|
+
"model",
|
|
16646
|
+
"provider"
|
|
16647
|
+
]);
|
|
16305
16648
|
|
|
16306
16649
|
// ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
16307
16650
|
var AGENT_METHODS = {
|
|
@@ -18586,9 +18929,9 @@ var Connection = class {
|
|
|
18586
18929
|
return;
|
|
18587
18930
|
}
|
|
18588
18931
|
const responseBatch = isResponseBatch(batch);
|
|
18589
|
-
const responseCount = responseBatch ? 0 : batch.reduce((
|
|
18932
|
+
const responseCount = responseBatch ? 0 : batch.reduce((count2, message) => count2 + (isNotificationMessage(message) ? 0 : 1), 0);
|
|
18590
18933
|
let remaining = responseCount;
|
|
18591
|
-
let remainingNotifications = batch.reduce((
|
|
18934
|
+
let remainingNotifications = batch.reduce((count2, message) => count2 + (isNotificationMessage(message) ? 1 : 0), 0);
|
|
18592
18935
|
let responseSent = false;
|
|
18593
18936
|
const responses = [];
|
|
18594
18937
|
const sendResponsesIfReady = async () => {
|
|
@@ -21256,16 +21599,16 @@ var Diff = class {
|
|
|
21256
21599
|
}
|
|
21257
21600
|
}
|
|
21258
21601
|
}
|
|
21259
|
-
addToPath(
|
|
21260
|
-
const last =
|
|
21602
|
+
addToPath(path10, added, removed, oldPosInc, options) {
|
|
21603
|
+
const last = path10.lastComponent;
|
|
21261
21604
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
21262
21605
|
return {
|
|
21263
|
-
oldPos:
|
|
21606
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21264
21607
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
21265
21608
|
};
|
|
21266
21609
|
} else {
|
|
21267
21610
|
return {
|
|
21268
|
-
oldPos:
|
|
21611
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21269
21612
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
21270
21613
|
};
|
|
21271
21614
|
}
|
|
@@ -21572,6 +21915,33 @@ function splitLines(text) {
|
|
|
21572
21915
|
}
|
|
21573
21916
|
|
|
21574
21917
|
// ../../../node_modules/smol-toml/dist/date.js
|
|
21918
|
+
/*!
|
|
21919
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
21920
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
21921
|
+
*
|
|
21922
|
+
* Redistribution and use in source and binary forms, with or without
|
|
21923
|
+
* modification, are permitted provided that the following conditions are met:
|
|
21924
|
+
*
|
|
21925
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
21926
|
+
* list of conditions and the following disclaimer.
|
|
21927
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
21928
|
+
* this list of conditions and the following disclaimer in the
|
|
21929
|
+
* documentation and/or other materials provided with the distribution.
|
|
21930
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
21931
|
+
* may be used to endorse or promote products derived from this software without
|
|
21932
|
+
* specific prior written permission.
|
|
21933
|
+
*
|
|
21934
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
21935
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21936
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21937
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21938
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21939
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21940
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21941
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
21942
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
21943
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
21944
|
+
*/
|
|
21575
21945
|
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
21576
21946
|
var TomlDate = class _TomlDate extends Date {
|
|
21577
21947
|
#hasDate = false;
|
|
@@ -21664,6 +22034,33 @@ var TomlDate = class _TomlDate extends Date {
|
|
|
21664
22034
|
};
|
|
21665
22035
|
|
|
21666
22036
|
// ../../../node_modules/smol-toml/dist/error.js
|
|
22037
|
+
/*!
|
|
22038
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22039
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22040
|
+
*
|
|
22041
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22042
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22043
|
+
*
|
|
22044
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22045
|
+
* list of conditions and the following disclaimer.
|
|
22046
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22047
|
+
* this list of conditions and the following disclaimer in the
|
|
22048
|
+
* documentation and/or other materials provided with the distribution.
|
|
22049
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22050
|
+
* may be used to endorse or promote products derived from this software without
|
|
22051
|
+
* specific prior written permission.
|
|
22052
|
+
*
|
|
22053
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22054
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22055
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22056
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22057
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22058
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22059
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22060
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22061
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22062
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22063
|
+
*/
|
|
21667
22064
|
function getLineColFromPtr(string4, ptr) {
|
|
21668
22065
|
let lines = string4.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
21669
22066
|
return [lines.length, lines.pop().length + 1];
|
|
@@ -21704,6 +22101,33 @@ ${codeblock}`, options);
|
|
|
21704
22101
|
};
|
|
21705
22102
|
|
|
21706
22103
|
// ../../../node_modules/smol-toml/dist/util.js
|
|
22104
|
+
/*!
|
|
22105
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22106
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22107
|
+
*
|
|
22108
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22109
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22110
|
+
*
|
|
22111
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22112
|
+
* list of conditions and the following disclaimer.
|
|
22113
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22114
|
+
* this list of conditions and the following disclaimer in the
|
|
22115
|
+
* documentation and/or other materials provided with the distribution.
|
|
22116
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22117
|
+
* may be used to endorse or promote products derived from this software without
|
|
22118
|
+
* specific prior written permission.
|
|
22119
|
+
*
|
|
22120
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22121
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22122
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22123
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22124
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22125
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22126
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22127
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22128
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22129
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22130
|
+
*/
|
|
21707
22131
|
function indexOfNewline(str, start = 0) {
|
|
21708
22132
|
let idx = str.indexOf("\n", start);
|
|
21709
22133
|
if (str.charCodeAt(idx - 1) === 13)
|
|
@@ -21759,6 +22183,33 @@ function skipUntil(ctx, sep, end) {
|
|
|
21759
22183
|
}
|
|
21760
22184
|
|
|
21761
22185
|
// ../../../node_modules/smol-toml/dist/primitive.js
|
|
22186
|
+
/*!
|
|
22187
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22188
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22189
|
+
*
|
|
22190
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22191
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22192
|
+
*
|
|
22193
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22194
|
+
* list of conditions and the following disclaimer.
|
|
22195
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22196
|
+
* this list of conditions and the following disclaimer in the
|
|
22197
|
+
* documentation and/or other materials provided with the distribution.
|
|
22198
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22199
|
+
* may be used to endorse or promote products derived from this software without
|
|
22200
|
+
* specific prior written permission.
|
|
22201
|
+
*
|
|
22202
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22203
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22204
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22205
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22206
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22207
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22208
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22209
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22210
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22211
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22212
|
+
*/
|
|
21762
22213
|
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
21763
22214
|
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
21764
22215
|
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
@@ -21915,6 +22366,33 @@ function parseValue(ctx, integersAsBigInt, end) {
|
|
|
21915
22366
|
}
|
|
21916
22367
|
|
|
21917
22368
|
// ../../../node_modules/smol-toml/dist/extract.js
|
|
22369
|
+
/*!
|
|
22370
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22371
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22372
|
+
*
|
|
22373
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22374
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22375
|
+
*
|
|
22376
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22377
|
+
* list of conditions and the following disclaimer.
|
|
22378
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22379
|
+
* this list of conditions and the following disclaimer in the
|
|
22380
|
+
* documentation and/or other materials provided with the distribution.
|
|
22381
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22382
|
+
* may be used to endorse or promote products derived from this software without
|
|
22383
|
+
* specific prior written permission.
|
|
22384
|
+
*
|
|
22385
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22386
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22387
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22388
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22389
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22390
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22391
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22392
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22393
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22394
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22395
|
+
*/
|
|
21918
22396
|
function extractValue(ctx, end, integersAsBigInt) {
|
|
21919
22397
|
let ptr = ctx.p;
|
|
21920
22398
|
let c = ctx.s.charCodeAt(ptr);
|
|
@@ -21948,6 +22426,33 @@ function extractValue(ctx, end, integersAsBigInt) {
|
|
|
21948
22426
|
}
|
|
21949
22427
|
|
|
21950
22428
|
// ../../../node_modules/smol-toml/dist/struct.js
|
|
22429
|
+
/*!
|
|
22430
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22431
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22432
|
+
*
|
|
22433
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22434
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22435
|
+
*
|
|
22436
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22437
|
+
* list of conditions and the following disclaimer.
|
|
22438
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22439
|
+
* this list of conditions and the following disclaimer in the
|
|
22440
|
+
* documentation and/or other materials provided with the distribution.
|
|
22441
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22442
|
+
* may be used to endorse or promote products derived from this software without
|
|
22443
|
+
* specific prior written permission.
|
|
22444
|
+
*
|
|
22445
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22446
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22447
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22448
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22449
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22450
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22451
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22452
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22453
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22454
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22455
|
+
*/
|
|
21951
22456
|
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
21952
22457
|
function parseKey(ctx, end = "=") {
|
|
21953
22458
|
let start = ctx.p;
|
|
@@ -22090,6 +22595,33 @@ function parseArray(ctx, integersAsBigInt) {
|
|
|
22090
22595
|
}
|
|
22091
22596
|
|
|
22092
22597
|
// ../../../node_modules/smol-toml/dist/parse.js
|
|
22598
|
+
/*!
|
|
22599
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22600
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22601
|
+
*
|
|
22602
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22603
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22604
|
+
*
|
|
22605
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22606
|
+
* list of conditions and the following disclaimer.
|
|
22607
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22608
|
+
* this list of conditions and the following disclaimer in the
|
|
22609
|
+
* documentation and/or other materials provided with the distribution.
|
|
22610
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22611
|
+
* may be used to endorse or promote products derived from this software without
|
|
22612
|
+
* specific prior written permission.
|
|
22613
|
+
*
|
|
22614
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22615
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22616
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22617
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22618
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22619
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22620
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22621
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22622
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22623
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22624
|
+
*/
|
|
22093
22625
|
function peekTable(key, table, meta3, type) {
|
|
22094
22626
|
let t = table;
|
|
22095
22627
|
let m = meta3;
|
|
@@ -22216,6 +22748,64 @@ function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
22216
22748
|
return res;
|
|
22217
22749
|
}
|
|
22218
22750
|
|
|
22751
|
+
// ../../../node_modules/smol-toml/dist/stringify.js
|
|
22752
|
+
/*!
|
|
22753
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22754
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22755
|
+
*
|
|
22756
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22757
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22758
|
+
*
|
|
22759
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22760
|
+
* list of conditions and the following disclaimer.
|
|
22761
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22762
|
+
* this list of conditions and the following disclaimer in the
|
|
22763
|
+
* documentation and/or other materials provided with the distribution.
|
|
22764
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22765
|
+
* may be used to endorse or promote products derived from this software without
|
|
22766
|
+
* specific prior written permission.
|
|
22767
|
+
*
|
|
22768
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22769
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22770
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22771
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22772
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22773
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22774
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22775
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22776
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22777
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22778
|
+
*/
|
|
22779
|
+
|
|
22780
|
+
// ../../../node_modules/smol-toml/dist/index.js
|
|
22781
|
+
/*!
|
|
22782
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
22783
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22784
|
+
*
|
|
22785
|
+
* Redistribution and use in source and binary forms, with or without
|
|
22786
|
+
* modification, are permitted provided that the following conditions are met:
|
|
22787
|
+
*
|
|
22788
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
22789
|
+
* list of conditions and the following disclaimer.
|
|
22790
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22791
|
+
* this list of conditions and the following disclaimer in the
|
|
22792
|
+
* documentation and/or other materials provided with the distribution.
|
|
22793
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
22794
|
+
* may be used to endorse or promote products derived from this software without
|
|
22795
|
+
* specific prior written permission.
|
|
22796
|
+
*
|
|
22797
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22798
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22799
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22800
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22801
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22802
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22803
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22804
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22805
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22806
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22807
|
+
*/
|
|
22808
|
+
|
|
22219
22809
|
// dist/models.js
|
|
22220
22810
|
var KIMI_MODEL_PREFIX = "kimi.";
|
|
22221
22811
|
function encodeKimiModelRef(alias) {
|
|
@@ -23219,19 +23809,259 @@ async function readKimiSessionUsage(sessionId, options = {}) {
|
|
|
23219
23809
|
}
|
|
23220
23810
|
}
|
|
23221
23811
|
|
|
23812
|
+
// dist/session-import.js
|
|
23813
|
+
import { readFile as readFile4, stat } from "node:fs/promises";
|
|
23814
|
+
import path7 from "node:path";
|
|
23815
|
+
|
|
23816
|
+
// ../../harness-adapter/dist/session-import.js
|
|
23817
|
+
import { lstat } from "node:fs/promises";
|
|
23818
|
+
var SessionImportChangedError = class extends Error {
|
|
23819
|
+
constructor(message = "Native Session changed during discovery; refresh and retry") {
|
|
23820
|
+
super(message);
|
|
23821
|
+
this.name = "SessionImportChangedError";
|
|
23822
|
+
}
|
|
23823
|
+
};
|
|
23824
|
+
function isMissingFileError(error51) {
|
|
23825
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
23826
|
+
}
|
|
23827
|
+
function sameFileFingerprint(left, right) {
|
|
23828
|
+
return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
23829
|
+
}
|
|
23830
|
+
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
23831
|
+
function isStorageAccessError(error51) {
|
|
23832
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
23833
|
+
}
|
|
23834
|
+
async function optionalLstat(file2) {
|
|
23835
|
+
try {
|
|
23836
|
+
return await lstat(file2);
|
|
23837
|
+
} catch (error51) {
|
|
23838
|
+
if (isMissingFileError(error51))
|
|
23839
|
+
return null;
|
|
23840
|
+
throw error51;
|
|
23841
|
+
}
|
|
23842
|
+
}
|
|
23843
|
+
async function readStableFiles(files, read) {
|
|
23844
|
+
const before = await Promise.all(files.map(optionalLstat));
|
|
23845
|
+
const value = await read(before);
|
|
23846
|
+
const after = await Promise.all(files.map(optionalLstat));
|
|
23847
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
23848
|
+
throw new SessionImportChangedError();
|
|
23849
|
+
return value;
|
|
23850
|
+
}
|
|
23851
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
23852
|
+
if (typeof value !== "string")
|
|
23853
|
+
return null;
|
|
23854
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
23855
|
+
if (!normalized)
|
|
23856
|
+
return null;
|
|
23857
|
+
if (normalized.length <= maxLength)
|
|
23858
|
+
return normalized;
|
|
23859
|
+
const characters = [...normalized];
|
|
23860
|
+
if (characters.length <= maxLength)
|
|
23861
|
+
return normalized;
|
|
23862
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
23863
|
+
}
|
|
23864
|
+
function sessionImportCandidate(input) {
|
|
23865
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
23866
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
23867
|
+
nativeSessionId: input.nativeSessionId,
|
|
23868
|
+
cwd: input.cwd,
|
|
23869
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
23870
|
+
updatedAt: Math.floor(time3),
|
|
23871
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
23872
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
23873
|
+
});
|
|
23874
|
+
return parsed.success ? parsed.data : null;
|
|
23875
|
+
}
|
|
23876
|
+
var SessionImportScope = class {
|
|
23877
|
+
#abort = new AbortController();
|
|
23878
|
+
#options;
|
|
23879
|
+
#pending = /* @__PURE__ */ new Set();
|
|
23880
|
+
constructor(options) {
|
|
23881
|
+
this.#options = options;
|
|
23882
|
+
}
|
|
23883
|
+
#closed() {
|
|
23884
|
+
return {
|
|
23885
|
+
ok: false,
|
|
23886
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
23887
|
+
};
|
|
23888
|
+
}
|
|
23889
|
+
read(operation) {
|
|
23890
|
+
const signal = this.#abort.signal;
|
|
23891
|
+
if (signal.aborted)
|
|
23892
|
+
return Promise.resolve(this.#closed());
|
|
23893
|
+
let started;
|
|
23894
|
+
try {
|
|
23895
|
+
started = operation(signal);
|
|
23896
|
+
} catch (error51) {
|
|
23897
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
23898
|
+
}
|
|
23899
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
23900
|
+
ok: false,
|
|
23901
|
+
error: {
|
|
23902
|
+
code: "unavailable",
|
|
23903
|
+
message: this.#options.unavailableMessage,
|
|
23904
|
+
retryable: true
|
|
23905
|
+
}
|
|
23906
|
+
}).finally(() => this.#pending.delete(request));
|
|
23907
|
+
this.#pending.add(request);
|
|
23908
|
+
return request;
|
|
23909
|
+
}
|
|
23910
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
23911
|
+
async resolve(operation) {
|
|
23912
|
+
const result = await this.read(operation);
|
|
23913
|
+
if (!result.ok)
|
|
23914
|
+
return result;
|
|
23915
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
23916
|
+
ok: false,
|
|
23917
|
+
error: {
|
|
23918
|
+
code: "sessionNotFound",
|
|
23919
|
+
message: this.#options.notFoundMessage,
|
|
23920
|
+
retryable: false
|
|
23921
|
+
}
|
|
23922
|
+
};
|
|
23923
|
+
}
|
|
23924
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
23925
|
+
async close() {
|
|
23926
|
+
this.#abort.abort();
|
|
23927
|
+
await Promise.allSettled(this.#pending);
|
|
23928
|
+
}
|
|
23929
|
+
};
|
|
23930
|
+
|
|
23931
|
+
// dist/session-import.js
|
|
23932
|
+
function isRecord5(value) {
|
|
23933
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23934
|
+
}
|
|
23935
|
+
var KimiSessionImport = class {
|
|
23936
|
+
#home;
|
|
23937
|
+
#scope = new SessionImportScope({
|
|
23938
|
+
closedMessage: "Kimi Session import is closed",
|
|
23939
|
+
unavailableMessage: "Kimi sessions could not be read; close native clients, check storage access and retry",
|
|
23940
|
+
notFoundMessage: "Kimi Session is no longer importable"
|
|
23941
|
+
});
|
|
23942
|
+
constructor(options) {
|
|
23943
|
+
this.#home = getKimiCodeHome(options.homeDirectory, options.environment);
|
|
23944
|
+
}
|
|
23945
|
+
listCandidates() {
|
|
23946
|
+
return this.#scope.read(async (signal) => {
|
|
23947
|
+
const candidates = [];
|
|
23948
|
+
for (const nativeSessionId of await this.#indexedSessions(signal)) {
|
|
23949
|
+
try {
|
|
23950
|
+
const source = await this.#source(nativeSessionId, signal);
|
|
23951
|
+
if (source)
|
|
23952
|
+
candidates.push(source.candidate);
|
|
23953
|
+
} catch (error51) {
|
|
23954
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
23955
|
+
throw error51;
|
|
23956
|
+
}
|
|
23957
|
+
}
|
|
23958
|
+
return candidates;
|
|
23959
|
+
});
|
|
23960
|
+
}
|
|
23961
|
+
resolveCandidate(nativeSessionId) {
|
|
23962
|
+
return this.#scope.resolve(async (signal) => (await this.#indexedSessions(signal)).has(nativeSessionId) ? this.#source(nativeSessionId, signal) : null);
|
|
23963
|
+
}
|
|
23964
|
+
close() {
|
|
23965
|
+
return this.#scope.close();
|
|
23966
|
+
}
|
|
23967
|
+
/** Live identities in Kimi's index. The last record of an identity decides, as in resume. */
|
|
23968
|
+
async #indexedSessions(signal) {
|
|
23969
|
+
const live = /* @__PURE__ */ new Set();
|
|
23970
|
+
let content;
|
|
23971
|
+
try {
|
|
23972
|
+
content = await readFile4(path7.join(this.#home, "session_index.jsonl"), {
|
|
23973
|
+
encoding: "utf8",
|
|
23974
|
+
signal
|
|
23975
|
+
});
|
|
23976
|
+
} catch (error51) {
|
|
23977
|
+
signal.throwIfAborted();
|
|
23978
|
+
if (isMissingFileError(error51))
|
|
23979
|
+
return live;
|
|
23980
|
+
throw error51;
|
|
23981
|
+
}
|
|
23982
|
+
for (const line of content.split("\n")) {
|
|
23983
|
+
if (!line.trim())
|
|
23984
|
+
continue;
|
|
23985
|
+
let entry;
|
|
23986
|
+
try {
|
|
23987
|
+
entry = JSON.parse(line);
|
|
23988
|
+
} catch {
|
|
23989
|
+
continue;
|
|
23990
|
+
}
|
|
23991
|
+
if (!isRecord5(entry) || typeof entry.sessionId !== "string" || !entry.sessionId)
|
|
23992
|
+
continue;
|
|
23993
|
+
if (entry.deleted || typeof entry.sessionDir !== "string")
|
|
23994
|
+
live.delete(entry.sessionId);
|
|
23995
|
+
else
|
|
23996
|
+
live.add(entry.sessionId);
|
|
23997
|
+
}
|
|
23998
|
+
return live;
|
|
23999
|
+
}
|
|
24000
|
+
async #source(nativeSessionId, signal) {
|
|
24001
|
+
signal.throwIfAborted();
|
|
24002
|
+
const options = { kimiCodeHome: this.#home };
|
|
24003
|
+
let located;
|
|
24004
|
+
try {
|
|
24005
|
+
located = await locateKimiSession(nativeSessionId, options);
|
|
24006
|
+
} catch (error51) {
|
|
24007
|
+
if (isStorageAccessError(error51))
|
|
24008
|
+
throw error51;
|
|
24009
|
+
return null;
|
|
24010
|
+
}
|
|
24011
|
+
if (!located)
|
|
24012
|
+
return null;
|
|
24013
|
+
const { state } = located;
|
|
24014
|
+
const files = [
|
|
24015
|
+
path7.join(located.sessionDir, "state.json"),
|
|
24016
|
+
path7.join(located.mainHomeDir, "wire.jsonl")
|
|
24017
|
+
];
|
|
24018
|
+
return readStableFiles(files, async ([stateInfo, wire]) => {
|
|
24019
|
+
if (!stateInfo?.isFile() || !wire?.isFile())
|
|
24020
|
+
return null;
|
|
24021
|
+
try {
|
|
24022
|
+
if (typeof state.cwd !== "string" || !path7.isAbsolute(state.cwd))
|
|
24023
|
+
return null;
|
|
24024
|
+
const cwd = path7.resolve(state.cwd);
|
|
24025
|
+
if (!(await stat(cwd)).isDirectory())
|
|
24026
|
+
return null;
|
|
24027
|
+
signal.throwIfAborted();
|
|
24028
|
+
const { turns } = await readKimiSessionSnapshot(nativeSessionId, options);
|
|
24029
|
+
const prompt = turns.flatMap((turn) => turn.input).find((input) => input.type === "text" && input.text.trim().length > 0);
|
|
24030
|
+
if (!prompt || prompt.type !== "text")
|
|
24031
|
+
return null;
|
|
24032
|
+
const activity = turns.flatMap((turn) => [turn.completedAtMs, turn.startedAtMs]).filter((time3) => typeof time3 === "number" && Number.isFinite(time3));
|
|
24033
|
+
const candidate = sessionImportCandidate({
|
|
24034
|
+
nativeSessionId,
|
|
24035
|
+
cwd,
|
|
24036
|
+
title: sessionImportTitle(state.title) ?? sessionImportTitle(prompt.text),
|
|
24037
|
+
// Wire record times are milliseconds; the state file's unit is not documented.
|
|
24038
|
+
updatedAt: activity.length > 0 ? Math.max(...activity) : wire.mtimeMs
|
|
24039
|
+
// Kimi has no cross-process activity marker: idleness cannot be established.
|
|
24040
|
+
});
|
|
24041
|
+
return candidate ? { candidate, nativeRef: createKimiNativeSessionRef(nativeSessionId, cwd) } : null;
|
|
24042
|
+
} catch (error51) {
|
|
24043
|
+
signal.throwIfAborted();
|
|
24044
|
+
if (isStorageAccessError(error51))
|
|
24045
|
+
throw error51;
|
|
24046
|
+
return null;
|
|
24047
|
+
}
|
|
24048
|
+
});
|
|
24049
|
+
}
|
|
24050
|
+
};
|
|
24051
|
+
|
|
23222
24052
|
// dist/kimi-session.js
|
|
23223
24053
|
import { setTimeout as delay } from "node:timers/promises";
|
|
23224
24054
|
|
|
23225
24055
|
// dist/command-history.js
|
|
23226
|
-
import { appendFile, readFile as
|
|
23227
|
-
import
|
|
24056
|
+
import { appendFile, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
|
|
24057
|
+
import path8 from "node:path";
|
|
23228
24058
|
async function readKimiCommandHistory(sessionId, options) {
|
|
23229
24059
|
const located = await locateKimiSession(sessionId, options);
|
|
23230
24060
|
if (!located)
|
|
23231
24061
|
return [];
|
|
23232
24062
|
let content;
|
|
23233
24063
|
try {
|
|
23234
|
-
content = await
|
|
24064
|
+
content = await readFile5(path8.join(located.sessionDir, "codexhost-commands.jsonl"), "utf8");
|
|
23235
24065
|
} catch (error51) {
|
|
23236
24066
|
if (error51.code === "ENOENT")
|
|
23237
24067
|
return [];
|
|
@@ -23261,7 +24091,7 @@ async function appendKimiCommandHistory(turn, options) {
|
|
|
23261
24091
|
const located = await locateKimiSession(turn.nativeTurnRef.nativeSessionId, options);
|
|
23262
24092
|
if (!located)
|
|
23263
24093
|
throw new Error("Cannot persist Kimi command: native session is missing");
|
|
23264
|
-
await appendFile(
|
|
24094
|
+
await appendFile(path8.join(located.sessionDir, "codexhost-commands.jsonl"), `${JSON.stringify(turn)}
|
|
23265
24095
|
`, "utf8");
|
|
23266
24096
|
}
|
|
23267
24097
|
async function copyKimiCommandHistory(turns, sessionId, options) {
|
|
@@ -23275,7 +24105,7 @@ async function copyKimiCommandHistory(turns, sessionId, options) {
|
|
|
23275
24105
|
nativeTurnRef: { ...turn.nativeTurnRef, nativeSessionId: sessionId },
|
|
23276
24106
|
...turn.checkpoint ? { checkpoint: { ...turn.checkpoint, nativeSessionId: sessionId } } : {}
|
|
23277
24107
|
}));
|
|
23278
|
-
await writeFile3(
|
|
24108
|
+
await writeFile3(path8.join(located.sessionDir, "codexhost-commands.jsonl"), copied.map((turn) => `${JSON.stringify(turn)}
|
|
23279
24109
|
`).join(""), "utf8");
|
|
23280
24110
|
}
|
|
23281
24111
|
|
|
@@ -23822,7 +24652,7 @@ var KimiSession = class {
|
|
|
23822
24652
|
}
|
|
23823
24653
|
});
|
|
23824
24654
|
};
|
|
23825
|
-
const completeAgentMessage = (phase) => {
|
|
24655
|
+
const completeAgentMessage = (phase, outcome = { status: "succeeded" }) => {
|
|
23826
24656
|
if (currentAgentMessage) {
|
|
23827
24657
|
const resolvedPhase = phase ?? currentAgentMessage.phase;
|
|
23828
24658
|
const item = {
|
|
@@ -23831,10 +24661,23 @@ var KimiSession = class {
|
|
|
23831
24661
|
text: currentAgentMessage.text,
|
|
23832
24662
|
...resolvedPhase ? { phase: resolvedPhase } : {}
|
|
23833
24663
|
};
|
|
23834
|
-
completeItem({ item, outcome
|
|
24664
|
+
completeItem({ item, outcome });
|
|
23835
24665
|
currentAgentMessage = null;
|
|
23836
24666
|
}
|
|
23837
24667
|
};
|
|
24668
|
+
const completeFinalMessage = (outcome) => {
|
|
24669
|
+
completeAgentMessage(outcome.status !== "succeeded" ? "commentary" : hasHadToolCallsInTurn ? "final_answer" : void 0, outcome);
|
|
24670
|
+
};
|
|
24671
|
+
const getActiveTool = (event) => {
|
|
24672
|
+
const existing = accumulator.get(event.toolCallId);
|
|
24673
|
+
if (existing) {
|
|
24674
|
+
return existing.status === "completed" || existing.status === "failed" ? void 0 : existing;
|
|
24675
|
+
}
|
|
24676
|
+
hasHadToolCallsInTurn = true;
|
|
24677
|
+
completeReasoning();
|
|
24678
|
+
completeAgentMessage("commentary");
|
|
24679
|
+
return accumulator.getOrCreate(event.toolCallId, turnId, event.name, event.kind);
|
|
24680
|
+
};
|
|
23838
24681
|
const handler = {
|
|
23839
24682
|
onEvent: (event) => {
|
|
23840
24683
|
if (this.#closed || this.#faulted || this.#activeTurn?.turnId !== turnId)
|
|
@@ -23856,12 +24699,9 @@ var KimiSession = class {
|
|
|
23856
24699
|
break;
|
|
23857
24700
|
}
|
|
23858
24701
|
case "tool.call": {
|
|
23859
|
-
|
|
23860
|
-
|
|
23861
|
-
|
|
23862
|
-
completeAgentMessage("commentary");
|
|
23863
|
-
}
|
|
23864
|
-
const state = accumulator.getOrCreate(event.toolCallId, turnId, event.name, event.kind);
|
|
24702
|
+
const state = getActiveTool(event);
|
|
24703
|
+
if (!state)
|
|
24704
|
+
break;
|
|
23865
24705
|
state.name = canonicalizeKimiToolName(event.name, event.kind, event.args);
|
|
23866
24706
|
if (event.kind)
|
|
23867
24707
|
state.kind = event.kind;
|
|
@@ -23878,11 +24718,9 @@ var KimiSession = class {
|
|
|
23878
24718
|
break;
|
|
23879
24719
|
}
|
|
23880
24720
|
case "tool.update": {
|
|
23881
|
-
|
|
23882
|
-
if (
|
|
23883
|
-
|
|
23884
|
-
}
|
|
23885
|
-
const state = accumulator.getOrCreate(event.toolCallId, turnId, event.name, event.kind);
|
|
24721
|
+
const state = getActiveTool(event);
|
|
24722
|
+
if (!state)
|
|
24723
|
+
break;
|
|
23886
24724
|
if (state.name === "Tool" && event.name) {
|
|
23887
24725
|
state.name = canonicalizeKimiToolName(event.name, event.kind ?? state.kind, event.rawInput ?? state.rawInput);
|
|
23888
24726
|
}
|
|
@@ -24038,13 +24876,13 @@ var KimiSession = class {
|
|
|
24038
24876
|
completeReasoning();
|
|
24039
24877
|
if (isCommandTurn)
|
|
24040
24878
|
appendAgentText(formatKimiCommandOutput(commandOutput));
|
|
24041
|
-
completeAgentMessage(hasHadToolCallsInTurn ? "final_answer" : void 0);
|
|
24042
24879
|
let currentNativeTurn = null;
|
|
24043
24880
|
if (isCommandTurn) {
|
|
24044
24881
|
const outcome = promptError ? {
|
|
24045
24882
|
status: "failed",
|
|
24046
24883
|
error: { code: "nativeFailure", message: promptError.message, retryable: false }
|
|
24047
24884
|
} : promptResponse?.stopReason === "cancelled" ? { status: "cancelled", reason: "Native command cancelled" } : { status: "succeeded" };
|
|
24885
|
+
completeFinalMessage(outcome);
|
|
24048
24886
|
const commandTurn = {
|
|
24049
24887
|
nativeTurnRef: createKimiNativeTurnRef(this.#sessionId, `command:${turnId}`),
|
|
24050
24888
|
input: command.input,
|
|
@@ -24135,6 +24973,8 @@ var KimiSession = class {
|
|
|
24135
24973
|
status: "succeeded"
|
|
24136
24974
|
};
|
|
24137
24975
|
}
|
|
24976
|
+
if (!isCommandTurn)
|
|
24977
|
+
completeFinalMessage(turnOutcome);
|
|
24138
24978
|
const completedOutcome = currentNativeTurn?.checkpoint ? { ...turnOutcome, checkpoint: currentNativeTurn.checkpoint } : turnOutcome;
|
|
24139
24979
|
return {
|
|
24140
24980
|
kind: "event",
|
|
@@ -24447,6 +25287,7 @@ function stateFromConfig(sessionId, cwd, configOptions) {
|
|
|
24447
25287
|
}
|
|
24448
25288
|
var KimiAdapter = class {
|
|
24449
25289
|
harnessId = kimiHarnessId3;
|
|
25290
|
+
sessionImport;
|
|
24450
25291
|
#options;
|
|
24451
25292
|
#deps;
|
|
24452
25293
|
#sessions = /* @__PURE__ */ new Set();
|
|
@@ -24459,6 +25300,10 @@ var KimiAdapter = class {
|
|
|
24459
25300
|
constructor(options = {}, dependencies = {}) {
|
|
24460
25301
|
this.#options = options;
|
|
24461
25302
|
this.#deps = dependencies;
|
|
25303
|
+
this.sessionImport = new KimiSessionImport({
|
|
25304
|
+
environment: { ...process.env, ...options.environment },
|
|
25305
|
+
homeDirectory: options.homeDirectory
|
|
25306
|
+
});
|
|
24462
25307
|
}
|
|
24463
25308
|
async inspectAccount() {
|
|
24464
25309
|
if (this.#closed)
|
|
@@ -24497,10 +25342,10 @@ var KimiAdapter = class {
|
|
|
24497
25342
|
return result;
|
|
24498
25343
|
}
|
|
24499
25344
|
const kimiHome2 = getKimiCodeHome(this.#options.homeDirectory, environment);
|
|
24500
|
-
const configPath =
|
|
25345
|
+
const configPath = path9.join(kimiHome2, "config.toml");
|
|
24501
25346
|
let nativeConfig = null;
|
|
24502
25347
|
try {
|
|
24503
|
-
const configContent = await
|
|
25348
|
+
const configContent = await readFile6(configPath, "utf8");
|
|
24504
25349
|
nativeConfig = parseKimiConfigToml(configContent);
|
|
24505
25350
|
} catch {
|
|
24506
25351
|
nativeConfig = null;
|
|
@@ -24611,10 +25456,10 @@ var KimiAdapter = class {
|
|
|
24611
25456
|
onFault: (error51) => session?.handleTransportFault(error51)
|
|
24612
25457
|
});
|
|
24613
25458
|
const kimiHome2 = getKimiCodeHome(this.#options.homeDirectory, environment);
|
|
24614
|
-
const configPath =
|
|
25459
|
+
const configPath = path9.join(kimiHome2, "config.toml");
|
|
24615
25460
|
let nativeConfig = null;
|
|
24616
25461
|
try {
|
|
24617
|
-
const configContent = await
|
|
25462
|
+
const configContent = await readFile6(configPath, "utf8");
|
|
24618
25463
|
nativeConfig = parseKimiConfigToml(configContent);
|
|
24619
25464
|
} catch {
|
|
24620
25465
|
nativeConfig = null;
|
|
@@ -24671,7 +25516,7 @@ var KimiAdapter = class {
|
|
|
24671
25516
|
await transport.close().catch(() => void 0);
|
|
24672
25517
|
return err2("checkpointNotFound", "Kimi Checkpoint does not belong to the source Native Session");
|
|
24673
25518
|
}
|
|
24674
|
-
if (
|
|
25519
|
+
if (path9.resolve(cwd) !== path9.resolve(located.state.cwd)) {
|
|
24675
25520
|
await transport.close().catch(() => void 0);
|
|
24676
25521
|
return err2("unsupported", "Kimi Code cannot fork across different working directories");
|
|
24677
25522
|
}
|
|
@@ -24794,7 +25639,7 @@ var KimiAdapter = class {
|
|
|
24794
25639
|
const located = await locateKimiSession(sourceId, historyOptions);
|
|
24795
25640
|
if (!located)
|
|
24796
25641
|
return err2("sessionNotFound", "Kimi source session was not found");
|
|
24797
|
-
if (
|
|
25642
|
+
if (path9.resolve(input.cwd) !== path9.resolve(located.state.cwd))
|
|
24798
25643
|
return err2("unsupported", "Kimi cannot roll back into another working directory");
|
|
24799
25644
|
const source = [...this.#sessions].find((candidate) => candidate.initialState.nativeRef?.nativeSessionId === sourceId);
|
|
24800
25645
|
if (source) {
|
|
@@ -24852,6 +25697,7 @@ var KimiAdapter = class {
|
|
|
24852
25697
|
return;
|
|
24853
25698
|
this.#closed = true;
|
|
24854
25699
|
this.#commandCatalog = KIMI_DEFAULT_COMMAND_CATALOG;
|
|
25700
|
+
await this.sessionImport.close();
|
|
24855
25701
|
for (const session of this.#sessions) {
|
|
24856
25702
|
await session.close().catch(() => void 0);
|
|
24857
25703
|
}
|
|
@@ -24860,7 +25706,7 @@ var KimiAdapter = class {
|
|
|
24860
25706
|
};
|
|
24861
25707
|
|
|
24862
25708
|
// dist/installation.js
|
|
24863
|
-
import { open, readFile as
|
|
25709
|
+
import { open, readFile as readFile7 } from "node:fs/promises";
|
|
24864
25710
|
import { homedir as homedir3 } from "node:os";
|
|
24865
25711
|
import { join as join3 } from "node:path";
|
|
24866
25712
|
function createKimiInstallation(environment) {
|
|
@@ -24883,7 +25729,7 @@ function createKimiInstallation(environment) {
|
|
|
24883
25729
|
async check() {
|
|
24884
25730
|
const currentVersion = versionFromOutput(await run(["--version"]));
|
|
24885
25731
|
const home = environment.KIMI_CODE_HOME ?? join3(environment.HOME ?? homedir3(), ".kimi-code");
|
|
24886
|
-
const region = await
|
|
25732
|
+
const region = await readFile7(join3(home, "region"), "utf8").catch(() => "");
|
|
24887
25733
|
const base = region.trim() === "global" ? "https://code.kimi.ai/kimi-code" : "https://code.kimi.com/kimi-code";
|
|
24888
25734
|
const latestVersion = installationVersion(await fetchInstallationText(`${base}/latest`));
|
|
24889
25735
|
const npm = await npmInstallation(executable(), ["@moonshot-ai/kimi-code"], environment);
|