@karlorz/codexhost-cli-win32-x64 0.14.0-4 → 0.15.0-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.
@@ -16518,6 +16518,7 @@ var HARNESS_BROKER_PROTOCOL_VERSION = 1;
16518
16518
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
16519
16519
  var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
16520
16520
  var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
16521
+ var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
16521
16522
  var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
16522
16523
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
16523
16524
  var harnessBrokerMethodSchema = external_exports.enum([
@@ -16525,6 +16526,8 @@ var harnessBrokerMethodSchema = external_exports.enum([
16525
16526
  "adapter.inspectAccount",
16526
16527
  "adapter.credits",
16527
16528
  "adapter.open",
16529
+ "adapter.sessionImport.list",
16530
+ "adapter.sessionImport.resolve",
16528
16531
  "adapter.subagent.readSnapshot",
16529
16532
  "session.readSnapshot",
16530
16533
  "session.readCapabilities",
@@ -16627,30 +16630,6 @@ function consumeBrokerFrames(socket, onFrame, onError) {
16627
16630
  });
16628
16631
  }
16629
16632
 
16630
- // ../../harness-broker/dist/paths.js
16631
- import os from "node:os";
16632
- import path from "node:path";
16633
- var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
16634
- var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
16635
- function defaultHarnessBrokerDirectory(environment = process.env) {
16636
- const home = environment.HOME || os.homedir();
16637
- return path.join(home, ".codexhost", "harness-broker");
16638
- }
16639
- function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
16640
- harnessPluginIdSchema.parse(harnessId);
16641
- if (harnessId !== "claude-code")
16642
- return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
16643
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
16644
- }
16645
- function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
16646
- harnessPluginIdSchema.parse(harnessId);
16647
- return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
16648
- }
16649
- function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
16650
- const home = environment.HOME || os.homedir();
16651
- return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
16652
- }
16653
-
16654
16633
  // ../../harness-broker/dist/validation.js
16655
16634
  var cwdSchema = external_exports.string().min(1).max(16384);
16656
16635
  var brokerEnvironmentSchema = external_exports.object({
@@ -16701,7 +16680,31 @@ var brokerOpenInputSchema = external_exports.discriminatedUnion("kind", [
16701
16680
  forkSchema,
16702
16681
  rollbackSchema
16703
16682
  ]);
16704
- var brokerInspectInputSchema = external_exports.object({ cwd: cwdSchema.optional(), refresh: external_exports.boolean().optional() }).strict();
16683
+ var brokerInspectInputSchema = external_exports.object({
16684
+ cwd: cwdSchema.optional(),
16685
+ refresh: external_exports.boolean().optional(),
16686
+ purpose: external_exports.literal("availability").optional()
16687
+ }).strict();
16688
+ var brokerSessionImportListParamsSchema = external_exports.object({
16689
+ offset: external_exports.number().int().nonnegative().safe(),
16690
+ limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
16691
+ }).strict();
16692
+ var brokerSessionImportResolveParamsSchema = external_exports.object({ nativeSessionId: harnessSessionImportIdSchema }).strict();
16693
+ var brokerSessionImportPageSchema = external_exports.object({
16694
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE),
16695
+ total: external_exports.number().int().nonnegative().safe()
16696
+ }).strict();
16697
+ var brokerSessionImportSourceSchema = external_exports.object({
16698
+ candidate: harnessSessionImportCandidateSchema,
16699
+ nativeRef: nativeSessionRefSchema
16700
+ }).strict().superRefine((source, context) => {
16701
+ if (source.nativeRef.nativeSessionId !== source.candidate.nativeSessionId) {
16702
+ context.addIssue({
16703
+ code: "custom",
16704
+ message: "Session import source identity does not match"
16705
+ });
16706
+ }
16707
+ });
16705
16708
  var textInputSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string().max(4e6) }).strict();
