@codexhost/cli-darwin-x64 0.14.0 → 0.15.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.
@@ -3040,10 +3040,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3040
3040
  const shape = def.shape;
3041
3041
  const propValues = {};
3042
3042
  for (const key in shape) {
3043
- const field = shape[key]._zod;
3044
- if (field.values) {
3043
+ const field2 = shape[key]._zod;
3044
+ if (field2.values) {
3045
3045
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
3046
- for (const v of field.values)
3046
+ for (const v of field2.values)
3047
3047
  propValues[key].add(v);
3048
3048
  }
3049
3049
  }
@@ -14790,6 +14790,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
14790
14790
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
14791
14791
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
14792
14792
 
14793
+ // ../../shared-contracts/dist/thread-questions.js
14794
+ var field = external_exports.discriminatedUnion("type", [
14795
+ external_exports.object({
14796
+ id: external_exports.string().min(1),
14797
+ type: external_exports.literal("choice"),
14798
+ prompt: external_exports.string(),
14799
+ options: external_exports.array(external_exports.object({
14800
+ value: external_exports.string().min(1),
14801
+ label: external_exports.string(),
14802
+ description: external_exports.string().optional()
14803
+ })).min(1),
14804
+ multiple: external_exports.boolean(),
14805
+ allowOther: external_exports.boolean(),
14806
+ optional: external_exports.boolean()
14807
+ }),
14808
+ external_exports.object({
14809
+ id: external_exports.string().min(1),
14810
+ type: external_exports.literal("text"),
14811
+ prompt: external_exports.string(),
14812
+ multiline: external_exports.boolean(),
14813
+ secret: external_exports.literal(false),
14814
+ optional: external_exports.boolean(),
14815
+ placeholder: external_exports.string().optional(),
14816
+ prefill: external_exports.string().optional()
14817
+ })
14818
+ ]);
14819
+ var threadQuestionSchema = external_exports.object({
14820
+ interactionId: external_exports.string().min(1),
14821
+ turnId: external_exports.string().min(1),
14822
+ title: external_exports.string().optional(),
14823
+ questions: external_exports.array(field).min(1)
14824
+ }).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
14825
+ message: "Shared cards require at least one multi-select question"
14826
+ });
14827
+ var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
14828
+ var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
14829
+ var threadQuestionRespondParamsSchema = external_exports.strictObject({
14830
+ threadId: external_exports.string().min(1),
14831
+ turnId: external_exports.string().min(1),
14832
+ interactionId: external_exports.string().min(1),
14833
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
14834
+ cancelled: external_exports.boolean().default(false)
14835
+ });
14836
+ var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
14837
+
14793
14838
  // ../../shared-contracts/dist/console.js
