@codexhost/cli-darwin-x64 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 field2 = shape[key]._zod;
3102
- if (field2.values) {
3101
+ const field3 = shape[key]._zod;
3102
+ if (field3.values) {
3103
3103
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
3104
- for (const v of field2.values)
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/console.js
14980
15027
  var consoleAnnouncementSchema = external_exports.strictObject({
14981
15028
  title: external_exports.string().trim().min(1).max(200),
@@ -16309,26 +16356,26 @@ function parseHostUsage(value) {
16309
16356
  }
16310
16357
  }
16311
16358
  const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
16312
- for (const field2 of [
16359
+ for (const field3 of [
16313
16360
  "totalCredits",
16314
16361
  "contextUsagePercent",
16315
16362
  "apiOutputTokensPerSecond"
16316
16363
  ]) {
16317
- const candidate = value[field2];
16364
+ const candidate = value[field3];
16318
16365
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16319
- throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
16366
+ throw new Error(`Harness Usage '${field3}' must be a finite non-negative number`);
16320
16367
  }
16321
16368
  }
16322
- for (const field2 of tokenFields) {
16323
- const candidate = value[field2];
16369
+ for (const field3 of tokenFields) {
16370
+ const candidate = value[field3];
16324
16371
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16325
- throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16372
+ throw new Error(`Harness Usage '${field3}' must be a non-negative safe integer`);
16326
16373
  }
16327
16374
  }
16328
- for (const field2 of safeIntegerFields) {
16329
- const candidate = value[field2];
16375
+ for (const field3 of safeIntegerFields) {
16376
+ const candidate = value[field3];
16330
16377
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16331
- throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16378
+ throw new Error(`Harness Usage '${field3}' must be a non-negative safe integer`);
16332
16379
  }
16333
16380
  }
16334
16381
  if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
@@ -16337,10 +16384,10 @@ function parseHostUsage(value) {
16337
16384
  if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
16338
16385
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
16339
16386
  }
16340
- for (const field2 of percentFields) {
16341
- const candidate = value[field2];
16387
+ for (const field3 of percentFields) {
16388
+ const candidate = value[field3];
16342
16389
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
16343
- throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
16390
+ throw new Error(`Harness Usage '${field3}' must be between 0 and 100`);
16344
16391
  }
16345
16392
  }
16346
16393
  if (value.sessionCacheUsage !== void 0) {
@@ -16411,19 +16458,19 @@ function parseHostUsageRequest(value) {
16411
16458
  if (typeof value.requestId !== "string" || value.requestId.length === 0) {
16412
16459
  throw new Error("Harness Usage request 'requestId' must be a non-empty string");
16413
16460
  }
16414
- for (const field2 of ["model", "provider"]) {
16415
- const candidate = value[field2];
16461
+ for (const field3 of ["model", "provider"]) {
16462
+ const candidate = value[field3];
16416
16463
  if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
16417
- throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
16464
+ throw new Error(`Harness Usage request '${field3}' must be a non-empty string`);
16418
16465
  }
16419
16466
  }
16420
16467
  if (value.historical !== void 0 && typeof value.historical !== "boolean") {
16421
16468
  throw new Error("Harness Usage request 'historical' must be a boolean");
16422
16469
  }
16423
- for (const field2 of requestTokenFields) {
16424
- const candidate = value[field2];
16470
+ for (const field3 of requestTokenFields) {
16471
+ const candidate = value[field3];
16425
16472
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16426
- throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
16473
+ throw new Error(`Harness Usage request '${field3}' must be a non-negative safe integer`);
16427
16474
  }
16428
16475
  }
16429
16476
  if (value.inputTokens === void 0 || value.outputTokens === void 0) {
@@ -16929,7 +16976,7 @@ var subscriptionSchema = external_exports.object({
16929
16976
  });
16930
16977
  function codingProduct(value) {
16931
16978
  const entry = recordSchema2.safeParse(value).data;
16932
- return [entry?.productId, entry?.productName].some((field2) => typeof field2 === "string" && field2.toLowerCase().includes("coding"));
16979
+ return [entry?.productId, entry?.productName].some((field3) => typeof field3 === "string" && field3.toLowerCase().includes("coding"));
16933
16980
  }
16934
16981
  async function queryEntitlement(family, apiKey, environment) {
16935
16982
  try {
@@ -17242,6 +17289,8 @@ async function accountConfig(installation, environment) {
17242
17289
  states
17243
17290
  },
17244
17291
  startPlan,
17292
+ signedIn: Boolean(family),
17293
+ startPlanChecked: !family || balanceData !== void 0,
17245
17294
  codingPlan
17246
17295
  };
17247
17296
  }
@@ -17347,6 +17396,8 @@ var CliTransport = class {
17347
17396
  // Aborting these cancels only this transport's running and queued shared verifications.
17348
17397
  #headerRequests = /* @__PURE__ */ new Map();
17349
17398
  #startPlan = false;
17399
+ #signedIn = false;
17400
+ #startPlanChecked = true;
17350
17401
  #codingPlan;
17351
17402
  #fault;
17352
17403
  #closed = false;
@@ -17359,6 +17410,14 @@ var CliTransport = class {
17359
17410
  get startPlan() {
17360
17411
  return this.#startPlan;
17361
17412
  }
17413
+ /** Whether ZCode Desktop is signed in to a Zhipu account, whatever that account is entitled to. */
17414
+ get signedIn() {
17415
+ return this.#signedIn;
17416
+ }
17417
+ /** False when the Start Plan balance could not be read, so its entitlement is unknown. */
17418
+ get startPlanChecked() {
17419
+ return this.#startPlanChecked;
17420
+ }
17362
17421
  constructor(options) {
17363
17422
  this.options = options;
17364
17423
  this.#context = {
@@ -17370,9 +17429,11 @@ var CliTransport = class {
17370
17429
  if (this.#child || this.#closed)
17371
17430
  throw new ZcodeError("invalidState", "ZCode transport already started or closed");
17372
17431
  const installation = await resolveInstallation(this.options.environment, this.options.app);
17373
- const { params: accountParams, startPlan, codingPlan } = await accountConfig(installation, this.options.environment);
17432
+ const { params: accountParams, startPlan, signedIn, startPlanChecked, codingPlan } = await accountConfig(installation, this.options.environment);
17374
17433
  this.#installation = installation;
17375
17434
  this.#startPlan = startPlan;
17435
+ this.#signedIn = signedIn;
17436
+ this.#startPlanChecked = startPlanChecked;
17376
17437
  this.#codingPlan = codingPlan;
17377
17438
  const child = spawn(installation.runtime, [installation.cli, "app-server", "--stdio", "--surface", "desktop"], {
17378
17439
  cwd: this.options.cwd,
@@ -17652,16 +17713,16 @@ var CliTransport = class {
17652
17713
  var CONFIG_URL = "https://zcode.z.ai/api/v1/client/configs";
17653
17714
  var CONFIG_TTL_MS = 6e4;
17654
17715
  var CONFIG_TIMEOUT_MS = 15e3;
17655
- var field = external_exports.string().min(1).optional().catch(void 0);
17716
+ var field2 = external_exports.string().min(1).optional().catch(void 0);
17656
17717
  var responseSchema = external_exports.object({
17657
17718
  data: external_exports.object({
17658
17719
  configs: external_exports.object({
17659
17720
  captcha: external_exports.object({
17660
17721
  enabled: external_exports.boolean().optional(),
17661
17722
  skip_model_request: external_exports.boolean().optional(),
17662
- region: field,
17663
- prefix: field,
17664
- sceneId: field
17723
+ region: field2,
17724
+ prefix: field2,
17725
+ sceneId: field2
17665
17726
  }).optional()
17666
17727
  })
17667
17728
  })
@@ -20074,9 +20135,20 @@ var ZcodeAdapter = class {
20074
20135
  if (!catalog.models.length)
20075
20136
  return {
20076
20137
  status: "unavailable",
20077
- error: {
20138
+ // A signed-in account without an active plan is not a login problem; only a signed-out
20139
+ // ZCode Desktop needs the login prompt.
20140
+ error: !transport.signedIn ? {
20078
20141
  code: "authenticationRequired",
20079
- message: "ZCode has no available models. Connect Start Plan or Personal Coding Plan in ZCode Desktop, or add a personal provider, then re-detect ZCode. Team Coding Plan is not supported.",
20142
+ 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.",
20143
+ retryable: true
20144
+ } : transport.startPlanChecked ? {
20145
+ code: "configurationRequired",
20146
+ 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.",
20147
+ retryable: true
20148
+ } : {
20149
+ // The balance request failed, so a valid Start Plan may just be unreadable now.
20150
+ code: "configurationRequired",
20151
+ 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.",
20080
20152
  retryable: true
20081
20153
  }
20082
20154
  };