@liberseek/boft-cli-linux-x64 0.7.4 → 0.7.6
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 +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +17934 -0
- package/app/console-web.js +27017 -0
- package/app/desktop-controller.mjs +154 -14
- package/app/host-runtime.mjs +3379 -1152
- package/app/plugins/antigravity/plugin.mjs +355 -74
- package/app/plugins/claude-code/plugin.mjs +2851 -2155
- package/app/plugins/codebuddy/plugin.mjs +436 -95
- package/app/plugins/cursor-cli/manifest.json +1 -1
- package/app/plugins/cursor-cli/plugin.mjs +1144 -497
- package/app/plugins/deepseek-harness/plugin.mjs +1212 -163
- package/app/plugins/grok/plugin.mjs +301 -81
- package/app/plugins/hermes/plugin.mjs +321 -87
- package/app/plugins/kimi-code/plugin.mjs +669 -76
- package/app/plugins/kiro-cli/plugin.mjs +237 -57
- package/app/plugins/muse/plugin.mjs +123 -8
- package/app/plugins/omp/plugin.mjs +470 -147
- package/app/plugins/opencode/plugin.mjs +3611 -208
- package/app/plugins/pi/plugin.mjs +911 -278
- package/app/plugins/qoder/plugin.mjs +407 -48
- package/app/plugins/qoder-cn/plugin.mjs +414 -49
- package/app/plugins/workbuddy/plugin.mjs +126 -8
- package/app/renderer-extension.js +3824 -2314
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/licenses/OpenCode-v2-Client-LICENSE.txt +21 -0
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ var __export = (target, all) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// dist/kimi-adapter.js
|
|
9
|
-
import { readFile as
|
|
10
|
-
import
|
|
9
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
10
|
+
import path8 from "node:path";
|
|
11
11
|
import { isDeepStrictEqual } from "node:util";
|
|
12
12
|
|
|
13
13
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
@@ -776,10 +776,10 @@ function mergeDefs(...defs) {
|
|
|
776
776
|
function cloneDef(schema) {
|
|
777
777
|
return mergeDefs(schema._zod.def);
|
|
778
778
|
}
|
|
779
|
-
function getElementAtPath(obj,
|
|
780
|
-
if (!
|
|
779
|
+
function getElementAtPath(obj, path9) {
|
|
780
|
+
if (!path9)
|
|
781
781
|
return obj;
|
|
782
|
-
return
|
|
782
|
+
return path9.reduce((acc, key) => acc?.[key], obj);
|
|
783
783
|
}
|
|
784
784
|
function promiseAllObject(promisesObj) {
|
|
785
785
|
const keys = Object.keys(promisesObj);
|
|
@@ -1188,11 +1188,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
return false;
|
|
1190
1190
|
}
|
|
1191
|
-
function prefixIssues(
|
|
1191
|
+
function prefixIssues(path9, issues) {
|
|
1192
1192
|
return issues.map((iss) => {
|
|
1193
1193
|
var _a3;
|
|
1194
1194
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1195
|
-
iss.path.unshift(
|
|
1195
|
+
iss.path.unshift(path9);
|
|
1196
1196
|
return iss;
|
|
1197
1197
|
});
|
|
1198
1198
|
}
|
|
@@ -1339,16 +1339,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1341
1341
|
const fieldErrors = { _errors: [] };
|
|
1342
|
-
const processError = (error52,
|
|
1342
|
+
const processError = (error52, path9 = []) => {
|
|
1343
1343
|
for (const issue2 of error52.issues) {
|
|
1344
1344
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1345
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1345
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
1346
1346
|
} else if (issue2.code === "invalid_key") {
|
|
1347
|
-
processError({ issues: issue2.issues }, [...
|
|
1347
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1348
1348
|
} else if (issue2.code === "invalid_element") {
|
|
1349
|
-
processError({ issues: issue2.issues }, [...
|
|
1349
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1350
1350
|
} else {
|
|
1351
|
-
const fullpath = [...
|
|
1351
|
+
const fullpath = [...path9, ...issue2.path];
|
|
1352
1352
|
if (fullpath.length === 0) {
|
|
1353
1353
|
fieldErrors._errors.push(mapper(issue2));
|
|
1354
1354
|
} else {
|
|
@@ -1375,17 +1375,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1377
1377
|
const result = { errors: [] };
|
|
1378
|
-
const processError = (error52,
|
|
1378
|
+
const processError = (error52, path9 = []) => {
|
|
1379
1379
|
var _a3, _b;
|
|
1380
1380
|
for (const issue2 of error52.issues) {
|
|
1381
1381
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1382
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1382
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
1383
1383
|
} else if (issue2.code === "invalid_key") {
|
|
1384
|
-
processError({ issues: issue2.issues }, [...
|
|
1384
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1385
1385
|
} else if (issue2.code === "invalid_element") {
|
|
1386
|
-
processError({ issues: issue2.issues }, [...
|
|
1386
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1387
1387
|
} else {
|
|
1388
|
-
const fullpath = [...
|
|
1388
|
+
const fullpath = [...path9, ...issue2.path];
|
|
1389
1389
|
if (fullpath.length === 0) {
|
|
1390
1390
|
result.errors.push(mapper(issue2));
|
|
1391
1391
|
continue;
|
|
@@ -1417,8 +1417,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1417
1417
|
}
|
|
1418
1418
|
function toDotPath(_path) {
|
|
1419
1419
|
const segs = [];
|
|
1420
|
-
const
|
|
1421
|
-
for (const seg of
|
|
1420
|
+
const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1421
|
+
for (const seg of path9) {
|
|
1422
1422
|
if (typeof seg === "number")
|
|
1423
1423
|
segs.push(`[${seg}]`);
|
|
1424
1424
|
else if (typeof seg === "symbol")
|
|
@@ -14110,13 +14110,13 @@ function resolveRef(ref, ctx) {
|
|
|
14110
14110
|
if (!ref.startsWith("#")) {
|
|
14111
14111
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14112
14112
|
}
|
|
14113
|
-
const
|
|
14114
|
-
if (
|
|
14113
|
+
const path9 = ref.slice(1).split("/").filter(Boolean);
|
|
14114
|
+
if (path9.length === 0) {
|
|
14115
14115
|
return ctx.rootSchema;
|
|
14116
14116
|
}
|
|
14117
14117
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14118
|
-
if (
|
|
14119
|
-
const key =
|
|
14118
|
+
if (path9[0] === defsKey) {
|
|
14119
|
+
const key = path9[1];
|
|
14120
14120
|
if (!key || !ctx.defs[key]) {
|
|
14121
14121
|
throw new Error(`Reference not found: ${ref}`);
|
|
14122
14122
|
}
|
|
@@ -14579,6 +14579,55 @@ var credentialImportsParamsSchema = external_exports.object({
|
|
|
14579
14579
|
request: credentialImportsRequestSchema
|
|
14580
14580
|
}).strict();
|
|
14581
14581
|
|
|
14582
|
+
// ../../shared-contracts/dist/harness-display-settings.js
|
|
14583
|
+
var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
|
|
14584
|
+
agent: external_exports.string().min(1).max(128),
|
|
14585
|
+
section: external_exports.enum(["main", "more", "auto"])
|
|
14586
|
+
})).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
|
|
14587
|
+
var harnessDisplaySettingsSchema = external_exports.strictObject({
|
|
14588
|
+
entries: harnessDisplayEntriesSchema.nullable()
|
|
14589
|
+
});
|
|
14590
|
+
var harnessDisplayGetSchema = external_exports.strictObject({});
|
|
14591
|
+
var harnessDisplaySetSchema = external_exports.strictObject({
|
|
14592
|
+
entries: harnessDisplayEntriesSchema,
|
|
14593
|
+
/** Import legacy Desktop preferences only if no shared settings exist yet. */
|
|
14594
|
+
initializeOnly: external_exports.boolean().optional()
|
|
14595
|
+
});
|
|
14596
|
+
|
|
14597
|
+
// ../../shared-contracts/dist/console.js
|
|
14598
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
14599
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
14600
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
14601
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
14602
|
+
});
|
|
14603
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
14604
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
14605
|
+
/** The console address. */
|
|
14606
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
14607
|
+
});
|
|
14608
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
14609
|
+
"codexhost/harness/plugins/list",
|
|
14610
|
+
"codexhost/harness/display-settings/get",
|
|
14611
|
+
"codexhost/harness/display-settings/set",
|
|
14612
|
+
"codexhost/harness/inspect",
|
|
14613
|
+
"codexhost/harness/launch-settings/get",
|
|
14614
|
+
"codexhost/harness/launch-settings/set",
|
|
14615
|
+
"codexhost/harness/web-ui/open",
|
|
14616
|
+
"codexhost/harness/accounts/sources",
|
|
14617
|
+
"codexhost/harness/accounts/list",
|
|
14618
|
+
"codexhost/harness/accounts/inspect",
|
|
14619
|
+
"codexhost/harness/credential-imports",
|
|
14620
|
+
"codexhost/harness/session-import/sources",
|
|
14621
|
+
"codexhost/harness/session-import/list",
|
|
14622
|
+
"codexhost/harness/session-import/import",
|
|
14623
|
+
"codexhost/account/list",
|
|
14624
|
+
"codexhost/account/refresh",
|
|
14625
|
+
"codexhost/account/usage/inspect",
|
|
14626
|
+
"codexhost/update/check",
|
|
14627
|
+
"codexhost/update/start",
|
|
14628
|
+
"codexhost/update/status"
|
|
14629
|
+
]);
|
|
14630
|
+
|
|
14582
14631
|
// ../../shared-contracts/dist/version.js
|
|
14583
14632
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
14584
14633
|
|
|
@@ -14632,6 +14681,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
14632
14681
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14633
14682
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14634
14683
|
|
|
14684
|
+
// ../../shared-contracts/dist/manual-compaction.js
|
|
14685
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
14686
|
+
threadId: hostThreadIdSchema,
|
|
14687
|
+
turnId: hostTurnIdSchema
|
|
14688
|
+
});
|
|
14689
|
+
|
|
14635
14690
|
// ../../shared-contracts/dist/thread-usage.js
|
|
14636
14691
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
14637
14692
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -14692,6 +14747,10 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
14692
14747
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
14693
14748
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
14694
14749
|
product: external_exports.string().min(1),
|
|
14750
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
14751
|
+
// Zero is a real empty cap, not an absent field.
|
|
14752
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
14753
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
14695
14754
|
usagePercent: usagePercentSchema,
|
|
14696
14755
|
resetsAt: external_exports.string().min(1).optional()
|
|
14697
14756
|
}).strict();
|
|
@@ -14701,11 +14760,14 @@ var accountResetCreditsSchema = external_exports.object({
|
|
|
14701
14760
|
expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
|
|
14702
14761
|
}).strict();
|
|
14703
14762
|
var accountCreditsSnapshotSchema = external_exports.object({
|
|
14763
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
14764
|
+
// Zero is a real empty cap, not an absent field.
|
|
14765
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
14766
|
+
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
14704
14767
|
/** Native label when the primary limit is scoped to a model or product group. */
|
|
14705
14768
|
label: external_exports.string().min(1).optional(),
|
|
14706
14769
|
usedPercent: usagePercentSchema.optional(),
|
|
14707
14770
|
remaining: external_exports.number().finite().optional(),
|
|
14708
|
-
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
14709
14771
|
resetsAt: external_exports.string().min(1).optional(),
|
|
14710
14772
|
periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
|
|
14711
14773
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
@@ -14736,12 +14798,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
14736
14798
|
}).strict();
|
|
14737
14799
|
|
|
14738
14800
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
14739
|
-
var
|
|
14801
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
14802
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
14803
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
14804
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
14805
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
14806
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
14807
|
+
}).strict();
|
|
14808
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
14740
14809
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
14741
14810
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
14742
14811
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
14743
|
-
credits: accountCreditsSnapshotSchema
|
|
14812
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
14813
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
14744
14814
|
}).strict();
|
|
14815
|
+
function requireReportedQuota(schema) {
|
|
14816
|
+
return schema.refine((value) => {
|
|
14817
|
+
const reported = value;
|
|
14818
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
14819
|
+
}, { message: "Account must report either credits or a balance" });
|
|
14820
|
+
}
|
|
14821
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
14745
14822
|
var harnessAccountIdentityShape = {
|
|
14746
14823
|
harnessId: harnessIdSchema,
|
|
14747
14824
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -14752,11 +14829,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
14752
14829
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
14753
14830
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
14754
14831
|
...harnessAccountIdentityShape,
|
|
14755
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
14832
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
14833
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
14834
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
14756
14835
|
}).strict();
|
|
14757
14836
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
14758
14837
|
var harnessAccountListResultSchema = external_exports.object({
|
|
14759
|
-
accounts: external_exports.array(
|
|
14838
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
14760
14839
|
}).strict();
|
|
14761
14840
|
|
|
14762
14841
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -14894,6 +14973,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
14894
14973
|
ref: harnessModelRefSchema,
|
|
14895
14974
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
14896
14975
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
14976
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
14977
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
14897
14978
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
14898
14979
|
}).strict();
|
|
14899
14980
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -14926,6 +15007,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
14926
15007
|
});
|
|
14927
15008
|
}
|
|
14928
15009
|
refs.add(model.ref.id);
|
|
15010
|
+
if (model.fastModel) {
|
|
15011
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
15012
|
+
context.addIssue({
|
|
15013
|
+
code: "custom",
|
|
15014
|
+
message: "Fast Model refs must be distinct and unique",
|
|
15015
|
+
path: ["models", index, "fastModel"]
|
|
15016
|
+
});
|
|
15017
|
+
}
|
|
15018
|
+
refs.add(model.fastModel.id);
|
|
15019
|
+
}
|
|
14929
15020
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
14930
15021
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
14931
15022
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -15048,11 +15139,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
15048
15139
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
15049
15140
|
}).strict();
|
|
15050
15141
|
var threadInspectionParamsSchema = external_exports.object({
|
|
15051
|
-
threadId: hostThreadIdSchema
|
|
15142
|
+
threadId: hostThreadIdSchema,
|
|
15143
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
15052
15144
|
}).strict();
|
|
15053
15145
|
var codexThreadInspectionSchema = external_exports.object({
|
|
15054
15146
|
owner: external_exports.literal("codex"),
|
|
15055
|
-
locked: external_exports.literal(true)
|
|
15147
|
+
locked: external_exports.literal(true),
|
|
15148
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
15056
15149
|
}).strict();
|
|
15057
15150
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15058
15151
|
owner: external_exports.literal("external"),
|
|
@@ -15180,10 +15273,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
15180
15273
|
restartRequired: external_exports.boolean()
|
|
15181
15274
|
}).strict();
|
|
15182
15275
|
|
|
15276
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
15277
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
15278
|
+
harnessId: harnessIdSchema,
|
|
15279
|
+
action: external_exports.enum(["check", "update"])
|
|
15280
|
+
}).strict();
|
|
15281
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
15282
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
15283
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
15284
|
+
updateAvailable: external_exports.boolean(),
|
|
15285
|
+
canUpdate: external_exports.boolean(),
|
|
15286
|
+
message: external_exports.string().max(2048).optional()
|
|
15287
|
+
}).strict();
|
|
15288
|
+
|
|
15183
15289
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
15184
15290
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
15185
15291
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
15186
15292
|
var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
|
|
15293
|
+
var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
|
|
15294
|
+
function isCodexAccountSiteUrl(value) {
|
|
15295
|
+
return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
|
|
15296
|
+
}
|
|
15297
|
+
var externalUrlOpenParamsSchema = external_exports.object({
|
|
15298
|
+
url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
|
|
15299
|
+
}).strict();
|
|
15300
|
+
var externalUrlOpenResultSchema = external_exports.object({}).strict();
|
|
15187
15301
|
var codexAccountPlanTypeSchema = external_exports.enum([
|
|
15188
15302
|
"free",
|
|
15189
15303
|
"go",
|
|
@@ -15209,7 +15323,8 @@ var codexAccountSchema = external_exports.object({
|
|
|
15209
15323
|
email: external_exports.string().email().max(320).optional(),
|
|
15210
15324
|
planType: codexAccountPlanTypeSchema.optional(),
|
|
15211
15325
|
authKind: codexAccountAuthKindSchema.optional(),
|
|
15212
|
-
authIdentity: nonBlankTextSchema3.max(256).optional()
|
|
15326
|
+
authIdentity: nonBlankTextSchema3.max(256).optional(),
|
|
15327
|
+
siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
|
|
15213
15328
|
}).strict();
|
|
15214
15329
|
var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
|
|
15215
15330
|
var codexAccountListResultSchema = external_exports.object({
|
|
@@ -19848,7 +19963,7 @@ var ClientSideConnection = class {
|
|
|
19848
19963
|
};
|
|
19849
19964
|
|
|
19850
19965
|
// dist/command.js
|
|
19851
|
-
import
|
|
19966
|
+
import path5 from "node:path";
|
|
19852
19967
|
|
|
19853
19968
|
// ../../harness-discovery/dist/environment.js
|
|
19854
19969
|
import fs from "node:fs";
|
|
@@ -19912,6 +20027,20 @@ function commandInvocation(command, arguments_, environment, platform = process.
|
|
|
19912
20027
|
};
|
|
19913
20028
|
}
|
|
19914
20029
|
|
|
20030
|
+
// ../../harness-discovery/dist/node-runtime.js
|
|
20031
|
+
import path3 from "node:path";
|
|
20032
|
+
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
20033
|
+
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
20034
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
20035
|
+
const runtimeDirectory = path3.dirname(runtimeExecutable);
|
|
20036
|
+
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
20037
|
+
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
20038
|
+
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
20039
|
+
directories.push(runtimeDirectory);
|
|
20040
|
+
}
|
|
20041
|
+
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
20042
|
+
}
|
|
20043
|
+
|
|
19915
20044
|
// ../../harness-discovery/dist/resolve.js
|
|
19916
20045
|
import os from "node:os";
|
|
19917
20046
|
|
|
@@ -20075,6 +20204,195 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
|
20075
20204
|
return void 0;
|
|
20076
20205
|
}
|
|
20077
20206
|
|
|
20207
|
+
// ../../harness-discovery/dist/installation.js
|
|
20208
|
+
import { execFile } from "node:child_process";
|
|
20209
|
+
import { homedir } from "node:os";
|
|
20210
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
20211
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
20212
|
+
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
20213
|
+
return new Promise((resolve, reject) => {
|
|
20214
|
+
const child = execFile(invocation.command, invocation.arguments, {
|
|
20215
|
+
env,
|
|
20216
|
+
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
20217
|
+
encoding: "utf8",
|
|
20218
|
+
timeout,
|
|
20219
|
+
killSignal: "SIGKILL",
|
|
20220
|
+
maxBuffer: 1024 * 1024,
|
|
20221
|
+
windowsHide: true,
|
|
20222
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
20223
|
+
}, (error51, stdout, stderr) => {
|
|
20224
|
+
if (error51)
|
|
20225
|
+
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
20226
|
+
else
|
|
20227
|
+
resolve((stdout || stderr).trim());
|
|
20228
|
+
});
|
|
20229
|
+
child.stdin?.end();
|
|
20230
|
+
});
|
|
20231
|
+
}
|
|
20232
|
+
function installationVersion(value) {
|
|
20233
|
+
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
20234
|
+
throw new Error("Harness returned an invalid version");
|
|
20235
|
+
return value.trim().replace(/^v/, "");
|
|
20236
|
+
}
|
|
20237
|
+
function versionFromOutput(output) {
|
|
20238
|
+
return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
|
|
20239
|
+
}
|
|
20240
|
+
function newerInstallationVersion(current, latest) {
|
|
20241
|
+
const a = installationVersion(current).replace(/\+.*/, "");
|
|
20242
|
+
const b = installationVersion(latest).replace(/\+.*/, "");
|
|
20243
|
+
const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
|
|
20244
|
+
const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
|
|
20245
|
+
for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
|
|
20246
|
+
if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
|
|
20247
|
+
return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
|
|
20248
|
+
}
|
|
20249
|
+
const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
|
|
20250
|
+
const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
|
|
20251
|
+
if (!preA.length || !preB.length)
|
|
20252
|
+
return !!preA.length && !preB.length;
|
|
20253
|
+
for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
|
|
20254
|
+
const x = preA[i];
|
|
20255
|
+
const y = preB[i];
|
|
20256
|
+
if (x === y)
|
|
20257
|
+
continue;
|
|
20258
|
+
if (x === void 0 || y === void 0)
|
|
20259
|
+
return x === void 0;
|
|
20260
|
+
const numericX = /^\d+$/.test(x);
|
|
20261
|
+
const numericY = /^\d+$/.test(y);
|
|
20262
|
+
if (numericX && numericY) {
|
|
20263
|
+
if (BigInt(x) === BigInt(y))
|
|
20264
|
+
continue;
|
|
20265
|
+
return BigInt(y) > BigInt(x);
|
|
20266
|
+
}
|
|
20267
|
+
if (numericX !== numericY)
|
|
20268
|
+
return numericX;
|
|
20269
|
+
return y > x;
|
|
20270
|
+
}
|
|
20271
|
+
return false;
|
|
20272
|
+
}
|
|
20273
|
+
function createInstallationManager(options) {
|
|
20274
|
+
let checking;
|
|
20275
|
+
let updating;
|
|
20276
|
+
const check2 = () => checking ??= options.check().finally(() => {
|
|
20277
|
+
checking = void 0;
|
|
20278
|
+
});
|
|
20279
|
+
return (action) => {
|
|
20280
|
+
if (updating)
|
|
20281
|
+
return updating;
|
|
20282
|
+
if (action === "check")
|
|
20283
|
+
return check2();
|
|
20284
|
+
updating = (async () => {
|
|
20285
|
+
const before = await check2();
|
|
20286
|
+
if (!before.updateAvailable)
|
|
20287
|
+
return before;
|
|
20288
|
+
if (!before.canUpdate)
|
|
20289
|
+
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
20290
|
+
await options.update(before);
|
|
20291
|
+
const after = await check2();
|
|
20292
|
+
if (after.currentVersion === before.currentVersion)
|
|
20293
|
+
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
20294
|
+
return after;
|
|
20295
|
+
})().finally(() => {
|
|
20296
|
+
updating = void 0;
|
|
20297
|
+
});
|
|
20298
|
+
return updating;
|
|
20299
|
+
};
|
|
20300
|
+
}
|
|
20301
|
+
async function fetchInstallationText(url2) {
|
|
20302
|
+
const request = async () => {
|
|
20303
|
+
const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
|
|
20304
|
+
if (!response.ok)
|
|
20305
|
+
throw new Error("Could not check the latest Harness version");
|
|
20306
|
+
return response.text();
|
|
20307
|
+
};
|
|
20308
|
+
try {
|
|
20309
|
+
return await request();
|
|
20310
|
+
} catch (error51) {
|
|
20311
|
+
if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
|
|
20312
|
+
throw error51;
|
|
20313
|
+
return request();
|
|
20314
|
+
}
|
|
20315
|
+
}
|
|
20316
|
+
|
|
20317
|
+
// ../../harness-discovery/dist/npm-installation.js
|
|
20318
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
20319
|
+
import path4 from "node:path";
|
|
20320
|
+
function referencesNpmBin(shim, name, bin) {
|
|
20321
|
+
if (bin.includes(".."))
|
|
20322
|
+
return false;
|
|
20323
|
+
const target = `node_modules/${name}/${bin.replace(/^\.\//, "")}`.toLowerCase();
|
|
20324
|
+
const text = shim.replaceAll("\\", "/").toLowerCase();
|
|
20325
|
+
return text.includes(`%dp0%/${target}"`) || text.includes(`%~dp0/${target}"`);
|
|
20326
|
+
}
|
|
20327
|
+
async function npmInstallation(command, packages, environment) {
|
|
20328
|
+
let selected = await realpath(command);
|
|
20329
|
+
if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
|
|
20330
|
+
const shim = (await readFile(selected, "utf8")).replaceAll("\\", "/");
|
|
20331
|
+
const root = path4.dirname(selected);
|
|
20332
|
+
for (const name of packages) {
|
|
20333
|
+
const directory2 = path4.join(root, "node_modules", ...name.split("/"));
|
|
20334
|
+
const metadata = await readFile(path4.join(directory2, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
20335
|
+
const bins = typeof metadata?.bin === "string" ? [metadata.bin] : Object.values(metadata?.bin ?? {});
|
|
20336
|
+
const bin = bins.find((entry) => referencesNpmBin(shim, name, entry));
|
|
20337
|
+
if (bin) {
|
|
20338
|
+
selected = await realpath(path4.join(directory2, bin));
|
|
20339
|
+
break;
|
|
20340
|
+
}
|
|
20341
|
+
}
|
|
20342
|
+
}
|
|
20343
|
+
let directory = path4.dirname(selected);
|
|
20344
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
20345
|
+
const metadata = await readFile(path4.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
20346
|
+
if (metadata?.name && packages.includes(metadata.name)) {
|
|
20347
|
+
const name = metadata.name;
|
|
20348
|
+
const currentVersion = installationVersion(metadata.version);
|
|
20349
|
+
const segments = name.split("/");
|
|
20350
|
+
let modules = directory;
|
|
20351
|
+
for (let index = 0; index < segments.length; index++)
|
|
20352
|
+
modules = path4.dirname(modules);
|
|
20353
|
+
const prefix = process.platform === "win32" ? path4.dirname(modules) : path4.dirname(path4.dirname(modules));
|
|
20354
|
+
const globalRoot = process.platform === "win32" ? path4.join(prefix, "node_modules") : path4.join(prefix, "lib", "node_modules");
|
|
20355
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
20356
|
+
const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
20357
|
+
let globalInstall = modules === globalRoot;
|
|
20358
|
+
if (process.platform === "win32") {
|
|
20359
|
+
const project = (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);
|
|
20360
|
+
const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
|
|
20361
|
+
const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
|
|
20362
|
+
if (path4.basename(bin) !== bin || entry.includes(".."))
|
|
20363
|
+
return false;
|
|
20364
|
+
const target = await realpath(path4.join(directory, entry)).catch(() => "");
|
|
20365
|
+
if (target.toLowerCase() !== selected.toLowerCase())
|
|
20366
|
+
return false;
|
|
20367
|
+
const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
|
|
20368
|
+
return referencesNpmBin(shim, name, entry);
|
|
20369
|
+
}));
|
|
20370
|
+
globalInstall = globalInstall && !project && launchers.some(Boolean);
|
|
20371
|
+
}
|
|
20372
|
+
const canUpdate = globalInstall && !!npm;
|
|
20373
|
+
return {
|
|
20374
|
+
prefix,
|
|
20375
|
+
currentVersion,
|
|
20376
|
+
canUpdate,
|
|
20377
|
+
latest: async () => {
|
|
20378
|
+
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`));
|
|
20379
|
+
return installationVersion(data.version);
|
|
20380
|
+
},
|
|
20381
|
+
update: async (version2) => {
|
|
20382
|
+
if (!canUpdate || !npm)
|
|
20383
|
+
throw new Error("Use the original package manager to update this installation");
|
|
20384
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${installationVersion(version2)}`], env, 3e5);
|
|
20385
|
+
}
|
|
20386
|
+
};
|
|
20387
|
+
}
|
|
20388
|
+
const parent = path4.dirname(directory);
|
|
20389
|
+
if (parent === directory)
|
|
20390
|
+
break;
|
|
20391
|
+
directory = parent;
|
|
20392
|
+
}
|
|
20393
|
+
return null;
|
|
20394
|
+
}
|
|
20395
|
+
|
|
20078
20396
|
// dist/command.js
|
|
20079
20397
|
var KimiExecutableError = class extends Error {
|
|
20080
20398
|
code = "KIMI_NOT_FOUND";
|
|
@@ -20099,7 +20417,7 @@ function resolveKimiExecutable(input = {}) {
|
|
|
20099
20417
|
});
|
|
20100
20418
|
if (!resolution)
|
|
20101
20419
|
throw new KimiExecutableError("Kimi Code CLI is not installed");
|
|
20102
|
-
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable :
|
|
20420
|
+
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
|
|
20103
20421
|
}
|
|
20104
20422
|
function kimiInvocation(command, environment = process.env, platform = process.platform) {
|
|
20105
20423
|
return commandInvocation(command, ["acp"], environment, platform);
|
|
@@ -20543,10 +20861,229 @@ var KimiAcpTransport = class {
|
|
|
20543
20861
|
}
|
|
20544
20862
|
};
|
|
20545
20863
|
|
|
20864
|
+
// dist/account-identity.js
|
|
20865
|
+
import { randomUUID } from "node:crypto";
|
|
20866
|
+
import { readFile as readFile2, rename, unlink, writeFile } from "node:fs/promises";
|
|
20867
|
+
import { homedir as homedir2 } from "node:os";
|
|
20868
|
+
import { join } from "node:path";
|
|
20869
|
+
var KIMI_USAGES_ENDPOINT = "https://api.kimi.com/coding/v1/usages";
|
|
20870
|
+
var KIMI_OAUTH_TOKEN_ENDPOINT = "https://auth.kimi.com/api/oauth/token";
|
|
20871
|
+
var KIMI_CODE_CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
20872
|
+
var REQUEST_TIMEOUT_MS = 8e3;
|
|
20873
|
+
var REFRESH_SKEW_MS = 6e4;
|
|
20874
|
+
var credentialSchema = external_exports.object({
|
|
20875
|
+
access_token: external_exports.string().min(1),
|
|
20876
|
+
refresh_token: external_exports.string().min(1).optional(),
|
|
20877
|
+
expires_at: external_exports.number().optional(),
|
|
20878
|
+
expires_in: external_exports.number().optional(),
|
|
20879
|
+
scope: external_exports.string().optional(),
|
|
20880
|
+
token_type: external_exports.string().optional()
|
|
20881
|
+
});
|
|
20882
|
+
var refreshResponseSchema = external_exports.object({
|
|
20883
|
+
access_token: external_exports.string().min(1),
|
|
20884
|
+
refresh_token: external_exports.string().min(1).optional(),
|
|
20885
|
+
expires_in: external_exports.number().positive().optional(),
|
|
20886
|
+
scope: external_exports.string().optional(),
|
|
20887
|
+
token_type: external_exports.string().optional()
|
|
20888
|
+
});
|
|
20889
|
+
function kimiHome(environment) {
|
|
20890
|
+
return environment.KIMI_CODE_HOME ?? join(environment.HOME ?? homedir2(), ".kimi-code");
|
|
20891
|
+
}
|
|
20892
|
+
function credentialPath(environment) {
|
|
20893
|
+
return join(kimiHome(environment), "credentials", "kimi-code.json");
|
|
20894
|
+
}
|
|
20895
|
+
function oauthTokenUrl(environment) {
|
|
20896
|
+
const host = environment.KIMI_CODE_OAUTH_HOST ?? environment.KIMI_OAUTH_HOST;
|
|
20897
|
+
return host ? `${host.replace(/\/$/u, "")}/api/oauth/token` : KIMI_OAUTH_TOKEN_ENDPOINT;
|
|
20898
|
+
}
|
|
20899
|
+
function isRecord3(value) {
|
|
20900
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20901
|
+
}
|
|
20902
|
+
function quantity(value) {
|
|
20903
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
20904
|
+
return value;
|
|
20905
|
+
if (typeof value === "string" && value.trim()) {
|
|
20906
|
+
const parsed = Number(value);
|
|
20907
|
+
if (Number.isFinite(parsed))
|
|
20908
|
+
return parsed;
|
|
20909
|
+
}
|
|
20910
|
+
return void 0;
|
|
20911
|
+
}
|
|
20912
|
+
function isFiveHourWindow(window) {
|
|
20913
|
+
if (!isRecord3(window))
|
|
20914
|
+
return false;
|
|
20915
|
+
const duration3 = quantity(window.duration);
|
|
20916
|
+
const unit = String(window.timeUnit ?? "").toLowerCase();
|
|
20917
|
+
return duration3 === 300 && unit.includes("minute");
|
|
20918
|
+
}
|
|
20919
|
+
function usageShare(detail) {
|
|
20920
|
+
if (!isRecord3(detail))
|
|
20921
|
+
return void 0;
|
|
20922
|
+
const limit = quantity(detail.limit);
|
|
20923
|
+
const remaining = quantity(detail.remaining);
|
|
20924
|
+
const used = quantity(detail.used) ?? (limit !== void 0 && remaining !== void 0 ? Math.max(0, limit - remaining) : void 0);
|
|
20925
|
+
if (limit === void 0 || limit <= 0 || used === void 0 || used < 0)
|
|
20926
|
+
return void 0;
|
|
20927
|
+
const resetsAt = typeof detail.resetTime === "string" && detail.resetTime ? detail.resetTime : void 0;
|
|
20928
|
+
return { usedPercent: Math.min(100, used / limit * 100), ...resetsAt ? { resetsAt } : {} };
|
|
20929
|
+
}
|
|
20930
|
+
function membershipPlan(user) {
|
|
20931
|
+
if (!isRecord3(user) || !isRecord3(user.membership) || typeof user.membership.level !== "string")
|
|
20932
|
+
return void 0;
|
|
20933
|
+
return user.membership.level.replace(/^LEVEL_/u, "").trim() || void 0;
|
|
20934
|
+
}
|
|
20935
|
+
function nickname(user) {
|
|
20936
|
+
if (!isRecord3(user) || typeof user.nickname !== "string")
|
|
20937
|
+
return void 0;
|
|
20938
|
+
return user.nickname.trim() || void 0;
|
|
20939
|
+
}
|
|
20940
|
+
function expiresAtMs(expiresAt) {
|
|
20941
|
+
if (expiresAt === void 0 || !Number.isFinite(expiresAt))
|
|
20942
|
+
return void 0;
|
|
20943
|
+
return expiresAt < 1e12 ? expiresAt * 1e3 : expiresAt;
|
|
20944
|
+
}
|
|
20945
|
+
function accessTokenFresh(credentials, now) {
|
|
20946
|
+
const expires = expiresAtMs(credentials.expires_at);
|
|
20947
|
+
return expires === void 0 || expires - REFRESH_SKEW_MS > now;
|
|
20948
|
+
}
|
|
20949
|
+
function projectKimiUsages(payload) {
|
|
20950
|
+
if (!isRecord3(payload))
|
|
20951
|
+
return null;
|
|
20952
|
+
const weekly = usageShare(payload.usage);
|
|
20953
|
+
if (!weekly)
|
|
20954
|
+
return null;
|
|
20955
|
+
const productUsage = (Array.isArray(payload.limits) ? payload.limits : []).flatMap((entry) => {
|
|
20956
|
+
if (!isRecord3(entry))
|
|
20957
|
+
return [];
|
|
20958
|
+
const share = usageShare(entry.detail);
|
|
20959
|
+
if (!share || !isFiveHourWindow(entry.window))
|
|
20960
|
+
return [];
|
|
20961
|
+
return [
|
|
20962
|
+
{
|
|
20963
|
+
product: "Kimi Code · 5-hour window",
|
|
20964
|
+
usagePercent: share.usedPercent,
|
|
20965
|
+
...share.resetsAt ? { resetsAt: share.resetsAt } : {}
|
|
20966
|
+
}
|
|
20967
|
+
];
|
|
20968
|
+
});
|
|
20969
|
+
const credits = {
|
|
20970
|
+
usedPercent: weekly.usedPercent,
|
|
20971
|
+
periodType: "weekly",
|
|
20972
|
+
...weekly.resetsAt ? { resetsAt: weekly.resetsAt } : {},
|
|
20973
|
+
...productUsage.length ? { productUsage } : {}
|
|
20974
|
+
};
|
|
20975
|
+
const plan = membershipPlan(payload.user);
|
|
20976
|
+
const label = nickname(payload.user);
|
|
20977
|
+
const parsed = harnessAccountSnapshotSchema.safeParse({
|
|
20978
|
+
label: label || "Kimi Code",
|
|
20979
|
+
...plan ? { plan } : {},
|
|
20980
|
+
credits
|
|
20981
|
+
});
|
|
20982
|
+
return parsed.success ? parsed.data : null;
|
|
20983
|
+
}
|
|
20984
|
+
async function readNativeCredentials(filePath, readAuthFile) {
|
|
20985
|
+
try {
|
|
20986
|
+
const raw = JSON.parse(await readAuthFile(filePath));
|
|
20987
|
+
if (!isRecord3(raw))
|
|
20988
|
+
return void 0;
|
|
20989
|
+
const parsed = credentialSchema.safeParse(raw);
|
|
20990
|
+
return parsed.success ? { raw, credentials: parsed.data } : void 0;
|
|
20991
|
+
} catch {
|
|
20992
|
+
return void 0;
|
|
20993
|
+
}
|
|
20994
|
+
}
|
|
20995
|
+
async function defaultWriteAuthFile(filePath, contents) {
|
|
20996
|
+
const temporary = `${filePath}.${randomUUID()}.tmp`;
|
|
20997
|
+
try {
|
|
20998
|
+
await writeFile(temporary, contents, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
20999
|
+
await rename(temporary, filePath);
|
|
21000
|
+
} finally {
|
|
21001
|
+
await unlink(temporary).catch(() => void 0);
|
|
21002
|
+
}
|
|
21003
|
+
}
|
|
21004
|
+
async function refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, signal, now) {
|
|
21005
|
+
const refreshToken = stored.credentials.refresh_token;
|
|
21006
|
+
if (!refreshToken)
|
|
21007
|
+
return void 0;
|
|
21008
|
+
const response = await fetchImpl(oauthTokenUrl(environment), {
|
|
21009
|
+
method: "POST",
|
|
21010
|
+
headers: { Accept: "application/json", "Content-Type": "application/x-www-form-urlencoded" },
|
|
21011
|
+
body: new URLSearchParams({
|
|
21012
|
+
client_id: KIMI_CODE_CLIENT_ID,
|
|
21013
|
+
grant_type: "refresh_token",
|
|
21014
|
+
refresh_token: refreshToken
|
|
21015
|
+
}),
|
|
21016
|
+
signal
|
|
21017
|
+
});
|
|
21018
|
+
if (!response.ok)
|
|
21019
|
+
return void 0;
|
|
21020
|
+
const parsed = refreshResponseSchema.safeParse(await response.json());
|
|
21021
|
+
if (!parsed.success)
|
|
21022
|
+
return void 0;
|
|
21023
|
+
const expiresIn = parsed.data.expires_in ?? stored.credentials.expires_in ?? 900;
|
|
21024
|
+
const next = {
|
|
21025
|
+
...stored.raw,
|
|
21026
|
+
access_token: parsed.data.access_token,
|
|
21027
|
+
refresh_token: parsed.data.refresh_token ?? refreshToken,
|
|
21028
|
+
expires_in: expiresIn,
|
|
21029
|
+
expires_at: now / 1e3 + expiresIn,
|
|
21030
|
+
...parsed.data.scope ? { scope: parsed.data.scope } : {},
|
|
21031
|
+
...parsed.data.token_type ? { token_type: parsed.data.token_type } : {}
|
|
21032
|
+
};
|
|
21033
|
+
await writeAuthFile(filePath, `${JSON.stringify(next, void 0, 2)}
|
|
21034
|
+
`).catch(() => void 0);
|
|
21035
|
+
stored.raw = next;
|
|
21036
|
+
stored.credentials = {
|
|
21037
|
+
...stored.credentials,
|
|
21038
|
+
access_token: parsed.data.access_token,
|
|
21039
|
+
refresh_token: parsed.data.refresh_token ?? refreshToken,
|
|
21040
|
+
expires_in: expiresIn,
|
|
21041
|
+
expires_at: now / 1e3 + expiresIn
|
|
21042
|
+
};
|
|
21043
|
+
return parsed.data.access_token;
|
|
21044
|
+
}
|
|
21045
|
+
async function fetchKimiAccount(input = {}) {
|
|
21046
|
+
try {
|
|
21047
|
+
const environment = input.environment ?? process.env;
|
|
21048
|
+
const fromEnv = environment.KIMI_CODE_API_KEY?.trim() || environment.KIMI_API_KEY?.trim();
|
|
21049
|
+
const readAuthFile = input.readAuthFile ?? ((filePath2) => readFile2(filePath2, "utf8"));
|
|
21050
|
+
const writeAuthFile = input.writeAuthFile ?? defaultWriteAuthFile;
|
|
21051
|
+
const fetchImpl = input.fetch ?? fetch;
|
|
21052
|
+
const requestSignal = () => input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]) : AbortSignal.timeout(REQUEST_TIMEOUT_MS);
|
|
21053
|
+
const now = input.now ?? Date.now();
|
|
21054
|
+
const filePath = credentialPath(environment);
|
|
21055
|
+
const stored = fromEnv ? void 0 : await readNativeCredentials(filePath, readAuthFile);
|
|
21056
|
+
let token = fromEnv ?? stored?.credentials.access_token;
|
|
21057
|
+
if (!token)
|
|
21058
|
+
return null;
|
|
21059
|
+
if (stored && !accessTokenFresh(stored.credentials, now)) {
|
|
21060
|
+
token = await refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, requestSignal(), now) ?? token;
|
|
21061
|
+
}
|
|
21062
|
+
const requestUsages = (accessToken) => fetchImpl(KIMI_USAGES_ENDPOINT, {
|
|
21063
|
+
method: "GET",
|
|
21064
|
+
headers: { Authorization: `Bearer ${accessToken}`, Accept: "application/json" },
|
|
21065
|
+
signal: requestSignal()
|
|
21066
|
+
});
|
|
21067
|
+
let response = await requestUsages(token);
|
|
21068
|
+
if (response.status === 401 && stored?.credentials.refresh_token) {
|
|
21069
|
+
const refreshed = await refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, requestSignal(), now);
|
|
21070
|
+
if (!refreshed)
|
|
21071
|
+
return null;
|
|
21072
|
+
token = refreshed;
|
|
21073
|
+
response = await requestUsages(token);
|
|
21074
|
+
}
|
|
21075
|
+
if (!response.ok)
|
|
21076
|
+
return null;
|
|
21077
|
+
return projectKimiUsages(await response.json());
|
|
21078
|
+
} catch {
|
|
21079
|
+
return null;
|
|
21080
|
+
}
|
|
21081
|
+
}
|
|
21082
|
+
|
|
20546
21083
|
// dist/history.js
|
|
20547
|
-
import { readFile } from "node:fs/promises";
|
|
21084
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
20548
21085
|
import os2 from "node:os";
|
|
20549
|
-
import
|
|
21086
|
+
import path6 from "node:path";
|
|
20550
21087
|
|
|
20551
21088
|
// ../../../node_modules/diff/libesm/diff/base.js
|
|
20552
21089
|
var Diff = class {
|
|
@@ -20648,16 +21185,16 @@ var Diff = class {
|
|
|
20648
21185
|
}
|
|
20649
21186
|
}
|
|
20650
21187
|
}
|
|
20651
|
-
addToPath(
|
|
20652
|
-
const last =
|
|
21188
|
+
addToPath(path9, added, removed, oldPosInc, options) {
|
|
21189
|
+
const last = path9.lastComponent;
|
|
20653
21190
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
20654
21191
|
return {
|
|
20655
|
-
oldPos:
|
|
21192
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
20656
21193
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
20657
21194
|
};
|
|
20658
21195
|
} else {
|
|
20659
21196
|
return {
|
|
20660
|
-
oldPos:
|
|
21197
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
20661
21198
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
20662
21199
|
};
|
|
20663
21200
|
}
|
|
@@ -21789,9 +22326,9 @@ function readKimiThinkingOptions(configOptions) {
|
|
|
21789
22326
|
}
|
|
21790
22327
|
|
|
21791
22328
|
// dist/projection.js
|
|
21792
|
-
import { randomUUID } from "node:crypto";
|
|
22329
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
21793
22330
|
function projectKimiApprovalRequest(turnId, request) {
|
|
21794
|
-
const interactionId = hostInteractionIdSchema.parse(
|
|
22331
|
+
const interactionId = hostInteractionIdSchema.parse(randomUUID2());
|
|
21795
22332
|
const optionIdByActionId = /* @__PURE__ */ new Map();
|
|
21796
22333
|
const actions = [];
|
|
21797
22334
|
const description = readAcpToolContentText(request.toolCall.content);
|
|
@@ -21835,7 +22372,7 @@ function projectKimiApprovalRequest(turnId, request) {
|
|
|
21835
22372
|
return { interaction, optionIdByActionId };
|
|
21836
22373
|
}
|
|
21837
22374
|
function projectKimiElicitationRequest(turnId, request) {
|
|
21838
|
-
const interactionId = hostInteractionIdSchema.parse(
|
|
22375
|
+
const interactionId = hostInteractionIdSchema.parse(randomUUID2());
|
|
21839
22376
|
const questions = [];
|
|
21840
22377
|
const schemaProperties = {};
|
|
21841
22378
|
const req = request;
|
|
@@ -21905,18 +22442,18 @@ function formatElicitationResponse(response, schemaProperties) {
|
|
|
21905
22442
|
}
|
|
21906
22443
|
return { action: "accept", content };
|
|
21907
22444
|
}
|
|
21908
|
-
function
|
|
22445
|
+
function isRecord4(value) {
|
|
21909
22446
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21910
22447
|
}
|
|
21911
22448
|
function canonicalizeKimiToolName(name, kind, rawInput) {
|
|
21912
22449
|
const trimmed = name?.trim();
|
|
21913
22450
|
const lower = trimmed?.toLowerCase() ?? "";
|
|
21914
22451
|
if (lower.startsWith("write") || lower.startsWith("writ")) {
|
|
21915
|
-
const isEdit =
|
|
22452
|
+
const isEdit = isRecord4(rawInput) && ("old_string" in rawInput || "oldText" in rawInput || "old" in rawInput);
|
|
21916
22453
|
return isEdit ? "Edit" : "Write";
|
|
21917
22454
|
}
|
|
21918
22455
|
if (kind === "edit" || lower.startsWith("edit")) {
|
|
21919
|
-
const isWrite =
|
|
22456
|
+
const isWrite = isRecord4(rawInput) && ("content" in rawInput || "text" in rawInput) && !("old_string" in rawInput || "oldText" in rawInput || "old" in rawInput);
|
|
21920
22457
|
return isWrite ? "Write" : "Edit";
|
|
21921
22458
|
}
|
|
21922
22459
|
if (kind === "execute" || lower.startsWith("bash") || lower.startsWith("shell") || lower.startsWith("run")) {
|
|
@@ -22125,14 +22662,14 @@ function createKimiNativeCheckpointRef(sessionId, turnId) {
|
|
|
22125
22662
|
});
|
|
22126
22663
|
}
|
|
22127
22664
|
function getKimiCodeHome(homeDirectory, environment = process.env) {
|
|
22128
|
-
return environment.KIMI_CODE_HOME || (homeDirectory ?
|
|
22665
|
+
return environment.KIMI_CODE_HOME || (homeDirectory ? path6.join(homeDirectory, ".kimi-code") : path6.join(os2.homedir(), ".kimi-code"));
|
|
22129
22666
|
}
|
|
22130
22667
|
async function locateKimiSession(sessionId, options = {}) {
|
|
22131
|
-
const
|
|
22132
|
-
const indexFile =
|
|
22668
|
+
const kimiHome2 = options.kimiCodeHome || getKimiCodeHome(options.homeDirectory);
|
|
22669
|
+
const indexFile = path6.join(kimiHome2, "session_index.jsonl");
|
|
22133
22670
|
let content;
|
|
22134
22671
|
try {
|
|
22135
|
-
content = await
|
|
22672
|
+
content = await readFile3(indexFile, "utf8");
|
|
22136
22673
|
} catch {
|
|
22137
22674
|
return null;
|
|
22138
22675
|
}
|
|
@@ -22153,15 +22690,15 @@ async function locateKimiSession(sessionId, options = {}) {
|
|
|
22153
22690
|
if (!targetEntry || targetEntry.deleted || !targetEntry.sessionDir) {
|
|
22154
22691
|
return null;
|
|
22155
22692
|
}
|
|
22156
|
-
const sessionDir =
|
|
22157
|
-
const normalizedKimiHome =
|
|
22158
|
-
const relativeToHome =
|
|
22159
|
-
if (relativeToHome.startsWith("..") ||
|
|
22693
|
+
const sessionDir = path6.resolve(targetEntry.sessionDir);
|
|
22694
|
+
const normalizedKimiHome = path6.resolve(kimiHome2);
|
|
22695
|
+
const relativeToHome = path6.relative(normalizedKimiHome, sessionDir);
|
|
22696
|
+
if (relativeToHome.startsWith("..") || path6.isAbsolute(relativeToHome)) {
|
|
22160
22697
|
throw new Error(`Session directory ${sessionDir} is outside KIMI_CODE_HOME`);
|
|
22161
22698
|
}
|
|
22162
22699
|
let state;
|
|
22163
22700
|
try {
|
|
22164
|
-
const stateContent = await
|
|
22701
|
+
const stateContent = await readFile3(path6.join(sessionDir, "state.json"), "utf8");
|
|
22165
22702
|
state = JSON.parse(stateContent);
|
|
22166
22703
|
} catch {
|
|
22167
22704
|
return null;
|
|
@@ -22169,7 +22706,7 @@ async function locateKimiSession(sessionId, options = {}) {
|
|
|
22169
22706
|
if (state.id !== sessionId) {
|
|
22170
22707
|
throw new Error(`State JSON session ID mismatch: expected ${sessionId}, found ${state.id}`);
|
|
22171
22708
|
}
|
|
22172
|
-
const mainHomeDir = state.agents?.main?.homedir ?
|
|
22709
|
+
const mainHomeDir = state.agents?.main?.homedir ? path6.resolve(state.agents.main.homedir) : path6.join(sessionDir, "agents", "main");
|
|
22173
22710
|
return { sessionDir, mainHomeDir, state };
|
|
22174
22711
|
}
|
|
22175
22712
|
async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
|
|
@@ -22462,14 +22999,14 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
|
|
|
22462
22999
|
let newContent = "";
|
|
22463
23000
|
if (tracked?.key) {
|
|
22464
23001
|
try {
|
|
22465
|
-
oldContent = await
|
|
23002
|
+
oldContent = await readFile3(path6.join(mainHomeDir, tracked.key), "utf8");
|
|
22466
23003
|
} catch {
|
|
22467
23004
|
oldContent = "";
|
|
22468
23005
|
}
|
|
22469
23006
|
}
|
|
22470
23007
|
if (checkpoint?.key) {
|
|
22471
23008
|
try {
|
|
22472
|
-
newContent = await
|
|
23009
|
+
newContent = await readFile3(path6.join(mainHomeDir, checkpoint.key), "utf8");
|
|
22473
23010
|
} catch {
|
|
22474
23011
|
newContent = "";
|
|
22475
23012
|
}
|
|
@@ -22542,10 +23079,10 @@ async function readKimiSessionSnapshot(sessionId, options = {}) {
|
|
|
22542
23079
|
if (!located) {
|
|
22543
23080
|
throw new Error(`Kimi native session not found: ${sessionId}`);
|
|
22544
23081
|
}
|
|
22545
|
-
const wirePath =
|
|
23082
|
+
const wirePath = path6.join(located.mainHomeDir, "wire.jsonl");
|
|
22546
23083
|
let wireContent = "";
|
|
22547
23084
|
try {
|
|
22548
|
-
wireContent = await
|
|
23085
|
+
wireContent = await readFile3(wirePath, "utf8");
|
|
22549
23086
|
} catch (error51) {
|
|
22550
23087
|
throw new Error(`Failed to read Kimi native history ${wirePath}: ${error51 instanceof Error ? error51.message : String(error51)}`, { cause: error51 });
|
|
22551
23088
|
}
|
|
@@ -22602,9 +23139,9 @@ async function readKimiSessionUsage(sessionId, options = {}) {
|
|
|
22602
23139
|
const located = await locateKimiSession(sessionId, options);
|
|
22603
23140
|
if (!located)
|
|
22604
23141
|
return null;
|
|
22605
|
-
const wirePath =
|
|
23142
|
+
const wirePath = path6.join(located.mainHomeDir, "wire.jsonl");
|
|
22606
23143
|
try {
|
|
22607
|
-
const wireContent = await
|
|
23144
|
+
const wireContent = await readFile3(wirePath, "utf8");
|
|
22608
23145
|
return extractKimiUsageFromWireLog(wireContent, options.contextWindowTokens);
|
|
22609
23146
|
} catch {
|
|
22610
23147
|
return null;
|
|
@@ -22615,15 +23152,15 @@ async function readKimiSessionUsage(sessionId, options = {}) {
|
|
|
22615
23152
|
import { setTimeout as delay } from "node:timers/promises";
|
|
22616
23153
|
|
|
22617
23154
|
// dist/command-history.js
|
|
22618
|
-
import { appendFile, readFile as
|
|
22619
|
-
import
|
|
23155
|
+
import { appendFile, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
23156
|
+
import path7 from "node:path";
|
|
22620
23157
|
async function readKimiCommandHistory(sessionId, options) {
|
|
22621
23158
|
const located = await locateKimiSession(sessionId, options);
|
|
22622
23159
|
if (!located)
|
|
22623
23160
|
return [];
|
|
22624
23161
|
let content;
|
|
22625
23162
|
try {
|
|
22626
|
-
content = await
|
|
23163
|
+
content = await readFile4(path7.join(located.sessionDir, "codexhost-commands.jsonl"), "utf8");
|
|
22627
23164
|
} catch (error51) {
|
|
22628
23165
|
if (error51.code === "ENOENT")
|
|
22629
23166
|
return [];
|
|
@@ -22653,7 +23190,7 @@ async function appendKimiCommandHistory(turn, options) {
|
|
|
22653
23190
|
const located = await locateKimiSession(turn.nativeTurnRef.nativeSessionId, options);
|
|
22654
23191
|
if (!located)
|
|
22655
23192
|
throw new Error("Cannot persist Kimi command: native session is missing");
|
|
22656
|
-
await appendFile(
|
|
23193
|
+
await appendFile(path7.join(located.sessionDir, "codexhost-commands.jsonl"), `${JSON.stringify(turn)}
|
|
22657
23194
|
`, "utf8");
|
|
22658
23195
|
}
|
|
22659
23196
|
async function copyKimiCommandHistory(turns, sessionId, options) {
|
|
@@ -22667,7 +23204,7 @@ async function copyKimiCommandHistory(turns, sessionId, options) {
|
|
|
22667
23204
|
nativeTurnRef: { ...turn.nativeTurnRef, nativeSessionId: sessionId },
|
|
22668
23205
|
...turn.checkpoint ? { checkpoint: { ...turn.checkpoint, nativeSessionId: sessionId } } : {}
|
|
22669
23206
|
}));
|
|
22670
|
-
await
|
|
23207
|
+
await writeFile2(path7.join(located.sessionDir, "codexhost-commands.jsonl"), copied.map((turn) => `${JSON.stringify(turn)}
|
|
22671
23208
|
`).join(""), "utf8");
|
|
22672
23209
|
}
|
|
22673
23210
|
|
|
@@ -23852,6 +24389,11 @@ var KimiAdapter = class {
|
|
|
23852
24389
|
this.#options = options;
|
|
23853
24390
|
this.#deps = dependencies;
|
|
23854
24391
|
}
|
|
24392
|
+
async inspectAccount() {
|
|
24393
|
+
if (this.#closed)
|
|
24394
|
+
return null;
|
|
24395
|
+
return fetchKimiAccount({ environment: { ...process.env, ...this.#options.environment } });
|
|
24396
|
+
}
|
|
23855
24397
|
#createTransport(options) {
|
|
23856
24398
|
return this.#deps.createTransport ? this.#deps.createTransport(options) : new KimiAcpTransport(options);
|
|
23857
24399
|
}
|
|
@@ -23883,11 +24425,11 @@ var KimiAdapter = class {
|
|
|
23883
24425
|
this.#inspectionCache = result;
|
|
23884
24426
|
return result;
|
|
23885
24427
|
}
|
|
23886
|
-
const
|
|
23887
|
-
const configPath =
|
|
24428
|
+
const kimiHome2 = getKimiCodeHome(this.#options.homeDirectory, environment);
|
|
24429
|
+
const configPath = path8.join(kimiHome2, "config.toml");
|
|
23888
24430
|
let nativeConfig = null;
|
|
23889
24431
|
try {
|
|
23890
|
-
const configContent = await
|
|
24432
|
+
const configContent = await readFile5(configPath, "utf8");
|
|
23891
24433
|
nativeConfig = parseKimiConfigToml(configContent);
|
|
23892
24434
|
} catch {
|
|
23893
24435
|
nativeConfig = null;
|
|
@@ -23997,11 +24539,11 @@ var KimiAdapter = class {
|
|
|
23997
24539
|
...this.#options.closeTimeoutMs ? { closeTimeoutMs: this.#options.closeTimeoutMs } : {},
|
|
23998
24540
|
onFault: (error51) => session?.handleTransportFault(error51)
|
|
23999
24541
|
});
|
|
24000
|
-
const
|
|
24001
|
-
const configPath =
|
|
24542
|
+
const kimiHome2 = getKimiCodeHome(this.#options.homeDirectory, environment);
|
|
24543
|
+
const configPath = path8.join(kimiHome2, "config.toml");
|
|
24002
24544
|
let nativeConfig = null;
|
|
24003
24545
|
try {
|
|
24004
|
-
const configContent = await
|
|
24546
|
+
const configContent = await readFile5(configPath, "utf8");
|
|
24005
24547
|
nativeConfig = parseKimiConfigToml(configContent);
|
|
24006
24548
|
} catch {
|
|
24007
24549
|
nativeConfig = null;
|
|
@@ -24058,7 +24600,7 @@ var KimiAdapter = class {
|
|
|
24058
24600
|
await transport.close().catch(() => void 0);
|
|
24059
24601
|
return err2("checkpointNotFound", "Kimi Checkpoint does not belong to the source Native Session");
|
|
24060
24602
|
}
|
|
24061
|
-
if (
|
|
24603
|
+
if (path8.resolve(cwd) !== path8.resolve(located.state.cwd)) {
|
|
24062
24604
|
await transport.close().catch(() => void 0);
|
|
24063
24605
|
return err2("unsupported", "Kimi Code cannot fork across different working directories");
|
|
24064
24606
|
}
|
|
@@ -24181,7 +24723,7 @@ var KimiAdapter = class {
|
|
|
24181
24723
|
const located = await locateKimiSession(sourceId, historyOptions);
|
|
24182
24724
|
if (!located)
|
|
24183
24725
|
return err2("sessionNotFound", "Kimi source session was not found");
|
|
24184
|
-
if (
|
|
24726
|
+
if (path8.resolve(input.cwd) !== path8.resolve(located.state.cwd))
|
|
24185
24727
|
return err2("unsupported", "Kimi cannot roll back into another working directory");
|
|
24186
24728
|
const source = [...this.#sessions].find((candidate) => candidate.initialState.nativeRef?.nativeSessionId === sourceId);
|
|
24187
24729
|
if (source) {
|
|
@@ -24246,13 +24788,64 @@ var KimiAdapter = class {
|
|
|
24246
24788
|
}
|
|
24247
24789
|
};
|
|
24248
24790
|
|
|
24791
|
+
// dist/installation.js
|
|
24792
|
+
import { open, readFile as readFile6 } from "node:fs/promises";
|
|
24793
|
+
import { homedir as homedir3 } from "node:os";
|
|
24794
|
+
import { join as join2 } from "node:path";
|
|
24795
|
+
function createKimiInstallation(environment) {
|
|
24796
|
+
const executable = () => resolveKimiExecutable({ environment });
|
|
24797
|
+
const run = (args, timeout) => runInstallationCommand(executable(), args, { ...environment, KIMI_CODE_NO_AUTO_UPDATE: "1" }, timeout);
|
|
24798
|
+
const nativeUpdaterAvailable = async () => {
|
|
24799
|
+
const file2 = await open(executable(), "r");
|
|
24800
|
+
try {
|
|
24801
|
+
const header = Buffer.alloc(4);
|
|
24802
|
+
await file2.read(header, 0, 4, 0);
|
|
24803
|
+
const magic = header.toString("hex");
|
|
24804
|
+
if (!["cffaedfe", "cefaedfe", "cafebabe", "7f454c46"].includes(magic) && !magic.startsWith("4d5a"))
|
|
24805
|
+
return false;
|
|
24806
|
+
} finally {
|
|
24807
|
+
await file2.close();
|
|
24808
|
+
}
|
|
24809
|
+
return /--manual/.test(await run(["__update_download", "--help"]));
|
|
24810
|
+
};
|
|
24811
|
+
return createInstallationManager({
|
|
24812
|
+
async check() {
|
|
24813
|
+
const currentVersion = versionFromOutput(await run(["--version"]));
|
|
24814
|
+
const home = environment.KIMI_CODE_HOME ?? join2(environment.HOME ?? homedir3(), ".kimi-code");
|
|
24815
|
+
const region = await readFile6(join2(home, "region"), "utf8").catch(() => "");
|
|
24816
|
+
const base = region.trim() === "global" ? "https://code.kimi.ai/kimi-code" : "https://code.kimi.com/kimi-code";
|
|
24817
|
+
const latestVersion = installationVersion(await fetchInstallationText(`${base}/latest`));
|
|
24818
|
+
const npm = await npmInstallation(executable(), ["@moonshot-ai/kimi-code"], environment);
|
|
24819
|
+
const canUpdate = npm ? npm.canUpdate : await nativeUpdaterAvailable();
|
|
24820
|
+
return {
|
|
24821
|
+
currentVersion,
|
|
24822
|
+
latestVersion,
|
|
24823
|
+
updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
|
|
24824
|
+
canUpdate,
|
|
24825
|
+
...!canUpdate ? { message: "Use the original installer to update this Kimi installation" } : {}
|
|
24826
|
+
};
|
|
24827
|
+
},
|
|
24828
|
+
async update(state) {
|
|
24829
|
+
const npm = await npmInstallation(executable(), ["@moonshot-ai/kimi-code"], environment);
|
|
24830
|
+
if (npm)
|
|
24831
|
+
await npm.update(state.latestVersion);
|
|
24832
|
+
else {
|
|
24833
|
+
if (!await nativeUpdaterAvailable())
|
|
24834
|
+
throw new Error("Kimi native updater is unavailable");
|
|
24835
|
+
await run(["__update_download", state.latestVersion, "--manual"], 3e5);
|
|
24836
|
+
await run(["--version"]);
|
|
24837
|
+
}
|
|
24838
|
+
}
|
|
24839
|
+
});
|
|
24840
|
+
}
|
|
24841
|
+
|
|
24249
24842
|
// dist/plugin.js
|
|
24250
24843
|
function createHarnessAdapter(context) {
|
|
24251
24844
|
const environment = { ...context.environment };
|
|
24252
|
-
return new KimiAdapter({
|
|
24845
|
+
return Object.assign(new KimiAdapter({
|
|
24253
24846
|
...environment[KIMI_COMMAND_ENV] ? { command: environment[KIMI_COMMAND_ENV] } : {},
|
|
24254
24847
|
environment
|
|
24255
|
-
});
|
|
24848
|
+
}), { installation: createKimiInstallation(environment) });
|
|
24256
24849
|
}
|
|
24257
24850
|
export {
|
|
24258
24851
|
createHarnessAdapter
|