14794
14839
  var consoleAnnouncementSchema = external_exports.strictObject({
14795
14840
  title: external_exports.string().trim().min(1).max(200),
@@ -16140,26 +16185,26 @@ function parseHostUsage(value) {
16140
16185
  }
16141
16186
  }
16142
16187
  const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
16143
- for (const field of [
16188
+ for (const field2 of [
16144
16189
  "totalCredits",
16145
16190
  "contextUsagePercent",
16146
16191
  "apiOutputTokensPerSecond"
16147
16192
  ]) {
16148
- const candidate = value[field];
16193
+ const candidate = value[field2];
16149
16194
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
16150
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
16195
+ throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
16151
16196
  }
16152
16197
  }
16153
- for (const field of tokenFields) {
16154
- const candidate = value[field];
16198
+ for (const field2 of tokenFields) {
16199
+ const candidate = value[field2];
16155
16200
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16156
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
16201
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16157
16202
  }
16158
16203
  }
16159
- for (const field of safeIntegerFields) {
16160
- const candidate = value[field];
16204
+ for (const field2 of safeIntegerFields) {
16205
+ const candidate = value[field2];
16161
16206
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16162
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
16207
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
16163
16208
  }
16164
16209
  }
16165
16210
  if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
@@ -16168,10 +16213,10 @@ function parseHostUsage(value) {
16168
16213
  if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
16169
16214
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
16170
16215
  }
16171
- for (const field of percentFields) {
16172
- const candidate = value[field];
16216
+ for (const field2 of percentFields) {
16217
+ const candidate = value[field2];
16173
16218
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
16174
- throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
16219
+ throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
16175
16220
  }
16176
16221
  }
16177
16222
  if (value.sessionCacheUsage !== void 0) {
@@ -16242,19 +16287,19 @@ function parseHostUsageRequest(value) {
16242
16287
  if (typeof value.requestId !== "string" || value.requestId.length === 0) {
16243
16288
  throw new Error("Harness Usage request 'requestId' must be a non-empty string");
16244
16289
  }
16245
- for (const field of ["model", "provider"]) {
16246
- const candidate = value[field];
16290
+ for (const field2 of ["model", "provider"]) {
16291
+ const candidate = value[field2];
16247
16292
  if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
16248
- throw new Error(`Harness Usage request '${field}' must be a non-empty string`);
16293
+ throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
16249
16294
  }
16250
16295
  }
16251
16296
  if (value.historical !== void 0 && typeof value.historical !== "boolean") {
16252
16297
  throw new Error("Harness Usage request 'historical' must be a boolean");
16253
16298
  }
16254
- for (const field of requestTokenFields) {
16255
- const candidate = value[field];
16299
+ for (const field2 of requestTokenFields) {
16300
+ const candidate = value[field2];
16256
16301
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
16257
- throw new Error(`Harness Usage request '${field}' must be a non-negative safe integer`);
16302
+ throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
16258
16303
  }
16259
16304
  }
16260
16305
  if (value.inputTokens === void 0 || value.outputTokens === void 0) {
@@ -16360,6 +16405,7 @@ var HARNESS_BROKER_PROTOCOL_VERSION = 1;
16360
16405
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
16361
16406
  var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
16362
16407
  var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
16408
+ var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
16363
16409
  var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
16364
16410
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
16365
16411
  var harnessBrokerMethodSchema = external_exports.enum([
@@ -16367,6 +16413,8 @@ var harnessBrokerMethodSchema = external_exports.enum([
16367
16413
  "adapter.inspectAccount",
16368
16414
  "adapter.credits",
16369
16415
  "adapter.open",
16416
+ "adapter.sessionImport.list",
16417
+ "adapter.sessionImport.resolve",
16370
16418
  "adapter.subagent.readSnapshot",
16371
16419
  "session.readSnapshot",
16372
16420
  "session.readCapabilities",
@@ -16469,30 +16517,6 @@ function consumeBrokerFrames(socket, onFrame, onError) {
16469
16517
  });
16470
16518
  }
16471
16519
 
16472
- // ../../harness-broker/dist/paths.js
16473
- import os from "node:os";
16474
- import path from "node:path";
16475
- var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
16476
- var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
16477
- function defaultHarnessBrokerDirectory(environment = process.env) {
16478
- const home = environment.HOME || os.homedir();
16479
- return path.join(home, ".codexhost", "harness-broker");
16480
- }
16481
- function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
16482
- harnessPluginIdSchema.parse(harnessId);
16483
- if (harnessId !== "claude-code")
16484
- return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
16485
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
16486
- }
16487
- function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
16488
- harnessPluginIdSchema.parse(harnessId);
16489
- return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
16490
- }
16491
- function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
16492
- const home = environment.HOME || os.homedir();
16493
- return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
16494
- }
16495
-
16496
16520
  // ../../harness-broker/dist/validation.js
16497
16521
  var cwdSchema = external_exports.string().min(1).max(16384);
16498
16522
  var brokerEnvironmentSchema = external_exports.object({
@@ -16543,7 +16567,31 @@ var brokerOpenInputSchema = external_exports.discriminatedUnion("kind", [
16543
16567
  forkSchema,
16544
16568
  rollbackSchema
16545
16569
  ]);
16546
- var brokerInspectInputSchema = external_exports.object({ cwd: cwdSchema.optional(), refresh: external_exports.boolean().optional() }).strict();
16570
+ var brokerInspectInputSchema = external_exports.object({
16571
+ cwd: cwdSchema.optional(),
16572
+ refresh: external_exports.boolean().optional(),
16573
+ purpose: external_exports.literal("availability").optional()
16574
+ }).strict();
16575
+ var brokerSessionImportListParamsSchema = external_exports.object({
16576
+ offset: external_exports.number().int().nonnegative().safe(),
16577
+ limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
16578
+ }).strict();
16579
+ var brokerSessionImportResolveParamsSchema = external_exports.object({ nativeSessionId: harnessSessionImportIdSchema }).strict();
16580
+ var brokerSessionImportPageSchema = external_exports.object({
16581
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE),
16582
+ total: external_exports.number().int().nonnegative().safe()
16583
+ }).strict();
16584
+ var brokerSessionImportSourceSchema = external_exports.object({
16585
+ candidate: harnessSessionImportCandidateSchema,
16586
+ nativeRef: nativeSessionRefSchema
16587
+ }).strict().superRefine((source, context) => {
16588
+ if (source.nativeRef.nativeSessionId !== source.candidate.nativeSessionId) {
16589
+ context.addIssue({
16590
+ code: "custom",
16591
+ message: "Session import source identity does not match"
16592
+ });
16593
+ }
16594
+ });
16547
16595
  var textInputSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string().max(4e6) }).strict();
16548
16596
  var turnStartSchema = external_exports.object({
16549
16597
  type: external_exports.literal("turn.start"),
@@ -16714,6 +16762,107 @@ var harnessOutputSchema = external_exports.custom((value) => {
16714
16762
  return false;
16715
16763
  });
16716
16764
 
16765
+ // ../../harness-broker/dist/session-import-client.js
16766
+ function createBrokerSessionImportCapability(input) {
16767
+ let listing = null;
16768
+ const closed = () => ({
16769
+ ok: false,
16770
+ error: { code: "invalidState", message: "Harness broker adapter is closed", retryable: false }
16771
+ });
16772
+ const invalid = () => ({
16773
+ ok: false,
16774
+ error: {
16775
+ code: "protocolError",
16776
+ message: "Harness broker returned invalid Session import metadata",
16777
+ retryable: false
16778
+ }
16779
+ });
16780
+ const list = async () => {
16781
+ try {
16782
+ const candidates = [];
16783
+ const identities = /* @__PURE__ */ new Set();
16784
+ let total;
16785
+ for (; ; ) {
16786
+ if (input.isClosed())
16787
+ return closed();
16788
+ const result = await input.request("adapter.sessionImport.list", {
16789
+ offset: candidates.length,
16790
+ limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
16791
+ });
16792
+ if (input.isClosed())
16793
+ return closed();
16794
+ if (!result.ok)
16795
+ return result;
16796
+ const page = brokerSessionImportPageSchema.safeParse(result.value);
16797
+ if (!page.success || total !== void 0 && total !== page.data.total || page.data.total < candidates.length + page.data.candidates.length || page.data.candidates.length === 0 && candidates.length < page.data.total)
16798
+ return invalid();
16799
+ total = page.data.total;
16800
+ for (const candidate of page.data.candidates) {
16801
+ if (identities.has(candidate.nativeSessionId))
16802
+ return invalid();
16803
+ identities.add(candidate.nativeSessionId);
16804
+ candidates.push(candidate);
16805
+ }
16806
+ if (candidates.length === total)
16807
+ return { ok: true, value: candidates };
16808
+ }
16809
+ } catch (error51) {
16810
+ return { ok: false, error: input.error(error51) };
16811
+ }
16812
+ };
16813
+ return {
16814
+ listCandidates() {
16815
+ if (input.isClosed())
16816
+ return Promise.resolve(closed());
16817
+ listing ??= list().finally(() => {
16818
+ listing = null;
16819
+ });
16820
+ return listing;
16821
+ },
16822
+ async resolveCandidate(nativeSessionId) {
16823
+ if (input.isClosed())
16824
+ return closed();
16825
+ try {
16826
+ const result = await input.request("adapter.sessionImport.resolve", { nativeSessionId });
16827
+ if (input.isClosed())
16828
+ return closed();
16829
+ if (!result.ok)
16830
+ return result;
16831
+ const source = brokerSessionImportSourceSchema.safeParse(result.value);
16832
+ if (!source.success || source.data.nativeRef.harnessId !== input.harnessId || source.data.candidate.nativeSessionId !== nativeSessionId)
16833
+ return invalid();
16834
+ return { ok: true, value: source.data };
16835
+ } catch (error51) {
16836
+ return { ok: false, error: input.error(error51) };
16837
+ }
16838
+ }
16839
+ };
16840
+ }
16841
+
16842
+ // ../../harness-broker/dist/paths.js
16843
+ import os from "node:os";
16844
+ import path from "node:path";
16845
+ var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
16846
+ var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
16847
+ function defaultHarnessBrokerDirectory(environment = process.env) {
16848
+ const home = environment.HOME || os.homedir();
16849
+ return path.join(home, ".codexhost", "harness-broker");
16850
+ }
16851
+ function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
16852
+ harnessPluginIdSchema.parse(harnessId);
16853
+ if (harnessId !== "claude-code")
16854
+ return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
16855
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
16856
+ }
16857
+ function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
16858
+ harnessPluginIdSchema.parse(harnessId);
16859
+ return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
16860
+ }
16861
+ function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
16862
+ const home = environment.HOME || os.homedir();
16863
+ return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
16864
+ }
16865
+
16717
16866
  // ../../harness-broker/dist/client.js
16718
16867
  function unavailable(message, retryable = true) {
16719
16868
  return { code: "unavailable", message, retryable, stage: "harnessBroker" };
@@ -17250,6 +17399,7 @@ var BrokeredHarnessAdapter = class {
17250
17399
  commandCatalog;
17251
17400
  liveCommandCatalog;
17252
17401
  harnessId;
17402
+ sessionImport;
17253
17403
  credits;
17254
17404
  refreshCredits;
17255
17405
  #descriptorPath;
@@ -17272,6 +17422,14 @@ var BrokeredHarnessAdapter = class {
17272
17422
  };
17273
17423
  constructor(input = {}) {
17274
17424
  this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
17425
+ if (input.sessionImport) {
17426
+ this.sessionImport = createBrokerSessionImportCapability({
17427
+ harnessId: this.harnessId,
17428
+ request: async (method, params) => parseHarnessResult(await this.#request(method, params, method === "adapter.sessionImport.resolve")),
17429
+ isClosed: () => this.#closed,
17430
+ error: (error51) => this.#error(error51)
17431
+ });
17432
+ }
17275
17433
  if (input.accountCredits !== false) {
17276
17434
  this.credits = () => this.#credits;
17277
17435
  this.refreshCredits = () => this.#refreshAccountCredits();
@@ -26819,6 +26977,7 @@ function createHarnessAdapter(context) {
26819
26977
  ...context.launchCommand ? { CODEXHOST_WORKBUDDY_COMMAND: context.launchCommand } : {}
26820
26978
  };
26821
26979
  return new BrokeredHarnessAdapter({
26980
+ sessionImport: true,
26822
26981
  accountCredits: false,
26823
26982
  harnessId: "workbuddy",
26824
26983
  commandCatalog: WORKBUDDY_COMMAND_CATALOG,
@@ -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
  }
@@ -14976,6 +14976,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
14976
14976
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
14977
14977
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
14978
14978
 
14979
+ // ../../shared-contracts/dist/thread-questions.js
14980
+ var field = external_exports.discriminatedUnion("type", [
14981
+ external_exports.object({
14982
+ id: external_exports.string().min(1),
14983
+ type: external_exports.literal("choice"),
14984
+ prompt: external_exports.string(),
14985
+ options: external_exports.array(external_exports.object({
14986
+ value: external_exports.string().min(1),
14987
+ label: external_exports.string(),
14988
+ description: external_exports.string().optional()
14989
+ })).min(1),
14990
+ multiple: external_exports.boolean(),
14991
+ allowOther: external_exports.boolean(),
14992
+ optional: external_exports.boolean()
14993
+ }),
14994
+ external_exports.object({
14995
+ id: external_exports.string().min(1),
14996
+ type: external_exports.literal("text"),
14997
+ prompt: external_exports.string(),
14998
+ multiline: external_exports.boolean(),
14999
+ secret: external_exports.literal(false),
15000
+ optional: external_exports.boolean(),
15001
+ placeholder: external_exports.string().optional(),
15002
+ prefill: external_exports.string().optional()
15003
+ })
15004
+ ]);
15005
+ var threadQuestionSchema = external_exports.object({
15006
+ interactionId: external_exports.string().min(1),
15007
+ turnId: external_exports.string().min(1),
15008
+ title: external_exports.string().optional(),
15009
+ questions: external_exports.array(field).min(1)
15010
+ }).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
15011
+ message: "Shared cards require at least one multi-select question"
15012
+ });
15013
+ var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
15014
+ var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
15015
+ var threadQuestionRespondParamsSchema = external_exports.strictObject({
15016
+ threadId: external_exports.string().min(1),
15017
+ turnId: external_exports.string().min(1),
15018
+ interactionId: external_exports.string().min(1),
15019
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
15020
+ cancelled: external_exports.boolean().default(false)
15021
+ });
15022
+ var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
15023
+
14979
15024
  // ../../shared-contracts/dist/console.js
14980
15025
  var consoleAnnouncementSchema = external_exports.strictObject({
14981
15026
  title: external_exports.string().trim().min(1).max(200),
@@ -16309,26 +16354,26 @@ function parseHostUsage(value) {
16309
16354
  }
16310
16355
  }
16311
16356
  const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
16312
- for (const field2 of [
16357
+ for (const field3 of [
16313
16358
  "totalCredits",
16314
16359
  "contextUsagePercent",
16315
16360
  "apiOutputTokensPerSecond"
16316
16361
  ]) {
16317
- const candidate = value[field2];
16362
+ const candidate = value[field3];
16318
16363
  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`);
16364
+ throw new Error(`Harness Usage '${field3}' must be a finite non-negative number`);
16320
16365
  }
16321
16366
  }
16322
- for (const field2 of tokenFields) {
16323
- const candidate = value[field2];
16367
+ for (const field3 of tokenFields) {
16368
+ const candidate = value[field3];
16324
16369
  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`);
16370
+ throw new Error(`Harness Usage '${field3}' must be a non-negative safe integer`);
16326
16371
  }
16327
16372
  }
16328
- for (const field2 of safeIntegerFields) {
16329
- const candidate = value[field2];
16373
+ for (const field3 of safeIntegerFields) {
16374
+ const candidate = value[field3];
16330
16375
  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`);
16376
+ throw new Error(`Harness Usage '${field3}' must be a non-negative safe integer`);
16332
16377
  }
16333
16378
  }
16334
16379
  if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
@@ -16337,10 +16382,10 @@ function parseHostUsage(value) {
16337
16382
  if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
16338
16383
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
16339
16384
  }
16340
- for (const field2 of percentFields) {
16341
- const candidate = value[field2];
16385
+ for (const field3 of percentFields) {
16386
+ const candidate = value[field3];
16342
16387
  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`);
16388
+ throw new Error(`Harness Usage '${field3}' must be between 0 and 100`);
16344
16389
  }
16345
16390
  }
16346
16391
  if (value.sessionCacheUsage !== void 0) {
@@ -16411,19 +16456,19 @@ function parseHostUsageRequest(value) {
16411
16456
  if (typeof value.requestId !== "string" || value.requestId.length === 0) {
16412
16457
  throw new Error("Harness Usage request 'requestId' must be a non-empty string");
16413
16458
  }
16414
- for (const field2 of ["model", "provider"]) {
16415
- const candidate = value[field2];
16459
+ for (const field3 of ["model", "provider"]) {
16460
+ const candidate = value[field3];
16416
16461
  if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
16417
- throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
16462
+ throw new Error(`Harness Usage request '${field3}' must be a non-empty string`);
16418
16463
  }
16419
16464
  }
16420
16465
  if (value.historical !== void 0 && typeof value.historical !== "boolean") {
16421
16466
  throw new Error("Harness Usage request 'historical' must be a boolean");
16422
16467
  }
16423
- for (const field2 of requestTokenFields) {
16424
- const candidate = value[field2];
16468
+ for (const field3 of requestTokenFields) {
16469
+ const candidate = value[field3];
16425
16470
  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`);
16471
+ throw new Error(`Harness Usage request '${field3}' must be a non-negative safe integer`);
16427
16472
  }
16428
16473
  }
16429
16474
  if (value.inputTokens === void 0 || value.outputTokens === void 0) {
@@ -16929,7 +16974,7 @@ var subscriptionSchema = external_exports.object({
16929
16974
  });
16930
16975
  function codingProduct(value) {
16931
16976
  const entry = recordSchema2.safeParse(value).data;
16932
- return [entry?.productId, entry?.productName].some((field2) => typeof field2 === "string" && field2.toLowerCase().includes("coding"));
16977
+ return [entry?.productId, entry?.productName].some((field3) => typeof field3 === "string" && field3.toLowerCase().includes("coding"));
16933
16978
  }
16934
16979
  async function queryEntitlement(family, apiKey, environment) {
16935
16980
  try {
@@ -17242,6 +17287,8 @@ async function accountConfig(installation, environment) {
17242
17287
  states
17243
17288
  },
17244
17289
  startPlan,
17290
+ signedIn: Boolean(family),
17291
+ startPlanChecked: !family || balanceData !== void 0,
17245
17292
  codingPlan
17246
17293
  };
17247
17294
  }
@@ -17347,6 +17394,8 @@ var CliTransport = class {
17347
17394
  // Aborting these cancels only this transport's running and queued shared verifications.
17348
17395
  #headerRequests = /* @__PURE__ */ new Map();
17349
17396
  #startPlan = false;
17397
+ #signedIn = false;
17398
+ #startPlanChecked = true;
17350
17399
  #codingPlan;
17351
17400
  #fault;
17352
17401
  #closed = false;
@@ -17359,6 +17408,14 @@ var CliTransport = class {
17359
17408
  get startPlan() {
17360
17409
  return this.#startPlan;
17361
17410
  }
17411
+ /** Whether ZCode Desktop is signed in to a Zhipu account, whatever that account is entitled to. */
17412
+ get signedIn() {
17413
+ return this.#signedIn;
17414
+ }
17415
+ /** False when the Start Plan balance could not be read, so its entitlement is unknown. */
17416
+ get startPlanChecked() {
17417
+ return this.#startPlanChecked;
17418
+ }
17362
17419
  constructor(options) {
17363
17420
  this.options = options;
17364
17421
  this.#context = {
@@ -17370,9 +17427,11 @@ var CliTransport = class {
17370
17427
  if (this.#child || this.#closed)
17371
17428
  throw new ZcodeError("invalidState", "ZCode transport already started or closed");
17372
17429
  const installation = await resolveInstallation(this.options.environment, this.options.app);
17373
- const { params: accountParams, startPlan, codingPlan } = await accountConfig(installation, this.options.environment);
17430
+ const { params: accountParams, startPlan, signedIn, startPlanChecked, codingPlan } = await accountConfig(installation, this.options.environment);
17374
17431
  this.#installation = installation;
17375
17432
  this.#startPlan = startPlan;
17433
+ this.#signedIn = signedIn;
17434
+ this.#startPlanChecked = startPlanChecked;
17376
17435
  this.#codingPlan = codingPlan;
17377
17436
  const child = spawn(installation.runtime, [installation.cli, "app-server", "--stdio", "--surface", "desktop"], {
17378
17437
  cwd: this.options.cwd,
@@ -17652,16 +17711,16 @@ var CliTransport = class {
17652
17711
  var CONFIG_URL = "https://zcode.z.ai/api/v1/client/configs";
17653
17712
  var CONFIG_TTL_MS = 6e4;
17654
17713
  var CONFIG_TIMEOUT_MS = 15e3;
17655
- var field = external_exports.string().min(1).optional().catch(void 0);
17714
+ var field2 = external_exports.string().min(1).optional().catch(void 0);
17656
17715
  var responseSchema = external_exports.object({
17657
17716
  data: external_exports.object({
17658
17717
  configs: external_exports.object({
17659
17718
  captcha: external_exports.object({
17660
17719
  enabled: external_exports.boolean().optional(),
17661
17720
  skip_model_request: external_exports.boolean().optional(),
17662
- region: field,
17663
- prefix: field,
17664
- sceneId: field
17721
+ region: field2,
17722
+ prefix: field2,
17723
+ sceneId: field2
17665
17724
  }).optional()
17666
17725
  })
17667
17726
  })
@@ -20074,9 +20133,20 @@ var ZcodeAdapter = class {
20074
20133
  if (!catalog.models.length)
20075
20134
  return {
20076
20135
  status: "unavailable",
20077
- error: {
20136
+ // A signed-in account without an active plan is not a login problem; only a signed-out
20137
+ // ZCode Desktop needs the login prompt.
20138
+ error: !transport.signedIn ? {
20078
20139
  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.",
20140
+ 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.",
20141
+ retryable: true
20142
+ } : transport.startPlanChecked ? {
20143
+ code: "configurationRequired",
20144
+ 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.",
20145
+ retryable: true
20146
+ } : {
20147
+ // The balance request failed, so a valid Start Plan may just be unreadable now.
20148
+ code: "configurationRequired",
20149
+ 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
20150
  retryable: true
20081
20151
  }
20082
20152
  };