@liberseek/boft-cli-linux-x64 0.8.4 → 0.8.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 +2 -2
- package/THIRD_PARTY_NOTICES.txt +6 -2
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +129 -28
- package/app/console-web.js +336 -78
- package/app/desktop-controller.mjs +1741 -60
- package/app/host-runtime.mjs +4983 -2002
- package/app/plugins/antigravity/plugin.mjs +423 -63
- package/app/plugins/claude-code/plugin.mjs +417 -264
- package/app/plugins/codebuddy/plugin.mjs +256 -134
- package/app/plugins/codex-usage/plugin.mjs +97 -32
- package/app/plugins/copilot/plugin.mjs +122 -57
- package/app/plugins/cursor-cli/plugin.mjs +236 -139
- package/app/plugins/deepseek-harness/plugin.mjs +584 -86
- package/app/plugins/devin/assets/icon.svg +1 -0
- package/app/plugins/devin/manifest.json +30 -0
- package/app/plugins/devin/plugin.mjs +23425 -0
- package/app/plugins/enabled.json +2 -0
- package/app/plugins/grok/plugin.mjs +839 -500
- package/app/plugins/hermes/plugin.mjs +522 -200
- package/app/plugins/kimi-code/plugin.mjs +134 -22
- package/app/plugins/kiro-cli/plugin.mjs +84 -19
- package/app/plugins/muse/plugin.mjs +74 -9
- package/app/plugins/omp/plugin.mjs +104 -39
- package/app/plugins/opencode/plugin.mjs +126 -61
- package/app/plugins/pi/plugin.mjs +1769 -468
- package/app/plugins/qoder/plugin.mjs +9617 -8682
- package/app/plugins/qoder-cn/plugin.mjs +9617 -8682
- package/app/plugins/qwen-code/assets/icon.svg +1 -0
- package/app/plugins/qwen-code/manifest.json +29 -0
- package/app/plugins/qwen-code/plugin.mjs +29366 -0
- package/app/plugins/workbuddy/plugin.mjs +256 -134
- package/app/plugins/zcode/plugin.mjs +265 -42
- package/app/renderer-extension.js +3286 -528
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/licenses/Qwen-Code-SDK-LICENSE.txt +203 -0
- package/package.json +2 -2
|
@@ -3098,10 +3098,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3098
3098
|
const shape = def.shape;
|
|
3099
3099
|
const propValues = {};
|
|
3100
3100
|
for (const key in shape) {
|
|
3101
|
-
const
|
|
3102
|
-
if (
|
|
3101
|
+
const field3 = shape[key]._zod;
|
|
3102
|
+
if (field3.values) {
|
|
3103
3103
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3104
|
-
for (const v of
|
|
3104
|
+
for (const v of field3.values)
|
|
3105
3105
|
propValues[key].add(v);
|
|
3106
3106
|
}
|
|
3107
3107
|
}
|
|
@@ -14869,6 +14869,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
|
14869
14869
|
cachedInputTokens: count,
|
|
14870
14870
|
cacheWriteInputTokens: count,
|
|
14871
14871
|
cacheKnownInputTokens: count,
|
|
14872
|
+
cacheHitCachedInputTokens: count,
|
|
14873
|
+
cacheHitInputTokens: count,
|
|
14872
14874
|
outputTokens: count,
|
|
14873
14875
|
reasoningOutputTokens: count,
|
|
14874
14876
|
/** USD at the public price, summed over the priced requests only. */
|
|
@@ -14976,6 +14978,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
|
14976
14978
|
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
14977
14979
|
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
14978
14980
|
|
|
14981
|
+
// ../../shared-contracts/dist/thread-questions.js
|
|
14982
|
+
var field = external_exports.discriminatedUnion("type", [
|
|
14983
|
+
external_exports.object({
|
|
14984
|
+
id: external_exports.string().min(1),
|
|
14985
|
+
type: external_exports.literal("choice"),
|
|
14986
|
+
prompt: external_exports.string(),
|
|
14987
|
+
options: external_exports.array(external_exports.object({
|
|
14988
|
+
value: external_exports.string().min(1),
|
|
14989
|
+
label: external_exports.string(),
|
|
14990
|
+
description: external_exports.string().optional()
|
|
14991
|
+
})).min(1),
|
|
14992
|
+
multiple: external_exports.boolean(),
|
|
14993
|
+
allowOther: external_exports.boolean(),
|
|
14994
|
+
optional: external_exports.boolean()
|
|
14995
|
+
}),
|
|
14996
|
+
external_exports.object({
|
|
14997
|
+
id: external_exports.string().min(1),
|
|
14998
|
+
type: external_exports.literal("text"),
|
|
14999
|
+
prompt: external_exports.string(),
|
|
15000
|
+
multiline: external_exports.boolean(),
|
|
15001
|
+
secret: external_exports.literal(false),
|
|
15002
|
+
optional: external_exports.boolean(),
|
|
15003
|
+
placeholder: external_exports.string().optional(),
|
|
15004
|
+
prefill: external_exports.string().optional()
|
|
15005
|
+
})
|
|
15006
|
+
]);
|
|
15007
|
+
var threadQuestionSchema = external_exports.object({
|
|
15008
|
+
interactionId: external_exports.string().min(1),
|
|
15009
|
+
turnId: external_exports.string().min(1),
|
|
15010
|
+
title: external_exports.string().optional(),
|
|
15011
|
+
questions: external_exports.array(field).min(1)
|
|
15012
|
+
}).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
|
|
15013
|
+
message: "Shared cards require at least one multi-select question"
|
|
15014
|
+
});
|
|
15015
|
+
var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
|
|
15016
|
+
var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
|
|
15017
|
+
var threadQuestionRespondParamsSchema = external_exports.strictObject({
|
|
15018
|
+
threadId: external_exports.string().min(1),
|
|
15019
|
+
turnId: external_exports.string().min(1),
|
|
15020
|
+
interactionId: external_exports.string().min(1),
|
|
15021
|
+
answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
15022
|
+
cancelled: external_exports.boolean().default(false)
|
|
15023
|
+
});
|
|
15024
|
+
var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
|
|
15025
|
+
|
|
14979
15026
|
// ../../shared-contracts/dist/harness-plugins.js
|
|
14980
15027
|
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
14981
15028
|
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
@@ -15735,6 +15782,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15735
15782
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15736
15783
|
text: external_exports.string().optional()
|
|
15737
15784
|
}).strict();
|
|
15785
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15786
|
+
kind: external_exports.literal("application"),
|
|
15787
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15788
|
+
try {
|
|
15789
|
+
return JSON.parse(text2);
|
|
15790
|
+
} catch {
|
|
15791
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15792
|
+
return external_exports.NEVER;
|
|
15793
|
+
}
|
|
15794
|
+
}).pipe(external_exports.object({
|
|
15795
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15796
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15797
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15798
|
+
}).strict())
|
|
15799
|
+
}).strict().transform((context) => context.value);
|
|
15738
15800
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15739
15801
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15740
15802
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15745,7 +15807,10 @@ var harnessPluginRouteSchema = external_exports.object({
|
|
|
15745
15807
|
harnessId: harnessPluginIdSchema,
|
|
15746
15808
|
model: harnessModelRefSchema.optional(),
|
|
15747
15809
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15748
|
-
permissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15810
|
+
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15811
|
+
/** A draft prewarm create: stays unsubmitted until the user's first Turn.
|
|
15812
|
+
* Desktop forwards only the Model of a main-process prewarm to thread/start. */
|
|
15813
|
+
prewarm: external_exports.literal(true).optional()
|
|
15749
15814
|
}).strict();
|
|
15750
15815
|
|
|
15751
15816
|
// ../../shared-contracts/dist/harness-launch-settings.js
|
|
@@ -16356,26 +16421,26 @@ function parseHostUsage(value) {
|
|
|
16356
16421
|
}
|
|
16357
16422
|
}
|
|
16358
16423
|
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
16359
|
-
for (const
|
|
16424
|
+
for (const field3 of [
|
|
16360
16425
|
"totalCredits",
|
|
16361
16426
|
"contextUsagePercent",
|
|
16362
16427
|
"apiOutputTokensPerSecond"
|
|
16363
16428
|
]) {
|
|
16364
|
-
const candidate = value[
|
|
16429
|
+
const candidate = value[field3];
|
|
16365
16430
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16366
|
-
throw new Error(`Harness Usage '${
|
|
16431
|
+
throw new Error(`Harness Usage '${field3}' must be a finite non-negative number`);
|
|
16367
16432
|
}
|
|
16368
16433
|
}
|
|
16369
|
-
for (const
|
|
16370
|
-
const candidate = value[
|
|
16434
|
+
for (const field3 of tokenFields) {
|
|
16435
|
+
const candidate = value[field3];
|
|
16371
16436
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16372
|
-
throw new Error(`Harness Usage '${
|
|
16437
|
+
throw new Error(`Harness Usage '${field3}' must be a non-negative safe integer`);
|
|
16373
16438
|
}
|
|
16374
16439
|
}
|
|
16375
|
-
for (const
|
|
16376
|
-
const candidate = value[
|
|
16440
|
+
for (const field3 of safeIntegerFields) {
|
|
16441
|
+
const candidate = value[field3];
|
|
16377
16442
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16378
|
-
throw new Error(`Harness Usage '${
|
|
16443
|
+
throw new Error(`Harness Usage '${field3}' must be a non-negative safe integer`);
|
|
16379
16444
|
}
|
|
16380
16445
|
}
|
|
16381
16446
|
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
@@ -16384,16 +16449,16 @@ function parseHostUsage(value) {
|
|
|
16384
16449
|
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
16385
16450
|
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
16386
16451
|
}
|
|
16387
|
-
for (const
|
|
16388
|
-
const candidate = value[
|
|
16452
|
+
for (const field3 of ["totalCredits", "contextUsagePercent"]) {
|
|
16453
|
+
const candidate = value[field3];
|
|
16389
16454
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16390
|
-
throw new Error(`Harness Usage '${
|
|
16455
|
+
throw new Error(`Harness Usage '${field3}' must be a finite non-negative number`);
|
|
16391
16456
|
}
|
|
16392
16457
|
}
|
|
16393
|
-
for (const
|
|
16394
|
-
const candidate = value[
|
|
16458
|
+
for (const field3 of percentFields) {
|
|
16459
|
+
const candidate = value[field3];
|
|
16395
16460
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
16396
|
-
throw new Error(`Harness Usage '${
|
|
16461
|
+
throw new Error(`Harness Usage '${field3}' must be between 0 and 100`);
|
|
16397
16462
|
}
|
|
16398
16463
|
}
|
|
16399
16464
|
if (value.sessionCacheUsage !== void 0) {
|
|
@@ -16464,19 +16529,19 @@ function parseHostUsageRequest(value) {
|
|
|
16464
16529
|
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
16465
16530
|
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
16466
16531
|
}
|
|
16467
|
-
for (const
|
|
16468
|
-
const candidate = value[
|
|
16532
|
+
for (const field3 of ["model", "provider"]) {
|
|
16533
|
+
const candidate = value[field3];
|
|
16469
16534
|
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
16470
|
-
throw new Error(`Harness Usage request '${
|
|
16535
|
+
throw new Error(`Harness Usage request '${field3}' must be a non-empty string`);
|
|
16471
16536
|
}
|
|
16472
16537
|
}
|
|
16473
16538
|
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
16474
16539
|
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
16475
16540
|
}
|
|
16476
|
-
for (const
|
|
16477
|
-
const candidate = value[
|
|
16541
|
+
for (const field3 of requestTokenFields) {
|
|
16542
|
+
const candidate = value[field3];
|
|
16478
16543
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16479
|
-
throw new Error(`Harness Usage request '${
|
|
16544
|
+
throw new Error(`Harness Usage request '${field3}' must be a non-negative safe integer`);
|
|
16480
16545
|
}
|
|
16481
16546
|
}
|
|
16482
16547
|
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
@@ -16882,7 +16947,7 @@ function createZcodeInstallation(environment, app) {
|
|
|
16882
16947
|
}
|
|
16883
16948
|
|
|
16884
16949
|
// dist/account.js
|
|
16885
|
-
import { createHash as
|
|
16950
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
16886
16951
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
16887
16952
|
import path5 from "node:path";
|
|
16888
16953
|
|
|
@@ -16931,10 +16996,100 @@ async function readCredential(installation, environment, key) {
|
|
|
16931
16996
|
}
|
|
16932
16997
|
|
|
16933
16998
|
// dist/personal-coding-plan.js
|
|
16934
|
-
import { createHash as
|
|
16999
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
16935
17000
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
16936
17001
|
import { homedir as homedir3 } from "node:os";
|
|
16937
17002
|
import path4 from "node:path";
|
|
17003
|
+
|
|
17004
|
+
// dist/project-token.js
|
|
17005
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
17006
|
+
var locationSchema = external_exports.object({
|
|
17007
|
+
organizationId: external_exports.string().trim().min(1),
|
|
17008
|
+
projectId: external_exports.string().trim().min(1),
|
|
17009
|
+
apiKeyId: external_exports.string().trim().min(1)
|
|
17010
|
+
});
|
|
17011
|
+
function readProjectCredential(credential, family, identity, origin) {
|
|
17012
|
+
const key = `project-key-location:v1:${encodeURIComponent(JSON.stringify([origin, family, identity, null, 1, "non-team"]))}`;
|
|
17013
|
+
const raw = credential(key);
|
|
17014
|
+
if (!raw)
|
|
17015
|
+
return void 0;
|
|
17016
|
+
const location = locationSchema.parse(JSON.parse(raw));
|
|
17017
|
+
const login = credential(`oauth:${family}:access_token`).trim();
|
|
17018
|
+
const loginToken = login.replace(/^Bearer\s+/i, "").trim();
|
|
17019
|
+
if (!loginToken)
|
|
17020
|
+
throw projectCredentialError();
|
|
17021
|
+
const accountScope = createHash2("sha256").update(JSON.stringify([
|
|
17022
|
+
family,
|
|
17023
|
+
"individual-coding-plan",
|
|
17024
|
+
null,
|
|
17025
|
+
login,
|
|
17026
|
+
credential("zcodejwttoken").trim() || null
|
|
17027
|
+
])).digest("hex");
|
|
17028
|
+
return { origin, loginToken, location, accountScope };
|
|
17029
|
+
}
|
|
17030
|
+
var tokenSchema = external_exports.object({
|
|
17031
|
+
success: external_exports.boolean().optional(),
|
|
17032
|
+
code: external_exports.union([external_exports.literal(0), external_exports.literal(200), external_exports.literal("0"), external_exports.literal("200")]),
|
|
17033
|
+
data: external_exports.object({
|
|
17034
|
+
enable: external_exports.boolean().optional(),
|
|
17035
|
+
accessToken: external_exports.string().trim().min(1),
|
|
17036
|
+
tokenType: external_exports.literal("Bearer"),
|
|
17037
|
+
expiresIn: external_exports.number().finite().positive(),
|
|
17038
|
+
expiresAt: external_exports.number().finite().positive()
|
|
17039
|
+
})
|
|
17040
|
+
});
|
|
17041
|
+
function projectCredentialError() {
|
|
17042
|
+
return new ZcodeError("authenticationRequired", "ZCode Personal Coding Plan project credentials are unavailable. Open the personal plan in ZCode Desktop, then re-detect ZCode and reopen the Thread");
|
|
17043
|
+
}
|
|
17044
|
+
var ProjectToken = class {
|
|
17045
|
+
#cached;
|
|
17046
|
+
async resolve(credential, appVersion, signal, rejectedFingerprint) {
|
|
17047
|
+
signal.throwIfAborted();
|
|
17048
|
+
const scope = createHash2("sha256").update(JSON.stringify(credential)).digest("hex");
|
|
17049
|
+
const cached2 = this.#cached;
|
|
17050
|
+
if (cached2?.scope === scope && cached2.fingerprint !== rejectedFingerprint && cached2.expiresAt > Date.now() + 12e4)
|
|
17051
|
+
return cached2.token;
|
|
17052
|
+
this.#cached = void 0;
|
|
17053
|
+
const { origin, location, loginToken } = credential;
|
|
17054
|
+
const url2 = `${origin}/api/biz/v1/organization/${encodeURIComponent(location.organizationId)}/projects/${encodeURIComponent(location.projectId)}/api_keys/${encodeURIComponent(location.apiKeyId)}/access_tokens`;
|
|
17055
|
+
const started = Date.now();
|
|
17056
|
+
try {
|
|
17057
|
+
const response = await fetch(url2, {
|
|
17058
|
+
method: "POST",
|
|
17059
|
+
headers: { Authorization: `Bearer ${loginToken}`, "Content-Type": "application/json" },
|
|
17060
|
+
body: JSON.stringify({ clientType: "zcode", clientVersion: appVersion }),
|
|
17061
|
+
redirect: "error",
|
|
17062
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(15e3)])
|
|
17063
|
+
});
|
|
17064
|
+
if (!response.ok)
|
|
17065
|
+
throw projectCredentialError();
|
|
17066
|
+
const parsed = tokenSchema.safeParse(await response.json());
|
|
17067
|
+
if (!parsed.success || parsed.data.success === false || parsed.data.data.enable === false)
|
|
17068
|
+
throw projectCredentialError();
|
|
17069
|
+
const data = parsed.data.data;
|
|
17070
|
+
const expiresAt = Math.min(data.expiresAt * 1e3, started + data.expiresIn * 1e3);
|
|
17071
|
+
signal.throwIfAborted();
|
|
17072
|
+
if (expiresAt <= Date.now())
|
|
17073
|
+
throw projectCredentialError();
|
|
17074
|
+
this.#cached = {
|
|
17075
|
+
scope,
|
|
17076
|
+
token: data.accessToken,
|
|
17077
|
+
expiresAt,
|
|
17078
|
+
fingerprint: createHash2("sha256").update(data.accessToken).digest("hex")
|
|
17079
|
+
};
|
|
17080
|
+
return data.accessToken;
|
|
17081
|
+
} catch (error51) {
|
|
17082
|
+
signal.throwIfAborted();
|
|
17083
|
+
if (error51 instanceof ZcodeError)
|
|
17084
|
+
throw error51;
|
|
17085
|
+
if (error51 instanceof Error && error51.name === "TimeoutError")
|
|
17086
|
+
throw new ZcodeError("unavailable", "ZCode project token request timed out. Try again.", true);
|
|
17087
|
+
throw projectCredentialError();
|
|
17088
|
+
}
|
|
17089
|
+
}
|
|
17090
|
+
};
|
|
17091
|
+
|
|
17092
|
+
// dist/personal-coding-plan.js
|
|
16938
17093
|
var familySchema = external_exports.enum(["zai", "bigmodel"]);
|
|
16939
17094
|
var recordSchema2 = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
16940
17095
|
var CONNECT = "Connect Personal Coding Plan in ZCode Desktop, then re-detect ZCode and reopen the Thread";
|
|
@@ -16982,13 +17137,13 @@ var subscriptionSchema = external_exports.object({
|
|
|
16982
17137
|
});
|
|
16983
17138
|
function codingProduct(value) {
|
|
16984
17139
|
const entry = recordSchema2.safeParse(value).data;
|
|
16985
|
-
return [entry?.productId, entry?.productName].some((
|
|
17140
|
+
return [entry?.productId, entry?.productName].some((field3) => typeof field3 === "string" && field3.toLowerCase().includes("coding"));
|
|
16986
17141
|
}
|
|
16987
17142
|
async function queryEntitlement(family, apiKey, environment) {
|
|
16988
17143
|
try {
|
|
16989
17144
|
const response = await fetch(`${personalCodingPlanOrigin(family, environment)}/api/biz/subscription/list`, {
|
|
16990
17145
|
method: "GET",
|
|
16991
|
-
//
|
|
17146
|
+
// Legacy Desktop uses a personal API Key; project-token Desktop uses its OAuth login.
|
|
16992
17147
|
headers: { Authorization: apiKey.trim() },
|
|
16993
17148
|
redirect: "error",
|
|
16994
17149
|
signal: AbortSignal.timeout(15e3)
|
|
@@ -17022,6 +17177,8 @@ var PersonalCodingPlanAccount = class {
|
|
|
17022
17177
|
installation;
|
|
17023
17178
|
environment;
|
|
17024
17179
|
#authorized = /* @__PURE__ */ new Map();
|
|
17180
|
+
#projectToken = new ProjectToken();
|
|
17181
|
+
issue;
|
|
17025
17182
|
constructor(installation, environment) {
|
|
17026
17183
|
this.installation = installation;
|
|
17027
17184
|
this.environment = environment;
|
|
@@ -17041,12 +17198,16 @@ var PersonalCodingPlanAccount = class {
|
|
|
17041
17198
|
const identity = normalized ? normalized.id.trim() : family === "zai" && typeof profile.user_id === "string" ? profile.user_id.trim() : "";
|
|
17042
17199
|
if (!identity || identity === "unknown")
|
|
17043
17200
|
return void 0;
|
|
17201
|
+
const project2 = readProjectCredential(credential, family, identity, personalCodingPlanOrigin(family, this.environment));
|
|
17202
|
+
if (project2)
|
|
17203
|
+
return { identity, current, apiKey: project2.loginToken, project: project2 };
|
|
17044
17204
|
const key = `account-provider:coding-plan:${providerId}:account:${encodeURIComponent(identity)}:api-key`;
|
|
17045
17205
|
return { identity, current, apiKey: credential(key).trim() };
|
|
17046
17206
|
}
|
|
17047
17207
|
async inspect(providerId, accountType) {
|
|
17048
17208
|
const family = familySchema.parse(accountType);
|
|
17049
17209
|
this.#authorized.delete(providerId);
|
|
17210
|
+
this.issue = void 0;
|
|
17050
17211
|
let current = false;
|
|
17051
17212
|
try {
|
|
17052
17213
|
const context = await this.#context(providerId, family);
|
|
@@ -17058,24 +17219,29 @@ var PersonalCodingPlanAccount = class {
|
|
|
17058
17219
|
unavailableReason: "not-connected"
|
|
17059
17220
|
};
|
|
17060
17221
|
current = context.current;
|
|
17061
|
-
const connectionKey =
|
|
17222
|
+
const connectionKey = createHash3("sha256").update(JSON.stringify([family, context.identity, "individual-coding-plan"])).digest("hex");
|
|
17062
17223
|
const base = { current, connectionKey };
|
|
17063
|
-
if (!context.apiKey)
|
|
17224
|
+
if (!context.apiKey) {
|
|
17225
|
+
if (current)
|
|
17226
|
+
this.issue = "ZCode is signed in, but its Personal Coding Plan credentials are not initialized. Open the personal plan in ZCode Desktop, then re-detect ZCode. This does not mean the subscription is inactive.";
|
|
17064
17227
|
return {
|
|
17065
17228
|
...base,
|
|
17066
17229
|
availability: "unavailable",
|
|
17067
17230
|
entitled: false,
|
|
17068
17231
|
unavailableReason: "credential-failed"
|
|
17069
17232
|
};
|
|
17233
|
+
}
|
|
17070
17234
|
const entitlement = await queryEntitlement(family, context.apiKey, this.environment);
|
|
17071
17235
|
const after = await this.#context(providerId, family);
|
|
17072
|
-
if (!after || after.identity !== context.identity || after.current !== current || after.apiKey !== context.apiKey)
|
|
17236
|
+
if (!after || after.identity !== context.identity || after.current !== current || after.apiKey !== context.apiKey || JSON.stringify(after.project) !== JSON.stringify(context.project))
|
|
17073
17237
|
return { availability: "unknown", entitled: false, current: false };
|
|
17074
17238
|
if (entitlement === "available") {
|
|
17075
17239
|
if (current)
|
|
17076
17240
|
this.#authorized.set(providerId, { family, identity: context.identity });
|
|
17077
17241
|
return { ...base, availability: "available", entitled: true };
|
|
17078
17242
|
}
|
|
17243
|
+
if (current)
|
|
17244
|
+
this.issue = entitlement === "unavailable" ? "ZCode Personal Coding Plan subscription check found no active subscription. Check the selected account in ZCode Desktop, then re-detect ZCode." : "ZCode Personal Coding Plan credentials or subscription could not be verified. Open the personal plan in ZCode Desktop, then re-detect ZCode; subscription status is unknown.";
|
|
17079
17245
|
return {
|
|
17080
17246
|
...base,
|
|
17081
17247
|
availability: entitlement === "unknown" ? "unknown" : "unavailable",
|
|
@@ -17085,6 +17251,9 @@ var PersonalCodingPlanAccount = class {
|
|
|
17085
17251
|
}
|
|
17086
17252
|
};
|
|
17087
17253
|
} catch {
|
|
17254
|
+
current = await readSelection(this.environment, family).catch(() => false);
|
|
17255
|
+
if (current)
|
|
17256
|
+
this.issue = "ZCode Personal Coding Plan credentials could not be read or verified. Open the personal plan in ZCode Desktop, then re-detect ZCode; subscription status is unknown.";
|
|
17088
17257
|
return { availability: "unknown", entitled: false, current };
|
|
17089
17258
|
}
|
|
17090
17259
|
}
|
|
@@ -17096,7 +17265,9 @@ var PersonalCodingPlanAccount = class {
|
|
|
17096
17265
|
type: external_exports.literal("zhipu-account"),
|
|
17097
17266
|
mode: external_exports.literal("individual-coding-plan"),
|
|
17098
17267
|
accountType: familySchema
|
|
17099
|
-
})
|
|
17268
|
+
}),
|
|
17269
|
+
expectedAccountScope: external_exports.string().optional(),
|
|
17270
|
+
rejectedProjectTokenFingerprint: external_exports.string().optional()
|
|
17100
17271
|
}).safeParse(request);
|
|
17101
17272
|
if (!parsed.success)
|
|
17102
17273
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
@@ -17109,6 +17280,23 @@ var PersonalCodingPlanAccount = class {
|
|
|
17109
17280
|
signal.throwIfAborted();
|
|
17110
17281
|
if (!context?.current || context.identity !== authorized.identity || !context.apiKey)
|
|
17111
17282
|
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
17283
|
+
if (context.project) {
|
|
17284
|
+
const { expectedAccountScope, rejectedProjectTokenFingerprint } = parsed.data;
|
|
17285
|
+
if (expectedAccountScope !== void 0 && expectedAccountScope !== context.project.accountScope || rejectedProjectTokenFingerprint && !expectedAccountScope)
|
|
17286
|
+
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
17287
|
+
const apiKey = await this.#projectToken.resolve(context.project, this.installation.version, signal, rejectedProjectTokenFingerprint);
|
|
17288
|
+
const after = await this.#context(providerId, authorized.family);
|
|
17289
|
+
signal.throwIfAborted();
|
|
17290
|
+
if (!after?.current || after.identity !== context.identity || JSON.stringify(after.project) !== JSON.stringify(context.project))
|
|
17291
|
+
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
17292
|
+
return {
|
|
17293
|
+
apiKey,
|
|
17294
|
+
apiKeyId: context.project.location.apiKeyId,
|
|
17295
|
+
accountScope: context.project.accountScope
|
|
17296
|
+
};
|
|
17297
|
+
}
|
|
17298
|
+
if (parsed.data.expectedAccountScope !== void 0 || parsed.data.rejectedProjectTokenFingerprint)
|
|
17299
|
+
throw new ZcodeError("authenticationRequired", CONNECT);
|
|
17112
17300
|
return { apiKey: context.apiKey };
|
|
17113
17301
|
}
|
|
17114
17302
|
};
|
|
@@ -17234,7 +17422,7 @@ async function queryStartPlanBalance(origin, appVersion, jwt2, deviceMid) {
|
|
|
17234
17422
|
async function accountConfig(installation, environment) {
|
|
17235
17423
|
const file2 = installation.builtinProviderConfig;
|
|
17236
17424
|
const builtin = builtinSchema.parse(JSON.parse(await readFile3(file2, "utf8")));
|
|
17237
|
-
const basedOnZCodeBuiltinRevision = `zcode-builtin:${builtin.revision}:${
|
|
17425
|
+
const basedOnZCodeBuiltinRevision = `zcode-builtin:${builtin.revision}:${createHash4("sha256").update(path5.resolve(file2)).digest("hex")}`;
|
|
17238
17426
|
const family = await readCredential(installation, environment, "oauth:active_provider");
|
|
17239
17427
|
let balanceData;
|
|
17240
17428
|
if (family) {
|
|
@@ -17286,7 +17474,7 @@ async function accountConfig(installation, environment) {
|
|
|
17286
17474
|
};
|
|
17287
17475
|
}
|
|
17288
17476
|
}
|
|
17289
|
-
const overlayDigest =
|
|
17477
|
+
const overlayDigest = createHash4("sha256").update(JSON.stringify([providers, states])).digest("hex").slice(0, 16);
|
|
17290
17478
|
return {
|
|
17291
17479
|
params: {
|
|
17292
17480
|
revision: `codexhost:${family || "signed-out"}:${builtin.revision}:${overlayDigest}`,
|
|
@@ -17295,12 +17483,15 @@ async function accountConfig(installation, environment) {
|
|
|
17295
17483
|
states
|
|
17296
17484
|
},
|
|
17297
17485
|
startPlan,
|
|
17486
|
+
signedIn: Boolean(family),
|
|
17487
|
+
startPlanChecked: !family || balanceData !== void 0,
|
|
17298
17488
|
codingPlan
|
|
17299
17489
|
};
|
|
17300
17490
|
}
|
|
17301
17491
|
async function providerRuntimeHeaders(request, signal, installation, environment, verifier, codingPlan) {
|
|
17302
17492
|
const mode = external_exports.object({ mode: external_exports.string() }).safeParse(request.accountAccess).data?.mode;
|
|
17303
17493
|
try {
|
|
17494
|
+
signal.throwIfAborted();
|
|
17304
17495
|
if (mode === "individual-coding-plan")
|
|
17305
17496
|
return { headersApplied: true, requestAuth: await codingPlan.requestAuth(request, signal) };
|
|
17306
17497
|
if (mode !== "start-plan")
|
|
@@ -17314,6 +17505,8 @@ async function providerRuntimeHeaders(request, signal, installation, environment
|
|
|
17314
17505
|
const headers = await verifier().verify(signal);
|
|
17315
17506
|
return { headersApplied: true, requestAuth: { apiKey, headers } };
|
|
17316
17507
|
} catch (error51) {
|
|
17508
|
+
if (signal.aborted)
|
|
17509
|
+
return { headersApplied: false };
|
|
17317
17510
|
return {
|
|
17318
17511
|
headersApplied: false,
|
|
17319
17512
|
errorMessage: error51 instanceof ZcodeError ? error51.message : "ZCode account authentication failed"
|
|
@@ -17400,6 +17593,8 @@ var CliTransport = class {
|
|
|
17400
17593
|
// Aborting these cancels only this transport's running and queued shared verifications.
|
|
17401
17594
|
#headerRequests = /* @__PURE__ */ new Map();
|
|
17402
17595
|
#startPlan = false;
|
|
17596
|
+
#signedIn = false;
|
|
17597
|
+
#startPlanChecked = true;
|
|
17403
17598
|
#codingPlan;
|
|
17404
17599
|
#fault;
|
|
17405
17600
|
#closed = false;
|
|
@@ -17412,6 +17607,17 @@ var CliTransport = class {
|
|
|
17412
17607
|
get startPlan() {
|
|
17413
17608
|
return this.#startPlan;
|
|
17414
17609
|
}
|
|
17610
|
+
/** Whether ZCode Desktop is signed in to a Zhipu account, whatever that account is entitled to. */
|
|
17611
|
+
get signedIn() {
|
|
17612
|
+
return this.#signedIn;
|
|
17613
|
+
}
|
|
17614
|
+
/** False when the Start Plan balance could not be read, so its entitlement is unknown. */
|
|
17615
|
+
get startPlanChecked() {
|
|
17616
|
+
return this.#startPlanChecked;
|
|
17617
|
+
}
|
|
17618
|
+
get codingPlanIssue() {
|
|
17619
|
+
return this.#codingPlan?.issue;
|
|
17620
|
+
}
|
|
17415
17621
|
constructor(options) {
|
|
17416
17622
|
this.options = options;
|
|
17417
17623
|
this.#context = {
|
|
@@ -17423,9 +17629,11 @@ var CliTransport = class {
|
|
|
17423
17629
|
if (this.#child || this.#closed)
|
|
17424
17630
|
throw new ZcodeError("invalidState", "ZCode transport already started or closed");
|
|
17425
17631
|
const installation = await resolveInstallation(this.options.environment, this.options.app);
|
|
17426
|
-
const { params: accountParams, startPlan, codingPlan } = await accountConfig(installation, this.options.environment);
|
|
17632
|
+
const { params: accountParams, startPlan, signedIn, startPlanChecked, codingPlan } = await accountConfig(installation, this.options.environment);
|
|
17427
17633
|
this.#installation = installation;
|
|
17428
17634
|
this.#startPlan = startPlan;
|
|
17635
|
+
this.#signedIn = signedIn;
|
|
17636
|
+
this.#startPlanChecked = startPlanChecked;
|
|
17429
17637
|
this.#codingPlan = codingPlan;
|
|
17430
17638
|
const child = spawn(installation.runtime, [installation.cli, "app-server", "--stdio", "--surface", "desktop"], {
|
|
17431
17639
|
cwd: this.options.cwd,
|
|
@@ -17705,16 +17913,16 @@ var CliTransport = class {
|
|
|
17705
17913
|
var CONFIG_URL = "https://zcode.z.ai/api/v1/client/configs";
|
|
17706
17914
|
var CONFIG_TTL_MS = 6e4;
|
|
17707
17915
|
var CONFIG_TIMEOUT_MS = 15e3;
|
|
17708
|
-
var
|
|
17916
|
+
var field2 = external_exports.string().min(1).optional().catch(void 0);
|
|
17709
17917
|
var responseSchema = external_exports.object({
|
|
17710
17918
|
data: external_exports.object({
|
|
17711
17919
|
configs: external_exports.object({
|
|
17712
17920
|
captcha: external_exports.object({
|
|
17713
17921
|
enabled: external_exports.boolean().optional(),
|
|
17714
17922
|
skip_model_request: external_exports.boolean().optional(),
|
|
17715
|
-
region:
|
|
17716
|
-
prefix:
|
|
17717
|
-
sceneId:
|
|
17923
|
+
region: field2,
|
|
17924
|
+
prefix: field2,
|
|
17925
|
+
sceneId: field2
|
|
17718
17926
|
}).optional()
|
|
17719
17927
|
})
|
|
17720
17928
|
})
|
|
@@ -20127,9 +20335,24 @@ var ZcodeAdapter = class {
|
|
|
20127
20335
|
if (!catalog.models.length)
|
|
20128
20336
|
return {
|
|
20129
20337
|
status: "unavailable",
|
|
20130
|
-
|
|
20338
|
+
// A signed-in account without an active plan is not a login problem; only a signed-out
|
|
20339
|
+
// ZCode Desktop needs the login prompt.
|
|
20340
|
+
error: !transport.signedIn ? {
|
|
20131
20341
|
code: "authenticationRequired",
|
|
20132
|
-
message: "ZCode has no available models.
|
|
20342
|
+
message: "ZCode has no available models. Sign in to ZCode Desktop with a Start Plan or Personal Coding Plan account, or add a personal provider, then re-detect ZCode. Team Coding Plan is not supported.",
|
|
20343
|
+
retryable: true
|
|
20344
|
+
} : transport.codingPlanIssue ? {
|
|
20345
|
+
code: "configurationRequired",
|
|
20346
|
+
message: transport.codingPlanIssue,
|
|
20347
|
+
retryable: true
|
|
20348
|
+
} : transport.startPlanChecked ? {
|
|
20349
|
+
code: "configurationRequired",
|
|
20350
|
+
message: "ZCode is signed in, but the account has no available models: no active Start Plan or event quota, no Personal Coding Plan, and no personal provider. Free trial and event quotas expire; subscribe to GLM Coding Plan or add a personal provider (API Key) in ZCode Desktop, then re-detect ZCode. Team Coding Plan is not supported.",
|
|
20351
|
+
retryable: true
|
|
20352
|
+
} : {
|
|
20353
|
+
// The balance request failed, so a valid Start Plan may just be unreadable now.
|
|
20354
|
+
code: "configurationRequired",
|
|
20355
|
+
message: "ZCode is signed in, but no models are available: the Start Plan balance could not be checked, and there is no Personal Coding Plan or personal provider. Re-detect ZCode in a moment; if this persists, check the network and the account in ZCode Desktop. Team Coding Plan is not supported.",
|
|
20133
20356
|
retryable: true
|
|
20134
20357
|
}
|
|
20135
20358
|
};
|