16706
16709
  var turnStartSchema = external_exports.object({
16707
16710
  type: external_exports.literal("turn.start"),
@@ -16872,6 +16875,107 @@ var harnessOutputSchema = external_exports.custom((value) => {
16872
16875
  return false;
16873
16876
  });
16874
16877
 
16878
+ // ../../harness-broker/dist/session-import-client.js
16879
+ function createBrokerSessionImportCapability(input) {
16880
+ let listing = null;
16881
+ const closed = () => ({
16882
+ ok: false,
16883
+ error: { code: "invalidState", message: "Harness broker adapter is closed", retryable: false }
16884
+ });
16885
+ const invalid = () => ({
16886
+ ok: false,
16887
+ error: {
16888
+ code: "protocolError",
16889
+ message: "Harness broker returned invalid Session import metadata",
16890
+ retryable: false
16891
+ }
16892
+ });
16893
+ const list = async () => {
16894
+ try {
16895
+ const candidates = [];
16896
+ const identities = /* @__PURE__ */ new Set();
16897
+ let total;
16898
+ for (; ; ) {
16899
+ if (input.isClosed())
16900
+ return closed();
16901
+ const result = await input.request("adapter.sessionImport.list", {
16902
+ offset: candidates.length,
16903
+ limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
16904
+ });
16905
+ if (input.isClosed())
16906
+ return closed();
16907
+ if (!result.ok)
16908
+ return result;
16909
+ const page = brokerSessionImportPageSchema.safeParse(result.value);
16910
+ 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)
16911
+ return invalid();
16912
+ total = page.data.total;
16913
+ for (const candidate of page.data.candidates) {
16914
+ if (identities.has(candidate.nativeSessionId))
16915
+ return invalid();
16916
+ identities.add(candidate.nativeSessionId);
16917
+ candidates.push(candidate);
16918
+ }
16919
+ if (candidates.length === total)
16920
+ return { ok: true, value: candidates };
16921
+ }
16922
+ } catch (error51) {
16923
+ return { ok: false, error: input.error(error51) };
16924
+ }
16925
+ };
16926
+ return {
16927
+ listCandidates() {
16928
+ if (input.isClosed())
16929
+ return Promise.resolve(closed());
16930
+ listing ??= list().finally(() => {
16931
+ listing = null;
16932
+ });
16933
+ return listing;
16934
+ },
16935
+ async resolveCandidate(nativeSessionId) {
16936
+ if (input.isClosed())
16937
+ return closed();
16938
+ try {
16939
+ const result = await input.request("adapter.sessionImport.resolve", { nativeSessionId });
16940
+ if (input.isClosed())
16941
+ return closed();
16942
+ if (!result.ok)
16943
+ return result;
16944
+ const source = brokerSessionImportSourceSchema.safeParse(result.value);
16945
+ if (!source.success || source.data.nativeRef.harnessId !== input.harnessId || source.data.candidate.nativeSessionId !== nativeSessionId)
16946
+ return invalid();
16947
+ return { ok: true, value: source.data };
16948
+ } catch (error51) {
16949
+ return { ok: false, error: input.error(error51) };
16950
+ }
16951
+ }
16952
+ };
16953
+ }
16954
+
16955
+ // ../../harness-broker/dist/paths.js
16956
+ import os from "node:os";
16957
+ import path from "node:path";
16958
+ var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
16959
+ var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
16960
+ function defaultHarnessBrokerDirectory(environment = process.env) {
16961
+ const home = environment.HOME || os.homedir();
16962
+ return path.join(home, ".codexhost", "harness-broker");
16963
+ }
16964
+ function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
16965
+ harnessPluginIdSchema.parse(harnessId);
16966
+ if (harnessId !== "claude-code")
16967
+ return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
16968
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
16969
+ }
16970
+ function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
16971
+ harnessPluginIdSchema.parse(harnessId);
16972
+ return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
16973
+ }
16974
+ function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
16975
+ const home = environment.HOME || os.homedir();
16976
+ return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
16977
+ }
16978
+
16875
16979
  // ../../harness-broker/dist/client.js
16876
16980
  function unavailable(message, retryable = true) {
16877
16981
  return { code: "unavailable", message, retryable, stage: "harnessBroker" };
@@ -17408,6 +17512,7 @@ var BrokeredHarnessAdapter = class {
17408
17512
  commandCatalog;
17409
17513
  liveCommandCatalog;
17410
17514
  harnessId;
17515
+ sessionImport;
17411
17516
  credits;
17412
17517
  refreshCredits;
17413
17518
  #descriptorPath;
@@ -17430,6 +17535,14 @@ var BrokeredHarnessAdapter = class {
17430
17535
  };
17431
17536
  constructor(input = {}) {
17432
17537
  this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
17538
+ if (input.sessionImport) {
17539
+ this.sessionImport = createBrokerSessionImportCapability({
17540
+ harnessId: this.harnessId,
17541
+ request: async (method, params) => parseHarnessResult(await this.#request(method, params, method === "adapter.sessionImport.resolve")),
17542
+ isClosed: () => this.#closed,
17543
+ error: (error51) => this.#error(error51)
17544
+ });
17545
+ }
17433
17546
  if (input.accountCredits !== false) {
17434
17547
  this.credits = () => this.#credits;
17435
17548
  this.refreshCredits = () => this.#refreshAccountCredits();
@@ -26977,6 +27090,7 @@ function createHarnessAdapter(context) {
26977
27090
  ...context.launchCommand ? { CODEXHOST_WORKBUDDY_COMMAND: context.launchCommand } : {}
26978
27091
  };
26979
27092
  return new BrokeredHarnessAdapter({
27093
+ sessionImport: true,
26980
27094
  accountCredits: false,
26981
27095
  harnessId: "workbuddy",
26982
27096
  commandCatalog: WORKBUDDY_COMMAND_CATALOG,
@@ -17400,6 +17400,8 @@ async function accountConfig(installation, environment) {
17400
17400
  states
17401
17401
  },
17402
17402
  startPlan,
17403
+ signedIn: Boolean(family),
17404
+ startPlanChecked: !family || balanceData !== void 0,
17403
17405
  codingPlan
17404
17406
  };
17405
17407
  }
@@ -17505,6 +17507,8 @@ var CliTransport = class {
17505
17507
  // Aborting these cancels only this transport's running and queued shared verifications.
17506
17508
  #headerRequests = /* @__PURE__ */ new Map();
17507
17509
  #startPlan = false;
17510
+ #signedIn = false;
17511
+ #startPlanChecked = true;
17508
17512
  #codingPlan;
17509
17513
  #fault;
17510
17514
  #closed = false;
@@ -17517,6 +17521,14 @@ var CliTransport = class {
17517
17521
  get startPlan() {
17518
17522
  return this.#startPlan;
17519
17523
  }
17524
+ /** Whether ZCode Desktop is signed in to a Zhipu account, whatever that account is entitled to. */
17525
+ get signedIn() {
17526
+ return this.#signedIn;
17527
+ }
17528
+ /** False when the Start Plan balance could not be read, so its entitlement is unknown. */
17529
+ get startPlanChecked() {
17530
+ return this.#startPlanChecked;
17531
+ }
17520
17532
  constructor(options) {
17521
17533
  this.options = options;
17522
17534
  this.#context = {
@@ -17528,9 +17540,11 @@ var CliTransport = class {
17528
17540
  if (this.#child || this.#closed)
17529
17541
  throw new ZcodeError("invalidState", "ZCode transport already started or closed");
17530
17542
  const installation = await resolveInstallation(this.options.environment, this.options.app);
17531
- const { params: accountParams, startPlan, codingPlan } = await accountConfig(installation, this.options.environment);
17543
+ const { params: accountParams, startPlan, signedIn, startPlanChecked, codingPlan } = await accountConfig(installation, this.options.environment);
17532
17544
  this.#installation = installation;
17533
17545
  this.#startPlan = startPlan;
17546
+ this.#signedIn = signedIn;
17547
+ this.#startPlanChecked = startPlanChecked;
17534
17548
  this.#codingPlan = codingPlan;
17535
17549
  const child = spawn(installation.runtime, [installation.cli, "app-server", "--stdio", "--surface", "desktop"], {
17536
17550
  cwd: this.options.cwd,
@@ -20232,9 +20246,20 @@ var ZcodeAdapter = class {
20232
20246
  if (!catalog.models.length)
20233
20247
  return {
20234
20248
  status: "unavailable",
20235
- error: {
20249
+ // A signed-in account without an active plan is not a login problem; only a signed-out
20250
+ // ZCode Desktop needs the login prompt.
20251
+ error: !transport.signedIn ? {
20236
20252
  code: "authenticationRequired",
20237
- 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.",
20253
+ 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.",
20254
+ retryable: true
20255
+ } : transport.startPlanChecked ? {
20256
+ code: "configurationRequired",
20257
+ 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.",
20258
+ retryable: true
20259
+ } : {
20260
+ // The balance request failed, so a valid Start Plan may just be unreadable now.
20261
+ code: "configurationRequired",
20262
+ 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.",
20238
20263
  retryable: true
20239
20264
  }
20240
20265
  };